@google-cloud/spanner 8.9.0 → 8.11.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 (64) hide show
  1. package/build/protos/status.json +243 -0
  2. package/build/src/backup.d.ts +2 -1
  3. package/build/src/batch-transaction.d.ts +2 -1
  4. package/build/src/codec.d.ts +2 -1
  5. package/build/src/codec.js +21 -20
  6. package/build/src/common.d.ts +3 -2
  7. package/build/src/database.d.ts +5 -2
  8. package/build/src/index.d.ts +3 -2
  9. package/build/src/index.js +7 -16
  10. package/build/src/instance-config.d.ts +2 -1
  11. package/build/src/instance.d.ts +4 -3
  12. package/build/src/instance.js +3 -2
  13. package/build/src/partial-result-stream.d.ts +2 -1
  14. package/build/src/partial-result-stream.js +5 -4
  15. package/build/src/protos.d.ts +21 -0
  16. package/build/src/protos.js +52 -0
  17. package/build/src/session.d.ts +2 -1
  18. package/build/src/spanner_grpc_config.json +1 -1
  19. package/build/src/table.d.ts +3 -2
  20. package/build/src/table.js +4 -3
  21. package/build/src/transaction-runner.d.ts +2 -1
  22. package/build/src/transaction-runner.js +6 -8
  23. package/build/src/transaction.d.ts +3 -2
  24. package/build/src/transaction.js +6 -5
  25. package/build/src/v1/index.d.ts +1 -4
  26. package/build/src/v1/index.js +5 -8
  27. package/package.json +8 -6
  28. package/build/protos/google/spanner/admin/database/v1/backup.proto +0 -773
  29. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +0 -230
  30. package/build/protos/google/spanner/admin/database/v1/common.proto +0 -132
  31. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +0 -1314
  32. package/build/protos/google/spanner/admin/instance/v1/common.proto +0 -64
  33. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +0 -2184
  34. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +0 -1604
  35. package/build/protos/google/spanner/v1/change_stream.proto +0 -451
  36. package/build/protos/google/spanner/v1/commit_response.proto +0 -80
  37. package/build/protos/google/spanner/v1/keys.proto +0 -163
  38. package/build/protos/google/spanner/v1/location.proto +0 -388
  39. package/build/protos/google/spanner/v1/mutation.proto +0 -156
  40. package/build/protos/google/spanner/v1/query_plan.proto +0 -156
  41. package/build/protos/google/spanner/v1/result_set.proto +0 -260
  42. package/build/protos/google/spanner/v1/spanner.proto +0 -1472
  43. package/build/protos/google/spanner/v1/transaction.proto +0 -329
  44. package/build/protos/google/spanner/v1/type.proto +0 -214
  45. package/build/protos/protos.d.ts +0 -44031
  46. package/build/protos/protos.js +0 -122630
  47. package/build/protos/protos.json +0 -11631
  48. package/build/src/v1/database_admin_client.d.ts +0 -2367
  49. package/build/src/v1/database_admin_client.js +0 -2914
  50. package/build/src/v1/database_admin_client_config.json +0 -169
  51. package/build/src/v1/database_admin_proto_list.json +0 -6
  52. package/build/src/v1/gapic_metadata.json +0 -27
  53. package/build/src/v1/instance_admin_client.d.ts +0 -2106
  54. package/build/src/v1/instance_admin_client.js +0 -2387
  55. package/build/src/v1/instance_admin_client_config.json +0 -129
  56. package/build/src/v1/instance_admin_proto_list.json +0 -4
  57. package/build/src/v1/spanner_client.d.ts +0 -1319
  58. package/build/src/v1/spanner_client.js +0 -1446
  59. package/build/src/v1/spanner_client_config.json +0 -123
  60. package/build/src/v1/spanner_executor_proxy_client.d.ts +0 -419
  61. package/build/src/v1/spanner_executor_proxy_client.js +0 -728
  62. package/build/src/v1/spanner_executor_proxy_client_config.json +0 -30
  63. package/build/src/v1/spanner_executor_proxy_proto_list.json +0 -15
  64. package/build/src/v1/spanner_proto_list.json +0 -12
