@google-cloud/spanner 5.16.2 → 5.16.3
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 +14 -0
- package/build/src/codec.js +2 -1
- package/build/src/database.d.ts +1 -1
- package/build/src/database.js +2 -2
- package/build/src/index.d.ts +3 -3
- package/build/src/index.js +7 -7
- package/build/src/instance.d.ts +3 -3
- package/build/src/instance.js +6 -5
- package/build/src/partial-result-stream.js +3 -0
- package/build/src/session-pool.d.ts +4 -4
- package/build/src/session-pool.js +6 -6
- package/build/src/transaction.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/nodejs-spanner?activeTab=versions
|
|
6
6
|
|
|
7
|
+
### [5.16.3](https://github.com/googleapis/nodejs-spanner/compare/v5.16.3...v5.16.3) (2022-01-21)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Miscellaneous Chores
|
|
11
|
+
|
|
12
|
+
* Release-As: 5.16.3 ([#1556](https://github.com/googleapis/nodejs-spanner/issues/1556)) ([31f5fbc](https://github.com/googleapis/nodejs-spanner/commit/31f5fbc6d890fd7296497d6992a7d186ea786476))
|
|
13
|
+
|
|
14
|
+
### [5.16.3](https://github.com/googleapis/nodejs-spanner/compare/v5.16.2...v5.16.3) (2022-01-19)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* for merging when array/struct chunks contain null ([#1541](https://github.com/googleapis/nodejs-spanner/issues/1541)) ([72871fc](https://github.com/googleapis/nodejs-spanner/commit/72871fca5b67aec3af633484ff70a73be55372be))
|
|
20
|
+
|
|
7
21
|
### [5.16.2](https://github.com/googleapis/nodejs-spanner/compare/v5.16.1...v5.16.2) (2022-01-17)
|
|
8
22
|
|
|
9
23
|
|
package/build/src/codec.js
CHANGED
|
@@ -22,6 +22,7 @@ const arrify = require("arrify");
|
|
|
22
22
|
const big_js_1 = require("big.js");
|
|
23
23
|
const is = require("is");
|
|
24
24
|
const protos_1 = require("../protos/protos");
|
|
25
|
+
const google_gax_1 = require("google-gax");
|
|
25
26
|
/**
|
|
26
27
|
* Date-like object used to represent Cloud Spanner Dates. DATE types represent
|
|
27
28
|
* a logical calendar date, independent of time zone. DATE values do not
|
|
@@ -117,7 +118,7 @@ class Int extends WrappedNumber {
|
|
|
117
118
|
valueOf() {
|
|
118
119
|
const num = Number(this.value);
|
|
119
120
|
if (num > Number.MAX_SAFE_INTEGER) {
|
|
120
|
-
throw new
|
|
121
|
+
throw new google_gax_1.GoogleError(`Integer ${this.value} is out of bounds.`);
|
|
121
122
|
}
|
|
122
123
|
return num;
|
|
123
124
|
}
|
package/build/src/database.d.ts
CHANGED
|
@@ -1547,7 +1547,7 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
1547
1547
|
/**
|
|
1548
1548
|
* Get a reference to a Table object.
|
|
1549
1549
|
*
|
|
1550
|
-
* @throws {
|
|
1550
|
+
* @throws {GoogleError} If a name is not provided.
|
|
1551
1551
|
*
|
|
1552
1552
|
* @param {string} name The name of the table.
|
|
1553
1553
|
* @return {Table} A Table object.
|
package/build/src/database.js
CHANGED
|
@@ -1048,7 +1048,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
1048
1048
|
/**
|
|
1049
1049
|
* Get a reference to a Table object.
|
|
1050
1050
|
*
|
|
1051
|
-
* @throws {
|
|
1051
|
+
* @throws {GoogleError} If a name is not provided.
|
|
1052
1052
|
*
|
|
1053
1053
|
* @param {string} name The name of the table.
|
|
1054
1054
|
* @return {Table} A Table object.
|
|
@@ -1066,7 +1066,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
1066
1066
|
*/
|
|
1067
1067
|
table(name) {
|
|
1068
1068
|
if (!name) {
|
|
1069
|
-
throw new
|
|
1069
|
+
throw new google_gax_1.GoogleError('A name is required to access a Table object.');
|
|
1070
1070
|
}
|
|
1071
1071
|
return new table_1.Table(this, name);
|
|
1072
1072
|
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -199,8 +199,8 @@ declare class Spanner extends GrpcService {
|
|
|
199
199
|
* @see {@link v1.InstanceAdminClient#createInstance}
|
|
200
200
|
* @see [CreateInstace API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance)
|
|
201
201
|
*
|
|
202
|
-
* @throws {
|
|
203
|
-
* @throws {
|
|
202
|
+
* @throws {GoogleError} If a name is not provided.
|
|
203
|
+
* @throws {GoogleError} If a configuration object is not provided.
|
|
204
204
|
*
|
|
205
205
|
* @param {string} name The name of the instance to be created.
|
|
206
206
|
* @param {CreateInstanceRequest} config Configuration object.
|
|
@@ -556,7 +556,7 @@ declare class Spanner extends GrpcService {
|
|
|
556
556
|
/**
|
|
557
557
|
* Get a reference to an Instance object.
|
|
558
558
|
*
|
|
559
|
-
* @throws {
|
|
559
|
+
* @throws {GoogleError} If a name is not provided.
|
|
560
560
|
*
|
|
561
561
|
* @param {string} name The name of the instance.
|
|
562
562
|
* @returns {Instance} An Instance object.
|
package/build/src/index.js
CHANGED
|
@@ -156,14 +156,14 @@ class Spanner extends service_1.GrpcService {
|
|
|
156
156
|
if (endpointWithPort) {
|
|
157
157
|
if (endpointWithPort.startsWith('http:') ||
|
|
158
158
|
endpointWithPort.startsWith('https:')) {
|
|
159
|
-
throw new
|
|
159
|
+
throw new google_gax_1.GoogleError('SPANNER_EMULATOR_HOST must not start with a protocol specification (http/https)');
|
|
160
160
|
}
|
|
161
161
|
const index = endpointWithPort.indexOf(':');
|
|
162
162
|
if (index > -1) {
|
|
163
163
|
const portName = endpointWithPort.substring(index + 1);
|
|
164
164
|
const port = +portName;
|
|
165
165
|
if (!port || port < 1 || port > 65535) {
|
|
166
|
-
throw new
|
|
166
|
+
throw new google_gax_1.GoogleError(`Invalid port number: ${portName}`);
|
|
167
167
|
}
|
|
168
168
|
return {
|
|
169
169
|
endpoint: endpointWithPort.substring(0, index),
|
|
@@ -187,10 +187,10 @@ class Spanner extends service_1.GrpcService {
|
|
|
187
187
|
}
|
|
188
188
|
createInstance(name, config, callback) {
|
|
189
189
|
if (!name) {
|
|
190
|
-
throw new
|
|
190
|
+
throw new google_gax_1.GoogleError('A name is required to create an instance.');
|
|
191
191
|
}
|
|
192
192
|
if (!config) {
|
|
193
|
-
throw new
|
|
193
|
+
throw new google_gax_1.GoogleError(['A configuration object is required to create an instance.'].join(''));
|
|
194
194
|
}
|
|
195
195
|
const formattedName = instance_1.Instance.formatName_(this.projectId, name);
|
|
196
196
|
const displayName = config.displayName || formattedName.split('/').pop();
|
|
@@ -205,7 +205,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
205
205
|
}, config),
|
|
206
206
|
};
|
|
207
207
|
if (reqOpts.instance.nodeCount && reqOpts.instance.processingUnits) {
|
|
208
|
-
throw new
|
|
208
|
+
throw new google_gax_1.GoogleError(['Only one of nodeCount or processingUnits can be specified.'].join(''));
|
|
209
209
|
}
|
|
210
210
|
if (!reqOpts.instance.nodeCount && !reqOpts.instance.processingUnits) {
|
|
211
211
|
// If neither nodes nor processingUnits are specified, default to a
|
|
@@ -450,7 +450,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
450
450
|
/**
|
|
451
451
|
* Get a reference to an Instance object.
|
|
452
452
|
*
|
|
453
|
-
* @throws {
|
|
453
|
+
* @throws {GoogleError} If a name is not provided.
|
|
454
454
|
*
|
|
455
455
|
* @param {string} name The name of the instance.
|
|
456
456
|
* @returns {Instance} An Instance object.
|
|
@@ -464,7 +464,7 @@ class Spanner extends service_1.GrpcService {
|
|
|
464
464
|
*/
|
|
465
465
|
instance(name) {
|
|
466
466
|
if (!name) {
|
|
467
|
-
throw new
|
|
467
|
+
throw new google_gax_1.GoogleError('A name is required to access an Instance object.');
|
|
468
468
|
}
|
|
469
469
|
const key = name.split('/').pop();
|
|
470
470
|
if (!this.instances_.has(key)) {
|
package/build/src/instance.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ declare class Instance extends common.GrpcServiceObject {
|
|
|
105
105
|
/**
|
|
106
106
|
* Get a reference to a Backup object.
|
|
107
107
|
*
|
|
108
|
-
* @throws {
|
|
108
|
+
* @throws {GoogleError} If any parameter is not provided.
|
|
109
109
|
*
|
|
110
110
|
* @param {string} backupId The name of the backup.
|
|
111
111
|
* @return {Backup} A Backup object.
|
|
@@ -317,7 +317,7 @@ declare class Instance extends common.GrpcServiceObject {
|
|
|
317
317
|
* @see {@link v1.DatabaseAdminClient#createDatabase}
|
|
318
318
|
* @see [CreateDatabase API Documentation](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.admin.database.v1#google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase)
|
|
319
319
|
*
|
|
320
|
-
* @throws {
|
|
320
|
+
* @throws {GoogleError} If a name is not provided.
|
|
321
321
|
*
|
|
322
322
|
* @param {name} name The name of the database to create.
|
|
323
323
|
* @param {CreateDatabaseRequest} [options] Configuration object.
|
|
@@ -379,7 +379,7 @@ declare class Instance extends common.GrpcServiceObject {
|
|
|
379
379
|
/**
|
|
380
380
|
* Get a reference to a Database object.
|
|
381
381
|
*
|
|
382
|
-
* @throws {
|
|
382
|
+
* @throws {GoogleError} If a name is not provided.
|
|
383
383
|
*
|
|
384
384
|
* @param {string} name The name of the instance.
|
|
385
385
|
* @param {SessionPoolOptions|SessionPoolCtor} [poolOptions] Session pool
|
package/build/src/instance.js
CHANGED
|
@@ -24,6 +24,7 @@ const extend = require("extend");
|
|
|
24
24
|
const snakeCase = require("lodash.snakecase");
|
|
25
25
|
const database_1 = require("./database");
|
|
26
26
|
const common_1 = require("./common");
|
|
27
|
+
const google_gax_1 = require("google-gax");
|
|
27
28
|
const backup_1 = require("./backup");
|
|
28
29
|
/**
|
|
29
30
|
* The {@link Instance} class represents a [Cloud Spanner
|
|
@@ -119,7 +120,7 @@ class Instance extends common.GrpcServiceObject {
|
|
|
119
120
|
/**
|
|
120
121
|
* Get a reference to a Backup object.
|
|
121
122
|
*
|
|
122
|
-
* @throws {
|
|
123
|
+
* @throws {GoogleError} If any parameter is not provided.
|
|
123
124
|
*
|
|
124
125
|
* @param {string} backupId The name of the backup.
|
|
125
126
|
* @return {Backup} A Backup object.
|
|
@@ -134,7 +135,7 @@ class Instance extends common.GrpcServiceObject {
|
|
|
134
135
|
*/
|
|
135
136
|
backup(backupId) {
|
|
136
137
|
if (!backupId) {
|
|
137
|
-
throw new
|
|
138
|
+
throw new google_gax_1.GoogleError('A backup ID is required to create a Backup.');
|
|
138
139
|
}
|
|
139
140
|
return new backup_1.Backup(this, backupId);
|
|
140
141
|
}
|
|
@@ -385,7 +386,7 @@ class Instance extends common.GrpcServiceObject {
|
|
|
385
386
|
}
|
|
386
387
|
createDatabase(name, optionsOrCallback, cb) {
|
|
387
388
|
if (!name) {
|
|
388
|
-
throw new
|
|
389
|
+
throw new google_gax_1.GoogleError('A name is required to create a database.');
|
|
389
390
|
}
|
|
390
391
|
const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb;
|
|
391
392
|
const options = typeof optionsOrCallback === 'object'
|
|
@@ -422,7 +423,7 @@ class Instance extends common.GrpcServiceObject {
|
|
|
422
423
|
/**
|
|
423
424
|
* Get a reference to a Database object.
|
|
424
425
|
*
|
|
425
|
-
* @throws {
|
|
426
|
+
* @throws {GoogleError} If a name is not provided.
|
|
426
427
|
*
|
|
427
428
|
* @param {string} name The name of the instance.
|
|
428
429
|
* @param {SessionPoolOptions|SessionPoolCtor} [poolOptions] Session pool
|
|
@@ -444,7 +445,7 @@ class Instance extends common.GrpcServiceObject {
|
|
|
444
445
|
*/
|
|
445
446
|
database(name, poolOptions, queryOptions) {
|
|
446
447
|
if (!name) {
|
|
447
|
-
throw new
|
|
448
|
+
throw new google_gax_1.GoogleError('A name is required to access a Database object.');
|
|
448
449
|
}
|
|
449
450
|
// Only add an additional key for SessionPoolOptions and QueryOptions if an
|
|
450
451
|
// options object with at least one value was passed in.
|
|
@@ -225,6 +225,9 @@ class PartialResultStream extends stream_1.Transform {
|
|
|
225
225
|
type.code === 'ARRAY' ||
|
|
226
226
|
type.code === protos_1.google.spanner.v1.TypeCode.STRUCT ||
|
|
227
227
|
type.code === 'STRUCT') {
|
|
228
|
+
if (head === null || tail === null) {
|
|
229
|
+
return [head, tail];
|
|
230
|
+
}
|
|
228
231
|
return [PartialResultStream.mergeLists(type, head, tail)];
|
|
229
232
|
}
|
|
230
233
|
if (is.string(head) && is.string(tail)) {
|
|
@@ -20,7 +20,7 @@ import { Database } from './database';
|
|
|
20
20
|
import { Session, types } from './session';
|
|
21
21
|
import { Transaction } from './transaction';
|
|
22
22
|
import { NormalCallback } from './common';
|
|
23
|
-
import { grpc } from 'google-gax';
|
|
23
|
+
import { GoogleError, grpc } from 'google-gax';
|
|
24
24
|
import trace = require('stack-trace');
|
|
25
25
|
/**
|
|
26
26
|
* @callback SessionPoolCloseCallback
|
|
@@ -142,7 +142,7 @@ export interface SessionPoolOptions {
|
|
|
142
142
|
*
|
|
143
143
|
* @private
|
|
144
144
|
*/
|
|
145
|
-
export declare class ReleaseError extends
|
|
145
|
+
export declare class ReleaseError extends GoogleError {
|
|
146
146
|
resource: unknown;
|
|
147
147
|
constructor(resource: unknown);
|
|
148
148
|
}
|
|
@@ -151,14 +151,14 @@ export declare class ReleaseError extends Error {
|
|
|
151
151
|
*
|
|
152
152
|
* @private
|
|
153
153
|
*/
|
|
154
|
-
export declare class SessionLeakError extends
|
|
154
|
+
export declare class SessionLeakError extends GoogleError {
|
|
155
155
|
messages: string[];
|
|
156
156
|
constructor(leaks: string[]);
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* Error to be thrown when the session pool is exhausted.
|
|
160
160
|
*/
|
|
161
|
-
export declare class SessionPoolExhaustedError extends
|
|
161
|
+
export declare class SessionPoolExhaustedError extends GoogleError {
|
|
162
162
|
messages: string[];
|
|
163
163
|
constructor(leaks: string[]);
|
|
164
164
|
}
|
|
@@ -39,7 +39,7 @@ const DEFAULTS = {
|
|
|
39
39
|
*
|
|
40
40
|
* @private
|
|
41
41
|
*/
|
|
42
|
-
class ReleaseError extends
|
|
42
|
+
class ReleaseError extends google_gax_1.GoogleError {
|
|
43
43
|
constructor(resource) {
|
|
44
44
|
super('Unable to release unknown resource.');
|
|
45
45
|
this.resource = resource;
|
|
@@ -51,7 +51,7 @@ exports.ReleaseError = ReleaseError;
|
|
|
51
51
|
*
|
|
52
52
|
* @private
|
|
53
53
|
*/
|
|
54
|
-
class SessionLeakError extends
|
|
54
|
+
class SessionLeakError extends google_gax_1.GoogleError {
|
|
55
55
|
constructor(leaks) {
|
|
56
56
|
super(`${leaks.length} session leak(s) detected.`);
|
|
57
57
|
// Restore error name that was overwritten by the super constructor call.
|
|
@@ -63,7 +63,7 @@ exports.SessionLeakError = SessionLeakError;
|
|
|
63
63
|
/**
|
|
64
64
|
* Error to be thrown when the session pool is exhausted.
|
|
65
65
|
*/
|
|
66
|
-
class SessionPoolExhaustedError extends
|
|
66
|
+
class SessionPoolExhaustedError extends google_gax_1.GoogleError {
|
|
67
67
|
constructor(leaks) {
|
|
68
68
|
super("No resources available." /* Exhausted */);
|
|
69
69
|
// Restore error name that was overwritten by the super constructor call.
|
|
@@ -435,7 +435,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
435
435
|
*/
|
|
436
436
|
async _acquire(type) {
|
|
437
437
|
if (!this.isOpen) {
|
|
438
|
-
throw new
|
|
438
|
+
throw new google_gax_1.GoogleError("Database is closed." /* Closed */);
|
|
439
439
|
}
|
|
440
440
|
// Get the stacktrace of the caller before we call any async methods, as calling an async method will break the stacktrace.
|
|
441
441
|
const frames = trace.get();
|
|
@@ -446,7 +446,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
446
446
|
const getSession = async () => {
|
|
447
447
|
const elapsed = Date.now() - startTime;
|
|
448
448
|
if (elapsed >= timeout) {
|
|
449
|
-
throw new
|
|
449
|
+
throw new google_gax_1.GoogleError("Timeout occurred while acquiring session." /* Timeout */);
|
|
450
450
|
}
|
|
451
451
|
const session = await this._getSession(type, startTime);
|
|
452
452
|
if (this._isValidSession(session)) {
|
|
@@ -706,7 +706,7 @@ class SessionPool extends events_1.EventEmitter {
|
|
|
706
706
|
const availableEvent = type + '-available';
|
|
707
707
|
const promises = [
|
|
708
708
|
this._onClose.then(() => {
|
|
709
|
-
throw new
|
|
709
|
+
throw new google_gax_1.GoogleError("Database is closed." /* Closed */);
|
|
710
710
|
}),
|
|
711
711
|
new Promise(resolve => {
|
|
712
712
|
this.once(availableEvent, resolve);
|
package/build/src/transaction.js
CHANGED
|
@@ -1312,7 +1312,7 @@ class Transaction extends Dml {
|
|
|
1312
1312
|
const keys = Object.keys(row);
|
|
1313
1313
|
const missingColumns = columns.filter(column => !keys.includes(column));
|
|
1314
1314
|
if (missingColumns.length > 0) {
|
|
1315
|
-
throw new
|
|
1315
|
+
throw new google_gax_1.GoogleError([
|
|
1316
1316
|
`Row at index ${index} does not contain the correct number of columns.`,
|
|
1317
1317
|
`Missing columns: ${JSON.stringify(missingColumns)}`,
|
|
1318
1318
|
].join('\n\n'));
|
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": "5.16.
|
|
4
|
+
"version": "5.16.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Google Inc.",
|
|
7
7
|
"engines": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"events-intercept": "^2.0.0",
|
|
63
63
|
"extend": "^3.0.2",
|
|
64
64
|
"google-auth-library": "^7.0.0",
|
|
65
|
-
"google-gax": "^2.
|
|
65
|
+
"google-gax": "^2.29.3",
|
|
66
66
|
"grpc-gcp": "^0.3.2",
|
|
67
67
|
"is": "^3.2.1",
|
|
68
68
|
"lodash.snakecase": "^4.1.1",
|