@google-cloud/spanner 6.1.4 → 6.3.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.
@@ -39,6 +39,22 @@
39
39
  "retry_codes_name": "idempotent",
40
40
  "retry_params_name": "e9fafda332ce8a1702dc1575de3ca81c4feb4799"
41
41
  },
42
+ "CreateInstanceConfig": {
43
+ "retry_codes_name": "non_idempotent",
44
+ "retry_params_name": "default"
45
+ },
46
+ "UpdateInstanceConfig": {
47
+ "retry_codes_name": "non_idempotent",
48
+ "retry_params_name": "default"
49
+ },
50
+ "DeleteInstanceConfig": {
51
+ "retry_codes_name": "non_idempotent",
52
+ "retry_params_name": "default"
53
+ },
54
+ "ListInstanceConfigOperations": {
55
+ "retry_codes_name": "non_idempotent",
56
+ "retry_params_name": "default"
57
+ },
42
58
  "ListInstances": {
43
59
  "timeout_millis": 3600000,
44
60
  "retry_codes_name": "idempotent",
@@ -1,3 +1,4 @@
1
1
  [
2
+ "../../protos/google/spanner/admin/instance/v1/common.proto",
2
3
  "../../protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto"
3
4
  ]
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import * as gax from 'google-gax';
3
- import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
2
+ import type * as gax from 'google-gax';
3
+ import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
4
4
  import { Transform } from 'stream';
5
5
  import * as protos from '../../protos/protos';
6
6
  /**
@@ -63,8 +63,15 @@ export declare class SpannerClient {
63
63
  * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
64
64
  * For more information, please check the
65
65
  * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
66
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
67
+ * need to avoid loading the default gRPC version and want to use the fallback
68
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
69
+ * ```
70
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
71
+ * const client = new SpannerClient({fallback: 'rest'}, gax);
72
+ * ```
66
73
  */
67
- constructor(opts?: ClientOptions);
74
+ constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
68
75
  /**
69
76
  * Initialize the client.
70
77
  * Performs asynchronous operations (such as authentication) and prepares the client.
@@ -18,9 +18,6 @@
18
18
  // ** All changes to this file may be overwritten. **
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.SpannerClient = void 0;
21
- /* global window */
22
- const gax = require("google-gax");
23
- const google_gax_1 = require("google-gax");
24
21
  const stream_1 = require("stream");
25
22
  const jsonProtos = require("../../protos/protos.json");
26
23
  /**
@@ -71,8 +68,15 @@ class SpannerClient {
71
68
  * Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
72
69
  * For more information, please check the
73
70
  * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
71
+ * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
72
+ * need to avoid loading the default gRPC version and want to use the fallback
73
+ * HTTP implementation. Load only fallback version and pass it to the constructor:
74
+ * ```
75
+ * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
76
+ * const client = new SpannerClient({fallback: 'rest'}, gax);
77
+ * ```
74
78
  */
75
- constructor(opts) {
79
+ constructor(opts, gaxInstance) {
76
80
  var _a, _b;
77
81
  this._terminated = false;
78
82
  this.descriptors = {
@@ -93,8 +97,12 @@ class SpannerClient {
93
97
  if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
94
98
  opts['scopes'] = staticMembers.scopes;
95
99
  }
100
+ // Load google-gax module synchronously if needed
101
+ if (!gaxInstance) {
102
+ gaxInstance = require('google-gax');
103
+ }
96
104
  // Choose either gRPC or proto-over-HTTP implementation of google-gax.
97
- this._gaxModule = opts.fallback ? gax.fallback : gax;
105
+ this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
98
106
  // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
99
107
  this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
100
108
  // Save options to use in initialize() method.
@@ -144,8 +152,8 @@ class SpannerClient {
144
152
  // Some of the methods on this service provide streaming responses.
145
153
  // Provide descriptors for these.
146
154
  this.descriptors.stream = {
147
- executeStreamingSql: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
148
- streamingRead: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
155
+ executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
156
+ streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
149
157
  };
150
158
  // Put together the default options sent with requests.
151
159
  this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -154,7 +162,7 @@ class SpannerClient {
154
162
  // merely providing the destination and request information.
155
163
  this.innerApiCalls = {};
156
164
  // Add a warn function to the client constructor so it can be easily tested.
157
- this.warn = gax.warn;
165
+ this.warn = this._gaxModule.warn;
158
166
  }
159
167
  /**
160
168
  * Initialize the client.
@@ -203,7 +211,7 @@ class SpannerClient {
203
211
  if (methodName in this.descriptors.stream) {
204
212
  const stream = new stream_1.PassThrough();
205
213
  setImmediate(() => {
206
- stream.emit('error', new google_gax_1.GoogleError('The client has already been closed.'));
214
+ stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
207
215
  });
208
216
  return stream;
209
217
  }
@@ -267,6 +275,7 @@ class SpannerClient {
267
275
  return this.auth.getProjectId();
268
276
  }
269
277
  createSession(request, optionsOrCallback, callback) {
278
+ var _a;
270
279
  request = request || {};
271
280
  let options;
272
281
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -280,13 +289,14 @@ class SpannerClient {
280
289
  options.otherArgs = options.otherArgs || {};
281
290
  options.otherArgs.headers = options.otherArgs.headers || {};
282
291
  options.otherArgs.headers['x-goog-request-params'] =
283
- gax.routingHeader.fromParams({
284
- database: request.database || '',
292
+ this._gaxModule.routingHeader.fromParams({
293
+ database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
285
294
  });
286
295
  this.initialize();
287
296
  return this.innerApiCalls.createSession(request, options, callback);
288
297
  }
289
298
  batchCreateSessions(request, optionsOrCallback, callback) {
299
+ var _a;
290
300
  request = request || {};
291
301
  let options;
292
302
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -300,13 +310,14 @@ class SpannerClient {
300
310
  options.otherArgs = options.otherArgs || {};
301
311
  options.otherArgs.headers = options.otherArgs.headers || {};
302
312
  options.otherArgs.headers['x-goog-request-params'] =
303
- gax.routingHeader.fromParams({
304
- database: request.database || '',
313
+ this._gaxModule.routingHeader.fromParams({
314
+ database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
305
315
  });
306
316
  this.initialize();
307
317
  return this.innerApiCalls.batchCreateSessions(request, options, callback);
308
318
  }
309
319
  getSession(request, optionsOrCallback, callback) {
320
+ var _a;
310
321
  request = request || {};
311
322
  let options;
312
323
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -320,13 +331,14 @@ class SpannerClient {
320
331
  options.otherArgs = options.otherArgs || {};
321
332
  options.otherArgs.headers = options.otherArgs.headers || {};
322
333
  options.otherArgs.headers['x-goog-request-params'] =
323
- gax.routingHeader.fromParams({
324
- name: request.name || '',
334
+ this._gaxModule.routingHeader.fromParams({
335
+ name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
325
336
  });
326
337
  this.initialize();
327
338
  return this.innerApiCalls.getSession(request, options, callback);
328
339
  }
329
340
  deleteSession(request, optionsOrCallback, callback) {
341
+ var _a;
330
342
  request = request || {};
331
343
  let options;
332
344
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -340,13 +352,14 @@ class SpannerClient {
340
352
  options.otherArgs = options.otherArgs || {};
341
353
  options.otherArgs.headers = options.otherArgs.headers || {};
342
354
  options.otherArgs.headers['x-goog-request-params'] =
343
- gax.routingHeader.fromParams({
344
- name: request.name || '',
355
+ this._gaxModule.routingHeader.fromParams({
356
+ name: (_a = request.name) !== null && _a !== void 0 ? _a : '',
345
357
  });
346
358
  this.initialize();
347
359
  return this.innerApiCalls.deleteSession(request, options, callback);
348
360
  }
349
361
  executeSql(request, optionsOrCallback, callback) {
362
+ var _a;
350
363
  request = request || {};
351
364
  let options;
352
365
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -360,13 +373,14 @@ class SpannerClient {
360
373
  options.otherArgs = options.otherArgs || {};
361
374
  options.otherArgs.headers = options.otherArgs.headers || {};
362
375
  options.otherArgs.headers['x-goog-request-params'] =
363
- gax.routingHeader.fromParams({
364
- session: request.session || '',
376
+ this._gaxModule.routingHeader.fromParams({
377
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
365
378
  });
366
379
  this.initialize();
367
380
  return this.innerApiCalls.executeSql(request, options, callback);
368
381
  }
369
382
  executeBatchDml(request, optionsOrCallback, callback) {
383
+ var _a;
370
384
  request = request || {};
371
385
  let options;
372
386
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -380,13 +394,14 @@ class SpannerClient {
380
394
  options.otherArgs = options.otherArgs || {};
381
395
  options.otherArgs.headers = options.otherArgs.headers || {};
382
396
  options.otherArgs.headers['x-goog-request-params'] =
383
- gax.routingHeader.fromParams({
384
- session: request.session || '',
397
+ this._gaxModule.routingHeader.fromParams({
398
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
385
399
  });
386
400
  this.initialize();
387
401
  return this.innerApiCalls.executeBatchDml(request, options, callback);
388
402
  }
389
403
  read(request, optionsOrCallback, callback) {
404
+ var _a;
390
405
  request = request || {};
391
406
  let options;
392
407
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -400,13 +415,14 @@ class SpannerClient {
400
415
  options.otherArgs = options.otherArgs || {};
401
416
  options.otherArgs.headers = options.otherArgs.headers || {};
402
417
  options.otherArgs.headers['x-goog-request-params'] =
403
- gax.routingHeader.fromParams({
404
- session: request.session || '',
418
+ this._gaxModule.routingHeader.fromParams({
419
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
405
420
  });
406
421
  this.initialize();
407
422
  return this.innerApiCalls.read(request, options, callback);
408
423
  }
409
424
  beginTransaction(request, optionsOrCallback, callback) {
425
+ var _a;
410
426
  request = request || {};
411
427
  let options;
412
428
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -420,13 +436,14 @@ class SpannerClient {
420
436
  options.otherArgs = options.otherArgs || {};
421
437
  options.otherArgs.headers = options.otherArgs.headers || {};
422
438
  options.otherArgs.headers['x-goog-request-params'] =
423
- gax.routingHeader.fromParams({
424
- session: request.session || '',
439
+ this._gaxModule.routingHeader.fromParams({
440
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
425
441
  });
426
442
  this.initialize();
427
443
  return this.innerApiCalls.beginTransaction(request, options, callback);
428
444
  }
429
445
  commit(request, optionsOrCallback, callback) {
446
+ var _a;
430
447
  request = request || {};
431
448
  let options;
432
449
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -440,13 +457,14 @@ class SpannerClient {
440
457
  options.otherArgs = options.otherArgs || {};
441
458
  options.otherArgs.headers = options.otherArgs.headers || {};
442
459
  options.otherArgs.headers['x-goog-request-params'] =
443
- gax.routingHeader.fromParams({
444
- session: request.session || '',
460
+ this._gaxModule.routingHeader.fromParams({
461
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
445
462
  });
446
463
  this.initialize();
447
464
  return this.innerApiCalls.commit(request, options, callback);
448
465
  }
449
466
  rollback(request, optionsOrCallback, callback) {
467
+ var _a;
450
468
  request = request || {};
451
469
  let options;
452
470
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -460,13 +478,14 @@ class SpannerClient {
460
478
  options.otherArgs = options.otherArgs || {};
461
479
  options.otherArgs.headers = options.otherArgs.headers || {};
462
480
  options.otherArgs.headers['x-goog-request-params'] =
463
- gax.routingHeader.fromParams({
464
- session: request.session || '',
481
+ this._gaxModule.routingHeader.fromParams({
482
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
465
483
  });
466
484
  this.initialize();
467
485
  return this.innerApiCalls.rollback(request, options, callback);
468
486
  }
469
487
  partitionQuery(request, optionsOrCallback, callback) {
488
+ var _a;
470
489
  request = request || {};
471
490
  let options;
472
491
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -480,13 +499,14 @@ class SpannerClient {
480
499
  options.otherArgs = options.otherArgs || {};
481
500
  options.otherArgs.headers = options.otherArgs.headers || {};
482
501
  options.otherArgs.headers['x-goog-request-params'] =
483
- gax.routingHeader.fromParams({
484
- session: request.session || '',
502
+ this._gaxModule.routingHeader.fromParams({
503
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
485
504
  });
486
505
  this.initialize();
487
506
  return this.innerApiCalls.partitionQuery(request, options, callback);
488
507
  }
489
508
  partitionRead(request, optionsOrCallback, callback) {
509
+ var _a;
490
510
  request = request || {};
491
511
  let options;
492
512
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -500,8 +520,8 @@ class SpannerClient {
500
520
  options.otherArgs = options.otherArgs || {};
501
521
  options.otherArgs.headers = options.otherArgs.headers || {};
502
522
  options.otherArgs.headers['x-goog-request-params'] =
503
- gax.routingHeader.fromParams({
504
- session: request.session || '',
523
+ this._gaxModule.routingHeader.fromParams({
524
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
505
525
  });
506
526
  this.initialize();
507
527
  return this.innerApiCalls.partitionRead(request, options, callback);
@@ -593,13 +613,14 @@ class SpannerClient {
593
613
  * for more details and examples.
594
614
  */
595
615
  executeStreamingSql(request, options) {
616
+ var _a;
596
617
  request = request || {};
597
618
  options = options || {};
598
619
  options.otherArgs = options.otherArgs || {};
599
620
  options.otherArgs.headers = options.otherArgs.headers || {};
600
621
  options.otherArgs.headers['x-goog-request-params'] =
601
- gax.routingHeader.fromParams({
602
- session: request.session || '',
622
+ this._gaxModule.routingHeader.fromParams({
623
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
603
624
  });
604
625
  this.initialize();
605
626
  return this.innerApiCalls.executeStreamingSql(request, options);
@@ -667,18 +688,20 @@ class SpannerClient {
667
688
  * for more details and examples.
668
689
  */
669
690
  streamingRead(request, options) {
691
+ var _a;
670
692
  request = request || {};
671
693
  options = options || {};
672
694
  options.otherArgs = options.otherArgs || {};
673
695
  options.otherArgs.headers = options.otherArgs.headers || {};
674
696
  options.otherArgs.headers['x-goog-request-params'] =
675
- gax.routingHeader.fromParams({
676
- session: request.session || '',
697
+ this._gaxModule.routingHeader.fromParams({
698
+ session: (_a = request.session) !== null && _a !== void 0 ? _a : '',
677
699
  });
678
700
  this.initialize();
679
701
  return this.innerApiCalls.streamingRead(request, options);
680
702
  }
681
703
  listSessions(request, optionsOrCallback, callback) {
704
+ var _a;
682
705
  request = request || {};
683
706
  let options;
684
707
  if (typeof optionsOrCallback === 'function' && callback === undefined) {
@@ -692,8 +715,8 @@ class SpannerClient {
692
715
  options.otherArgs = options.otherArgs || {};
693
716
  options.otherArgs.headers = options.otherArgs.headers || {};
694
717
  options.otherArgs.headers['x-goog-request-params'] =
695
- gax.routingHeader.fromParams({
696
- database: request.database || '',
718
+ this._gaxModule.routingHeader.fromParams({
719
+ database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
697
720
  });
698
721
  this.initialize();
699
722
  return this.innerApiCalls.listSessions(request, options, callback);
@@ -735,13 +758,14 @@ class SpannerClient {
735
758
  * for more details and examples.
736
759
  */
737
760
  listSessionsStream(request, options) {
761
+ var _a;
738
762
  request = request || {};
739
763
  options = options || {};
740
764
  options.otherArgs = options.otherArgs || {};
741
765
  options.otherArgs.headers = options.otherArgs.headers || {};
742
766
  options.otherArgs.headers['x-goog-request-params'] =
743
- gax.routingHeader.fromParams({
744
- database: request.database || '',
767
+ this._gaxModule.routingHeader.fromParams({
768
+ database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
745
769
  });
746
770
  const defaultCallSettings = this._defaults['listSessions'];
747
771
  const callSettings = defaultCallSettings.merge(options);
@@ -786,13 +810,14 @@ class SpannerClient {
786
810
  * for more details and examples.
787
811
  */
788
812
  listSessionsAsync(request, options) {
813
+ var _a;
789
814
  request = request || {};
790
815
  options = options || {};
791
816
  options.otherArgs = options.otherArgs || {};
792
817
  options.otherArgs.headers = options.otherArgs.headers || {};
793
818
  options.otherArgs.headers['x-goog-request-params'] =
794
- gax.routingHeader.fromParams({
795
- database: request.database || '',
819
+ this._gaxModule.routingHeader.fromParams({
820
+ database: (_a = request.database) !== null && _a !== void 0 ? _a : '',
796
821
  });
797
822
  const defaultCallSettings = this._defaults['listSessions'];
798
823
  const callSettings = defaultCallSettings.merge(options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "6.1.4",
4
+ "version": "6.3.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -51,31 +51,34 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@google-cloud/common": "^4.0.0",
54
- "@google-cloud/precise-date": "^2.0.0",
54
+ "@google-cloud/precise-date": "^3.0.0",
55
55
  "@google-cloud/projectify": "^3.0.0",
56
56
  "@google-cloud/promisify": "^3.0.0",
57
+ "@grpc/proto-loader": "^0.7.0",
57
58
  "@types/big.js": "^6.0.0",
58
59
  "@types/stack-trace": "0.0.29",
59
60
  "arrify": "^2.0.0",
60
61
  "big.js": "^6.0.0",
61
62
  "checkpoint-stream": "^0.1.1",
63
+ "duplexify": "^4.1.1",
62
64
  "events-intercept": "^2.0.0",
63
65
  "extend": "^3.0.2",
64
66
  "google-auth-library": "^8.0.2",
65
- "google-gax": "^3.0.1",
66
- "grpc-gcp": "^0.4.0",
67
+ "google-gax": "^3.3.0",
68
+ "grpc-gcp": "^1.0.0",
67
69
  "is": "^3.2.1",
68
70
  "lodash.snakecase": "^4.1.1",
69
71
  "merge-stream": "^2.0.0",
70
72
  "p-queue": "^6.0.2",
71
73
  "protobufjs": "^7.0.0",
74
+ "retry-request": "^5.0.0",
72
75
  "split-array-stream": "^2.0.0",
73
76
  "stack-trace": "0.0.10",
74
77
  "stream-events": "^1.0.4",
78
+ "teeny-request": "^8.0.0",
75
79
  "through2": "^4.0.0"
76
80
  },
77
81
  "devDependencies": {
78
- "@grpc/proto-loader": "^0.7.0",
79
82
  "@types/concat-stream": "^2.0.0",
80
83
  "@types/extend": "^3.0.0",
81
84
  "@types/is": "0.0.21",
@@ -94,27 +97,24 @@
94
97
  "codecov": "^3.0.2",
95
98
  "concat-stream": "^2.0.0",
96
99
  "dedent": "^0.7.0",
97
- "duplexify": "^4.1.1",
98
100
  "execa": "^5.0.0",
99
101
  "gts": "^3.1.0",
100
102
  "jsdoc": "^3.6.2",
101
103
  "jsdoc-fresh": "^2.0.0",
102
104
  "jsdoc-region-tag": "^2.0.0",
103
- "linkinator": "^2.0.0",
105
+ "linkinator": "^4.0.0",
104
106
  "lodash.random": "^3.2.0",
105
107
  "mocha": "^9.2.2",
106
108
  "mv": "^2.1.1",
107
109
  "ncp": "^2.0.0",
108
110
  "p-limit": "^3.0.1",
109
111
  "proxyquire": "^2.0.1",
110
- "retry-request": "^5.0.0",
111
112
  "sinon": "^14.0.0",
112
113
  "stats-lite": "^2.1.1",
113
- "teeny-request": "^8.0.0",
114
114
  "time-span": "^4.0.0",
115
115
  "tmp": "^0.2.0",
116
116
  "typescript": "^4.6.4",
117
- "uuid": "^8.0.0",
117
+ "uuid": "^9.0.0",
118
118
  "yargs": "^17.0.0"
119
119
  }
120
120
  }