@@ -1,1446 +0,0 @@
1
- "use strict";
2
- // Copyright 2026 Google LLC
3
- //
4
- // Licensed under the Apache License, Version 2.0 (the "License");
5
- // you may not use this file except in compliance with the License.
6
- // You may obtain a copy of the License at
7
- //
8
- // https://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- //
16
- // ** This file is automatically generated by gapic-generator-typescript. **
17
- // ** https://github.com/googleapis/gapic-generator-typescript **
18
- // ** All changes to this file may be overwritten. **
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.SpannerClient = void 0;
21
- const stream_1 = require("stream");
22
- const jsonProtos = require("../../protos/protos.json");
23
- const google_gax_1 = require("google-gax");
24
- /**
25
- * Client JSON configuration object, loaded from
26
- * `src/v1/spanner_client_config.json`.
27
- * This file defines retry strategy and timeouts for all API methods in this library.
28
- */
29
- const gapicConfig = require("./spanner_client_config.json");
30
- const version = require('../../../package.json').version;
31
- /**
32
- * Cloud Spanner API
33
- *
34
- * The Cloud Spanner API can be used to manage sessions and execute
35
- * transactions on data stored in Cloud Spanner databases.
36
- * @class
37
- * @memberof v1
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;
61
- /**
62
- * Construct an instance of SpannerClient.
63
- *
64
- * @param {object} [options] - The configuration object.
65
- * The options accepted by the constructor are described in detail
66
- * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
67
- * The common options are:
68
- * @param {object} [options.credentials] - Credentials object.
69
- * @param {string} [options.credentials.client_email]
70
- * @param {string} [options.credentials.private_key]
71
- * @param {string} [options.email] - Account email address. Required when
72
- * using a .pem or .p12 keyFilename.
73
- * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
74
- * .p12 key downloaded from the Google Developers Console. If you provide
75
- * a path to a JSON file, the projectId option below is not necessary.
76
- * NOTE: .pem and .p12 require you to specify options.email as well.
77
- * @param {number} [options.port] - The port on which to connect to
78
- * the remote host.
79
- * @param {string} [options.projectId] - The project ID from the Google
80
- * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
81
- * the environment variable GCLOUD_PROJECT for your project ID. If your
82
- * app is running in an environment which supports
83
- * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials},
84
- * your project ID will be detected automatically.
85
- * @param {string} [options.apiEndpoint] - The domain name of the
86
- * API remote host.
87
- * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
88
- * Follows the structure of {@link gapicConfig}.
89
- * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode.
90
- * For more information, please check the
91
- * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
92
- * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you
93
- * need to avoid loading the default gRPC version and want to use the fallback
94
- * HTTP implementation. Load only fallback version and pass it to the constructor:
95
- * ```
96
- * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC
97
- * const client = new SpannerClient({fallback: true}, gax);
98
- * ```
99
- */
100
- constructor(opts, gaxInstance) {
101
- // Ensure that options include all the required fields.
102
- const staticMembers = this.constructor;
103
- if (opts?.universe_domain &&
104
- opts?.universeDomain &&
105
- opts?.universe_domain !== opts?.universeDomain) {
106
- throw new Error('Please set either universe_domain or universeDomain, but not both.');
107
- }
108
- const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
109
- ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
110
- : undefined;
111
- this._universeDomain =
112
- opts?.universeDomain ??
113
- opts?.universe_domain ??
114
- universeDomainEnvVar ??
115
- 'googleapis.com';
116
- this._servicePath = 'spanner.' + this._universeDomain;
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');
123
- opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
124
- // Request numeric enum values if REST transport is used.
125
- opts.numericEnums = true;
126
- // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
127
- if (servicePath !== this._servicePath && !('scopes' in opts)) {
128
- opts['scopes'] = staticMembers.scopes;
129
- }
130
- // Load google-gax module synchronously if needed
131
- if (!gaxInstance) {
132
- gaxInstance = require('google-gax');
133
- }
134
- // Choose either gRPC or proto-over-HTTP implementation of google-gax.
135
- this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance;
136
- // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
137
- this._gaxGrpc = new this._gaxModule.GrpcClient(opts);
138
- // Save options to use in initialize() method.
139
- this._opts = opts;
140
- // Save the auth object to the client, for use by other methods.
141
- this.auth = this._gaxGrpc.auth;
142
- // Set useJWTAccessWithScope on the auth object.
143
- this.auth.useJWTAccessWithScope = true;
144
- // Set defaultServicePath on the auth object.
145
- this.auth.defaultServicePath = this._servicePath;
146
- // Set the default scopes in auth client if needed.
147
- if (servicePath === this._servicePath) {
148
- this.auth.defaultScopes = staticMembers.scopes;
149
- }
150
- // Determine the client header string.
151
- const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
152
- if (typeof process === 'object' && 'versions' in process) {
153
- clientHeader.push(`gl-node/${process.versions.node}`);
154
- }
155
- else {
156
- clientHeader.push(`gl-web/${this._gaxModule.version}`);
157
- }
158
- if (!opts.fallback) {
159
- clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`);
160
- }
161
- else {
162
- clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`);
163
- }
164
- if (opts.libName && opts.libVersion) {
165
- clientHeader.push(`${opts.libName}/${opts.libVersion}`);
166
- }
167
- // Load the applicable protos.
168
- this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
169
- // This API contains "path templates"; forward-slash-separated
170
- // identifiers to uniquely identify resources within the API.
171
- // Create useful helper objects for these.
172
- this.pathTemplates = {
173
- databasePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}'),
174
- sessionPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/instances/{instance}/databases/{database}/sessions/{session}'),
175
- };
176
- // Some of the methods on this service return "paged" results,
177
- // (e.g. 50 results at a time, with tokens to get subsequent
178
- // pages). Denote the keys used for pagination and results.
179
- this.descriptors.page = {
180
- listSessions: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'sessions'),
181
- };
182
- // Some of the methods on this service provide streaming responses.
183
- // Provide descriptors for these.
184
- this.descriptors.stream = {
185
- executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
186
- streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
187
- batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
188
- fetchCacheUpdate: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries),
189
- };
190
- // Put together the default options sent with requests.
191
- this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
192
- // Set up a dictionary of "inner API calls"; the core implementation
193
- // of calling the API is handled in `google-gax`, with this code
194
- // merely providing the destination and request information.
195
- this.innerApiCalls = {};
196
- // Add a warn function to the client constructor so it can be easily tested.
197
- this.warn = this._gaxModule.warn;
198
- }
199
- /**
200
- * Initialize the client.
201
- * Performs asynchronous operations (such as authentication) and prepares the client.
202
- * This function will be called automatically when any class method is called for the
203
- * first time, but if you need to initialize it before calling an actual method,
204
- * feel free to call initialize() directly.
205
- *
206
- * You can await on this method if you want to make sure the client is initialized.
207
- *
208
- * @returns {Promise} A promise that resolves to an authenticated service stub.
209
- */
210
- initialize() {
211
- // If the client stub promise is already initialized, return immediately.
212
- if (this.spannerStub) {
213
- return this.spannerStub;
214
- }
215
- // Put together the "service stub" for
216
- // google.spanner.v1.Spanner.
217
- this.spannerStub = this._gaxGrpc.createStub(this._opts.fallback
218
- ? this._protos.lookupService('google.spanner.v1.Spanner')
219
- : // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
- this._protos.google.spanner.v1.Spanner, this._opts, this._providedCustomServicePath);
221
- // Iterate over each of the methods that the service provides
222
- // and create an API call method for each.
223
- const spannerStubMethods = [
224
- 'createSession',
225
- 'batchCreateSessions',
226
- 'getSession',
227
- 'listSessions',
228
- 'deleteSession',
229
- 'executeSql',
230
- 'executeStreamingSql',
231
- 'executeBatchDml',
232
- 'read',
233
- 'streamingRead',
234
- 'beginTransaction',
235
- 'commit',
236
- 'rollback',
237
- 'partitionQuery',
238
- 'partitionRead',
239
- 'batchWrite',
240
- 'fetchCacheUpdate',
241
- ];
242
- for (const methodName of spannerStubMethods) {
243
- const callPromise = this.spannerStub.then(stub => (...args) => {
244
- if (this._terminated) {
245
- if (methodName in this.descriptors.stream) {
246
- const stream = new stream_1.PassThrough({ objectMode: true });
247
- setImmediate(() => {
248
- stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.'));
249
- });
250
- return stream;
251
- }
252
- return Promise.reject('The client has already been closed.');
253
- }
254
- const func = stub[methodName];
255
- return func.apply(stub, args);
256
- }, (err) => () => {
257
- throw err;
258
- });
259
- const descriptor = this.descriptors.page[methodName] ||
260
- this.descriptors.stream[methodName] ||
261
- undefined;
262
- const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback);
263
- this.innerApiCalls[methodName] = apiCall;
264
- }
265
- return this.spannerStub;
266
- }
267
- /**
268
- * The DNS address for this API service.
269
- * @deprecated Use the apiEndpoint method of the client instance.
270
- * @returns {string} The DNS address for this service.
271
- */
272
- static get servicePath() {
273
- if (typeof process === 'object' &&
274
- typeof process.emitWarning === 'function') {
275
- process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
276
- }
277
- return 'spanner.googleapis.com';
278
- }
279
- /**
280
- * The DNS address for this API service - same as servicePath.
281
- * @deprecated Use the apiEndpoint method of the client instance.
282
- * @returns {string} The DNS address for this service.
283
- */
284
- static get apiEndpoint() {
285
- if (typeof process === 'object' &&
286
- typeof process.emitWarning === 'function') {
287
- process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
288
- }
289
- return 'spanner.googleapis.com';
290
- }
291
- /**
292
- * The DNS address for this API service.
293
- * @returns {string} The DNS address for this service.
294
- */
295
- get apiEndpoint() {
296
- return this._servicePath;
297
- }
298
- get universeDomain() {
299
- return this._universeDomain;
300
- }
301
- /**
302
- * The port for this API service.
303
- * @returns {number} The default port for this service.
304
- */
305
- static get port() {
306
- return 443;
307
- }
308
- /**
309
- * The scopes needed to make gRPC calls for every method defined
310
- * in this service.
311
- * @returns {string[]} List of default scopes.
312
- */
313
- static get scopes() {
314
- return [
315
- 'https://www.googleapis.com/auth/cloud-platform',
316
- 'https://www.googleapis.com/auth/spanner.data',
317
- ];
318
- }
319
- /**
320
- * Return the project ID used by this class.
321
- * @returns {Promise} A promise that resolves to string containing the project ID.
322
- */
323
- getProjectId(callback) {
324
- if (callback) {
325
- this.auth.getProjectId(callback);
326
- return;
327
- }
328
- return this.auth.getProjectId();
329
- }
330
- createSession(request, optionsOrCallback, callback) {
331
- request = request || {};
332
- let options;
333
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
334
- callback = optionsOrCallback;
335
- options = {};
336
- }
337
- else {
338
- options = optionsOrCallback;
339
- }
340
- options = options || {};
341
- options.otherArgs = options.otherArgs || {};
342
- options.otherArgs.headers = options.otherArgs.headers || {};
343
- options.otherArgs.headers['x-goog-request-params'] =
344
- this._gaxModule.routingHeader.fromParams({
345
- database: request.database ?? '',
346
- });
347
- this.initialize().catch(err => {
348
- throw err;
349
- });
350
- this._log.info('createSession request %j', request);
351
- const wrappedCallback = callback
352
- ? (error, response, options, rawResponse) => {
353
- this._log.info('createSession response %j', response);
354
- callback(error, response, options, rawResponse); // We verified callback above.
355
- }
356
- : undefined;
357
- return this.innerApiCalls
358
- .createSession(request, options, wrappedCallback)
359
- ?.then(([response, options, rawResponse]) => {
360
- this._log.info('createSession response %j', response);
361
- return [response, options, rawResponse];
362
- })
363
- .catch((error) => {
364
- if (error &&
365
- 'statusDetails' in error &&
366
- error.statusDetails instanceof Array) {
367
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
368
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
369
- }
370
- throw error;
371
- });
372
- }
373
- batchCreateSessions(request, optionsOrCallback, callback) {
374
- request = request || {};
375
- let options;
376
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
377
- callback = optionsOrCallback;
378
- options = {};
379
- }
380
- else {
381
- options = optionsOrCallback;
382
- }
383
- options = options || {};
384
- options.otherArgs = options.otherArgs || {};
385
- options.otherArgs.headers = options.otherArgs.headers || {};
386
- options.otherArgs.headers['x-goog-request-params'] =
387
- this._gaxModule.routingHeader.fromParams({
388
- database: request.database ?? '',
389
- });
390
- this.initialize().catch(err => {
391
- throw err;
392
- });
393
- this._log.info('batchCreateSessions request %j', request);
394
- const wrappedCallback = callback
395
- ? (error, response, options, rawResponse) => {
396
- this._log.info('batchCreateSessions response %j', response);
397
- callback(error, response, options, rawResponse); // We verified callback above.
398
- }
399
- : undefined;
400
- return this.innerApiCalls
401
- .batchCreateSessions(request, options, wrappedCallback)
402
- ?.then(([response, options, rawResponse]) => {
403
- this._log.info('batchCreateSessions response %j', response);
404
- return [response, options, rawResponse];
405
- })
406
- .catch((error) => {
407
- if (error &&
408
- 'statusDetails' in error &&
409
- error.statusDetails instanceof Array) {
410
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
411
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
412
- }
413
- throw error;
414
- });
415
- }
416
- getSession(request, optionsOrCallback, callback) {
417
- request = request || {};
418
- let options;
419
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
420
- callback = optionsOrCallback;
421
- options = {};
422
- }
423
- else {
424
- options = optionsOrCallback;
425
- }
426
- options = options || {};
427
- options.otherArgs = options.otherArgs || {};
428
- options.otherArgs.headers = options.otherArgs.headers || {};
429
- options.otherArgs.headers['x-goog-request-params'] =
430
- this._gaxModule.routingHeader.fromParams({
431
- name: request.name ?? '',
432
- });
433
- this.initialize().catch(err => {
434
- throw err;
435
- });
436
- this._log.info('getSession request %j', request);
437
- const wrappedCallback = callback
438
- ? (error, response, options, rawResponse) => {
439
- this._log.info('getSession response %j', response);
440
- callback(error, response, options, rawResponse); // We verified callback above.
441
- }
442
- : undefined;
443
- return this.innerApiCalls
444
- .getSession(request, options, wrappedCallback)
445
- ?.then(([response, options, rawResponse]) => {
446
- this._log.info('getSession response %j', response);
447
- return [response, options, rawResponse];
448
- })
449
- .catch((error) => {
450
- if (error &&
451
- 'statusDetails' in error &&
452
- error.statusDetails instanceof Array) {
453
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
454
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
455
- }
456
- throw error;
457
- });
458
- }
459
- deleteSession(request, optionsOrCallback, callback) {
460
- request = request || {};
461
- let options;
462
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
463
- callback = optionsOrCallback;
464
- options = {};
465
- }
466
- else {
467
- options = optionsOrCallback;
468
- }
469
- options = options || {};
470
- options.otherArgs = options.otherArgs || {};
471
- options.otherArgs.headers = options.otherArgs.headers || {};
472
- options.otherArgs.headers['x-goog-request-params'] =
473
- this._gaxModule.routingHeader.fromParams({
474
- name: request.name ?? '',
475
- });
476
- this.initialize().catch(err => {
477
- throw err;
478
- });
479
- this._log.info('deleteSession request %j', request);
480
- const wrappedCallback = callback
481
- ? (error, response, options, rawResponse) => {
482
- this._log.info('deleteSession response %j', response);
483
- callback(error, response, options, rawResponse); // We verified callback above.
484
- }
485
- : undefined;
486
- return this.innerApiCalls
487
- .deleteSession(request, options, wrappedCallback)
488
- ?.then(([response, options, rawResponse]) => {
489
- this._log.info('deleteSession response %j', response);
490
- return [response, options, rawResponse];
491
- })
492
- .catch((error) => {
493
- if (error &&
494
- 'statusDetails' in error &&
495
- error.statusDetails instanceof Array) {
496
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
497
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
498
- }
499
- throw error;
500
- });
501
- }
502
- executeSql(request, optionsOrCallback, callback) {
503
- request = request || {};
504
- let options;
505
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
506
- callback = optionsOrCallback;
507
- options = {};
508
- }
509
- else {
510
- options = optionsOrCallback;
511
- }
512
- options = options || {};
513
- options.otherArgs = options.otherArgs || {};
514
- options.otherArgs.headers = options.otherArgs.headers || {};
515
- options.otherArgs.headers['x-goog-request-params'] =
516
- this._gaxModule.routingHeader.fromParams({
517
- session: request.session ?? '',
518
- });
519
- this.initialize().catch(err => {
520
- throw err;
521
- });
522
- this._log.info('executeSql request %j', request);
523
- const wrappedCallback = callback
524
- ? (error, response, options, rawResponse) => {
525
- this._log.info('executeSql response %j', response);
526
- callback(error, response, options, rawResponse); // We verified callback above.
527
- }
528
- : undefined;
529
- return this.innerApiCalls
530
- .executeSql(request, options, wrappedCallback)
531
- ?.then(([response, options, rawResponse]) => {
532
- this._log.info('executeSql response %j', response);
533
- return [response, options, rawResponse];
534
- })
535
- .catch((error) => {
536
- if (error &&
537
- 'statusDetails' in error &&
538
- error.statusDetails instanceof Array) {
539
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
540
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
541
- }
542
- throw error;
543
- });
544
- }
545
- executeBatchDml(request, optionsOrCallback, callback) {
546
- request = request || {};
547
- let options;
548
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
549
- callback = optionsOrCallback;
550
- options = {};
551
- }
552
- else {
553
- options = optionsOrCallback;
554
- }
555
- options = options || {};
556
- options.otherArgs = options.otherArgs || {};
557
- options.otherArgs.headers = options.otherArgs.headers || {};
558
- options.otherArgs.headers['x-goog-request-params'] =
559
- this._gaxModule.routingHeader.fromParams({
560
- session: request.session ?? '',
561
- });
562
- this.initialize().catch(err => {
563
- throw err;
564
- });
565
- this._log.info('executeBatchDml request %j', request);
566
- const wrappedCallback = callback
567
- ? (error, response, options, rawResponse) => {
568
- this._log.info('executeBatchDml response %j', response);
569
- callback(error, response, options, rawResponse); // We verified callback above.
570
- }
571
- : undefined;
572
- return this.innerApiCalls
573
- .executeBatchDml(request, options, wrappedCallback)
574
- ?.then(([response, options, rawResponse]) => {
575
- this._log.info('executeBatchDml response %j', response);
576
- return [response, options, rawResponse];
577
- })
578
- .catch((error) => {
579
- if (error &&
580
- 'statusDetails' in error &&
581
- error.statusDetails instanceof Array) {
582
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
583
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
584
- }
585
- throw error;
586
- });
587
- }
588
- read(request, optionsOrCallback, callback) {
589
- request = request || {};
590
- let options;
591
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
592
- callback = optionsOrCallback;
593
- options = {};
594
- }
595
- else {
596
- options = optionsOrCallback;
597
- }
598
- options = options || {};
599
- options.otherArgs = options.otherArgs || {};
600
- options.otherArgs.headers = options.otherArgs.headers || {};
601
- options.otherArgs.headers['x-goog-request-params'] =
602
- this._gaxModule.routingHeader.fromParams({
603
- session: request.session ?? '',
604
- });
605
- this.initialize().catch(err => {
606
- throw err;
607
- });
608
- this._log.info('read request %j', request);
609
- const wrappedCallback = callback
610
- ? (error, response, options, rawResponse) => {
611
- this._log.info('read response %j', response);
612
- callback(error, response, options, rawResponse); // We verified callback above.
613
- }
614
- : undefined;
615
- return this.innerApiCalls
616
- .read(request, options, wrappedCallback)
617
- ?.then(([response, options, rawResponse]) => {
618
- this._log.info('read response %j', response);
619
- return [response, options, rawResponse];
620
- })
621
- .catch((error) => {
622
- if (error &&
623
- 'statusDetails' in error &&
624
- error.statusDetails instanceof Array) {
625
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
626
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
627
- }
628
- throw error;
629
- });
630
- }
631
- beginTransaction(request, optionsOrCallback, callback) {
632
- request = request || {};
633
- let options;
634
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
635
- callback = optionsOrCallback;
636
- options = {};
637
- }
638
- else {
639
- options = optionsOrCallback;
640
- }
641
- options = options || {};
642
- options.otherArgs = options.otherArgs || {};
643
- options.otherArgs.headers = options.otherArgs.headers || {};
644
- options.otherArgs.headers['x-goog-request-params'] =
645
- this._gaxModule.routingHeader.fromParams({
646
- session: request.session ?? '',
647
- });
648
- this.initialize().catch(err => {
649
- throw err;
650
- });
651
- this._log.info('beginTransaction request %j', request);
652
- const wrappedCallback = callback
653
- ? (error, response, options, rawResponse) => {
654
- this._log.info('beginTransaction response %j', response);
655
- callback(error, response, options, rawResponse); // We verified callback above.
656
- }
657
- : undefined;
658
- return this.innerApiCalls
659
- .beginTransaction(request, options, wrappedCallback)
660
- ?.then(([response, options, rawResponse]) => {
661
- this._log.info('beginTransaction response %j', response);
662
- return [response, options, rawResponse];
663
- })
664
- .catch((error) => {
665
- if (error &&
666
- 'statusDetails' in error &&
667
- error.statusDetails instanceof Array) {
668
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
669
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
670
- }
671
- throw error;
672
- });
673
- }
674
- commit(request, optionsOrCallback, callback) {
675
- request = request || {};
676
- let options;
677
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
678
- callback = optionsOrCallback;
679
- options = {};
680
- }
681
- else {
682
- options = optionsOrCallback;
683
- }
684
- options = options || {};
685
- options.otherArgs = options.otherArgs || {};
686
- options.otherArgs.headers = options.otherArgs.headers || {};
687
- options.otherArgs.headers['x-goog-request-params'] =
688
- this._gaxModule.routingHeader.fromParams({
689
- session: request.session ?? '',
690
- });
691
- this.initialize().catch(err => {
692
- throw err;
693
- });
694
- this._log.info('commit request %j', request);
695
- const wrappedCallback = callback
696
- ? (error, response, options, rawResponse) => {
697
- this._log.info('commit response %j', response);
698
- callback(error, response, options, rawResponse); // We verified callback above.
699
- }
700
- : undefined;
701
- return this.innerApiCalls
702
- .commit(request, options, wrappedCallback)
703
- ?.then(([response, options, rawResponse]) => {
704
- this._log.info('commit response %j', response);
705
- return [response, options, rawResponse];
706
- })
707
- .catch((error) => {
708
- if (error &&
709
- 'statusDetails' in error &&
710
- error.statusDetails instanceof Array) {
711
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
712
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
713
- }
714
- throw error;
715
- });
716
- }
717
- rollback(request, optionsOrCallback, callback) {
718
- request = request || {};
719
- let options;
720
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
721
- callback = optionsOrCallback;
722
- options = {};
723
- }
724
- else {
725
- options = optionsOrCallback;
726
- }
727
- options = options || {};
728
- options.otherArgs = options.otherArgs || {};
729
- options.otherArgs.headers = options.otherArgs.headers || {};
730
- options.otherArgs.headers['x-goog-request-params'] =
731
- this._gaxModule.routingHeader.fromParams({
732
- session: request.session ?? '',
733
- });
734
- this.initialize().catch(err => {
735
- throw err;
736
- });
737
- this._log.info('rollback request %j', request);
738
- const wrappedCallback = callback
739
- ? (error, response, options, rawResponse) => {
740
- this._log.info('rollback response %j', response);
741
- callback(error, response, options, rawResponse); // We verified callback above.
742
- }
743
- : undefined;
744
- return this.innerApiCalls
745
- .rollback(request, options, wrappedCallback)
746
- ?.then(([response, options, rawResponse]) => {
747
- this._log.info('rollback response %j', response);
748
- return [response, options, rawResponse];
749
- })
750
- .catch((error) => {
751
- if (error &&
752
- 'statusDetails' in error &&
753
- error.statusDetails instanceof Array) {
754
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
755
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
756
- }
757
- throw error;
758
- });
759
- }
760
- partitionQuery(request, optionsOrCallback, callback) {
761
- request = request || {};
762
- let options;
763
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
764
- callback = optionsOrCallback;
765
- options = {};
766
- }
767
- else {
768
- options = optionsOrCallback;
769
- }
770
- options = options || {};
771
- options.otherArgs = options.otherArgs || {};
772
- options.otherArgs.headers = options.otherArgs.headers || {};
773
- options.otherArgs.headers['x-goog-request-params'] =
774
- this._gaxModule.routingHeader.fromParams({
775
- session: request.session ?? '',
776
- });
777
- this.initialize().catch(err => {
778
- throw err;
779
- });
780
- this._log.info('partitionQuery request %j', request);
781
- const wrappedCallback = callback
782
- ? (error, response, options, rawResponse) => {
783
- this._log.info('partitionQuery response %j', response);
784
- callback(error, response, options, rawResponse); // We verified callback above.
785
- }
786
- : undefined;
787
- return this.innerApiCalls
788
- .partitionQuery(request, options, wrappedCallback)
789
- ?.then(([response, options, rawResponse]) => {
790
- this._log.info('partitionQuery response %j', response);
791
- return [response, options, rawResponse];
792
- })
793
- .catch((error) => {
794
- if (error &&
795
- 'statusDetails' in error &&
796
- error.statusDetails instanceof Array) {
797
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
798
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
799
- }
800
- throw error;
801
- });
802
- }
803
- partitionRead(request, optionsOrCallback, callback) {
804
- request = request || {};
805
- let options;
806
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
807
- callback = optionsOrCallback;
808
- options = {};
809
- }
810
- else {
811
- options = optionsOrCallback;
812
- }
813
- options = options || {};
814
- options.otherArgs = options.otherArgs || {};
815
- options.otherArgs.headers = options.otherArgs.headers || {};
816
- options.otherArgs.headers['x-goog-request-params'] =
817
- this._gaxModule.routingHeader.fromParams({
818
- session: request.session ?? '',
819
- });
820
- this.initialize().catch(err => {
821
- throw err;
822
- });
823
- this._log.info('partitionRead request %j', request);
824
- const wrappedCallback = callback
825
- ? (error, response, options, rawResponse) => {
826
- this._log.info('partitionRead response %j', response);
827
- callback(error, response, options, rawResponse); // We verified callback above.
828
- }
829
- : undefined;
830
- return this.innerApiCalls
831
- .partitionRead(request, options, wrappedCallback)
832
- ?.then(([response, options, rawResponse]) => {
833
- this._log.info('partitionRead response %j', response);
834
- return [response, options, rawResponse];
835
- })
836
- .catch((error) => {
837
- if (error &&
838
- 'statusDetails' in error &&
839
- error.statusDetails instanceof Array) {
840
- const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
841
- error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
842
- }
843
- throw error;
844
- });
845
- }
846
- /**
847
- * Like {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, except returns the
848
- * result set as a stream. Unlike
849
- * {@link protos.google.spanner.v1.Spanner.ExecuteSql|ExecuteSql}, there is no limit on
850
- * the size of the returned result set. However, no individual row in the
851
- * result set can exceed 100 MiB, and no column value can exceed 10 MiB.
852
- *
853
- * The query string can be SQL or [Graph Query Language
854
- * (GQL)](https://cloud.google.com/spanner/docs/reference/standard-sql/graph-intro).
855
- *
856
- * @param {Object} request
857
- * The request object that will be sent.
858
- * @param {string} request.session
859
- * Required. The session in which the SQL query should be performed.
860
- * @param {google.spanner.v1.TransactionSelector} request.transaction
861
- * The transaction to use.
862
- *
863
- * For queries, if none is provided, the default is a temporary read-only
864
- * transaction with strong concurrency.
865
- *
866
- * Standard DML statements require a read-write transaction. To protect
867
- * against replays, single-use transactions are not supported. The caller
868
- * must either supply an existing transaction ID or begin a new transaction.
869
- *
870
- * Partitioned DML requires an existing Partitioned DML transaction ID.
871
- * @param {string} request.sql
872
- * Required. The SQL string.
873
- * @param {google.protobuf.Struct} request.params
874
- * Parameter names and values that bind to placeholders in the SQL string.
875
- *
876
- * A parameter placeholder consists of the `@` character followed by the
877
- * parameter name (for example, `@firstName`). Parameter names must conform
878
- * to the naming requirements of identifiers as specified at
879
- * https://cloud.google.com/spanner/docs/lexical#identifiers.
880
- *
881
- * Parameters can appear anywhere that a literal value is expected. The same
882
- * parameter name can be used more than once, for example:
883
- *
884
- * `"WHERE id > @msg_id AND id < @msg_id + 100"`
885
- *
886
- * It's an error to execute a SQL statement with unbound parameters.
887
- * @param {number[]} request.paramTypes
888
- * It isn't always possible for Cloud Spanner to infer the right SQL type
889
- * from a JSON value. For example, values of type `BYTES` and values
890
- * of type `STRING` both appear in
891
- * {@link protos.google.spanner.v1.ExecuteSqlRequest.params|params} as JSON strings.
892
- *
893
- * In these cases, you can use `param_types` to specify the exact
894
- * SQL type for some or all of the SQL statement parameters. See the
895
- * definition of {@link protos.google.spanner.v1.Type|Type} for more information
896
- * about SQL types.
897
- * @param {Buffer} request.resumeToken
898
- * If this request is resuming a previously interrupted SQL statement
899
- * execution, `resume_token` should be copied from the last
900
- * {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
901
- * interruption. Doing this enables the new SQL statement execution to resume
902
- * where the last one left off. The rest of the request parameters must
903
- * exactly match the request that yielded this token.
904
- * @param {google.spanner.v1.ExecuteSqlRequest.QueryMode} request.queryMode
905
- * Used to control the amount of debugging information returned in
906
- * {@link protos.google.spanner.v1.ResultSetStats|ResultSetStats}. If
907
- * {@link protos.google.spanner.v1.ExecuteSqlRequest.partition_token|partition_token} is
908
- * set, {@link protos.google.spanner.v1.ExecuteSqlRequest.query_mode|query_mode} can only
909
- * be set to
910
- * {@link protos.google.spanner.v1.ExecuteSqlRequest.QueryMode.NORMAL|QueryMode.NORMAL}.
911
- * @param {Buffer} request.partitionToken
912
- * If present, results are restricted to the specified partition
913
- * previously created using `PartitionQuery`. There must be an exact
914
- * match for the values of fields common to this message and the
915
- * `PartitionQueryRequest` message used to create this `partition_token`.
916
- * @param {number} request.seqno
917
- * A per-transaction sequence number used to identify this request. This field
918
- * makes each request idempotent such that if the request is received multiple
919
- * times, at most one succeeds.
920
- *
921
- * The sequence number must be monotonically increasing within the
922
- * transaction. If a request arrives for the first time with an out-of-order
923
- * sequence number, the transaction can be aborted. Replays of previously
924
- * handled requests yield the same response as the first execution.
925
- *
926
- * Required for DML statements. Ignored for queries.
927
- * @param {google.spanner.v1.ExecuteSqlRequest.QueryOptions} request.queryOptions
928
- * Query optimizer configuration to use for the given query.
929
- * @param {google.spanner.v1.RequestOptions} request.requestOptions
930
- * Common options for this request.
931
- * @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
932
- * Directed read options for this request.
933
- * @param {boolean} request.dataBoostEnabled
934
- * If this is for a partitioned query and this field is set to `true`, the
935
- * request is executed with Spanner Data Boost independent compute resources.
936
- *
937
- * If the field is set to `true` but the request doesn't set
938
- * `partition_token`, the API returns an `INVALID_ARGUMENT` error.
939
- * @param {boolean} [request.lastStatement]
940
- * Optional. If set to `true`, this statement marks the end of the
941
- * transaction. After this statement executes, you must commit or abort the
942
- * transaction. Attempts to execute any other requests against this
943
- * transaction (including reads and queries) are rejected.
944
- *
945
- * For DML statements, setting this option might cause some error reporting to
946
- * be deferred until commit time (for example, validation of unique
947
- * constraints). Given this, successful execution of a DML statement shouldn't
948
- * be assumed until a subsequent `Commit` call completes successfully.
949
- * @param {google.spanner.v1.RoutingHint} [request.routingHint]
950
- * Optional. Makes the Spanner requests location-aware if present.
951
- *
952
- * It gives the server hints that can be used to route the request
953
- * to an appropriate server, potentially significantly decreasing latency and
954
- * improving throughput. To achieve improved performance, most fields must be
955
- * filled in with accurate values.
956
- * @param {object} [options]
957
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
958
- * @returns {Stream}
959
- * An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
960
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
961
- * for more details and examples.
962
- */
963
- executeStreamingSql(request, options) {
964
- request = request || {};
965
- options = options || {};
966
- options.otherArgs = options.otherArgs || {};
967
- options.otherArgs.headers = options.otherArgs.headers || {};
968
- options.otherArgs.headers['x-goog-request-params'] =
969
- this._gaxModule.routingHeader.fromParams({
970
- session: request.session ?? '',
971
- });
972
- this.initialize().catch(err => {
973
- throw err;
974
- });
975
- this._log.info('executeStreamingSql stream %j', options);
976
- return this.innerApiCalls.executeStreamingSql(request, options);
977
- }
978
- /**
979
- * Like {@link protos.google.spanner.v1.Spanner.Read|Read}, except returns the result set
980
- * as a stream. Unlike {@link protos.google.spanner.v1.Spanner.Read|Read}, there is no
981
- * limit on the size of the returned result set. However, no individual row in
982
- * the result set can exceed 100 MiB, and no column value can exceed
983
- * 10 MiB.
984
- *
985
- * @param {Object} request
986
- * The request object that will be sent.
987
- * @param {string} request.session
988
- * Required. The session in which the read should be performed.
989
- * @param {google.spanner.v1.TransactionSelector} request.transaction
990
- * The transaction to use. If none is provided, the default is a
991
- * temporary read-only transaction with strong concurrency.
992
- * @param {string} request.table
993
- * Required. The name of the table in the database to be read.
994
- * @param {string} request.index
995
- * If non-empty, the name of an index on
996
- * {@link protos.google.spanner.v1.ReadRequest.table|table}. This index is used instead of
997
- * the table primary key when interpreting
998
- * {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} and sorting result rows.
999
- * See {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} for further
1000
- * information.
1001
- * @param {string[]} request.columns
1002
- * Required. The columns of {@link protos.google.spanner.v1.ReadRequest.table|table} to be
1003
- * returned for each row matching this request.
1004
- * @param {google.spanner.v1.KeySet} request.keySet
1005
- * Required. `key_set` identifies the rows to be yielded. `key_set` names the
1006
- * primary keys of the rows in {@link protos.google.spanner.v1.ReadRequest.table|table} to
1007
- * be yielded, unless {@link protos.google.spanner.v1.ReadRequest.index|index} is present.
1008
- * If {@link protos.google.spanner.v1.ReadRequest.index|index} is present, then
1009
- * {@link protos.google.spanner.v1.ReadRequest.key_set|key_set} instead names index keys
1010
- * in {@link protos.google.spanner.v1.ReadRequest.index|index}.
1011
- *
1012
- * If the {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token}
1013
- * field is empty, rows are yielded in table primary key order (if
1014
- * {@link protos.google.spanner.v1.ReadRequest.index|index} is empty) or index key order
1015
- * (if {@link protos.google.spanner.v1.ReadRequest.index|index} is non-empty). If the
1016
- * {@link protos.google.spanner.v1.ReadRequest.partition_token|partition_token} field
1017
- * isn't empty, rows are yielded in an unspecified order.
1018
- *
1019
- * It isn't an error for the `key_set` to name rows that don't
1020
- * exist in the database. Read yields nothing for nonexistent rows.
1021
- * @param {number} request.limit
1022
- * If greater than zero, only the first `limit` rows are yielded. If `limit`
1023
- * is zero, the default is no limit. A limit can't be specified if
1024
- * `partition_token` is set.
1025
- * @param {Buffer} request.resumeToken
1026
- * If this request is resuming a previously interrupted read,
1027
- * `resume_token` should be copied from the last
1028
- * {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} yielded before the
1029
- * interruption. Doing this enables the new read to resume where the last read
1030
- * left off. The rest of the request parameters must exactly match the request
1031
- * that yielded this token.
1032
- * @param {Buffer} request.partitionToken
1033
- * If present, results are restricted to the specified partition
1034
- * previously created using `PartitionRead`. There must be an exact
1035
- * match for the values of fields common to this message and the
1036
- * PartitionReadRequest message used to create this partition_token.
1037
- * @param {google.spanner.v1.RequestOptions} request.requestOptions
1038
- * Common options for this request.
1039
- * @param {google.spanner.v1.DirectedReadOptions} request.directedReadOptions
1040
- * Directed read options for this request.
1041
- * @param {boolean} request.dataBoostEnabled
1042
- * If this is for a partitioned read and this field is set to `true`, the
1043
- * request is executed with Spanner Data Boost independent compute resources.
1044
- *
1045
- * If the field is set to `true` but the request doesn't set
1046
- * `partition_token`, the API returns an `INVALID_ARGUMENT` error.
1047
- * @param {google.spanner.v1.ReadRequest.OrderBy} [request.orderBy]
1048
- * Optional. Order for the returned rows.
1049
- *
1050
- * By default, Spanner returns result rows in primary key order except for
1051
- * PartitionRead requests. For applications that don't require rows to be
1052
- * returned in primary key (`ORDER_BY_PRIMARY_KEY`) order, setting
1053
- * `ORDER_BY_NO_ORDER` option allows Spanner to optimize row retrieval,
1054
- * resulting in lower latencies in certain cases (for example, bulk point
1055
- * lookups).
1056
- * @param {google.spanner.v1.ReadRequest.LockHint} [request.lockHint]
1057
- * Optional. Lock Hint for the request, it can only be used with read-write
1058
- * transactions.
1059
- * @param {google.spanner.v1.RoutingHint} [request.routingHint]
1060
- * Optional. Makes the Spanner requests location-aware if present.
1061
- *
1062
- * It gives the server hints that can be used to route the request
1063
- * to an appropriate server, potentially significantly decreasing latency and
1064
- * improving throughput. To achieve improved performance, most fields must be
1065
- * filled in with accurate values.
1066
- * @param {object} [options]
1067
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1068
- * @returns {Stream}
1069
- * An object stream which emits {@link protos.google.spanner.v1.PartialResultSet|PartialResultSet} on 'data' event.
1070
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
1071
- * for more details and examples.
1072
- */
1073
- streamingRead(request, options) {
1074
- request = request || {};
1075
- options = options || {};
1076
- options.otherArgs = options.otherArgs || {};
1077
- options.otherArgs.headers = options.otherArgs.headers || {};
1078
- options.otherArgs.headers['x-goog-request-params'] =
1079
- this._gaxModule.routingHeader.fromParams({
1080
- session: request.session ?? '',
1081
- });
1082
- this.initialize().catch(err => {
1083
- throw err;
1084
- });
1085
- this._log.info('streamingRead stream %j', options);
1086
- return this.innerApiCalls.streamingRead(request, options);
1087
- }
1088
- /**
1089
- * Batches the supplied mutation groups in a collection of efficient
1090
- * transactions. All mutations in a group are committed atomically. However,
1091
- * mutations across groups can be committed non-atomically in an unspecified
1092
- * order and thus, they must be independent of each other. Partial failure is
1093
- * possible, that is, some groups might have been committed successfully,
1094
- * while some might have failed. The results of individual batches are
1095
- * streamed into the response as the batches are applied.
1096
- *
1097
- * `BatchWrite` requests are not replay protected, meaning that each mutation
1098
- * group can be applied more than once. Replays of non-idempotent mutations
1099
- * can have undesirable effects. For example, replays of an insert mutation
1100
- * can produce an already exists error or if you use generated or commit
1101
- * timestamp-based keys, it can result in additional rows being added to the
1102
- * mutation's table. We recommend structuring your mutation groups to be
1103
- * idempotent to avoid this issue.
1104
- *
1105
- * @param {Object} request
1106
- * The request object that will be sent.
1107
- * @param {string} request.session
1108
- * Required. The session in which the batch request is to be run.
1109
- * @param {google.spanner.v1.RequestOptions} request.requestOptions
1110
- * Common options for this request.
1111
- * @param {number[]} request.mutationGroups
1112
- * Required. The groups of mutations to be applied.
1113
- * @param {boolean} [request.excludeTxnFromChangeStreams]
1114
- * Optional. If you don't set the `exclude_txn_from_change_streams` option or
1115
- * if it's set to `false`, then any change streams monitoring columns modified
1116
- * by transactions will capture the updates made within that transaction.
1117
- * @param {object} [options]
1118
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1119
- * @returns {Stream}
1120
- * An object stream which emits {@link protos.google.spanner.v1.BatchWriteResponse|BatchWriteResponse} on 'data' event.
1121
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
1122
- * for more details and examples.
1123
- */
1124
- batchWrite(request, options) {
1125
- request = request || {};
1126
- options = options || {};
1127
- options.otherArgs = options.otherArgs || {};
1128
- options.otherArgs.headers = options.otherArgs.headers || {};
1129
- options.otherArgs.headers['x-goog-request-params'] =
1130
- this._gaxModule.routingHeader.fromParams({
1131
- session: request.session ?? '',
1132
- });
1133
- this.initialize().catch(err => {
1134
- throw err;
1135
- });
1136
- this._log.info('batchWrite stream %j', options);
1137
- return this.innerApiCalls.batchWrite(request, options);
1138
- }
1139
- /**
1140
- * Retrieves a cache update for a given database.
1141
- *
1142
- * This RPC can be used to warm up the client cache by fetching key recipes
1143
- * and server information for a given database. It is recommended to call
1144
- * this RPC at the beginning of the client's lifecycle, prior to any other
1145
- * data plane operations.
1146
- *
1147
- * The cache update is returned as a stream because the response can be too
1148
- * large to fit into a single `CacheUpdate` message.
1149
- *
1150
- * @param {Object} request
1151
- * The request object that will be sent.
1152
- * @param {string} request.database
1153
- * Required. The database for which to retrieve the cache update.
1154
- * @param {number} [request.maxRecipeCount]
1155
- * Optional. The maximum number of key recipes to return in the response.
1156
- * If not set, a default limit of 100 will be used.
1157
- * @param {number} [request.maxRangeCount]
1158
- * Optional. The maximum number of ranges to return in the response.
1159
- * If not set, a default limit of 10000 will be used.
1160
- * @param {object} [options]
1161
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1162
- * @returns {Stream}
1163
- * An object stream which emits {@link protos.google.spanner.v1.CacheUpdate|CacheUpdate} on 'data' event.
1164
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#server-streaming | documentation }
1165
- * for more details and examples.
1166
- */
1167
- fetchCacheUpdate(request, options) {
1168
- request = request || {};
1169
- options = options || {};
1170
- options.otherArgs = options.otherArgs || {};
1171
- options.otherArgs.headers = options.otherArgs.headers || {};
1172
- options.otherArgs.headers['x-goog-request-params'] =
1173
- this._gaxModule.routingHeader.fromParams({
1174
- database: request.database ?? '',
1175
- });
1176
- this.initialize().catch(err => {
1177
- throw err;
1178
- });
1179
- this._log.info('fetchCacheUpdate stream %j', options);
1180
- return this.innerApiCalls.fetchCacheUpdate(request, options);
1181
- }
1182
- listSessions(request, optionsOrCallback, callback) {
1183
- request = request || {};
1184
- let options;
1185
- if (typeof optionsOrCallback === 'function' && callback === undefined) {
1186
- callback = optionsOrCallback;
1187
- options = {};
1188
- }
1189
- else {
1190
- options = optionsOrCallback;
1191
- }
1192
- options = options || {};
1193
- options.otherArgs = options.otherArgs || {};
1194
- options.otherArgs.headers = options.otherArgs.headers || {};
1195
- options.otherArgs.headers['x-goog-request-params'] =
1196
- this._gaxModule.routingHeader.fromParams({
1197
- database: request.database ?? '',
1198
- });
1199
- this.initialize().catch(err => {
1200
- throw err;
1201
- });
1202
- const wrappedCallback = callback
1203
- ? (error, values, nextPageRequest, rawResponse) => {
1204
- this._log.info('listSessions values %j', values);
1205
- callback(error, values, nextPageRequest, rawResponse); // We verified callback above.
1206
- }
1207
- : undefined;
1208
- this._log.info('listSessions request %j', request);
1209
- return this.innerApiCalls
1210
- .listSessions(request, options, wrappedCallback)
1211
- ?.then(([response, input, output]) => {
1212
- this._log.info('listSessions values %j', response);
1213
- return [response, input, output];
1214
- });
1215
- }
1216
- /**
1217
- * Equivalent to `listSessions`, but returns a NodeJS Stream object.
1218
- * @param {Object} request
1219
- * The request object that will be sent.
1220
- * @param {string} request.database
1221
- * Required. The database in which to list sessions.
1222
- * @param {number} request.pageSize
1223
- * Number of sessions to be returned in the response. If 0 or less, defaults
1224
- * to the server's maximum allowed page size.
1225
- * @param {string} request.pageToken
1226
- * If non-empty, `page_token` should contain a
1227
- * {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
1228
- * from a previous
1229
- * {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
1230
- * @param {string} request.filter
1231
- * An expression for filtering the results of the request. Filter rules are
1232
- * case insensitive. The fields eligible for filtering are:
1233
- *
1234
- * * `labels.key` where key is the name of a label
1235
- *
1236
- * Some examples of using filters are:
1237
- *
1238
- * * `labels.env:*` --> The session has the label "env".
1239
- * * `labels.env:dev` --> The session has the label "env" and the value of
1240
- * the label contains the string "dev".
1241
- * @param {object} [options]
1242
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1243
- * @returns {Stream}
1244
- * An object stream which emits an object representing {@link protos.google.spanner.v1.Session|Session} on 'data' event.
1245
- * The client library will perform auto-pagination by default: it will call the API as many
1246
- * times as needed. Note that it can affect your quota.
1247
- * We recommend using `listSessionsAsync()`
1248
- * method described below for async iteration which you can stop as needed.
1249
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1250
- * for more details and examples.
1251
- */
1252
- listSessionsStream(request, options) {
1253
- request = request || {};
1254
- options = options || {};
1255
- options.otherArgs = options.otherArgs || {};
1256
- options.otherArgs.headers = options.otherArgs.headers || {};
1257
- options.otherArgs.headers['x-goog-request-params'] =
1258
- this._gaxModule.routingHeader.fromParams({
1259
- database: request.database ?? '',
1260
- });
1261
- const defaultCallSettings = this._defaults['listSessions'];
1262
- const callSettings = defaultCallSettings.merge(options);
1263
- this.initialize().catch(err => {
1264
- throw err;
1265
- });
1266
- this._log.info('listSessions stream %j', request);
1267
- return this.descriptors.page.listSessions.createStream(this.innerApiCalls.listSessions, request, callSettings);
1268
- }
1269
- /**
1270
- * Equivalent to `listSessions`, but returns an iterable object.
1271
- *
1272
- * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
1273
- * @param {Object} request
1274
- * The request object that will be sent.
1275
- * @param {string} request.database
1276
- * Required. The database in which to list sessions.
1277
- * @param {number} request.pageSize
1278
- * Number of sessions to be returned in the response. If 0 or less, defaults
1279
- * to the server's maximum allowed page size.
1280
- * @param {string} request.pageToken
1281
- * If non-empty, `page_token` should contain a
1282
- * {@link protos.google.spanner.v1.ListSessionsResponse.next_page_token|next_page_token}
1283
- * from a previous
1284
- * {@link protos.google.spanner.v1.ListSessionsResponse|ListSessionsResponse}.
1285
- * @param {string} request.filter
1286
- * An expression for filtering the results of the request. Filter rules are
1287
- * case insensitive. The fields eligible for filtering are:
1288
- *
1289
- * * `labels.key` where key is the name of a label
1290
- *
1291
- * Some examples of using filters are:
1292
- *
1293
- * * `labels.env:*` --> The session has the label "env".
1294
- * * `labels.env:dev` --> The session has the label "env" and the value of
1295
- * the label contains the string "dev".
1296
- * @param {object} [options]
1297
- * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1298
- * @returns {Object}
1299
- * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }.
1300
- * When you iterate the returned iterable, each element will be an object representing
1301
- * {@link protos.google.spanner.v1.Session|Session}. The API will be called under the hood as needed, once per the page,
1302
- * so you can stop the iteration when you don't need more results.
1303
- * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation }
1304
- * for more details and examples.
1305
- */
1306
- listSessionsAsync(request, options) {
1307
- request = request || {};
1308
- options = options || {};
1309
- options.otherArgs = options.otherArgs || {};
1310
- options.otherArgs.headers = options.otherArgs.headers || {};
1311
- options.otherArgs.headers['x-goog-request-params'] =
1312
- this._gaxModule.routingHeader.fromParams({
1313
- database: request.database ?? '',
1314
- });
1315
- const defaultCallSettings = this._defaults['listSessions'];
1316
- const callSettings = defaultCallSettings.merge(options);
1317
- this.initialize().catch(err => {
1318
- throw err;
1319
- });
1320
- this._log.info('listSessions iterate %j', request);
1321
- return this.descriptors.page.listSessions.asyncIterate(this.innerApiCalls['listSessions'], request, callSettings);
1322
- }
1323
- // --------------------
1324
- // -- Path templates --
1325
- // --------------------
1326
- /**
1327
- * Return a fully-qualified database resource name string.
1328
- *
1329
- * @param {string} project
1330
- * @param {string} instance
1331
- * @param {string} database
1332
- * @returns {string} Resource name string.
1333
- */
1334
- databasePath(project, instance, database) {
1335
- return this.pathTemplates.databasePathTemplate.render({
1336
- project: project,
1337
- instance: instance,
1338
- database: database,
1339
- });
1340
- }
1341
- /**
1342
- * Parse the project from Database resource.
1343
- *
1344
- * @param {string} databaseName
1345
- * A fully-qualified path representing Database resource.
1346
- * @returns {string} A string representing the project.
1347
- */
1348
- matchProjectFromDatabaseName(databaseName) {
1349
- return this.pathTemplates.databasePathTemplate.match(databaseName).project;
1350
- }
1351
- /**
1352
- * Parse the instance from Database resource.
1353
- *
1354
- * @param {string} databaseName
1355
- * A fully-qualified path representing Database resource.
1356
- * @returns {string} A string representing the instance.
1357
- */
1358
- matchInstanceFromDatabaseName(databaseName) {
1359
- return this.pathTemplates.databasePathTemplate.match(databaseName).instance;
1360
- }
1361
- /**
1362
- * Parse the database from Database resource.
1363
- *
1364
- * @param {string} databaseName
1365
- * A fully-qualified path representing Database resource.
1366
- * @returns {string} A string representing the database.
1367
- */
1368
- matchDatabaseFromDatabaseName(databaseName) {
1369
- return this.pathTemplates.databasePathTemplate.match(databaseName).database;
1370
- }
1371
- /**
1372
- * Return a fully-qualified session resource name string.
1373
- *
1374
- * @param {string} project
1375
- * @param {string} instance
1376
- * @param {string} database
1377
- * @param {string} session
1378
- * @returns {string} Resource name string.
1379
- */
1380
- sessionPath(project, instance, database, session) {
1381
- return this.pathTemplates.sessionPathTemplate.render({
1382
- project: project,
1383
- instance: instance,
1384
- database: database,
1385
- session: session,
1386
- });
1387
- }
1388
- /**
1389
- * Parse the project from Session resource.
1390
- *
1391
- * @param {string} sessionName
1392
- * A fully-qualified path representing Session resource.
1393
- * @returns {string} A string representing the project.
1394
- */
1395
- matchProjectFromSessionName(sessionName) {
1396
- return this.pathTemplates.sessionPathTemplate.match(sessionName).project;
1397
- }
1398
- /**
1399
- * Parse the instance from Session resource.
1400
- *
1401
- * @param {string} sessionName
1402
- * A fully-qualified path representing Session resource.
1403
- * @returns {string} A string representing the instance.
1404
- */
1405
- matchInstanceFromSessionName(sessionName) {
1406
- return this.pathTemplates.sessionPathTemplate.match(sessionName).instance;
1407
- }
1408
- /**
1409
- * Parse the database from Session resource.
1410
- *
1411
- * @param {string} sessionName
1412
- * A fully-qualified path representing Session resource.
1413
- * @returns {string} A string representing the database.
1414
- */
1415
- matchDatabaseFromSessionName(sessionName) {
1416
- return this.pathTemplates.sessionPathTemplate.match(sessionName).database;
1417
- }
1418
- /**
1419
- * Parse the session from Session resource.
1420
- *
1421
- * @param {string} sessionName
1422
- * A fully-qualified path representing Session resource.
1423
- * @returns {string} A string representing the session.
1424
- */
1425
- matchSessionFromSessionName(sessionName) {
1426
- return this.pathTemplates.sessionPathTemplate.match(sessionName).session;
1427
- }
1428
- /**
1429
- * Terminate the gRPC channel and close the client.
1430
- *
1431
- * The client will no longer be usable and all future behavior is undefined.
1432
- * @returns {Promise} A promise that resolves when the client is closed.
1433
- */
1434
- close() {
1435
- if (this.spannerStub && !this._terminated) {
1436
- return this.spannerStub.then(stub => {
1437
- this._log.info('ending gRPC channel');
1438
- this._terminated = true;
1439
- stub.close();
1440
- });
1441
- }
1442
- return Promise.resolve();
1443
- }
1444
- }
1445
- exports.SpannerClient = SpannerClient;
1446
- //# sourceMappingURL=spanner_client.js.map