@google-cloud/spanner 7.2.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2023 Google LLC
2
+ // Copyright 2024 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ class InstanceAdminClient {
92
92
  * ```
93
93
  */
94
94
  constructor(opts, gaxInstance) {
95
- var _a, _b;
95
+ var _a, _b, _c, _d;
96
96
  this._terminated = false;
97
97
  this.descriptors = {
98
98
  page: {},
@@ -102,16 +102,24 @@ class InstanceAdminClient {
102
102
  };
103
103
  // Ensure that options include all the required fields.
104
104
  const staticMembers = this.constructor;
105
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
105
+ if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
106
+ (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
107
+ (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
108
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
109
+ }
110
+ this._universeDomain =
111
+ (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : 'googleapis.com';
112
+ this._servicePath = 'spanner.' + this._universeDomain;
113
+ const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
106
114
  this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
107
115
  const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
108
- const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
109
- const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
116
+ const clientConfig = (_c = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _c !== void 0 ? _c : {};
117
+ const fallback = (_d = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _d !== void 0 ? _d : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
110
118
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
111
119
  // Request numeric enum values if REST transport is used.
112
120
  opts.numericEnums = true;
113
121
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
114
- if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
122
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
115
123
  opts['scopes'] = staticMembers.scopes;
116
124
  }
117
125
  // Load google-gax module synchronously if needed
@@ -129,9 +137,9 @@ class InstanceAdminClient {
129
137
  // Set useJWTAccessWithScope on the auth object.
130
138
  this.auth.useJWTAccessWithScope = true;
131
139
  // Set defaultServicePath on the auth object.
132
- this.auth.defaultServicePath = staticMembers.servicePath;
140
+ this.auth.defaultServicePath = this._servicePath;
133
141
  // Set the default scopes in auth client if needed.
134
- if (servicePath === staticMembers.servicePath) {
142
+ if (servicePath === this._servicePath) {
135
143
  this.auth.defaultScopes = staticMembers.scopes;
136
144
  }
137
145
  // Determine the client header string.
@@ -296,19 +304,38 @@ class InstanceAdminClient {
296
304
  }
297
305
  /**
298
306
  * The DNS address for this API service.
307
+ * @deprecated Use the apiEndpoint method of the client instance.
299
308
  * @returns {string} The DNS address for this service.
300
309
  */
301
310
  static get servicePath() {
311
+ if (typeof process !== undefined &&
312
+ typeof process.emitWarning === 'function') {
313
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
314
+ }
302
315
  return 'spanner.googleapis.com';
303
316
  }
304
317
  /**
305
- * The DNS address for this API service - same as servicePath(),
306
- * exists for compatibility reasons.
318
+ * The DNS address for this API service - same as servicePath.
319
+ * @deprecated Use the apiEndpoint method of the client instance.
307
320
  * @returns {string} The DNS address for this service.
308
321
  */
309
322
  static get apiEndpoint() {
323
+ if (typeof process !== undefined &&
324
+ typeof process.emitWarning === 'function') {
325
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
326
+ }
310
327
  return 'spanner.googleapis.com';
311
328
  }
329
+ /**
330
+ * The DNS address for this API service.
331
+ * @returns {string} The DNS address for this service.
332
+ */
333
+ get apiEndpoint() {
334
+ return this._servicePath;
335
+ }
336
+ get universeDomain() {
337
+ return this._universeDomain;
338
+ }
312
339
  /**
313
340
  * The port for this API service.
314
341
  * @returns {number} The default port for this service.
@@ -19,6 +19,8 @@ export declare class SpannerClient {
19
19
  private _gaxGrpc;
20
20
  private _protos;
21
21
  private _defaults;
22
+ private _universeDomain;
23
+ private _servicePath;
22
24
  auth: gax.GoogleAuth;
23
25
  descriptors: Descriptors;
24
26
  warn: (code: string, message: string, warnType?: string) => void;
@@ -87,15 +89,22 @@ export declare class SpannerClient {
87
89
  }>;
88
90
  /**
89
91
  * The DNS address for this API service.
92
+ * @deprecated Use the apiEndpoint method of the client instance.
90
93
  * @returns {string} The DNS address for this service.
91
94
  */
92
95
  static get servicePath(): string;
93
96
  /**
94
- * The DNS address for this API service - same as servicePath(),
95
- * exists for compatibility reasons.
97
+ * The DNS address for this API service - same as servicePath.
98
+ * @deprecated Use the apiEndpoint method of the client instance.
96
99
  * @returns {string} The DNS address for this service.
97
100
  */
98
101
  static get apiEndpoint(): string;
102
+ /**
103
+ * The DNS address for this API service.
104
+ * @returns {string} The DNS address for this service.
105
+ */
106
+ get apiEndpoint(): string;
107
+ get universeDomain(): string;
99
108
  /**
100
109
  * The port for this API service.
101
110
  * @returns {number} The default port for this service.
@@ -562,6 +571,12 @@ export declare class SpannerClient {
562
571
  * If `true`, then statistics related to the transaction will be included in
563
572
  * the {@link protos.google.spanner.v1.CommitResponse.commit_stats|CommitResponse}.
564
573
  * Default value is `false`.
574
+ * @param {google.protobuf.Duration} [request.maxCommitDelay]
575
+ * Optional. The amount of latency this request is willing to incur in order
576
+ * to improve throughput. If this field is not set, Spanner assumes requests
577
+ * are relatively latency sensitive and automatically determines an
578
+ * appropriate delay time. You can specify a batching delay value between 0
579
+ * and 500 ms.
565
580
  * @param {google.spanner.v1.RequestOptions} request.requestOptions
566
581
  * Common options for this request.
567
582
  * @param {object} [options]
@@ -633,9 +648,10 @@ export declare class SpannerClient {
633
648
  * @param {string} request.sql
634
649
  * Required. The query request to generate partitions for. The request will
635
650
  * fail if the query is not root partitionable. For a query to be root
636
- * partitionable, it needs to satisfy a few conditions. For example, the first
637
- * operator in the query execution plan must be a distributed union operator.
638
- * For more information about other conditions, see [Read data in
651
+ * partitionable, it needs to satisfy a few conditions. For example, if the
652
+ * query execution plan contains a distributed union operator, then it must be
653
+ * the first operator in the plan. For more information about other
654
+ * conditions, see [Read data in
639
655
  * parallel](https://cloud.google.com/spanner/docs/reads#read_data_in_parallel).
640
656
  *
641
657
  * The query request must not contain DML commands, such as INSERT, UPDATE, or
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2023 Google LLC
2
+ // Copyright 2024 Google LLC
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License");
5
5
  // you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ class SpannerClient {
76
76
  * ```
