@google-cloud/spanner 6.5.0 → 6.7.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
6
6
 
7
+ ## [6.7.0](https://github.com/googleapis/nodejs-spanner/compare/v6.6.0...v6.7.0) (2023-01-17)
8
+
9
+
10
+ ### Features
11
+
12
+ * Added SuggestConversationSummary RPC ([#1744](https://github.com/googleapis/nodejs-spanner/issues/1744)) ([14346f3](https://github.com/googleapis/nodejs-spanner/commit/14346f3cf8ed0cb0a93c255dc520dc62887c0e1a))
13
+
14
+ ## [6.6.0](https://github.com/googleapis/nodejs-spanner/compare/v6.5.0...v6.6.0) (2022-12-16)
15
+
16
+
17
+ ### Features
18
+
19
+ * Export data types in index.ts ([#1726](https://github.com/googleapis/nodejs-spanner/issues/1726)) ([844f57f](https://github.com/googleapis/nodejs-spanner/commit/844f57fa5e79e5e5a5ede80df5e117004427f201)), closes [#1720](https://github.com/googleapis/nodejs-spanner/issues/1720)
20
+ * Fgac support and samples ([#1751](https://github.com/googleapis/nodejs-spanner/issues/1751)) ([0a394df](https://github.com/googleapis/nodejs-spanner/commit/0a394df9bfa193d79edc4c3a3d26238f361c0d45))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * Add sleep after admin request intensive tests ([#1758](https://github.com/googleapis/nodejs-spanner/issues/1758)) ([7643ceb](https://github.com/googleapis/nodejs-spanner/commit/7643ceb7cde9f420539877b86fdb0d38b254348d))
26
+
7
27
  ## [6.5.0](https://github.com/googleapis/nodejs-spanner/compare/v6.4.0...v6.5.0) (2022-11-30)
8
28
 
9
29
 
package/README.md CHANGED
@@ -89,6 +89,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
89
89
 
90
90
  | Sample | Source Code | Try it |
91
91
  | --------------------------- | --------------------------------- | ------ |
92
+ | Add and drop new database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/add-and-drop-new-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/add-and-drop-new-database-role.js,samples/README.md) |
92
93
  | Backups-cancel | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-cancel.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-cancel.js,samples/README.md) |
93
94
  | Copies a source backup | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-copy.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-copy.js,samples/README.md) |
94
95
  | Backups-create-with-encryption-key | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/backups-create-with-encryption-key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/backups-create-with-encryption-key.js,samples/README.md) |
@@ -110,8 +111,13 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
110
111
  | Gets the default leader option of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-get-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-get-default-leader.js,samples/README.md) |
111
112
  | Updates the default leader of an existing database | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/database-update-default-leader.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/database-update-default-leader.js,samples/README.md) |
112
113
  | Datatypes | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/datatypes.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/datatypes.js,samples/README.md) |
114
+ | Delete using DML returning. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml-returning-delete.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml-returning-delete.js,samples/README.md) |
115
+ | Insert using DML returning. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml-returning-insert.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml-returning-insert.js,samples/README.md) |
116
+ | Update using DML returning. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml-returning-update.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml-returning-update.js,samples/README.md) |
113
117
  | DML | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/dml.js,samples/README.md) |
118
+ | Enable fine grained access control | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/enable-fine-grained-access.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/enable-fine-grained-access.js,samples/README.md) |
114
119
  | Get-commit-stats | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-commit-stats.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-commit-stats.js,samples/README.md) |
120
+ | List database roles | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-database-roles.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-database-roles.js,samples/README.md) |
115
121
  | Gets the instance config metadata for the configuration nam6 | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/get-instance-config.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/get-instance-config.js,samples/README.md) |
116
122
  | Creates a new value-storing index | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/index-create-storing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/index-create-storing.js,samples/README.md) |
117
123
  | Creates a new index | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/index-create.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/index-create.js,samples/README.md) |
@@ -140,6 +146,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
140
146
  | Execute a batch of DML statements on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-batch.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-batch.js,samples/README.md) |
141
147
  | Updates data in a table in a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-getting-started-update.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-getting-started-update.js,samples/README.md) |
142
148
  | Execute a Partitioned DML on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-partitioned.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-partitioned.js,samples/README.md) |
149
+ | Delete using DML returning on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-returning-delete.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-returning-delete.js,samples/README.md) |
150
+ | Insert using DML returning on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-returning-insert.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-returning-insert.js,samples/README.md) |
151
+ | Update using DML returning on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-returning-update.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-returning-update.js,samples/README.md) |
143
152
  | Execute a DML statement with parameters on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-dml-with-parameter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-dml-with-parameter.js,samples/README.md) |
