@google-cloud/spanner 7.21.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/build/protos/google/spanner/admin/database/v1/backup.proto +1 -1
  2. package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +1 -1
  3. package/build/protos/google/spanner/admin/database/v1/common.proto +1 -1
  4. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +1 -1
  5. package/build/protos/google/spanner/admin/instance/v1/common.proto +1 -1
  6. package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +1 -1
  7. package/build/protos/google/spanner/executor/v1/cloud_executor.proto +1 -1
  8. package/build/protos/google/spanner/v1/commit_response.proto +1 -1
  9. package/build/protos/google/spanner/v1/keys.proto +1 -1
  10. package/build/protos/google/spanner/v1/mutation.proto +1 -1
  11. package/build/protos/google/spanner/v1/query_plan.proto +1 -1
  12. package/build/protos/google/spanner/v1/result_set.proto +55 -49
  13. package/build/protos/google/spanner/v1/spanner.proto +1 -1
  14. package/build/protos/google/spanner/v1/transaction.proto +1 -1
  15. package/build/protos/google/spanner/v1/type.proto +1 -1
  16. package/build/protos/protos.d.ts +56 -194
  17. package/build/protos/protos.js +71 -288
  18. package/build/protos/protos.json +8 -2
  19. package/build/src/backup.js +7 -0
  20. package/build/src/batch-transaction.d.ts +48 -29
  21. package/build/src/batch-transaction.js +13 -98
  22. package/build/src/codec.js +43 -26
  23. package/build/src/common-grpc/service-object.js +1 -0
  24. package/build/src/common-grpc/service.js +25 -8
  25. package/build/src/database.js +52 -42
  26. package/build/src/helper.d.ts +9 -0
  27. package/build/src/helper.js +24 -0
  28. package/build/src/index.js +24 -13
  29. package/build/src/instance-config.d.ts +1 -1
  30. package/build/src/instance-config.js +4 -0
  31. package/build/src/instance.js +12 -6
  32. package/build/src/instrument.js +2 -4
  33. package/build/src/multiplexed-session.js +7 -1
  34. package/build/src/partial-result-stream.js +9 -5
  35. package/build/src/request_id_header.js +1 -0
  36. package/build/src/session-factory.js +5 -2
  37. package/build/src/session-pool.js +23 -6
  38. package/build/src/session.d.ts +0 -1
  39. package/build/src/session.js +7 -2
  40. package/build/src/table.js +6 -3
  41. package/build/src/transaction-runner.js +12 -2
  42. package/build/src/transaction.js +66 -52
  43. package/build/src/v1/database_admin_client.d.ts +3 -2
  44. package/build/src/v1/database_admin_client.js +551 -167
  45. package/build/src/v1/instance_admin_client.d.ts +2 -1
  46. package/build/src/v1/instance_admin_client.js +453 -133
  47. package/build/src/v1/spanner_client.d.ts +2 -1
  48. package/build/src/v1/spanner_client.js +283 -85
  49. package/build/src/v1/spanner_executor_proxy_client.d.ts +2 -1
  50. package/build/src/v1/spanner_executor_proxy_client.js +41 -19
  51. package/package.json +57 -58
@@ -7673,8 +7673,7 @@
7673
7673
  "php_namespace": "Google\\Cloud\\Spanner\\V1",
7674
7674
  "ruby_package": "Google::Cloud::Spanner::V1",
7675
7675
  "(google.api.resource_definition).type": "spanner.googleapis.com/Database",
7676
- "(google.api.resource_definition).pattern": "projects/{project}/instances/{instance}/databases/{database}",
7677
- "cc_enable_arenas": true
7676
+ "(google.api.resource_definition).pattern": "projects/{project}/instances/{instance}/databases/{database}"
7678
7677
  },
7679
7678
  "nested": {
7680
7679
  "Spanner": {
@@ -9155,6 +9154,13 @@
9155
9154
  "options": {
9156
9155
  "(google.api.field_behavior)": "OPTIONAL"
9157
9156
  }
9157
+ },
9158
+ "last": {
9159
+ "type": "bool",
9160
+ "id": 9,
9161
+ "options": {
9162
+ "(google.api.field_behavior)": "OPTIONAL"
9163
+ }
9158
9164
  }
9159
9165
  }
