@google-cloud/spanner 7.7.0 → 7.8.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 (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +4 -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 +56 -1
  20. package/build/src/codec.js +109 -4
  21. package/build/src/database.d.ts +34 -4
  22. package/build/src/database.js +23 -0
  23. package/build/src/index.d.ts +50 -1
  24. package/build/src/index.js +53 -0
  25. package/build/src/partial-result-stream.d.ts +41 -0
  26. package/build/src/partial-result-stream.js +6 -1
  27. package/build/src/table.d.ts +1 -0
  28. package/build/src/table.js +36 -2
  29. package/build/src/transaction-runner.d.ts +1 -0
  30. package/build/src/transaction-runner.js +3 -0
  31. package/build/src/transaction.d.ts +55 -0
  32. package/build/src/transaction.js +28 -2
  33. package/build/src/v1/database_admin_client.d.ts +175 -126
  34. package/build/src/v1/database_admin_client.js +85 -57
  35. package/build/src/v1/spanner_client_config.json +15 -14
  36. package/package.json +3 -3
@@ -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": {
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { Big } from 'big.js';
2
3
  import { common as p } from 'protobufjs';
3
4
  import { google as spannerClient } from '../protos/protos';
@@ -6,6 +7,32 @@ export interface Field {
6
7
  name: string;
7
8
  value: Value;
8
9
  }
10
+ export interface IProtoMessageParams {
11
+ value: object;
12
+ fullName: string;
13
+ /**
14
+ * Provide a First Class function that includes nested functions named
15
+ * "encode" for serialization and "decode" for deserialization of the proto
16
+ * message. The function should be sourced from the JS file generated by
17
+ * protobufjs-cli for the proto message.
18
+ */
19
+ messageFunction?: Function;
20
+ }
21
+ export interface IProtoEnumParams {
22
+ value: string | number;
23
+ fullName: string;
24
+ /**
25
+ * An object containing enum string to id mapping.
26
+ * @example: { POP: 0, JAZZ: 1, FOLK: 2, ROCK: 3 }
27
+ *
28
+ * The object should be sourced from the JS file generated by
29
+ * protobufjs-cli for the proto message. Additionally, please review the
30
+ * sample at {@link www.samples.com} for guidance.
31
+ *
32
+ * ToDo: Update the link
33
+ */
34
+ enumObject?: object;
35
+ }
9
36
  export interface Json {
10
37
  [field: string]: Value;
11
38
  }
@@ -139,6 +166,28 @@ export declare class PGNumeric {
139
166
  valueOf(): Big;
140
167
  toJSON(): string;
141
168
  }
169
+ /**
170
+ * @typedef ProtoMessage
171
+ * @see Spanner.protoMessage
172
+ */
173
+ export declare class ProtoMessage {
174
+ value: Buffer;
175
+ fullName: string;
176
+ messageFunction?: Function;
177
+ constructor(protoMessageParams: IProtoMessageParams);
178
+ toJSON(): string;
179
+ }
180
+ /**
181
+ * @typedef ProtoEnum
182
+ * @see Spanner.protoEnum
183
+ */
184
+ export declare class ProtoEnum {
185
+ value: string;
186
+ fullName: string;
187
+ enumObject?: object;
188
+ constructor(protoEnumParams: IProtoEnumParams);
189
+ toJSON(): string;
190
+ }
142
191
  /**
143
192
  * @typedef PGJsonb
144
193
  * @see Spanner.pgJsonb
@@ -185,9 +234,10 @@ declare function convertFieldsToJson(fields: Field[], options?: JSONOptions): Js
185
234
  *
186
235
  * @param {*} value Value to decode
187
236
  * @param {object[]} type Value type object.
237
+ * @param columnMetadata Optional parameter to deserialize data
188
238
  * @returns {*}
189
239
  */
190
- declare function decode(value: Value, type: spannerClient.spanner.v1.Type): Value;
240
+ declare function decode(value: Value, type: spannerClient.spanner.v1.Type, columnMetadata?: object): Value;
191
241
  /**
192
242
  * Encode a value in the format the API expects.
193
243
  *
@@ -207,6 +257,7 @@ export interface Type {
207
257
  type: string;
208
258
  fields?: FieldType[];
209
259
  child?: Type;
260
+ fullName?: string;
210
261
  }
211
262
  interface FieldType extends Type {
212
263
  name: string;
@@ -226,6 +277,8 @@ interface FieldType extends Type {
226
277
  * - string
227
278
  * - bytes
228
279
  * - json
280
+ * - proto
281
+ * - enum
229
282
  * - timestamp
230
283
  * - date
231
284
  * - struct
@@ -298,6 +351,8 @@ export declare const codec: {
298
351
  Numeric: typeof Numeric;
299
352
  PGNumeric: typeof PGNumeric;
300
353
  PGJsonb: typeof PGJsonb;
354
+ ProtoMessage: typeof ProtoMessage;
355
+ ProtoEnum: typeof ProtoEnum;
301
356
  PGOid: typeof PGOid;
302
357
  convertFieldsToJson: typeof convertFieldsToJson;
303
358
  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,
@@ -52,10 +52,14 @@ type GetTransactionCallback = NormalCallback<Transaction>;
52
52
  export interface SessionPoolConstructor {
53
53
  new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
54
54
  }
55
+ export type GetDatabaseDialectCallback = NormalCallback<EnumKey<typeof google.spanner.admin.database.v1.DatabaseDialect>>;
55
56
  export interface SetIamPolicyRequest {
56
57
  policy: Policy | null;
57
58
  updateMask?: FieldMask | null;
58
59
  }
60
+ export interface RunPartitionedUpdateOptions extends ExecuteSqlRequest {
61
+ excludeTxnFromChangeStreams?: boolean;
62
+ }
59
63
  export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
60
64
  export type UpdateSchemaResponse = [
61
65
  GaxOperation,
@@ -67,7 +71,7 @@ export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
67
71
  /**
68
72
  * IDatabase structure with database state enum translated to string form.
69
73
  */
70
- type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
74
+ 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
75
  restoreInfo?: IRestoreInfoTranslatedEnum | null;
72
76
  };
