@google-cloud/spanner 8.5.0 → 8.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.
@@ -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
  },
@@ -191,7 +191,7 @@ declare class Database extends common.GrpcServiceObject {
191
191
  private _traceConfig;
192
192
  private _nthRequest;
193
193
  _clientId: number;
194
- constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
194
+ constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions, databaseRole?: string | null);
195
195
  _nextNthRequest(): number;
196
196
  /**
197
197
  * @typedef {array} SetDatabaseMetadataResponse
@@ -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
  *
@@ -71,7 +71,7 @@ class Database extends common.GrpcServiceObject {
71
71
  _traceConfig;
72
72
  _nthRequest;
73
73
  _clientId;
74
- constructor(instance, name, poolOptions, queryOptions) {
74
+ constructor(instance, name, poolOptions, queryOptions, databaseRole) {
75
75
  const methods = {
76
76
  /**
77
77
  * Create a database.
@@ -159,12 +159,11 @@ class Database extends common.GrpcServiceObject {
159
159
  }
160
160
  },
161
161
  });
162
- if (typeof poolOptions === 'object') {
163
- this.databaseRole = poolOptions.databaseRole || null;
164
- this.labels = poolOptions.labels || null;
165
- }
166
162
  this.formattedName_ = formattedName_;
167
163
  this.instance = instance;
164
+ const poolOpts = typeof poolOptions === 'object' ? poolOptions : null;
165
+ this.databaseRole = databaseRole || poolOpts?.databaseRole || null;
166
+ this.labels = this._getSpanner().sessionLabels || poolOpts?.labels || null;
168
167
  this._observabilityOptions = instance._observabilityOptions;
169
168
  this._traceConfig = {
170
169
  opts: this._observabilityOptions,
@@ -230,7 +229,7 @@ class Database extends common.GrpcServiceObject {
230
229
  options = { count: options };
231
230
  }
232
231
  const count = options.count;
233
- const labels = options.labels || {};
232
+ const labels = options.labels || this.labels || null;
234
233
  const databaseRole = options.databaseRole || this.databaseRole || null;
235
234
  const reqOpts = {
236
235
  database: this.formattedName_,
@@ -67,6 +67,9 @@ export interface SpannerOptions extends GrpcClientOptions {
67
67
  observabilityOptions?: ObservabilityOptions;
68
68
  disableBuiltInMetrics?: boolean;
69
69
  interceptors?: any[];
70
+ sessionLabels?: {
71
+ [key: string]: string;
72
+ };
70
73
  /**
71
74
  * The Trusted Cloud Domain (TPC) DNS of the service used to make requests.
72
75
  * Defaults to `googleapis.com`.
@@ -186,6 +189,9 @@ declare class Spanner extends GrpcService {
186
189
  directedReadOptions: google.spanner.v1.IDirectedReadOptions | null;
187
190
  defaultTransactionOptions: RunTransactionOptions;
188
191
  _observabilityOptions: ObservabilityOptions | undefined;
192
+ sessionLabels: {
193
+ [key: string]: string;
194
+ } | null;
189
195
  private _universeDomain;
190
196
  private _isInSecureCredentials;
191
197
  private static _isAFEServerTimingEnabled;
@@ -160,6 +160,7 @@ class Spanner extends service_1.GrpcService {
160
160
  directedReadOptions;
161
161
  defaultTransactionOptions;
162
162
  _observabilityOptions;
163
+ sessionLabels;
163
164
  _universeDomain;
164
165
  _isInSecureCredentials;
165
166
  static _isAFEServerTimingEnabled;
@@ -301,6 +302,7 @@ class Spanner extends service_1.GrpcService {
301
302
  this.directedReadOptions = directedReadOptions;
302
303
  this.defaultTransactionOptions = defaultTransactionOptions;
303
304
  this._observabilityOptions = options.observabilityOptions;
305
+ this.sessionLabels = options.sessionLabels || null;
304
306
  this.commonHeaders_ = (0, common_1.getCommonHeaders)(this.projectFormattedName_, this._observabilityOptions?.enableEndToEndTracing);
305
307
  (0, instrument_1.ensureInitialContextManagerSet)();
306
308
  this._nthClientId = (0, request_id_header_1.nextSpannerClientId)();
@@ -439,7 +439,7 @@ declare class Instance extends common.GrpcServiceObject {
439
439
  * const database = instance.database('my-database');
440
440
  * ```
441
441
  */
442
- database(name: string, poolOptions?: SessionPoolOptions | SessionPoolConstructor, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions): Database;
442
+ database(name: string, poolOptions?: SessionPoolOptions | SessionPoolConstructor, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions, databaseRole?: string | null): Database;
443
443
  /**
444
444
  * @typedef {array} DeleteInstanceResponse
445
445
  * @property {object} 0 The full API response.
@@ -504,7 +504,7 @@ class Instance extends common.GrpcServiceObject {
504
504
  * const database = instance.database('my-database');
505
505
  * ```
506
506
  */
507
- database(name, poolOptions, queryOptions) {
507
+ database(name, poolOptions, queryOptions, databaseRole) {
508
508
  if (!name) {
509
509
  throw new google_gax_1.GoogleError('A name is required to access a Database object.');
510
510
  }
@@ -519,7 +519,7 @@ class Instance extends common.GrpcServiceObject {
519
519
  }
520
520
  const key = name.split('/').pop() + optionsKey;
521
521
  if (!this.databases_.has(key)) {
522
- const db = new database_1.Database(this, name, poolOptions, queryOptions);
522
+ const db = new database_1.Database(this, name, poolOptions, queryOptions, databaseRole);
523
523
  db._observabilityOptions = this._observabilityOptions;
524
524
  const parent = this.parent;
525
525
  if (parent && parent._nthClientId) {
@@ -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
  };
@@ -93,7 +93,7 @@ class PartialResultStream extends stream_1.Transform {
93
93
  res = this._addChunk(chunk);
94
94
  }
95
95
  if (chunk.last) {
96
- this.emit('end');
96
+ this.push(null);
97
97
  return;
98
98
  }
99
99
  if (res) {
@@ -128,6 +128,9 @@ export interface SessionPoolOptions {
128
128
  fail?: boolean;
129
129
  idlesAfter?: number;
130
130
  keepAlive?: number;
131
+ /**
132
+ * @deprecated Use SpannerOptions.sessionLabels instead.
133
+ */
131
134
  labels?: {
132
135
  [label: string]: string;
133
136
  };
@@ -140,6 +143,9 @@ export interface SessionPoolOptions {
140
143
  */
141
144
  writes?: number;
142
145
  incStep?: number;
146
+ /**
147
+ * @deprecated Use Database constructor to pass databaseRole.
148
+ */
143
149
  databaseRole?: string | null;
144
150
  }
145
151
  /**
@@ -29,12 +29,10 @@ const DEFAULTS = {
29
29
  fail: false,
30
30
  idlesAfter: 10,
31
31
  keepAlive: 30,
32
- labels: {},
33
32
  max: 100,
34
33
  maxIdle: 1,
35
34
  min: 25,
36
35
  incStep: 25,
37
- databaseRole: null,
38
36
  };
39
37
  /**
40
38
  * Error to be thrown when attempting to release unknown resources.
@@ -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.5.0",
4
+ "version": "8.7.0",
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
+ }