@google-cloud/spanner 7.7.0 → 7.9.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 (43) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +5 -0
  3. package/build/protos/google/spanner/admin/database/v1/backup.proto +190 -109
  4. package/build/protos/google/spanner/admin/database/v1/common.proto +30 -10
  5. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +166 -100
  6. package/build/protos/google/spanner/admin/instance/v1/common.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 +1 -1
  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 +30 -0
  17. package/build/protos/protos.js +204 -0
  18. package/build/protos/protos.json +43 -0
  19. package/build/src/codec.d.ts +55 -1
  20. package/build/src/codec.js +109 -4
  21. package/build/src/common-grpc/service.d.ts +0 -1
  22. package/build/src/common.js +2 -2
  23. package/build/src/database.d.ts +94 -7
  24. package/build/src/database.js +131 -0
  25. package/build/src/index.d.ts +59 -3
  26. package/build/src/index.js +55 -1
  27. package/build/src/instance.d.ts +0 -2
  28. package/build/src/partial-result-stream.d.ts +41 -1
  29. package/build/src/partial-result-stream.js +8 -3
  30. package/build/src/session-pool.d.ts +0 -2
  31. package/build/src/session-pool.js +7 -7
  32. package/build/src/table.d.ts +1 -0
  33. package/build/src/table.js +36 -2
  34. package/build/src/transaction-runner.d.ts +1 -0
  35. package/build/src/transaction-runner.js +5 -2
  36. package/build/src/transaction.d.ts +100 -2
  37. package/build/src/transaction.js +135 -30
  38. package/build/src/v1/database_admin_client.d.ts +175 -127
  39. package/build/src/v1/database_admin_client.js +85 -57
  40. package/build/src/v1/instance_admin_client.d.ts +0 -1
  41. package/build/src/v1/spanner_client.d.ts +0 -1
  42. package/build/src/v1/spanner_client_config.json +15 -14
  43. package/package.json +6 -6
@@ -1690,6 +1690,14 @@
1690
1690
  "(google.api.field_behavior)": "OUTPUT_ONLY"
1691
1691
  }
1692
1692
  },
1693
+ "encryptionInformation": {
1694
+ "rule": "repeated",
1695
+ "type": "EncryptionInfo",
1696
+ "id": 13,
1697
+ "options": {
1698
+ "(google.api.field_behavior)": "OUTPUT_ONLY"
1699
+ }
1700
+ },
1693
1701
  "databaseDialect": {
1694
1702
  "type": "DatabaseDialect",
1695
1703
  "id": 10,
@@ -2008,6 +2016,15 @@
2008
2016
  "(google.api.field_behavior)": "OPTIONAL",
2009
2017
  "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2010
2018
  }
2019
+ },
2020
+ "kmsKeyNames": {
2021
+ "rule": "repeated",
2022
+ "type": "string",
2023
+ "id": 3,
2024
+ "options": {
2025
+ "(google.api.field_behavior)": "OPTIONAL",
2026
+ "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2027
+ }
2011
2028
  }
2012
2029
  },
2013
2030
  "nested": {
@@ -2037,6 +2054,15 @@
2037
2054
  "(google.api.field_behavior)": "OPTIONAL",
2038
2055
  "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2039
2056
  }
2057
+ },
2058
+ "kmsKeyNames": {
2059
+ "rule": "repeated",
2060
+ "type": "string",
2061
+ "id": 3,
2062
+ "options": {
2063
+ "(google.api.field_behavior)": "OPTIONAL",
2064
+ "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2065
+ }
2040
2066
  }
2041
2067
  },
2042
2068
  "nested": {
@@ -2074,6 +2100,14 @@
2074
2100
  "options": {
2075
2101
  "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2076
2102
  }
2103
+ },
2104
+ "kmsKeyNames": {
2105
+ "rule": "repeated",
2106
+ "type": "string",
2107
+ "id": 3,
2108
+ "options": {
2109
+ "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
2110
+ }
2077
2111
  }
