@google-cloud/spanner 8.6.0 → 8.7.1

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.
@@ -5739,7 +5739,8 @@
5739
5739
  "generateDbPartitionsQuery",
5740
5740
  "executePartition",
5741
5741
  "executeChangeStreamQuery",
5742
- "queryCancellation"
5742
+ "queryCancellation",
5743
+ "adaptMessage"
5743
5744
  ]
5744
5745
  }
5745
5746
  },
@@ -5819,6 +5820,10 @@
5819
5820
  "queryCancellation": {
5820
5821
  "type": "QueryCancellationAction",
5821
5822
  "id": 51
5823
+ },
5824
+ "adaptMessage": {
5825
+ "type": "AdaptMessageAction",
5826
+ "id": 52
5822
5827
  }
5823
5828
  }
5824
5829
  },
@@ -5894,6 +5899,11 @@
5894
5899
  "oneof": [
5895
5900
  "autocommitIfSupported"
5896
5901
  ]
5902
+ },
5903
+ "_lastStatement": {
5904
+ "oneof": [
5905
+ "lastStatement"
5906
+ ]
5897
5907
  }
5898
5908
  },
5899
5909
  "fields": {
@@ -5907,15 +5917,36 @@
5907
5917
  "options": {
5908
5918
  "proto3_optional": true
5909
5919
  }
5920
+ },
5921
+ "lastStatement": {
5922
+ "type": "bool",
5923
+ "id": 3,
5924
+ "options": {
5925
+ "proto3_optional": true
5926
+ }
5910
5927
  }
5911
5928
  }
5912
5929
  },
5913
5930
  "BatchDmlAction": {
5931
+ "oneofs": {
5932
+ "_lastStatements": {
5933
+ "oneof": [
5934
+ "lastStatements"
5935
+ ]
5936
+ }
5937
+ },
5914
5938
  "fields": {
5915
5939
  "updates": {
5916
5940
  "rule": "repeated",
5917
5941
  "type": "QueryAction",
5918
5942
  "id": 1
5943
+ },
5944
+ "lastStatements": {
5945
+ "type": "bool",
5946
+ "id": 2,
5947
+ "options": {
5948
+ "proto3_optional": true
5949
+ }
5919
5950
  }
5920
5951
  }
5921
5952
  },
@@ -6325,6 +6356,26 @@
6325
6356
  "optimistic": {
6326
6357
  "type": "bool",
6327
6358
  "id": 1
6359
+ },
6360
+ "excludeFromChangeStreams": {
6361
+ "type": "bool",
6362
+ "id": 2
6363
+ },
6364
+ "serializableOptimistic": {
6365
+ "type": "bool",
6366
+ "id": 3
6367
+ },
6368
+ "snapshotIsolationOptimistic": {
6369
+ "type": "bool",
6370
+ "id": 4
6371
+ },
6372
+ "snapshotIsolationPessimistic": {
6373
+ "type": "bool",
6374
+ "id": 5
6375
+ },
6376
+ "excludeTxnFromChangeStreams": {
6377
+ "type": "bool",
6378
+ "id": 6
6328
6379
  }
6329
6380
  }
6330
6381
  },
@@ -6376,7 +6427,8 @@
6376
6427
  "listCloudBackupOperations",
6377
6428
  "getOperation",
6378
6429
  "cancelOperation",
6379
- "changeQuorumCloudDatabase"
6430
+ "changeQuorumCloudDatabase",
6431
+ "addSplitPoints"
6380
6432
  ]
6381
6433
  }
6382
6434
  },
@@ -6492,6 +6544,10 @@
6492
6544
  "changeQuorumCloudDatabase": {
6493
6545
  "type": "ChangeQuorumCloudDatabaseAction",
6494
6546
  "id": 28
6547
+ },
6548
+ "addSplitPoints": {
6549
+ "type": "AddSplitPointsAction",
6550
+ "id": 29
6495
6551
  }
6496
6552
  }
6497
6553
  },
@@ -6661,6 +6717,10 @@
6661
6717
  "keyType": "string",
6662
6718
  "type": "string",
6663
6719
  "id": 5