9160
9166
  },
@@ -45,6 +45,13 @@ const precise_date_1 = require("@google-cloud/precise-date");
45
45
  * ```
46
46
  */
47
47
  class Backup {
48
+ id;
49
+ formattedName_;
50
+ instanceFormattedName_;
51
+ resourceHeader_;
52
+ request;
53
+ metadata;
54
+ sourceName;
48
55
  constructor(instance, name, sourceName) {
49
56
  this.request = instance.request;
50
57
  this.instanceFormattedName_ = instance.formattedName_;
@@ -13,14 +13,25 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Snapshot } from './transaction';
16
+ import { ExecuteSqlRequest, ReadCallback, ReadRequest, ReadResponse, RunCallback, RunResponse, Snapshot } from './transaction';
17
17
  import { google } from '../protos/protos';
18
18
  import { Session } from '.';
19
+ import { ResourceCallback } from '../src/common';
19
20
  export interface TransactionIdentifier {
20
21
  session: string | Session;
21
22
  transaction?: string;
22
23
  timestamp?: google.protobuf.ITimestamp;
23
24
  }
25
+ export type CreateReadPartitionsResponse = [
26
+ ReadRequest[],
27
+ google.spanner.v1.IPartitionResponse
28
+ ];
29
+ export type CreateReadPartitionsCallback = ResourceCallback<ReadRequest[], google.spanner.v1.IPartitionResponse>;
30
+ export type CreateQueryPartitionsResponse = [
31
+ ExecuteSqlRequest[],
32
+ google.spanner.v1.IPartitionResponse
33
+ ];
34
+ export type CreateQueryPartitionsCallback = ResourceCallback<ExecuteSqlRequest[], google.spanner.v1.IPartitionResponse>;
24
35
  /**
25
36
  * Use a BatchTransaction object to create partitions and read/query against
26
37
  * your Cloud Spanner database.
@@ -75,17 +86,17 @@ declare class BatchTransaction extends Snapshot {
75
86
  /**
76
87
  * @see [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
77
88
  * @typedef {object} QueryPartition
78
- * @property {string} partitionToken The partition token.
89
+ * @property {string} partitionToken A token representing the partition, used to identify and execute the partition at a later time.
79
90
  */
80
91
  /**
81
92
  * @typedef {array} CreateQueryPartitionsResponse
82
- * @property {QueryPartition[]} 0 List of query partitions.
93
+ * @property {ExecuteSqlRequest[]} 0 Array of ExecuteSqlRequest partitions.
83
94
  * @property {object} 1 The full API response.
84
95
  */
85
96
  /**
86
97
  * @callback CreateQueryPartitionsCallback
87
98
  * @param {?Error} err Request error, if any.
88
- * @param {QueryPartition[]} partitions List of query partitions.
99
+ * @param {ExecuteSqlRequest[]} partitions Array of ExecuteSqlRequest partitions.
89
100
  * @param {object} apiResponse The full API response.
90
101
  */
91
102
  /**
@@ -93,22 +104,23 @@ declare class BatchTransaction extends Snapshot {
93
104
  * operation in parallel. Partitions become invalid when the transaction used
94
105
  * to create them is closed.
95
106
  *
96
- * @param {string|object} query A SQL query or
97
- * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
98
- * object.
107
+ * @param {string|ExecuteSqlRequest} query - A SQL query string or an {@link ExecuteSqlRequest} object.
108
+ * If a string is provided, it will be wrapped into an `ExecuteSqlRequest`.
99
109
  * @param {object} [query.gaxOptions] Request configuration options,
100
110
  * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
101
111
  * for more details.
102
112
  * @param {object} [query.params] A map of parameter name to values.
103
113
  * @param {object} [query.partitionOptions] A map of partition options.
104
114
  * @param {object} [query.types] A map of parameter types.
105
- * @param {CreateQueryPartitionsCallback} [callback] Callback callback function.
106
- * @returns {Promise<CreateQueryPartitionsResponse>}
115
+ * @param {CreateQueryPartitionsCallback} [callback] - Optional Callback function. If not provided, a promise is returned.
116
+ * @returns {Promise<CreateQueryPartitionsResponse>|void} A promise resolving to an array of
117
+ * `ExecuteSqlRequest' partitions and `IPartitionResponse` , or void if a callback is provided.
107
118
  *
