@google-cloud/spanner 6.3.0 → 6.5.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 +22 -0
- package/README.md +3 -0
- package/build/protos/google/spanner/v1/result_set.proto +12 -0
- package/build/protos/google/spanner/v1/transaction.proto +39 -10
- package/build/protos/protos.d.ts +22 -0
- package/build/protos/protos.js +99 -3
- package/build/protos/protos.json +19 -1
- package/build/src/backup.d.ts +12 -12
- package/build/src/codec.d.ts +11 -1
- package/build/src/codec.js +34 -1
- package/build/src/common.d.ts +4 -4
- package/build/src/database.d.ts +30 -30
- package/build/src/database.js +10 -10
- package/build/src/index.d.ts +33 -15
- package/build/src/index.js +47 -26
- package/build/src/instance-config.d.ts +10 -10
- package/build/src/instance.d.ts +30 -30
- package/build/src/partial-result-stream.d.ts +1 -1
- package/build/src/session-pool.d.ts +64 -81
- package/build/src/session-pool.js +122 -251
- package/build/src/session.d.ts +8 -9
- package/build/src/table.d.ts +20 -20
- package/build/src/transaction-runner.d.ts +1 -1
- package/build/src/transaction-runner.js +4 -1
- package/build/src/transaction.d.ts +34 -11
- package/build/src/transaction.js +102 -13
- package/package.json +3 -3
package/build/src/common.d.ts
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
import { grpc, CallOptions, Operation as GaxOperation } from 'google-gax';
|
|
17
17
|
import { google as instanceAdmin } from '../protos/protos';
|
|
18
18
|
import { google as databaseAdmin } from '../protos/protos';
|
|
19
|
-
export
|
|
20
|
-
export
|
|
19
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
20
|
+
export type Schema = string | string[] | databaseAdmin.spanner.admin.database.v1.IUpdateDatabaseDdlRequest;
|
|
21
21
|
export interface ResourceCallback<Resource, Response> {
|
|
22
22
|
(err: grpc.ServiceError | null, resource?: Resource | null, response?: Response): void;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
25
|
-
export
|
|
24
|
+
export type PagedResponse<Item, Response> = [Item[], {} | null, Response];
|
|
25
|
+
export type RequestCallback<T, R = void> = R extends void ? NormalCallback<T> : PagedCallback<T, R>;
|
|
26
26
|
export interface NormalCallback<TResponse> {
|
|
27
27
|
(err: grpc.ServiceError | null, res?: TResponse | null): void;
|
|
28
28
|
}
|
package/build/src/database.d.ts
CHANGED
|
@@ -31,49 +31,49 @@ import { AsyncRunTransactionCallback, RunTransactionCallback, RunTransactionOpti
|
|
|
31
31
|
import { IOperation, LongRunningCallback, NormalCallback, PagedOptionsWithFilter, PagedResponse, RequestCallback, ResourceCallback, Schema } from './common';
|
|
32
32
|
import { Duplex, Readable } from 'stream';
|
|
33
33
|
import { EnumKey, RequestConfig, TranslateEnumKeys } from '.';
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
type CreateBatchTransactionCallback = ResourceCallback<BatchTransaction, google.spanner.v1.ITransaction | google.spanner.v1.ISession>;
|
|
35
|
+
type CreateBatchTransactionResponse = [
|
|
36
36
|
BatchTransaction,
|
|
37
37
|
google.spanner.v1.ITransaction | google.spanner.v1.ISession
|
|
38
38
|
];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
type DatabaseResponse = [Database, r.Response];
|
|
40
|
+
type DatabaseCallback = ResourceCallback<Database, r.Response>;
|
|
41
|
+
type GetSnapshotCallback = NormalCallback<Snapshot>;
|
|
42
|
+
type GetTransactionCallback = NormalCallback<Transaction>;
|
|
43
43
|
export interface SessionPoolConstructor {
|
|
44
44
|
new (database: Database, options?: SessionPoolOptions | null): SessionPoolInterface;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
47
|
-
export
|
|
46
|
+
export type UpdateSchemaCallback = ResourceCallback<GaxOperation, databaseAdmin.longrunning.IOperation>;
|
|
47
|
+
export type UpdateSchemaResponse = [
|
|
48
48
|
GaxOperation,
|
|
49
49
|
databaseAdmin.longrunning.IOperation
|
|
50
50
|
];
|
|
51
|
-
|
|
52
|
-
export
|
|
51
|
+
type PoolRequestCallback = RequestCallback<Session>;
|
|
52
|
+
export type GetSessionsOptions = PagedOptionsWithFilter;
|
|
53
53
|
/**
|
|
54
54
|
* IDatabase structure with database state enum translated to string form.
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
type IDatabaseTranslatedEnum = Omit<TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IDatabase, 'state', typeof databaseAdmin.spanner.admin.database.v1.Database.State>, 'restoreInfo'> & {
|
|
57
57
|
restoreInfo?: IRestoreInfoTranslatedEnum | null;
|
|
58
58
|
};
|
|
59
59
|
/**
|
|
60
60
|
* IRestoreInfo structure with restore source type enum translated to string form.
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
type IRestoreInfoTranslatedEnum = TranslateEnumKeys<databaseAdmin.spanner.admin.database.v1.IRestoreInfo, 'sourceType', typeof databaseAdmin.spanner.admin.database.v1.RestoreSourceType>;
|
|
63
|
+
type GetDatabaseMetadataResponse = [IDatabaseTranslatedEnum];
|
|
64
|
+
type GetDatabaseMetadataCallback = RequestCallback<IDatabaseTranslatedEnum>;
|
|
65
|
+
type GetSchemaCallback = RequestCallback<string, databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse>;
|
|
66
|
+
type GetSchemaResponse = [
|
|
67
67
|
string[],
|
|
68
68
|
databaseAdmin.spanner.admin.database.v1.IGetDatabaseDdlResponse
|
|
69
69
|
];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export
|
|
70
|
+
type GetSessionsCallback = RequestCallback<Session, google.spanner.v1.IListSessionsResponse>;
|
|
71
|
+
type GetSessionsResponse = PagedResponse<Session, google.spanner.v1.IListSessionsResponse>;
|
|
72
|
+
export type GetDatabaseConfig = GetConfig & databaseAdmin.spanner.admin.database.v1.IGetDatabaseRequest & {
|
|
73
73
|
gaxOptions?: CallOptions;
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
export
|
|
75
|
+
type DatabaseCloseResponse = [google.protobuf.IEmpty];
|
|
76
|
+
export type CreateSessionResponse = [
|
|
77
77
|
Session,
|
|
78
78
|
spannerClient.spanner.v1.ISession
|
|
79
79
|
];
|
|
@@ -83,28 +83,28 @@ export interface CreateSessionOptions {
|
|
|
83
83
|
} | null;
|
|
84
84
|
gaxOptions?: CallOptions;
|
|
85
85
|
}
|
|
86
|
-
export
|
|
86
|
+
export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
|
|
87
87
|
export interface BatchCreateSessionsOptions extends CreateSessionOptions {
|
|
88
88
|
count: number;
|
|
89
89
|
}
|
|
90
|
-
export
|
|
90
|
+
export type BatchCreateSessionsResponse = [
|
|
91
91
|
Session[],
|
|
92
92
|
spannerClient.spanner.v1.IBatchCreateSessionsResponse
|
|
93
93
|
];
|
|
94
|
-
export
|
|
95
|
-
export
|
|
96
|
-
export
|
|
94
|
+
export type BatchCreateSessionsCallback = ResourceCallback<Session[], spannerClient.spanner.v1.IBatchCreateSessionsResponse>;
|
|
95
|
+
export type DatabaseDeleteResponse = [databaseAdmin.protobuf.IEmpty];
|
|
96
|
+
export type DatabaseDeleteCallback = NormalCallback<databaseAdmin.protobuf.IEmpty>;
|
|
97
97
|
export interface CancelableDuplex extends Duplex {
|
|
98
98
|
cancel(): void;
|
|
99
99
|
}
|
|
100
|
-
export
|
|
101
|
-
export
|
|
100
|
+
export type RestoreDatabaseCallback = LongRunningCallback<Database>;
|
|
101
|
+
export type RestoreDatabaseResponse = [
|
|
102
102
|
Database,
|
|
103
103
|
GaxOperation,
|
|
104
104
|
databaseAdmin.longrunning.IOperation
|
|
105
105
|
];
|
|
106
|
-
export
|
|
107
|
-
export
|
|
106
|
+
export type GetRestoreInfoCallback = NormalCallback<IRestoreInfoTranslatedEnum>;
|
|
107
|
+
export type GetStateCallback = NormalCallback<EnumKey<typeof databaseAdmin.spanner.admin.database.v1.Database.State>>;
|
|
108
108
|
interface DatabaseRequest {
|
|
109
109
|
(config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
|
|
110
110
|
<T>(config: RequestConfig, callback: RequestCallback<T>): void;
|
package/build/src/database.js
CHANGED
|
@@ -241,7 +241,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
241
241
|
const options = typeof optionsOrCallback === 'object'
|
|
242
242
|
? optionsOrCallback
|
|
243
243
|
: {};
|
|
244
|
-
this.pool_.
|
|
244
|
+
this.pool_.getSession((err, session) => {
|
|
245
245
|
if (err) {
|
|
246
246
|
callback(err, null, undefined);
|
|
247
247
|
return;
|
|
@@ -539,7 +539,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
539
539
|
const options = typeof optionsOrCallback === 'object'
|
|
540
540
|
? optionsOrCallback
|
|
541
541
|
: {};
|
|
542
|
-
this.pool_.
|
|
542
|
+
this.pool_.getSession((err, session) => {
|
|
543
543
|
if (err) {
|
|
544
544
|
callback(err);
|
|
545
545
|
return;
|
|
@@ -564,7 +564,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
564
564
|
});
|
|
565
565
|
}
|
|
566
566
|
getTransaction(callback) {
|
|
567
|
-
this.pool_.
|
|
567
|
+
this.pool_.getSession((err, session, transaction) => {
|
|
568
568
|
if (!err) {
|
|
569
569
|
this._releaseOnEnd(session, transaction);
|
|
570
570
|
}
|
|
@@ -588,7 +588,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
588
588
|
}
|
|
589
589
|
makePooledRequest_(config, callback) {
|
|
590
590
|
const pool = this.pool_;
|
|
591
|
-
pool.
|
|
591
|
+
pool.getSession((err, session) => {
|
|
592
592
|
if (err) {
|
|
593
593
|
callback(err, null);
|
|
594
594
|
return;
|
|
@@ -632,7 +632,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
waitForSessionStream.on('reading', () => {
|
|
635
|
-
pool.
|
|
635
|
+
pool.getSession((err, session_) => {
|
|
636
636
|
if (err) {
|
|
637
637
|
destroyStream(err);
|
|
638
638
|
return;
|
|
@@ -706,7 +706,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
708
|
runPartitionedUpdate(query, callback) {
|
|
709
|
-
this.pool_.
|
|
709
|
+
this.pool_.getSession((err, session) => {
|
|
710
710
|
if (err) {
|
|
711
711
|
callback(err, 0);
|
|
712
712
|
return;
|
|
@@ -866,7 +866,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
866
866
|
*/
|
|
867
867
|
runStream(query, options) {
|
|
868
868
|
const proxyStream = through.obj();
|
|
869
|
-
this.pool_.
|
|
869
|
+
this.pool_.getSession((err, session) => {
|
|
870
870
|
if (err) {
|
|
871
871
|
proxyStream.destroy(err);
|
|
872
872
|
return;
|
|
@@ -915,7 +915,7 @@ class Database extends common.GrpcServiceObject {
|
|
|
915
915
|
const options = typeof optionsOrRunFn === 'object' && optionsOrRunFn
|
|
916
916
|
? optionsOrRunFn
|
|
917
917
|
: {};
|
|
918
|
-
this.pool_.
|
|
918
|
+
this.pool_.getSession((err, session, transaction) => {
|
|
919
919
|
if (err && (0, session_pool_1.isSessionNotFoundError)(err)) {
|
|
920
920
|
this.runTransaction(options, runFn);
|
|
921
921
|
return;
|
|
@@ -1004,13 +1004,13 @@ class Database extends common.GrpcServiceObject {
|
|
|
1004
1004
|
const options = typeof optionsOrRunFn === 'object'
|
|
1005
1005
|
? optionsOrRunFn
|
|
1006
1006
|
: {};
|
|
1007
|
-
const
|
|
1007
|
+
const getSession = this.pool_.getSession.bind(this.pool_);
|
|
1008
1008
|
// Loop to retry 'Session not found' errors.
|
|
1009
1009
|
// (and yes, we like while (true) more than for (;;) here)
|
|
1010
1010
|
// eslint-disable-next-line no-constant-condition
|
|
1011
1011
|
while (true) {
|
|
1012
1012
|
try {
|
|
1013
|
-
const [session, transaction] = await (0, promisify_1.promisify)(
|
|
1013
|
+
const [session, transaction] = await (0, promisify_1.promisify)(getSession)();
|
|
1014
1014
|
transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
|
|
1015
1015
|
const runner = new transaction_runner_1.AsyncTransactionRunner(session, transaction, runFn, options);
|
|
1016
1016
|
try {
|
package/build/src/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import { GrpcService } from './common-grpc/service';
|
|
|
18
18
|
import { PreciseDate } from '@google-cloud/precise-date';
|
|
19
19
|
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
|
20
20
|
import { common as p } from 'protobufjs';
|
|
21
|
-
import { Float, Int, Numeric, PGNumeric, Struct } from './codec';
|
|
21
|
+
import { Float, Int, Numeric, PGNumeric, PGJsonb, Struct } from './codec';
|
|
22
22
|
import { Backup } from './backup';
|
|
23
23
|
import { Database } from './database';
|
|
24
24
|
import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
|
|
@@ -31,21 +31,21 @@ import { SessionPool } from './session-pool';
|
|
|
31
31
|
import { Table } from './table';
|
|
32
32
|
import { PartitionedDml, Snapshot, Transaction } from './transaction';
|
|
33
33
|
import * as v1 from './v1';
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
34
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
35
|
+
export type GetInstancesOptions = PagedOptionsWithFilter;
|
|
36
|
+
export type GetInstancesResponse = PagedResponse<Instance, instanceAdmin.spanner.admin.instance.v1.IListInstancesResponse>;
|
|
37
|
+
export type GetInstancesCallback = PagedCallback<Instance, instanceAdmin.spanner.admin.instance.v1.IListInstancesResponse>;
|
|
38
|
+
export type GetInstanceConfigsOptions = PagedOptions;
|
|
39
|
+
export type GetInstanceConfigsResponse = PagedResponse<instanceAdmin.spanner.admin.instance.v1.IInstanceConfig, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigsResponse>;
|
|
40
|
+
export type GetInstanceConfigsCallback = PagedCallback<instanceAdmin.spanner.admin.instance.v1.IInstanceConfig, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigsResponse>;
|
|
41
41
|
export interface GetInstanceConfigOptions {
|
|
42
42
|
gaxOptions?: CallOptions;
|
|
43
43
|
}
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
44
|
+
export type GetInstanceConfigResponse = [IInstanceConfig];
|
|
45
|
+
export type GetInstanceConfigCallback = NormalCallback<IInstanceConfig>;
|
|
46
|
+
export type GetInstanceConfigOperationsOptions = PagedOptionsWithFilter;
|
|
47
|
+
export type GetInstanceConfigOperationsResponse = PagedResponse<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
|
|
48
|
+
export type GetInstanceConfigOperationsCallback = PagedCallback<IOperation, instanceAdmin.spanner.admin.instance.v1.IListInstanceConfigOperationsResponse>;
|
|
49
49
|
export interface SpannerOptions extends GrpcClientOptions {
|
|
50
50
|
apiEndpoint?: string;
|
|
51
51
|
servicePath?: string;
|
|
@@ -87,7 +87,7 @@ export interface CreateInstanceConfigRequest {
|
|
|
87
87
|
*
|
|
88
88
|
* @param E enum type.
|
|
89
89
|
*/
|
|
90
|
-
export
|
|
90
|
+
export type EnumKey<E extends {
|
|
91
91
|
[index: string]: unknown;
|
|
92
92
|
}> = keyof E;
|
|
93
93
|
/**
|
|
@@ -98,7 +98,7 @@ export declare type EnumKey<E extends {
|
|
|
98
98
|
* @param U name of the enum property.
|
|
99
99
|
* @param E enum type to translate.
|
|
100
100
|
*/
|
|
101
|
-
export
|
|
101
|
+
export type TranslateEnumKeys<T, U extends keyof T, E extends {
|
|
102
102
|
[index: string]: unknown;
|
|
103
103
|
}> = {
|
|
104
104
|
[P in keyof T]: P extends U ? EnumKey<E> | null | undefined : T[P];
|
|
@@ -897,6 +897,24 @@ declare class Spanner extends GrpcService {
|
|
|
897
897
|
* ```
|
|
898
898
|
*/
|
|
899
899
|
static pgNumeric(value: any): PGNumeric;
|
|
900
|
+
/**
|
|
901
|
+
* Helper function to get a Cloud Spanner pgJsonb object.
|
|
902
|
+
*
|
|
903
|
+
* @param {object|string} value The pgJsonb value as a string or object.
|
|
904
|
+
* @returns {PGJsonb}
|
|
905
|
+
*
|
|
906
|
+
* @example
|
|
907
|
+
* ```
|
|
908
|
+
* const {Spanner} = require('@google-cloud/spanner');
|
|
909
|
+
* const pgJsonb1 = Spanner.pgJsonb({rating: 6});
|
|
910
|
+
* const pgJsonb2 = Spanner.pgJsonb(`[
|
|
911
|
+
* {
|
|
912
|
+
* "name": null,
|
|
913
|
+
* "open": true
|
|
914
|
+
* }]`)
|
|
915
|
+
* ```
|
|
916
|
+
*/
|
|
917
|
+
static pgJsonb(value: any): PGJsonb;
|
|
900
918
|
/**
|
|
901
919
|
* Helper function to get a Cloud Spanner Struct object.
|
|
902
920
|
*
|
package/build/src/index.js
CHANGED
|
@@ -94,6 +94,32 @@ const gcpApiConfig = require('./spanner_grpc_config.json');
|
|
|
94
94
|
* @param {ClientConfig} [options] Configuration options.
|
|
95
95
|
*/
|
|
96
96
|
class Spanner extends service_1.GrpcService {
|
|
97
|
+
/**
|
|
98
|
+
* Gets the configured Spanner emulator host from an environment variable.
|
|
99
|
+
*/
|
|
100
|
+
static getSpannerEmulatorHost() {
|
|
101
|
+
const endpointWithPort = process.env.SPANNER_EMULATOR_HOST;
|
|
102
|
+
if (endpointWithPort) {
|
|
103
|
+
if (endpointWithPort.startsWith('http:') ||
|
|
104
|
+
endpointWithPort.startsWith('https:')) {
|
|
105
|
+
throw new google_gax_1.GoogleError('SPANNER_EMULATOR_HOST must not start with a protocol specification (http/https)');
|
|
106
|
+
}
|
|
107
|
+
const index = endpointWithPort.indexOf(':');
|
|
108
|
+
if (index > -1) {
|
|
109
|
+
const portName = endpointWithPort.substring(index + 1);
|
|
110
|
+
const port = +portName;
|
|
111
|
+
if (!port || port < 1 || port > 65535) {
|
|
112
|
+
throw new google_gax_1.GoogleError(`Invalid port number: ${portName}`);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
endpoint: endpointWithPort.substring(0, index),
|
|
116
|
+
port: +endpointWithPort.substring(index + 1),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return { endpoint: endpointWithPort };
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
97
123
|
constructor(options) {
|
|
98
124
|
const scopes = [];
|
|
99
125
|
const clientClasses = [
|
|
@@ -152,32 +178,6 @@ class Spanner extends service_1.GrpcService {
|
|
|
152
178
|
[common_1.CLOUD_RESOURCE_HEADER]: this.projectFormattedName_,
|
|
153
179
|
};
|
|
154
180
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Gets the configured Spanner emulator host from an environment variable.
|
|
157
|
-
*/
|
|
158
|
-
static getSpannerEmulatorHost() {
|
|
159
|
-
const endpointWithPort = process.env.SPANNER_EMULATOR_HOST;
|
|
160
|
-
if (endpointWithPort) {
|
|
161
|
-
if (endpointWithPort.startsWith('http:') ||
|
|
162
|
-
endpointWithPort.startsWith('https:')) {
|
|
163
|
-
throw new google_gax_1.GoogleError('SPANNER_EMULATOR_HOST must not start with a protocol specification (http/https)');
|
|
164
|
-
}
|
|
165
|
-
const index = endpointWithPort.indexOf(':');
|
|
166
|
-
if (index > -1) {
|
|
167
|
-
const portName = endpointWithPort.substring(index + 1);
|
|
168
|
-
const port = +portName;
|
|
169
|
-
if (!port || port < 1 || port > 65535) {
|
|
170
|
-
throw new google_gax_1.GoogleError(`Invalid port number: ${portName}`);
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
endpoint: endpointWithPort.substring(0, index),
|
|
174
|
-
port: +endpointWithPort.substring(index + 1),
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return { endpoint: endpointWithPort };
|
|
178
|
-
}
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
181
|
/** Closes this Spanner client and cleans up all resources used by it. */
|
|
182
182
|
close() {
|
|
183
183
|
this.clients_.forEach(c => {
|
|
@@ -829,6 +829,26 @@ class Spanner extends service_1.GrpcService {
|
|
|
829
829
|
static pgNumeric(value) {
|
|
830
830
|
return new codec_1.codec.PGNumeric(value);
|
|
831
831
|
}
|
|
832
|
+
/**
|
|
833
|
+
* Helper function to get a Cloud Spanner pgJsonb object.
|
|
834
|
+
*
|
|
835
|
+
* @param {object|string} value The pgJsonb value as a string or object.
|
|
836
|
+
* @returns {PGJsonb}
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```
|
|
840
|
+
* const {Spanner} = require('@google-cloud/spanner');
|
|
841
|
+
* const pgJsonb1 = Spanner.pgJsonb({rating: 6});
|
|
842
|
+
* const pgJsonb2 = Spanner.pgJsonb(`[
|
|
843
|
+
* {
|
|
844
|
+
* "name": null,
|
|
845
|
+
* "open": true
|
|
846
|
+
* }]`)
|
|
847
|
+
* ```
|
|
848
|
+
*/
|
|
849
|
+
static pgJsonb(value) {
|
|
850
|
+
return new codec_1.codec.PGJsonb(value);
|
|
851
|
+
}
|
|
832
852
|
/**
|
|
833
853
|
* Helper function to get a Cloud Spanner Struct object.
|
|
834
854
|
*
|
|
@@ -876,6 +896,7 @@ Spanner.GOOGLE_STANDARD_SQL = protos_1.google.spanner.admin.database.v1.Database
|
|
|
876
896
|
'int',
|
|
877
897
|
'numeric',
|
|
878
898
|
'pgNumeric',
|
|
899
|
+
'pgJsonb',
|
|
879
900
|
'operation',
|
|
880
901
|
'timestamp',
|
|
881
902
|
],
|
|
@@ -18,20 +18,20 @@ import { Operation as GaxOperation } from 'google-gax/build/src/longRunningCalls
|
|
|
18
18
|
import { LongRunningCallback, RequestCallback, ResourceCallback, NormalCallback } from './common';
|
|
19
19
|
import { GetInstanceConfigCallback, GetInstanceConfigOptions, GetInstanceConfigResponse, RequestConfig, Spanner } from './index';
|
|
20
20
|
import { CallOptions } from 'google-gax';
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
21
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
22
|
+
export type CreateInstanceConfigCallback = LongRunningCallback<InstanceConfig>;
|
|
23
|
+
export type SetInstanceConfigMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
|
|
24
|
+
export type DeleteInstanceConfigCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
|
|
25
|
+
export type ExistsInstanceConfigCallback = NormalCallback<boolean>;
|
|
26
|
+
export type CreateInstanceConfigResponse = [
|
|
27
27
|
InstanceConfig,
|
|
28
28
|
GaxOperation,
|
|
29
29
|
IOperation
|
|
30
30
|
];
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
31
|
+
export type SetInstanceConfigMetadataResponse = [GaxOperation, IOperation];
|
|
32
|
+
export type DeleteInstanceConfigResponse = [instanceAdmin.protobuf.IEmpty];
|
|
33
|
+
export type ExistsInstanceConfigResponse = boolean;
|
|
34
|
+
export type IInstanceConfig = instanceAdmin.spanner.admin.instance.v1.IInstanceConfig;
|
|
35
35
|
interface InstanceConfigRequest {
|
|
36
36
|
(config: RequestConfig, callback: ResourceCallback<GaxOperation, IOperation>): void;
|
|
37
37
|
<T>(config: RequestConfig, callback: RequestCallback<T>): void;
|
package/build/src/instance.d.ts
CHANGED
|
@@ -28,46 +28,46 @@ import { google as instanceAdmin } from '../protos/protos';
|
|
|
28
28
|
import { google as databaseAdmin } from '../protos/protos';
|
|
29
29
|
import { google as spannerClient } from '../protos/protos';
|
|
30
30
|
import { CreateInstanceRequest } from './index';
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
31
|
+
export type IBackup = databaseAdmin.spanner.admin.database.v1.IBackup;
|
|
32
|
+
export type IDatabase = databaseAdmin.spanner.admin.database.v1.IDatabase;
|
|
33
|
+
export type IInstance = instanceAdmin.spanner.admin.instance.v1.IInstance;
|
|
34
|
+
export type IOperation = instanceAdmin.longrunning.IOperation;
|
|
35
|
+
export type CreateInstanceResponse = [Instance, GaxOperation, IOperation];
|
|
36
|
+
export type CreateDatabaseResponse = [Database, GaxOperation, IOperation];
|
|
37
|
+
export type DeleteInstanceResponse = [instanceAdmin.protobuf.IEmpty];
|
|
38
|
+
export type ExistsInstanceResponse = [boolean];
|
|
39
|
+
export type GetInstanceResponse = [Instance, IInstance];
|
|
40
|
+
export type GetInstanceMetadataResponse = [IInstance];
|
|
41
41
|
export interface GetInstanceMetadataOptions {
|
|
42
42
|
fieldNames?: string | string[];
|
|
43
43
|
gaxOptions?: CallOptions;
|
|
44
44
|
}
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
45
|
+
export type GetDatabasesResponse = PagedResponse<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
|
|
46
|
+
export type SetInstanceMetadataResponse = [GaxOperation, IOperation];
|
|
47
|
+
export type GetBackupsResponse = PagedResponse<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
|
|
48
|
+
export type GetBackupOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
|
|
49
|
+
export type GetDatabaseOperationsResponse = PagedResponse<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
|
|
50
50
|
export interface CreateDatabaseOptions extends databaseAdmin.spanner.admin.database.v1.ICreateDatabaseRequest {
|
|
51
51
|
poolOptions?: SessionPoolOptions;
|
|
52
52
|
poolCtor?: SessionPool;
|
|
53
53
|
schema?: string | string[];
|
|
54
54
|
gaxOptions?: CallOptions;
|
|
55
55
|
}
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
56
|
+
export type GetDatabasesOptions = PagedOptions;
|
|
57
|
+
export type CreateInstanceCallback = LongRunningCallback<Instance>;
|
|
58
|
+
export type CreateDatabaseCallback = LongRunningCallback<Database>;
|
|
59
|
+
export type DeleteInstanceCallback = NormalCallback<instanceAdmin.protobuf.IEmpty>;
|
|
60
|
+
export type ExistsInstanceCallback = NormalCallback<boolean>;
|
|
61
|
+
export type GetDatabasesCallback = RequestCallback<Database, databaseAdmin.spanner.admin.database.v1.IListDatabasesResponse>;
|
|
62
|
+
export type GetInstanceCallback = ResourceCallback<Instance, IInstance>;
|
|
63
|
+
export type GetInstanceMetadataCallback = NormalCallback<IInstance>;
|
|
64
|
+
export type SetInstanceMetadataCallback = ResourceCallback<GaxOperation, IOperation>;
|
|
65
|
+
export type GetBackupsOptions = PagedOptionsWithFilter;
|
|
66
|
+
export type GetBackupsCallback = RequestCallback<Backup, databaseAdmin.spanner.admin.database.v1.IListBackupsResponse>;
|
|
67
|
+
export type GetBackupOperationsOptions = PagedOptionsWithFilter;
|
|
68
|
+
export type GetBackupOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListBackupOperationsResponse>;
|
|
69
|
+
export type GetDatabaseOperationsOptions = PagedOptionsWithFilter;
|
|
70
|
+
export type GetDatabaseOperationsCallback = RequestCallback<IOperation, databaseAdmin.spanner.admin.database.v1.IListDatabaseOperationsResponse>;
|
|
71
71
|
export interface GetInstanceConfig extends GetConfig, CreateInstanceRequest, GetInstanceMetadataOptions {
|
|
72
72
|
}
|
|
73
73
|
interface InstanceRequest {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { Readable, Transform } from 'stream';
|
|
18
18
|
import { JSONOptions, Json, Field, Value } from './codec';
|
|
19
19
|
import { google } from '../protos/protos';
|
|
20
|
-
export
|
|
20
|
+
export type ResumeToken = string | Uint8Array;
|
|
21
21
|
/**
|
|
22
22
|
* @callback RequestFunction
|
|
23
23
|
* @param {string} [resumeToken] The token used to resume getting results.
|