@google-cloud/spanner 7.21.0 → 8.0.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 (51) hide show
  1. package/build/protos/google/spanner/admin/database/v1/backup.proto +1 -1
  2. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +1 -1
  3. package/build/protos/google/spanner/admin/database/v1/common.proto +1 -1
  4. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1 -1
  5. package/build/protos/google/spanner/admin/instance/v1/common.proto +1 -1
  6. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +1 -1
  7. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1 -1
  8. package/build/protos/google/spanner/v1/commit_response.proto +1 -1
  9. package/build/protos/google/spanner/v1/keys.proto +1 -1
  10. package/build/protos/google/spanner/v1/mutation.proto +1 -1
  11. package/build/protos/google/spanner/v1/query_plan.proto +1 -1
  12. package/build/protos/google/spanner/v1/result_set.proto +55 -49
  13. package/build/protos/google/spanner/v1/spanner.proto +1 -1
  14. package/build/protos/google/spanner/v1/transaction.proto +1 -1
  15. package/build/protos/google/spanner/v1/type.proto +1 -1
  16. package/build/protos/protos.d.ts +56 -194
  17. package/build/protos/protos.js +71 -288
  18. package/build/protos/protos.json +8 -2
  19. package/build/src/backup.js +7 -0
  20. package/build/src/batch-transaction.d.ts +48 -29
  21. package/build/src/batch-transaction.js +13 -98
  22. package/build/src/codec.js +43 -26
  23. package/build/src/common-grpc/service-object.js +1 -0
  24. package/build/src/common-grpc/service.js +25 -8
  25. package/build/src/database.js +52 -42
  26. package/build/src/helper.d.ts +9 -0
  27. package/build/src/helper.js +24 -0
  28. package/build/src/index.js +24 -13
  29. package/build/src/instance-config.d.ts +1 -1
  30. package/build/src/instance-config.js +4 -0
  31. package/build/src/instance.js +12 -6
  32. package/build/src/instrument.js +2 -4
  33. package/build/src/multiplexed-session.js +7 -1
  34. package/build/src/partial-result-stream.js +9 -5
  35. package/build/src/request_id_header.js +1 -0
  36. package/build/src/session-factory.js +5 -2
  37. package/build/src/session-pool.js +23 -6
  38. package/build/src/session.d.ts +0 -1
  39. package/build/src/session.js +7 -2
  40. package/build/src/table.js +6 -3
  41. package/build/src/transaction-runner.js +12 -2
  42. package/build/src/transaction.js +66 -52
  43. package/build/src/v1/database_admin_client.d.ts +3 -2
  44. package/build/src/v1/database_admin_client.js +551 -167
  45. package/build/src/v1/instance_admin_client.d.ts +2 -1
  46. package/build/src/v1/instance_admin_client.js +453 -133
  47. package/build/src/v1/spanner_client.d.ts +2 -1
  48. package/build/src/v1/spanner_client.js +283 -85
  49. package/build/src/v1/spanner_executor_proxy_client.d.ts +2 -1
  50. package/build/src/v1/spanner_executor_proxy_client.js +41 -19
  51. package/package.json +57 -58
