@google-cloud/spanner 7.6.0 → 7.8.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.
- package/CHANGELOG.md +29 -0
- package/README.md +4 -0
- package/build/protos/google/spanner/admin/database/v1/backup.proto +190 -109
- package/build/protos/google/spanner/admin/database/v1/common.proto +30 -10
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +166 -100
- package/build/protos/google/spanner/admin/instance/v1/common.proto +15 -1
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +6 -0
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +30 -6
- package/build/protos/google/spanner/v1/commit_response.proto +1 -1
- package/build/protos/google/spanner/v1/keys.proto +1 -1
- package/build/protos/google/spanner/v1/mutation.proto +1 -1
- package/build/protos/google/spanner/v1/query_plan.proto +1 -1
- package/build/protos/google/spanner/v1/result_set.proto +1 -1
- package/build/protos/google/spanner/v1/spanner.proto +1 -1
- package/build/protos/google/spanner/v1/transaction.proto +1 -1
- package/build/protos/google/spanner/v1/type.proto +1 -1
- package/build/protos/protos.d.ts +310 -40
- package/build/protos/protos.js +942 -89
- package/build/protos/protos.json +115 -5
- package/build/src/codec.d.ts +56 -1
- package/build/src/codec.js +109 -4
- package/build/src/database.d.ts +41 -5
- package/build/src/database.js +37 -2
- package/build/src/index.d.ts +50 -1
- package/build/src/index.js +53 -0
- package/build/src/partial-result-stream.d.ts +41 -0
- package/build/src/partial-result-stream.js +6 -1
- package/build/src/table.d.ts +1 -0
- package/build/src/table.js +36 -2
- package/build/src/transaction-runner.d.ts +1 -0
- package/build/src/transaction-runner.js +3 -0
- package/build/src/transaction.d.ts +55 -0
- package/build/src/transaction.js +28 -2
- package/build/src/v1/database_admin_client.d.ts +175 -126
- package/build/src/v1/database_admin_client.js +95 -64
- package/build/src/v1/instance_admin_client.js +10 -7
- package/build/src/v1/spanner_client.js +10 -7
- package/build/src/v1/spanner_client_config.json +15 -14
- package/build/src/v1/spanner_executor_proxy_client.js +10 -7
- package/package.json +3 -3
package/build/protos/protos.json
CHANGED
|
@@ -1118,9 +1118,21 @@
|
|
|
1118
1118
|
1001,
|
|
1119
1119
|
1001
|
|
1120
1120
|
],
|
|
1121
|
+
[
|
|
1122
|
+
1002,
|
|
1123
|
+
1002
|
|
1124
|
+
],
|
|
1125
|
+
[
|
|
1126
|
+
9990,
|
|
1127
|
+
9990
|
|
1128
|
+
],
|
|
1121
1129
|
[
|
|
1122
1130
|
9995,
|
|
1123
1131
|
9999
|
|
1132
|
+
],
|
|
1133
|
+
[
|
|
1134
|
+
10000,
|
|
1135
|
+
10000
|
|
1124
1136
|
]
|
|
1125
1137
|
],
|
|
1126
1138
|
"reserved": [
|
|
@@ -1678,6 +1690,14 @@
|
|
|
1678
1690
|
"(google.api.field_behavior)": "OUTPUT_ONLY"
|
|
1679
1691
|
}
|
|
1680
1692
|
},
|
|
1693
|
+
"encryptionInformation": {
|
|
1694
|
+
"rule": "repeated",
|
|
1695
|
+
"type": "EncryptionInfo",
|
|
1696
|
+
"id": 13,
|
|
1697
|
+
"options": {
|
|
1698
|
+
"(google.api.field_behavior)": "OUTPUT_ONLY"
|
|
1699
|
+
}
|
|
1700
|
+
},
|
|
1681
1701
|
"databaseDialect": {
|
|
1682
1702
|
"type": "DatabaseDialect",
|
|
1683
1703
|
"id": 10,
|
|
@@ -1996,6 +2016,15 @@
|
|
|
1996
2016
|
"(google.api.field_behavior)": "OPTIONAL",
|
|
1997
2017
|
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
1998
2018
|
}
|
|
2019
|
+
},
|
|
2020
|
+
"kmsKeyNames": {
|
|
2021
|
+
"rule": "repeated",
|
|
2022
|
+
"type": "string",
|
|
2023
|
+
"id": 3,
|
|
2024
|
+
"options": {
|
|
2025
|
+
"(google.api.field_behavior)": "OPTIONAL",
|
|
2026
|
+
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
2027
|
+
}
|
|
1999
2028
|
}
|
|
2000
2029
|
},
|
|
2001
2030
|
"nested": {
|
|
@@ -2025,6 +2054,15 @@
|
|
|
2025
2054
|
"(google.api.field_behavior)": "OPTIONAL",
|
|
2026
2055
|
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
2027
2056
|
}
|
|
2057
|
+
},
|
|
2058
|
+
"kmsKeyNames": {
|
|
2059
|
+
"rule": "repeated",
|
|
2060
|
+
"type": "string",
|
|
2061
|
+
"id": 3,
|
|
2062
|
+
"options": {
|
|
2063
|
+
"(google.api.field_behavior)": "OPTIONAL",
|
|
2064
|
+
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
2065
|
+
}
|
|
2028
2066
|
}
|
|
2029
2067
|
},
|
|
2030
2068
|
"nested": {
|
|
@@ -2062,6 +2100,14 @@
|
|
|
2062
2100
|
"options": {
|
|
2063
2101
|
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
2064
2102
|
}
|
|
2103
|
+
},
|
|
2104
|
+
"kmsKeyNames": {
|
|
2105
|
+
"rule": "repeated",
|
|
2106
|
+
"type": "string",
|
|
2107
|
+
"id": 3,
|
|
2108
|
+
"options": {
|
|
2109
|
+
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
2110
|
+
}
|
|
2065
2111
|
}
|
|
2066
2112
|
}
|
|
2067
2113
|
},
|
|
@@ -3040,6 +3086,15 @@
|
|
|
3040
3086
|
"(google.api.field_behavior)": "OPTIONAL",
|
|
3041
3087
|
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
3042
3088
|
}
|
|
3089
|
+
},
|
|
3090
|
+
"kmsKeyNames": {
|
|
3091
|
+
"rule": "repeated",
|
|
3092
|
+
"type": "string",
|
|
3093
|
+
"id": 3,
|
|
3094
|
+
"options": {
|
|
3095
|
+
"(google.api.field_behavior)": "OPTIONAL",
|
|
3096
|
+
"(google.api.resource_reference).type": "cloudkms.googleapis.com/CryptoKey"
|
|
3097
|
+
}
|
|
3043
3098
|
}
|
|
3044
3099
|
},
|
|
3045
3100
|
"nested": {
|
|
@@ -3193,6 +3248,13 @@
|
|
|
3193
3248
|
}
|
|
3194
3249
|
}
|
|
3195
3250
|
},
|
|
3251
|
+
"FulfillmentPeriod": {
|
|
3252
|
+
"values": {
|
|
3253
|
+
"FULFILLMENT_PERIOD_UNSPECIFIED": 0,
|
|
3254
|
+
"FULFILLMENT_PERIOD_NORMAL": 1,
|
|
3255
|
+
"FULFILLMENT_PERIOD_EXTENDED": 2
|
|
3256
|
+
}
|
|
3257
|
+
},
|
|
3196
3258
|
"InstanceAdmin": {
|
|
3197
3259
|
"options": {
|
|
3198
3260
|
"(google.api.default_host)": "spanner.googleapis.com",
|
|
@@ -4186,6 +4248,10 @@
|
|
|
4186
4248
|
"endTime": {
|
|
4187
4249
|
"type": "google.protobuf.Timestamp",
|
|
4188
4250
|
"id": 4
|
|
4251
|
+
},
|
|
4252
|
+
"expectedFulfillmentPeriod": {
|
|
4253
|
+
"type": "FulfillmentPeriod",
|
|
4254
|
+
"id": 5
|
|
4189
4255
|
}
|
|
4190
4256
|
}
|
|
4191
4257
|
},
|
|
@@ -4206,6 +4272,10 @@
|
|
|
4206
4272
|
"endTime": {
|
|
4207
4273
|
"type": "google.protobuf.Timestamp",
|
|
4208
4274
|
"id": 4
|
|
4275
|
+
},
|
|
4276
|
+
"expectedFulfillmentPeriod": {
|
|
4277
|
+
"type": "FulfillmentPeriod",
|
|
4278
|
+
"id": 5
|
|
4209
4279
|
}
|
|
4210
4280
|
}
|
|
4211
4281
|
},
|
|
@@ -4633,6 +4703,10 @@
|
|
|
4633
4703
|
"type": "string",
|
|
4634
4704
|
"id": 1
|
|
4635
4705
|
},
|
|
4706
|
+
"spannerOptions": {
|
|
4707
|
+
"type": "SpannerOptions",
|
|
4708
|
+
"id": 2
|
|
4709
|
+
},
|
|
4636
4710
|
"start": {
|
|
4637
4711
|
"type": "StartTransactionAction",
|
|
4638
4712
|
"id": 10
|
|
@@ -5253,7 +5327,7 @@
|
|
|
5253
5327
|
"listCloudBackupOperations",
|
|
5254
5328
|
"getOperation",
|
|
5255
5329
|
"cancelOperation",
|
|
5256
|
-
"
|
|
5330
|
+
"changeQuorumCloudDatabase"
|
|
5257
5331
|
]
|
|
5258
5332
|
}
|
|
5259
5333
|
},
|
|
@@ -5366,8 +5440,8 @@
|
|
|
5366
5440
|
"type": "CancelOperationAction",
|
|
5367
5441
|
"id": 26
|
|
5368
5442
|
},
|
|
5369
|
-
"
|
|
5370
|
-
"type": "
|
|
5443
|
+
"changeQuorumCloudDatabase": {
|
|
5444
|
+
"type": "ChangeQuorumCloudDatabaseAction",
|
|
5371
5445
|
"id": 28
|
|
5372
5446
|
}
|
|
5373
5447
|
}
|
|
@@ -5746,7 +5820,7 @@
|
|
|
5746
5820
|
}
|
|
5747
5821
|
}
|
|
5748
5822
|
},
|
|
5749
|
-
"
|
|
5823
|
+
"ChangeQuorumCloudDatabaseAction": {
|
|
5750
5824
|
"oneofs": {
|
|
5751
5825
|
"_databaseUri": {
|
|
5752
5826
|
"oneof": [
|
|
@@ -5892,6 +5966,10 @@
|
|
|
5892
5966
|
"databaseId": {
|
|
5893
5967
|
"type": "string",
|
|
5894
5968
|
"id": 5
|
|
5969
|
+
},
|
|
5970
|
+
"encryptionConfig": {
|
|
5971
|
+
"type": "google.spanner.admin.database.v1.EncryptionConfig",
|
|
5972
|
+
"id": 7
|
|
5895
5973
|
}
|
|
5896
5974
|
}
|
|
5897
5975
|
},
|
|
@@ -5949,6 +6027,10 @@
|
|
|
5949
6027
|
"options": {
|
|
5950
6028
|
"proto3_optional": true
|
|
5951
6029
|
}
|
|
6030
|
+
},
|
|
6031
|
+
"encryptionConfig": {
|
|
6032
|
+
"type": "google.spanner.admin.database.v1.EncryptionConfig",
|
|
6033
|
+
"id": 7
|
|
5952
6034
|
}
|
|
5953
6035
|
}
|
|
5954
6036
|
},
|
|
@@ -6774,6 +6856,22 @@
|
|
|
6774
6856
|
"id": 1
|
|
6775
6857
|
}
|
|
6776
6858
|
}
|
|
6859
|
+
},
|
|
6860
|
+
"SpannerOptions": {
|
|
6861
|
+
"fields": {
|
|
6862
|
+
"sessionPoolOptions": {
|
|
6863
|
+
"type": "SessionPoolOptions",
|
|
6864
|
+
"id": 1
|
|
6865
|
+
}
|
|
6866
|
+
}
|
|
6867
|
+
},
|
|
6868
|
+
"SessionPoolOptions": {
|
|
6869
|
+
"fields": {
|
|
6870
|
+
"useMultiplexed": {
|
|
6871
|
+
"type": "bool",
|
|
6872
|
+
"id": 1
|
|
6873
|
+
}
|
|
6874
|
+
}
|
|
6777
6875
|
}
|
|
6778
6876
|
}
|
|
6779
6877
|
}
|
|
@@ -8367,7 +8465,10 @@
|
|
|
8367
8465
|
"rule": "repeated",
|
|
8368
8466
|
"type": "google.api.FieldBehavior",
|
|
8369
8467
|
"id": 1052,
|
|
8370
|
-
"extend": "google.protobuf.FieldOptions"
|
|
8468
|
+
"extend": "google.protobuf.FieldOptions",
|
|
8469
|
+
"options": {
|
|
8470
|
+
"packed": false
|
|
8471
|
+
}
|
|
8371
8472
|
},
|
|
8372
8473
|
"FieldBehavior": {
|
|
8373
8474
|
"values": {
|
|
@@ -8562,6 +8663,11 @@
|
|
|
8562
8663
|
"id": 1050,
|
|
8563
8664
|
"extend": "google.protobuf.ServiceOptions"
|
|
8564
8665
|
},
|
|
8666
|
+
"apiVersion": {
|
|
8667
|
+
"type": "string",
|
|
8668
|
+
"id": 525000001,
|
|
8669
|
+
"extend": "google.protobuf.ServiceOptions"
|
|
8670
|
+
},
|
|
8565
8671
|
"CommonLanguageSettings": {
|
|
8566
8672
|
"fields": {
|
|
8567
8673
|
"referenceDocsUri": {
|
|
@@ -8670,6 +8776,10 @@
|
|
|
8670
8776
|
"protoReferenceDocumentationUri": {
|
|
8671
8777
|
"type": "string",
|
|
8672
8778
|
"id": 110
|
|
8779
|
+
},
|
|
8780
|
+
"restReferenceDocumentationUri": {
|
|
8781
|
+
"type": "string",
|
|
8782
|
+
"id": 111
|
|
8673
8783
|
}
|
|
8674
8784
|
}
|
|
8675
8785
|
},
|
package/build/src/codec.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Big } from 'big.js';
|
|
2
3
|
import { common as p } from 'protobufjs';
|
|
3
4
|
import { google as spannerClient } from '../protos/protos';
|
|
@@ -6,6 +7,32 @@ export interface Field {
|
|
|
6
7
|
name: string;
|
|
7
8
|
value: Value;
|
|
8
9
|
}
|
|
10
|
+
export interface IProtoMessageParams {
|
|
11
|
+
value: object;
|
|
12
|
+
fullName: string;
|
|
13
|
+
/**
|
|
14
|
+
* Provide a First Class function that includes nested functions named
|
|
15
|
+
* "encode" for serialization and "decode" for deserialization of the proto
|
|
16
|
+
* message. The function should be sourced from the JS file generated by
|
|
17
|
+
* protobufjs-cli for the proto message.
|
|
18
|
+
*/
|
|
19
|
+
messageFunction?: Function;
|
|
20
|
+
}
|
|
21
|
+
export interface IProtoEnumParams {
|
|
22
|
+
value: string | number;
|
|
23
|
+
fullName: string;
|
|
24
|
+
/**
|
|
25
|
+
* An object containing enum string to id mapping.
|
|
26
|
+
* @example: { POP: 0, JAZZ: 1, FOLK: 2, ROCK: 3 }
|
|
27
|
+
*
|
|
28
|
+
* The object should be sourced from the JS file generated by
|
|
29
|
+
* protobufjs-cli for the proto message. Additionally, please review the
|
|
30
|
+
* sample at {@link www.samples.com} for guidance.
|
|
31
|
+
*
|
|
32
|
+
* ToDo: Update the link
|
|
33
|
+
*/
|
|
34
|
+
enumObject?: object;
|
|
35
|
+
}
|
|
9
36
|
export interface Json {
|
|
10
37
|
[field: string]: Value;
|
|
11
38
|
}
|
|
@@ -139,6 +166,28 @@ export declare class PGNumeric {
|
|
|
139
166
|
valueOf(): Big;
|
|
140
167
|
toJSON(): string;
|
|
141
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* @typedef ProtoMessage
|
|
171
|
+
* @see Spanner.protoMessage
|
|
172
|
+
*/
|
|
173
|
+
export declare class ProtoMessage {
|
|
174
|
+
value: Buffer;
|
|
175
|
+
fullName: string;
|
|
176
|
+
messageFunction?: Function;
|
|
177
|
+
constructor(protoMessageParams: IProtoMessageParams);
|
|
178
|
+
toJSON(): string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @typedef ProtoEnum
|
|
182
|
+
* @see Spanner.protoEnum
|
|
183
|
+
*/
|
|
184
|
+
export declare class ProtoEnum {
|
|
185
|
+
value: string;
|
|
186
|
+
fullName: string;
|
|
187
|
+
enumObject?: object;
|
|
188
|
+
constructor(protoEnumParams: IProtoEnumParams);
|
|
189
|
+
toJSON(): string;
|
|
190
|
+
}
|
|
142
191
|
/**
|
|
143
192
|
* @typedef PGJsonb
|
|
144
193
|
* @see Spanner.pgJsonb
|
|
@@ -185,9 +234,10 @@ declare function convertFieldsToJson(fields: Field[], options?: JSONOptions): Js
|
|
|
185
234
|
*
|
|
186
235
|
* @param {*} value Value to decode
|
|
187
236
|
* @param {object[]} type Value type object.
|
|
237
|
+
* @param columnMetadata Optional parameter to deserialize data
|
|
188
238
|
* @returns {*}
|
|
189
239
|
*/
|
|
190
|
-
declare function decode(value: Value, type: spannerClient.spanner.v1.Type): Value;
|
|
240
|
+
declare function decode(value: Value, type: spannerClient.spanner.v1.Type, columnMetadata?: object): Value;
|
|
191
241
|
/**
|
|
192
242
|
* Encode a value in the format the API expects.
|
|
193
243
|
*
|
|
@@ -207,6 +257,7 @@ export interface Type {
|
|
|
207
257
|
type: string;
|
|
208
258
|
fields?: FieldType[];
|
|
209
259
|
child?: Type;
|
|
260
|
+
fullName?: string;
|
|
210
261
|
}
|
|
211
262
|
interface FieldType extends Type {
|
|
212
263
|
name: string;
|
|
@@ -226,6 +277,8 @@ interface FieldType extends Type {
|
|
|
226
277
|
* - string
|
|
227
278
|
* - bytes
|
|
228
279
|
* - json
|
|
280
|
+
* - proto
|
|
281
|
+
* - enum
|
|
229
282
|
* - timestamp
|
|
230
283
|
* - date
|
|
231
284
|
* - struct
|
|
@@ -298,6 +351,8 @@ export declare const codec: {
|
|
|
298
351
|
Numeric: typeof Numeric;
|
|
299
352
|
PGNumeric: typeof PGNumeric;
|
|
300
353
|
PGJsonb: typeof PGJsonb;
|
|
354
|
+
ProtoMessage: typeof ProtoMessage;
|
|
355
|
+
ProtoEnum: typeof ProtoEnum;
|
|
301
356
|
PGOid: typeof PGOid;
|
|
302
357
|
convertFieldsToJson: typeof convertFieldsToJson;
|
|
303
358
|
decode: typeof decode;
|
package/build/src/codec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codec = exports.PGOid = exports.PGJsonb = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.Float32 = exports.SpannerDate = void 0;
|
|
3
|
+
exports.codec = exports.PGOid = exports.PGJsonb = exports.ProtoEnum = exports.ProtoMessage = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.Float32 = exports.SpannerDate = void 0;
|
|
4
4
|
/*!
|
|
5
5
|
* Copyright 2017 Google Inc. All Rights Reserved.
|
|
6
6
|
*
|
|
@@ -209,6 +209,69 @@ class PGNumeric {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.PGNumeric = PGNumeric;
|
|
212
|
+
/**
|
|
213
|
+
* @typedef ProtoMessage
|
|
214
|
+
* @see Spanner.protoMessage
|
|
215
|
+
*/
|
|
216
|
+
class ProtoMessage {
|
|
217
|
+
constructor(protoMessageParams) {
|
|
218
|
+
this.fullName = protoMessageParams.fullName;
|
|
219
|
+
this.messageFunction = protoMessageParams.messageFunction;
|
|
220
|
+
if (protoMessageParams.value instanceof Buffer) {
|
|
221
|
+
this.value = protoMessageParams.value;
|
|
222
|
+
}
|
|
223
|
+
else if (protoMessageParams.messageFunction) {
|
|
224
|
+
this.value = protoMessageParams.messageFunction['encode'](protoMessageParams.value).finish();
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
throw new google_gax_1.GoogleError(`protoMessageParams cannot be used to construct
|
|
228
|
+
the ProtoMessage. Pass the serialized buffer of the
|
|
229
|
+
proto message as the value or provide the message object along with the
|
|
230
|
+
corresponding messageFunction generated by protobufjs-cli.`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
toJSON() {
|
|
234
|
+
if (this.messageFunction) {
|
|
235
|
+
return this.messageFunction['toObject'](this.messageFunction['decode'](this.value));
|
|
236
|
+
}
|
|
237
|
+
return this.value.toString();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.ProtoMessage = ProtoMessage;
|
|
241
|
+
/**
|
|
242
|
+
* @typedef ProtoEnum
|
|
243
|
+
* @see Spanner.protoEnum
|
|
244
|
+
*/
|
|
245
|
+
class ProtoEnum {
|
|
246
|
+
constructor(protoEnumParams) {
|
|
247
|
+
this.fullName = protoEnumParams.fullName;
|
|
248
|
+
this.enumObject = protoEnumParams.enumObject;
|
|
249
|
+
/**
|
|
250
|
+
* @code{IProtoEnumParams} can accept either a number or a string as a value so
|
|
251
|
+
* converting to string and checking whether it's numeric using regex.
|
|
252
|
+
*/
|
|
253
|
+
if (/^\d+$/.test(protoEnumParams.value.toString())) {
|
|
254
|
+
this.value = protoEnumParams.value.toString();
|
|
255
|
+
}
|
|
256
|
+
else if (protoEnumParams.enumObject &&
|
|
257
|
+
protoEnumParams.enumObject[protoEnumParams.value]) {
|
|
258
|
+
this.value = protoEnumParams.enumObject[protoEnumParams.value];
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
throw new google_gax_1.GoogleError(`protoEnumParams cannot be used for constructing the
|
|
262
|
+
ProtoEnum. Pass the number as the value or provide the enum string
|
|
263
|
+
constant as the value along with the corresponding enumObject generated
|
|
264
|
+
by protobufjs-cli.`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
toJSON() {
|
|
268
|
+
if (this.enumObject) {
|
|
269
|
+
return Object.getPrototypeOf(this.enumObject)[this.value];
|
|
270
|
+
}
|
|
271
|
+
return this.value.toString();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.ProtoEnum = ProtoEnum;
|
|
212
275
|
/**
|
|
213
276
|
* @typedef PGJsonb
|
|
214
277
|
* @see Spanner.pgJsonb
|
|
@@ -316,6 +379,9 @@ function convertValueToJson(value, options) {
|
|
|
316
379
|
if (Array.isArray(value)) {
|
|
317
380
|
return value.map(child => convertValueToJson(child, options));
|
|
318
381
|
}
|
|
382
|
+
if (value instanceof ProtoMessage || value instanceof ProtoEnum) {
|
|
383
|
+
return value.toJSON();
|
|
384
|
+
}
|
|
319
385
|
return value;
|
|
320
386
|
}
|
|
321
387
|
/**
|
|
@@ -325,9 +391,10 @@ function convertValueToJson(value, options) {
|
|
|
325
391
|
*
|
|
326
392
|
* @param {*} value Value to decode
|
|
327
393
|
* @param {object[]} type Value type object.
|
|
394
|
+
* @param columnMetadata Optional parameter to deserialize data
|
|
328
395
|
* @returns {*}
|
|
329
396
|
*/
|
|
330
|
-
function decode(value, type) {
|
|
397
|
+
function decode(value, type, columnMetadata) {
|
|
331
398
|
if (is.null(value)) {
|
|
332
399
|
return null;
|
|
333
400
|
}
|
|
@@ -338,6 +405,23 @@ function decode(value, type) {
|
|
|
338
405
|
case 'BYTES':
|
|
339
406
|
decoded = Buffer.from(decoded, 'base64');
|
|
340
407
|
break;
|
|
408
|
+
case protos_1.google.spanner.v1.TypeCode.PROTO:
|
|
409
|
+
case 'PROTO':
|
|
410
|
+
decoded = Buffer.from(decoded, 'base64');
|
|
411
|
+
decoded = new ProtoMessage({
|
|
412
|
+
value: decoded,
|
|
413
|
+
fullName: type.protoTypeFqn,
|
|
414
|
+
messageFunction: columnMetadata,
|
|
415
|
+
});
|
|
416
|
+
break;
|
|
417
|
+
case protos_1.google.spanner.v1.TypeCode.ENUM:
|
|
418
|
+
case 'ENUM':
|
|
419
|
+
decoded = new ProtoEnum({
|
|
420
|
+
value: decoded,
|
|
421
|
+
fullName: type.protoTypeFqn,
|
|
422
|
+
enumObject: columnMetadata,
|
|
423
|
+
});
|
|
424
|
+
break;
|
|
341
425
|
case protos_1.google.spanner.v1.TypeCode.FLOAT32:
|
|
342
426
|
case 'FLOAT32':
|
|
343
427
|
decoded = new Float32(decoded);
|
|
@@ -387,13 +471,13 @@ function decode(value, type) {
|
|
|
387
471
|
case protos_1.google.spanner.v1.TypeCode.ARRAY:
|
|
388
472
|
case 'ARRAY':
|
|
389
473
|
decoded = decoded.map(value => {
|
|
390
|
-
return decode(value, type.arrayElementType);
|
|
474
|
+
return decode(value, type.arrayElementType, columnMetadata);
|
|
391
475
|
});
|
|
392
476
|
break;
|
|
393
477
|
case protos_1.google.spanner.v1.TypeCode.STRUCT:
|
|
394
478
|
case 'STRUCT':
|
|
395
479
|
fields = type.structType.fields.map(({ name, type }, index) => {
|
|
396
|
-
const value = decode((!Array.isArray(decoded) && decoded[name]) || decoded[index], type);
|
|
480
|
+
const value = decode((!Array.isArray(decoded) && decoded[name]) || decoded[index], type, columnMetadata);
|
|
397
481
|
return { name, value };
|
|
398
482
|
});
|
|
399
483
|
decoded = Struct.fromArray(fields);
|
|
@@ -443,6 +527,12 @@ function encodeValue(value) {
|
|
|
443
527
|
if (Buffer.isBuffer(value)) {
|
|
444
528
|
return value.toString('base64');
|
|
445
529
|
}
|
|
530
|
+
if (value instanceof ProtoMessage) {
|
|
531
|
+
return value.value.toString('base64');
|
|
532
|
+
}
|
|
533
|
+
if (value instanceof ProtoEnum) {
|
|
534
|
+
return value.value;
|
|
535
|
+
}
|
|
446
536
|
if (value instanceof Struct) {
|
|
447
537
|
return Array.from(value).map(field => encodeValue(field.value));
|
|
448
538
|
}
|
|
@@ -478,6 +568,8 @@ const TypeCode = {
|
|
|
478
568
|
bytes: 'BYTES',
|
|
479
569
|
json: 'JSON',
|
|
480
570
|
jsonb: 'JSON',
|
|
571
|
+
proto: 'PROTO',
|
|
572
|
+
enum: 'ENUM',
|
|
481
573
|
array: 'ARRAY',
|
|
482
574
|
struct: 'STRUCT',
|
|
483
575
|
};
|
|
@@ -496,6 +588,8 @@ const TypeCode = {
|
|
|
496
588
|
* - string
|
|
497
589
|
* - bytes
|
|
498
590
|
* - json
|
|
591
|
+
* - proto
|
|
592
|
+
* - enum
|
|
499
593
|
* - timestamp
|
|
500
594
|
* - date
|
|
501
595
|
* - struct
|
|
@@ -542,6 +636,12 @@ function getType(value) {
|
|
|
542
636
|
if (value instanceof PGOid) {
|
|
543
637
|
return { type: 'pgOid' };
|
|
544
638
|
}
|
|
639
|
+
if (value instanceof ProtoMessage) {
|
|
640
|
+
return { type: 'proto', fullName: value.fullName };
|
|
641
|
+
}
|
|
642
|
+
if (value instanceof ProtoEnum) {
|
|
643
|
+
return { type: 'enum', fullName: value.fullName };
|
|
644
|
+
}
|
|
545
645
|
if (is.boolean(value)) {
|
|
546
646
|
return { type: 'bool' };
|
|
547
647
|
}
|
|
@@ -642,6 +742,9 @@ function createTypeObject(friendlyType) {
|
|
|
642
742
|
const type = {
|
|
643
743
|
code,
|
|
644
744
|
};
|
|
745
|
+
if (code === 'PROTO' || code === 'ENUM') {
|
|
746
|
+
type.protoTypeFqn = config.fullName || '';
|
|
747
|
+
}
|
|
645
748
|
if (code === 'ARRAY') {
|
|
646
749
|
type.arrayElementType = exports.codec.createTypeObject(config.child);
|
|
647
750
|
}
|
|
@@ -676,6 +779,8 @@ exports.codec = {
|
|
|
676
779
|
Numeric,
|
|
677
780
|
PGNumeric,
|
|
678
781
|
PGJsonb,
|
|
782
|
+
ProtoMessage,
|
|
783
|
+
ProtoEnum,
|
|
679
784
|
PGOid,
|
|
680
785
|
convertFieldsToJson,
|
|
681
786
|
decode,
|
package/build/src/database.d.ts
CHANGED
|
@@ -52,10 +52,14 @@ type GetTransactionCallback = NormalCallback<Transaction>;
|
|
|
52
52
|
export interface SessionPoolConstructor {
|
|
53
53
|
new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
|
|
54
54
|
}
|
|
55
|
+
export type GetDatabaseDialectCallback = NormalCallback<EnumKey<typeof google.spanner.admin.database.v1.DatabaseDialect>>;
|
|
55
56
|
export interface SetIamPolicyRequest {
|
|
56
57
|
policy: Policy | null;
|
|
57
58
|
updateMask?: FieldMask | null;
|
|
58
59
|
}
|
|
60
|
+
export interface RunPartitionedUpdateOptions extends ExecuteSqlRequest {
|
|
61
|
+
excludeTxnFromChangeStreams?: boolean;
|
|
62
|
+
}
|
|
59
63
|
export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
|
|
60
64
|
export type UpdateSchemaResponse = [
|
|
61
65
|
GaxOperation,
|
|
@@ -67,7 +71,7 @@ export type GetDatabaseRolesOptions = PagedOptionsWithFilter;
|
|
|
67
71
|
/**
|
|
68
72
|
* IDatabase structure with database state enum translated to string form.
|
|
69
73
|
*/
|
|
70
|
-
type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
|
|
74
|
+
type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'databaseDialect', typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect>, 'restoreInfo'> & {
|
|
71
75
|
restoreInfo?: IRestoreInfoTranslatedEnum | null;
|
|
72
76
|
};
|
|
73
77
|
/**
|
|
@@ -106,6 +110,12 @@ export interface GetIamPolicyOptions {
|
|
|
106
110
|
requestedPolicyVersion?: number | null;
|
|
107
111
|
gaxOptions?: CallOptions;
|
|
108
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* @typedef {object} GetTransactionOptions
|
|
115
|
+
* * @property {boolean} [optimisticLock] The optimistic lock a
|
|
116
|
+
* {@link Transaction} should use while running.
|
|
117
|
+
*/
|
|
118
|
+
export type GetTransactionOptions = Omit<RunTransactionOptions, 'timeout'>;
|
|
109
119
|
export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
|
|
110
120
|
export interface BatchCreateSessionsOptions extends CreateSessionOptions {
|
|
111
121
|
count: number;
|
|
@@ -166,6 +176,7 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
166
176
|
};
|
|
167
177
|
request: DatabaseRequest;
|
|
168
178
|
databaseRole?: string | null;
|
|
179
|
+
databaseDialect?: EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | null;
|
|
169
180
|
constructor(instance: Instance, name: string, poolOptions?: SessionPoolConstructor | SessionPoolOptions, queryOptions?: spannerClient.spanner.v1.ExecuteSqlRequest.IQueryOptions);
|
|
170
181
|
/**
|
|
171
182
|
* @typedef {array} SetDatabaseMetadataResponse
|
|
@@ -811,6 +822,31 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
811
822
|
getState(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State> | undefined>;
|
|
812
823
|
getState(callback: GetStateCallback): void;
|
|
813
824
|
getState(options: CallOptions, callback: GetStateCallback): void;
|
|
825
|
+
/**
|
|
826
|
+
* Retrieves the dialect of the database
|
|
827
|
+
*
|
|
828
|
+
* @see {@link #getMetadata}
|
|
829
|
+
*
|
|
830
|
+
* @method Database#getDatabaseDialect
|
|
831
|
+
*
|
|
832
|
+
* @param {object} [gaxOptions] Request configuration options,
|
|
833
|
+
* See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions}
|
|
834
|
+
* for more details.
|
|
835
|
+
* @param {GetDatabaseDialectCallback} [callback] Callback function.
|
|
836
|
+
* @returns {Promise<EnumKey<typeof, databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>}
|
|
837
|
+
* When resolved, contains the database dialect of the database if the dialect is defined.
|
|
838
|
+
* @example
|
|
839
|
+
* const {Spanner} = require('@google-cloud/spanner');
|
|
840
|
+
* const spanner = new Spanner();
|
|
841
|
+
* const instance = spanner.instance('my-instance');
|
|
842
|
+
* const database = instance.database('my-database');
|
|
843
|
+
* const dialect = await database.getDatabaseDialect();
|
|
844
|
+
* const isGoogleSQL = (dialect === 'GOOGLE_STANDARD_SQL');
|
|
845
|
+
* const isPostgreSQL = (dialect === 'POSTGRESQL');
|
|
846
|
+
*/
|
|
847
|
+
getDatabaseDialect(options?: CallOptions): Promise<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.DatabaseDialect> | undefined>;
|
|
848
|
+
getDatabaseDialect(callback: GetDatabaseDialectCallback): void;
|
|
849
|
+
getDatabaseDialect(options: CallOptions, callback: GetDatabaseDialectCallback): void;
|
|
814
850
|
/**
|
|
815
851
|
* @typedef {array} GetSchemaResponse
|
|
816
852
|
* @property {string[]} 0 An array of database DDL statements.
|
|
@@ -1140,7 +1176,7 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
1140
1176
|
* });
|
|
1141
1177
|
* ```
|
|
1142
1178
|
*/
|
|
1143
|
-
getTransaction(): Promise<[Transaction]>;
|
|
1179
|
+
getTransaction(optionsOrCallback?: GetTransactionOptions): Promise<[Transaction]>;
|
|
1144
1180
|
getTransaction(callback: GetTransactionCallback): void;
|
|
1145
1181
|
/**
|
|
1146
1182
|
* Query object for listing database operations.
|
|
@@ -1521,9 +1557,9 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
1521
1557
|
* @param {RunUpdateCallback} [callback] Callback function.
|
|
1522
1558
|
* @returns {Promise<RunUpdateResponse>}
|
|
1523
1559
|
*/
|
|
1524
|
-
runPartitionedUpdate(query: string |
|
|
1525
|
-
runPartitionedUpdate(query: string |
|
|
1526
|
-
_runPartitionedUpdate(session: Session, query: string |
|
|
1560
|
+
runPartitionedUpdate(query: string | RunPartitionedUpdateOptions): Promise<[number]>;
|
|
1561
|
+
runPartitionedUpdate(query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void;
|
|
1562
|
+
_runPartitionedUpdate(session: Session, query: string | RunPartitionedUpdateOptions, callback?: RunUpdateCallback): void | Promise<number>;
|
|
1527
1563
|
/**
|
|
1528
1564
|
* Create a readable object stream to receive resulting rows from a SQL
|
|
1529
1565
|
* statement.
|