77
77
  */
78
78
  constructor(opts, gaxInstance) {
79
- var _a, _b;
79
+ var _a, _b, _c, _d;
80
80
  this._terminated = false;
81
81
  this.descriptors = {
82
82
  page: {},
@@ -86,16 +86,24 @@ class SpannerClient {
86
86
  };
87
87
  // Ensure that options include all the required fields.
88
88
  const staticMembers = this.constructor;
89
- const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
89
+ if ((opts === null || opts === void 0 ? void 0 : opts.universe_domain) &&
90
+ (opts === null || opts === void 0 ? void 0 : opts.universeDomain) &&
91
+ (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
92
+ throw new Error('Please set either universe_domain or universeDomain, but not both.');
93
+ }
94
+ this._universeDomain =
95
+ (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : 'googleapis.com';
96
+ this._servicePath = 'spanner.' + this._universeDomain;
97
+ const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
90
98
  this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
91
99
  const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
92
- const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
93
- const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
100
+ const clientConfig = (_c = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _c !== void 0 ? _c : {};
101
+ const fallback = (_d = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _d !== void 0 ? _d : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
94
102
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
95
103
  // Request numeric enum values if REST transport is used.
96
104
  opts.numericEnums = true;
97
105
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
98
- if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
106
+ if (servicePath !== this._servicePath && !('scopes' in opts)) {
99
107
  opts['scopes'] = staticMembers.scopes;
100
108
  }
101
109
  // Load google-gax module synchronously if needed
@@ -113,9 +121,9 @@ class SpannerClient {
113
121
  // Set useJWTAccessWithScope on the auth object.
114
122
  this.auth.useJWTAccessWithScope = true;
115
123
  // Set defaultServicePath on the auth object.
116
- this.auth.defaultServicePath = staticMembers.servicePath;
124
+ this.auth.defaultServicePath = this._servicePath;
117
125
  // Set the default scopes in auth client if needed.
118
- if (servicePath === staticMembers.servicePath) {
126
+ if (servicePath === this._servicePath) {
119
127
  this.auth.defaultScopes = staticMembers.scopes;
120
128
  }
121
129
  // Determine the client header string.
@@ -153,9 +161,12 @@ class SpannerClient {
153
161
  // Some of the methods on this service provide streaming responses.
154
162
  // Provide descriptors for these.
155
163
  this.descriptors.stream = {
156
- executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback),
157
- streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback),
158
- batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback),
164
+ executeStreamingSql: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback,
165
+ /* gaxStreamingRetries: */ false),
166
+ streamingRead: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback,
167
+ /* gaxStreamingRetries: */ false),
168
+ batchWrite: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback,
169
+ /* gaxStreamingRetries: */ false),
159
170
  };
160
171
  // Put together the default options sent with requests.
161
172
  this._defaults = this._gaxGrpc.constructSettings('google.spanner.v1.Spanner', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
@@ -235,19 +246,38 @@ class SpannerClient {
235
246
  }
236
247
  /**
237
248
  * The DNS address for this API service.
249
+ * @deprecated Use the apiEndpoint method of the client instance.
238
250
  * @returns {string} The DNS address for this service.
239
251
  */
240
252
  static get servicePath() {
253
+ if (typeof process !== undefined &&
254
+ typeof process.emitWarning === 'function') {
255
+ process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
256
+ }
241
257
  return 'spanner.googleapis.com';
242
258
  }
243
259
  /**
244
- * The DNS address for this API service - same as servicePath(),
245
- * exists for compatibility reasons.
260
+ * The DNS address for this API service - same as servicePath.
261
+ * @deprecated Use the apiEndpoint method of the client instance.
246
262
  * @returns {string} The DNS address for this service.
247
263
  */
248
264
  static get apiEndpoint() {
265
+ if (typeof process !== undefined &&
266
+ typeof process.emitWarning === 'function') {
267
+ process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
268
+ }
249
269
  return 'spanner.googleapis.com';
250
270
  }
271
+ /**
272
+ * The DNS address for this API service.
273
+ * @returns {string} The DNS address for this service.
274
+ */
275
+ get apiEndpoint() {
276
+ return this._servicePath;
277
+ }
278
+ get universeDomain() {
279
+ return this._universeDomain;
280
+ }
251
281
  /**
252
282
  * The port for this API service.
253
283
  * @returns {number} The default port for this service.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "7.2.0",
4
+ "version": "7.3.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -65,7 +65,7 @@
65
65
  "events-intercept": "^2.0.0",
66
66
  "extend": "^3.0.2",
67
67
  "google-auth-library": "^9.0.0",
68
- "google-gax": "4.0.5",
68
+ "google-gax": "4.3.0",
69
69
  "grpc-gcp": "^1.0.0",
70
70
  "is": "^3.2.1",
71
71
  "lodash.snakecase": "^4.1.1",
@@ -90,7 +90,7 @@
90
90
  "@types/ncp": "^2.0.1",
91
91
  "@types/proxyquire": "^1.3.28",
92
92
  "@types/request": "^2.48.3",
93
- "@types/sinon": "^10.0.0",
93
+ "@types/sinon": "^17.0.0",
94
94
  "@types/through2": "^2.0.34",
95
95
  "@types/uuid": "^9.0.0",
96
96
  "binary-search-bounds": "^2.0.4",
@@ -99,7 +99,7 @@
99
99
  "concat-stream": "^2.0.0",
100
100
  "dedent": "^1.0.0",
101
101
  "execa": "^5.0.0",
102
- "gapic-tools": "^0.2.0",
102
+ "gapic-tools": "^0.3.0",
103
103
  "gts": "^5.0.0",
104
104
  "jsdoc": "^4.0.0",
105
105
  "jsdoc-fresh": "^3.0.0",
@@ -111,7 +111,7 @@
111
111
  "ncp": "^2.0.0",
112
112
  "p-limit": "^3.0.1",
113
113
  "proxyquire": "^2.0.1",
114
- "sinon": "^15.0.0",
114
+ "sinon": "^17.0.0",
115
115
  "stats-lite": "^2.1.1",
116
116
  "time-span": "^4.0.0",
117
117
  "tmp": "^0.2.0",