108
119
  * @example <caption>include:samples/batch.js</caption>
109
120
  * region_tag:spanner_batch_client
110
121
  */
111
- createQueryPartitions(query: any, callback: any): void;
122
+ createQueryPartitions(query: string | ExecuteSqlRequest): Promise<CreateQueryPartitionsResponse>;
123
+ createQueryPartitions(query: string | ExecuteSqlRequest, callback: CreateQueryPartitionsCallback): void;
112
124
  protected getDBName(): string;
113
125
  /**
114
126
  * Generic create partition method. Handles common parameters used in both
@@ -124,20 +136,20 @@ declare class BatchTransaction extends Snapshot {
124
136
  /**
125
137
  * @typedef {object} ReadPartition
126
138
  * @mixes ReadRequestOptions
127
- * @property {string} partitionToken The partition token.
128
- * @property {object} [gaxOptions] Request configuration options,
129
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
139
+ * @property {string} partitionToken partitionToken A token representing the partition, used to identify and execute the partition at a later time.
140
+ * @property {object} [gaxOptions] optional request configuration options,
141
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
130
142
  * for more details.
131
143
  */
132
144
  /**
133
145
  * @typedef {array} CreateReadPartitionsResponse
134
- * @property {ReadPartition[]} 0 List of read partitions.
146
+ * @property {ReadPartition[]} 0 Array of read partitions.
135
147
  * @property {object} 1 The full API response.
136
148
  */
137
149
  /**
138
150
  * @callback CreateReadPartitionsCallback
139
151
  * @param {?Error} err Request error, if any.
140
- * @param {ReadPartition[]} partitions List of read partitions.
152
+ * @param {ReadPartition[]} partitions Array of read partitions.
141
153
  * @param {object} apiResponse The full API response.
142
154
  */
143
155
  /**
@@ -145,30 +157,37 @@ declare class BatchTransaction extends Snapshot {
145
157
  * operation in parallel. Partitions become invalid when the transaction used
146
158
  * to create them is closed.
147
159
  *
148
- * @param {ReadRequestOptions} options Configuration object, describing what to
160
+ * @param {ReadRequest} options Configuration object, describing what to
149
161
  * read from.
150
162
  * @param {CreateReadPartitionsCallback} [callback] Callback function.
151
- * @returns {Promise<CreateReadPartitionsResponse>}
163
+ * @returns {Promise<CreateReadPartitionsResponse>|void} A promise that resolves
164
+ * to an array containing the read partitions and the full API response, or `void` if a callback is provided.
152
165
  */
153
- createReadPartitions(options: any, callback: any): void;
166
+ createReadPartitions(options: ReadRequest): Promise<CreateReadPartitionsResponse>;
167
+ createReadPartitions(options: ReadRequest, callback: CreateReadPartitionsCallback): void;
154
168
  /**
155
- * Executes partition.
169
+ * Executes partition using either a read or a SQL query, depending on the type of partition provided.
156
170
  *
157
- * @see {@link Transaction#read} when using {@link ReadPartition}.
158
- * @see {@link Transaction#run} when using {@link QueryParition}.
171
+ * @param {ReadRequest|ExecuteSqlRequest} partition The partition object to execute.
172
+ * This can either be a `ReadPartition` or a `QueryPartition`.
159
173
  *
160
- * @param {ReadPartition|QueryParition} partition The partition object.
161
- * @param {object} [partition.gaxOptions] Request configuration options,
162
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
163
- * for more details.
164
- * @param {TransactionRequestReadCallback|RunCallback} [callback] Callback
165
- * function.
166
- * @returns {Promise<RunResponse>|Promise<TransactionRequestReadResponse>}
174
+ * @param {ReadCallback|RunCallback} [callback] Optional Callback function. If not provided,
175
+ * a promise will be returned.
176
+ *
177
+ * If the partition is a read partition, it will execute a read using {@link Transaction#read}
178
+ * @see {@link Transaction#read} when using {@link ReadRequest}.
179
+ *
180
+ * If the partition is query partition, it will execute a SQL query using {@link Transaction#run}
181
+ * @see {@link Transaction#run} when using {@link ExecuteSqlRequest}.
182
+ *
183
+ * @returns {Promise<ReadResponse | RunResponse>|void} Returns a promise when no callback is provided,
184
+ * or void when a callback is used.
167
185
  *
168
186
  * @example <caption>include:samples/batch.js</caption>
169
187
  * region_tag:spanner_batch_execute_partitions
170
188
  */
