@google-cloud/pubsub 4.11.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +2 -2
  2. package/build/protos/google/pubsub/v1/pubsub.proto +144 -29
  3. package/build/protos/google/pubsub/v1/schema.proto +2 -3
  4. package/build/protos/protos.d.ts +477 -11
  5. package/build/protos/protos.js +1681 -151
  6. package/build/protos/protos.json +203 -28
  7. package/build/src/debug.js +2 -0
  8. package/build/src/debug.js.map +1 -1
  9. package/build/src/default-options.d.ts +2 -2
  10. package/build/src/default-options.js +3 -3
  11. package/build/src/default-options.js.map +1 -1
  12. package/build/src/exponential-retry.js +4 -1
  13. package/build/src/exponential-retry.js.map +1 -1
  14. package/build/src/histogram.js +3 -0
  15. package/build/src/histogram.js.map +1 -1
  16. package/build/src/iam.js +3 -0
  17. package/build/src/iam.js.map +1 -1
  18. package/build/src/index.d.ts +0 -2
  19. package/build/src/index.js +1 -5
  20. package/build/src/index.js.map +1 -1
  21. package/build/src/lease-manager.d.ts +0 -3
  22. package/build/src/lease-manager.js +14 -19
  23. package/build/src/lease-manager.js.map +1 -1
  24. package/build/src/message-queues.js +31 -23
  25. package/build/src/message-queues.js.map +1 -1
  26. package/build/src/message-stream.js +13 -4
  27. package/build/src/message-stream.js.map +1 -1
  28. package/build/src/publisher/flow-control.js +4 -1
  29. package/build/src/publisher/flow-control.js.map +1 -1
  30. package/build/src/publisher/flow-publisher.js +5 -2
  31. package/build/src/publisher/flow-publisher.js.map +1 -1
  32. package/build/src/publisher/index.d.ts +0 -2
  33. package/build/src/publisher/index.js +9 -6
  34. package/build/src/publisher/index.js.map +1 -1
  35. package/build/src/publisher/message-batch.d.ts +0 -11
  36. package/build/src/publisher/message-batch.js +13 -1
  37. package/build/src/publisher/message-batch.js.map +1 -1
  38. package/build/src/publisher/message-queues.js +10 -3
  39. package/build/src/publisher/message-queues.js.map +1 -1
  40. package/build/src/publisher/publish-error.js +5 -0
  41. package/build/src/publisher/publish-error.js.map +1 -1
  42. package/build/src/publisher/pubsub-message.d.ts +0 -68
  43. package/build/src/pubsub.js +14 -5
  44. package/build/src/pubsub.js.map +1 -1
  45. package/build/src/schema.js +3 -0
  46. package/build/src/schema.js.map +1 -1
  47. package/build/src/snapshot.js +3 -0
  48. package/build/src/snapshot.js.map +1 -1
  49. package/build/src/subscriber.d.ts +11 -15
  50. package/build/src/subscriber.js +84 -26
  51. package/build/src/subscriber.js.map +1 -1
  52. package/build/src/subscription.js +11 -2
  53. package/build/src/subscription.js.map +1 -1
  54. package/build/src/telemetry-tracing.d.ts +2 -220
  55. package/build/src/telemetry-tracing.js +52 -121
  56. package/build/src/telemetry-tracing.js.map +1 -1
  57. package/build/src/temporal.js +8 -8
  58. package/build/src/temporal.js.map +1 -1
  59. package/build/src/topic.js +8 -1
  60. package/build/src/topic.js.map +1 -1
  61. package/build/src/util.js +3 -2
  62. package/build/src/util.js.map +1 -1
  63. package/build/src/v1/publisher_client.d.ts +8 -4
  64. package/build/src/v1/publisher_client.js +228 -78
  65. package/build/src/v1/publisher_client.js.map +1 -1
  66. package/build/src/v1/publisher_proto_list.json +4 -0
  67. package/build/src/v1/schema_service_client.d.ts +4 -3
  68. package/build/src/v1/schema_service_client.js +233 -73
  69. package/build/src/v1/schema_service_client.js.map +1 -1
  70. package/build/src/v1/schema_service_proto_list.json +4 -0
  71. package/build/src/v1/subscriber_client.d.ts +11 -7
  72. package/build/src/v1/subscriber_client.js +324 -96
  73. package/build/src/v1/subscriber_client.js.map +1 -1
  74. package/build/src/v1/subscriber_proto_list.json +4 -0
  75. package/package.json +45 -47
  76. package/CHANGELOG.md +0 -1606
