@google-cloud/spanner 8.10.0 → 8.12.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/build/protos/status.json +243 -0
- package/build/src/backup.d.ts +2 -1
- package/build/src/batch-transaction.d.ts +2 -1
- package/build/src/codec.d.ts +2 -1
- package/build/src/codec.js +21 -20
- package/build/src/common-grpc/service.js +9 -10
- package/build/src/common.d.ts +3 -2
- package/build/src/database.d.ts +7 -2
- package/build/src/database.js +58 -37
- package/build/src/index.d.ts +3 -2
- package/build/src/index.js +7 -16
- package/build/src/instance-config.d.ts +3 -3
- package/build/src/instance-config.js +1 -1
- package/build/src/instance.d.ts +5 -5
- package/build/src/instance.js +3 -2
- package/build/src/instrument.js +5 -4
- package/build/src/multiplexed-session.d.ts +3 -0
- package/build/src/multiplexed-session.js +28 -2
- package/build/src/partial-result-stream.d.ts +2 -1
- package/build/src/partial-result-stream.js +161 -35
- package/build/src/protos.d.ts +21 -0
- package/build/src/protos.js +52 -0
- package/build/src/session-factory.d.ts +4 -2
- package/build/src/session-factory.js +14 -3
- package/build/src/session.d.ts +2 -1
- package/build/src/table.d.ts +3 -2
- package/build/src/table.js +4 -3
- package/build/src/transaction-runner.d.ts +2 -1
- package/build/src/transaction-runner.js +6 -8
- package/build/src/transaction.d.ts +45 -4
- package/build/src/transaction.js +105 -6
- package/build/src/v1/index.d.ts +1 -4
- package/build/src/v1/index.js +5 -8
- package/package.json +4 -9
- package/build/protos/google/spanner/admin/database/v1/backup.proto +0 -773
- package/build/protos/google/spanner/admin/database/v1/backup_schedule.proto +0 -230
- package/build/protos/google/spanner/admin/database/v1/common.proto +0 -132
- package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +0 -1314
- package/build/protos/google/spanner/admin/instance/v1/common.proto +0 -64
- package/build/protos/google/spanner/admin/instance/v1/spanner_instance_admin.proto +0 -2184
- package/build/protos/google/spanner/executor/v1/cloud_executor.proto +0 -1604
- package/build/protos/google/spanner/v1/change_stream.proto +0 -451
- package/build/protos/google/spanner/v1/commit_response.proto +0 -80
- package/build/protos/google/spanner/v1/keys.proto +0 -163
- package/build/protos/google/spanner/v1/location.proto +0 -388
- package/build/protos/google/spanner/v1/mutation.proto +0 -156
- package/build/protos/google/spanner/v1/query_plan.proto +0 -156
- package/build/protos/google/spanner/v1/result_set.proto +0 -260
- package/build/protos/google/spanner/v1/spanner.proto +0 -1472
- package/build/protos/google/spanner/v1/transaction.proto +0 -329
- package/build/protos/google/spanner/v1/type.proto +0 -214
- package/build/protos/protos.d.ts +0 -44031
- package/build/protos/protos.js +0 -122630
- package/build/protos/protos.json +0 -11631
- package/build/src/v1/database_admin_client.d.ts +0 -2367
- package/build/src/v1/database_admin_client.js +0 -2914
- package/build/src/v1/database_admin_client_config.json +0 -169
- package/build/src/v1/database_admin_proto_list.json +0 -6
- package/build/src/v1/gapic_metadata.json +0 -27
- package/build/src/v1/instance_admin_client.d.ts +0 -2106
- package/build/src/v1/instance_admin_client.js +0 -2387
- package/build/src/v1/instance_admin_client_config.json +0 -129
- package/build/src/v1/instance_admin_proto_list.json +0 -4
- package/build/src/v1/spanner_client.d.ts +0 -1319
- package/build/src/v1/spanner_client.js +0 -1446
- package/build/src/v1/spanner_client_config.json +0 -123
- package/build/src/v1/spanner_executor_proxy_client.d.ts +0 -419
- package/build/src/v1/spanner_executor_proxy_client.js +0 -728
- package/build/src/v1/spanner_executor_proxy_client_config.json +0 -30
- package/build/src/v1/spanner_executor_proxy_proto_list.json +0 -15
- package/build/src/v1/spanner_proto_list.json +0 -12
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nested": {
|
|
3
|
+
"google": {
|
|
4
|
+
"nested": {
|
|
5
|
+
"protobuf": {
|
|
6
|
+
"nested": {
|
|
7
|
+
"Any": {
|
|
8
|
+
"fields": {
|
|
9
|
+
"type_url": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"id": 1
|
|
12
|
+
},
|
|
13
|
+
"value": {
|
|
14
|
+
"type": "bytes",
|
|
15
|
+
"id": 2
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"Duration": {
|
|
20
|
+
"fields": {
|
|
21
|
+
"seconds": {
|
|
22
|
+
"type": "int64",
|
|
23
|
+
"id": 1
|
|
24
|
+
},
|
|
25
|
+
"nanos": {
|
|
26
|
+
"type": "int32",
|
|
27
|
+
"id": 2
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"rpc": {
|
|
34
|
+
"options": {
|
|
35
|
+
"cc_enable_arenas": true,
|
|
36
|
+
"go_package": "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails",
|
|
37
|
+
"java_multiple_files": true,
|
|
38
|
+
"java_outer_classname": "ErrorDetailsProto",
|
|
39
|
+
"java_package": "com.google.rpc",
|
|
40
|
+
"objc_class_prefix": "RPC"
|
|
41
|
+
},
|
|
42
|
+
"nested": {
|
|
43
|
+
"Status": {
|
|
44
|
+
"fields": {
|
|
45
|
+
"code": {
|
|
46
|
+
"type": "int32",
|
|
47
|
+
"id": 1
|
|
48
|
+
},
|
|
49
|
+
"message": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"id": 2
|
|
52
|
+
},
|
|
53
|
+
"details": {
|
|
54
|
+
"rule": "repeated",
|
|
55
|
+
"type": "google.protobuf.Any",
|
|
56
|
+
"id": 3
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"RetryInfo": {
|
|
61
|
+
"fields": {
|
|
62
|
+
"retryDelay": {
|
|
63
|
+
"type": "google.protobuf.Duration",
|
|
64
|
+
"id": 1
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"DebugInfo": {
|
|
69
|
+
"fields": {
|
|
70
|
+
"stackEntries": {
|
|
71
|
+
"rule": "repeated",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"id": 1
|
|
74
|
+
},
|
|
75
|
+
"detail": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"id": 2
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"QuotaFailure": {
|
|
82
|
+
"fields": {
|
|
83
|
+
"violations": {
|
|
84
|
+
"rule": "repeated",
|
|
85
|
+
"type": "Violation",
|
|
86
|
+
"id": 1
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"nested": {
|
|
90
|
+
"Violation": {
|
|
91
|
+
"fields": {
|
|
92
|
+
"subject": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"id": 1
|
|
95
|
+
},
|
|
96
|
+
"description": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"id": 2
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"ErrorInfo": {
|
|
105
|
+
"fields": {
|
|
106
|
+
"reason": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"id": 1
|
|
109
|
+
},
|
|
110
|
+
"domain": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"id": 2
|
|
113
|
+
},
|
|
114
|
+
"metadata": {
|
|
115
|
+
"keyType": "string",
|
|
116
|
+
"type": "string",
|
|
117
|
+
"id": 3
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"PreconditionFailure": {
|
|
122
|
+
"fields": {
|
|
123
|
+
"violations": {
|
|
124
|
+
"rule": "repeated",
|
|
125
|
+
"type": "Violation",
|
|
126
|
+
"id": 1
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"nested": {
|
|
130
|
+
"Violation": {
|
|
131
|
+
"fields": {
|
|
132
|
+
"type": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"id": 1
|
|
135
|
+
},
|
|
136
|
+
"subject": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"id": 2
|
|
139
|
+
},
|
|
140
|
+
"description": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"id": 3
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
"BadRequest": {
|
|
149
|
+
"fields": {
|
|
150
|
+
"fieldViolations": {
|
|
151
|
+
"rule": "repeated",
|
|
152
|
+
"type": "FieldViolation",
|
|
153
|
+
"id": 1
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"nested": {
|
|
157
|
+
"FieldViolation": {
|
|
158
|
+
"fields": {
|
|
159
|
+
"field": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"id": 1
|
|
162
|
+
},
|
|
163
|
+
"description": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"id": 2
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"RequestInfo": {
|
|
172
|
+
"fields": {
|
|
173
|
+
"requestId": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"id": 1
|
|
176
|
+
},
|
|
177
|
+
"servingData": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"id": 2
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"ResourceInfo": {
|
|
184
|
+
"fields": {
|
|
185
|
+
"resourceType": {
|
|
186
|
+
"type": "string",
|
|
187
|
+
"id": 1
|
|
188
|
+
},
|
|
189
|
+
"resourceName": {
|
|
190
|
+
"type": "string",
|
|
191
|
+
"id": 2
|
|
192
|
+
},
|
|
193
|
+
"owner": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"id": 3
|
|
196
|
+
},
|
|
197
|
+
"description": {
|
|
198
|
+
"type": "string",
|
|
199
|
+
"id": 4
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"Help": {
|
|
204
|
+
"fields": {
|
|
205
|
+
"links": {
|
|
206
|
+
"rule": "repeated",
|
|
207
|
+
"type": "Link",
|
|
208
|
+
"id": 1
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"nested": {
|
|
212
|
+
"Link": {
|
|
213
|
+
"fields": {
|
|
214
|
+
"description": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"id": 1
|
|
217
|
+
},
|
|
218
|
+
"url": {
|
|
219
|
+
"type": "string",
|
|
220
|
+
"id": 2
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"LocalizedMessage": {
|
|
227
|
+
"fields": {
|
|
228
|
+
"locale": {
|
|
229
|
+
"type": "string",
|
|
230
|
+
"id": 1
|
|
231
|
+
},
|
|
232
|
+
"message": {
|
|
233
|
+
"type": "string",
|
|
234
|
+
"id": 2
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
package/build/src/backup.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ import { IOperation, LongRunningCallback, RequestCallback, ResourceCallback, Nor
|
|
|
17
17
|
import { EnumKey, RequestConfig, TranslateEnumKeys } from '.';
|
|
18
18
|
import { CallOptions, Metadata, Operation as GaxOperation } from 'google-gax';
|
|
19
19
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
20
|
-
import {
|
|
20
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
21
|
+
import databaseAdmin = protos.google;
|
|
21
22
|
import { common as p } from 'protobufjs';
|
|
22
23
|
export type CreateBackupCallback = LongRunningCallback<Backup>;
|
|
23
24
|
export type CopyBackupCallback = LongRunningCallback<Backup>;
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ExecuteSqlRequest, ReadCallback, ReadRequest, ReadResponse, RunCallback, RunResponse, Snapshot } from './transaction';
|
|
17
|
-
import {
|
|
17
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
18
|
+
import google = protos.google;
|
|
18
19
|
import { Session } from '.';
|
|
19
20
|
import { ResourceCallback } from '../src/common';
|
|
20
21
|
export interface TransactionIdentifier {
|
package/build/src/codec.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Big } from 'big.js';
|
|
2
2
|
import { common as p } from 'protobufjs';
|
|
3
|
-
import {
|
|
3
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
4
|
+
import spannerClient = protos.google;
|
|
4
5
|
export type Value = any;
|
|
5
6
|
export interface Field {
|
|
6
7
|
name: string;
|
package/build/src/codec.js
CHANGED
|
@@ -21,7 +21,8 @@ const service_1 = require("./common-grpc/service");
|
|
|
21
21
|
const precise_date_1 = require("@google-cloud/precise-date");
|
|
22
22
|
const helper_1 = require("./helper");
|
|
23
23
|
const big_js_1 = require("big.js");
|
|
24
|
-
const
|
|
24
|
+
const spanner_api_1 = require("@google-cloud/spanner-api");
|
|
25
|
+
var spannerClient = spanner_api_1.protos.google;
|
|
25
26
|
const google_gax_1 = require("google-gax");
|
|
26
27
|
const DATE_REGEX = /^\d{4}-\d{1,2}-\d{1,2}/;
|
|
27
28
|
const DIGITS_REGEX = /^\d+$/;
|
|
@@ -724,11 +725,11 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
724
725
|
}
|
|
725
726
|
let decoder;
|
|
726
727
|
switch (type.code) {
|
|
727
|
-
case
|
|
728
|
+
case spannerClient.spanner.v1.TypeCode.BYTES:
|
|
728
729
|
case 'BYTES':
|
|
729
730
|
decoder = val => Buffer.from(val, 'base64');
|
|
730
731
|
break;
|
|
731
|
-
case
|
|
732
|
+
case spannerClient.spanner.v1.TypeCode.PROTO:
|
|
732
733
|
case 'PROTO':
|
|
733
734
|
if (jsonMode) {
|
|
734
735
|
decoder = val => {
|
|
@@ -750,7 +751,7 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
750
751
|
};
|
|
751
752
|
}
|
|
752
753
|
break;
|
|
753
|
-
case
|
|
754
|
+
case spannerClient.spanner.v1.TypeCode.ENUM:
|
|
754
755
|
case 'ENUM':
|
|
755
756
|
if (jsonMode) {
|
|
756
757
|
decoder = val => {
|
|
@@ -787,18 +788,18 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
787
788
|
});
|
|
788
789
|
}
|
|
789
790
|
break;
|
|
790
|
-
case
|
|
791
|
+
case spannerClient.spanner.v1.TypeCode.FLOAT32:
|
|
791
792
|
case 'FLOAT32':
|
|
792
793
|
decoder = wrapNumbers ? val => new Float32(val) : val => Number(val);
|
|
793
794
|
break;
|
|
794
|
-
case
|
|
795
|
+
case spannerClient.spanner.v1.TypeCode.FLOAT64:
|
|
795
796
|
case 'FLOAT64':
|
|
796
797
|
decoder = wrapNumbers ? val => new Float(val) : val => Number(val);
|
|
797
798
|
break;
|
|
798
|
-
case
|
|
799
|
+
case spannerClient.spanner.v1.TypeCode.INT64:
|
|
799
800
|
case 'INT64':
|
|
800
801
|
if (type.typeAnnotation ===
|
|
801
|
-
|
|
802
|
+
spannerClient.spanner.v1.TypeAnnotationCode.PG_OID ||
|
|
802
803
|
type.typeAnnotation === 'PG_OID') {
|
|
803
804
|
decoder = wrapNumbers
|
|
804
805
|
? val => new PGOid(val)
|
|
@@ -822,10 +823,10 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
822
823
|
};
|
|
823
824
|
}
|
|
824
825
|
break;
|
|
825
|
-
case
|
|
826
|
+
case spannerClient.spanner.v1.TypeCode.NUMERIC:
|
|
826
827
|
case 'NUMERIC':
|
|
827
828
|
if (type.typeAnnotation ===
|
|
828
|
-
|
|
829
|
+
spannerClient.spanner.v1.TypeAnnotationCode.PG_NUMERIC ||
|
|
829
830
|
type.typeAnnotation === 'PG_NUMERIC') {
|
|
830
831
|
decoder = val => new PGNumeric(val);
|
|
831
832
|
}
|
|
@@ -833,18 +834,18 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
833
834
|
decoder = val => new Numeric(val);
|
|
834
835
|
}
|
|
835
836
|
break;
|
|
836
|
-
case
|
|
837
|
+
case spannerClient.spanner.v1.TypeCode.TIMESTAMP:
|
|
837
838
|
case 'TIMESTAMP':
|
|
838
839
|
decoder = val => parsePreciseDate(val);
|
|
839
840
|
break;
|
|
840
|
-
case
|
|
841
|
+
case spannerClient.spanner.v1.TypeCode.DATE:
|
|
841
842
|
case 'DATE':
|
|
842
843
|
decoder = val => new SpannerDate(val);
|
|
843
844
|
break;
|
|
844
|
-
case
|
|
845
|
+
case spannerClient.spanner.v1.TypeCode.JSON:
|
|
845
846
|
case 'JSON':
|
|
846
847
|
if (type.typeAnnotation ===
|
|
847
|
-
|
|
848
|
+
spannerClient.spanner.v1.TypeAnnotationCode.PG_JSONB ||
|
|
848
849
|
type.typeAnnotation === 'PG_JSONB') {
|
|
849
850
|
decoder = val => new PGJsonb(val);
|
|
850
851
|
}
|
|
@@ -852,17 +853,17 @@ function getDecoder(type, columnMetadata, options) {
|
|
|
852
853
|
decoder = val => JSON.parse(val);
|
|
853
854
|
}
|
|
854
855
|
break;
|
|
855
|
-
case
|
|
856
|
+
case spannerClient.spanner.v1.TypeCode.INTERVAL:
|
|
856
857
|
case 'INTERVAL':
|
|
857
858
|
decoder = val => Interval.fromISO8601(val);
|
|
858
859
|
break;
|
|
859
|
-
case
|
|
860
|
+
case spannerClient.spanner.v1.TypeCode.ARRAY:
|
|
860
861
|
case 'ARRAY': {
|
|
861
862
|
const elementDecoder = getDecoder(type.arrayElementType, columnMetadata, options);
|
|
862
863
|
decoder = val => val.map(elementDecoder);
|
|
863
864
|
break;
|
|
864
865
|
}
|
|
865
|
-
case
|
|
866
|
+
case spannerClient.spanner.v1.TypeCode.STRUCT:
|
|
866
867
|
case 'STRUCT': {
|
|
867
868
|
const includeNameless = options?.includeNameless === true;
|
|
868
869
|
const fields = type.structType.fields;
|
|
@@ -1296,13 +1297,13 @@ function createTypeObject(friendlyType) {
|
|
|
1296
1297
|
}
|
|
1297
1298
|
if (friendlyType.type === 'pgNumeric') {
|
|
1298
1299
|
type.typeAnnotation =
|
|
1299
|
-
|
|
1300
|
+
spannerClient.spanner.v1.TypeAnnotationCode.PG_NUMERIC;
|
|
1300
1301
|
}
|
|
1301
1302
|
else if (friendlyType.type === 'jsonb') {
|
|
1302
|
-
type.typeAnnotation =
|
|
1303
|
+
type.typeAnnotation = spannerClient.spanner.v1.TypeAnnotationCode.PG_JSONB;
|
|
1303
1304
|
}
|
|
1304
1305
|
else if (friendlyType.type === 'pgOid') {
|
|
1305
|
-
type.typeAnnotation =
|
|
1306
|
+
type.typeAnnotation = spannerClient.spanner.v1.TypeAnnotationCode.PG_OID;
|
|
1306
1307
|
}
|
|
1307
1308
|
return type;
|
|
1308
1309
|
}
|
|
@@ -28,7 +28,6 @@ const extend = require("extend");
|
|
|
28
28
|
const google_gax_1 = require("google-gax");
|
|
29
29
|
const retryRequest = require("retry-request");
|
|
30
30
|
const stream_1 = require("stream");
|
|
31
|
-
const helper_2 = require("../helper");
|
|
32
31
|
const gaxProtoPath = path.join(path.dirname(require.resolve('google-gax')), '..', 'protos');
|
|
33
32
|
// TODO: convert this object to an array
|
|
34
33
|
/**
|
|
@@ -173,7 +172,7 @@ class ObjectToStructConverter {
|
|
|
173
172
|
for (const prop in obj) {
|
|
174
173
|
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
175
174
|
const value = obj[prop];
|
|
176
|
-
if ((0,
|
|
175
|
+
if ((0, helper_1.isUndefined)(value)) {
|
|
177
176
|
continue;
|
|
178
177
|
}
|
|
179
178
|
convertedObject.fields[prop] = this.encodeValue_(value);
|
|
@@ -198,22 +197,22 @@ class ObjectToStructConverter {
|
|
|
198
197
|
*/
|
|
199
198
|
encodeValue_(value) {
|
|
200
199
|
let convertedValue;
|
|
201
|
-
if ((0,
|
|
200
|
+
if ((0, helper_1.isNull)(value)) {
|
|
202
201
|
convertedValue = {
|
|
203
202
|
nullValue: 0,
|
|
204
203
|
};
|
|
205
204
|
}
|
|
206
|
-
else if ((0,
|
|
205
|
+
else if ((0, helper_1.isNumber)(value)) {
|
|
207
206
|
convertedValue = {
|
|
208
207
|
numberValue: value,
|
|
209
208
|
};
|
|
210
209
|
}
|
|
211
|
-
else if ((0,
|
|
210
|
+
else if ((0, helper_1.isString)(value)) {
|
|
212
211
|
convertedValue = {
|
|
213
212
|
stringValue: value,
|
|
214
213
|
};
|
|
215
214
|
}
|
|
216
|
-
else if ((0,
|
|
215
|
+
else if ((0, helper_1.isBoolean)(value)) {
|
|
217
216
|
convertedValue = {
|
|
218
217
|
boolValue: value,
|
|
219
218
|
};
|
|
@@ -223,7 +222,7 @@ class ObjectToStructConverter {
|
|
|
223
222
|
blobValue: value,
|
|
224
223
|
};
|
|
225
224
|
}
|
|
226
|
-
else if ((0,
|
|
225
|
+
else if ((0, helper_1.isObject)(value)) {
|
|
227
226
|
if (this.seenObjects.has(value)) {
|
|
228
227
|
// Circular reference.
|
|
229
228
|
if (!this.removeCircular) {
|
|
@@ -242,7 +241,7 @@ class ObjectToStructConverter {
|
|
|
242
241
|
};
|
|
243
242
|
}
|
|
244
243
|
}
|
|
245
|
-
else if ((0,
|
|
244
|
+
else if ((0, helper_1.isArray)(value)) {
|
|
246
245
|
convertedValue = {
|
|
247
246
|
listValue: {
|
|
248
247
|
values: value.map(this.encodeValue_.bind(this)),
|
|
@@ -531,7 +530,7 @@ class GrpcService extends common_1.Service {
|
|
|
531
530
|
const service = this.getService_(protoOpts);
|
|
532
531
|
const grpcMetadata = this.grpcMetadata;
|
|
533
532
|
const grpcOpts = {};
|
|
534
|
-
if ((0,
|
|
533
|
+
if ((0, helper_1.isNumber)(protoOpts.timeout)) {
|
|
535
534
|
grpcOpts.deadline = GrpcService.createDeadline_(protoOpts.timeout);
|
|
536
535
|
}
|
|
537
536
|
try {
|
|
@@ -625,7 +624,7 @@ class GrpcService extends common_1.Service {
|
|
|
625
624
|
* @return {error|null}
|
|
626
625
|
*/
|
|
627
626
|
static decorateError_(err) {
|
|
628
|
-
const errorObj = (0,
|
|
627
|
+
const errorObj = (0, helper_1.isError)(err) ? err : {};
|
|
629
628
|
return GrpcService.decorateGrpcResponse_(errorObj, err);
|
|
630
629
|
}
|
|
631
630
|
/**
|
package/build/src/common.d.ts
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { grpc, CallOptions, Operation as GaxOperation } from 'google-gax';
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
17
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
18
|
+
import instanceAdmin = protos.google;
|
|
19
|
+
import databaseAdmin = protos.google;
|
|
19
20
|
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
20
21
|
export type Schema = string | string[] | databaseAdmin.spanner.admin.database.v1.IUpdateDatabaseDdlRequest;
|
|
21
22
|
export interface ResourceCallback<Resource, Response> {
|
package/build/src/database.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ import * as r from 'teeny-request';
|
|
|
19
19
|
import { CallOptions, Operation as GaxOperation } from 'google-gax';
|
|
20
20
|
import { BatchTransaction, TransactionIdentifier } from './batch-transaction';
|
|
21
21
|
import { SessionFactoryInterface } from './session-factory';
|
|
22
|
-
import {
|
|
22
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
23
|
+
import google = protos.google;
|
|
24
|
+
import databaseAdmin = protos.google;
|
|
25
|
+
import spannerClient = protos.google;
|
|
23
26
|
import IsolationLevel = google.spanner.v1.TransactionOptions.IsolationLevel;
|
|
24
27
|
import ReadLockMode = google.spanner.v1.TransactionOptions.ReadWrite.ReadLockMode;
|
|
25
28
|
import { GetDatabaseOperationsOptions, GetDatabaseOperationsResponse, Instance, GetDatabaseOperationsCallback } from './instance';
|
|
@@ -256,7 +259,7 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
256
259
|
setMetadata(metadata: IDatabase, gaxOptions?: CallOptions): Promise<SetDatabaseMetadataResponse>;
|
|
257
260
|
setMetadata(metadata: IDatabase, callback: SetDatabaseMetadataCallback): void;
|
|
258
261
|
setMetadata(metadata: IDatabase, gaxOptions: CallOptions, callback: SetDatabaseMetadataCallback): void;
|
|
259
|
-
static getEnvironmentQueryOptions():
|
|
262
|
+
static getEnvironmentQueryOptions(): google.spanner.v1.ExecuteSqlRequest.IQueryOptions;
|
|
260
263
|
/**
|
|
261
264
|
* @typedef {object} BatchCreateSessionsOptions
|
|
262
265
|
* @property {number} count The number of sessions to create.
|
|
@@ -1798,6 +1801,8 @@ declare class Database extends common.GrpcServiceObject {
|
|
|
1798
1801
|
*/
|
|
1799
1802
|
runTransaction(runFn: RunTransactionCallback): void;
|
|
1800
1803
|
runTransaction(options: RunTransactionOptions, runFn: RunTransactionCallback): void;
|
|
1804
|
+
private _runTransaction;
|
|
1805
|
+
private _executeTransactionRunner;
|
|
1801
1806
|
runTransactionAsync<T = {}>(runFn: AsyncRunTransactionCallback<T>): Promise<T>;
|
|
1802
1807
|
runTransactionAsync<T = {}>(options: RunTransactionOptions, runFn: AsyncRunTransactionCallback<T>): Promise<T>;
|
|
1803
1808
|
/**
|
package/build/src/database.js
CHANGED
|
@@ -1229,12 +1229,13 @@ class Database extends common.GrpcServiceObject {
|
|
|
1229
1229
|
(0, instrument_1.startTrace)('Database.runTransaction', {
|
|
1230
1230
|
...this._traceConfig,
|
|
1231
1231
|
transactionTag: options.requestOptions?.transactionTag,
|
|
1232
|
-
}, span =>
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1232
|
+
}, span => this._runTransaction(span, options, runFn));
|
|
1233
|
+
}
|
|
1234
|
+
_runTransaction(span, options, runFn) {
|
|
1235
|
+
this.sessionFactory_.getSessionForReadWrite((err, session, transaction) => {
|
|
1236
|
+
if (err) {
|
|
1237
|
+
(0, instrument_1.setSpanError)(span, err);
|
|
1238
|
+
if ((0, session_pool_1.isSessionNotFoundError)(err)) {
|
|
1238
1239
|
span.addEvent('No session available', {
|
|
1239
1240
|
'session.id': session?.id,
|
|
1240
1241
|
});
|
|
@@ -1242,34 +1243,46 @@ class Database extends common.GrpcServiceObject {
|
|
|
1242
1243
|
this.runTransaction(options, runFn);
|
|
1243
1244
|
return;
|
|
1244
1245
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1246
|
+
span.end();
|
|
1247
|
+
runFn(err);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
this._executeTransactionRunner(session, transaction, span, options, runFn);
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
_executeTransactionRunner(session, transaction, span, options, runFn) {
|
|
1254
|
+
transaction._observabilityOptions = this._observabilityOptions;
|
|
1255
|
+
transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
|
|
1256
|
+
transaction.setReadWriteTransactionOptions(options);
|
|
1257
|
+
const release = () => {
|
|
1258
|
+
this.sessionFactory_.release(session);
|
|
1259
|
+
span.end();
|
|
1260
|
+
};
|
|
1261
|
+
const runner = new transaction_runner_1.TransactionRunner(session, transaction, runFn, options);
|
|
1262
|
+
runner
|
|
1263
|
+
.run()
|
|
1264
|
+
.then(() => {
|
|
1265
|
+
release();
|
|
1266
|
+
return null;
|
|
1267
|
+
}, err => {
|
|
1268
|
+
(0, instrument_1.setSpanError)(span, err);
|
|
1269
|
+
if ((0, session_pool_1.isSessionNotFoundError)(err)) {
|
|
1270
|
+
span.addEvent('No session available', {
|
|
1271
|
+
'session.id': session.id,
|
|
1271
1272
|
});
|
|
1272
|
-
|
|
1273
|
+
release();
|
|
1274
|
+
this.runTransaction(options, runFn);
|
|
1275
|
+
}
|
|
1276
|
+
else {
|
|
1277
|
+
setImmediate(runFn, err);
|
|
1278
|
+
release();
|
|
1279
|
+
}
|
|
1280
|
+
return null;
|
|
1281
|
+
})
|
|
1282
|
+
.catch(err => {
|
|
1283
|
+
(0, instrument_1.setSpanErrorAndException)(span, err);
|
|
1284
|
+
span.end();
|
|
1285
|
+
this.emit('error', err);
|
|
1273
1286
|
});
|
|
1274
1287
|
}
|
|
1275
1288
|
/**
|
|
@@ -1531,11 +1544,19 @@ class Database extends common.GrpcServiceObject {
|
|
|
1531
1544
|
return;
|
|
1532
1545
|
}
|
|
1533
1546
|
span.addEvent('Using Session', { 'session.id': session?.id });
|
|
1534
|
-
|
|
1547
|
+
const activeTransaction = transaction ?? session?.transaction(this.queryOptions_);
|
|
1548
|
+
if (!activeTransaction) {
|
|
1549
|
+
const error = new Error('No transaction available to commit');
|
|
1550
|
+
(0, instrument_1.setSpanError)(span, error);
|
|
1551
|
+
span.end();
|
|
1552
|
+
cb(error);
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
this._releaseOnEnd(session, activeTransaction, span);
|
|
1535
1556
|
try {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
return
|
|
1557
|
+
activeTransaction.setReadWriteTransactionOptions(options);
|
|
1558
|
+
activeTransaction.setQueuedMutations(mutations.proto());
|
|
1559
|
+
return activeTransaction.commit(options, (err, resp) => {
|
|
1539
1560
|
if (err) {
|
|
1540
1561
|
(0, instrument_1.setSpanError)(span, err);
|
|
1541
1562
|
}
|
package/build/src/index.d.ts
CHANGED
|
@@ -23,7 +23,9 @@ import { Database } from './database';
|
|
|
23
23
|
import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
|
|
24
24
|
import { InstanceConfig, CreateInstanceConfigCallback, CreateInstanceConfigResponse } from './instance-config';
|
|
25
25
|
import { grpc, GrpcClientOptions, CallOptions } from 'google-gax';
|
|
26
|
-
import {
|
|
26
|
+
import { protos } from '@google-cloud/spanner-api';
|
|
27
|
+
import google = protos.google;
|
|
28
|
+
import instanceAdmin = protos.google;
|
|
27
29
|
import { PagedOptions, PagedResponse, PagedCallback, PagedOptionsWithFilter, NormalCallback } from './common';
|
|
28
30
|
import { Session } from './session';
|
|
29
31
|
import { SessionPool } from './session-pool';
|
|
@@ -1247,7 +1249,6 @@ export { MutationSet };
|
|
|
1247
1249
|
* @property {constructor} SpannerClient
|
|
1248
1250
|
* Reference to {@link v1.SpannerClient}
|
|
1249
1251
|
*/
|
|
1250
|
-
import * as protos from '../protos/protos';
|
|
1251
1252
|
import IInstanceConfig = instanceAdmin.spanner.admin.instance.v1.IInstanceConfig;
|
|
1252
1253
|
import { RunTransactionOptions } from './transaction-runner';
|
|
1253
1254
|
export { v1, protos };
|