73
77
  /**
@@ -172,6 +176,7 @@ declare class Database extends common.GrpcServiceObject {
172
176
  };
173
177
  request: DatabaseRequest;
174
178
  databaseRole?: string | null;
179
+ databaseDialect?: EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | null;
175
180
  constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
176
181
  /**
177
182
  * @typedef {array} SetDatabaseMetadataResponse
@@ -817,6 +822,31 @@ declare class Database extends common.GrpcServiceObject {
817
822
  getState(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State> | undefined>;
818
823
  getState(callback: GetStateCallback): void;
819
824
  getState(options: CallOptions, callback: GetStateCallback): void;
825
+ /**
826
+ * Retrieves the dialect of the database
827
+ *
828
+ * @see {@link #getMetadata}
829
+ *
830
+ * @method Database#getDatabaseDialect
831
+ *
832
+ * @param {object} [gaxOptions] Request configuration options,
833
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
834
+ * for more details.
835
+ * @param {GetDatabaseDialectCallback} [callback] Callback function.
836
+ * @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>}
837
+ * When resolved, contains the database dialect of the database if the dialect is defined.
838
+ * @example
839
+ * const {Spanner} = require('@google-cloud/spanner');
840
+ * const spanner = new Spanner();
841
+ * const instance = spanner.instance('my-instance');
842
+ * const database = instance.database('my-database');
843
+ * const dialect = await database.getDatabaseDialect();
844
+ * const isGoogleSQL = (dialect === 'GOOGLE_STANDARD_SQL');
845
+ * const isPostgreSQL = (dialect === 'POSTGRESQL');
846
+ */
847
+ getDatabaseDialect(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>;
848
+ getDatabaseDialect(callback: GetDatabaseDialectCallback): void;
849
+ getDatabaseDialect(options: CallOptions, callback: GetDatabaseDialectCallback): void;
820
850
  /**
821
851
  * @typedef {array} GetSchemaResponse
822
852
  * @property {string[]} 0 An array of database DDL statements.
@@ -1527,9 +1557,9 @@ declare class Database extends common.GrpcServiceObject {
1527
1557
  * @param {RunUpdateCallback} [callback] Callback function.
1528
1558
  * @returns {Promise<RunUpdateResponse>}
1529
1559
  */
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>;
1560
+ runPartitionedUpdate(query: string | RunPartitionedUpdateOptions): Promise<[number]>;
1561
+ runPartitionedUpdate(query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void;
1562
+ _runPartitionedUpdate(session: Session, query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void | Promise<number>;
1533
1563
  /**
1534
1564
  * Create a readable object stream to receive resulting rows from a SQL
1535
1565
  * statement.
@@ -442,6 +442,16 @@ class Database extends common.GrpcServiceObject {
442
442
  const [metadata] = await this.getMetadata(gaxOptions);
443
443
  return metadata.state || undefined;
444
444
  }
445
+ async getDatabaseDialect(optionsOrCallback, cb) {
446
+ const gaxOptions = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
447
+ if (this.databaseDialect === 'DATABASE_DIALECT_UNSPECIFIED' ||
448
+ this.databaseDialect === null ||
449
+ this.databaseDialect === undefined) {
450
+ const [metadata] = await this.getMetadata(gaxOptions);
451
+ this.databaseDialect = metadata.databaseDialect;
452
+ }
453
+ return this.databaseDialect || undefined;
454
+ }
445
455
  getSchema(optionsOrCallback, cb) {
446
456
  const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
447
457
  const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
@@ -631,6 +641,9 @@ class Database extends common.GrpcServiceObject {
631
641
  if (options.optimisticLock) {
632
642
  transaction.useOptimisticLock();
633
643
  }
644
+ if (options.excludeTxnFromChangeStreams) {
645
+ transaction.excludeTxnFromChangeStreams();
646
+ }
634
647
  if (!err) {
635
648
  this._releaseOnEnd(session, transaction);
636
649
  }
@@ -811,6 +824,9 @@ class Database extends common.GrpcServiceObject {
811
824
  }
812
825
  _runPartitionedUpdate(session, query, callback) {
813
826
  const transaction = session.partitionedDml();
827
+ if (typeof query !== 'string' && query.excludeTxnFromChangeStreams) {
828
+ transaction.excludeTxnFromChangeStreams();
829
+ }
814
830
  transaction.begin(err => {
815
831
  if (err) {
816
832
  this.pool_.release(session);
@@ -1022,6 +1038,9 @@ class Database extends common.GrpcServiceObject {
1022
1038
  if (options.optimisticLock) {
1023
1039
  transaction.useOptimisticLock();
1024
1040
  }
1041
+ if (options.excludeTxnFromChangeStreams) {
1042
+ transaction.excludeTxnFromChangeStreams();
1043
+ }
1025
1044
  const release = this.pool_.release.bind(this.pool_, session);
1026
1045
  const runner = new transaction_runner_1.TransactionRunner(session, transaction, runFn, options);
1027
1046
  runner.run().then(release, err => {
@@ -1113,6 +1132,9 @@ class Database extends common.GrpcServiceObject {
1113
1132
  if (options.optimisticLock) {
1114
1133
  transaction.useOptimisticLock();
1115
1134
  }
1135
+ if (options.excludeTxnFromChangeStreams) {
1136
+ transaction.excludeTxnFromChangeStreams();
1137
+ }
1116
1138
  const runner = new transaction_runner_1.AsyncTransactionRunner(session, transaction, runFn, options);
1117
1139
  try {
1118
1140
  return await runner.run();
@@ -1239,6 +1261,7 @@ exports.Database = Database;
1239
1261
  'batchTransaction',
1240
1262
  'getRestoreInfo',
1241
1263
  'getState',
1264
+ 'getDatabaseDialect',
1242
1265
  'getOperations',
1243
1266
  'runTransaction',
1244
1267
  'runTransactionAsync',
@@ -18,7 +18,7 @@ import { GrpcService } from './common-grpc/service';
18
18
  import { PreciseDate } from '@google-cloud/precise-date';
19
19
  import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
20
20
  import { common as p } from 'protobufjs';
21
- import { Float32, Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct } from './codec';
21
+ import { Float32, Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct, ProtoMessage, ProtoEnum, IProtoMessageParams, IProtoEnumParams } from './codec';
22
22
  import { Backup } from './backup';
23
23
  import { Database } from './database';
24
24
  import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
@@ -968,6 +968,55 @@ declare class Spanner extends GrpcService {
968
968
  * ```
969
969
  */
970
970
  static pgJsonb(value: any): PGJsonb;
971
+ /**
972
+ * @typedef IProtoMessageParams
973
+ * @property {object} value Proto Message value as serialized-buffer or message object.
974
+ * @property {string} fullName Fully-qualified path name of proto message.
975
+ * @property {Function} [messageFunction] Function generated by protobufs containing
976
+ * helper methods for deserializing and serializing messages.
977
+ */
978
+ /**
979
+ * Helper function to get a Cloud Spanner proto Message object.
980
+ *
981
+ * @param {IProtoMessageParams} params The proto message value params
982
+ * @returns {ProtoMessage}
983
+ *
984
+ * @example
985
+ * ```
986
+ * const {Spanner} = require('@google-cloud/spanner');
987
+ * const protoMessage = Spanner.protoMessage({
988
+ * value: singerInfo,
989
+ * messageFunction: music.SingerInfo,
990
+ * fullName: "examples.spanner.music.SingerInfo"
991
+ * });
992
+ * ```
993
+ */
994
+ static protoMessage(params: IProtoMessageParams): ProtoMessage;
995
+ /**
996
+ * @typedef IProtoEnumParams
997
+ * @property {string | number} value Proto Enum value as a string constant or
998
+ * an integer constant.
999
+ * @property {string} fullName Fully-qualified path name of proto enum.
1000
+ * @property {object} [enumObject] An enum object generated by protobufjs-cli.
1001
+ */
1002
+ /**
1003
+ * Helper function to get a Cloud Spanner proto enum object.
1004
+ *
1005
+ * @param {IProtoEnumParams} params The proto enum value params in the format of
1006
+ * @code{IProtoEnumParams}
1007
+ * @returns {ProtoEnum}
1008
+ *
1009
+ * @example
1010
+ * ```
1011
+ * const {Spanner} = require('@google-cloud/spanner');
1012
+ * const protoEnum = Spanner.protoEnum({
1013
+ * value: 'ROCK',
1014
+ * enumObject: music.Genre,
1015
+ * fullName: "examples.spanner.music.Genre"
1016
+ * });
1017
+ * ```
1018
+ */
1019
+ static protoEnum(params: IProtoEnumParams): ProtoEnum;
971
1020
  /**
972
1021
  * Helper function to get a Cloud Spanner Struct object.
973
1022
  *
@@ -921,6 +921,59 @@ class Spanner extends service_1.GrpcService {
921
921
  static pgJsonb(value) {
922
922
  return new codec_1.codec.PGJsonb(value);
923
923
  }
924
+ /**
925
+ * @typedef IProtoMessageParams
926
+ * @property {object} value Proto Message value as serialized-buffer or message object.
927
+ * @property {string} fullName Fully-qualified path name of proto message.
928
+ * @property {Function} [messageFunction] Function generated by protobufs containing
929
+ * helper methods for deserializing and serializing messages.
930
+ */
931
+ /**
932
+ * Helper function to get a Cloud Spanner proto Message object.
933
+ *
934
+ * @param {IProtoMessageParams} params The proto message value params
935
+ * @returns {ProtoMessage}
936
+ *
937
+ * @example
938
+ * ```
939
+ * const {Spanner} = require('@google-cloud/spanner');
940
+ * const protoMessage = Spanner.protoMessage({
941
+ * value: singerInfo,
942
+ * messageFunction: music.SingerInfo,
943
+ * fullName: "examples.spanner.music.SingerInfo"
944
+ * });
945
+ * ```
946
+ */
947
+ static protoMessage(params) {
948
+ return new codec_1.codec.ProtoMessage(params);
949
+ }
950
+ /**
951
+ * @typedef IProtoEnumParams
952
+ * @property {string | number} value Proto Enum value as a string constant or
953
+ * an integer constant.
954
+ * @property {string} fullName Fully-qualified path name of proto enum.
955
+ * @property {object} [enumObject] An enum object generated by protobufjs-cli.
956
+ */
957
+ /**
958
+ * Helper function to get a Cloud Spanner proto enum object.
959
+ *
960
+ * @param {IProtoEnumParams} params The proto enum value params in the format of
961
+ * @code{IProtoEnumParams}
962
+ * @returns {ProtoEnum}
963
+ *
964
+ * @example
965
+ * ```
966
+ * const {Spanner} = require('@google-cloud/spanner');
967
+ * const protoEnum = Spanner.protoEnum({
968
+ * value: 'ROCK',
969
+ * enumObject: music.Genre,
970
+ * fullName: "examples.spanner.music.Genre"
971
+ * });
972
+ * ```
973
+ */
974
+ static protoEnum(params) {
975
+ return new codec_1.codec.ProtoEnum(params);
976
+ }
924
977
  /**
925
978
  * Helper function to get a Cloud Spanner Struct object.
926
979
  *