144
153
  | Calls a server side function on a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-functions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-functions.js,samples/README.md) |
145
154
  | Creates a new storing index in a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-index-create-storing.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-index-create-storing.js,samples/README.md) |
@@ -153,6 +162,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
153
162
  | Query the information schema metadata in a Spanner PostgreSQL database. | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/pg-schema-information.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/pg-schema-information.js,samples/README.md) |
154
163
  | Queryoptions | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/queryoptions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/queryoptions.js,samples/README.md) |
155
164
  | Quickstart | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
165
+ | Read data with database role | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/read-data-with-database-role.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/read-data-with-database-role.js,samples/README.md) |
156
166
  | Sets a request tag for a single query | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/request-tag.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/request-tag.js,samples/README.md) |
157
167
  | Run Batch update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-batch-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-batch-dml.js,samples/README.md) |
158
168
  | Run partitioned update with RPC priority | [source code](https://github.com/googleapis/nodejs-spanner/blob/main/samples/rpc-priority-partitioned-dml.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-spanner&page=editor&open_in_editor=samples/rpc-priority-partitioned-dml.js,samples/README.md) |
@@ -1,4 +1,4 @@
1
- // Copyright 2022 Google LLC
1
+ // Copyright 2023 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- // Copyright 2022 Google LLC
1
+ // Copyright 2023 Google LLC
2
2
  //
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
@@ -31,6 +31,12 @@ import { AsyncRunTransactionCallback, RunTransactionCallback, RunTransactionOpti
31
31
  import { IOperation, LongRunningCallback, NormalCallback, PagedOptionsWithFilter, PagedResponse, RequestCallback, ResourceCallback, Schema } from './common';
32
32
  import { Duplex, Readable } from 'stream';
33
33
  import { EnumKey, RequestConfig, TranslateEnumKeys } from '.';
34
+ import IPolicy = google.iam.v1.IPolicy;
35
+ import Policy = google.iam.v1.Policy;
36
+ import FieldMask = google.protobuf.FieldMask;
37
+ export type GetDatabaseRolesCallback = RequestCallback<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
38
+ export type GetDatabaseRolesResponse = PagedResponse<IDatabaseRole, databaseAdmin.spanner.admin.database.v1.IListDatabaseRolesResponse>;
39
+ type IDatabaseRole = databaseAdmin.spanner.admin.database.v1.IDatabaseRole;
34
40
  type CreateBatchTransactionCallback = ResourceCallback<BatchTransaction, google.spanner.v1.ITransaction | google.spanner.v1.ISession>;
35
41
  type CreateBatchTransactionResponse = [
36
42
  BatchTransaction,
@@ -43,6 +49,10 @@ type GetTransactionCallback = NormalCallback<Transaction>;
43
49
  export interface SessionPoolConstructor {
44
50
  new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
45
51
  }
52
+ export interface SetIamPolicyRequest {
53
+ policy: Policy | null;
54
+ updateMask?: FieldMask | null;
55
+ }
46
56
  export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
47
57
  export type UpdateSchemaResponse = [
48
58
  GaxOperation,
@@ -50,6 +60,7 @@ export type UpdateSchemaResponse = [
50
60
  ];
51
61
  type PoolRequestCallback = RequestCallback<Session>;
52
62
  export type GetSessionsOptions = PagedOptionsWithFilter;
63
+ export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
53
64
  /**
54
65
  * IDatabase structure with database state enum translated to string form.
55
66
  */
@@ -67,6 +78,10 @@ type GetSchemaResponse = [
67
78
  string[],
68
79
  databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse
69
80
  ];
81
+ type GetIamPolicyResponse = IPolicy;
82
+ type GetIamPolicyCallback = RequestCallback<IPolicy>;
83
+ type SetIamPolicyResponse = IPolicy;
84
+ type SetIamPolicyCallback = RequestCallback<IPolicy>;
70
85
  type GetSessionsCallback = RequestCallback<Session, google.spanner.v1.IListSessionsResponse>;
71
86
  type GetSessionsResponse = PagedResponse<Session, google.spanner.v1.IListSessionsResponse>;
72
87
  export type GetDatabaseConfig = GetConfig & databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
@@ -81,6 +96,11 @@ export interface CreateSessionOptions {
81
96
  labels?: {
82
97
  [k: string]: string;
83
98
  } | null;
99
+ databaseRole?: string | null;
100
+ gaxOptions?: CallOptions;
101
+ }
102
+ export interface GetIamPolicyOptions {
103
+ requestedPolicyVersion?: number | null;
84
104
  gaxOptions?: CallOptions;
85
105
  }
86
106
  export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
@@ -142,6 +162,7 @@ declare class Database extends common.GrpcServiceObject {
142
162
  [k: string]: string;
143
163
  };
144
164
  request: DatabaseRequest;
165
+ databaseRole?: string | null;
145
166
  constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
146
167
  static getEnvironmentQueryOptions(): databaseAdmin.spanner.v1.ExecuteSqlRequest.IQueryOptions;
147
168
  /**
@@ -772,6 +793,53 @@ declare class Database extends common.GrpcServiceObject {
772
793
  getSchema(options?: CallOptions): Promise<GetSchemaResponse>;
773
794
  getSchema(callback: GetSchemaCallback): void;
774
795
  getSchema(options: CallOptions, callback: GetSchemaCallback): void;
796
+ /**
797
+ * Options object for requested policy version.
798
+ *
799
+ * @typedef {object} GetIamPolicyOptions
800
+ * @property {number|null} [requestedPolicyVersion] policy version requested, possible values are 0, 1 and 3,
801
+ * See {@link https://cloud.google.com/iam/docs/policies#versions} for more details
802
+ * @property {object} [gaxOptions] Request configuration options,
803
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
804
+ * for more details.
805
+ */
806
+ /**
807
+ * @callback GetIamPolicyCallback
808
+ * @param {?Error} err Request error, if any.
809
+ * @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
810
+ */
811
+ /**
812
+ * Retrieves the policy of the database.
813
+ *
814
+ * A Policy is a collection of bindings. A binding binds one or more members, or principals,
815
+ * to a single role. Principals can be user accounts, service accounts, Google groups, and
816
+ * domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
817
+ * predefined role or a user-created custom role.
818
+ *
819
+ * @see {@link #getIamPolicy}
820
+ *
821
+ * @method Database#getIamPolicy
822
+ * @param {object} [options] requestedPolicyVersion and gax options(configuration options)
823
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
824
+ * for more details on gax options.
825
+ * @param {GetIamPolicyCallback} [callback] Callback function.
826
+ * @returns {Promise<Policy | undefined>}
827
+ * When resolved, contains the current policy of the database.
828
+ *
829
+ * @example
830
+ * ```
831
+ * const {Spanner} = require('@google-cloud/spanner');
832
+ * const spanner = new Spanner();
833
+ * const instance = spanner.instance('my-instance');
834
+ * const database = instance.database('my-database');
835
+ * const policy = await database.getIamPolicy();
836
+ * console.log(policy.bindings, policy.version, policy.etag, policy.auditConfigs)
837
+ * const policyWithVersion specified = await database.getIamPolicy({requestedPolicyVersion: 3});
838
+ * ```
839
+ */
840
+ getIamPolicy(options?: GetIamPolicyOptions): Promise<GetIamPolicyResponse>;
841
+ getIamPolicy(callback: GetIamPolicyCallback): void;
842
+ getIamPolicy(options: GetIamPolicyOptions, callback: GetIamPolicyCallback): void;
775
843
  /**
776
844
  * Options object for listing sessions.
777
845
  *
@@ -1068,6 +1136,67 @@ declare class Database extends common.GrpcServiceObject {
1068
1136
  getOperations(options?: GetDatabaseOperationsOptions): Promise<GetDatabaseOperationsResponse>;
1069
1137
  getOperations(callback: GetDatabaseOperationsCallback): void;
1070
1138
  getOperations(options: GetDatabaseOperationsOptions, callback: GetDatabaseOperationsCallback): void;
1139
+ /**
1140
+ * @typedef {array} GetDatabaseRolesResponse
1141
+ * @property {IDatabaseRolees[]} 0 Array of list of database roles.
1142
+ * @property {object} 1 A query object to receive more results.
1143
+ * @property {object} 2 The full API response.
1144
+ */
1145
+ /**
1146
+ * @callback GetDatabaseRolesCallback
1147
+ * @param {?Error} err Request error, if any.
1148
+ * @param {object} apiResponse The full API response.
1149
+ */
1150
+ /**
1151
+ * Gets a list of database roles
1152
+ *
1153
+ * @see {@link v1.DatabaseAdminClient#getDatabaseRoles}
1154
+ * @see [GetDatabaseRoles API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseRoles)
1155
+ *
1156
+ * @param {object} [gaxOptions] Request configuration options,
1157
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
1158
+ * for more details.
1159
+ * @param {GetDatabaseRolesCallback} [callback] Callback function.
1160
+ * @returns {Promise<GetDatabaseRolesResponse>}
1161
+ *
1162
+ * @example
1163
+ * ```
1164
+ * const {Spanner} = require('@google-cloud/spanner');
1165
+ * const spanner = new Spanner();
1166
+ *
1167
+ * const instance = spanner.instance('my-instance');
1168
+ * const database = instance.database('my-database');
1169
+ *
1170
+ * database.getDatabaseRoles(function(err, roles) {
1171
+ * // `roles` is an array of `DatabaseRoles` objects.
1172
+ * });
1173
+ *
1174
+ * //-
1175
+ * // To control how many API requests are made and page through the results
1176
+ * // manually, set `autoPaginate` to `false`.
1177
+ * //-
1178
+ * function callback(err, roles, nextQuery, apiResponse) {
1179
+ * if (nextQuery) {
1180
+ * // More results exist.
1181
+ * database.getDatabaseRoles(nextQuery, callback);
1182
+ * }
1183
+ * }
1184
+ *
1185
+ * database.getInstances({
1186
+ * gaxOptions: {autoPaginate: false}
1187
+ * }, callback);
1188
+ *
1189
+ * //-
1190
+ * // If the callback is omitted, we'll return a Promise.
1191
+ * //-
1192
+ * database.getInstances().then(function(data) {
1193
+ * const roles = data[0];
1194
+ * });
1195
+ * ```
1196
+ */
1197
+ getDatabaseRoles(gaxOptions?: CallOptions): Promise<GetDatabaseRolesResponse>;
1198
+ getDatabaseRoles(callback: GetDatabaseRolesCallback): void;
1199
+ getDatabaseRoles(gaxOptions: CallOptions, callback: GetDatabaseRolesCallback): void;
1071
1200
  /**
1072
1201
  * Make an API request, first assuring an active session is used.
1073
1202
  *
@@ -1583,6 +1712,57 @@ declare class Database extends common.GrpcServiceObject {
1583
1712
  * const table = database.table('Singers');
1584
1713
  * ```
1585
1714
  */
1715
+ /**
1716
+ * @callback SetIamPolicyCallback
1717
+ * @param {?Error} err Request error, if any.
1718
+ * @param {google.iam.v1.Policy| undefined} policy Returns policy for the give database
1719
+ */
1720
+ /**
1721
+ * Sets the policy for the database.
1722
+ *
1723
+ * A Policy is a collection of bindings. A binding binds one or more members, or principals,
1724
+ * to a single role. Principals can be user accounts, service accounts, Google groups, and
1725
+ * domains (such as G Suite). A role is a named list of permissions; each role can be an IAM
1726
+ * predefined role or a user-created custom role.
1727
+ *
1728
+ * @see {@link #setIamPolicy}
1729
+ *
1730
+ * @method Database#setIamPolicy
1731
+ * @param {object} [policy] requestedPolicyVersion and gax options(configuration options)
1732
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
1733
+ * for more details on gax options.
1734
+ * @param {object} [options] Requested configuration options,
1735
+ * See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html}
1736
+ * for more details on Call Options.
1737
+ * @param {SetIamPolicyCallback} [callback] Callback function.
1738
+ * @returns {Promise<Policy | undefined>}
1739
+ * When resolved, contains the current policy of the database.
1740
+ *
1741
+ * @example
1742
+ * ```
1743
+ * const {Spanner} = require('@google-cloud/spanner');
1744
+ * const spanner = new Spanner();
1745
+ * const instance = spanner.instance('my-instance');
1746
+ * const database = instance.database('my-database');
1747
+ * const binding = {
1748
+ * role: 'roles/spanner.fineGrainedAccessUser',
1749
+ * members: ['user:asthamohta@google.com'],
1750
+ * condition: {
1751
+ * title: 'new condition',
1752
+ * expression: 'resource.name.endsWith("/databaseRoles/parent")',
1753
+ * },
1754
+ * };
1755
+ * const policy = {
1756
+ * bindings: [newBinding],
1757
+ * version: 3,
1758
+ *};
1759
+ * const policy = await database.setIamPolicy({policy: policy});
1760
+ * ```
1761
+ */
1762
+ setIamPolicy(policy: SetIamPolicyRequest): Promise<SetIamPolicyResponse>;
1763
+ setIamPolicy(policy: SetIamPolicyRequest, options?: CallOptions): Promise<SetIamPolicyResponse>;
1764
+ setIamPolicy(policy: SetIamPolicyRequest, callback: SetIamPolicyCallback): void;
1765
+ setIamPolicy(policy: SetIamPolicyRequest, options: CallOptions, callback: SetIamPolicyCallback): void;
1586
1766
  table(name: string): Table;
1587
1767
  /**
1588
1768
  * Update the schema of the database by creating/altering/dropping tables,
@@ -141,6 +141,9 @@ class Database extends common.GrpcServiceObject {
141
141
  typeof poolOptions === 'function'
142
142
  ? new poolOptions(this, null)
143
143
  : new session_pool_1.SessionPool(this, poolOptions);
144
+ if (typeof poolOptions === 'object') {
145
+ this.databaseRole = poolOptions.databaseRole || null;
146
+ }
144
147
  this.formattedName_ = formattedName_;
145
148
  this.instance = instance;
146
149
  this.resourceHeader_ = {
@@ -170,9 +173,10 @@ class Database extends common.GrpcServiceObject {
170
173
  }
171
174
  const count = options.count;
172
175
  const labels = options.labels || {};
176
+ const databaseRole = options.databaseRole || this.databaseRole || null;
173
177
  const reqOpts = {
174
178
  database: this.formattedName_,
175
- sessionTemplate: { labels },
179
+ sessionTemplate: { labels: labels, creatorRole: databaseRole },
176
180
  sessionCount: count,
177
181
  };
178
182
  this.request({
@@ -265,9 +269,12 @@ class Database extends common.GrpcServiceObject {
265
269
  const reqOpts = {
266
270
  database: this.formattedName_,
267
271
  };
272
+ reqOpts.session = {};
268
273
  if (options.labels) {
269
- reqOpts.session = { labels: options.labels };
274
+ reqOpts.session.labels = options.labels;
270
275
  }
276
+ reqOpts.session.creatorRole =
277
+ options.databaseRole || this.databaseRole || null;
271
278
  this.request({
272
279
  client: 'SpannerClient',
273
280
  method: 'createSession',
@@ -425,6 +432,25 @@ class Database extends common.GrpcServiceObject {
425
432
  callback(err, statements ? statements.statements : null, ...args);
426
433
  });
427
434
  }
435
+ getIamPolicy(optionsOrCallback, cb) {
436
+ const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
437
+ const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
438
+ const reqOpts = {
439
+ resource: this.formattedName_,
440
+ options: {
441
+ requestedPolicyVersion: options.requestedPolicyVersion || null,
442
+ },
443
+ };
444
+ this.request({
445
+ client: 'DatabaseAdminClient',
446
+ method: 'getIamPolicy',
447
+ reqOpts,
448
+ gaxOpts: options.gaxOptions,
449
+ headers: this.resourceHeader_,
450
+ }, (err, resp) => {
451
+ callback(err, resp);
452
+ });
453
+ }
428
454
  getSessions(optionsOrCallback, cb) {
429
455
  // eslint-disable-next-line @typescript-eslint/no-this-alias
430
456
  const self = this;
@@ -586,6 +612,35 @@ class Database extends common.GrpcServiceObject {
586
612
  };
587
613
  return this.instance.getDatabaseOperations(dbSpecificQuery);
588
614
  }
615
+ getDatabaseRoles(optionsOrCallback, cb) {
616
+ const gaxOpts = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
617
+ const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
618
+ let reqOpts = {
619
+ parent: this.formattedName_,
620
+ };
621
+ // Copy over pageSize and pageToken values from gaxOptions.
622
+ // However, values set on options take precedence.
623
+ if (gaxOpts) {
624
+ reqOpts = extend({}, {
625
+ pageSize: gaxOpts.pageSize,
626
+ pageToken: gaxOpts.pageToken,
627
+ }, reqOpts);
628
+ delete gaxOpts.pageSize;
629
+ delete gaxOpts.pageToken;
630
+ }
631
+ this.request({
632
+ client: 'DatabaseAdminClient',
633
+ method: 'listDatabaseRoles',
634
+ reqOpts,
635
+ gaxOpts,
636
+ headers: this.resourceHeader_,
637
+ }, (err, roles, nextPageRequest, ...args) => {
638
+ const nextQuery = nextPageRequest
639
+ ? extend({}, gaxOpts, nextPageRequest)
640
+ : null;
641
+ callback(err, roles, nextQuery, ...args);
642
+ });
643
+ }
589
644
  makePooledRequest_(config, callback) {
590
645
  const pool = this.pool_;
591
646
  pool.getSession((err, session) => {
@@ -924,6 +979,9 @@ class Database extends common.GrpcServiceObject {
924
979
  runFn(err);
925
980
  return;
926
981
  }
982
+ if (options.optimisticLock) {
983
+ transaction.useOptimisticLock();
984
+ }
927
985
  const release = this.pool_.release.bind(this.pool_, session);
928
986
  const runner = new transaction_runner_1.TransactionRunner(session, transaction, runFn, options);
929
987
  runner.run().then(release, err => {
@@ -1012,6 +1070,9 @@ class Database extends common.GrpcServiceObject {
1012
1070
  try {
1013
1071
  const [session, transaction] = await (0, promisify_1.promisify)(getSession)();
1014
1072
  transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
1073
+ if (options.optimisticLock) {
1074
+ transaction.useOptimisticLock();
1075
+ }
1015
1076
  const runner = new transaction_runner_1.AsyncTransactionRunner(session, transaction, runFn, options);
1016
1077
  try {
1017
1078
  return await runner.run();
@@ -1045,25 +1106,27 @@ class Database extends common.GrpcServiceObject {
1045
1106
  session(name) {
1046
1107
  return new session_1.Session(this, name);
1047
1108
  }
1048
- /**
1049
- * Get a reference to a Table object.
1050
- *
1051
- * @throws {GoogleError} If a name is not provided.
1052
- *
1053
- * @param {string} name The name of the table.
1054
- * @return {Table} A Table object.
1055
- *
1056
- * @example
1057
- * ```
1058
- * const {Spanner} = require('@google-cloud/spanner');
1059
- * const spanner = new Spanner();
1060
- *
1061
- * const instance = spanner.instance('my-instance');
1062
- * const database = instance.database('my-database');
1063
- *
1064
- * const table = database.table('Singers');
1065
- * ```
1066
- */
1109
+ setIamPolicy(policy, optionsOrCallback, cb) {
1110
+ const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {};
1111
+ const callback = typeof optionsOrCallback === 'function'
1112
+ ? optionsOrCallback
1113
+ : cb;
1114
+ const gaxOpts = options;
1115
+ const reqOpts = {
1116
+ resource: this.formattedName_,
1117
+ policy: policy.policy,
1118
+ updateMask: policy.updateMask || null,
1119
+ };
1120
+ this.request({
1121
+ client: 'DatabaseAdminClient',
1122
+ method: 'setIamPolicy',
1123
+ reqOpts,
1124
+ gaxOpts: gaxOpts,
1125
+ headers: this.resourceHeader_,
1126
+ }, (err, resp) => {
1127
+ callback(err, resp);
1128
+ });
1129
+ }
1067
1130
  table(name) {
1068
1131
  if (!name) {
1069
1132
  throw new google_gax_1.GoogleError('A name is required to access a Table object.');
@@ -1155,6 +1218,7 @@ exports.Database = Database;
1155
1218
  'getSessions',
1156
1219
  'getSnapshot',
1157
1220
  'getTransaction',
1221
+ 'getIamPolicy',
1158
1222
  'restore',
1159
1223
  'run',
1160
1224
  'runPartitionedUpdate',
@@ -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 { Float, Int, Numeric, PGNumeric, PGJsonb, Struct } from './codec';
21
+ import { Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct } from './codec';
22
22
  import { Backup } from './backup';
23
23
  import { Database } from './database';
24
24
  import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
@@ -1070,3 +1070,4 @@ declare const _default: {
1070
1070
  Spanner: typeof Spanner;
1071
1071
  };
1072
1072
  export default _default;
1073
+ export { Float, Int, Struct, Numeric, PGNumeric, SpannerDate };
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
18
+ exports.SpannerDate = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
19
19
  const service_1 = require("./common-grpc/service");
20
20
  const precise_date_1 = require("@google-cloud/precise-date");
21
21
  const projectify_1 = require("@google-cloud/projectify");
@@ -26,6 +26,12 @@ const path = require("path");
26
26
  const streamEvents = require("stream-events");
27
27
  const through = require("through2");
28
28
  const codec_1 = require("./codec");
29
+ Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return codec_1.Float; } });
30
+ Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return codec_1.Int; } });
31
+ Object.defineProperty(exports, "Numeric", { enumerable: true, get: function () { return codec_1.Numeric; } });
32
+ Object.defineProperty(exports, "PGNumeric", { enumerable: true, get: function () { return codec_1.PGNumeric; } });
33
+ Object.defineProperty(exports, "SpannerDate", { enumerable: true, get: function () { return codec_1.SpannerDate; } });
34
+ Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return codec_1.Struct; } });
29
35
  const backup_1 = require("./backup");
