@google-cloud/spanner 5.15.0 → 5.16.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.
- package/CHANGELOG.md +34 -0
- package/README.md +55 -53
- package/build/protos/protos.d.ts +2 -1
- package/build/protos/protos.js +7 -0
- package/build/protos/protos.json +14 -1
- package/build/src/backup.d.ts +214 -0
- package/build/src/backup.js +4 -196
- package/build/src/batch-transaction.d.ts +6 -0
- package/build/src/batch-transaction.js +6 -0
- package/build/src/codec.d.ts +4 -0
- package/build/src/codec.js +4 -0
- package/build/src/database.d.ts +1244 -22
- package/build/src/database.js +36 -1184
- package/build/src/index.d.ts +366 -17
- package/build/src/index.js +39 -312
- package/build/src/instance.d.ts +526 -0
- package/build/src/instance.js +18 -498
- package/build/src/session-pool.d.ts +5 -5
- package/build/src/session-pool.js +13 -8
- package/build/src/session.d.ts +98 -0
- package/build/src/session.js +16 -82
- package/build/src/table.d.ts +645 -0
- package/build/src/table.js +4 -623
- package/build/src/transaction.d.ts +509 -19
- package/build/src/transaction.js +60 -443
- package/build/src/v1/database_admin_client.d.ts +666 -40
- package/build/src/v1/database_admin_client.js +32 -706
- package/build/src/v1/gapic_metadata.json +1 -1
- package/build/src/v1/instance_admin_client.d.ts +357 -20
- package/build/src/v1/instance_admin_client.js +16 -377
- package/build/src/v1/spanner_client.d.ts +586 -13
- package/build/src/v1/spanner_client.js +10 -596
- package/package.json +3 -3
package/build/src/backup.js
CHANGED
|
@@ -28,10 +28,12 @@ const precise_date_1 = require("@google-cloud/precise-date");
|
|
|
28
28
|
* @class
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
|
+
* ```
|
|
31
32
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
32
33
|
* const spanner = new Spanner();
|
|
33
34
|
* const instance = spanner.instance('my-instance');
|
|
34
35
|
* const backup = instance.backup('my-backup');
|
|
36
|
+
* ```
|
|
35
37
|
*/
|
|
36
38
|
class Backup {
|
|
37
39
|
constructor(instance, name) {
|
|
@@ -43,68 +45,6 @@ class Backup {
|
|
|
43
45
|
[common_1.CLOUD_RESOURCE_HEADER]: this.instanceFormattedName_,
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {object} CreateBackupOptions
|
|
48
|
-
* @property {string} databasePath The database path.
|
|
49
|
-
* @property {string|number|google.protobuf.Timestamp|external:PreciseDate}
|
|
50
|
-
* expireTime The expire time of the backup.
|
|
51
|
-
* @property {string|number|google.protobuf.Timestamp|external:PreciseDate}
|
|
52
|
-
* versionTime Take a backup of the state of the database at this time.
|
|
53
|
-
* @property {google.spanner.admin.database.v1.ICreateBackupEncryptionConfig}
|
|
54
|
-
* encryptionConfig An encryption configuration describing the
|
|
55
|
-
* encryption type and key resources in Cloud KMS to be used to encrypt
|
|
56
|
-
* the backup.
|
|
57
|
-
* @property {object} [gaxOptions] The request configuration options,
|
|
58
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
59
|
-
* for more details.
|
|
60
|
-
*/
|
|
61
|
-
/**
|
|
62
|
-
* @typedef {array} CreateBackupResponse
|
|
63
|
-
* @property {Backup} 0 The new {@link Backup}.
|
|
64
|
-
* @property {google.longrunning.Operation} 1 An {@link Operation} object that can be used to check
|
|
65
|
-
* the status of the request.
|
|
66
|
-
* @property {object} 2 The full API response.
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* @callback CreateBackupCallback
|
|
70
|
-
* @param {?Error} err Request error, if any.
|
|
71
|
-
* @param {Backup} backup The new {@link Backup}.
|
|
72
|
-
* @param {google.longrunning.Operation} operation An {@link Operation} object that can be used to
|
|
73
|
-
* check the status of the request.
|
|
74
|
-
* @param {object} apiResponse The full API response.
|
|
75
|
-
*/
|
|
76
|
-
/**
|
|
77
|
-
* Create a backup.
|
|
78
|
-
*
|
|
79
|
-
* @method Backup#create
|
|
80
|
-
* @param {CreateBackupOptions} options Parameters for creating a backup.
|
|
81
|
-
* @param {CallOptions} [options.gaxOptions] The request configuration
|
|
82
|
-
* options, See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
83
|
-
* for more details.
|
|
84
|
-
* @param {CreateBackupCallback} [callback] Callback function.
|
|
85
|
-
* @returns {Promise<CreateBackupResponse>} When resolved, the backup
|
|
86
|
-
* operation will have started, but will not have necessarily completed.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
90
|
-
* const spanner = new Spanner();
|
|
91
|
-
* const instance = spanner.instance('my-instance');
|
|
92
|
-
* const oneDay = 1000 * 60 * 60 * 24;
|
|
93
|
-
* const expireTime = Date.now() + oneDay;
|
|
94
|
-
* const versionTime = Date.now() - oneDay;
|
|
95
|
-
* const backup = instance.backup('my-backup');
|
|
96
|
-
* const [, backupOperation] = await backup.create({
|
|
97
|
-
* databasePath: 'projects/my-project/instances/my-instance/databases/my-database',
|
|
98
|
-
* expireTime: expireTime,
|
|
99
|
-
* versionTime: versionTime,
|
|
100
|
-
* encryptionConfig: {
|
|
101
|
-
* encryptionType: 'CUSTOMER_MANAGED_ENCRYPTION',
|
|
102
|
-
* kmsKeyName: 'projects/my-project-id/my-region/keyRings/my-key-ring/cryptoKeys/my-key',
|
|
103
|
-
* },
|
|
104
|
-
* });
|
|
105
|
-
* // Await completion of the backup operation.
|
|
106
|
-
* await backupOperation.promise();
|
|
107
|
-
*/
|
|
108
48
|
create(options, callback) {
|
|
109
49
|
const gaxOpts = options.gaxOptions;
|
|
110
50
|
const reqOpts = {
|
|
@@ -137,38 +77,6 @@ class Backup {
|
|
|
137
77
|
callback(null, this, operation, resp);
|
|
138
78
|
});
|
|
139
79
|
}
|
|
140
|
-
/**
|
|
141
|
-
* @typedef {array} GetMetadataResponse
|
|
142
|
-
* @property {object} 0 The {@link Backup} metadata.
|
|
143
|
-
* @property {object} 1 The full API response.
|
|
144
|
-
*/
|
|
145
|
-
/**
|
|
146
|
-
* @callback GetMetadataCallback
|
|
147
|
-
* @param {?Error} err Request error, if any.
|
|
148
|
-
* @param {object} metadata The {@link Backup} metadata.
|
|
149
|
-
* @param {object} apiResponse The full API response.
|
|
150
|
-
*/
|
|
151
|
-
/**
|
|
152
|
-
* Retrieves backup's metadata.
|
|
153
|
-
*
|
|
154
|
-
* @see {@link #getState}
|
|
155
|
-
* @see {@link #getExpireTime}
|
|
156
|
-
*
|
|
157
|
-
* @method Backup#getMetadata
|
|
158
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
159
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
160
|
-
* for more details.
|
|
161
|
-
* @param {GetMetadataCallback} [callback] Callback function.
|
|
162
|
-
* @returns {Promise<GetMetadataResponse>}
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
166
|
-
* const spanner = new Spanner();
|
|
167
|
-
* const instance = spanner.instance('my-instance');
|
|
168
|
-
* const backup = instance.backup('my-backup');
|
|
169
|
-
* const [backupInfo] = await backup.getMetadata();
|
|
170
|
-
* console.log(`${backupInfo.name}: size=${backupInfo.sizeBytes}`);
|
|
171
|
-
*/
|
|
172
80
|
getMetadata(gaxOptionsOrCallback, cb) {
|
|
173
81
|
const callback = typeof gaxOptionsOrCallback === 'function'
|
|
174
82
|
? gaxOptionsOrCallback
|
|
@@ -192,69 +100,14 @@ class Backup {
|
|
|
192
100
|
callback(err, response);
|
|
193
101
|
});
|
|
194
102
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Retrieves the state of the backup.
|
|
197
|
-
*
|
|
198
|
-
* The backup state indicates if the backup has completed.
|
|
199
|
-
*
|
|
200
|
-
* @see {@link #getMetadata}
|
|
201
|
-
*
|
|
202
|
-
* @method Backup#getState
|
|
203
|
-
* @param {GetStateCallback} [callback] Callback function.
|
|
204
|
-
* @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.Backup.State> | undefined>}
|
|
205
|
-
* When resolved, contains the current state of the backup if it exists.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
209
|
-
* const spanner = new Spanner();
|
|
210
|
-
* const instance = spanner.instance('my-instance');
|
|
211
|
-
* const backup = instance.backup('my-backup');
|
|
212
|
-
* const state = await backup.getState();
|
|
213
|
-
* const backupCompleted = (state === 'READY');
|
|
214
|
-
*/
|
|
215
103
|
async getState() {
|
|
216
104
|
const [backupInfo] = await this.getMetadata();
|
|
217
105
|
return backupInfo.state;
|
|
218
106
|
}
|
|
219
|
-
/**
|
|
220
|
-
* Retrieves the expiry time of the backup.
|
|
221
|
-
*
|
|
222
|
-
* @see {@link #updateExpireTime}
|
|
223
|
-
* @see {@link #getMetadata}
|
|
224
|
-
*
|
|
225
|
-
* @method Backup#getExpireTime
|
|
226
|
-
* @returns {Promise<external:PreciseDate>} When resolved, contains the
|
|
227
|
-
* current expire time of the backup if it exists.
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
231
|
-
* const spanner = new Spanner();
|
|
232
|
-
* const instance = spanner.instance('my-instance');
|
|
233
|
-
* const backup = instance.backup('my-backup');
|
|
234
|
-
* const expireTime = await backup.getExpireTime();
|
|
235
|
-
* console.log(`Backup expires on ${expireTime.toISOString()}`);
|
|
236
|
-
*/
|
|
237
107
|
async getExpireTime() {
|
|
238
108
|
const [backupInfo] = await this.getMetadata();
|
|
239
109
|
return new precise_date_1.PreciseDate(backupInfo.expireTime);
|
|
240
110
|
}
|
|
241
|
-
/**
|
|
242
|
-
* Checks whether the backup exists.
|
|
243
|
-
*
|
|
244
|
-
* @see {@link #getMetadata}
|
|
245
|
-
*
|
|
246
|
-
* @method Backup#exists
|
|
247
|
-
* @returns {Promise<boolean>} When resolved, contains true if the backup
|
|
248
|
-
* exists and false if it does not exist.
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
252
|
-
* const spanner = new Spanner();
|
|
253
|
-
* const instance = spanner.instance('my-instance');
|
|
254
|
-
* const backup = instance.backup('my-backup');
|
|
255
|
-
* const alreadyExists = await backup.exists();
|
|
256
|
-
* console.log(`Does backup exist? ${alreadyExists}`);
|
|
257
|
-
*/
|
|
258
111
|
async exists() {
|
|
259
112
|
try {
|
|
260
113
|
// Attempt to read metadata to determine whether backup exists
|
|
@@ -270,36 +123,6 @@ class Backup {
|
|
|
270
123
|
throw err;
|
|
271
124
|
}
|
|
272
125
|
}
|
|
273
|
-
/**
|
|
274
|
-
* @callback UpdateExpireTimeCallback
|
|
275
|
-
* @param {?Error} err Request error, if any.
|
|
276
|
-
* @param {google.spanner.admin.database.v1.IBackup} backup The updated
|
|
277
|
-
* backup.
|
|
278
|
-
*/
|
|
279
|
-
/**
|
|
280
|
-
* Sets the expiry time of a backup.
|
|
281
|
-
*
|
|
282
|
-
* @see {@link #getExpireTime}
|
|
283
|
-
*
|
|
284
|
-
* @method Backup#updateExpireTime
|
|
285
|
-
* @param {string|number|google.protobuf.Timestamp|external:PreciseDate}
|
|
286
|
-
* expireTime The expiry time to update with.
|
|
287
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
288
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
289
|
-
* for more details.
|
|
290
|
-
* @param {UpdateExpireTimeCallback} [callback] Callback function.
|
|
291
|
-
* @returns {Promise<google.spanner.admin.database.v1.IBackup>} When resolved,
|
|
292
|
-
* the backup's expire time will have been updated.
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
296
|
-
* const spanner = new Spanner();
|
|
297
|
-
* const instance = spanner.instance('my-instance');
|
|
298
|
-
* const backup = instance.backup('my-backup');
|
|
299
|
-
* const oneDay = 1000 * 60 * 60 * 24;
|
|
300
|
-
* const newExpireTime = Spanner.timestamp(Date.now() + oneDay);
|
|
301
|
-
* await backup.updateExpireTime(newExpireTime);
|
|
302
|
-
*/
|
|
303
126
|
updateExpireTime(expireTime, gaxOptionsOrCallback, cb) {
|
|
304
127
|
const callback = typeof gaxOptionsOrCallback === 'function'
|
|
305
128
|
? gaxOptionsOrCallback
|
|
@@ -326,23 +149,6 @@ class Backup {
|
|
|
326
149
|
callback(err, response);
|
|
327
150
|
});
|
|
328
151
|
}
|
|
329
|
-
/**
|
|
330
|
-
* Deletes a backup.
|
|
331
|
-
*
|
|
332
|
-
* @method Backup#delete
|
|
333
|
-
* @param {object} [gaxOptions] Request configuration options,
|
|
334
|
-
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
335
|
-
* for more details.
|
|
336
|
-
* @param {DeleteBackupCallback} [callback] Callback function.
|
|
337
|
-
* @returns {Promise<void>} When resolved, the backup will have been deleted.
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* const {Spanner} = require('@google-cloud/spanner');
|
|
341
|
-
* const spanner = new Spanner();
|
|
342
|
-
* const instance = spanner.instance('my-instance');
|
|
343
|
-
* const backup = instance.backup('my-backup');
|
|
344
|
-
* await backup.delete();
|
|
345
|
-
*/
|
|
346
152
|
delete(gaxOptionsOrCallback, cb) {
|
|
347
153
|
const callback = typeof gaxOptionsOrCallback === 'function'
|
|
348
154
|
? gaxOptionsOrCallback
|
|
@@ -373,11 +179,13 @@ class Backup {
|
|
|
373
179
|
* @returns {string}
|
|
374
180
|
*
|
|
375
181
|
* @example
|
|
182
|
+
* ```
|
|
376
183
|
* Backup.formatName_(
|
|
377
184
|
* 'projects/grape-spaceship-123/instances/my-instance',
|
|
378
185
|
* 'my-backup'
|
|
379
186
|
* );
|
|
380
187
|
* // 'projects/grape-spaceship-123/instances/my-instance/backups/my-backup'
|
|
188
|
+
* ```
|
|
381
189
|
*/
|
|
382
190
|
static formatName_(instanceName, name) {
|
|
383
191
|
if (name.indexOf('/') > -1) {
|
|
@@ -47,6 +47,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
47
47
|
* @returns {Promise<BasicResponse>}
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
|
+
* ```
|
|
50
51
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
51
52
|
* const spanner = new Spanner();
|
|
52
53
|
*
|
|
@@ -68,6 +69,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
68
69
|
* const transaction = data[0];
|
|
69
70
|
* return transaction.close();
|
|
70
71
|
* });
|
|
72
|
+
* ```
|
|
71
73
|
*/
|
|
72
74
|
close(callback?: any): void;
|
|
73
75
|
/**
|
|
@@ -176,6 +178,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
176
178
|
* @returns {ReadableStream} A readable stream that emits rows.
|
|
177
179
|
*
|
|
178
180
|
* @example
|
|
181
|
+
* ```
|
|
179
182
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
180
183
|
* const spanner = new Spanner();
|
|
181
184
|
*
|
|
@@ -210,6 +213,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
210
213
|
* });
|
|
211
214
|
* });
|
|
212
215
|
* });
|
|
216
|
+
* ```
|
|
213
217
|
*/
|
|
214
218
|
executeStream(partition: any): import("./partial-result-stream").PartialResultStream;
|
|
215
219
|
/**
|
|
@@ -225,6 +229,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
225
229
|
* @returns {TransactionIdentifier}
|
|
226
230
|
*
|
|
227
231
|
* @example
|
|
232
|
+
* ```
|
|
228
233
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
229
234
|
* const spanner = new Spanner();
|
|
230
235
|
*
|
|
@@ -234,6 +239,7 @@ declare class BatchTransaction extends Snapshot {
|
|
|
234
239
|
* database.createBatchTransaction(function(err, transaction) {
|
|
235
240
|
* const identifier = transaction.identifier();
|
|
236
241
|
* });
|
|
242
|
+
* ```
|
|
237
243
|
*/
|
|
238
244
|
identifier(): TransactionIdentifier;
|
|
239
245
|
}
|
|
@@ -48,6 +48,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
48
48
|
* @returns {Promise<BasicResponse>}
|
|
49
49
|
*
|
|
50
50
|
* @example
|
|
51
|
+
* ```
|
|
51
52
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
52
53
|
* const spanner = new Spanner();
|
|
53
54
|
*
|
|
@@ -69,6 +70,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
69
70
|
* const transaction = data[0];
|
|
70
71
|
* return transaction.close();
|
|
71
72
|
* });
|
|
73
|
+
* ```
|
|
72
74
|
*/
|
|
73
75
|
close(callback) {
|
|
74
76
|
this.end();
|
|
@@ -244,6 +246,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
244
246
|
* @returns {ReadableStream} A readable stream that emits rows.
|
|
245
247
|
*
|
|
246
248
|
* @example
|
|
249
|
+
* ```
|
|
247
250
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
248
251
|
* const spanner = new Spanner();
|
|
249
252
|
*
|
|
@@ -278,6 +281,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
278
281
|
* });
|
|
279
282
|
* });
|
|
280
283
|
* });
|
|
284
|
+
* ```
|
|
281
285
|
*/
|
|
282
286
|
executeStream(partition) {
|
|
283
287
|
if (is.string(partition.table)) {
|
|
@@ -298,6 +302,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
298
302
|
* @returns {TransactionIdentifier}
|
|
299
303
|
*
|
|
300
304
|
* @example
|
|
305
|
+
* ```
|
|
301
306
|
* const {Spanner} = require('@google-cloud/spanner');
|
|
302
307
|
* const spanner = new Spanner();
|
|
303
308
|
*
|
|
@@ -307,6 +312,7 @@ class BatchTransaction extends transaction_1.Snapshot {
|
|
|
307
312
|
* database.createBatchTransaction(function(err, transaction) {
|
|
308
313
|
* const identifier = transaction.identifier();
|
|
309
314
|
* });
|
|
315
|
+
* ```
|
|
310
316
|
*/
|
|
311
317
|
identifier() {
|
|
312
318
|
return {
|
package/build/src/codec.d.ts
CHANGED
|
@@ -37,7 +37,9 @@ export interface JSONOptions {
|
|
|
37
37
|
* @param {number} [date] Number representing the date.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
|
+
* ```
|
|
40
41
|
* Spanner.date('3-3-1933');
|
|
42
|
+
* ```
|
|
41
43
|
*/
|
|
42
44
|
export declare class SpannerDate extends Date {
|
|
43
45
|
constructor(dateString?: string);
|
|
@@ -204,8 +206,10 @@ interface FieldType extends Type {
|
|
|
204
206
|
* @returns {object}
|
|
205
207
|
*
|
|
206
208
|
* @example
|
|
209
|
+
* ```
|
|
207
210
|
* codec.getType(NaN);
|
|
208
211
|
* // {type: 'float64'}
|
|
212
|
+
* ```
|
|
209
213
|
*/
|
|
210
214
|
declare function getType(value: Value): Type;
|
|
211
215
|
/**
|
package/build/src/codec.js
CHANGED
|
@@ -45,7 +45,9 @@ const protos_1 = require("../protos/protos");
|
|
|
45
45
|
* @param {number} [date] Number representing the date.
|
|
46
46
|
*
|
|
47
47
|
* @example
|
|
48
|
+
* ```
|
|
48
49
|
* Spanner.date('3-3-1933');
|
|
50
|
+
* ```
|
|
49
51
|
*/
|
|
50
52
|
class SpannerDate extends Date {
|
|
51
53
|
constructor(...dateFields) {
|
|
@@ -417,8 +419,10 @@ const TypeCode = {
|
|
|
417
419
|
* @returns {object}
|
|
418
420
|
*
|
|
419
421
|
* @example
|
|
422
|
+
* ```
|
|
420
423
|
* codec.getType(NaN);
|
|
421
424
|
* // {type: 'float64'}
|
|
425
|
+
* ```
|
|
422
426
|
*/
|
|
423
427
|
function getType(value) {
|
|
424
428
|
const isSpecialNumber = is.infinite(value) || (is.number(value) && isNaN(value));
|