From 624a745263c836c5ef367d6cca22c1bbb58af4b1 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Mon, 16 May 2022 23:45:55 -0700 Subject: [PATCH 01/10] feat!: Update library to use Node 12 --- .kokoro/continuous/node10/common.cfg | 34 ----------- .kokoro/continuous/node10/docs.cfg | 4 -- .kokoro/continuous/node10/test.cfg | 9 --- .kokoro/continuous/node8/common.cfg | 24 -------- .kokoro/continuous/node8/test.cfg | 0 .kokoro/presubmit/node10/common.cfg | 34 ----------- .kokoro/presubmit/node10/docs.cfg | 4 -- .kokoro/presubmit/node10/lint.cfg | 4 -- .kokoro/presubmit/node10/test.cfg | 0 .kokoro/presubmit/node8/common.cfg | 24 -------- .kokoro/presubmit/node8/test.cfg | 0 package.json | 12 ++-- protos/protos.d.ts | 68 ++++++++++++---------- protos/protos.js | 84 ++++++++++++++++++---------- protos/protos.json | 7 +++ samples/package.json | 2 +- 16 files changed, 104 insertions(+), 206 deletions(-) delete mode 100644 .kokoro/continuous/node10/common.cfg delete mode 100644 .kokoro/continuous/node10/docs.cfg delete mode 100644 .kokoro/continuous/node10/test.cfg delete mode 100644 .kokoro/continuous/node8/common.cfg delete mode 100644 .kokoro/continuous/node8/test.cfg delete mode 100644 .kokoro/presubmit/node10/common.cfg delete mode 100644 .kokoro/presubmit/node10/docs.cfg delete mode 100644 .kokoro/presubmit/node10/lint.cfg delete mode 100644 .kokoro/presubmit/node10/test.cfg delete mode 100644 .kokoro/presubmit/node8/common.cfg delete mode 100644 .kokoro/presubmit/node8/test.cfg diff --git a/.kokoro/continuous/node10/common.cfg b/.kokoro/continuous/node10/common.cfg deleted file mode 100644 index 894795cb4..000000000 --- a/.kokoro/continuous/node10/common.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "nodejs-pubsub/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node10/docs.cfg b/.kokoro/continuous/node10/docs.cfg deleted file mode 100644 index c8c5ddbe3..000000000 --- a/.kokoro/continuous/node10/docs.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/docs.sh" -} diff --git a/.kokoro/continuous/node10/test.cfg b/.kokoro/continuous/node10/test.cfg deleted file mode 100644 index 609c0cf0a..000000000 --- a/.kokoro/continuous/node10/test.cfg +++ /dev/null @@ -1,9 +0,0 @@ -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} diff --git a/.kokoro/continuous/node8/common.cfg b/.kokoro/continuous/node8/common.cfg deleted file mode 100644 index 623fa5f51..000000000 --- a/.kokoro/continuous/node8/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "nodejs-pubsub/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node8/test.cfg b/.kokoro/continuous/node8/test.cfg deleted file mode 100644 index e69de29bb..000000000 diff --git a/.kokoro/presubmit/node10/common.cfg b/.kokoro/presubmit/node10/common.cfg deleted file mode 100644 index 894795cb4..000000000 --- a/.kokoro/presubmit/node10/common.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Bring in codecov.io token into the build as $KOKORO_KEYSTORE_DIR/73713_dpebot_codecov_token -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "dpebot_codecov_token" - } - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "nodejs-pubsub/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:10-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node10/docs.cfg b/.kokoro/presubmit/node10/docs.cfg deleted file mode 100644 index c8c5ddbe3..000000000 --- a/.kokoro/presubmit/node10/docs.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/docs.sh" -} diff --git a/.kokoro/presubmit/node10/lint.cfg b/.kokoro/presubmit/node10/lint.cfg deleted file mode 100644 index 219d3808d..000000000 --- a/.kokoro/presubmit/node10/lint.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/lint.sh" -} diff --git a/.kokoro/presubmit/node10/test.cfg b/.kokoro/presubmit/node10/test.cfg deleted file mode 100644 index e69de29bb..000000000 diff --git a/.kokoro/presubmit/node8/common.cfg b/.kokoro/presubmit/node8/common.cfg deleted file mode 100644 index 623fa5f51..000000000 --- a/.kokoro/presubmit/node8/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "nodejs-pubsub/.kokoro/trampoline.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/nodejs-pubsub/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node8/test.cfg b/.kokoro/presubmit/node8/test.cfg deleted file mode 100644 index e69de29bb..000000000 diff --git a/package.json b/package.json index 8df7d1c88..e458284d4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "author": "Google Inc.", "engines": { - "node": ">=10" + "node": ">=12.0.0" }, "repository": "googleapis/nodejs-pubsub", "main": "./build/src/index.js", @@ -57,8 +57,8 @@ "@types/long": "^4.0.0", "arrify": "^2.0.0", "extend": "^3.0.2", - "google-auth-library": "^7.0.0", - "google-gax": "2.30.4", + "google-auth-library": "^8.0.2", + "google-gax": "^3.0.1", "is-stream-ended": "^0.1.4", "lodash.snakecase": "^4.1.1", "p-defer": "^3.0.0" @@ -80,12 +80,12 @@ "c8": "^7.0.0", "codecov": "^3.0.0", "execa": "^5.0.0", - "gts": "^2.0.0", + "gts": "^3.1.0", "jsdoc": "^3.6.2", "jsdoc-fresh": "^1.0.1", "jsdoc-region-tag": "^1.0.2", "linkinator": "^2.0.0", - "mocha": "^8.0.0", + "mocha": "^9.2.2", "mv": "^2.1.1", "ncp": "^2.0.0", "null-loader": "^4.0.0", @@ -94,7 +94,7 @@ "sinon": "^14.0.0", "tmp": "^0.2.0", "ts-loader": "^9.0.0", - "typescript": "^3.8.3", + "typescript": "^4.6.4", "uuid": "^8.0.0", "webpack": "^5.0.0", "webpack-cli": "^4.0.0", diff --git a/protos/protos.d.ts b/protos/protos.d.ts index 92e36484f..c98c45ac6 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -173,63 +173,63 @@ export namespace google { namespace Publisher { /** - * Callback as used by {@link google.pubsub.v1.Publisher#createTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|createTopic}. * @param error Error, if any * @param [response] Topic */ type CreateTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#updateTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|updateTopic}. * @param error Error, if any * @param [response] Topic */ type UpdateTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#publish}. + * Callback as used by {@link google.pubsub.v1.Publisher|publish}. * @param error Error, if any * @param [response] PublishResponse */ type PublishCallback = (error: (Error|null), response?: google.pubsub.v1.PublishResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#getTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|getTopic}. * @param error Error, if any * @param [response] Topic */ type GetTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopics}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopics}. * @param error Error, if any * @param [response] ListTopicsResponse */ type ListTopicsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSubscriptions}. * @param error Error, if any * @param [response] ListTopicSubscriptionsResponse */ type ListTopicSubscriptionsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicSubscriptionsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSnapshots}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSnapshots}. * @param error Error, if any * @param [response] ListTopicSnapshotsResponse */ type ListTopicSnapshotsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicSnapshotsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#deleteTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|deleteTopic}. * @param error Error, if any * @param [response] Empty */ type DeleteTopicCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher#detachSubscription}. + * Callback as used by {@link google.pubsub.v1.Publisher|detachSubscription}. * @param error Error, if any * @param [response] DetachSubscriptionResponse */ @@ -2140,112 +2140,112 @@ export namespace google { namespace Subscriber { /** - * Callback as used by {@link google.pubsub.v1.Subscriber#createSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|createSubscription}. * @param error Error, if any * @param [response] Subscription */ type CreateSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#getSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|getSubscription}. * @param error Error, if any * @param [response] Subscription */ type GetSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#updateSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|updateSubscription}. * @param error Error, if any * @param [response] Subscription */ type UpdateSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#listSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Subscriber|listSubscriptions}. * @param error Error, if any * @param [response] ListSubscriptionsResponse */ type ListSubscriptionsCallback = (error: (Error|null), response?: google.pubsub.v1.ListSubscriptionsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSubscription}. * @param error Error, if any * @param [response] Empty */ type DeleteSubscriptionCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#modifyAckDeadline}. + * Callback as used by {@link google.pubsub.v1.Subscriber|modifyAckDeadline}. * @param error Error, if any * @param [response] Empty */ type ModifyAckDeadlineCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#acknowledge}. + * Callback as used by {@link google.pubsub.v1.Subscriber|acknowledge}. * @param error Error, if any * @param [response] Empty */ type AcknowledgeCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#pull}. + * Callback as used by {@link google.pubsub.v1.Subscriber|pull}. * @param error Error, if any * @param [response] PullResponse */ type PullCallback = (error: (Error|null), response?: google.pubsub.v1.PullResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#streamingPull}. + * Callback as used by {@link google.pubsub.v1.Subscriber|streamingPull}. * @param error Error, if any * @param [response] StreamingPullResponse */ type StreamingPullCallback = (error: (Error|null), response?: google.pubsub.v1.StreamingPullResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#modifyPushConfig}. + * Callback as used by {@link google.pubsub.v1.Subscriber|modifyPushConfig}. * @param error Error, if any * @param [response] Empty */ type ModifyPushConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#getSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|getSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type GetSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#listSnapshots}. + * Callback as used by {@link google.pubsub.v1.Subscriber|listSnapshots}. * @param error Error, if any * @param [response] ListSnapshotsResponse */ type ListSnapshotsCallback = (error: (Error|null), response?: google.pubsub.v1.ListSnapshotsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#createSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|createSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type CreateSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#updateSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|updateSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type UpdateSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSnapshot}. * @param error Error, if any * @param [response] Empty */ type DeleteSnapshotCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#seek}. + * Callback as used by {@link google.pubsub.v1.Subscriber|seek}. * @param error Error, if any * @param [response] SeekResponse */ @@ -5492,42 +5492,42 @@ export namespace google { namespace SchemaService { /** - * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|createSchema}. * @param error Error, if any * @param [response] Schema */ type CreateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|getSchema}. * @param error Error, if any * @param [response] Schema */ type GetSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. + * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemas}. * @param error Error, if any * @param [response] ListSchemasResponse */ type ListSchemasCallback = (error: (Error|null), response?: google.pubsub.v1.ListSchemasResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. * @param error Error, if any * @param [response] Empty */ type DeleteSchemaCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|validateSchema}. * @param error Error, if any * @param [response] ValidateSchemaResponse */ type ValidateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.ValidateSchemaResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. + * Callback as used by {@link google.pubsub.v1.SchemaService|validateMessage}. * @param error Error, if any * @param [response] ValidateMessageResponse */ @@ -8982,6 +8982,9 @@ export namespace google { /** FieldOptions lazy */ lazy?: (boolean|null); + /** FieldOptions unverifiedLazy */ + unverifiedLazy?: (boolean|null); + /** FieldOptions deprecated */ deprecated?: (boolean|null); @@ -9019,6 +9022,9 @@ export namespace google { /** FieldOptions lazy. */ public lazy: boolean; + /** FieldOptions unverifiedLazy. */ + public unverifiedLazy: boolean; + /** FieldOptions deprecated. */ public deprecated: boolean; diff --git a/protos/protos.js b/protos/protos.js index e93dbbbd6..6b22eb407 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -90,7 +90,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.Publisher#createTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|createTopic}. * @memberof google.pubsub.v1.Publisher * @typedef CreateTopicCallback * @type {function} @@ -123,7 +123,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#updateTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|updateTopic}. * @memberof google.pubsub.v1.Publisher * @typedef UpdateTopicCallback * @type {function} @@ -156,7 +156,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#publish}. + * Callback as used by {@link google.pubsub.v1.Publisher|publish}. * @memberof google.pubsub.v1.Publisher * @typedef PublishCallback * @type {function} @@ -189,7 +189,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#getTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|getTopic}. * @memberof google.pubsub.v1.Publisher * @typedef GetTopicCallback * @type {function} @@ -222,7 +222,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopics}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopics}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicsCallback * @type {function} @@ -255,7 +255,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSubscriptions}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicSubscriptionsCallback * @type {function} @@ -288,7 +288,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSnapshots}. + * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSnapshots}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicSnapshotsCallback * @type {function} @@ -321,7 +321,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#deleteTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher|deleteTopic}. * @memberof google.pubsub.v1.Publisher * @typedef DeleteTopicCallback * @type {function} @@ -354,7 +354,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher#detachSubscription}. + * Callback as used by {@link google.pubsub.v1.Publisher|detachSubscription}. * @memberof google.pubsub.v1.Publisher * @typedef DetachSubscriptionCallback * @type {function} @@ -4304,7 +4304,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.Subscriber#createSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|createSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef CreateSubscriptionCallback * @type {function} @@ -4337,7 +4337,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#getSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|getSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef GetSubscriptionCallback * @type {function} @@ -4370,7 +4370,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#updateSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|updateSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef UpdateSubscriptionCallback * @type {function} @@ -4403,7 +4403,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#listSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Subscriber|listSubscriptions}. * @memberof google.pubsub.v1.Subscriber * @typedef ListSubscriptionsCallback * @type {function} @@ -4436,7 +4436,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef DeleteSubscriptionCallback * @type {function} @@ -4469,7 +4469,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#modifyAckDeadline}. + * Callback as used by {@link google.pubsub.v1.Subscriber|modifyAckDeadline}. * @memberof google.pubsub.v1.Subscriber * @typedef ModifyAckDeadlineCallback * @type {function} @@ -4502,7 +4502,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#acknowledge}. + * Callback as used by {@link google.pubsub.v1.Subscriber|acknowledge}. * @memberof google.pubsub.v1.Subscriber * @typedef AcknowledgeCallback * @type {function} @@ -4535,7 +4535,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#pull}. + * Callback as used by {@link google.pubsub.v1.Subscriber|pull}. * @memberof google.pubsub.v1.Subscriber * @typedef PullCallback * @type {function} @@ -4568,7 +4568,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#streamingPull}. + * Callback as used by {@link google.pubsub.v1.Subscriber|streamingPull}. * @memberof google.pubsub.v1.Subscriber * @typedef StreamingPullCallback * @type {function} @@ -4601,7 +4601,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#modifyPushConfig}. + * Callback as used by {@link google.pubsub.v1.Subscriber|modifyPushConfig}. * @memberof google.pubsub.v1.Subscriber * @typedef ModifyPushConfigCallback * @type {function} @@ -4634,7 +4634,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#getSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|getSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef GetSnapshotCallback * @type {function} @@ -4667,7 +4667,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#listSnapshots}. + * Callback as used by {@link google.pubsub.v1.Subscriber|listSnapshots}. * @memberof google.pubsub.v1.Subscriber * @typedef ListSnapshotsCallback * @type {function} @@ -4700,7 +4700,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#createSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|createSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef CreateSnapshotCallback * @type {function} @@ -4733,7 +4733,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#updateSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|updateSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef UpdateSnapshotCallback * @type {function} @@ -4766,7 +4766,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef DeleteSnapshotCallback * @type {function} @@ -4799,7 +4799,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber#seek}. + * Callback as used by {@link google.pubsub.v1.Subscriber|seek}. * @memberof google.pubsub.v1.Subscriber * @typedef SeekCallback * @type {function} @@ -12470,7 +12470,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|createSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef CreateSchemaCallback * @type {function} @@ -12503,7 +12503,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|getSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef GetSchemaCallback * @type {function} @@ -12536,7 +12536,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. + * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemas}. * @memberof google.pubsub.v1.SchemaService * @typedef ListSchemasCallback * @type {function} @@ -12569,7 +12569,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef DeleteSchemaCallback * @type {function} @@ -12602,7 +12602,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService|validateSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef ValidateSchemaCallback * @type {function} @@ -12635,7 +12635,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. + * Callback as used by {@link google.pubsub.v1.SchemaService|validateMessage}. * @memberof google.pubsub.v1.SchemaService * @typedef ValidateMessageCallback * @type {function} @@ -21801,6 +21801,7 @@ * @property {boolean|null} [packed] FieldOptions packed * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [unverifiedLazy] FieldOptions unverifiedLazy * @property {boolean|null} [deprecated] FieldOptions deprecated * @property {boolean|null} [weak] FieldOptions weak * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption @@ -21857,6 +21858,14 @@ */ FieldOptions.prototype.lazy = false; + /** + * FieldOptions unverifiedLazy. + * @member {boolean} unverifiedLazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.unverifiedLazy = false; + /** * FieldOptions deprecated. * @member {boolean} deprecated @@ -21933,6 +21942,8 @@ writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); + if (message.unverifiedLazy != null && Object.hasOwnProperty.call(message, "unverifiedLazy")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.unverifiedLazy); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -21990,6 +22001,9 @@ case 5: message.lazy = reader.bool(); break; + case 15: + message.unverifiedLazy = reader.bool(); + break; case 3: message.deprecated = reader.bool(); break; @@ -22073,6 +22087,9 @@ if (message.lazy != null && message.hasOwnProperty("lazy")) if (typeof message.lazy !== "boolean") return "lazy: boolean expected"; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + if (typeof message.unverifiedLazy !== "boolean") + return "unverifiedLazy: boolean expected"; if (message.deprecated != null && message.hasOwnProperty("deprecated")) if (typeof message.deprecated !== "boolean") return "deprecated: boolean expected"; @@ -22158,6 +22175,8 @@ } if (object.lazy != null) message.lazy = Boolean(object.lazy); + if (object.unverifiedLazy != null) + message.unverifiedLazy = Boolean(object.unverifiedLazy); if (object.deprecated != null) message.deprecated = Boolean(object.deprecated); if (object.weak != null) @@ -22245,6 +22264,7 @@ object.lazy = false; object.jstype = options.enums === String ? "JS_NORMAL" : 0; object.weak = false; + object.unverifiedLazy = false; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -22259,6 +22279,8 @@ object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; if (message.weak != null && message.hasOwnProperty("weak")) object.weak = message.weak; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + object.unverifiedLazy = message.unverifiedLazy; if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) diff --git a/protos/protos.json b/protos/protos.json index dc897e5af..bd2ed2b6e 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2534,6 +2534,13 @@ "default": false } }, + "unverifiedLazy": { + "type": "bool", + "id": 15, + "options": { + "default": false + } + }, "deprecated": { "type": "bool", "id": 3, diff --git a/samples/package.json b/samples/package.json index 6d4ad77f7..c16017ff9 100644 --- a/samples/package.json +++ b/samples/package.json @@ -9,7 +9,7 @@ "author": "Google Inc.", "repository": "googleapis/nodejs-pubsub", "engines": { - "node": ">=10" + "node": ">=12.0.0" }, "scripts": { "test": "mocha build/system-test --timeout 600000", From dbc3ae5a8216cf194017aee801a9e3f08ea2ab2f Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 17 May 2022 06:47:32 +0000 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .github/sync-repo-settings.yaml | 2 +- .github/workflows/ci.yaml | 2 +- protos/protos.d.ts | 68 ++++++++++++-------------- protos/protos.js | 84 ++++++++++++--------------------- protos/protos.json | 7 --- 5 files changed, 64 insertions(+), 99 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 1b3626833..d1e8b5e6e 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -9,9 +9,9 @@ branchProtectionRules: - "ci/kokoro: System test" - docs - lint - - test (10) - test (12) - test (14) + - test (16) - cla/google - windows - OwlBot Post Processor diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 25251dbb7..f447b84ab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [10, 12, 14] + node: [12, 14, 16] steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/protos/protos.d.ts b/protos/protos.d.ts index c98c45ac6..92e36484f 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -173,63 +173,63 @@ export namespace google { namespace Publisher { /** - * Callback as used by {@link google.pubsub.v1.Publisher|createTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#createTopic}. * @param error Error, if any * @param [response] Topic */ type CreateTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|updateTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#updateTopic}. * @param error Error, if any * @param [response] Topic */ type UpdateTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|publish}. + * Callback as used by {@link google.pubsub.v1.Publisher#publish}. * @param error Error, if any * @param [response] PublishResponse */ type PublishCallback = (error: (Error|null), response?: google.pubsub.v1.PublishResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|getTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#getTopic}. * @param error Error, if any * @param [response] Topic */ type GetTopicCallback = (error: (Error|null), response?: google.pubsub.v1.Topic) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopics}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopics}. * @param error Error, if any * @param [response] ListTopicsResponse */ type ListTopicsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSubscriptions}. * @param error Error, if any * @param [response] ListTopicSubscriptionsResponse */ type ListTopicSubscriptionsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicSubscriptionsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSnapshots}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSnapshots}. * @param error Error, if any * @param [response] ListTopicSnapshotsResponse */ type ListTopicSnapshotsCallback = (error: (Error|null), response?: google.pubsub.v1.ListTopicSnapshotsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|deleteTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#deleteTopic}. * @param error Error, if any * @param [response] Empty */ type DeleteTopicCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Publisher|detachSubscription}. + * Callback as used by {@link google.pubsub.v1.Publisher#detachSubscription}. * @param error Error, if any * @param [response] DetachSubscriptionResponse */ @@ -2140,112 +2140,112 @@ export namespace google { namespace Subscriber { /** - * Callback as used by {@link google.pubsub.v1.Subscriber|createSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#createSubscription}. * @param error Error, if any * @param [response] Subscription */ type CreateSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|getSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#getSubscription}. * @param error Error, if any * @param [response] Subscription */ type GetSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|updateSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#updateSubscription}. * @param error Error, if any * @param [response] Subscription */ type UpdateSubscriptionCallback = (error: (Error|null), response?: google.pubsub.v1.Subscription) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|listSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Subscriber#listSubscriptions}. * @param error Error, if any * @param [response] ListSubscriptionsResponse */ type ListSubscriptionsCallback = (error: (Error|null), response?: google.pubsub.v1.ListSubscriptionsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSubscription}. * @param error Error, if any * @param [response] Empty */ type DeleteSubscriptionCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|modifyAckDeadline}. + * Callback as used by {@link google.pubsub.v1.Subscriber#modifyAckDeadline}. * @param error Error, if any * @param [response] Empty */ type ModifyAckDeadlineCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|acknowledge}. + * Callback as used by {@link google.pubsub.v1.Subscriber#acknowledge}. * @param error Error, if any * @param [response] Empty */ type AcknowledgeCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|pull}. + * Callback as used by {@link google.pubsub.v1.Subscriber#pull}. * @param error Error, if any * @param [response] PullResponse */ type PullCallback = (error: (Error|null), response?: google.pubsub.v1.PullResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|streamingPull}. + * Callback as used by {@link google.pubsub.v1.Subscriber#streamingPull}. * @param error Error, if any * @param [response] StreamingPullResponse */ type StreamingPullCallback = (error: (Error|null), response?: google.pubsub.v1.StreamingPullResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|modifyPushConfig}. + * Callback as used by {@link google.pubsub.v1.Subscriber#modifyPushConfig}. * @param error Error, if any * @param [response] Empty */ type ModifyPushConfigCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|getSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#getSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type GetSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|listSnapshots}. + * Callback as used by {@link google.pubsub.v1.Subscriber#listSnapshots}. * @param error Error, if any * @param [response] ListSnapshotsResponse */ type ListSnapshotsCallback = (error: (Error|null), response?: google.pubsub.v1.ListSnapshotsResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|createSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#createSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type CreateSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|updateSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#updateSnapshot}. * @param error Error, if any * @param [response] Snapshot */ type UpdateSnapshotCallback = (error: (Error|null), response?: google.pubsub.v1.Snapshot) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSnapshot}. * @param error Error, if any * @param [response] Empty */ type DeleteSnapshotCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|seek}. + * Callback as used by {@link google.pubsub.v1.Subscriber#seek}. * @param error Error, if any * @param [response] SeekResponse */ @@ -5492,42 +5492,42 @@ export namespace google { namespace SchemaService { /** - * Callback as used by {@link google.pubsub.v1.SchemaService|createSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. * @param error Error, if any * @param [response] Schema */ type CreateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|getSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. * @param error Error, if any * @param [response] Schema */ type GetSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.Schema) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemas}. + * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. * @param error Error, if any * @param [response] ListSchemasResponse */ type ListSchemasCallback = (error: (Error|null), response?: google.pubsub.v1.ListSchemasResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. * @param error Error, if any * @param [response] Empty */ type DeleteSchemaCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|validateSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. * @param error Error, if any * @param [response] ValidateSchemaResponse */ type ValidateSchemaCallback = (error: (Error|null), response?: google.pubsub.v1.ValidateSchemaResponse) => void; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|validateMessage}. + * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. * @param error Error, if any * @param [response] ValidateMessageResponse */ @@ -8982,9 +8982,6 @@ export namespace google { /** FieldOptions lazy */ lazy?: (boolean|null); - /** FieldOptions unverifiedLazy */ - unverifiedLazy?: (boolean|null); - /** FieldOptions deprecated */ deprecated?: (boolean|null); @@ -9022,9 +9019,6 @@ export namespace google { /** FieldOptions lazy. */ public lazy: boolean; - /** FieldOptions unverifiedLazy. */ - public unverifiedLazy: boolean; - /** FieldOptions deprecated. */ public deprecated: boolean; diff --git a/protos/protos.js b/protos/protos.js index 6b22eb407..e93dbbbd6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -90,7 +90,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.Publisher|createTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#createTopic}. * @memberof google.pubsub.v1.Publisher * @typedef CreateTopicCallback * @type {function} @@ -123,7 +123,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|updateTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#updateTopic}. * @memberof google.pubsub.v1.Publisher * @typedef UpdateTopicCallback * @type {function} @@ -156,7 +156,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|publish}. + * Callback as used by {@link google.pubsub.v1.Publisher#publish}. * @memberof google.pubsub.v1.Publisher * @typedef PublishCallback * @type {function} @@ -189,7 +189,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|getTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#getTopic}. * @memberof google.pubsub.v1.Publisher * @typedef GetTopicCallback * @type {function} @@ -222,7 +222,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopics}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopics}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicsCallback * @type {function} @@ -255,7 +255,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSubscriptions}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicSubscriptionsCallback * @type {function} @@ -288,7 +288,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|listTopicSnapshots}. + * Callback as used by {@link google.pubsub.v1.Publisher#listTopicSnapshots}. * @memberof google.pubsub.v1.Publisher * @typedef ListTopicSnapshotsCallback * @type {function} @@ -321,7 +321,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|deleteTopic}. + * Callback as used by {@link google.pubsub.v1.Publisher#deleteTopic}. * @memberof google.pubsub.v1.Publisher * @typedef DeleteTopicCallback * @type {function} @@ -354,7 +354,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Publisher|detachSubscription}. + * Callback as used by {@link google.pubsub.v1.Publisher#detachSubscription}. * @memberof google.pubsub.v1.Publisher * @typedef DetachSubscriptionCallback * @type {function} @@ -4304,7 +4304,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.Subscriber|createSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#createSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef CreateSubscriptionCallback * @type {function} @@ -4337,7 +4337,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|getSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#getSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef GetSubscriptionCallback * @type {function} @@ -4370,7 +4370,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|updateSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#updateSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef UpdateSubscriptionCallback * @type {function} @@ -4403,7 +4403,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|listSubscriptions}. + * Callback as used by {@link google.pubsub.v1.Subscriber#listSubscriptions}. * @memberof google.pubsub.v1.Subscriber * @typedef ListSubscriptionsCallback * @type {function} @@ -4436,7 +4436,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSubscription}. + * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSubscription}. * @memberof google.pubsub.v1.Subscriber * @typedef DeleteSubscriptionCallback * @type {function} @@ -4469,7 +4469,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|modifyAckDeadline}. + * Callback as used by {@link google.pubsub.v1.Subscriber#modifyAckDeadline}. * @memberof google.pubsub.v1.Subscriber * @typedef ModifyAckDeadlineCallback * @type {function} @@ -4502,7 +4502,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|acknowledge}. + * Callback as used by {@link google.pubsub.v1.Subscriber#acknowledge}. * @memberof google.pubsub.v1.Subscriber * @typedef AcknowledgeCallback * @type {function} @@ -4535,7 +4535,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|pull}. + * Callback as used by {@link google.pubsub.v1.Subscriber#pull}. * @memberof google.pubsub.v1.Subscriber * @typedef PullCallback * @type {function} @@ -4568,7 +4568,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|streamingPull}. + * Callback as used by {@link google.pubsub.v1.Subscriber#streamingPull}. * @memberof google.pubsub.v1.Subscriber * @typedef StreamingPullCallback * @type {function} @@ -4601,7 +4601,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|modifyPushConfig}. + * Callback as used by {@link google.pubsub.v1.Subscriber#modifyPushConfig}. * @memberof google.pubsub.v1.Subscriber * @typedef ModifyPushConfigCallback * @type {function} @@ -4634,7 +4634,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|getSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#getSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef GetSnapshotCallback * @type {function} @@ -4667,7 +4667,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|listSnapshots}. + * Callback as used by {@link google.pubsub.v1.Subscriber#listSnapshots}. * @memberof google.pubsub.v1.Subscriber * @typedef ListSnapshotsCallback * @type {function} @@ -4700,7 +4700,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|createSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#createSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef CreateSnapshotCallback * @type {function} @@ -4733,7 +4733,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|updateSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#updateSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef UpdateSnapshotCallback * @type {function} @@ -4766,7 +4766,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|deleteSnapshot}. + * Callback as used by {@link google.pubsub.v1.Subscriber#deleteSnapshot}. * @memberof google.pubsub.v1.Subscriber * @typedef DeleteSnapshotCallback * @type {function} @@ -4799,7 +4799,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.Subscriber|seek}. + * Callback as used by {@link google.pubsub.v1.Subscriber#seek}. * @memberof google.pubsub.v1.Subscriber * @typedef SeekCallback * @type {function} @@ -12470,7 +12470,7 @@ }; /** - * Callback as used by {@link google.pubsub.v1.SchemaService|createSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#createSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef CreateSchemaCallback * @type {function} @@ -12503,7 +12503,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService|getSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#getSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef GetSchemaCallback * @type {function} @@ -12536,7 +12536,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService|listSchemas}. + * Callback as used by {@link google.pubsub.v1.SchemaService#listSchemas}. * @memberof google.pubsub.v1.SchemaService * @typedef ListSchemasCallback * @type {function} @@ -12569,7 +12569,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService|deleteSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#deleteSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef DeleteSchemaCallback * @type {function} @@ -12602,7 +12602,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService|validateSchema}. + * Callback as used by {@link google.pubsub.v1.SchemaService#validateSchema}. * @memberof google.pubsub.v1.SchemaService * @typedef ValidateSchemaCallback * @type {function} @@ -12635,7 +12635,7 @@ */ /** - * Callback as used by {@link google.pubsub.v1.SchemaService|validateMessage}. + * Callback as used by {@link google.pubsub.v1.SchemaService#validateMessage}. * @memberof google.pubsub.v1.SchemaService * @typedef ValidateMessageCallback * @type {function} @@ -21801,7 +21801,6 @@ * @property {boolean|null} [packed] FieldOptions packed * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype * @property {boolean|null} [lazy] FieldOptions lazy - * @property {boolean|null} [unverifiedLazy] FieldOptions unverifiedLazy * @property {boolean|null} [deprecated] FieldOptions deprecated * @property {boolean|null} [weak] FieldOptions weak * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption @@ -21858,14 +21857,6 @@ */ FieldOptions.prototype.lazy = false; - /** - * FieldOptions unverifiedLazy. - * @member {boolean} unverifiedLazy - * @memberof google.protobuf.FieldOptions - * @instance - */ - FieldOptions.prototype.unverifiedLazy = false; - /** * FieldOptions deprecated. * @member {boolean} deprecated @@ -21942,8 +21933,6 @@ writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); - if (message.unverifiedLazy != null && Object.hasOwnProperty.call(message, "unverifiedLazy")) - writer.uint32(/* id 15, wireType 0 =*/120).bool(message.unverifiedLazy); if (message.uninterpretedOption != null && message.uninterpretedOption.length) for (var i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -22001,9 +21990,6 @@ case 5: message.lazy = reader.bool(); break; - case 15: - message.unverifiedLazy = reader.bool(); - break; case 3: message.deprecated = reader.bool(); break; @@ -22087,9 +22073,6 @@ if (message.lazy != null && message.hasOwnProperty("lazy")) if (typeof message.lazy !== "boolean") return "lazy: boolean expected"; - if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) - if (typeof message.unverifiedLazy !== "boolean") - return "unverifiedLazy: boolean expected"; if (message.deprecated != null && message.hasOwnProperty("deprecated")) if (typeof message.deprecated !== "boolean") return "deprecated: boolean expected"; @@ -22175,8 +22158,6 @@ } if (object.lazy != null) message.lazy = Boolean(object.lazy); - if (object.unverifiedLazy != null) - message.unverifiedLazy = Boolean(object.unverifiedLazy); if (object.deprecated != null) message.deprecated = Boolean(object.deprecated); if (object.weak != null) @@ -22264,7 +22245,6 @@ object.lazy = false; object.jstype = options.enums === String ? "JS_NORMAL" : 0; object.weak = false; - object.unverifiedLazy = false; object[".google.api.resourceReference"] = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) @@ -22279,8 +22259,6 @@ object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; if (message.weak != null && message.hasOwnProperty("weak")) object.weak = message.weak; - if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) - object.unverifiedLazy = message.unverifiedLazy; if (message.uninterpretedOption && message.uninterpretedOption.length) { object.uninterpretedOption = []; for (var j = 0; j < message.uninterpretedOption.length; ++j) diff --git a/protos/protos.json b/protos/protos.json index bd2ed2b6e..dc897e5af 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -2534,13 +2534,6 @@ "default": false } }, - "unverifiedLazy": { - "type": "bool", - "id": 15, - "options": { - "default": false - } - }, "deprecated": { "type": "bool", "id": 3, From 6b554c289ab1c18a8cf0168b0e10f6076010d60d Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 10:12:49 -0700 Subject: [PATCH 03/10] run lint --- src/message-queues.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/message-queues.ts b/src/message-queues.ts index a46e71927..e8f431720 100644 --- a/src/message-queues.ts +++ b/src/message-queues.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import {CallOptions, grpc} from 'google-gax'; +import {CallOptions, grpc, ServiceError} from 'google-gax'; import defer = require('p-defer'); import {Message, Subscriber} from './subscriber'; @@ -214,7 +214,7 @@ export class AckQueue extends MessageQueue { try { await client.acknowledge(reqOpts, this._options.callOptions!); } catch (e) { - throw new BatchError(e, ackIds, 'acknowledge'); + throw new BatchError(e as ServiceError, ackIds, 'acknowledge'); } } } @@ -258,7 +258,7 @@ export class ModAckQueue extends MessageQueue { try { await client.modifyAckDeadline(reqOpts, this._options.callOptions!); } catch (e) { - throw new BatchError(e, ackIds, 'modifyAckDeadline'); + throw new BatchError(e as ServiceError, ackIds, 'modifyAckDeadline'); } }); From ec22ef3c459f7dea12e9f15aa3eeca98d2d6be13 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 12:08:02 -0700 Subject: [PATCH 04/10] run lint --- test/pubsub.ts | 241 +++++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 119 deletions(-) diff --git a/test/pubsub.ts b/test/pubsub.ts index d908973d5..fc3595234 100644 --- a/test/pubsub.ts +++ b/test/pubsub.ts @@ -29,7 +29,6 @@ import {Topic} from '../src/topic'; import * as util from '../src/util'; import {Schema, SchemaTypes} from '../src'; import {ISchema, SchemaViews} from '../src/schema'; - // eslint-disable-next-line @typescript-eslint/no-var-requires const PKG = require('../../package.json'); const sandbox = sinon.createSandbox(); @@ -150,7 +149,7 @@ describe('PubSub', () => { let PubSub: typeof pubsubTypes.PubSub; const PROJECT_ID = 'test-project'; - let pubsub: pubsubTypes.PubSub; + let pubsub: Partial; const OPTIONS = { projectId: PROJECT_ID, } as pubsubTypes.ClientConfig; @@ -272,7 +271,7 @@ describe('PubSub', () => { }); it('should not be in the opened state after close()', async () => { - await pubsub.close(); + await pubsub.close?.(); assert.strictEqual(pubsub.isOpen, false); }); @@ -340,13 +339,13 @@ describe('PubSub', () => { it('should throw if no Topic is provided', async () => { await assert.rejects(async () => { - await pubsub.createSubscription(undefined!, undefined!); + await pubsub.createSubscription?.(undefined!, undefined!); }, /A Topic is required for a new subscription\./); }); it('should throw if no subscription name is provided', async () => { await assert.rejects(async () => { - await pubsub.createSubscription(TOPIC_NAME, undefined!); + await pubsub.createSubscription?.(TOPIC_NAME, undefined!); }, /A subscription name is required./); }); @@ -355,7 +354,7 @@ describe('PubSub', () => { callback(null, apiResponse); }; - pubsub.createSubscription(TOPIC, SUB_NAME, done); + pubsub.createSubscription?.(TOPIC, SUB_NAME, done); }); it('should allow undefined/optional configuration options', done => { @@ -377,7 +376,7 @@ describe('PubSub', () => { setImmediate(done); return SUBSCRIPTION as subby.Subscription; }; - pubsub.createSubscription(TOPIC, SUB_NAME, opts, assert.ifError); + pubsub.createSubscription?.(TOPIC, SUB_NAME, opts, assert.ifError); }); it('should create a Topic object from a string', done => { @@ -389,7 +388,7 @@ describe('PubSub', () => { return TOPIC; }; - pubsub.createSubscription(TOPIC_NAME, SUB_NAME, assert.ifError); + pubsub.createSubscription?.(TOPIC_NAME, SUB_NAME, assert.ifError); }); it('should send correct request', done => { @@ -418,7 +417,7 @@ describe('PubSub', () => { done(); }; - pubsub.createSubscription(TOPIC, SUB_NAME, options, assert.ifError); + pubsub.createSubscription?.(TOPIC, SUB_NAME, options, assert.ifError); }); it('should pass options to the api request', done => { @@ -450,7 +449,7 @@ describe('PubSub', () => { done(); }; - pubsub.createSubscription(TOPIC, SUB_NAME, options, assert.ifError); + pubsub.createSubscription?.(TOPIC, SUB_NAME, options, assert.ifError); }); it('should discard flow control options', done => { @@ -481,7 +480,7 @@ describe('PubSub', () => { done(); }; - pubsub.createSubscription(TOPIC, SUB_NAME, options, assert.ifError); + pubsub.createSubscription?.(TOPIC, SUB_NAME, options, assert.ifError); }); it('should format the metadata', done => { @@ -500,7 +499,12 @@ describe('PubSub', () => { done(); }; - pubsub.createSubscription(TOPIC, SUB_NAME, fakeMetadata, assert.ifError); + pubsub.createSubscription?.( + TOPIC, + SUB_NAME, + fakeMetadata, + assert.ifError + ); }); describe('error', () => { @@ -529,7 +533,7 @@ describe('PubSub', () => { done(); } - pubsub.createSubscription(TOPIC_NAME, SUB_NAME, callback); + pubsub.createSubscription?.(TOPIC_NAME, SUB_NAME, callback); }); }); @@ -563,7 +567,7 @@ describe('PubSub', () => { done(); } - pubsub.createSubscription(TOPIC_NAME, SUB_NAME, callback); + pubsub.createSubscription?.(TOPIC_NAME, SUB_NAME, callback); }); }); }); @@ -605,7 +609,7 @@ describe('PubSub', () => { }); it('should return an error & API response', done => { - pubsub.createTopic('new-topic', (err, topic, apiResponse_) => { + pubsub.createTopic?.('new-topic', (err, topic, apiResponse_) => { assert.strictEqual(err, error); assert.strictEqual(topic, null); assert.strictEqual(apiResponse_, apiResponse); @@ -632,7 +636,7 @@ describe('PubSub', () => { return topicInstance as Topic; }; - pubsub.createTopic(topicName, (err, topic) => { + pubsub.createTopic?.(topicName, (err, topic) => { assert.ifError(err); assert.strictEqual(topic, topicInstance); done(); @@ -640,7 +644,7 @@ describe('PubSub', () => { }); it('should pass apiResponse to callback', done => { - pubsub.createTopic('new-topic', (err, topic, apiResponse_) => { + pubsub.createTopic?.('new-topic', (err, topic, apiResponse_) => { assert.ifError(err); assert.strictEqual(apiResponse_, apiResponse); done(); @@ -659,7 +663,7 @@ describe('PubSub', () => { it('should throw if no subscription name is provided', async () => { await assert.rejects(async () => { - await pubsub.detachSubscription(undefined!); + await pubsub.detachSubscription?.(undefined!); }, /A subscription name is required./); }); @@ -668,7 +672,7 @@ describe('PubSub', () => { .stub(pubsub, 'request') .callsArgOnWith(1, undefined, undefined, apiResponse); - pubsub.detachSubscription(SUB_NAME, (err, response) => { + pubsub.detachSubscription?.(SUB_NAME, (err, response) => { assert.strictEqual(response, apiResponse); done(); }); @@ -679,7 +683,7 @@ describe('PubSub', () => { .stub(pubsub, 'request') .callsArgOnWith(1, undefined, undefined, apiResponse); - pubsub.detachSubscription(SUB_NAME, undefined!, (_err, _response) => { + pubsub.detachSubscription?.(SUB_NAME, undefined!, (_err, _response) => { assert.strictEqual(_response, apiResponse); done(); }); @@ -692,7 +696,7 @@ describe('PubSub', () => { return SUBSCRIPTION as subby.Subscription; }); - await pubsub.detachSubscription(SUB_NAME); + await pubsub.detachSubscription?.(SUB_NAME); }); it('should send correct request', done => { @@ -713,7 +717,7 @@ describe('PubSub', () => { done(); }); - pubsub.detachSubscription(SUB_NAME, options, assert.ifError); + pubsub.detachSubscription?.(SUB_NAME, options, assert.ifError); }); it('should pass options to the api request', done => { @@ -732,7 +736,7 @@ describe('PubSub', () => { done(); }); - pubsub.detachSubscription(SUB_NAME, options, assert.ifError); + pubsub.detachSubscription?.(SUB_NAME, options, assert.ifError); }); }); @@ -755,10 +759,10 @@ describe('PubSub', () => { }); it('should do nothing if correct options are not set', () => { - pubsub.determineBaseUrl_(); + pubsub.determineBaseUrl_?.(); - assert.strictEqual(pubsub.options.servicePath, undefined); - assert.strictEqual(pubsub.options.port, undefined); + assert.strictEqual(pubsub.options?.servicePath, undefined); + assert.strictEqual(pubsub.options?.port, undefined); }); it('should use the apiEndpoint option', () => { @@ -766,10 +770,10 @@ describe('PubSub', () => { const testingUrl = 'localhost:8085'; setHost(defaultBaseUrl_); - pubsub.options.apiEndpoint = testingUrl; - pubsub.determineBaseUrl_(); + pubsub!.options!.apiEndpoint = testingUrl; + pubsub.determineBaseUrl_?.(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, 8085); assert.strictEqual(pubsub.options.sslCreds, fakeCreds); assert.strictEqual(pubsub.isEmulator, true); @@ -777,34 +781,34 @@ describe('PubSub', () => { it('should remove slashes from the baseUrl', () => { setHost('localhost:8080/'); - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, 8080); setHost('localhost:8081//'); - pubsub.determineBaseUrl_(); + pubsub.determineBaseUrl_?.(); assert.strictEqual(pubsub.options.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, 8081); }); it('should set the port to undefined if not set', () => { setHost('localhost'); - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, undefined); }); it('should set the port to 80 for http with no port specified', () => { setHost('http://localhost/'); - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); - assert.strictEqual(pubsub.options.port, 80); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); + assert.strictEqual(pubsub.options?.port, 80); }); it('should set the port to 443 for https with no port specified', () => { setHost('https://localhost/'); - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, 443); }); @@ -817,9 +821,9 @@ describe('PubSub', () => { }; setHost('localhost'); - pubsub.options.grpc = fakeGrpc as unknown as typeof gax.grpc; - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.sslCreds, fakeCredentials); + pubsub!.options!.grpc = fakeGrpc as unknown as typeof gax.grpc; + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.sslCreds, fakeCredentials); }); // This tests both the EMULATOR environment variable and detecting @@ -836,8 +840,8 @@ describe('PubSub', () => { }); it('should use the PUBSUB_EMULATOR_HOST env var', () => { - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, 'localhost'); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, 'localhost'); assert.strictEqual(pubsub.options.port, 9090); assert.strictEqual(pubsub.isEmulator, true); }); @@ -858,9 +862,9 @@ describe('PubSub', () => { }); it('should use the CLOUDSDK_API_ENDPOINT_OVERRIDES_PUBSUB env var', () => { - pubsub.determineBaseUrl_(); - assert.strictEqual(pubsub.options.servicePath, server); - assert.strictEqual(pubsub.options.port, 443); + pubsub.determineBaseUrl_?.(); + assert.strictEqual(pubsub.options?.servicePath, server); + assert.strictEqual(pubsub.options?.port, 443); assert.strictEqual(pubsub.isEmulator, false); assert.strictEqual(pubsub.options.sslCreds, undefined); }); @@ -878,11 +882,11 @@ describe('PubSub', () => { }); it('should accept a query and a callback', done => { - pubsub.getSnapshots({}, done); + pubsub.getSnapshots?.({}, done); }); it('should accept just a callback', done => { - pubsub.getSnapshots(done); + pubsub.getSnapshots?.(done); }); it('should build the right request', done => { @@ -917,7 +921,7 @@ describe('PubSub', () => { done(); }; - pubsub.getSnapshots(options, assert.ifError); + pubsub.getSnapshots?.(options, assert.ifError); }); it('should return Snapshot instances with metadata', done => { @@ -929,7 +933,7 @@ describe('PubSub', () => { }); // eslint-disable-next-line @typescript-eslint/no-explicit-any - pubsub.getSnapshots((err: any, snapshots: any) => { + pubsub.getSnapshots?.((err: any, snapshots: any) => { assert.ifError(err); assert.strictEqual(snapshots![0], snapshot); assert.strictEqual( @@ -951,7 +955,7 @@ describe('PubSub', () => { callback(err_, snapshots_, nextQuery_, apiResponse_); }; - pubsub.getSnapshots((err, snapshots, apiResponse) => { + pubsub.getSnapshots?.((err, snapshots, apiResponse) => { assert.strictEqual(err, err_); assert.deepStrictEqual(snapshots, snapshots_); assert.strictEqual(apiResponse, nextQuery_); @@ -970,11 +974,11 @@ describe('PubSub', () => { }); it('should accept a query and a callback', done => { - pubsub.getSubscriptions({}, done); + pubsub.getSubscriptions?.({}, done); }); it('should accept just a callback', done => { - pubsub.getSubscriptions(done); + pubsub.getSubscriptions?.(done); }); it('should pass the correct arguments to the API', done => { @@ -1002,7 +1006,7 @@ describe('PubSub', () => { done(); }; - pubsub.getSubscriptions(options, assert.ifError); + pubsub.getSubscriptions?.(options, assert.ifError); }); it('should pass options to API request', done => { @@ -1017,11 +1021,11 @@ describe('PubSub', () => { done(); }; - pubsub.getSubscriptions(opts, assert.ifError); + pubsub.getSubscriptions?.(opts, assert.ifError); }); it('should return Subscription instances', done => { - pubsub.getSubscriptions( + pubsub.getSubscriptions?.( ( err: gax.grpc.ServiceError | null, subscriptions?: subby.Subscription[] | null @@ -1043,7 +1047,7 @@ describe('PubSub', () => { callback(err_, subs_, nextQuery_, apiResponse_); }; - pubsub.getSubscriptions( + pubsub.getSubscriptions?.( ( err: gax.grpc.ServiceError | null, subs?: subby.Subscription[] | null, @@ -1072,7 +1076,7 @@ describe('PubSub', () => { done(); }; - pubsub.getSubscriptions(opts, assert.ifError); + pubsub.getSubscriptions?.(opts, assert.ifError); }); it('should create a topic instance from a name', done => { @@ -1092,7 +1096,7 @@ describe('PubSub', () => { return fakeTopic as Topic; }; - pubsub.getSubscriptions(opts, assert.ifError); + pubsub.getSubscriptions?.(opts, assert.ifError); }); }); }); @@ -1108,11 +1112,11 @@ describe('PubSub', () => { }); it('should accept a query and a callback', done => { - pubsub.getTopics({}, done); + pubsub.getTopics?.({}, done); }); it('should accept just a callback', done => { - pubsub.getTopics(done); + pubsub.getTopics?.(done); }); it('should build the right request', done => { @@ -1147,7 +1151,7 @@ describe('PubSub', () => { done(); }; - pubsub.getTopics(options, assert.ifError); + pubsub.getTopics?.(options, assert.ifError); }); it('should return Topic instances with metadata', done => { @@ -1159,7 +1163,7 @@ describe('PubSub', () => { }; // eslint-disable-next-line @typescript-eslint/no-explicit-any - pubsub.getTopics((err: any, topics: any) => { + pubsub.getTopics?.((err: any, topics: any) => { assert.ifError(err); assert.strictEqual(topics![0], topic); // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -1178,7 +1182,7 @@ describe('PubSub', () => { callback(err_, topics_, nextQuery_, apiResponse_); }; - pubsub.getTopics((err, topics, apiResponse) => { + pubsub.getTopics?.((err, topics, apiResponse) => { assert.strictEqual(err, err_); assert.deepStrictEqual(topics, topics_); assert.strictEqual(apiResponse, nextQuery_); @@ -1210,10 +1214,10 @@ describe('PubSub', () => { }); it('should throw if the PubSub is already closed', done => { - pubsub.close((err: Error | null) => { + pubsub.close?.((err: Error | null) => { assert.strictEqual(err, null); - pubsub.request(CONFIG, (errInner: Error | null) => { + pubsub.request?.(CONFIG, (errInner: Error | null) => { assert.notStrictEqual(errInner, null); assert.strictEqual( errInner!.message.indexOf('closed PubSub object') >= 0, @@ -1230,7 +1234,7 @@ describe('PubSub', () => { done(); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); it('should return error from getClient_', done => { @@ -1239,7 +1243,7 @@ describe('PubSub', () => { callback(expectedError); }; - pubsub.request(CONFIG, (err: gax.grpc.ServiceError | null) => { + pubsub.request?.(CONFIG, (err: gax.grpc.ServiceError | null) => { assert.strictEqual(expectedError, err); done(); }); @@ -1260,7 +1264,7 @@ describe('PubSub', () => { pubsub.getClient_ = (config, callback: Function) => { callback(null, fakeClient); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); it('should replace the project id token on reqOpts', done => { @@ -1270,12 +1274,11 @@ describe('PubSub', () => { assert.strictEqual(projectId, PROJECT_ID); done(); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); }); describe('getClientAsync_', () => { - // eslint-disable-next-line @typescript-eslint/class-name-casing const FAKE_CLIENT_INSTANCE = class { close() {} }; @@ -1293,11 +1296,11 @@ describe('PubSub', () => { describe('closeAllClients_', () => { it('should close out any open client', async () => { // Create a client that we'll close. - const client = await pubsub.getClientAsync_(CONFIG); + const client = await pubsub!.getClientAsync_!(CONFIG); // Stub out its close method, and verify it gets called. const stub = sandbox.stub(client, 'close').resolves(); - await pubsub.closeAllClients_(); + await pubsub.closeAllClients_?.(); assert.strictEqual(stub.called, true); }); @@ -1310,29 +1313,29 @@ describe('PubSub', () => { }); it('should get and cache the project ID', async () => { - sandbox.stub(pubsub.auth, 'getProjectId').resolves(PROJECT_ID); + sandbox.stub(pubsub!.auth!, 'getProjectId').resolves(PROJECT_ID); - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); assert.strictEqual(pubsub.projectId, PROJECT_ID); - assert.strictEqual(pubsub.options.projectId, PROJECT_ID); + assert.strictEqual(pubsub.options?.projectId, PROJECT_ID); }); it('should get the project ID if placeholder', async () => { pubsub.projectId = '{{projectId}}'; - sandbox.stub(pubsub.auth, 'getProjectId').resolves(PROJECT_ID); + sandbox.stub(pubsub!.auth!, 'getProjectId').resolves(PROJECT_ID); - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); assert.strictEqual(pubsub.projectId, PROJECT_ID); }); it('should return auth errors that occur', async () => { const error = new Error('err'); - sandbox.stub(pubsub.auth, 'getProjectId').rejects(error); + sandbox.stub(pubsub!.auth!, 'getProjectId').rejects(error); try { - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); throw new Error('getClientAsync_ should have thrown an error'); } catch (e) { assert.strictEqual(e, error); @@ -1343,9 +1346,9 @@ describe('PubSub', () => { pubsub.isEmulator = true; const error = new Error('err'); - sandbox.stub(pubsub.auth, 'getProjectId').rejects(error); + sandbox.stub(pubsub!.auth!, 'getProjectId').rejects(error); - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); assert.strictEqual(pubsub.projectId, ''); }); @@ -1353,14 +1356,14 @@ describe('PubSub', () => { pubsub.projectId = PROJECT_ID; const error = new Error('getProjectId should not be called.'); - sandbox.stub(pubsub.auth, 'getProjectId').rejects(error); + sandbox.stub(pubsub!.auth!, 'getProjectId').rejects(error); - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); }); }); it('should cache the client', async () => { - delete pubsub.api.fakeClient; + delete pubsub.api?.fakeClient; let numTimesFakeClientInstantiated = 0; @@ -1370,10 +1373,10 @@ describe('PubSub', () => { return FAKE_CLIENT_INSTANCE; }; - await pubsub.getClientAsync_(CONFIG); - assert.strictEqual(pubsub.api.FakeClient, FAKE_CLIENT_INSTANCE); + await pubsub.getClientAsync_?.(CONFIG); + assert.strictEqual(pubsub.api?.FakeClient, FAKE_CLIENT_INSTANCE); - await pubsub.getClientAsync_(CONFIG); + await pubsub.getClientAsync_?.(CONFIG); assert.strictEqual(numTimesFakeClientInstantiated, 1); }); @@ -1386,7 +1389,7 @@ describe('PubSub', () => { return FAKE_CLIENT_INSTANCE; }; - const client = await pubsub.getClientAsync_(CONFIG); + const client = await pubsub.getClientAsync_?.(CONFIG); assert.strictEqual(client, FAKE_CLIENT_INSTANCE); }); }); @@ -1403,7 +1406,7 @@ describe('PubSub', () => { .withArgs(CONFIG) .resolves(FAKE_CLIENT_INSTANCE); - pubsub.getClient_(CONFIG, (err, client) => { + pubsub.getClient_?.(CONFIG, (err, client) => { assert.ifError(err); assert.strictEqual(client, FAKE_CLIENT_INSTANCE); done(); @@ -1414,7 +1417,7 @@ describe('PubSub', () => { const error = new Error('err'); sandbox.stub(pubsub, 'getClientAsync_').rejects(error); - pubsub.getClient_(CONFIG, err => { + pubsub.getClient_?.(CONFIG, err => { assert.strictEqual(err, error); done(); }); @@ -1450,7 +1453,7 @@ describe('PubSub', () => { done(); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); it('should return error from getting the client', done => { @@ -1460,7 +1463,7 @@ describe('PubSub', () => { callback(error); }; - pubsub.request(CONFIG, (err: gax.ServiceError | null) => { + pubsub.request?.(CONFIG, (err: gax.ServiceError | null) => { assert.strictEqual(err, error); done(); }); @@ -1474,7 +1477,7 @@ describe('PubSub', () => { done(); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); it('should call the client method correctly', done => { @@ -1504,7 +1507,7 @@ describe('PubSub', () => { callback(null, fakeClient); }; - pubsub.request(CONFIG, assert.ifError); + pubsub.request?.(CONFIG, assert.ifError); }); }); @@ -1518,7 +1521,7 @@ describe('PubSub', () => { it('should return a Snapshot object', () => { const SNAPSHOT_NAME = 'new-snapshot'; - const snapshot = pubsub.snapshot(SNAPSHOT_NAME); + const snapshot = pubsub.snapshot?.(SNAPSHOT_NAME); const args = (snapshot as {} as FakeSnapshot).calledWith_; assert(snapshot instanceof FakeSnapshot); @@ -1534,7 +1537,7 @@ describe('PubSub', () => { it('should return a Subscription object', () => { // tslint:disable-next-line only-arrow-functions subscriptionOverride = function () {}; - const subscription = pubsub.subscription(SUB_NAME, {}); + const subscription = pubsub.subscription?.(SUB_NAME, {}); assert(subscription instanceof subscriptionOverride); }); @@ -1547,7 +1550,7 @@ describe('PubSub', () => { assert.strictEqual(name, SUB_NAME); done(); }; - pubsub.subscription(SUB_NAME); + pubsub.subscription?.(SUB_NAME); }); it('should honor settings', done => { @@ -1560,7 +1563,7 @@ describe('PubSub', () => { assert.strictEqual(options, CONFIG); done(); }; - pubsub.subscription(SUB_NAME, CONFIG); + pubsub.subscription?.(SUB_NAME, CONFIG); }); it('should throw if a name is not provided', () => { @@ -1580,13 +1583,13 @@ describe('PubSub', () => { }); it('should return a Topic object', () => { - assert(pubsub.topic('new-topic') instanceof FakeTopic); + assert(pubsub.topic?.('new-topic') instanceof FakeTopic); }); it('should pass the correct args', () => { const fakeName = 'with-options'; const fakeOptions = {}; - const topic = pubsub.topic(fakeName, fakeOptions); + const topic = pubsub.topic?.(fakeName, fakeOptions); const [ps, name, options] = (topic as {} as FakeTopic).calledWith_; @@ -1605,9 +1608,9 @@ describe('PubSub', () => { it('should close the schema client when it has been opened', async () => { // Force it to create a client. - const client = await pubsub.getSchemaClient_(); - sandbox.stub(client, 'close').resolves(); - await pubsub.close(); + const client = await pubsub.getSchemaClient_?.(); + sandbox.stub(client!, 'close').resolves(); + await pubsub.close?.(); }); // I feel like this ought to be a test, but something in getSchemaClient_() @@ -1623,10 +1626,10 @@ describe('PubSub', () => { const schemaId = 'id'; const type = SchemaTypes.Avro; const definition = 'def'; - const name = Schema.formatName_(pubsub.projectId, schemaId); + const name = Schema.formatName_(pubsub.projectId!, schemaId); // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_(); + const client = await pubsub.getSchemaClient_!(); const def = defer(); sandbox.stub(client, 'createSchema').callsFake(req => { assert.strictEqual(req.parent, pubsub.name); @@ -1637,7 +1640,7 @@ describe('PubSub', () => { def.resolve(); }); const result = await Promise.all([ - pubsub.createSchema(schemaId, type, definition), + pubsub.createSchema!(schemaId, type, definition), def, ]); assert.strictEqual(result[0].id, schemaId); @@ -1645,7 +1648,7 @@ describe('PubSub', () => { it('calls down to listSchemas correctly', async () => { // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_(); + const client = await pubsub.getSchemaClient_!(); sandbox.stub(client, 'listSchemasAsync').callsFake((req, gaxOpts) => { assert.strictEqual(req!.parent, pubsub.name); @@ -1663,7 +1666,7 @@ describe('PubSub', () => { }); const ids = [] as string[]; - for await (const s of pubsub.listSchemas(SchemaViews.Basic, {})) { + for await (const s of pubsub.listSchemas!(SchemaViews.Basic, {})) { ids.push(s.name!); } @@ -1673,30 +1676,30 @@ describe('PubSub', () => { it('defaults to BASIC for listSchemas', async () => { // Grab the schema client it'll be using so we can stub it. - const client = await pubsub.getSchemaClient_(); + const client = await pubsub.getSchemaClient_?.(); - sandbox.stub(client, 'listSchemasAsync').callsFake(req => { + sandbox.stub(client!, 'listSchemasAsync').callsFake(req => { assert.strictEqual(req!.view, 'BASIC'); // eslint-disable-next-line @typescript-eslint/no-explicit-any return toAsync([]) as any; }); // eslint-disable-next-line @typescript-eslint/no-unused-vars - for await (const s of pubsub.listSchemas()) { + for await (const s of pubsub.listSchemas!()) { break; } }); it('returns a proper Schema object from schema()', async () => { - const schema = pubsub.schema('foo'); - assert.strictEqual(schema.id, 'foo'); + const schema = pubsub.schema?.('foo'); + assert.strictEqual(schema!.id, 'foo'); - const name = await schema.getName(); - assert.strictEqual(name, Schema.formatName_(pubsub.projectId, 'foo')); + const name = await schema!.getName(); + assert.strictEqual(name, Schema.formatName_(pubsub!.projectId!, 'foo')); }); it('calls validateSchema() on the client when validateSchema() is called', async () => { - const client = await pubsub.getSchemaClient_(); + const client = await pubsub.getSchemaClient_!(); const ischema: ISchema = { name: 'test', type: SchemaTypes.Avro, @@ -1713,7 +1716,7 @@ describe('PubSub', () => { called = true; }); - await pubsub.validateSchema(ischema, {}); + await pubsub.validateSchema!(ischema, {}); assert.ok(called); }); }); From 9b881415ed5785b75481e03098c2703edc19ed04 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 13:13:21 -0700 Subject: [PATCH 05/10] fix linting --- test/subscription.ts | 115 ++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/test/subscription.ts b/test/subscription.ts index a5699b8a1..e436ceea8 100644 --- a/test/subscription.ts +++ b/test/subscription.ts @@ -95,7 +95,7 @@ class FakeSubscriber extends EventEmitter { describe('Subscription', () => { // tslint:disable-next-line variable-name let Subscription: typeof subby.Subscription; - let subscription: subby.Subscription; + let subscription: Partial; const PROJECT_ID = 'test-project'; const SUB_NAME = 'test-subscription'; @@ -183,7 +183,7 @@ describe('Subscription', () => { it('should open the subscriber when a listener is attached', () => { const stub = sandbox.stub(subscriber, 'open'); - subscription.on('message', () => {}); + subscription.on?.('message', () => {}); assert.strictEqual(stub.callCount, 1); }); @@ -191,8 +191,8 @@ describe('Subscription', () => { const stub = sandbox.stub(subscriber, 'close'); const cb = () => {}; - subscription.on('message', cb); - subscription.removeListener('message', cb); + subscription.on?.('message', cb); + subscription.removeListener?.('message', cb); assert.strictEqual(stub.callCount, 1); }); @@ -200,7 +200,7 @@ describe('Subscription', () => { it('should emit messages', done => { const message = {}; - subscription.on('message', (msg: Message) => { + subscription.on?.('message', (msg: Message) => { assert.strictEqual(msg, message); done(); }); @@ -211,7 +211,7 @@ describe('Subscription', () => { it('should emit errors', done => { const error = new Error('err'); - subscription.on('error', (err: Error) => { + subscription.on?.('error', (err: Error) => { assert.strictEqual(err, error); done(); }); @@ -220,7 +220,7 @@ describe('Subscription', () => { }); it('should emit close events', done => { - subscription.on('close', done); + subscription.on?.('close', done); subscriber.emit('close'); }); }); @@ -330,7 +330,7 @@ describe('Subscription', () => { describe('close', () => { it('should call the success callback', done => { sandbox.stub(subscriber, 'close').resolves(); - subscription.close(done); + subscription.close?.(done); }); it('should pass back any errors that occurs', done => { @@ -338,10 +338,11 @@ describe('Subscription', () => { sandbox.stub(subscriber, 'close').rejects(fakeErr); - subscription.close(err => { - assert.strictEqual(err, fakeErr); - done(); - }); + subscription.close?.(), + (err: Error) => { + assert.strictEqual(err, fakeErr); + done(); + }; }); }); @@ -356,14 +357,14 @@ describe('Subscription', () => { const expectedError = /Subscriptions can only be created when accessed through Topics/; delete subscription.topic; - await assert.rejects(subscription.create(), expectedError); + await assert.rejects(subscription.create!(), expectedError); }); it('should pass the correct params', () => { const fakeOptions = {}; const stub = sandbox.stub(PUBSUB, 'createSubscription'); - subscription.create(fakeOptions, assert.ifError); + subscription.create?.(fakeOptions, assert.ifError); const [topic, name, options] = stub.lastCall.args; assert.strictEqual(topic, TOPIC_NAME); @@ -374,7 +375,7 @@ describe('Subscription', () => { it('should optionally accept options', () => { const stub = sandbox.stub(PUBSUB, 'createSubscription'); - subscription.create(assert.ifError); + subscription.create?.(assert.ifError); const options = stub.lastCall.args[2]; assert.deepStrictEqual(options, {}); @@ -385,7 +386,7 @@ describe('Subscription', () => { const fakeResponse = {}; const stub = sandbox.stub(PUBSUB, 'createSubscription'); - subscription.create((err, sub, resp) => { + subscription.create?.((err, sub, resp) => { assert.strictEqual(err, fakeErr); assert.strictEqual(sub, null); assert.strictEqual(resp, fakeResponse); @@ -401,7 +402,7 @@ describe('Subscription', () => { const fakeSub = new Subscription(PUBSUB, SUB_FULL_NAME); const fakeResponse = {}; - subscription.create(err => { + subscription.create?.(err => { assert.ifError(err); assert.strictEqual(subscription.metadata, fakeResponse); done(); @@ -416,7 +417,7 @@ describe('Subscription', () => { const fakeResponse = {}; const stub = sandbox.stub(PUBSUB, 'createSubscription'); - subscription.create((err, sub, resp) => { + subscription.create?.((err, sub, resp) => { assert.ifError(err); assert.strictEqual(sub, subscription); assert.strictEqual(resp, fakeResponse); @@ -457,7 +458,7 @@ describe('Subscription', () => { done(); }; - subscription.createSnapshot(SNAPSHOT_NAME, assert.ifError); + subscription.createSnapshot?.(SNAPSHOT_NAME, assert.ifError); }); it('should optionally accept gax options', done => { @@ -468,7 +469,7 @@ describe('Subscription', () => { done(); }; - subscription.createSnapshot(SNAPSHOT_NAME, gaxOpts, assert.ifError); + subscription.createSnapshot?.(SNAPSHOT_NAME, gaxOpts, assert.ifError); }); it('should pass back any errors to the callback', done => { @@ -479,7 +480,7 @@ describe('Subscription', () => { callback(error, apiResponse); }; - subscription.createSnapshot(SNAPSHOT_NAME, (err, snapshot, resp) => { + subscription.createSnapshot?.(SNAPSHOT_NAME, (err, snapshot, resp) => { assert.strictEqual(err, error); assert.strictEqual(snapshot, null); assert.strictEqual(resp, apiResponse); @@ -499,7 +500,7 @@ describe('Subscription', () => { callback(null, apiResponse); }; - subscription.createSnapshot(SNAPSHOT_NAME, (err, snapshot, resp) => { + subscription.createSnapshot?.(SNAPSHOT_NAME, (err, snapshot, resp) => { assert.ifError(err); assert.strictEqual(snapshot, fakeSnapshot); assert.strictEqual(snapshot!.metadata, apiResponse); @@ -519,7 +520,7 @@ describe('Subscription', () => { }); it('should return the debug events to the callback', done => { - subscription.on('debug', err => { + subscription.on?.('debug', err => { assert.strictEqual(err, error); done(); }); @@ -544,7 +545,7 @@ describe('Subscription', () => { done(); }; - subscription.delete(assert.ifError); + subscription.delete?.(assert.ifError); }); it('should optionally accept gax options', done => { @@ -555,7 +556,7 @@ describe('Subscription', () => { done(); }; - subscription.delete(gaxOpts, assert.ifError); + subscription.delete?.(gaxOpts, assert.ifError); }); describe('success', () => { @@ -568,7 +569,7 @@ describe('Subscription', () => { }); it('should return the api response', done => { - subscription.delete((err, resp) => { + subscription.delete?.((err, resp) => { assert.ifError(err); assert.strictEqual(resp, apiResponse); done(); @@ -578,9 +579,9 @@ describe('Subscription', () => { it('should close the subscriber if open', done => { const stub = sandbox.stub(subscriber, 'close'); - subscription.open(); + subscription.open?.(); - subscription.delete(err => { + subscription.delete?.(err => { assert.ifError(err); assert.strictEqual(stub.callCount, 1); done(); @@ -598,7 +599,7 @@ describe('Subscription', () => { }); it('should return the error to the callback', done => { - subscription.delete(err => { + subscription.delete?.(err => { assert.strictEqual(err, error); done(); }); @@ -610,7 +611,7 @@ describe('Subscription', () => { done(new Error('Should not be called.')); }; - subscription.delete(() => { + subscription.delete?.(() => { done(); }); }); @@ -620,7 +621,7 @@ describe('Subscription', () => { done(new Error('Should not be called.')); }; - subscription.delete(() => { + subscription.delete?.(() => { done(); }); }); @@ -631,7 +632,7 @@ describe('Subscription', () => { it('should return true if it finds metadata', done => { sandbox.stub(subscription, 'getMetadata').yields(null, {}); - subscription.exists((err, exists) => { + subscription.exists?.((err, exists) => { assert.ifError(err); assert(exists); done(); @@ -642,7 +643,7 @@ describe('Subscription', () => { const error = {code: 5} as ServiceError; sandbox.stub(subscription, 'getMetadata').yields(error); - subscription.exists((err, exists) => { + subscription.exists?.((err, exists) => { assert.ifError(err); assert.strictEqual(exists, false); done(); @@ -653,7 +654,7 @@ describe('Subscription', () => { const error = {code: 4} as ServiceError; sandbox.stub(subscription, 'getMetadata').yields(error); - subscription.exists((err, exists) => { + subscription.exists?.((err, exists) => { assert.strictEqual(err, error); assert.strictEqual(exists, undefined); done(); @@ -674,7 +675,7 @@ describe('Subscription', () => { done(); }); - subscription.get(options, assert.ifError); + subscription.get?.(options, assert.ifError); }); describe('success', () => { @@ -687,7 +688,7 @@ describe('Subscription', () => { callback(null, fakeMetadata); }); - subscription.get((err, sub, resp) => { + subscription.get?.((err, sub, resp) => { assert.ifError(err); assert.strictEqual(sub, subscription); assert.strictEqual(resp, fakeMetadata); @@ -704,7 +705,7 @@ describe('Subscription', () => { callback(null); // the done fn }); - subscription.get(options, done); + subscription.get?.(options, done); }); }); @@ -716,7 +717,7 @@ describe('Subscription', () => { .stub(subscription, 'getMetadata') .callsArgWith(1, error, apiResponse); - subscription.get((err, sub, resp) => { + subscription.get?.((err, sub, resp) => { assert.strictEqual(err, error); assert.strictEqual(sub, null); assert.strictEqual(resp, apiResponse); @@ -731,7 +732,7 @@ describe('Subscription', () => { .stub(subscription, 'getMetadata') .callsArgWith(1, error, apiResponse); - subscription.get((err, sub, resp) => { + subscription.get?.((err, sub, resp) => { assert.strictEqual(err, error); assert.strictEqual(sub, null); assert.strictEqual(resp, apiResponse); @@ -748,7 +749,7 @@ describe('Subscription', () => { delete subscription.create; - subscription.get((err, sub, resp) => { + subscription.get?.((err, sub, resp) => { assert.strictEqual(err, error); assert.strictEqual(sub, null); assert.strictEqual(resp, apiResponse); @@ -773,7 +774,7 @@ describe('Subscription', () => { }); subscription.topic = 'hi-ho-silver'; - subscription.get(fakeOptions, assert.ifError); + subscription.get?.(fakeOptions, assert.ifError); }); }); }); @@ -789,7 +790,7 @@ describe('Subscription', () => { done(); }; - subscription.getMetadata(assert.ifError); + subscription.getMetadata?.(assert.ifError); }); it('should optionally accept gax options', done => { @@ -800,7 +801,7 @@ describe('Subscription', () => { done(); }; - subscription.getMetadata(gaxOpts, assert.ifError); + subscription.getMetadata?.(gaxOpts, assert.ifError); }); it('should pass back any errors that occur', done => { @@ -811,7 +812,7 @@ describe('Subscription', () => { callback(error, apiResponse); }; - subscription.getMetadata((err, metadata) => { + subscription.getMetadata?.((err, metadata) => { assert.strictEqual(err, error); assert.strictEqual(metadata, apiResponse); done(); @@ -825,7 +826,7 @@ describe('Subscription', () => { callback(null, apiResponse); }; - subscription.getMetadata((err, metadata) => { + subscription.getMetadata?.((err, metadata) => { assert.ifError(err); assert.strictEqual(metadata, apiResponse); assert.strictEqual(subscription.metadata, apiResponse); @@ -848,7 +849,7 @@ describe('Subscription', () => { done(); }; - subscription.modifyPushConfig(fakeConfig, assert.ifError); + subscription.modifyPushConfig?.(fakeConfig, assert.ifError); }); it('should optionally accept gaxOpts', done => { @@ -859,7 +860,7 @@ describe('Subscription', () => { done(); }; - subscription.modifyPushConfig(fakeConfig, gaxOpts, assert.ifError); + subscription.modifyPushConfig?.(fakeConfig, gaxOpts, assert.ifError); }); }); @@ -867,7 +868,7 @@ describe('Subscription', () => { it('should open the subscriber', () => { const stub = sandbox.stub(subscriber, 'open'); - subscription.open(); + subscription.open?.(); assert.strictEqual(stub.callCount, 1); }); @@ -875,8 +876,8 @@ describe('Subscription', () => { it('should noop if already open', () => { const spy = sandbox.spy(subscriber, 'open'); - subscription.open(); - subscription.open(); + subscription.open?.(); + subscription.open?.(); assert.strictEqual(spy.callCount, 1); }); @@ -916,7 +917,7 @@ describe('Subscription', () => { done(); }; - subscription.seek(FAKE_SNAPSHOT_NAME, assert.ifError); + subscription.seek?.(FAKE_SNAPSHOT_NAME, assert.ifError); }); it('should optionally accept a Date object', done => { @@ -933,7 +934,7 @@ describe('Subscription', () => { done(); }; - subscription.seek(date, assert.ifError); + subscription.seek?.(date, assert.ifError); }); it('should optionally accept gax options', done => { @@ -944,7 +945,7 @@ describe('Subscription', () => { done(); }; - subscription.seek(FAKE_SNAPSHOT_NAME, gaxOpts, assert.ifError); + subscription.seek?.(FAKE_SNAPSHOT_NAME, gaxOpts, assert.ifError); }); }); @@ -995,7 +996,7 @@ describe('Subscription', () => { done(); }; - subscription.setMetadata(METADATA, done); + subscription.setMetadata?.(METADATA, done); }); it('should optionally accept gax options', done => { @@ -1005,7 +1006,7 @@ describe('Subscription', () => { assert.strictEqual(config.gaxOpts, gaxOpts); done(); }; - subscription.setMetadata(METADATA, gaxOpts, done); + subscription.setMetadata?.(METADATA, gaxOpts, done); }); }); @@ -1013,7 +1014,7 @@ describe('Subscription', () => { it('should pass the options to the subscriber', () => { const options = {}; const stub = sandbox.stub(subscriber, 'setOptions').withArgs(options); - subscription.setOptions(options); + subscription.setOptions?.(options); assert.strictEqual(stub.callCount, 1); }); }); @@ -1029,7 +1030,7 @@ describe('Subscription', () => { done(); }; - subscription.snapshot(SNAPSHOT_NAME); + subscription.snapshot?.(SNAPSHOT_NAME); }); }); }); From d5de29ac05c403a800addf701e2e945f43e2eabf Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 13:23:16 -0700 Subject: [PATCH 06/10] run lint --- test/topic.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/topic.ts b/test/topic.ts index f5733a0d4..bbd0aa2df 100644 --- a/test/topic.ts +++ b/test/topic.ts @@ -488,7 +488,15 @@ describe('Topic', () => { describe('getSubscriptions', () => { it('should make the correct request', done => { - const options = { + interface testOptions { + a: string; + b: string; + gaxOpts?: { + e: string; + }; + autoPaginate?: boolean; + } + const options: testOptions = { a: 'a', b: 'b', gaxOpts: { From 82dc03accc8a4d0429f661491ea3d4cce71d2e28 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 13:38:31 -0700 Subject: [PATCH 07/10] retry --- test/subscription.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/subscription.ts b/test/subscription.ts index e436ceea8..ec73b2641 100644 --- a/test/subscription.ts +++ b/test/subscription.ts @@ -338,7 +338,7 @@ describe('Subscription', () => { sandbox.stub(subscriber, 'close').rejects(fakeErr); - subscription.close?.(), + subscription.close!(), (err: Error) => { assert.strictEqual(err, fakeErr); done(); From f24b7b0548a0a60615b683238bf72411a1ccee06 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 17 May 2022 13:55:14 -0700 Subject: [PATCH 08/10] retry --- test/subscription.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/subscription.ts b/test/subscription.ts index ec73b2641..ecd3ee67a 100644 --- a/test/subscription.ts +++ b/test/subscription.ts @@ -338,7 +338,7 @@ describe('Subscription', () => { sandbox.stub(subscriber, 'close').rejects(fakeErr); - subscription.close!(), + subscription?.close!(), (err: Error) => { assert.strictEqual(err, fakeErr); done(); From 11c1a8aacf1cb99c62baa6dba0e2b88737970ca7 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 19 May 2022 15:28:09 -0700 Subject: [PATCH 09/10] assert subscriiption exists --- test/subscription.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/subscription.ts b/test/subscription.ts index ecd3ee67a..96ac1c1ab 100644 --- a/test/subscription.ts +++ b/test/subscription.ts @@ -338,7 +338,7 @@ describe('Subscription', () => { sandbox.stub(subscriber, 'close').rejects(fakeErr); - subscription?.close!(), + subscription!.close!(), (err: Error) => { assert.strictEqual(err, fakeErr); done(); From b3ea32904efee3908defd396817b58933788de7d Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 20 May 2022 12:18:01 -0700 Subject: [PATCH 10/10] fix failing test --- test/subscription.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/subscription.ts b/test/subscription.ts index 96ac1c1ab..1fdaa36f9 100644 --- a/test/subscription.ts +++ b/test/subscription.ts @@ -338,11 +338,10 @@ describe('Subscription', () => { sandbox.stub(subscriber, 'close').rejects(fakeErr); - subscription!.close!(), - (err: Error) => { - assert.strictEqual(err, fakeErr); - done(); - }; + subscription!.close!((err: Error | undefined) => { + assert.strictEqual(err, fakeErr); + done(); + }); }); });