@google-cloud/spanner 6.6.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,13 @@
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
+
7
14
  ## [6.6.0](https://github.com/googleapis/nodejs-spanner/compare/v6.5.0...v6.6.0) (2022-12-16)
8
15
 
9
16
 
package/README.md CHANGED
@@ -111,6 +111,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
111
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) |
112
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) |
113
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) |
114
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) |
115
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) |
116
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) |
@@ -143,6 +146,9 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-spanner/tre
143
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) |
144
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) |
145
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) |
146
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) |
147
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) |
148
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) |
@@ -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.
@@ -979,6 +979,9 @@ class Database extends common.GrpcServiceObject {
979
979
  runFn(err);
980
980
  return;
981
981
  }
982
+ if (options.optimisticLock) {
983
+ transaction.useOptimisticLock();
984
+ }
982
985
  const release = this.pool_.release.bind(this.pool_, session);
983
986
  const runner = new transaction_runner_1.TransactionRunner(session, transaction, runFn, options);
984
987
  runner.run().then(release, err => {
@@ -1067,6 +1070,9 @@ class Database extends common.GrpcServiceObject {
1067
1070
  try {
1068
1071
  const [session, transaction] = await (0, promisify_1.promisify)(getSession)();
1069
1072
  transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
1073
+ if (options.optimisticLock) {
1074
+ transaction.useOptimisticLock();
1075
+ }
1070
1076
  const runner = new transaction_runner_1.AsyncTransactionRunner(session, transaction, runFn, options);
1071
1077
  try {
1072
1078
  return await runner.run();
@@ -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.6.0",
4
+ "version": "6.7.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
@@ -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",