171
- execute(partition: any, callback: any): void;
189
+ execute(partition: ReadRequest | ExecuteSqlRequest): Promise<ReadResponse | RunResponse>;
190
+ execute(partition: ReadRequest | ExecuteSqlRequest, callback: ReadCallback | RunCallback): void;
172
191
  /**
173
192
  * Executes partition in streaming mode.
174
193
  *
@@ -80,53 +80,13 @@ class BatchTransaction extends transaction_1.Snapshot {
80
80
  callback();
81
81
  }
82
82
  }
83
- /**
84
- * @see [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
85
- * @typedef {object} QueryPartition
86
- * @property {string} partitionToken The partition token.
87
- */
88
- /**
89
- * @typedef {array} CreateQueryPartitionsResponse
90
- * @property {QueryPartition[]} 0 List of query partitions.
91
- * @property {object} 1 The full API response.
92
- */
93
- /**
94
- * @callback CreateQueryPartitionsCallback
95
- * @param {?Error} err Request error, if any.
96
- * @param {QueryPartition[]} partitions List of query partitions.
97
- * @param {object} apiResponse The full API response.
98
- */
99
- /**
100
- * Creates a set of query partitions that can be used to execute a query
101
- * operation in parallel. Partitions become invalid when the transaction used
102
- * to create them is closed.
103
- *
104
- * @param {string|object} query A SQL query or
105
- * [`ExecuteSqlRequest`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.ExecuteSqlRequest)
106
- * object.
107
- * @param {object} [query.gaxOptions] Request configuration options,
108
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
109
- * for more details.
110
- * @param {object} [query.params] A map of parameter name to values.
111
- * @param {object} [query.partitionOptions] A map of partition options.
112
- * @param {object} [query.types] A map of parameter types.
113
- * @param {CreateQueryPartitionsCallback} [callback] Callback callback function.
114
- * @returns {Promise<CreateQueryPartitionsResponse>}
115
- *
116
- * @example <caption>include:samples/batch.js</caption>
117
- * region_tag:spanner_batch_client
118
- */
119
- createQueryPartitions(query, callback) {
120
- if (is.string(query)) {
121
- query = {
122
- sql: query,
123
- };
124
- }
125
- const reqOpts = Object.assign({}, query, transaction_1.Snapshot.encodeParams(query));
83
+ createQueryPartitions(query, cb) {
84
+ const request = typeof query === 'string' ? { sql: query } : query;
85
+ const reqOpts = Object.assign({}, request, transaction_1.Snapshot.encodeParams(request));
126
86
  delete reqOpts.gaxOptions;
127
87
  delete reqOpts.types;
128
88
  const traceConfig = {
129
- sql: query,
89
+ sql: request.sql,
130
90
  opts: this._observabilityOptions,
131
91
  dbName: this.getDBName(),
132
92
  };
@@ -139,14 +99,14 @@ class BatchTransaction extends transaction_1.Snapshot {
139
99
  client: 'SpannerClient',
140
100
  method: 'partitionQuery',
141
101
  reqOpts,
142
- gaxOpts: query.gaxOptions,
102
+ gaxOpts: request.gaxOptions,
143
103
  headers: (0, request_id_header_1.injectRequestIDIntoHeaders)(headers, this.session),
144
104
  }, (err, partitions, resp) => {
145
105
  if (err) {
146
106
  (0, instrument_1.setSpanError)(span, err);
147
107
  }
148
108
  span.end();
149
- callback(err, partitions, resp);
109
+ cb(err, partitions, resp);
150
110
  });
151
111
  });
