@google-cloud/spanner 8.13.0 → 9.0.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.
@@ -212,28 +212,10 @@ class Snapshot extends events_1.EventEmitter {
212
212
  },
213
213
  },
214
214
  };
215
- this.request = (config, callback) => {
216
- let gaxOpts;
217
- if (!config.gaxOpts || Object.keys(config.gaxOpts).length === 0) {
218
- gaxOpts = this._bindGaxOpts;
219
- }
220
- else {
221
- gaxOpts = injectGaxOpt(config.gaxOpts, 'affinityKey', this._affinityKey);
222
- }
223
- config = Object.assign({}, config, { gaxOpts });
224
- return session.request(config, callback);
225
- };
226
- this.requestStream = (config) => {
227
- let gaxOpts;
228
- if (!config.gaxOpts || Object.keys(config.gaxOpts).length === 0) {
229
- gaxOpts = this._bindGaxOpts;
230
- }
231
- else {
232
- gaxOpts = injectGaxOpt(config.gaxOpts, 'affinityKey', this._affinityKey);
233
- }
234
- config = Object.assign({}, config, { gaxOpts });
235
- return session.requestStream(config);
236
- };
215
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
216
+ this.request = (config, callback) => session.request(this._applyAffinityGaxOpts(config), callback);
217
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
+ this.requestStream = (config) => session.requestStream(this._applyAffinityGaxOpts(config));
237
219
  }