6720
+ },
6721
+ "edition": {
6722
+ "type": "google.spanner.admin.instance.v1.Instance.Edition",
6723
+ "id": 8
6664
6724
  }
6665
6725
  }
6666
6726
  },
@@ -6728,6 +6788,10 @@
6728
6788
  "keyType": "string",
6729
6789
  "type": "string",
6730
6790
  "id": 6
6791
+ },
6792
+ "edition": {
6793
+ "type": "google.spanner.admin.instance.v1.Instance.Edition",
6794
+ "id": 8
6731
6795
  }
6732
6796
  }
6733
6797
  },
@@ -6892,6 +6956,35 @@
6892
6956
  }
6893
6957
  }
6894
6958
  },
6959
+ "AdaptMessageAction": {
6960
+ "fields": {
6961
+ "databaseUri": {
6962
+ "type": "string",
6963
+ "id": 1
6964
+ },
6965
+ "protocol": {
6966
+ "type": "string",
6967
+ "id": 2
6968
+ },
6969
+ "payload": {
6970
+ "type": "bytes",
6971
+ "id": 3
6972
+ },
6973
+ "attachments": {
6974
+ "keyType": "string",
6975
+ "type": "string",
6976
+ "id": 4
6977
+ },
6978
+ "query": {
6979
+ "type": "string",
6980
+ "id": 5
6981
+ },
6982
+ "prepareThenExecute": {
6983
+ "type": "bool",
6984
+ "id": 6
6985
+ }
6986
+ }
6987
+ },
6895
6988
  "ListCloudDatabasesAction": {
6896
6989
  "fields": {
6897
6990
  "projectId": {
@@ -7241,6 +7334,27 @@
7241
7334
  }
7242
7335
  }
7243
7336
  },
7337
+ "AddSplitPointsAction": {
7338
+ "fields": {
7339
+ "projectId": {
7340
+ "type": "string",
7341
+ "id": 1
7342
+ },
7343
+ "instanceId": {
7344
+ "type": "string",
7345
+ "id": 2
7346
+ },
7347
+ "databaseId": {
7348
+ "type": "string",
7349
+ "id": 3
7350
+ },
7351
+ "splitPoints": {
7352
+ "rule": "repeated",
7353
+ "type": "google.spanner.admin.database.v1.SplitPoints",
7354
+ "id": 4
7355
+ }
7356
+ }
7357
+ },
7244
7358
  "StartBatchTransactionAction": {
7245
7359
  "oneofs": {
7246
7360
  "param": {
@@ -7495,6 +7609,11 @@
7495
7609
  "oneof": [
7496
7610
  "adminResult"
7497
7611
  ]
7612
+ },
7613
+ "_snapshotIsolationTxnReadTimestamp": {
7614
+ "oneof": [
7615
+ "snapshotIsolationTxnReadTimestamp"
7616
+ ]
7498
7617
  }
7499
7618
  },
7500
7619
  "fields": {
@@ -7561,6 +7680,13 @@
7561
7680
  "rule": "repeated",
7562
7681
  "type": "ChangeStreamRecord",
7563
7682
  "id": 10
7683
+ },
7684
+ "snapshotIsolationTxnReadTimestamp": {
7685
+ "type": "int64",
7686
+ "id": 11,
7687
+ "options": {
7688
+ "proto3_optional": true
7689
+ }
7564
7690
  }
7565
7691
  }
7566
7692
  },
@@ -8743,12 +8869,18 @@
8743
8869
  },
8744
8870
  "params": {
8745
8871
  "type": "google.protobuf.Struct",
8746
- "id": 4
8872
+ "id": 4,
8873
+ "options": {
8874
+ "(google.api.field_behavior)": "OPTIONAL"
8875
+ }
8747
8876
  },
8748
8877
  "paramTypes": {
8749
8878
  "keyType": "string",
8750
8879
  "type": "Type",
8751
- "id": 5
8880
+ "id": 5,
8881
+ "options": {
8882
+ "(google.api.field_behavior)": "OPTIONAL"
8883
+ }
8752
8884
  },