@@ -18,6 +18,7 @@ export declare class PublisherClient {
18
18
  private _defaults;
19
19
  private _universeDomain;
20
20
  private _servicePath;
21
+ private _log;
21
22
  auth: gax.GoogleAuth;
22
23
  descriptors: Descriptors;
23
24
  warn: (code: string, message: string, warnType?: string) => void;
@@ -53,7 +54,7 @@ export declare class PublisherClient {
53
54
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
54
55
  * the environment variable GCLOUD_PROJECT for your project ID. If your
55
56
  * app is running in an environment which supports
56
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
57
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
57
58
  * your project ID will be detected automatically.
58
59
  * @param {string} [options.apiEndpoint] - The domain name of the
59
60
  * API remote host.
@@ -160,6 +161,9 @@ export declare class PublisherClient {
160
161
  * Output only. An output-only field indicating the state of the topic.
161
162
  * @param {google.pubsub.v1.IngestionDataSourceSettings} [request.ingestionDataSourceSettings]
162
163
  * Optional. Settings for ingestion from a data source into this topic.
164
+ * @param {number[]} [request.messageTransforms]
165
+ * Optional. Transforms to be applied to messages published to the topic.
166
+ * Transforms are applied in the order specified.
163
167
  * @param {object} [options]
164
168
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
165
169
  * @returns {Promise} - The promise which resolves to an array.
@@ -334,7 +338,7 @@ export declare class PublisherClient {
334
338
  listTopics(request: protos.google.pubsub.v1.IListTopicsRequest, options: CallOptions, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicsRequest, protos.google.pubsub.v1.IListTopicsResponse | null | undefined, protos.google.pubsub.v1.ITopic>): void;
335
339
  listTopics(request: protos.google.pubsub.v1.IListTopicsRequest, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicsRequest, protos.google.pubsub.v1.IListTopicsResponse | null | undefined, protos.google.pubsub.v1.ITopic>): void;
336
340
  /**
337
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
341
+ * Equivalent to `listTopics`, but returns a NodeJS Stream object.
338
342
  * @param {Object} request
339
343
  * The request object that will be sent.
340
344
  * @param {string} request.project
@@ -418,7 +422,7 @@ export declare class PublisherClient {
418
422
  listTopicSubscriptions(request: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicSubscriptionsRequest, protos.google.pubsub.v1.IListTopicSubscriptionsResponse | null | undefined, string>): void;
419
423
  listTopicSubscriptions(request: protos.google.pubsub.v1.IListTopicSubscriptionsRequest, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicSubscriptionsRequest, protos.google.pubsub.v1.IListTopicSubscriptionsResponse | null | undefined, string>): void;
420
424
  /**
421
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
425
+ * Equivalent to `listTopicSubscriptions`, but returns a NodeJS Stream object.
422
426
  * @param {Object} request
423
427
  * The request object that will be sent.
424
428
  * @param {string} request.topic
@@ -506,7 +510,7 @@ export declare class PublisherClient {
506
510
  listTopicSnapshots(request: protos.google.pubsub.v1.IListTopicSnapshotsRequest, options: CallOptions, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicSnapshotsRequest, protos.google.pubsub.v1.IListTopicSnapshotsResponse | null | undefined, string>): void;
507
511
  listTopicSnapshots(request: protos.google.pubsub.v1.IListTopicSnapshotsRequest, callback: PaginationCallback<protos.google.pubsub.v1.IListTopicSnapshotsRequest, protos.google.pubsub.v1.IListTopicSnapshotsResponse | null | undefined, string>): void;
508
512
  /**
509
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
513
+ * Equivalent to `listTopicSnapshots`, but returns a NodeJS Stream object.
510
514
  * @param {Object} request
511
515
  * The request object that will be sent.
512
516
  * @param {string} request.topic
@@ -19,6 +19,7 @@
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.PublisherClient = void 0;
21
21
  const jsonProtos = require("../../protos/protos.json");
22
+ const google_gax_1 = require("google-gax");
22
23
  /**
23
24
  * Client JSON configuration object, loaded from
24
25
  * `src/v1/publisher_client_config.json`.
@@ -33,6 +34,28 @@ const version = require('../../../package.json').version;
33
34
  * @memberof v1
34
35
  */
35
36
  class PublisherClient {
37
+ _terminated = false;
38
+ _opts;
39
+ _providedCustomServicePath;
40
+ _gaxModule;
41
+ _gaxGrpc;
42
+ _protos;
43
+ _defaults;
44
+ _universeDomain;
45
+ _servicePath;
46
+ _log = google_gax_1.loggingUtils.log('pubsub');
47
+ auth;
48
+ descriptors = {
49
+ page: {},
50
+ stream: {},
51
+ longrunning: {},
52
+ batching: {},
53
+ };
54
+ warn;
55
+ innerApiCalls;
56
+ iamClient;
57
+ pathTemplates;
58
+ publisherStub;
36
59
  /**
37
60
  * Construct an instance of PublisherClient.
38
61
  *
@@ -55,7 +78,7 @@ class PublisherClient {
55
78
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
56
79
  * the environment variable GCLOUD_PROJECT for your project ID. If your
57
80
  * app is running in an environment which supports
58
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
81
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
59
82
  * your project ID will be detected automatically.
60
83
  * @param {string} [options.apiEndpoint] - The domain name of the
61
84
  * API remote host.
@@ -73,32 +96,28 @@ class PublisherClient {
73
96
  * ```
74
97
  */
75
98
  constructor(opts, gaxInstance) {
76
- var _a, _b, _c, _d, _e;
77
- this._terminated = false;
78
- this.descriptors = {
79
- page: {},
80
- stream: {},
81
- longrunning: {},
82
- batching: {},
83
- };
84
99
  // Ensure that options include all the required fields.
85
100
  const staticMembers = this.constructor;
86
- if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
87
- (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
88
- (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
101
+ if (opts?.universe_domain &&
102
+ opts?.universeDomain &&
103
+ opts?.universe_domain !== opts?.universeDomain) {
89
104
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
90
105
  }
91
106
  const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
92
107
  ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
93
108
  : undefined;
94
109
  this._universeDomain =
95
- (_c = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : universeDomainEnvVar) !== null && _c !== void 0 ? _c : 'googleapis.com';
110
+ opts?.universeDomain ??
111
+ opts?.universe_domain ??
112
+ universeDomainEnvVar ??
113
+ 'googleapis.com';
96
114
  this._servicePath = 'pubsub.' + this._universeDomain;
97
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
98
- this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
99
- const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
100
- const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
101
- const fallback = (_e = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _e !== void 0 ? _e : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
115
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
116
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
117
+ const port = opts?.port || staticMembers.port;
118
+ const clientConfig = opts?.clientConfig ?? {};
119
+ const fallback = opts?.fallback ??
120
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
102
121
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
103
122
  // Request numeric enum values if REST transport is used.
104
123
  opts.numericEnums = true;
@@ -193,7 +212,6 @@ class PublisherClient {
193
212
  * @returns {Promise} A promise that resolves to an authenticated service stub.
194
213
  */
195
214
  initialize() {
196
- var _a;
197
215
  // If the client stub promise is already initialized, return immediately.
198
216
  if (this.publisherStub) {
199
217
  return this.publisherStub;
@@ -228,7 +246,7 @@ class PublisherClient {
228
246
  throw err;
229
247
  });
230
248
  const descriptor = this.descriptors.page[methodName] ||
231
- ((_a = this.descriptors.batching) === null || _a === void 0 ? void 0 : _a[methodName]) ||
249
+ this.descriptors.batching?.[methodName] ||
232
250
  undefined;
233
251
  const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
234
252
  this.innerApiCalls[methodName] = apiCall;
@@ -299,7 +317,6 @@ class PublisherClient {
299
317
  return this.auth.getProjectId();
300
318
  }
301
319
  createTopic(request, optionsOrCallback, callback) {
302
- var _a;
303
320
  request = request || {};
304
321
  let options;
305
322
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -314,13 +331,26 @@ class PublisherClient {
314
331
  options.otherArgs.headers = options.otherArgs.headers || {};
315
332
  options.otherArgs.headers['x-goog-request-params'] =
316
333
  this._gaxModule.routingHeader.fromParams({
317
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
334
+ name: request.name ?? '',
318
335
  });
319
- this.initialize();
320
- return this.innerApiCalls.createTopic(request, options, callback);
336
+ this.initialize().catch(err => {
337
+ throw err;
338
+ });
339
+ this._log.info('createTopic request %j', request);
340
+ const wrappedCallback = callback
341
+ ? (error, response, options, rawResponse) => {
342
+ this._log.info('createTopic response %j', response);
343
+ callback(error, response, options, rawResponse); // We verified callback above.
344
+ }
345
+ : undefined;
346
+ return this.innerApiCalls
347
+ .createTopic(request, options, wrappedCallback)
348
+ ?.then(([response, options, rawResponse]) => {
349
+ this._log.info('createTopic response %j', response);
350
+ return [response, options, rawResponse];
351
+ });
321
352
  }
322
353
  updateTopic(request, optionsOrCallback, callback) {
323
- var _a;
324
354
  request = request || {};
325
355
  let options;
326
356
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -335,13 +365,26 @@ class PublisherClient {
335
365
  options.otherArgs.headers = options.otherArgs.headers || {};
336
366
  options.otherArgs.headers['x-goog-request-params'] =
337
367
  this._gaxModule.routingHeader.fromParams({
338
- 'topic.name': (_a = request.topic.name) !== null && _a !== void 0 ? _a : '',
368
+ 'topic.name': request.topic.name ?? '',
339
369
  });
340
- this.initialize();
341
- return this.innerApiCalls.updateTopic(request, options, callback);
370
+ this.initialize().catch(err => {
371
+ throw err;
372
+ });
373
+ this._log.info('updateTopic request %j', request);
374
+ const wrappedCallback = callback
375
+ ? (error, response, options, rawResponse) => {
376
+ this._log.info('updateTopic response %j', response);
377
+ callback(error, response, options, rawResponse); // We verified callback above.
378
+ }
379
+ : undefined;
380
+ return this.innerApiCalls
381
+ .updateTopic(request, options, wrappedCallback)
382
+ ?.then(([response, options, rawResponse]) => {
383
+ this._log.info('updateTopic response %j', response);
384
+ return [response, options, rawResponse];
385
+ });
342
386
  }
343
387
  publish(request, optionsOrCallback, callback) {
344
- var _a;
345
388
  request = request || {};
346
389
  let options;
347
390
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -356,13 +399,26 @@ class PublisherClient {
356
399
  options.otherArgs.headers = options.otherArgs.headers || {};
357
400
  options.otherArgs.headers['x-goog-request-params'] =
358
401
  this._gaxModule.routingHeader.fromParams({
359
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
402
+ topic: request.topic ?? '',
360
403
  });
361
- this.initialize();
362
- return this.innerApiCalls.publish(request, options, callback);
404
+ this.initialize().catch(err => {
405
+ throw err;
406
+ });
407
+ this._log.info('publish request %j', request);
408
+ const wrappedCallback = callback
409
+ ? (error, response, options, rawResponse) => {
410
+ this._log.info('publish response %j', response);
411
+ callback(error, response, options, rawResponse); // We verified callback above.
412
+ }
413
+ : undefined;
414
+ return this.innerApiCalls
415
+ .publish(request, options, wrappedCallback)
416
+ ?.then(([response, options, rawResponse]) => {
417
+ this._log.info('publish response %j', response);
418
+ return [response, options, rawResponse];
419
+ });
363
420
  }
364
421
  getTopic(request, optionsOrCallback, callback) {
365
- var _a;
366
422
  request = request || {};
367
423
  let options;
368
424
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -377,13 +433,26 @@ class PublisherClient {
377
433
  options.otherArgs.headers = options.otherArgs.headers || {};
378
434
  options.otherArgs.headers['x-goog-request-params'] =
379
435
  this._gaxModule.routingHeader.fromParams({
380
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
436
+ topic: request.topic ?? '',
381
437
  });
382
- this.initialize();
383
- return this.innerApiCalls.getTopic(request, options, callback);
438
+ this.initialize().catch(err => {
439
+ throw err;
440
+ });
441
+ this._log.info('getTopic request %j', request);
442
+ const wrappedCallback = callback
443
+ ? (error, response, options, rawResponse) => {
444
+ this._log.info('getTopic response %j', response);
445
+ callback(error, response, options, rawResponse); // We verified callback above.
446
+ }
447
+ : undefined;
448
+ return this.innerApiCalls
449
+ .getTopic(request, options, wrappedCallback)
450
+ ?.then(([response, options, rawResponse]) => {
451
+ this._log.info('getTopic response %j', response);
452
+ return [response, options, rawResponse];
453
+ });
384
454
  }
385
455
  deleteTopic(request, optionsOrCallback, callback) {
386
- var _a;
387
456
  request = request || {};
388
457
  let options;
389
458
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -398,13 +467,26 @@ class PublisherClient {
398
467
  options.otherArgs.headers = options.otherArgs.headers || {};
399
468
  options.otherArgs.headers['x-goog-request-params'] =
400
469
  this._gaxModule.routingHeader.fromParams({
401
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
470
+ topic: request.topic ?? '',
402
471
  });
403
- this.initialize();
404
- return this.innerApiCalls.deleteTopic(request, options, callback);
472
+ this.initialize().catch(err => {
473
+ throw err;
474
+ });
475
+ this._log.info('deleteTopic request %j', request);
476
+ const wrappedCallback = callback
477
+ ? (error, response, options, rawResponse) => {
478
+ this._log.info('deleteTopic response %j', response);
479
+ callback(error, response, options, rawResponse); // We verified callback above.
480
+ }
481
+ : undefined;
482
+ return this.innerApiCalls
483
+ .deleteTopic(request, options, wrappedCallback)
484
+ ?.then(([response, options, rawResponse]) => {
485
+ this._log.info('deleteTopic response %j', response);
486
+ return [response, options, rawResponse];
487
+ });
405
488
  }
406
489
  detachSubscription(request, optionsOrCallback, callback) {
407
- var _a;
408
490
  request = request || {};
409
491
  let options;
410
492
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -419,13 +501,26 @@ class PublisherClient {
419
501
  options.otherArgs.headers = options.otherArgs.headers || {};
420
502
  options.otherArgs.headers['x-goog-request-params'] =
421
503
  this._gaxModule.routingHeader.fromParams({
422
- subscription: (_a = request.subscription) !== null && _a !== void 0 ? _a : '',
504
+ subscription: request.subscription ?? '',
423
505
  });
424
- this.initialize();
425
- return this.innerApiCalls.detachSubscription(request, options, callback);
506
+ this.initialize().catch(err => {
507
+ throw err;
508
+ });
509
+ this._log.info('detachSubscription request %j', request);
510
+ const wrappedCallback = callback
511
+ ? (error, response, options, rawResponse) => {
512
+ this._log.info('detachSubscription response %j', response);
513
+ callback(error, response, options, rawResponse); // We verified callback above.
514
+ }
515
+ : undefined;
516
+ return this.innerApiCalls
517
+ .detachSubscription(request, options, wrappedCallback)
518
+ ?.then(([response, options, rawResponse]) => {
519
+ this._log.info('detachSubscription response %j', response);
520
+ return [response, options, rawResponse];
521
+ });
426
522
  }
427
523
  listTopics(request, optionsOrCallback, callback) {
428
- var _a;
429
524
  request = request || {};
430
525
  let options;
431
526
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -440,13 +535,27 @@ class PublisherClient {
440
535
  options.otherArgs.headers = options.otherArgs.headers || {};
441
536
  options.otherArgs.headers['x-goog-request-params'] =
442
537
  this._gaxModule.routingHeader.fromParams({
443
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
538
+ project: request.project ?? '',
444
539
  });
445
- this.initialize();
446
- return this.innerApiCalls.listTopics(request, options, callback);
540
+ this.initialize().catch(err => {
541
+ throw err;
542
+ });
543
+ const wrappedCallback = callback
544
+ ? (error, values, nextPageRequest, rawResponse) => {
545
+ this._log.info('listTopics values %j', values);
546
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
547
+ }
548
+ : undefined;
549
+ this._log.info('listTopics request %j', request);
550
+ return this.innerApiCalls
551
+ .listTopics(request, options, wrappedCallback)
552
+ ?.then(([response, input, output]) => {
553
+ this._log.info('listTopics values %j', response);
554
+ return [response, input, output];
555
+ });
447
556
  }
448
557
  /**
449
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
558
+ * Equivalent to `listTopics`, but returns a NodeJS Stream object.
450
559
  * @param {Object} request
451
560
  * The request object that will be sent.
452
561
  * @param {string} request.project
@@ -470,18 +579,20 @@ class PublisherClient {
470
579
  * for more details and examples.
471
580
  */
472
581
  listTopicsStream(request, options) {
473
- var _a;
474
582
  request = request || {};
475
583
  options = options || {};
476
584
  options.otherArgs = options.otherArgs || {};
477
585
  options.otherArgs.headers = options.otherArgs.headers || {};
478
586
  options.otherArgs.headers['x-goog-request-params'] =
479
587
  this._gaxModule.routingHeader.fromParams({
480
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
588
+ project: request.project ?? '',
481
589
  });
482
590
  const defaultCallSettings = this._defaults['listTopics'];
483
591
  const callSettings = defaultCallSettings.merge(options);
484
- this.initialize();
592
+ this.initialize().catch(err => {
593
+ throw err;
594
+ });
595
+ this._log.info('listTopics stream %j', request);
485
596
  return this.descriptors.page.listTopics.createStream(this.innerApiCalls.listTopics, request, callSettings);
486
597
  }
487
598
  /**
@@ -510,22 +621,23 @@ class PublisherClient {
510
621
  * for more details and examples.
511
622
  */
512
623
  listTopicsAsync(request, options) {
513
- var _a;
514
624
  request = request || {};
515
625
  options = options || {};
516
626
  options.otherArgs = options.otherArgs || {};
517
627
  options.otherArgs.headers = options.otherArgs.headers || {};
518
628
  options.otherArgs.headers['x-goog-request-params'] =
519
629
  this._gaxModule.routingHeader.fromParams({
520
- project: (_a = request.project) !== null && _a !== void 0 ? _a : '',
630
+ project: request.project ?? '',
521
631
  });
522
632
  const defaultCallSettings = this._defaults['listTopics'];
523
633
  const callSettings = defaultCallSettings.merge(options);
524
- this.initialize();
634
+ this.initialize().catch(err => {
635
+ throw err;
636
+ });
637
+ this._log.info('listTopics iterate %j', request);
525
638
  return this.descriptors.page.listTopics.asyncIterate(this.innerApiCalls['listTopics'], request, callSettings);
526
639
  }
527
640
  listTopicSubscriptions(request, optionsOrCallback, callback) {
528
- var _a;
529
641
  request = request || {};
530
642
  let options;
531
643
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -540,13 +652,27 @@ class PublisherClient {
540
652
  options.otherArgs.headers = options.otherArgs.headers || {};
541
653
  options.otherArgs.headers['x-goog-request-params'] =
542
654
  this._gaxModule.routingHeader.fromParams({
543
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
655
+ topic: request.topic ?? '',
544
656
  });
545
- this.initialize();
546
- return this.innerApiCalls.listTopicSubscriptions(request, options, callback);
657
+ this.initialize().catch(err => {
658
+ throw err;
659
+ });
660
+ const wrappedCallback = callback
661
+ ? (error, values, nextPageRequest, rawResponse) => {
662
+ this._log.info('listTopicSubscriptions values %j', values);
663
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
664
+ }
665
+ : undefined;
666
+ this._log.info('listTopicSubscriptions request %j', request);
667
+ return this.innerApiCalls
668
+ .listTopicSubscriptions(request, options, wrappedCallback)
669
+ ?.then(([response, input, output]) => {
670
+ this._log.info('listTopicSubscriptions values %j', response);
671
+ return [response, input, output];
672
+ });
547
673
  }
548
674
  /**
549
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
675
+ * Equivalent to `listTopicSubscriptions`, but returns a NodeJS Stream object.
550
676
  * @param {Object} request
551
677
  * The request object that will be sent.
552
678
  * @param {string} request.topic
@@ -570,18 +696,20 @@ class PublisherClient {
570
696
  * for more details and examples.
571
697
  */
572
698
  listTopicSubscriptionsStream(request, options) {
573
- var _a;
574
699
  request = request || {};
575
700
  options = options || {};
576
701
  options.otherArgs = options.otherArgs || {};
577
702
  options.otherArgs.headers = options.otherArgs.headers || {};
578
703
  options.otherArgs.headers['x-goog-request-params'] =
579
704
  this._gaxModule.routingHeader.fromParams({
580
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
705
+ topic: request.topic ?? '',
581
706
  });
582
707
  const defaultCallSettings = this._defaults['listTopicSubscriptions'];
583
708
  const callSettings = defaultCallSettings.merge(options);
584
- this.initialize();
709
+ this.initialize().catch(err => {
710
+ throw err;
711
+ });
712
+ this._log.info('listTopicSubscriptions stream %j', request);
585
713
  return this.descriptors.page.listTopicSubscriptions.createStream(this.innerApiCalls.listTopicSubscriptions, request, callSettings);
586
714
  }
587
715
  /**
@@ -610,22 +738,23 @@ class PublisherClient {
610
738
  * for more details and examples.
611
739
  */
612
740
  listTopicSubscriptionsAsync(request, options) {
613
- var _a;
614
741
  request = request || {};
615
742
  options = options || {};
616
743
  options.otherArgs = options.otherArgs || {};
617
744
  options.otherArgs.headers = options.otherArgs.headers || {};
618
745
  options.otherArgs.headers['x-goog-request-params'] =
619
746
  this._gaxModule.routingHeader.fromParams({
620
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
747
+ topic: request.topic ?? '',
621
748
  });
622
749
  const defaultCallSettings = this._defaults['listTopicSubscriptions'];
623
750
  const callSettings = defaultCallSettings.merge(options);
624
- this.initialize();
751
+ this.initialize().catch(err => {
752
+ throw err;
753
+ });
754
+ this._log.info('listTopicSubscriptions iterate %j', request);
625
755
  return this.descriptors.page.listTopicSubscriptions.asyncIterate(this.innerApiCalls['listTopicSubscriptions'], request, callSettings);
626
756
  }
627
757
  listTopicSnapshots(request, optionsOrCallback, callback) {
628
- var _a;
629
758
  request = request || {};
630
759
  let options;
631
760
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -640,13 +769,27 @@ class PublisherClient {
640
769
  options.otherArgs.headers = options.otherArgs.headers || {};
641
770
  options.otherArgs.headers['x-goog-request-params'] =
642
771
  this._gaxModule.routingHeader.fromParams({
643
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
772
+ topic: request.topic ?? '',
644
773
  });
645
- this.initialize();
646
- return this.innerApiCalls.listTopicSnapshots(request, options, callback);
774
+ this.initialize().catch(err => {
775
+ throw err;
776
+ });
777
+ const wrappedCallback = callback
778
+ ? (error, values, nextPageRequest, rawResponse) => {
779
+ this._log.info('listTopicSnapshots values %j', values);
780
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
781
+ }
782
+ : undefined;
783
+ this._log.info('listTopicSnapshots request %j', request);
784
+ return this.innerApiCalls
785
+ .listTopicSnapshots(request, options, wrappedCallback)
786
+ ?.then(([response, input, output]) => {
787
+ this._log.info('listTopicSnapshots values %j', response);
788
+ return [response, input, output];
789
+ });
647
790
  }
648
791
  /**
649
- * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
792
+ * Equivalent to `listTopicSnapshots`, but returns a NodeJS Stream object.
650
793
  * @param {Object} request
651
794
  * The request object that will be sent.
652
795
  * @param {string} request.topic
@@ -670,18 +813,20 @@ class PublisherClient {
670
813
  * for more details and examples.
671
814
  */
672
815
  listTopicSnapshotsStream(request, options) {
673
- var _a;
674
816
  request = request || {};
675
817
  options = options || {};
676
818
  options.otherArgs = options.otherArgs || {};
677
819
  options.otherArgs.headers = options.otherArgs.headers || {};
678
820
  options.otherArgs.headers['x-goog-request-params'] =
679
821
  this._gaxModule.routingHeader.fromParams({
680
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
822
+ topic: request.topic ?? '',
681
823
  });
682
824
  const defaultCallSettings = this._defaults['listTopicSnapshots'];
683
825
  const callSettings = defaultCallSettings.merge(options);
684
- this.initialize();
826
+ this.initialize().catch(err => {
827
+ throw err;
828
+ });
829
+ this._log.info('listTopicSnapshots stream %j', request);
685
830
  return this.descriptors.page.listTopicSnapshots.createStream(this.innerApiCalls.listTopicSnapshots, request, callSettings);
686
831
  }
687
832
  /**
@@ -710,18 +855,20 @@ class PublisherClient {
710
855
  * for more details and examples.
711
856
  */
712
857
  listTopicSnapshotsAsync(request, options) {
713
- var _a;
714
858
  request = request || {};
715
859
  options = options || {};
716
860
  options.otherArgs = options.otherArgs || {};
717
861
  options.otherArgs.headers = options.otherArgs.headers || {};
718
862
  options.otherArgs.headers['x-goog-request-params'] =
719
863
  this._gaxModule.routingHeader.fromParams({
720
- topic: (_a = request.topic) !== null && _a !== void 0 ? _a : '',
864
+ topic: request.topic ?? '',
721
865
  });
722
866
  const defaultCallSettings = this._defaults['listTopicSnapshots'];
723
867
  const callSettings = defaultCallSettings.merge(options);
724
- this.initialize();
868
+ this.initialize().catch(err => {
869
+ throw err;
870
+ });
871
+ this._log.info('listTopicSnapshots iterate %j', request);
725
872
  return this.descriptors.page.listTopicSnapshots.asyncIterate(this.innerApiCalls['listTopicSnapshots'], request, callSettings);
726
873
  }
727
874
  /**
@@ -986,9 +1133,12 @@ class PublisherClient {
986
1133
  close() {
987
1134
  if (this.publisherStub && !this._terminated) {
988
1135
  return this.publisherStub.then(stub => {
1136
+ this._log.info('ending gRPC channel');
989
1137
  this._terminated = true;
990
1138
  stub.close();
991
- this.iamClient.close();
1139
+ this.iamClient.close().catch(err => {
1140
+ throw err;
1141
+ });
992
1142
  });
993
1143
  }
994
1144
  return Promise.resolve();