@google-cloud/spanner 7.21.0 → 8.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.
- package/README.md +2 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/common.proto +1 -1
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +36 -1
- package/build/protos/google/spanner/admin/instance/v1/common.proto +1 -1
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +1 -1
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1 -1
- package/build/protos/google/spanner/v1/change_stream.proto +451 -0
- package/build/protos/google/spanner/v1/commit_response.proto +10 -5
- package/build/protos/google/spanner/v1/keys.proto +1 -1
- package/build/protos/google/spanner/v1/mutation.proto +1 -1
- package/build/protos/google/spanner/v1/query_plan.proto +1 -1
- package/build/protos/google/spanner/v1/result_set.proto +55 -49
- package/build/protos/google/spanner/v1/spanner.proto +1 -1
- package/build/protos/google/spanner/v1/transaction.proto +41 -357
- package/build/protos/google/spanner/v1/type.proto +1 -1
- package/build/protos/protos.d.ts +1577 -194
- package/build/protos/protos.js +3977 -288
- package/build/protos/protos.json +325 -3
- package/build/src/backup.js +7 -0
- package/build/src/batch-transaction.d.ts +48 -29
- package/build/src/batch-transaction.js +15 -100
- package/build/src/codec.js +63 -47
- package/build/src/common-grpc/service-object.js +1 -0
- package/build/src/common-grpc/service.js +35 -18
- package/build/src/common.d.ts +1 -0
- package/build/src/common.js +9 -1
- package/build/src/database.d.ts +1 -0
- package/build/src/database.js +54 -42
- package/build/src/helper.d.ts +99 -0
- package/build/src/helper.js +178 -0
- package/build/src/index.d.ts +33 -0
- package/build/src/index.js +202 -21
- package/build/src/instance-config.d.ts +1 -1
- package/build/src/instance-config.js +4 -0
- package/build/src/instance.js +12 -6
- package/build/src/instrument.js +5 -6
- package/build/src/metrics/constants.d.ts +36 -0
- package/build/src/metrics/constants.js +106 -0
- package/build/src/metrics/external-types.d.ts +20 -0
- package/build/src/metrics/external-types.js +32 -0
- package/build/src/metrics/interceptor.d.ts +13 -0
- package/build/src/metrics/interceptor.js +87 -0
- package/build/src/metrics/metrics-tracer-factory.d.ts +165 -0
- package/build/src/metrics/metrics-tracer-factory.js +389 -0
- package/build/src/metrics/metrics-tracer.d.ts +204 -0
- package/build/src/metrics/metrics-tracer.js +371 -0
- package/build/src/metrics/spanner-metrics-exporter.d.ts +35 -0
- package/build/src/metrics/spanner-metrics-exporter.js +119 -0
- package/build/src/metrics/transform.d.ts +144 -0
- package/build/src/metrics/transform.js +272 -0
- package/build/src/multiplexed-session.js +7 -1
- package/build/src/partial-result-stream.js +18 -10
- package/build/src/request_id_header.js +1 -0
- package/build/src/session-factory.d.ts +34 -0
- package/build/src/session-factory.js +35 -2
- package/build/src/session-pool.js +24 -8
- package/build/src/session.d.ts +0 -1
- package/build/src/session.js +7 -2
- package/build/src/table.js +6 -3
- package/build/src/transaction-runner.d.ts +1 -0
- package/build/src/transaction-runner.js +18 -2
- package/build/src/transaction.d.ts +42 -1
- package/build/src/transaction.js +258 -94
- package/build/src/v1/database_admin_client.d.ts +37 -2
- package/build/src/v1/database_admin_client.js +718 -168
- package/build/src/v1/database_admin_client_config.json +4 -0
- package/build/src/v1/instance_admin_client.d.ts +122 -1
- package/build/src/v1/instance_admin_client.js +765 -146
- package/build/src/v1/spanner_client.d.ts +2 -1
- package/build/src/v1/spanner_client.js +391 -85
- package/build/src/v1/spanner_executor_proxy_client.d.ts +2 -1
- package/build/src/v1/spanner_executor_proxy_client.js +41 -19
- package/build/src/v1/spanner_proto_list.json +1 -0
- package/package.json +64 -58
|
@@ -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://
|
|
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 (
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
112
|
+
opts?.universeDomain ??
|
|
113
|
+
opts?.universe_domain ??
|
|
114
|
+
universeDomainEnvVar ??
|
|
115
|
+
'googleapis.com';
|
|
99
116
|
this._servicePath = 'spanner.' + this._universeDomain;
|
|
100
|
-
const servicePath =
|
|
101
|
-
this._providedCustomServicePath = !!(
|
|
102
|
-
const port =
|
|
103
|
-
const clientConfig =
|
|
104
|
-
const fallback =
|
|
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,35 @@ 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:
|
|
343
|
+
database: request.database ?? '',
|
|
327
344
|
});
|
|
328
|
-
this.initialize()
|
|
329
|
-
|
|
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
|
+
})
|
|
361
|
+
.catch((error) => {
|
|
362
|
+
if (error &&
|
|
363
|
+
'statusDetails' in error &&
|
|
364
|
+
error.statusDetails instanceof Array) {
|
|
365
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
366
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
367
|
+
}
|
|
368
|
+
throw error;
|
|
369
|
+
});
|
|
330
370
|
}
|
|
331
371
|
batchCreateSessions(request, optionsOrCallback, callback) {
|
|
332
|
-
var _a;
|
|
333
372
|
request = request || {};
|
|
334
373
|
let options;
|
|
335
374
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -344,13 +383,35 @@ class SpannerClient {
|
|
|
344
383
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
345
384
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
346
385
|
this._gaxModule.routingHeader.fromParams({
|
|
347
|
-
database:
|
|
386
|
+
database: request.database ?? '',
|
|
348
387
|
});
|
|
349
|
-
this.initialize()
|
|
350
|
-
|
|
388
|
+
this.initialize().catch(err => {
|
|
389
|
+
throw err;
|
|
390
|
+
});
|
|
391
|
+
this._log.info('batchCreateSessions request %j', request);
|
|
392
|
+
const wrappedCallback = callback
|
|
393
|
+
? (error, response, options, rawResponse) => {
|
|
394
|
+
this._log.info('batchCreateSessions response %j', response);
|
|
395
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
396
|
+
}
|
|
397
|
+
: undefined;
|
|
398
|
+
return this.innerApiCalls
|
|
399
|
+
.batchCreateSessions(request, options, wrappedCallback)
|
|
400
|
+
?.then(([response, options, rawResponse]) => {
|
|
401
|
+
this._log.info('batchCreateSessions response %j', response);
|
|
402
|
+
return [response, options, rawResponse];
|
|
403
|
+
})
|
|
404
|
+
.catch((error) => {
|
|
405
|
+
if (error &&
|
|
406
|
+
'statusDetails' in error &&
|
|
407
|
+
error.statusDetails instanceof Array) {
|
|
408
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
409
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
410
|
+
}
|
|
411
|
+
throw error;
|
|
412
|
+
});
|
|
351
413
|
}
|
|
352
414
|
getSession(request, optionsOrCallback, callback) {
|
|
353
|
-
var _a;
|
|
354
415
|
request = request || {};
|
|
355
416
|
let options;
|
|
356
417
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -365,13 +426,35 @@ class SpannerClient {
|
|
|
365
426
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
366
427
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
367
428
|
this._gaxModule.routingHeader.fromParams({
|
|
368
|
-
name:
|
|
429
|
+
name: request.name ?? '',
|
|
369
430
|
});
|
|
370
|
-
this.initialize()
|
|
371
|
-
|
|
431
|
+
this.initialize().catch(err => {
|
|
432
|
+
throw err;
|
|
433
|
+
});
|
|
434
|
+
this._log.info('getSession request %j', request);
|
|
435
|
+
const wrappedCallback = callback
|
|
436
|
+
? (error, response, options, rawResponse) => {
|
|
437
|
+
this._log.info('getSession response %j', response);
|
|
438
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
439
|
+
}
|
|
440
|
+
: undefined;
|
|
441
|
+
return this.innerApiCalls
|
|
442
|
+
.getSession(request, options, wrappedCallback)
|
|
443
|
+
?.then(([response, options, rawResponse]) => {
|
|
444
|
+
this._log.info('getSession response %j', response);
|
|
445
|
+
return [response, options, rawResponse];
|
|
446
|
+
})
|
|
447
|
+
.catch((error) => {
|
|
448
|
+
if (error &&
|
|
449
|
+
'statusDetails' in error &&
|
|
450
|
+
error.statusDetails instanceof Array) {
|
|
451
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
452
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
453
|
+
}
|
|
454
|
+
throw error;
|
|
455
|
+
});
|
|
372
456
|
}
|
|
373
457
|
deleteSession(request, optionsOrCallback, callback) {
|
|
374
|
-
var _a;
|
|
375
458
|
request = request || {};
|
|
376
459
|
let options;
|
|
377
460
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -386,13 +469,35 @@ class SpannerClient {
|
|
|
386
469
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
387
470
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
388
471
|
this._gaxModule.routingHeader.fromParams({
|
|
389
|
-
name:
|
|
472
|
+
name: request.name ?? '',
|
|
390
473
|
});
|
|
391
|
-
this.initialize()
|
|
392
|
-
|
|
474
|
+
this.initialize().catch(err => {
|
|
475
|
+
throw err;
|
|
476
|
+
});
|
|
477
|
+
this._log.info('deleteSession request %j', request);
|
|
478
|
+
const wrappedCallback = callback
|
|
479
|
+
? (error, response, options, rawResponse) => {
|
|
480
|
+
this._log.info('deleteSession response %j', response);
|
|
481
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
482
|
+
}
|
|
483
|
+
: undefined;
|
|
484
|
+
return this.innerApiCalls
|
|
485
|
+
.deleteSession(request, options, wrappedCallback)
|
|
486
|
+
?.then(([response, options, rawResponse]) => {
|
|
487
|
+
this._log.info('deleteSession response %j', response);
|
|
488
|
+
return [response, options, rawResponse];
|
|
489
|
+
})
|
|
490
|
+
.catch((error) => {
|
|
491
|
+
if (error &&
|
|
492
|
+
'statusDetails' in error &&
|
|
493
|
+
error.statusDetails instanceof Array) {
|
|
494
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
495
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
496
|
+
}
|
|
497
|
+
throw error;
|
|
498
|
+
});
|
|
393
499
|
}
|
|
394
500
|
executeSql(request, optionsOrCallback, callback) {
|
|
395
|
-
var _a;
|
|
396
501
|
request = request || {};
|
|
397
502
|
let options;
|
|
398
503
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -407,13 +512,35 @@ class SpannerClient {
|
|
|
407
512
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
408
513
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
409
514
|
this._gaxModule.routingHeader.fromParams({
|
|
410
|
-
session:
|
|
515
|
+
session: request.session ?? '',
|
|
411
516
|
});
|
|
412
|
-
this.initialize()
|
|
413
|
-
|
|
517
|
+
this.initialize().catch(err => {
|
|
518
|
+
throw err;
|
|
519
|
+
});
|
|
520
|
+
this._log.info('executeSql request %j', request);
|
|
521
|
+
const wrappedCallback = callback
|
|
522
|
+
? (error, response, options, rawResponse) => {
|
|
523
|
+
this._log.info('executeSql response %j', response);
|
|
524
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
525
|
+
}
|
|
526
|
+
: undefined;
|
|
527
|
+
return this.innerApiCalls
|
|
528
|
+
.executeSql(request, options, wrappedCallback)
|
|
529
|
+
?.then(([response, options, rawResponse]) => {
|
|
530
|
+
this._log.info('executeSql response %j', response);
|
|
531
|
+
return [response, options, rawResponse];
|
|
532
|
+
})
|
|
533
|
+
.catch((error) => {
|
|
534
|
+
if (error &&
|
|
535
|
+
'statusDetails' in error &&
|
|
536
|
+
error.statusDetails instanceof Array) {
|
|
537
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
538
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
539
|
+
}
|
|
540
|
+
throw error;
|
|
541
|
+
});
|
|
414
542
|
}
|
|
415
543
|
executeBatchDml(request, optionsOrCallback, callback) {
|
|
416
|
-
var _a;
|
|
417
544
|
request = request || {};
|
|
418
545
|
let options;
|
|
419
546
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -428,13 +555,35 @@ class SpannerClient {
|
|
|
428
555
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
429
556
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
430
557
|
this._gaxModule.routingHeader.fromParams({
|
|
431
|
-
session:
|
|
558
|
+
session: request.session ?? '',
|
|
432
559
|
});
|
|
433
|
-
this.initialize()
|
|
434
|
-
|
|
560
|
+
this.initialize().catch(err => {
|
|
561
|
+
throw err;
|
|
562
|
+
});
|
|
563
|
+
this._log.info('executeBatchDml request %j', request);
|
|
564
|
+
const wrappedCallback = callback
|
|
565
|
+
? (error, response, options, rawResponse) => {
|
|
566
|
+
this._log.info('executeBatchDml response %j', response);
|
|
567
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
568
|
+
}
|
|
569
|
+
: undefined;
|
|
570
|
+
return this.innerApiCalls
|
|
571
|
+
.executeBatchDml(request, options, wrappedCallback)
|
|
572
|
+
?.then(([response, options, rawResponse]) => {
|
|
573
|
+
this._log.info('executeBatchDml response %j', response);
|
|
574
|
+
return [response, options, rawResponse];
|
|
575
|
+
})
|
|
576
|
+
.catch((error) => {
|
|
577
|
+
if (error &&
|
|
578
|
+
'statusDetails' in error &&
|
|
579
|
+
error.statusDetails instanceof Array) {
|
|
580
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
581
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
582
|
+
}
|
|
583
|
+
throw error;
|
|
584
|
+
});
|
|
435
585
|
}
|
|
436
586
|
read(request, optionsOrCallback, callback) {
|
|
437
|
-
var _a;
|
|
438
587
|
request = request || {};
|
|
439
588
|
let options;
|
|
440
589
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -449,13 +598,35 @@ class SpannerClient {
|
|
|
449
598
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
450
599
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
451
600
|
this._gaxModule.routingHeader.fromParams({
|
|
452
|
-
session:
|
|
601
|
+
session: request.session ?? '',
|
|
453
602
|
});
|
|
454
|
-
this.initialize()
|
|
455
|
-
|
|
603
|
+
this.initialize().catch(err => {
|
|
604
|
+
throw err;
|
|
605
|
+
});
|
|
606
|
+
this._log.info('read request %j', request);
|
|
607
|
+
const wrappedCallback = callback
|
|
608
|
+
? (error, response, options, rawResponse) => {
|
|
609
|
+
this._log.info('read response %j', response);
|
|
610
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
611
|
+
}
|
|
612
|
+
: undefined;
|
|
613
|
+
return this.innerApiCalls
|
|
614
|
+
.read(request, options, wrappedCallback)
|
|
615
|
+
?.then(([response, options, rawResponse]) => {
|
|
616
|
+
this._log.info('read response %j', response);
|
|
617
|
+
return [response, options, rawResponse];
|
|
618
|
+
})
|
|
619
|
+
.catch((error) => {
|
|
620
|
+
if (error &&
|
|
621
|
+
'statusDetails' in error &&
|
|
622
|
+
error.statusDetails instanceof Array) {
|
|
623
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
624
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
625
|
+
}
|
|
626
|
+
throw error;
|
|
627
|
+
});
|
|
456
628
|
}
|
|
457
629
|
beginTransaction(request, optionsOrCallback, callback) {
|
|
458
|
-
var _a;
|
|
459
630
|
request = request || {};
|
|
460
631
|
let options;
|
|
461
632
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -470,13 +641,35 @@ class SpannerClient {
|
|
|
470
641
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
471
642
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
472
643
|
this._gaxModule.routingHeader.fromParams({
|
|
473
|
-
session:
|
|
644
|
+
session: request.session ?? '',
|
|
474
645
|
});
|
|
475
|
-
this.initialize()
|
|
476
|
-
|
|
646
|
+
this.initialize().catch(err => {
|
|
647
|
+
throw err;
|
|
648
|
+
});
|
|
649
|
+
this._log.info('beginTransaction request %j', request);
|
|
650
|
+
const wrappedCallback = callback
|
|
651
|
+
? (error, response, options, rawResponse) => {
|
|
652
|
+
this._log.info('beginTransaction response %j', response);
|
|
653
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
654
|
+
}
|
|
655
|
+
: undefined;
|
|
656
|
+
return this.innerApiCalls
|
|
657
|
+
.beginTransaction(request, options, wrappedCallback)
|
|
658
|
+
?.then(([response, options, rawResponse]) => {
|
|
659
|
+
this._log.info('beginTransaction response %j', response);
|
|
660
|
+
return [response, options, rawResponse];
|
|
661
|
+
})
|
|
662
|
+
.catch((error) => {
|
|
663
|
+
if (error &&
|
|
664
|
+
'statusDetails' in error &&
|
|
665
|
+
error.statusDetails instanceof Array) {
|
|
666
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
667
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
668
|
+
}
|
|
669
|
+
throw error;
|
|
670
|
+
});
|
|
477
671
|
}
|
|
478
672
|
commit(request, optionsOrCallback, callback) {
|
|
479
|
-
var _a;
|
|
480
673
|
request = request || {};
|
|
481
674
|
let options;
|
|
482
675
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -491,13 +684,35 @@ class SpannerClient {
|
|
|
491
684
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
492
685
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
493
686
|
this._gaxModule.routingHeader.fromParams({
|
|
494
|
-
session:
|
|
687
|
+
session: request.session ?? '',
|
|
495
688
|
});
|
|
496
|
-
this.initialize()
|
|
497
|
-
|
|
689
|
+
this.initialize().catch(err => {
|
|
690
|
+
throw err;
|
|
691
|
+
});
|
|
692
|
+
this._log.info('commit request %j', request);
|
|
693
|
+
const wrappedCallback = callback
|
|
694
|
+
? (error, response, options, rawResponse) => {
|
|
695
|
+
this._log.info('commit response %j', response);
|
|
696
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
697
|
+
}
|
|
698
|
+
: undefined;
|
|
699
|
+
return this.innerApiCalls
|
|
700
|
+
.commit(request, options, wrappedCallback)
|
|
701
|
+
?.then(([response, options, rawResponse]) => {
|
|
702
|
+
this._log.info('commit response %j', response);
|
|
703
|
+
return [response, options, rawResponse];
|
|
704
|
+
})
|
|
705
|
+
.catch((error) => {
|
|
706
|
+
if (error &&
|
|
707
|
+
'statusDetails' in error &&
|
|
708
|
+
error.statusDetails instanceof Array) {
|
|
709
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
710
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
711
|
+
}
|
|
712
|
+
throw error;
|
|
713
|
+
});
|
|
498
714
|
}
|
|
499
715
|
rollback(request, optionsOrCallback, callback) {
|
|
500
|
-
var _a;
|
|
501
716
|
request = request || {};
|
|
502
717
|
let options;
|
|
503
718
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -512,13 +727,35 @@ class SpannerClient {
|
|
|
512
727
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
513
728
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
514
729
|
this._gaxModule.routingHeader.fromParams({
|
|
515
|
-
session:
|
|
730
|
+
session: request.session ?? '',
|
|
516
731
|
});
|
|
517
|
-
this.initialize()
|
|
518
|
-
|
|
732
|
+
this.initialize().catch(err => {
|
|
733
|
+
throw err;
|
|
734
|
+
});
|
|
735
|
+
this._log.info('rollback request %j', request);
|
|
736
|
+
const wrappedCallback = callback
|
|
737
|
+
? (error, response, options, rawResponse) => {
|
|
738
|
+
this._log.info('rollback response %j', response);
|
|
739
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
740
|
+
}
|
|
741
|
+
: undefined;
|
|
742
|
+
return this.innerApiCalls
|
|
743
|
+
.rollback(request, options, wrappedCallback)
|
|
744
|
+
?.then(([response, options, rawResponse]) => {
|
|
745
|
+
this._log.info('rollback response %j', response);
|
|
746
|
+
return [response, options, rawResponse];
|
|
747
|
+
})
|
|
748
|
+
.catch((error) => {
|
|
749
|
+
if (error &&
|
|
750
|
+
'statusDetails' in error &&
|
|
751
|
+
error.statusDetails instanceof Array) {
|
|
752
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
753
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
754
|
+
}
|
|
755
|
+
throw error;
|
|
756
|
+
});
|
|
519
757
|
}
|
|
520
758
|
partitionQuery(request, optionsOrCallback, callback) {
|
|
521
|
-
var _a;
|
|
522
759
|
request = request || {};
|
|
523
760
|
let options;
|
|
524
761
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -533,13 +770,35 @@ class SpannerClient {
|
|
|
533
770
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
534
771
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
535
772
|
this._gaxModule.routingHeader.fromParams({
|
|
536
|
-
session:
|
|
773
|
+
session: request.session ?? '',
|
|
537
774
|
});
|
|
538
|
-
this.initialize()
|
|
539
|
-
|
|
775
|
+
this.initialize().catch(err => {
|
|
776
|
+
throw err;
|
|
777
|
+
});
|
|
778
|
+
this._log.info('partitionQuery request %j', request);
|
|
779
|
+
const wrappedCallback = callback
|
|
780
|
+
? (error, response, options, rawResponse) => {
|
|
781
|
+
this._log.info('partitionQuery response %j', response);
|
|
782
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
783
|
+
}
|
|
784
|
+
: undefined;
|
|
785
|
+
return this.innerApiCalls
|
|
786
|
+
.partitionQuery(request, options, wrappedCallback)
|
|
787
|
+
?.then(([response, options, rawResponse]) => {
|
|
788
|
+
this._log.info('partitionQuery response %j', response);
|
|
789
|
+
return [response, options, rawResponse];
|
|
790
|
+
})
|
|
791
|
+
.catch((error) => {
|
|
792
|
+
if (error &&
|
|
793
|
+
'statusDetails' in error &&
|
|
794
|
+
error.statusDetails instanceof Array) {
|
|
795
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
796
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
797
|
+
}
|
|
798
|
+
throw error;
|
|
799
|
+
});
|
|
540
800
|
}
|
|
541
801
|
partitionRead(request, optionsOrCallback, callback) {
|
|
542
|
-
var _a;
|
|
543
802
|
request = request || {};
|
|
544
803
|
let options;
|
|
545
804
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -554,10 +813,33 @@ class SpannerClient {
|
|
|
554
813
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
555
814
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
556
815
|
this._gaxModule.routingHeader.fromParams({
|
|
557
|
-
session:
|
|
816
|
+
session: request.session ?? '',
|
|
558
817
|
});
|
|
559
|
-
this.initialize()
|
|
560
|
-
|
|
818
|
+
this.initialize().catch(err => {
|
|
819
|
+
throw err;
|
|
820
|
+
});
|
|
821
|
+
this._log.info('partitionRead request %j', request);
|
|
822
|
+
const wrappedCallback = callback
|
|
823
|
+
? (error, response, options, rawResponse) => {
|
|
824
|
+
this._log.info('partitionRead response %j', response);
|
|
825
|
+
callback(error, response, options, rawResponse); // We verified callback above.
|
|
826
|
+
}
|
|
827
|
+
: undefined;
|
|
828
|
+
return this.innerApiCalls
|
|
829
|
+
.partitionRead(request, options, wrappedCallback)
|
|
830
|
+
?.then(([response, options, rawResponse]) => {
|
|
831
|
+
this._log.info('partitionRead response %j', response);
|
|
832
|
+
return [response, options, rawResponse];
|
|
833
|
+
})
|
|
834
|
+
.catch((error) => {
|
|
835
|
+
if (error &&
|
|
836
|
+
'statusDetails' in error &&
|
|
837
|
+
error.statusDetails instanceof Array) {
|
|
838
|
+
const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
|
|
839
|
+
error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
|
|
840
|
+
}
|
|
841
|
+
throw error;
|
|
842
|
+
});
|
|
561
843
|
}
|
|
562
844
|
/**
|
|
563
845
|
* Like {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the
|
|
@@ -667,16 +949,18 @@ class SpannerClient {
|
|
|
667
949
|
* for more details and examples.
|
|
668
950
|
*/
|
|
669
951
|
executeStreamingSql(request, options) {
|
|
670
|
-
var _a;
|
|
671
952
|
request = request || {};
|
|
672
953
|
options = options || {};
|
|
673
954
|
options.otherArgs = options.otherArgs || {};
|
|
674
955
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
675
956
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
676
957
|
this._gaxModule.routingHeader.fromParams({
|
|
677
|
-
session:
|
|
958
|
+
session: request.session ?? '',
|
|
678
959
|
});
|
|
679
|
-
this.initialize()
|
|
960
|
+
this.initialize().catch(err => {
|
|
961
|
+
throw err;
|
|
962
|
+
});
|
|
963
|
+
this._log.info('executeStreamingSql stream %j', options);
|
|
680
964
|
return this.innerApiCalls.executeStreamingSql(request, options);
|
|
681
965
|
}
|
|
682
966
|
/**
|
|
@@ -767,16 +1051,18 @@ class SpannerClient {
|
|
|
767
1051
|
* for more details and examples.
|
|
768
1052
|
*/
|
|
769
1053
|
streamingRead(request, options) {
|
|
770
|
-
var _a;
|
|
771
1054
|
request = request || {};
|
|
772
1055
|
options = options || {};
|
|
773
1056
|
options.otherArgs = options.otherArgs || {};
|
|
774
1057
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
775
1058
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
776
1059
|
this._gaxModule.routingHeader.fromParams({
|
|
777
|
-
session:
|
|
1060
|
+
session: request.session ?? '',
|
|
778
1061
|
});
|
|
779
|
-
this.initialize()
|
|
1062
|
+
this.initialize().catch(err => {
|
|
1063
|
+
throw err;
|
|
1064
|
+
});
|
|
1065
|
+
this._log.info('streamingRead stream %j', options);
|
|
780
1066
|
return this.innerApiCalls.streamingRead(request, options);
|
|
781
1067
|
}
|
|
782
1068
|
/**
|
|
@@ -825,20 +1111,21 @@ class SpannerClient {
|
|
|
825
1111
|
* for more details and examples.
|
|
826
1112
|
*/
|
|
827
1113
|
batchWrite(request, options) {
|
|
828
|
-
var _a;
|
|
829
1114
|
request = request || {};
|
|
830
1115
|
options = options || {};
|
|
831
1116
|
options.otherArgs = options.otherArgs || {};
|
|
832
1117
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
833
1118
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
834
1119
|
this._gaxModule.routingHeader.fromParams({
|
|
835
|
-
session:
|
|
1120
|
+
session: request.session ?? '',
|
|
836
1121
|
});
|
|
837
|
-
this.initialize()
|
|
1122
|
+
this.initialize().catch(err => {
|
|
1123
|
+
throw err;
|
|
1124
|
+
});
|
|
1125
|
+
this._log.info('batchWrite stream %j', options);
|
|
838
1126
|
return this.innerApiCalls.batchWrite(request, options);
|
|
839
1127
|
}
|
|
840
1128
|
listSessions(request, optionsOrCallback, callback) {
|
|
841
|
-
var _a;
|
|
842
1129
|
request = request || {};
|
|
843
1130
|
let options;
|
|
844
1131
|
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
|
@@ -853,10 +1140,24 @@ class SpannerClient {
|
|
|
853
1140
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
854
1141
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
855
1142
|
this._gaxModule.routingHeader.fromParams({
|
|
856
|
-
database:
|
|
1143
|
+
database: request.database ?? '',
|
|
857
1144
|
});
|
|
858
|
-
this.initialize()
|
|
859
|
-
|
|
1145
|
+
this.initialize().catch(err => {
|
|
1146
|
+
throw err;
|
|
1147
|
+
});
|
|
1148
|
+
const wrappedCallback = callback
|
|
1149
|
+
? (error, values, nextPageRequest, rawResponse) => {
|
|
1150
|
+
this._log.info('listSessions values %j', values);
|
|
1151
|
+
callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
|
|
1152
|
+
}
|
|
1153
|
+
: undefined;
|
|
1154
|
+
this._log.info('listSessions request %j', request);
|
|
1155
|
+
return this.innerApiCalls
|
|
1156
|
+
.listSessions(request, options, wrappedCallback)
|
|
1157
|
+
?.then(([response, input, output]) => {
|
|
1158
|
+
this._log.info('listSessions values %j', response);
|
|
1159
|
+
return [response, input, output];
|
|
1160
|
+
});
|
|
860
1161
|
}
|
|
861
1162
|
/**
|
|
862
1163
|
* Equivalent to `listSessions`, but returns a NodeJS Stream object.
|
|
@@ -895,18 +1196,20 @@ class SpannerClient {
|
|
|
895
1196
|
* for more details and examples.
|
|
896
1197
|
*/
|
|
897
1198
|
listSessionsStream(request, options) {
|
|
898
|
-
var _a;
|
|
899
1199
|
request = request || {};
|
|
900
1200
|
options = options || {};
|
|
901
1201
|
options.otherArgs = options.otherArgs || {};
|
|
902
1202
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
903
1203
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
904
1204
|
this._gaxModule.routingHeader.fromParams({
|
|
905
|
-
database:
|
|
1205
|
+
database: request.database ?? '',
|
|
906
1206
|
});
|
|
907
1207
|
const defaultCallSettings = this._defaults['listSessions'];
|
|
908
1208
|
const callSettings = defaultCallSettings.merge(options);
|
|
909
|
-
this.initialize()
|
|
1209
|
+
this.initialize().catch(err => {
|
|
1210
|
+
throw err;
|
|
1211
|
+
});
|
|
1212
|
+
this._log.info('listSessions stream %j', request);
|
|
910
1213
|
return this.descriptors.page.listSessions.createStream(this.innerApiCalls.listSessions, request, callSettings);
|
|
911
1214
|
}
|
|
912
1215
|
/**
|
|
@@ -947,18 +1250,20 @@ class SpannerClient {
|
|
|
947
1250
|
* for more details and examples.
|
|
948
1251
|
*/
|
|
949
1252
|
listSessionsAsync(request, options) {
|
|
950
|
-
var _a;
|
|
951
1253
|
request = request || {};
|
|
952
1254
|
options = options || {};
|
|
953
1255
|
options.otherArgs = options.otherArgs || {};
|
|
954
1256
|
options.otherArgs.headers = options.otherArgs.headers || {};
|
|
955
1257
|
options.otherArgs.headers['x-goog-request-params'] =
|
|
956
1258
|
this._gaxModule.routingHeader.fromParams({
|
|
957
|
-
database:
|
|
1259
|
+
database: request.database ?? '',
|
|
958
1260
|
});
|
|
959
1261
|
const defaultCallSettings = this._defaults['listSessions'];
|
|
960
1262
|
const callSettings = defaultCallSettings.merge(options);
|
|
961
|
-
this.initialize()
|
|
1263
|
+
this.initialize().catch(err => {
|
|
1264
|
+
throw err;
|
|
1265
|
+
});
|
|
1266
|
+
this._log.info('listSessions iterate %j', request);
|
|
962
1267
|
return this.descriptors.page.listSessions.asyncIterate(this.innerApiCalls['listSessions'], request, callSettings);
|
|
963
1268
|
}
|
|
964
1269
|
// --------------------
|
|
@@ -1075,6 +1380,7 @@ class SpannerClient {
|
|
|
1075
1380
|
close() {
|
|
1076
1381
|
if (this.spannerStub && !this._terminated) {
|
|
1077
1382
|
return this.spannerStub.then(stub => {
|
|
1383
|
+
this._log.info('ending gRPC channel');
|
|
1078
1384
|
this._terminated = true;
|
|
1079
1385
|
stub.close();
|
|
1080
1386
|
});
|