diff --git a/README.md b/README.md index db9c9ef33..1db6a6e2e 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,10 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree | Create Subscription with ordering enabled | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithOrdering.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithOrdering.js,samples/README.md) | | Create Subscription With Retry Policy | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createSubscriptionWithRetryPolicy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createSubscriptionWithRetryPolicy.js,samples/README.md) | | Create Topic | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopic.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopic.js,samples/README.md) | +| Create Topic With AWS MSK Ingestion | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithAwsMskIngestion.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithAwsMskIngestion.js,samples/README.md) | +| Create Topic With Azure Event Hubs Ingestion | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithAzureEventHubsIngestion.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithAzureEventHubsIngestion.js,samples/README.md) | | Create Topic With Cloud Storage Ingestion | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithCloudStorageIngestion.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithCloudStorageIngestion.js,samples/README.md) | +| Create Topic With Confluent Cloud Ingestion | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithConfluentCloudIngestion.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithConfluentCloudIngestion.js,samples/README.md) | | Create Topic With Kinesis Ingestion | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithKinesisIngestion.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithKinesisIngestion.js,samples/README.md) | | Create Topic With Schema | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithSchema.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithSchema.js,samples/README.md) | | Create Topic With Schema Revisions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithSchemaRevisions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithSchemaRevisions.js,samples/README.md) | diff --git a/package.json b/package.json index a34cf91df..bec597e2c 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@google-cloud/paginator": "^5.0.0", "@google-cloud/precise-date": "^4.0.0", "@google-cloud/projectify": "^4.0.0", - "@google-cloud/promisify": "^4.0.0", + "@google-cloud/promisify": "~4.0.0", "@opentelemetry/api": "~1.9.0", "@opentelemetry/semantic-conventions": "~1.29.0", "arrify": "^2.0.0", diff --git a/samples/README.md b/samples/README.md index dc6caf537..7635d0758 100644 --- a/samples/README.md +++ b/samples/README.md @@ -35,7 +35,10 @@ guides. * [Create Subscription with ordering enabled](#create-subscription-with-ordering-enabled) * [Create Subscription With Retry Policy](#create-subscription-with-retry-policy) * [Create Topic](#create-topic) + * [Create Topic With AWS MSK Ingestion](#create-topic-with-aws-msk-ingestion) + * [Create Topic With Azure Event Hubs Ingestion](#create-topic-with-azure-event-hubs-ingestion) * [Create Topic With Cloud Storage Ingestion](#create-topic-with-cloud-storage-ingestion) + * [Create Topic With Confluent Cloud Ingestion](#create-topic-with-confluent-cloud-ingestion) * [Create Topic With Kinesis Ingestion](#create-topic-with-kinesis-ingestion) * [Create Topic With Schema](#create-topic-with-schema) * [Create Topic With Schema Revisions](#create-topic-with-schema-revisions) @@ -390,6 +393,44 @@ __Usage:__ +### Create Topic With AWS MSK Ingestion + +Creates a new topic, with AWS MSK ingestion enabled. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithAwsMskIngestion.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithAwsMskIngestion.js,samples/README.md) + +__Usage:__ + + +`node createTopicWithAwsMskIngestion.js ` + + +----- + + + + +### Create Topic With Azure Event Hubs Ingestion + +Creates a new topic, with Azure Event Hubs ingestion enabled. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithAzureEventHubsIngestion.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithAzureEventHubsIngestion.js,samples/README.md) + +__Usage:__ + + +`node createTopicWithAzureEventHubsIngestion.js ` + + +----- + + + + ### Create Topic With Cloud Storage Ingestion Creates a new topic, with Cloud Storage ingestion enabled. @@ -409,6 +450,25 @@ __Usage:__ +### Create Topic With Confluent Cloud Ingestion + +Creates a new topic, with Confluent Cloud ingestion enabled. + +View the [source code](https://github.com/googleapis/nodejs-pubsub/blob/main/samples/createTopicWithConfluentCloudIngestion.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/createTopicWithConfluentCloudIngestion.js,samples/README.md) + +__Usage:__ + + +`node createTopicWithConfluentCloudIngestion.js ` + + +----- + + + + ### Create Topic With Kinesis Ingestion Creates a new topic, with Kinesis ingestion enabled. diff --git a/src/publisher/index.ts b/src/publisher/index.ts index a4ab81fa6..01692a5a1 100644 --- a/src/publisher/index.ts +++ b/src/publisher/index.ts @@ -191,8 +191,10 @@ export class Publisher { // We must have at least one of: // - `data` as a Buffer // - `attributes` that are not empty - if (data && !(data instanceof Buffer)) { - throw new TypeError('Data must be in the form of a Buffer.'); + if (data && !(data instanceof Uint8Array)) { + throw new TypeError( + 'Data must be in the form of a Buffer or Uint8Array.' + ); } const keys = Object.keys(attributes!); diff --git a/test/publisher/index.ts b/test/publisher/index.ts index a4e6f28fb..9393b470f 100644 --- a/test/publisher/index.ts +++ b/test/publisher/index.ts @@ -237,7 +237,7 @@ describe('Publisher', () => { const badData = {} as Buffer; assert.throws( () => publisher.publishMessage({data: badData}, spy), - /Data must be in the form of a Buffer\./ + /Data must be in the form of a Buffer or Uint8Array\./ ); }); diff --git a/test/pubsub.ts b/test/pubsub.ts index d4ceef18b..d0dd97bcf 100644 --- a/test/pubsub.ts +++ b/test/pubsub.ts @@ -689,7 +689,10 @@ describe('PubSub', () => { const apiResponse = { name: 'new-topic', }; - let requestStub: sinon.SinonStub; + + // Types changed, so this is needed instead of `unknown`. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let requestStub: sinon.SinonStub; beforeEach(() => { requestStub = sandbox