30
36
  Object.defineProperty(exports, "Backup", { enumerable: true, get: function () { return backup_1.Backup; } });
31
37
  const database_1 = require("./database");
@@ -149,6 +149,7 @@ export interface SessionPoolOptions {
149
149
  */
150
150
  writes?: number;
151
151
  incStep?: number;
152
+ databaseRole?: string | null;
152
153
  }
153
154
  /**
154
155
  * Error to be thrown when attempting to release unknown resources.
@@ -32,6 +32,7 @@ const DEFAULTS = {
32
32
  maxIdle: 1,
33
33
  min: 25,
34
34
  incStep: 25,
35
+ databaseRole: null,
35
36
  };
36
37
  /**
37
38
  * Error to be thrown when attempting to release unknown resources.
@@ -245,6 +246,9 @@ class SessionPool extends events_1.EventEmitter {
245
246
  this.database = database;
246
247
  this.options = Object.assign({}, DEFAULTS, options);
247
248
  this.options.min = Math.min(this.options.min, this.options.max);
249
+ this.options.databaseRole = this.options.databaseRole
250
+ ? this.options.databaseRole
251
+ : database.databaseRole;
248
252
  this._inventory = {
249
253
  sessions: [],
250
254
  borrowed: new Set(),
@@ -458,6 +462,7 @@ class SessionPool extends events_1.EventEmitter {
458
462
  */