152
112
  }
@@ -203,36 +163,7 @@ class BatchTransaction extends transaction_1.Snapshot {
203
163
  });
204
164
  });
205
165
  }
206
- /**
207
- * @typedef {object} ReadPartition
208
- * @mixes ReadRequestOptions
209
- * @property {string} partitionToken The partition token.
210
- * @property {object} [gaxOptions] Request configuration options,
211
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
212
- * for more details.
213
- */
214
- /**
215
- * @typedef {array} CreateReadPartitionsResponse
216
- * @property {ReadPartition[]} 0 List of read partitions.
217
- * @property {object} 1 The full API response.
218
- */
219
- /**
220
- * @callback CreateReadPartitionsCallback
221
- * @param {?Error} err Request error, if any.
222
- * @param {ReadPartition[]} partitions List of read partitions.
223
- * @param {object} apiResponse The full API response.
224
- */
225
- /**
226
- * Creates a set of read partitions that can be used to execute a read
227
- * operation in parallel. Partitions become invalid when the transaction used
228
- * to create them is closed.
229
- *
230
- * @param {ReadRequestOptions} options Configuration object, describing what to
231
- * read from.
232
- * @param {CreateReadPartitionsCallback} [callback] Callback function.
233
- * @returns {Promise<CreateReadPartitionsResponse>}
234
- */
235
- createReadPartitions(options, callback) {
166
+ createReadPartitions(options, cb) {
236
167
  const traceConfig = {
237
168
  opts: this._observabilityOptions,
238
169
  dbName: this.getDBName(),
@@ -259,33 +190,17 @@ class BatchTransaction extends transaction_1.Snapshot {
259
190
  (0, instrument_1.setSpanError)(span, err);
260
191
  }
261
192
  span.end();
262
- callback(err, partitions, resp);
193
+ cb(err, partitions, resp);
263
194
  });
264
195
  });
265
196
  }