238
220
  else {
239
221
  this.request = session.request.bind(session);
@@ -253,6 +235,34 @@ class Snapshot extends events_1.EventEmitter {
253
235
  this._latestPreCommitToken = null;
254
236
  this._mutationKey = null;
255
237
  }
238
+ /**
239
+ * Binds the multiplexed session affinity key to the gax options of an
240
+ * outgoing request, so that all requests of this transaction are routed to
241
+ * the same gRPC channel.
242
+ *
243
+ * `config` is always a request descriptor that was freshly constructed by the
244
+ * caller for this one RPC (and {@link Spanner#prepareGapicRequest_} already
245
+ * modifies `config.headers` in place), so the affinity key is assigned
246
+ * directly instead of allocating a copy of the descriptor per request.
247
+ *
248
+ * @private
249
+ *
250
+ * @param {object} config The request configuration.
251
+ * @returns {object} The same request configuration.
252
+ */
253
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
254
+ _applyAffinityGaxOpts(config) {
255
+ if (!config) {
256
+ return config;
257
+ }
258
+ if (!config.gaxOpts || Object.keys(config.gaxOpts).length === 0) {
259
+ config.gaxOpts = this._bindGaxOpts;
260
+ }
261
+ else {
262
+ config.gaxOpts = injectGaxOpt(config.gaxOpts, 'affinityKey', this._affinityKey);
263
+ }
264
+ return config;
265
+ }
256
266
  _updatePrecommitToken(resp) {
257
267
  if (this._latestPreCommitToken === null ||
258
268
  this._latestPreCommitToken === undefined ||
@@ -1453,6 +1463,7 @@ class Snapshot extends events_1.EventEmitter {
1453
1463
  * @returns {object}
1454
1464
  */
1455
1465
  static encodeParams(request) {
1466
+ const isUuidUntyped = codec_1.codec.isUuidUntypedEnv();
1456
1467
  const typeMap = request.types || {};
1457
1468
  const params = { fields: request.params?.fields || {} };
1458
1469
  const paramTypes = request.paramTypes || {};
@@ -1461,7 +1472,7 @@ class Snapshot extends events_1.EventEmitter {
1461
1472
  Object.keys(request.params).forEach(param => {
1462
1473
  const value = request.params[param];
1463
1474
  if (!typeMap[param]) {
1464
- typeMap[param] = codec_1.codec.getType(value);
1475
+ typeMap[param] = codec_1.codec.getType(value, isUuidUntyped);
1465
1476
  }
1466
1477
  fields[param] = codec_1.codec.encode(value);
1467
1478
  });
@@ -1470,7 +1481,7 @@ class Snapshot extends events_1.EventEmitter {
1470
1481
  if (!(0, helper_1.isEmpty)(typeMap)) {
1471
1482
  Object.keys(typeMap).forEach(param => {
1472
1483
  const type = typeMap[param];
1473
- if (process.env['SPANNER_ENABLE_UUID_AS_UNTYPED'] === 'true') {
1484
+ if (isUuidUntyped) {
1474
1485
  const typeObject = codec_1.codec.createTypeObject(type);
1475
1486
  if ((type.child &&
1476
1487
  typeObject.code === 'ARRAY' &&
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@google-cloud/spanner",
3
3
  "description": "Cloud Spanner Client Library for Node.js",
4
- "version": "8.13.0",
4
+ "version": "9.0.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Google Inc.",
7
7
  "engines": {
8
- "node": ">=18"
8
+ "node": ">=22"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
@@ -54,42 +54,42 @@
54
54
  "@babel/core": "7.27.7",
55
55
  "@babel/helpers": "7.27.6",
56
56
  "@babel/traverse": "7.27.7",
57
- "@google-cloud/common": "^6.0.0",
58
- "@google-cloud/monitoring": "^5.0.0",
59
- "@google-cloud/opentelemetry-resource-util": "^2.4.0",
60
- "@google-cloud/precise-date": "^5.0.0",
61
- "@google-cloud/promisify": "^5.0.0",
62
- "@google-cloud/spanner-api": "^0.2.0",
57
+ "@google-cloud/common": "^8.0.0",
58
+ "@google-cloud/monitoring": "^6.0.0",
59
+ "@google-cloud/precise-date": "^6.0.0",
60
+ "@google-cloud/promisify": "^6.0.0",
61
+ "@google-cloud/spanner-api": "^0.4.0",
63
62
  "@grpc/grpc-js": "^1.13.2",
64
63
  "@grpc/proto-loader": "^0.8.0",
65
64
  "@opentelemetry/api": "^1.9.0",
66
65
  "@opentelemetry/context-async-hooks": "^2.0.0",
67
66
  "@opentelemetry/core": "^2.0.0",
68
- "@opentelemetry/resources": "^1.8.0",
69
- "@opentelemetry/sdk-metrics": "^1.30.1",
67
+ "@opentelemetry/resource-detector-gcp": "^0.57.0",
68
+ "@opentelemetry/resources": "^2.11.0",
69
+ "@opentelemetry/sdk-metrics": "^2.11.0",
70
70
  "@opentelemetry/semantic-conventions": "^1.30.0",
71
71
  "@types/big.js": "^6.2.2",
72
72
  "@types/stack-trace": "^0.0.33",
73
73
  "big.js": "^7.0.0",
74
74
  "duplexify": "^4.1.3",
75
75
  "extend": "^3.0.2",
76
- "google-auth-library": "^10.0.0-rc.1",
77
- "google-gax": "5.0.6",
76
+ "google-auth-library": "^11.0.0",
77
+ "google-gax": "^6.0.0",
78
78
  "grpc-gcp": "^1.0.1",
79
79
  "lodash.snakecase": "^4.1.1",
80
80
  "p-queue": "^6.0.2",
81
81
  "protobufjs": "^7.4.0",
82
- "retry-request": "^8.0.0",
82
+ "retry-request": "^9.0.0",
83
83
  "stack-trace": "0.0.10",
84
84
  "stream-events": "^1.0.5",
85
- "teeny-request": "^10.0.0",
85
+ "teeny-request": "^11.0.0",
86
86
  "through2": "^4.0.2"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@grpc/reflection": "^1.0.4",
90
- "@opentelemetry/sdk-trace-base": "^2.0.0",
90
+ "@opentelemetry/sdk-trace-base": "^2.11.0",
91
91
  "@opentelemetry/sdk-trace-node": "^2.0.0",
92
- "@opentelemetry/exporter-trace-otlp-grpc": "^0.57.0",
92
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.222.0",
93
93
  "@types/concat-stream": "^2.0.3",
94
94
  "@types/extend": "^3.0.4",
95
95
  "@types/is": "^0.0.25",
@@ -97,7 +97,7 @@
97
97
  "@types/mocha": "^10.0.10",
98
98
  "@types/mv": "^2.1.4",
99
99
  "@types/ncp": "^2.0.8",
100
- "@types/node": "^25.5.0",
100
+ "@types/node": "^22.18.12",
101
101
  "@types/proxyquire": "^1.3.31",
102
102
  "@types/request": "^2.48.12",
103
103
  "@types/sinon": "^21.0.0",
@@ -109,12 +109,12 @@
109
109
  "concat-stream": "^2.0.0",
110
110
  "dedent": "^1.5.3",
111
111
  "execa": "^5.0.0",
112
- "gapic-tools": "^1.0.1",
112
+ "gapic-tools": "^2.0.0",
113
113
  "grpc-health-check": "^2.1.0",
114
114
  "gts": "^6.0.2",
115
115
  "jsdoc": "^4.0.4",
116
- "jsdoc-fresh": "^5.0.0",
117
- "jsdoc-region-tag": "^4.0.0",
116
+ "jsdoc-fresh": "^6.0.0",
117
+ "jsdoc-region-tag": "^5.0.0",
118
118
  "lodash.random": "^3.2.0",
119
119
  "long": "^5.3.2",
120
120
  "mocha": "^11.1.0",
@@ -132,17 +132,9 @@
132
132
  "yargs": "^17.7.2"
133
133
  },
134
134
  "overrides": {
135
- "gcp-metadata": "^7.0.1",
136
135
  "@sinonjs/fake-timers": "15.2.1",
137
136
  "brace-expansion": "5.0.7",
138
137
  "@eslint-community/eslint-utils": "<4.10.0"
139
138
  },
140
- "pnpm": {
141
- "overrides": {
142
- "gcp-metadata": "^7.0.1",
143
- "@sinonjs/fake-timers": "15.2.1",
144
- "@eslint-community/eslint-utils": "<4.10.0"
145
- }
146
- },
147
139
  "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/spanner"
148
140
  }