8753
8885
  "partitionOptions": {
8754
8886
  "type": "PartitionOptions",
@@ -9848,6 +9980,13 @@
9848
9980
  "options": {
9849
9981
  "(google.api.field_behavior)": "OPTIONAL"
9850
9982
  }
9983
+ },
9984
+ "cacheUpdate": {
9985
+ "type": "CacheUpdate",
9986
+ "id": 6,
9987
+ "options": {
9988
+ "(google.api.field_behavior)": "OPTIONAL"
9989
+ }
9851
9990
  }
9852
9991
  }
9853
9992
  },
@@ -1198,6 +1198,7 @@ declare class Database extends common.GrpcServiceObject {
1198
1198
  */
1199
1199
  getTransaction(optionsOrCallback?: GetTransactionOptions): Promise<[Transaction]>;
1200
1200
  getTransaction(callback: GetTransactionCallback): void;
1201
+ getTransaction(options: GetTransactionOptions, callback: GetTransactionCallback): void;
1201
1202
  /**
1202
1203
  * Query object for listing database operations.
1203
1204
  *
@@ -194,6 +194,7 @@ declare class Spanner extends GrpcService {
194
194
  } | null;
195
195
  private _universeDomain;
196
196
  private _isInSecureCredentials;
197
+ private _metricsEnabled;
197
198
  private static _isAFEServerTimingEnabled;
198
199
  readonly _nthClientId: number;
199
200
  /**
@@ -163,6 +163,7 @@ class Spanner extends service_1.GrpcService {
163
163
  sessionLabels;
164
164
  _universeDomain;
165
165
  _isInSecureCredentials;
166
+ _metricsEnabled = false;
166
167
  static _isAFEServerTimingEnabled;
167
168
  _nthClientId;
168
169
  /**
@@ -766,10 +767,12 @@ class Spanner extends service_1.GrpcService {
766
767
  configureMetrics_(disableBuiltInMetrics) {
767
768
  // Only enable metrics if not explicitly disabled and we are not using
768
769
  // insecure credentials.
769
- const metricsEnabled = process.env.SPANNER_DISABLE_BUILTIN_METRICS !== 'true' &&
770
- !disableBuiltInMetrics &&
771
- !this._isInSecureCredentials;
772
- if (metricsEnabled) {
770
+ const metricsExplicitlyDisabled = process.env.SPANNER_DISABLE_BUILTIN_METRICS === 'true' ||
771
+ !!disableBuiltInMetrics;
772
+ this._metricsEnabled =
773
+ !metricsExplicitlyDisabled && !this._isInSecureCredentials;
774
+ metrics_tracer_factory_1.MetricsTracerFactory.enabled = this._metricsEnabled;
775
+ if (this._metricsEnabled) {
773
776
  try {
774
777
  this.auth.getProjectId((err, projectId) => {
775
778
  if (err || !projectId) {
@@ -778,7 +781,6 @@ class Spanner extends service_1.GrpcService {
778
781
  err);
779
782
  return;
780
783
  }
781
- metrics_tracer_factory_1.MetricsTracerFactory.enabled = metricsEnabled;
782
784
  this.projectId_ = projectId;
783
785
  const factory = metrics_tracer_factory_1.MetricsTracerFactory.getInstance(projectId);
784
786
  const periodicReader = new sdk_metrics_1.PeriodicExportingMetricReader({
@@ -848,7 +850,7 @@ class Spanner extends service_1.GrpcService {
848
850
  // Attach the x-goog-spanner-request-id to the currently active span.
849
851
  (0, request_id_header_1.attributeXGoogSpannerRequestIdToActiveSpan)(config);
850
852
  const interceptors = [];
851
- if (metrics_tracer_factory_1.MetricsTracerFactory.enabled) {
853
+ if (this._metricsEnabled) {
852
854
  interceptors.push(interceptor_1.MetricInterceptor);
853
855
  }
854
856
  const requestFn = gaxClient[config.method].bind(gaxClient, reqOpts,
@@ -919,7 +921,9 @@ class Spanner extends service_1.GrpcService {
919
921
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
920
922
  request(config, callback) {
921
923
  let metricsTracer = null;
922
- if (config.client === 'SpannerClient' && this.projectId_) {
924
+ if (this._metricsEnabled &&
925
+ config.client === 'SpannerClient' &&
926
+ this.projectId_) {
923
927
  metricsTracer =
924
928
  metrics_tracer_factory_1.MetricsTracerFactory?.getInstance(this.projectId_)?.createMetricsTracer(config.method, config.reqOpts.database ?? config.reqOpts.session, config.headers['x-goog-spanner-request-id']) ?? null;
925
929
  }
@@ -982,7 +986,9 @@ class Spanner extends service_1.GrpcService {
982
986
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
983
987
  requestStream(config) {
984
988
  let metricsTracer = null;
985
- if (config.client === 'SpannerClient' && this.projectId_) {
989
+ if (this._metricsEnabled &&
990
+ config.client === 'SpannerClient' &&
991
+ this.projectId_) {
986
992
  metricsTracer =
987
993
  metrics_tracer_factory_1.MetricsTracerFactory?.getInstance(this.projectId_)?.createMetricsTracer(config.method, config.reqOpts.session ?? config.reqOpts.database, config.headers['x-goog-spanner-request-id']) ?? null;
988
994
  }
@@ -72,9 +72,7 @@ const MetricInterceptor = (options, nextCall) => {
72
72
  metricsTracer?.recordAfeLatency(status.code);
73
73
  }
74
74
  else {
75
- // Disable afe_connectivity_error_count metric as AFE header is disabled in backend
76
- // currently.
77
- // metricsTracer?.recordAfeConnectivityErrorCount(status.code);
75
+ metricsTracer?.recordAfeConnectivityErrorCount(status.code);
78
76
  }
79
77
  },
80
78
  };
@@ -255,7 +255,7 @@ class MetricsTracerFactory {
255
255
  * @param requestId The request id of the gRPC call set under 'x-goog-spanner-request-id'.
256
256
  */
257
257
  clearCurrentTracer(requestId) {
258
- const operationRequest = this._extractOperationRequest(requestId);
258
+ const operationRequest = this._extractOperationRequest(requestId) || requestId;
259
259
  if (!this._currentOperationTracers.has(operationRequest)) {
260
260
  return;
261
261
  }
@@ -14,7 +14,7 @@ declare class MetricAttemptTracer {
14
14
  /**
15
15
  * Returns the start time of the attempt.
16
16
  */
17
- get startTime(): Date;
17
+ get startTime(): number;
18
18
  }
19
19
  /**
20
20
  * MetricOperationTracer tracks the lifecycle and metadata of a single gRPC spanner operation,
@@ -50,7 +50,7 @@ declare class MetricOperationTracer {
50
50
  /**
51
51
  * Returns the start time of the operation.
52
52
  */
53
- get startTime(): Date;
53
+ get startTime(): number;
54
54
  /**
55
55
  * Increments the attempt count and creates a new MetricAttemptTracer
56
56
  * for tracking the next attempt within this operation.
@@ -107,7 +107,7 @@ export declare class MetricsTracer {
107
107
  */
108
108
  constructor(_instrumentAttemptCounter: Counter | null, _instrumentAttemptLatency: Histogram | null, _instrumentOperationCounter: Counter | null, _instrumentOperationLatency: Histogram | null, _instrumentGfeConnectivityErrorCount: Counter | null, _instrumentGfeLatency: Histogram | null, _instrumentAfeConnectivityErrorCount: Counter | null, _instrumentAfeLatency: Histogram | null, enabled: boolean, _database: string, _instance: string, _projectId: string, _methodName: string, _request: string);
109
109
  /**
110
- * Returns the difference in milliseconds between two Date objects.
110
+ * Returns the difference in milliseconds between two times.
111
111
  * @param start The start time.
112
112
  * @param end The end time.
113
113
  * @returns The time difference in milliseconds.
@@ -29,7 +29,7 @@ class MetricAttemptTracer {
29
29
  _startTime;
30
30
  status;
31
31
  constructor() {
32
- this._startTime = new Date(Date.now());
32
+ this._startTime = performance.now();
33
33
  this.status = grpc_js_1.status[grpc_js_1.status.UNKNOWN];
34
34
  }
35
35
  /**
@@ -63,7 +63,7 @@ class MetricOperationTracer {
63
63
  _currentAttempt;
64
64
  constructor() {
65
65
  this._attemptCount = 0;
66
- this._startTime = new Date(Date.now());
66
+ this._startTime = performance.now();
67
67
  this._currentAttempt = null;
68
68
  }
69
69
  /**
@@ -167,13 +167,13 @@ class MetricsTracer {
167
167
  this._clientAttributes[constants_1.MONITORED_RES_LABEL_KEY_INSTANCE] = _instance;
168
168
  }
169
169
  /**
170
- * Returns the difference in milliseconds between two Date objects.
170
+ * Returns the difference in milliseconds between two times.
171
171
  * @param start The start time.
172
172
  * @param end The end time.
173
173
  * @returns The time difference in milliseconds.
174
174
  */
175
175
  _getMillisecondTimeDifference(start, end) {
176
- return end.valueOf() - start.valueOf();
176
+ return end - start;
177
177
  }
178
178
  /**
179
179
  * Gets the current client and resource attributes for metrics.
@@ -224,7 +224,7 @@ class MetricsTracer {
224
224
  return;
225
225
  this.currentOperation.currentAttempt.status = grpc_js_1.status[statusCode];
226
226
  const attemptAttributes = this._createAttemptOtelAttributes();
227
- const endTime = new Date(Date.now());
227
+ const endTime = performance.now();
228
228
  const attemptLatencyMilliseconds = this._getMillisecondTimeDifference(this.currentOperation.currentAttempt.startTime, endTime);
229
229
  this.instrumentAttemptLatency?.record(attemptLatencyMilliseconds, attemptAttributes);
230
230
  this.instrumentAttemptCounter?.add(1, attemptAttributes);
@@ -247,7 +247,7 @@ class MetricsTracer {
247
247
  recordOperationCompletion() {
248
248
  if (!this.enabled || !this.currentOperation)
249
249
  return;
250
- const endTime = new Date(Date.now());
250
+ const endTime = performance.now();
251
251
  const operationAttributes = this._createOperationOtelAttributes();
252
252
  const operationLatencyMilliseconds = this._getMillisecondTimeDifference(this.currentOperation.startTime, endTime);
253
253
  this.instrumentOperationCounter?.add(1, operationAttributes);
@@ -718,8 +718,9 @@ export declare class SpannerClient {
718
718
  * {@link protos.google.spanner.v1.Spanner.ExecuteStreamingSql|`ExecuteStreamingSql`} with
719
719
  * a `PartitionedDml` transaction for large, partition-friendly DML
720
720
  * operations.
721
- * @param {google.protobuf.Struct} request.params
722
- * Parameter names and values that bind to placeholders in the SQL string.
721
+ * @param {google.protobuf.Struct} [request.params]
722
+ * Optional. Parameter names and values that bind to placeholders in the SQL
723
+ * string.
723
724
  *
724
725
  * A parameter placeholder consists of the `@` character followed by the
725
726
  * parameter name (for example, `@firstName`). Parameter names can contain
@@ -731,10 +732,10 @@ export declare class SpannerClient {
731
732
  * `"WHERE id > @msg_id AND id < @msg_id + 100"`
732
733
  *
733
734
  * It's an error to execute a SQL statement with unbound parameters.
734
- * @param {number[]} request.paramTypes
735
- * It isn't always possible for Cloud Spanner to infer the right SQL type
736
- * from a JSON value. For example, values of type `BYTES` and values
737
- * of type `STRING` both appear in
735
+ * @param {number[]} [request.paramTypes]
736
+ * Optional. It isn't always possible for Cloud Spanner to infer the right SQL
737
+ * type from a JSON value. For example, values of type `BYTES` and values of
738
+ * type `STRING` both appear in
738
739
  * {@link protos.google.spanner.v1.PartitionQueryRequest.params|params} as JSON strings.
739
740
  *
740
741
  * In these cases, `param_types` can be used to specify the exact
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "8.6.0",
4
+ "version": "8.7.1",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
8
8
  "node": ">=18"
9
9
  },
10
- "repository": "googleapis/nodejs-spanner",
10
+ "repository": {
11
+ "type": "git",
12
+ "directory": "handwritten/spanner",
13
+ "url": "https://github.com/googleapis/google-cloud-node.git"
14
+ },
11
15
  "main": "./build/src/index.js",
12
16
  "types": "./build/src/index.d.ts",
13
17
  "files": [
@@ -54,6 +58,9 @@
54
58
  "coverage": "c8 mocha build/test build/test/common && c8 report --check-coverage"
55
59
  },
56
60
  "dependencies": {
61
+ "@babel/core": "7.27.7",
62
+ "@babel/helpers": "7.27.6",
63
+ "@babel/traverse": "7.27.7",
57
64
  "@google-cloud/common": "^6.0.0",
58
65
  "@google-cloud/monitoring": "^5.0.0",
59
66
  "@google-cloud/opentelemetry-resource-util": "^2.4.0",
@@ -88,14 +95,13 @@
88
95
  "stream-events": "^1.0.5",
89
96
  "teeny-request": "^10.0.0",
90
97
  "through2": "^4.0.2",
91
- "@babel/traverse": "7.27.7",
92
- "@babel/core": "7.27.7",
93
- "@babel/helpers": "7.27.6",
94
98
  "uuid": "^11.1.0"
95
99
  },
96
100
  "devDependencies": {
101
+ "@grpc/reflection": "^1.0.4",
97
102
  "@opentelemetry/sdk-trace-base": "^2.0.0",
98
103
  "@opentelemetry/sdk-trace-node": "^2.0.0",
104
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.57.0",
99
105
  "@types/concat-stream": "^2.0.3",
100
106
  "@types/extend": "^3.0.4",
101
107
  "@types/is": "^0.0.25",
@@ -104,10 +110,12 @@
104
110
  "@types/mocha": "^10.0.10",
105
111
  "@types/mv": "^2.1.4",
106
112
  "@types/ncp": "^2.0.8",
113
+ "@types/node": "^25.5.0",
107
114
  "@types/proxyquire": "^1.3.31",
108
115
  "@types/request": "^2.48.12",
109
116
  "@types/sinon": "^21.0.0",
110
117
  "@types/through2": "^2.0.41",
118
+ "@types/yargs": "^17.0.35",
111
119
  "binary-search-bounds": "^2.0.5",
112
120
  "c8": "^10.1.3",
113
121
  "codecov": "^3.8.3",
@@ -115,12 +123,14 @@
115
123
  "dedent": "^1.5.3",
116
124
  "execa": "^5.0.0",
117
125
  "gapic-tools": "^1.0.1",
126
+ "grpc-health-check": "^2.1.0",
118
127
  "gts": "^6.0.2",
119
128
  "jsdoc": "^4.0.4",
120
129
  "jsdoc-fresh": "^5.0.0",
121
130
  "jsdoc-region-tag": "^4.0.0",
122
131
  "linkinator": "^6.1.2",
123
132
  "lodash.random": "^3.2.0",
133
+ "long": "^5.3.2",
124
134
  "mocha": "^11.1.0",
125
135
  "mv": "^2.1.1",
126
136
  "ncp": "^2.0.0",
@@ -128,11 +138,22 @@
128
138
  "p-limit": "^3.0.1",
129
139
  "path-to-regexp": "^8.2.0",
130
140
  "proxyquire": "^2.1.3",
131
- "sinon": "^21.0.0",
141
+ "sinon": "21.0.3",
132
142
  "stats-lite": "^2.2.0",
133
143
  "time-span": "4.0.0",
134
144
  "tmp": "^0.2.3",
135
145
  "typescript": "^5.8.2",
136
146
  "yargs": "^17.7.2"
137
- }
138
- }
147
+ },
148
+ "overrides": {
149
+ "gcp-metadata": "^7.0.1",
150
+ "@sinonjs/fake-timers": "15.2.1"
151
+ },
152
+ "pnpm": {
153
+ "overrides": {
154
+ "gcp-metadata": "^7.0.1",
155
+ "@sinonjs/fake-timers": "15.2.1"
156
+ }
157
+ },
158
+ "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/spanner"
159
+ }