Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
60 changes: 60 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <topic-name> <cluster-arn> <msk-topic> <role-arn> <gcp-service-account>`


-----




### 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 <topic-name> <cluster-arn> <msk-topic> <role-arn> <gcp-service-account>`


-----




### Create Topic With Cloud Storage Ingestion

Creates a new topic, with Cloud Storage ingestion enabled.
Expand All @@ -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 <topic-name> <bootstrap-server> <cluster-id> <confluent-topic> <identity-pool-id> <gcp-service-account>`


-----




### Create Topic With Kinesis Ingestion

Creates a new topic, with Kinesis ingestion enabled.
Expand Down
6 changes: 4 additions & 2 deletions src/publisher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand Down
2 changes: 1 addition & 1 deletion test/publisher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\./
);
});

Expand Down
5 changes: 4 additions & 1 deletion test/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,10 @@ describe('PubSub', () => {
const apiResponse = {
name: 'new-topic',
};
let requestStub: sinon.SinonStub<unknown[], unknown>;

// Types changed, so this is needed instead of `unknown`.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let requestStub: sinon.SinonStub<any[], any>;

beforeEach(() => {
requestStub = sandbox
Expand Down