459
463
  async _createSessions(amount) {
460
464
  const labels = this.options.labels;
465
+ const databaseRole = this.options.databaseRole;
461
466
  if (amount <= 0) {
462
467
  return;
463
468
  }
@@ -469,7 +474,8 @@ class SessionPool extends events_1.EventEmitter {
469
474
  try {
470
475
  [sessions] = await this.database.batchCreateSessions({
471
476
  count: amount,
472
- labels,
477
+ labels: labels,
478
+ databaseRole: databaseRole,
473
479
  });
474
480
  amount -= sessions.length;
475
481
  }
@@ -32,8 +32,16 @@ export declare const enum types {
32
32
  ReadOnly = "readonly",
33
33
  ReadWrite = "readwrite"
34
34
  }
35
- export type GetSessionMetadataCallback = NormalCallback<google.spanner.v1.ISession>;
36
- export type GetSessionMetadataResponse = [google.spanner.v1.ISession];
35
+ export interface GetSessionMetadataResponse {
36
+ name?: string | null;
37
+ labels?: {
38
+ [k: string]: string;
39
+ } | null;
40
+ createTime?: google.protobuf.ITimestamp | null;
41
+ approximateLastUseTime?: google.protobuf.ITimestamp | null;
42
+ databaseRole?: string | null;
43
+ }
44
+ export type GetSessionMetadataCallback = NormalCallback<GetSessionMetadataResponse>;
37
45
  export type KeepAliveCallback = NormalCallback<google.spanner.v1.IResultSet>;
38
46
  export type KeepAliveResponse = [google.spanner.v1.IResultSet];
39
47
  export type DeleteSessionResponse = [google.protobuf.IEmpty];
@@ -185,6 +185,9 @@ class Session extends common.GrpcServiceObject {
185
185
  typeof optionsOrCallback === 'function'
186
186
  ? optionsOrCallback
187
187
  : callback;
188
+ this.labels = options.labels || null;
189
+ this.databaseRole =
190
+ options.databaseRole || database.databaseRole || null;
188
191
  return database.createSession(options, (err, session, apiResponse) => {
189
192
  if (err) {
190
193
  callback(err, null, apiResponse);
@@ -232,6 +235,8 @@ class Session extends common.GrpcServiceObject {
232
235
  headers: this.resourceHeader_,
233
236
  }, (err, resp) => {
234
237
  if (resp) {
238
+ resp.databaseRole = resp.creatorRole;
239
+ delete resp.creatorRole;
235
240
  this.metadata = resp;
236
241
  }
237
242
  callback(err, resp);
@@ -27,6 +27,7 @@ import IRequestOptions = google.spanner.v1.IRequestOptions;
27
27
  export interface RunTransactionOptions {
28
28
  timeout?: number;
29
29
  requestOptions?: Pick<IRequestOptions, 'transactionTag'>;
30
+ optimisticLock?: boolean;
30
31
  }
31
32
  /**
32
33
  * A function to execute in the context of a transaction.
@@ -116,6 +116,9 @@ class Runner {
116
116
  return transaction;
117
117
  }
118
118
  const transaction = this.session.transaction(this.session.parent.queryOptions_);
119
+ if (this.options.optimisticLock) {
120
+ transaction.useOptimisticLock();
121
+ }
119
122
  if (this.attempts > 0) {
120
123
  await transaction.begin();
121
124
  }
@@ -1413,6 +1413,17 @@ export declare class Transaction extends Dml {
1413
1413
  * Mark transaction as started from the runner.
1414
1414
  */
1415
1415
  useInRunner(): void;
1416
+ /**
1417
+ * Use optimistic concurrency control for the transaction.
1418
+ *
1419
+ * In this concurrency mode, operations during the execution phase, i.e.,
1420
+ * reads and queries, are performed without acquiring locks, and transactional
1421
+ * consistency is ensured by running a validation process in the commit phase
1422
+ * (when any needed locks are acquired). The validation process succeeds only
1423
+ * if there are no conflicting committed transactions (that committed
1424
+ * mutations to the read data at a commit timestamp after the read timestamp).
1425
+ */
1426
+ useOptimisticLock(): void;
1416
1427
  }
1417
1428
  /**
1418
1429
  * This type of transaction is used to execute a single Partitioned DML
@@ -26,6 +26,8 @@ const stream_1 = require("stream");
26
26
  const codec_1 = require("./codec");
27
27
  const partial_result_stream_1 = require("./partial-result-stream");
28
28
  const common_1 = require("./common");
29
+ const protos_1 = require("../protos/protos");
30
+ var ReadLockMode = protos_1.google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode;
29
31
  const RETRY_INFO_TYPE = 'type.googleapis.com/google.rpc.retryinfo';
30
32
  const RETRY_INFO_BIN = 'google.rpc.retryinfo-bin';
31
33
  /**
@@ -1428,6 +1430,19 @@ class Transaction extends Dml {
1428
1430
  useInRunner() {
1429
1431
  this._useInRunner = true;
1430
1432
  }
1433
+ /**
1434
+ * Use optimistic concurrency control for the transaction.
1435
+ *
1436
+ * In this concurrency mode, operations during the execution phase, i.e.,
1437
+ * reads and queries, are performed without acquiring locks, and transactional
1438
+ * consistency is ensured by running a validation process in the commit phase
1439
+ * (when any needed locks are acquired). The validation process succeeds only
1440
+ * if there are no conflicting committed transactions (that committed
1441
+ * mutations to the read data at a commit timestamp after the read timestamp).
1442
+ */
1443
+ useOptimisticLock() {
1444
+ this._options.readWrite.readLockMode = ReadLockMode.OPTIMISTIC;
1445
+ }
1431
1446
  }
1432
1447
  exports.Transaction = Transaction;
1433
1448
  /*! Developer Documentation
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2022 Google LLC
2
+ // Copyright 2023 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.
@@ -95,6 +95,8 @@ class DatabaseAdminClient {
95
95
  const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
96
96
  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');
97
97
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
98
+ // Request numeric enum values if REST transport is used.
99
+ opts.numericEnums = true;
98
100
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
99
101
  if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
100
102
  opts['scopes'] = staticMembers.scopes;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2022 Google LLC
2
+ // Copyright 2023 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.
@@ -109,6 +109,8 @@ class InstanceAdminClient {
109
109
  const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
110
110
  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');
111
111
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
112
+ // Request numeric enum values if REST transport is used.
113
+ opts.numericEnums = true;
112
114
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
113
115
  if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
114
116
  opts['scopes'] = staticMembers.scopes;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2022 Google LLC
2
+ // Copyright 2023 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.
@@ -93,6 +93,8 @@ class SpannerClient {
93
93
  const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
94
94
  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');
95
95
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
96
+ // Request numeric enum values if REST transport is used.
97
+ opts.numericEnums = true;
96
98
  // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
97
99
  if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
98
100
  opts['scopes'] = staticMembers.scopes;
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": "6.5.0",
4
+ "version": "6.7.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -91,7 +91,7 @@
91
91
  "@types/request": "^2.48.3",
92
92
  "@types/sinon": "^10.0.0",
93
93
  "@types/through2": "^2.0.34",
94
- "@types/uuid": "^8.0.0",
94
+ "@types/uuid": "^9.0.0",
95
95
  "binary-search-bounds": "^2.0.4",
96
96
  "c8": "^7.0.0",
97
97
  "codecov": "^3.0.2",
@@ -109,7 +109,7 @@
109
109
  "ncp": "^2.0.0",
110
110
  "p-limit": "^3.0.1",
111
111
  "proxyquire": "^2.0.1",
112
- "sinon": "^14.0.0",
112
+ "sinon": "^15.0.0",
113
113
  "stats-lite": "^2.1.1",
114
114
  "time-span": "^4.0.0",
115
115
  "tmp": "^0.2.0",