@@ -20,6 +20,7 @@ export declare class SpannerClient {
20
20
  private _defaults;
21
21
  private _universeDomain;
22
22
  private _servicePath;
23
+ private _log;
23
24
  auth: gax.GoogleAuth;
24
25
  descriptors: Descriptors;
25
26
  warn: (code: string, message: string, warnType?: string) => void;
@@ -54,7 +55,7 @@ export declare class SpannerClient {
54
55
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
55
56
  * the environment variable GCLOUD_PROJECT for your project ID. If your
56
57
  * app is running in an environment which supports
57
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
58
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
58
59
  * your project ID will be detected automatically.
59
60
  * @param {string} [options.apiEndpoint] - The domain name of the
60
61
  * API remote host.
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.SpannerClient = void 0;
21
21
  const stream_1 = require("stream");
22
22
  const jsonProtos = require("../../protos/protos.json");
23
+ const google_gax_1 = require("google-gax");
23
24
  /**
24
25
  * Client JSON configuration object, loaded from
25
26
  * `src/v1/spanner_client_config.json`.
@@ -36,6 +37,27 @@ const version = require('../../../package.json').version;
36
37
  * @memberof v1
37
38
  */
38
39
  class SpannerClient {
40
+ _terminated = false;
41
+ _opts;
42
+ _providedCustomServicePath;
43
+ _gaxModule;
44
+ _gaxGrpc;
45
+ _protos;
46
+ _defaults;
47
+ _universeDomain;
48
+ _servicePath;
49
+ _log = google_gax_1.loggingUtils.log('spanner');
50
+ auth;
51
+ descriptors = {
52
+ page: {},
53
+ stream: {},
54
+ longrunning: {},
55
+ batching: {},
56
+ };
57
+ warn;
58
+ innerApiCalls;
59
+ pathTemplates;
60
+ spannerStub;
39
61
  /**
40
62
  * Construct an instance of SpannerClient.
41
63
  *
@@ -58,7 +80,7 @@ class SpannerClient {
58
80
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
59
81
  * the environment variable GCLOUD_PROJECT for your project ID. If your
60
82
  * app is running in an environment which supports
61
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
83
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
62
84
  * your project ID will be detected automatically.
63
85
  * @param {string} [options.apiEndpoint] - The domain name of the
64
86
  * API remote host.
@@ -76,32 +98,28 @@ class SpannerClient {
76
98
  * ```
77
99
  */
78
100
  constructor(opts, gaxInstance) {
79
- var _a, _b, _c, _d, _e;
80
- this._terminated = false;
81
- this.descriptors = {
82
- page: {},
83
- stream: {},
84
- longrunning: {},
85
- batching: {},
86
- };
87
101
  // Ensure that options include all the required fields.
88
102
  const staticMembers = this.constructor;
89
- if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
90
- (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
91
- (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
103
+ if (opts?.universe_domain &&
104
+ opts?.universeDomain &&
105
+ opts?.universe_domain !== opts?.universeDomain) {
92
106
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
93
107
  }
94
108
  const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
95
109
  ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
96
110
  : undefined;
97
111
  this._universeDomain =
98
- (_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';
112
+ opts?.universeDomain ??
113
+ opts?.universe_domain ??
114
+ universeDomainEnvVar ??
115
+ 'googleapis.com';
99
116
  this._servicePath = 'spanner.' + this._universeDomain;
100
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
101
- this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
102
- const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
103
- const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
104
- 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');
117
+ const servicePath = opts?.servicePath || opts?.apiEndpoint || this._servicePath;
118
+ this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint);
119
+ const port = opts?.port || staticMembers.port;
120
+ const clientConfig = opts?.clientConfig ?? {};
121
+ const fallback = opts?.fallback ??
122
+ (typeof window !== 'undefined' && typeof window?.fetch === 'function');
105
123
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
106
124
  // Request numeric enum values if REST transport is used.
107
125
  opts.numericEnums = true;
@@ -308,7 +326,6 @@ class SpannerClient {
308
326
  return this.auth.getProjectId();
309
327
  }
310
328
  createSession(request, optionsOrCallback, callback) {
311
- var _a;
312
329
  request = request || {};
313
330
  let options;
314
331
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -323,13 +340,26 @@ class SpannerClient {
323
340
  options.otherArgs.headers = options.otherArgs.headers || {};
324
341
  options.otherArgs.headers['x-goog-request-params'] =
325
342
  this._gaxModule.routingHeader.fromParams({
326
- database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
343
+ database: request.database ?? '',
327
344
  });
328
- this.initialize();
329
- return this.innerApiCalls.createSession(request, options, callback);
345
+ this.initialize().catch(err => {
346
+ throw err;
347
+ });
348
+ this._log.info('createSession request %j', request);
349
+ const wrappedCallback = callback
350
+ ? (error, response, options, rawResponse) => {
351
+ this._log.info('createSession response %j', response);
352
+ callback(error, response, options, rawResponse); // We verified callback above.
353
+ }
354
+ : undefined;
355
+ return this.innerApiCalls
356
+ .createSession(request, options, wrappedCallback)
357
+ ?.then(([response, options, rawResponse]) => {
358
+ this._log.info('createSession response %j', response);
359
+ return [response, options, rawResponse];
360
+ });
330
361
  }
331
362
  batchCreateSessions(request, optionsOrCallback, callback) {
332
- var _a;
333
363
  request = request || {};
334
364
  let options;
335
365
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -344,13 +374,26 @@ class SpannerClient {
344
374
  options.otherArgs.headers = options.otherArgs.headers || {};
345
375
  options.otherArgs.headers['x-goog-request-params'] =
346
376
  this._gaxModule.routingHeader.fromParams({
347
- database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
377
+ database: request.database ?? '',
348
378
  });
349
- this.initialize();
350
- return this.innerApiCalls.batchCreateSessions(request, options, callback);
379
+ this.initialize().catch(err => {
380
+ throw err;
381
+ });
382
+ this._log.info('batchCreateSessions request %j', request);
383
+ const wrappedCallback = callback
384
+ ? (error, response, options, rawResponse) => {
385
+ this._log.info('batchCreateSessions response %j', response);
386
+ callback(error, response, options, rawResponse); // We verified callback above.
387
+ }
388
+ : undefined;
389
+ return this.innerApiCalls
390
+ .batchCreateSessions(request, options, wrappedCallback)
391
+ ?.then(([response, options, rawResponse]) => {
392
+ this._log.info('batchCreateSessions response %j', response);
393
+ return [response, options, rawResponse];
394
+ });
351
395
  }
352
396
  getSession(request, optionsOrCallback, callback) {
353
- var _a;
354
397
  request = request || {};
355
398
  let options;
356
399
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -365,13 +408,26 @@ class SpannerClient {
365
408
  options.otherArgs.headers = options.otherArgs.headers || {};
366
409
  options.otherArgs.headers['x-goog-request-params'] =
367
410
  this._gaxModule.routingHeader.fromParams({
368
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
411
+ name: request.name ?? '',
369
412
  });
370
- this.initialize();
371
- return this.innerApiCalls.getSession(request, options, callback);
413
+ this.initialize().catch(err => {
414
+ throw err;
415
+ });
416
+ this._log.info('getSession request %j', request);
417
+ const wrappedCallback = callback
418
+ ? (error, response, options, rawResponse) => {
419
+ this._log.info('getSession response %j', response);
420
+ callback(error, response, options, rawResponse); // We verified callback above.
421
+ }
422
+ : undefined;
423
+ return this.innerApiCalls
424
+ .getSession(request, options, wrappedCallback)
425
+ ?.then(([response, options, rawResponse]) => {
426
+ this._log.info('getSession response %j', response);
427
+ return [response, options, rawResponse];
428
+ });
372
429
  }
373
430
  deleteSession(request, optionsOrCallback, callback) {
374
- var _a;
375
431
  request = request || {};
376
432
  let options;
377
433
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -386,13 +442,26 @@ class SpannerClient {
386
442
  options.otherArgs.headers = options.otherArgs.headers || {};
387
443
  options.otherArgs.headers['x-goog-request-params'] =
388
444
  this._gaxModule.routingHeader.fromParams({
389
- name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
445
+ name: request.name ?? '',
390
446
  });
391
- this.initialize();
392
- return this.innerApiCalls.deleteSession(request, options, callback);
447
+ this.initialize().catch(err => {
448
+ throw err;
449
+ });
450
+ this._log.info('deleteSession request %j', request);
451
+ const wrappedCallback = callback
452
+ ? (error, response, options, rawResponse) => {
453
+ this._log.info('deleteSession response %j', response);
454
+ callback(error, response, options, rawResponse); // We verified callback above.
455
+ }
456
+ : undefined;
457
+ return this.innerApiCalls
458
+ .deleteSession(request, options, wrappedCallback)
459
+ ?.then(([response, options, rawResponse]) => {
460
+ this._log.info('deleteSession response %j', response);
461
+ return [response, options, rawResponse];
462
+ });
393
463
  }
394
464
  executeSql(request, optionsOrCallback, callback) {
395
- var _a;
396
465
  request = request || {};
397
466
  let options;
398
467
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -407,13 +476,26 @@ class SpannerClient {
407
476
  options.otherArgs.headers = options.otherArgs.headers || {};
408
477
  options.otherArgs.headers['x-goog-request-params'] =
409
478
  this._gaxModule.routingHeader.fromParams({
410
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
479
+ session: request.session ?? '',
411
480
  });
412
- this.initialize();
413
- return this.innerApiCalls.executeSql(request, options, callback);
481
+ this.initialize().catch(err => {
482
+ throw err;
483
+ });
484
+ this._log.info('executeSql request %j', request);
485
+ const wrappedCallback = callback
486
+ ? (error, response, options, rawResponse) => {
487
+ this._log.info('executeSql response %j', response);
488
+ callback(error, response, options, rawResponse); // We verified callback above.
489
+ }
490
+ : undefined;
491
+ return this.innerApiCalls
492
+ .executeSql(request, options, wrappedCallback)
493
+ ?.then(([response, options, rawResponse]) => {
494
+ this._log.info('executeSql response %j', response);
495
+ return [response, options, rawResponse];
496
+ });
414
497
  }
415
498
  executeBatchDml(request, optionsOrCallback, callback) {
416
- var _a;
417
499
  request = request || {};
418
500
  let options;
419
501
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -428,13 +510,26 @@ class SpannerClient {
428
510
  options.otherArgs.headers = options.otherArgs.headers || {};
429
511
  options.otherArgs.headers['x-goog-request-params'] =
430
512
  this._gaxModule.routingHeader.fromParams({
431
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
513
+ session: request.session ?? '',
432
514
  });
433
- this.initialize();
434
- return this.innerApiCalls.executeBatchDml(request, options, callback);
515
+ this.initialize().catch(err => {
516
+ throw err;
517
+ });
518
+ this._log.info('executeBatchDml request %j', request);
519
+ const wrappedCallback = callback
520
+ ? (error, response, options, rawResponse) => {
521
+ this._log.info('executeBatchDml response %j', response);
522
+ callback(error, response, options, rawResponse); // We verified callback above.
523
+ }
524
+ : undefined;
525
+ return this.innerApiCalls
526
+ .executeBatchDml(request, options, wrappedCallback)
527
+ ?.then(([response, options, rawResponse]) => {
528
+ this._log.info('executeBatchDml response %j', response);
529
+ return [response, options, rawResponse];
530
+ });
435
531
  }
436
532
  read(request, optionsOrCallback, callback) {
437
- var _a;
438
533
  request = request || {};
439
534
  let options;
440
535
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -449,13 +544,26 @@ class SpannerClient {
449
544
  options.otherArgs.headers = options.otherArgs.headers || {};
450
545
  options.otherArgs.headers['x-goog-request-params'] =
451
546
  this._gaxModule.routingHeader.fromParams({
452
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
547
+ session: request.session ?? '',
453
548
  });
454
- this.initialize();
455
- return this.innerApiCalls.read(request, options, callback);
549
+ this.initialize().catch(err => {
550
+ throw err;
551
+ });
552
+ this._log.info('read request %j', request);
553
+ const wrappedCallback = callback
554
+ ? (error, response, options, rawResponse) => {
555
+ this._log.info('read response %j', response);
556
+ callback(error, response, options, rawResponse); // We verified callback above.
557
+ }
558
+ : undefined;
559
+ return this.innerApiCalls
560
+ .read(request, options, wrappedCallback)
561
+ ?.then(([response, options, rawResponse]) => {
562
+ this._log.info('read response %j', response);
563
+ return [response, options, rawResponse];
564
+ });
456
565
  }
457
566
  beginTransaction(request, optionsOrCallback, callback) {
458
- var _a;
459
567
  request = request || {};
460
568
  let options;
461
569
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -470,13 +578,26 @@ class SpannerClient {
470
578
  options.otherArgs.headers = options.otherArgs.headers || {};
471
579
  options.otherArgs.headers['x-goog-request-params'] =
472
580
  this._gaxModule.routingHeader.fromParams({
473
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
581
+ session: request.session ?? '',
474
582
  });
475
- this.initialize();
476
- return this.innerApiCalls.beginTransaction(request, options, callback);
583
+ this.initialize().catch(err => {
584
+ throw err;
585
+ });
586
+ this._log.info('beginTransaction request %j', request);
587
+ const wrappedCallback = callback
588
+ ? (error, response, options, rawResponse) => {
589
+ this._log.info('beginTransaction response %j', response);
590
+ callback(error, response, options, rawResponse); // We verified callback above.
591
+ }
592
+ : undefined;
593
+ return this.innerApiCalls
594
+ .beginTransaction(request, options, wrappedCallback)
595
+ ?.then(([response, options, rawResponse]) => {
596
+ this._log.info('beginTransaction response %j', response);
597
+ return [response, options, rawResponse];
598
+ });
477
599
  }
478
600
  commit(request, optionsOrCallback, callback) {
479
- var _a;
480
601
  request = request || {};
481
602
  let options;
482
603
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -491,13 +612,26 @@ class SpannerClient {
491
612
  options.otherArgs.headers = options.otherArgs.headers || {};
492
613
  options.otherArgs.headers['x-goog-request-params'] =
493
614
  this._gaxModule.routingHeader.fromParams({
494
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
615
+ session: request.session ?? '',
495
616
  });
496
- this.initialize();
497
- return this.innerApiCalls.commit(request, options, callback);
617
+ this.initialize().catch(err => {
618
+ throw err;
619
+ });
620
+ this._log.info('commit request %j', request);
621
+ const wrappedCallback = callback
622
+ ? (error, response, options, rawResponse) => {
623
+ this._log.info('commit response %j', response);
624
+ callback(error, response, options, rawResponse); // We verified callback above.
625
+ }
626
+ : undefined;
627
+ return this.innerApiCalls
628
+ .commit(request, options, wrappedCallback)
629
+ ?.then(([response, options, rawResponse]) => {
630
+ this._log.info('commit response %j', response);
631
+ return [response, options, rawResponse];
632
+ });
498
633
  }
499
634
  rollback(request, optionsOrCallback, callback) {
500
- var _a;
501
635
  request = request || {};
502
636
  let options;
503
637
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -512,13 +646,26 @@ class SpannerClient {
512
646
  options.otherArgs.headers = options.otherArgs.headers || {};
513
647
  options.otherArgs.headers['x-goog-request-params'] =
514
648
  this._gaxModule.routingHeader.fromParams({
515
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
649
+ session: request.session ?? '',
516
650
  });
517
- this.initialize();
518
- return this.innerApiCalls.rollback(request, options, callback);
651
+ this.initialize().catch(err => {
652
+ throw err;
653
+ });
654
+ this._log.info('rollback request %j', request);
655
+ const wrappedCallback = callback
656
+ ? (error, response, options, rawResponse) => {
657
+ this._log.info('rollback response %j', response);
658
+ callback(error, response, options, rawResponse); // We verified callback above.
659
+ }
660
+ : undefined;
661
+ return this.innerApiCalls
662
+ .rollback(request, options, wrappedCallback)
663
+ ?.then(([response, options, rawResponse]) => {
664
+ this._log.info('rollback response %j', response);
665
+ return [response, options, rawResponse];
666
+ });
519
667
  }
520
668
  partitionQuery(request, optionsOrCallback, callback) {
521
- var _a;
522
669
  request = request || {};
523
670
  let options;
524
671
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -533,13 +680,26 @@ class SpannerClient {
533
680
  options.otherArgs.headers = options.otherArgs.headers || {};
534
681
  options.otherArgs.headers['x-goog-request-params'] =
535
682
  this._gaxModule.routingHeader.fromParams({
536
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
683
+ session: request.session ?? '',
537
684
  });
538
- this.initialize();
539
- return this.innerApiCalls.partitionQuery(request, options, callback);
685
+ this.initialize().catch(err => {
686
+ throw err;
687
+ });
688
+ this._log.info('partitionQuery request %j', request);
689
+ const wrappedCallback = callback
690
+ ? (error, response, options, rawResponse) => {
691
+ this._log.info('partitionQuery response %j', response);
692
+ callback(error, response, options, rawResponse); // We verified callback above.
693
+ }
694
+ : undefined;
695
+ return this.innerApiCalls
696
+ .partitionQuery(request, options, wrappedCallback)
697
+ ?.then(([response, options, rawResponse]) => {
698
+ this._log.info('partitionQuery response %j', response);
699
+ return [response, options, rawResponse];
700
+ });
540
701
  }
541
702
  partitionRead(request, optionsOrCallback, callback) {
542
- var _a;
543
703
  request = request || {};
544
704
  let options;
545
705
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -554,10 +714,24 @@ class SpannerClient {
554
714
  options.otherArgs.headers = options.otherArgs.headers || {};
555
715
  options.otherArgs.headers['x-goog-request-params'] =
556
716
  this._gaxModule.routingHeader.fromParams({
557
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
717
+ session: request.session ?? '',
558
718
  });
559
- this.initialize();
560
- return this.innerApiCalls.partitionRead(request, options, callback);
719
+ this.initialize().catch(err => {
720
+ throw err;
721
+ });
722
+ this._log.info('partitionRead request %j', request);
723
+ const wrappedCallback = callback
724
+ ? (error, response, options, rawResponse) => {
725
+ this._log.info('partitionRead response %j', response);
726
+ callback(error, response, options, rawResponse); // We verified callback above.
727
+ }
728
+ : undefined;
729
+ return this.innerApiCalls
730
+ .partitionRead(request, options, wrappedCallback)
731
+ ?.then(([response, options, rawResponse]) => {
732
+ this._log.info('partitionRead response %j', response);
733
+ return [response, options, rawResponse];
734
+ });
561
735
  }
562
736
  /**
563
737
  * Like {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the
@@ -667,16 +841,18 @@ class SpannerClient {
667
841
  * for more details and examples.
668
842
  */
669
843
  executeStreamingSql(request, options) {
670
- var _a;
671
844
  request = request || {};
672
845
  options = options || {};
673
846
  options.otherArgs = options.otherArgs || {};
674
847
  options.otherArgs.headers = options.otherArgs.headers || {};
675
848
  options.otherArgs.headers['x-goog-request-params'] =
676
849
  this._gaxModule.routingHeader.fromParams({
677
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
850
+ session: request.session ?? '',
678
851
  });
679
- this.initialize();
852
+ this.initialize().catch(err => {
853
+ throw err;
854
+ });
855
+ this._log.info('executeStreamingSql stream %j', options);
680
856
  return this.innerApiCalls.executeStreamingSql(request, options);
681
857
  }
682
858
  /**
@@ -767,16 +943,18 @@ class SpannerClient {
767
943
  * for more details and examples.
768
944
  */
769
945
  streamingRead(request, options) {
770
- var _a;
771
946
  request = request || {};
772
947
  options = options || {};
773
948
  options.otherArgs = options.otherArgs || {};
774
949
  options.otherArgs.headers = options.otherArgs.headers || {};
775
950
  options.otherArgs.headers['x-goog-request-params'] =
776
951
  this._gaxModule.routingHeader.fromParams({
777
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
952
+ session: request.session ?? '',
778
953
  });
779
- this.initialize();
954
+ this.initialize().catch(err => {
955
+ throw err;
956
+ });
957
+ this._log.info('streamingRead stream %j', options);
780
958
  return this.innerApiCalls.streamingRead(request, options);
781
959
  }
782
960
  /**
@@ -825,20 +1003,21 @@ class SpannerClient {
825
1003
  * for more details and examples.
826
1004
  */
827
1005
  batchWrite(request, options) {
828
- var _a;
829
1006
  request = request || {};
830
1007
  options = options || {};
831
1008
  options.otherArgs = options.otherArgs || {};
832
1009
  options.otherArgs.headers = options.otherArgs.headers || {};
833
1010
  options.otherArgs.headers['x-goog-request-params'] =
834
1011
  this._gaxModule.routingHeader.fromParams({
835
- session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
1012
+ session: request.session ?? '',
836
1013
  });
837
- this.initialize();
1014
+ this.initialize().catch(err => {
1015
+ throw err;
1016
+ });
1017
+ this._log.info('batchWrite stream %j', options);
838
1018
  return this.innerApiCalls.batchWrite(request, options);
839
1019
  }
840
1020
  listSessions(request, optionsOrCallback, callback) {
841
- var _a;
842
1021
  request = request || {};
843
1022
  let options;
844
1023
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -853,10 +1032,24 @@ class SpannerClient {
853
1032
  options.otherArgs.headers = options.otherArgs.headers || {};
854
1033
  options.otherArgs.headers['x-goog-request-params'] =
855
1034
  this._gaxModule.routingHeader.fromParams({
856
- database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
1035
+ database: request.database ?? '',
857
1036
  });
858
- this.initialize();
859
- return this.innerApiCalls.listSessions(request, options, callback);
1037
+ this.initialize().catch(err => {
1038
+ throw err;
1039
+ });
1040
+ const wrappedCallback = callback
1041
+ ? (error, values, nextPageRequest, rawResponse) => {
1042
+ this._log.info('listSessions values %j', values);
1043
+ callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
1044
+ }
1045
+ : undefined;
1046
+ this._log.info('listSessions request %j', request);
1047
+ return this.innerApiCalls
1048
+ .listSessions(request, options, wrappedCallback)
1049
+ ?.then(([response, input, output]) => {
1050
+ this._log.info('listSessions values %j', response);
1051
+ return [response, input, output];
1052
+ });
860
1053
  }
861
1054
  /**
862
1055
  * Equivalent to `listSessions`, but returns a NodeJS Stream object.
@@ -895,18 +1088,20 @@ class SpannerClient {
895
1088
  * for more details and examples.
896
1089
  */
897
1090
  listSessionsStream(request, options) {
898
- var _a;
899
1091
  request = request || {};
900
1092
  options = options || {};
901
1093
  options.otherArgs = options.otherArgs || {};
902
1094
  options.otherArgs.headers = options.otherArgs.headers || {};
903
1095
  options.otherArgs.headers['x-goog-request-params'] =
904
1096
  this._gaxModule.routingHeader.fromParams({
905
- database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
1097
+ database: request.database ?? '',
906
1098
  });
907
1099
  const defaultCallSettings = this._defaults['listSessions'];
908
1100
  const callSettings = defaultCallSettings.merge(options);
909
- this.initialize();
1101
+ this.initialize().catch(err => {
1102
+ throw err;
1103
+ });
1104
+ this._log.info('listSessions stream %j', request);
910
1105
  return this.descriptors.page.listSessions.createStream(this.innerApiCalls.listSessions, request, callSettings);
911
1106
  }
912
1107
  /**
@@ -947,18 +1142,20 @@ class SpannerClient {
947
1142
  * for more details and examples.
948
1143
  */
949
1144
  listSessionsAsync(request, options) {
950
- var _a;
951
1145
  request = request || {};
952
1146
  options = options || {};
953
1147
  options.otherArgs = options.otherArgs || {};
954
1148
  options.otherArgs.headers = options.otherArgs.headers || {};
955
1149
  options.otherArgs.headers['x-goog-request-params'] =
956
1150
  this._gaxModule.routingHeader.fromParams({
957
- database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
1151
+ database: request.database ?? '',
958
1152
  });
959
1153
  const defaultCallSettings = this._defaults['listSessions'];
960
1154
  const callSettings = defaultCallSettings.merge(options);
961
- this.initialize();
1155
+ this.initialize().catch(err => {
1156
+ throw err;
1157
+ });
1158
+ this._log.info('listSessions iterate %j', request);
962
1159
  return this.descriptors.page.listSessions.asyncIterate(this.innerApiCalls['listSessions'], request, callSettings);
963
1160
  }
964
1161
  // --------------------
@@ -1075,6 +1272,7 @@ class SpannerClient {
1075
1272
  close() {
1076
1273
  if (this.spannerStub && !this._terminated) {
1077
1274
  return this.spannerStub.then(stub => {
1275
+ this._log.info('ending gRPC channel');
1078
1276
  this._terminated = true;
1079
1277
  stub.close();
1080
1278
  });
@@ -15,6 +15,7 @@ export declare class SpannerExecutorProxyClient {
15
15
  private _defaults;
16
16
  private _universeDomain;
17
17
  private _servicePath;
18
+ private _log;
18
19
  auth: gax.GoogleAuth;
19
20
  descriptors: Descriptors;
20
21
  warn: (code: string, message: string, warnType?: string) => void;
@@ -49,7 +50,7 @@ export declare class SpannerExecutorProxyClient {
49
50
  * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
50
51
  * the environment variable GCLOUD_PROJECT for your project ID. If your
51
52
  * app is running in an environment which supports
52
- * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
53
+ * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
53
54
  * your project ID will be detected automatically.
54
55
  * @param {string} [options.apiEndpoint] - The domain name of the
55
56
  * API remote host.