2078
2112
  }
2079
2113
  },
@@ -3052,6 +3086,15 @@
3052
3086
  "(google.api.field_behavior)": "OPTIONAL",
3053
3087
  "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
3054
3088
  }
3089
+ },
3090
+ "kmsKeyNames": {
3091
+ "rule": "repeated",
3092
+ "type": "string",
3093
+ "id": 3,
3094
+ "options": {
3095
+ "(google.api.field_behavior)": "OPTIONAL",
3096
+ "(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
3097
+ }
3055
3098
  }
3056
3099
  },
3057
3100
  "nested": {
@@ -6,6 +6,32 @@ export interface Field {
6
6
  name: string;
7
7
  value: Value;
8
8
  }
9
+ export interface IProtoMessageParams {
10
+ value: object;
11
+ fullName: string;
12
+ /**
13
+ * Provide a First Class function that includes nested functions named
14
+ * "encode" for serialization and "decode" for deserialization of the proto
15
+ * message. The function should be sourced from the JS file generated by
16
+ * protobufjs-cli for the proto message.
17
+ */
18
+ messageFunction?: Function;
19
+ }
20
+ export interface IProtoEnumParams {
21
+ value: string | number;
22
+ fullName: string;
23
+ /**
24
+ * An object containing enum string to id mapping.
25
+ * @example: { POP: 0, JAZZ: 1, FOLK: 2, ROCK: 3 }
26
+ *
27
+ * The object should be sourced from the JS file generated by
28
+ * protobufjs-cli for the proto message. Additionally, please review the
29
+ * sample at {@link www.samples.com} for guidance.
30
+ *
31
+ * ToDo: Update the link
32
+ */
33
+ enumObject?: object;
34
+ }
9
35
  export interface Json {
10
36
  [field: string]: Value;
11
37
  }
@@ -139,6 +165,28 @@ export declare class PGNumeric {
139
165
  valueOf(): Big;
140
166
  toJSON(): string;
141
167
  }
168
+ /**
169
+ * @typedef ProtoMessage
170
+ * @see Spanner.protoMessage
171
+ */
172
+ export declare class ProtoMessage {
173
+ value: Buffer;
174
+ fullName: string;
175
+ messageFunction?: Function;
176
+ constructor(protoMessageParams: IProtoMessageParams);
177
+ toJSON(): string;
178
+ }
179
+ /**
180
+ * @typedef ProtoEnum
181
+ * @see Spanner.protoEnum
182
+ */
183
+ export declare class ProtoEnum {
184
+ value: string;
185
+ fullName: string;
186
+ enumObject?: object;
187
+ constructor(protoEnumParams: IProtoEnumParams);
188
+ toJSON(): string;
189
+ }
142
190
  /**
143
191
  * @typedef PGJsonb
144
192
  * @see Spanner.pgJsonb
@@ -185,9 +233,10 @@ declare function convertFieldsToJson(fields: Field[], options?: JSONOptions): Js
185
233
  *
186
234
  * @param {*} value Value to decode
187
235
  * @param {object[]} type Value type object.
236
+ * @param columnMetadata Optional parameter to deserialize data
188
237
  * @returns {*}
189
238
  */
190
- declare function decode(value: Value, type: spannerClient.spanner.v1.Type): Value;
239
+ declare function decode(value: Value, type: spannerClient.spanner.v1.Type, columnMetadata?: object): Value;
191
240
  /**
192
241
  * Encode a value in the format the API expects.
193
242
  *
@@ -207,6 +256,7 @@ export interface Type {
207
256
  type: string;
208
257
  fields?: FieldType[];
209
258
  child?: Type;
259
+ fullName?: string;
210
260
  }
211
261
  interface FieldType extends Type {
212
262
  name: string;
@@ -226,6 +276,8 @@ interface FieldType extends Type {
226
276
  * - string
227
277
  * - bytes
228
278
  * - json
279
+ * - proto
280
+ * - enum
229
281
  * - timestamp
230
282
  * - date
231
283
  * - struct
@@ -298,6 +350,8 @@ export declare const codec: {
298
350
  Numeric: typeof Numeric;
299
351
  PGNumeric: typeof PGNumeric;
300
352
  PGJsonb: typeof PGJsonb;
353
+ ProtoMessage: typeof ProtoMessage;
354
+ ProtoEnum: typeof ProtoEnum;
301
355
  PGOid: typeof PGOid;
302
356
  convertFieldsToJson: typeof convertFieldsToJson;
303
357
  decode: typeof decode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.codec = exports.PGOid = exports.PGJsonb = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.Float32 = exports.SpannerDate = void 0;
3
+ exports.codec = exports.PGOid = exports.PGJsonb = exports.ProtoEnum = exports.ProtoMessage = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.Float32 = exports.SpannerDate = void 0;
4
4
  /*!
5
5
  * Copyright 2017 Google Inc. All Rights Reserved.
6
6
  *
@@ -209,6 +209,69 @@ class PGNumeric {
209
209
  }
210
210
  }
211
211
  exports.PGNumeric = PGNumeric;
212
+ /**
213
+ * @typedef ProtoMessage
214
+ * @see Spanner.protoMessage
215
+ */
216
+ class ProtoMessage {
217
+ constructor(protoMessageParams) {
218
+ this.fullName = protoMessageParams.fullName;
219
+ this.messageFunction = protoMessageParams.messageFunction;
220
+ if (protoMessageParams.value instanceof Buffer) {
221
+ this.value = protoMessageParams.value;
222
+ }
223
+ else if (protoMessageParams.messageFunction) {
224
+ this.value = protoMessageParams.messageFunction['encode'](protoMessageParams.value).finish();
225
+ }
226
+ else {
227
+ throw new google_gax_1.GoogleError(`protoMessageParams cannot be used to construct
228
+ the ProtoMessage. Pass the serialized buffer of the
229
+ proto message as the value or provide the message object along with the
230
+ corresponding messageFunction generated by protobufjs-cli.`);
231
+ }
232
+ }
233
+ toJSON() {
234
+ if (this.messageFunction) {
235
+ return this.messageFunction['toObject'](this.messageFunction['decode'](this.value));
236
+ }
237
+ return this.value.toString();
238
+ }
239
+ }
240
+ exports.ProtoMessage = ProtoMessage;
241
+ /**
242
+ * @typedef ProtoEnum
243
+ * @see Spanner.protoEnum
244
+ */
245
+ class ProtoEnum {
246
+ constructor(protoEnumParams) {
247
+ this.fullName = protoEnumParams.fullName;
248
+ this.enumObject = protoEnumParams.enumObject;
249
+ /**
250
+ * @code{IProtoEnumParams} can accept either a number or a string as a value so
251
+ * converting to string and checking whether it's numeric using regex.
252
+ */
253
+ if (/^\d+$/.test(protoEnumParams.value.toString())) {
254
+ this.value = protoEnumParams.value.toString();
255
+ }
256
+ else if (protoEnumParams.enumObject &&
257
+ protoEnumParams.enumObject[protoEnumParams.value]) {
258
+ this.value = protoEnumParams.enumObject[protoEnumParams.value];
259
+ }
260
+ else {
261
+ throw new google_gax_1.GoogleError(`protoEnumParams cannot be used for constructing the
262
+ ProtoEnum. Pass the number as the value or provide the enum string
263
+ constant as the value along with the corresponding enumObject generated
264
+ by protobufjs-cli.`);
265
+ }
266
+ }
267
+ toJSON() {
268
+ if (this.enumObject) {
269
+ return Object.getPrototypeOf(this.enumObject)[this.value];
270
+ }
271
+ return this.value.toString();
272
+ }
273
+ }
274
+ exports.ProtoEnum = ProtoEnum;
212
275
  /**
213
276
  * @typedef PGJsonb
214
277
  * @see Spanner.pgJsonb
@@ -316,6 +379,9 @@ function convertValueToJson(value, options) {
316
379
  if (Array.isArray(value)) {
317
380
  return value.map(child => convertValueToJson(child, options));
318
381
  }
382
+ if (value instanceof ProtoMessage || value instanceof ProtoEnum) {
383
+ return value.toJSON();
384
+ }
319
385
  return value;
320
386
  }
321
387
  /**
@@ -325,9 +391,10 @@ function convertValueToJson(value, options) {
325
391
  *
326
392
  * @param {*} value Value to decode
327
393
  * @param {object[]} type Value type object.
394
+ * @param columnMetadata Optional parameter to deserialize data
328
395
  * @returns {*}
329
396
  */
330
- function decode(value, type) {
397
+ function decode(value, type, columnMetadata) {
331
398
  if (is.null(value)) {
332
399
  return null;
333
400
  }
@@ -338,6 +405,23 @@ function decode(value, type) {
338
405
  case 'BYTES':
339
406
  decoded = Buffer.from(decoded, 'base64');
340
407
  break;
408
+ case protos_1.google.spanner.v1.TypeCode.PROTO:
409
+ case 'PROTO':
410
+ decoded = Buffer.from(decoded, 'base64');
411
+ decoded = new ProtoMessage({
412
+ value: decoded,
413
+ fullName: type.protoTypeFqn,
414
+ messageFunction: columnMetadata,
415
+ });
416
+ break;
417
+ case protos_1.google.spanner.v1.TypeCode.ENUM:
418
+ case 'ENUM':
419
+ decoded = new ProtoEnum({
420
+ value: decoded,
421
+ fullName: type.protoTypeFqn,
422
+ enumObject: columnMetadata,
423
+ });
424
+ break;
341
425
  case protos_1.google.spanner.v1.TypeCode.FLOAT32:
342
426
  case 'FLOAT32':
343
427
  decoded = new Float32(decoded);
@@ -387,13 +471,13 @@ function decode(value, type) {
387
471
  case protos_1.google.spanner.v1.TypeCode.ARRAY:
388
472
  case 'ARRAY':
389
473
  decoded = decoded.map(value => {
390
- return decode(value, type.arrayElementType);
474
+ return decode(value, type.arrayElementType, columnMetadata);
391
475
  });
392
476
  break;
393
477
  case protos_1.google.spanner.v1.TypeCode.STRUCT:
394
478
  case 'STRUCT':
395
479
  fields = type.structType.fields.map(({ name, type }, index) => {
396
- const value = decode((!Array.isArray(decoded) && decoded[name]) || decoded[index], type);
480
+ const value = decode((!Array.isArray(decoded) && decoded[name]) || decoded[index], type, columnMetadata);
397
481
  return { name, value };
398
482
  });
399
483
  decoded = Struct.fromArray(fields);
@@ -443,6 +527,12 @@ function encodeValue(value) {
443
527
  if (Buffer.isBuffer(value)) {
444
528
  return value.toString('base64');
445
529
  }
530
+ if (value instanceof ProtoMessage) {
531
+ return value.value.toString('base64');
532
+ }
533
+ if (value instanceof ProtoEnum) {
534
+ return value.value;
535
+ }
446
536
  if (value instanceof Struct) {
447
537
  return Array.from(value).map(field => encodeValue(field.value));
448
538
  }
@@ -478,6 +568,8 @@ const TypeCode = {
478
568
  bytes: 'BYTES',
479
569
  json: 'JSON',
480
570
  jsonb: 'JSON',
571
+ proto: 'PROTO',
572
+ enum: 'ENUM',
481
573
  array: 'ARRAY',
482
574
  struct: 'STRUCT',
483
575
  };
@@ -496,6 +588,8 @@ const TypeCode = {
496
588
  * - string
497
589
  * - bytes
498
590
  * - json
591
+ * - proto
592
+ * - enum
499
593
  * - timestamp
500
594
  * - date
501
595
  * - struct
@@ -542,6 +636,12 @@ function getType(value) {
542
636
  if (value instanceof PGOid) {
543
637
  return { type: 'pgOid' };
544
638
  }
639
+ if (value instanceof ProtoMessage) {
640
+ return { type: 'proto', fullName: value.fullName };
641
+ }
642
+ if (value instanceof ProtoEnum) {
643
+ return { type: 'enum', fullName: value.fullName };
644
+ }
545
645
  if (is.boolean(value)) {
546
646
  return { type: 'bool' };
547
647
  }
@@ -642,6 +742,9 @@ function createTypeObject(friendlyType) {
642
742
  const type = {
643
743
  code,
644
744
  };
745
+ if (code === 'PROTO' || code === 'ENUM') {
746
+ type.protoTypeFqn = config.fullName || '';
747
+ }
645
748
  if (code === 'ARRAY') {
646
749
  type.arrayElementType = exports.codec.createTypeObject(config.child);
647
750
  }
@@ -676,6 +779,8 @@ exports.codec = {
676
779
  Numeric,
677
780
  PGNumeric,
678
781
  PGJsonb,
782
+ ProtoMessage,
783
+ ProtoEnum,
679
784
  PGOid,
680
785
  convertFieldsToJson,
681
786
  decode,
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- /// <reference types="node" />
17
16
  import { Abortable, BodyResponseCallback, DecorateRequestOptions, Service, ServiceConfig } from '@google-cloud/common';
18
17
  import { grpc } from 'google-gax';
19
18
  import { Request, Response } from 'teeny-request';
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.addLeaderAwareRoutingHeader = exports.LEADER_AWARE_ROUTING_HEADER = exports.CLOUD_RESOURCE_HEADER = void 0;
18
+ exports.LEADER_AWARE_ROUTING_HEADER = exports.CLOUD_RESOURCE_HEADER = void 0;
19
+ exports.addLeaderAwareRoutingHeader = addLeaderAwareRoutingHeader;
19
20
  /*!
20
21
  * HTTP header for the resource prefix to improve routing
21
22
  * by the backend.
@@ -32,5 +33,4 @@ exports.LEADER_AWARE_ROUTING_HEADER = 'x-goog-spanner-route-to-leader';
32
33
  function addLeaderAwareRoutingHeader(headers) {
33
34
  headers[exports.LEADER_AWARE_ROUTING_HEADER] = 'true';
34
35
  }
35
- exports.addLeaderAwareRoutingHeader = addLeaderAwareRoutingHeader;
36
36
  //# sourceMappingURL=common.js.map
@@ -13,8 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- /// <reference types="node" />
17
- /// <reference types="node" />
18
16
  import { ExistsCallback, GetConfig } from '@google-cloud/common';
19
17
  declare const common: any;
20
18
  import * as r from 'teeny-request';
@@ -26,7 +24,7 @@ import { PartialResultStream } from './partial-result-stream';
26
24
  import { Session } from './session';
27
25
  import { SessionPoolCloseCallback, SessionPoolInterface, SessionPoolOptions } from './session-pool';
28
26
  import { CreateTableCallback, CreateTableResponse, Table } from './table';
29
- import { ExecuteSqlRequest, RunCallback, RunResponse, RunUpdateCallback, Snapshot, TimestampBounds, Transaction } from './transaction';
27
+ import { BatchWriteOptions, ExecuteSqlRequest, MutationGroup, RunCallback, RunResponse, RunUpdateCallback, Snapshot, TimestampBounds, Transaction } from './transaction';
30
28
  import { AsyncRunTransactionCallback, RunTransactionCallback, RunTransactionOptions } from './transaction-runner';
31
29
  import { IOperation, LongRunningCallback, NormalCallback, PagedOptionsWithFilter, PagedResponse, RequestCallback, ResourceCallback, Schema } from './common';
32
30
  import { Duplex, Readable } from 'stream';
@@ -52,10 +50,14 @@ type GetTransactionCallback = NormalCallback<Transaction>;
52
50
  export interface SessionPoolConstructor {
53
51
  new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
54
52
  }
53
+ export type GetDatabaseDialectCallback = NormalCallback<EnumKey<typeof google.spanner.admin.database.v1.DatabaseDialect>>;
55
54
  export interface SetIamPolicyRequest {
56
55
  policy: Policy | null;
57
56
  updateMask?: FieldMask | null;
58
57
  }
58
+ export interface RunPartitionedUpdateOptions extends ExecuteSqlRequest {
59
+ excludeTxnFromChangeStreams?: boolean;
60
+ }
59
61
  export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
60
62
  export type UpdateSchemaResponse = [
61
63
  GaxOperation,
@@ -67,7 +69,7 @@ export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
67
69
  /**
68
70
  * IDatabase structure with database state enum translated to string form.
69
71
  */
70
- type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
72
+ type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'databaseDialect', typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect>, 'restoreInfo'> & {
71
73
  restoreInfo?: IRestoreInfoTranslatedEnum | null;
72
74
  };
73
75
  /**
@@ -172,6 +174,7 @@ declare class Database extends common.GrpcServiceObject {
172
174
  };
173
175
  request: DatabaseRequest;
174
176
  databaseRole?: string | null;
177
+ databaseDialect?: EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | null;
175
178
  constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
176
179
  /**
177
180
  * @typedef {array} SetDatabaseMetadataResponse
@@ -817,6 +820,31 @@ declare class Database extends common.GrpcServiceObject {
817
820
  getState(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State> | undefined>;
818
821
  getState(callback: GetStateCallback): void;
819
822
  getState(options: CallOptions, callback: GetStateCallback): void;
823
+ /**
824
+ * Retrieves the dialect of the database
825
+ *
826
+ * @see {@link #getMetadata}
827
+ *
828
+ * @method Database#getDatabaseDialect
829
+ *
830
+ * @param {object} [gaxOptions] Request configuration options,
831
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
832
+ * for more details.
833
+ * @param {GetDatabaseDialectCallback} [callback] Callback function.
834
+ * @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>}
835
+ * When resolved, contains the database dialect of the database if the dialect is defined.
836
+ * @example
837
+ * const {Spanner} = require('@google-cloud/spanner');
838
+ * const spanner = new Spanner();
839
+ * const instance = spanner.instance('my-instance');
840
+ * const database = instance.database('my-database');
841
+ * const dialect = await database.getDatabaseDialect();
842
+ * const isGoogleSQL = (dialect === 'GOOGLE_STANDARD_SQL');
843
+ * const isPostgreSQL = (dialect === 'POSTGRESQL');
844
+ */
845
+ getDatabaseDialect(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>;
846
+ getDatabaseDialect(callback: GetDatabaseDialectCallback): void;
847
+ getDatabaseDialect(options: CallOptions, callback: GetDatabaseDialectCallback): void;
820
848
  /**
821
849
  * @typedef {array} GetSchemaResponse
822
850
  * @property {string[]} 0 An array of database DDL statements.
@@ -1527,9 +1555,9 @@ declare class Database extends common.GrpcServiceObject {
1527
1555
  * @param {RunUpdateCallback} [callback] Callback function.
1528
1556
  * @returns {Promise<RunUpdateResponse>}
1529
1557
  */
1530
- runPartitionedUpdate(query: string | ExecuteSqlRequest): Promise<[number]>;
1531
- runPartitionedUpdate(query: string | ExecuteSqlRequest, callback?: RunUpdateCallback): void;
1532
- _runPartitionedUpdate(session: Session, query: string | ExecuteSqlRequest, callback?: RunUpdateCallback): void | Promise<number>;
1558
+ runPartitionedUpdate(query: string | RunPartitionedUpdateOptions): Promise<[number]>;
1559
+ runPartitionedUpdate(query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void;
1560
+ _runPartitionedUpdate(session: Session, query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void | Promise<number>;
1533
1561
  /**
1534
1562
  * Create a readable object stream to receive resulting rows from a SQL
1535
1563
  * statement.
@@ -1749,6 +1777,65 @@ declare class Database extends common.GrpcServiceObject {
1749
1777
  runTransaction(options: RunTransactionOptions, runFn: RunTransactionCallback): void;
1750
1778
  runTransactionAsync<T = {}>(runFn: AsyncRunTransactionCallback<T>): Promise<T>;
1751
1779
  runTransactionAsync<T = {}>(options: RunTransactionOptions, runFn: AsyncRunTransactionCallback<T>): Promise<T>;
1780
+ /**
1781
+ * Write a batch of mutations to Spanner.
1782
+ *
1783
+ * All mutations in a group are committed atomically. However, mutations across
1784
+ * groups can be committed non-atomically in an unspecified order and thus, they
1785
+ * must be independent of each other. Partial failure is possible, i.e., some groups
1786
+ * may have been committed successfully, while some may have failed. The results of
1787
+ * individual batches are streamed into the response as the batches are applied.
1788
+ *
1789
+ * batchWriteAtLeastOnce requests are not replay protected, meaning that each mutation group may
1790
+ * be applied more than once. Replays of non-idempotent mutations may have undesirable
1791
+ * effects. For example, replays of an insert mutation may produce an already exists
1792
+ * error or if you use generated or commit timestamp-based keys, it may result in additional
1793
+ * rows being added to the mutation's table. We recommend structuring your mutation groups to
1794
+ * be idempotent to avoid this issue.
1795
+ *
1796
+ * @method Spanner#batchWriteAtLeastOnce
1797
+ *
1798
+ * @param {MutationGroup[]} [mutationGroups] The group of mutations to be applied.
1799
+ * @param {BatchWriteOptions} [options] Options object for batch write request.
1800
+ *
1801
+ * @returns {ReadableStream} An object stream which emits
1802
+ * {@link protos.google.spanner.v1.BatchWriteResponse|BatchWriteResponse}
1803
+ * on 'data' event.
1804
+ *
1805
+ * @example
1806
+ * ```
1807
+ * const {Spanner} = require('@google-cloud/spanner');
1808
+ * const spanner = new Spanner();
1809
+ *
1810
+ * const instance = spanner.instance('my-instance');
1811
+ * const database = instance.database('my-database');
1812
+ * const mutationGroup = new MutationGroup();
1813
+ * mutationGroup.insert('Singers', {
1814
+ * SingerId: '1',
1815
+ * FirstName: 'Marc',
1816
+ * LastName: 'Richards',
1817
+ * });
1818
+ *
1819
+ * database.batchWriteAtLeastOnce([mutationGroup])
1820
+ * .on('error', console.error)
1821
+ * .on('data', response => {
1822
+ * console.log('response: ', response);
1823
+ * })
1824
+ * .on('end', () => {
1825
+ * console.log('Request completed successfully');
1826
+ * });
1827
+ *
1828
+ * //-
1829
+ * // If you anticipate many results, you can end a stream early to prevent
1830
+ * // unnecessary processing and API requests.
1831
+ * //-
1832
+ * database.batchWriteAtLeastOnce()
1833
+ * .on('data', response => {
1834
+ * this.end();
1835
+ * });
1836
+ * ```
1837
+ */
1838
+ batchWriteAtLeastOnce(mutationGroups: MutationGroup[], options?: BatchWriteOptions): NodeJS.ReadableStream;
1752
1839
  /**
1753
1840
  * Create a Session object.
1754
1841
  *