266
- /**
267
- * Executes partition.
268
- *
269
- * @see {@link Transaction#read} when using {@link ReadPartition}.
270
- * @see {@link Transaction#run} when using {@link QueryParition}.
271
- *
272
- * @param {ReadPartition|QueryParition} partition The partition object.
273
- * @param {object} [partition.gaxOptions] Request configuration options,
274
- * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
275
- * for more details.
276
- * @param {TransactionRequestReadCallback|RunCallback} [callback] Callback
277
- * function.
278
- * @returns {Promise<RunResponse>|Promise<TransactionRequestReadResponse>}
279
- *
280
- * @example <caption>include:samples/batch.js</caption>
281
- * region_tag:spanner_batch_execute_partitions
282
- */
283
- execute(partition, callback) {
284
- if (is.string(partition.table)) {
285
- this.read(partition.table, partition, callback);
197
+ execute(partition, cb) {
198
+ const isRead = typeof partition.table === 'string';
199
+ if (isRead) {
200
+ this.read(partition.table, partition, cb);
286
201
  return;
287
202
  }
288
- this.run(partition, callback);
203
+ this.run(partition, cb);
289
204
  }
290
205
  /**
291
206
  * Executes partition in streaming mode.
@@ -18,7 +18,7 @@ exports.codec = exports.Interval = exports.PGOid = exports.PGJsonb = exports.Pro
18
18
  */
19
19
  const service_1 = require("./common-grpc/service");
20
20
  const precise_date_1 = require("@google-cloud/precise-date");
21
- const arrify = require("arrify");
21
+ const helper_1 = require("./helper");
22
22
  const big_js_1 = require("big.js");
23
23
  const is = require("is");
24
24
  const protos_1 = require("../protos/protos");
@@ -85,12 +85,14 @@ exports.SpannerDate = SpannerDate;
85
85
  * @private
86
86
  */
87
87
  class WrappedNumber {
88
+ value;
88
89
  }
89
90
  /**
90
91
  * @typedef Float32
91
92
  * @see Spanner.float32
92
93
  */
93
94
  class Float32 extends WrappedNumber {
95
+ value;
94
96
  constructor(value) {
95
97
  super();
96
98
  this.value = value;
@@ -105,6 +107,7 @@ exports.Float32 = Float32;
105
107
  * @see Spanner.float
106
108
  */
107
109
  class Float extends WrappedNumber {
110
+ value;
108
111
  constructor(value) {
109
112
  super();
110
113
  this.value = value;
@@ -119,6 +122,7 @@ exports.Float = Float;
119
122
  * @see Spanner.int
120
123
  */
121
124
  class Int extends WrappedNumber {
125
+ value;
122
126
  constructor(value) {
123
127
  super();
124
128
  this.value = value.toString();
@@ -179,6 +183,7 @@ exports.Struct = Struct;
179
183
  * @see Spanner.numeric
180
184
  */
181
185
  class Numeric {
186
+ value;
182
187
  constructor(value) {
183
188
  this.value = value;
184
189
  }
@@ -195,6 +200,7 @@ exports.Numeric = Numeric;
195
200
  * @see Spanner.pgNumeric
196
201
  */
197
202
  class PGNumeric {
203
+ value;
198
204
  constructor(pgValue) {
199
205
  this.value = pgValue.toString();
200
206
  }
@@ -214,6 +220,9 @@ exports.PGNumeric = PGNumeric;
214
220
  * @see Spanner.protoMessage
215
221
  */
216
222
  class ProtoMessage {
223
+ value;
224
+ fullName;
225
+ messageFunction;
217
226
  constructor(protoMessageParams) {
218
227
  this.fullName = protoMessageParams.fullName;
219
228
  this.messageFunction = protoMessageParams.messageFunction;
@@ -243,6 +252,9 @@ exports.ProtoMessage = ProtoMessage;
243
252
  * @see Spanner.protoEnum
244
253
  */
245
254
  class ProtoEnum {
255
+ value;
256
+ fullName;
257
+ enumObject;
246
258
  constructor(protoEnumParams) {
247
259
  this.fullName = protoEnumParams.fullName;
248
260
  this.enumObject = protoEnumParams.enumObject;
@@ -277,6 +289,7 @@ exports.ProtoEnum = ProtoEnum;
277
289
  * @see Spanner.pgJsonb
278
290
  */
279
291
  class PGJsonb {
292
+ value;
280
293
  constructor(pgValue) {
281
294
  if (typeof pgValue === 'string') {
282
295
  pgValue = JSON.parse(pgValue);
@@ -293,6 +306,7 @@ exports.PGJsonb = PGJsonb;
293
306
  * @see Spanner.pgOid
294
307
  */
295
308
  class PGOid extends WrappedNumber {
309
+ value;
296
310
  constructor(value) {
297
311
  super();
298
312
  this.value = value.toString();
@@ -311,6 +325,32 @@ exports.PGOid = PGOid;
311
325
  * @see Spanner.interval
312
326
  */
313
327
  class Interval {
328
+ months;
329
+ days;
330
+ nanoseconds;
331
+ // Regex to parse ISO8601 duration format: P[n]Y[n]M[n]DT[n]H[n]M[n][.fffffffff]S
332
+ // Only seconds can be fractional, and can have at most 9 digits after decimal point.
333
+ // Both '.' and ',' are considered valid decimal point.
334
+ static ISO8601_PATTERN = /^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(T(?=-?[.,]?\d)(-?\d+H)?(-?\d+M)?(-?(((\d+)([.,]\d{1,9})?)|([.,]\d{1,9}))S)?)?$/;
335
+ static MONTHS_PER_YEAR = 12;
336
+ static DAYS_PER_MONTH = 30;
337
+ static HOURS_PER_DAY = 24;
338
+ static MINUTES_PER_HOUR = 60;
339
+ static SECONDS_PER_MINUTE = 60;
340
+ static SECONDS_PER_HOUR = Interval.MINUTES_PER_HOUR * Interval.SECONDS_PER_MINUTE;
341
+ static MILLISECONDS_PER_SECOND = 1000;
342
+ static MICROSECONDS_PER_MILLISECOND = 1000;
343
+ static NANOSECONDS_PER_MICROSECOND = 1000;
344
+ static NANOSECONDS_PER_MILLISECOND = Interval.MICROSECONDS_PER_MILLISECOND *
345
+ Interval.NANOSECONDS_PER_MICROSECOND;
346
+ static NANOSECONDS_PER_SECOND = Interval.MILLISECONDS_PER_SECOND *
347
+ Interval.MICROSECONDS_PER_MILLISECOND *
348
+ Interval.NANOSECONDS_PER_MICROSECOND;
349
+ static NANOSECONDS_PER_DAY = BigInt(Interval.HOURS_PER_DAY) *
350
+ BigInt(Interval.SECONDS_PER_HOUR) *
351
+ BigInt(Interval.NANOSECONDS_PER_SECOND);
352
+ static NANOSECONDS_PER_MONTH = BigInt(Interval.DAYS_PER_MONTH) * Interval.NANOSECONDS_PER_DAY;
353
+ static ZERO = new Interval(0, 0, BigInt(0));
314
354
  /**
315
355
  * @param months months part of the `Interval`
316
356
  * @param days days part of the `Interval`
@@ -513,29 +553,6 @@ class Interval {
513
553
  }
514
554
  }
515
555
  exports.Interval = Interval;
516
- // Regex to parse ISO8601 duration format: P[n]Y[n]M[n]DT[n]H[n]M[n][.fffffffff]S
517
- // Only seconds can be fractional, and can have at most 9 digits after decimal point.
518
- // Both '.' and ',' are considered valid decimal point.
519
- Interval.ISO8601_PATTERN = /^P(?!$)(-?\d+Y)?(-?\d+M)?(-?\d+D)?(T(?=-?[.,]?\d)(-?\d+H)?(-?\d+M)?(-?(((\d+)([.,]\d{1,9})?)|([.,]\d{1,9}))S)?)?$/;
520
- Interval.MONTHS_PER_YEAR = 12;
521
- Interval.DAYS_PER_MONTH = 30;
522
- Interval.HOURS_PER_DAY = 24;
523
- Interval.MINUTES_PER_HOUR = 60;
524
- Interval.SECONDS_PER_MINUTE = 60;
525
- Interval.SECONDS_PER_HOUR = Interval.MINUTES_PER_HOUR * Interval.SECONDS_PER_MINUTE;
526
- Interval.MILLISECONDS_PER_SECOND = 1000;
527
- Interval.MICROSECONDS_PER_MILLISECOND = 1000;
528
- Interval.NANOSECONDS_PER_MICROSECOND = 1000;
529
- Interval.NANOSECONDS_PER_MILLISECOND = Interval.MICROSECONDS_PER_MILLISECOND *
530
- Interval.NANOSECONDS_PER_MICROSECOND;
531
- Interval.NANOSECONDS_PER_SECOND = Interval.MILLISECONDS_PER_SECOND *
532
- Interval.MICROSECONDS_PER_MILLISECOND *
533
- Interval.NANOSECONDS_PER_MICROSECOND;
534
- Interval.NANOSECONDS_PER_DAY = BigInt(Interval.HOURS_PER_DAY) *
535
- BigInt(Interval.SECONDS_PER_HOUR) *
536
- BigInt(Interval.NANOSECONDS_PER_SECOND);
537
- Interval.NANOSECONDS_PER_MONTH = BigInt(Interval.DAYS_PER_MONTH) * Interval.NANOSECONDS_PER_DAY;
538
- Interval.ZERO = new Interval(0, 0, BigInt(0));
539
556
  /**
540
557
  * @typedef JSONOptions
541
558
  * @property {boolean} [wrapNumbers=false] Indicates if the numbers should be
@@ -934,7 +951,7 @@ function getType(value) {
934
951
  * @returns {object}
935
952
  */
936
953
  function convertToListValue(value) {
937
- const values = arrify(value).map(exports.codec.encode);
954
+ const values = (0, helper_1.toArray)(value).map(exports.codec.encode);
938
955
  return { values };
939
956
  }
940
957
  /**
@@ -992,7 +1009,7 @@ function createTypeObject(friendlyType) {
992
1009
  }
993
1010
  if (code === 'STRUCT') {
994
1011
  type.structType = {
995
- fields: arrify(config.fields).map(field => {
1012
+ fields: (0, helper_1.toArray)(config.fields).map(field => {
996
1013
  return { name: field.name, type: exports.codec.createTypeObject(field) };
997
1014
  }),
998
1015
  };
@@ -36,6 +36,7 @@ class GrpcServiceObject extends common_1.ServiceObject {
36
36
  */
37
37
  constructor(config) {
38
38
  super(config);
39
+ this.parent = config.parent;
39
40
  }
40
41
  delete(callback) {
41
42
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -125,6 +125,9 @@ const GRPC_SERVICE_OPTIONS = {
125
125
  'grpc.initial_reconnect_backoff_ms': 5000,
126
126
  };
127
127
  class ObjectToStructConverter {
128
+ seenObjects;
129
+ removeCircular;
130
+ stringify;
128
131
  /**
129
132
  * A class that can be used to convert an object to a struct. Optionally this
130
133
  * class can be used to erase/throw on circular references during conversion.
@@ -259,6 +262,19 @@ class ObjectToStructConverter {
259
262
  }
260
263
  exports.ObjectToStructConverter = ObjectToStructConverter;
261
264
  class GrpcService extends common_1.Service {
265
+ grpc;
266
+ grpcVersion;
267
+ grpcCredentials;
268
+ grpcMetadata;
269
+ maxRetries;
270
+ userAgent;
271
+ activeServiceMap_ = new Map();
272
+ protos = {};
273
+ /** A cache for proto objects. */
274
+ static protoObjectCache = {};
275
+ static GRPC_SERVICE_OPTIONS = GRPC_SERVICE_OPTIONS;
276
+ static GRPC_ERROR_CODE_TO_HTTP = GRPC_ERROR_CODE_TO_HTTP;
277
+ static ObjectToStructConverter = ObjectToStructConverter;
262
278
  /**
263
279
  * Service is a base class, meant to be inherited from by a "service," like
264
280
  * BigQuery or Storage.
@@ -274,8 +290,6 @@ class GrpcService extends common_1.Service {
274
290
  */
275
291
  constructor(config, options) {
276
292
  super(config, options);
277
- this.activeServiceMap_ = new Map();
278
- this.protos = {};
279
293
  if (global['GCLOUD_SANDBOX_ENV']) {
280
294
  // gRPC has a tendency to cause our doc unit tests to fail, so we prevent
281
295
  // any calls to that library from going through.
@@ -764,7 +778,15 @@ class GrpcService extends common_1.Service {
764
778
  */
765
779
  getGrpcCredentials_(callback) {
766
780
  this.authClient.getClient().then(client => {
767
- const credentials = this.grpc.credentials.combineChannelCredentials(this.grpc.credentials.createSsl(), this.grpc.credentials.createFromGoogleCredential(client));
781
+ const credentials = this.grpc.credentials.combineChannelCredentials(this.grpc.credentials.createSsl(), google_gax_1.grpc.credentials.createFromGoogleCredential({
782
+ // the `grpc` package does not support the `Headers` object yet
783
+ getRequestHeaders: async (url) => {
784
+ const headers = await client.getRequestHeaders(url);
785
+ const genericHeadersObject = {};
786
+ headers.forEach((value, key) => (genericHeadersObject[key] = value));
787
+ return genericHeadersObject;
788
+ },
789
+ }));
768
790
  if (!this.projectId || this.projectId === '{{projectId}}') {
769
791
  this.projectId = client.projectId;
770
792
  }
@@ -818,9 +840,4 @@ class GrpcService extends common_1.Service {
818
840
  }
819
841
  }
820
842
  exports.GrpcService = GrpcService;
821
- /** A cache for proto objects. */
822
- GrpcService.protoObjectCache = {};
823
- GrpcService.GRPC_SERVICE_OPTIONS = GRPC_SERVICE_OPTIONS;
824
- GrpcService.GRPC_ERROR_CODE_TO_HTTP = GRPC_ERROR_CODE_TO_HTTP;
825
- GrpcService.ObjectToStructConverter = ObjectToStructConverter;
826
843
  //# sourceMappingURL=service.js.map