@google-cloud/spanner 7.5.0 → 7.7.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.
@@ -61,6 +61,15 @@ declare abstract class WrappedNumber {
61
61
  value: string | number;
62
62
  abstract valueOf(): number;
63
63
  }
64
+ /**
65
+ * @typedef Float32
66
+ * @see Spanner.float32
67
+ */
68
+ export declare class Float32 extends WrappedNumber {
69
+ value: number;
70
+ constructor(value: number);
71
+ valueOf(): number;
72
+ }
64
73
  /**
65
74
  * @typedef Float
66
75
  * @see Spanner.float
@@ -209,6 +218,7 @@ interface FieldType extends Type {
209
218
  /**
210
219
  * @typedef {object} ParamType
211
220
  * @property {string} type The param type. Must be one of the following:
221
+ * - float32
212
222
  * - float64
213
223
  * - int64
214
224
  * - numeric
@@ -282,6 +292,7 @@ export declare const codec: {
282
292
  convertProtoTimestampToDate: typeof convertProtoTimestampToDate;
283
293
  createTypeObject: typeof createTypeObject;
284
294
  SpannerDate: typeof SpannerDate;
295
+ Float32: typeof Float32;
285
296
  Float: typeof Float;
286
297
  Int: typeof Int;
287
298
  Numeric: typeof Numeric;
@@ -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.SpannerDate = void 0;
3
+ exports.codec = exports.PGOid = exports.PGJsonb = 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
  *
@@ -86,6 +86,20 @@ exports.SpannerDate = SpannerDate;
86
86
  */
87
87
  class WrappedNumber {
88
88
  }
89
+ /**
90
+ * @typedef Float32
91
+ * @see Spanner.float32
92
+ */
93
+ class Float32 extends WrappedNumber {
94
+ constructor(value) {
95
+ super();
96
+ this.value = value;
97
+ }
98
+ valueOf() {
99
+ return Number(this.value);
100
+ }
101
+ }
102
+ exports.Float32 = Float32;
89
103
  /**
90
104
  * @typedef Float
91
105
  * @see Spanner.float
@@ -324,6 +338,10 @@ function decode(value, type) {
324
338
  case 'BYTES':
325
339
  decoded = Buffer.from(decoded, 'base64');
326
340
  break;
341
+ case protos_1.google.spanner.v1.TypeCode.FLOAT32:
342
+ case 'FLOAT32':
343
+ decoded = new Float32(decoded);
344
+ break;
327
345
  case protos_1.google.spanner.v1.TypeCode.FLOAT64:
328
346
  case 'FLOAT64':
329
347
  decoded = new Float(decoded);
@@ -450,6 +468,7 @@ const TypeCode = {
450
468
  bool: 'BOOL',
451
469
  int64: 'INT64',
452
470
  pgOid: 'INT64',
471
+ float32: 'FLOAT32',
453
472
  float64: 'FLOAT64',
454
473
  numeric: 'NUMERIC',
455
474
  pgNumeric: 'NUMERIC',
@@ -469,6 +488,7 @@ const TypeCode = {
469
488
  /**
470
489
  * @typedef {object} ParamType
471
490
  * @property {string} type The param type. Must be one of the following:
491
+ * - float32
472
492
  * - float64
473
493
  * - int64
474
494
  * - numeric
@@ -501,6 +521,9 @@ const TypeCode = {
501
521
  */
502
522
  function getType(value) {
503
523
  const isSpecialNumber = is.infinite(value) || (is.number(value) && isNaN(value));
524
+ if (value instanceof Float32) {
525
+ return { type: 'float32' };
526
+ }
504
527
  if (is.decimal(value) || isSpecialNumber || value instanceof Float) {
505
528
  return { type: 'float64' };
506
529
  }
@@ -647,6 +670,7 @@ exports.codec = {
647
670
  convertProtoTimestampToDate,
648
671
  createTypeObject,
649
672
  SpannerDate,
673
+ Float32,
650
674
  Float,
651
675
  Int,
652
676
  Numeric,
@@ -106,6 +106,12 @@ export interface GetIamPolicyOptions {
106
106
  requestedPolicyVersion?: number | null;
107
107
  gaxOptions?: CallOptions;
108
108
  }
109
+ /**
110
+ * @typedef {object} GetTransactionOptions
111
+ * * @property {boolean} [optimisticLock] The optimistic lock a
112
+ * {@link Transaction} should use while running.
113
+ */
114
+ export type GetTransactionOptions = Omit<RunTransactionOptions, 'timeout'>;
109
115
  export type CreateSessionCallback = ResourceCallback<Session, spannerClient.spanner.v1.ISession>;
110
116
  export interface BatchCreateSessionsOptions extends CreateSessionOptions {
111
117
  count: number;
@@ -1140,7 +1146,7 @@ declare class Database extends common.GrpcServiceObject {
1140
1146
  * });
1141
1147
  * ```
1142
1148
  */
1143
- getTransaction(): Promise<[Transaction]>;
1149
+ getTransaction(optionsOrCallback?: GetTransactionOptions): Promise<[Transaction]>;
1144
1150
  getTransaction(callback: GetTransactionCallback): void;
1145
1151
  /**
1146
1152
  * Query object for listing database operations.
@@ -617,12 +617,24 @@ class Database extends common.GrpcServiceObject {
617
617
  });
618
618
  });
619
619
  }
620
- getTransaction(callback) {
620
+ getTransaction(optionsOrCallback, callback) {
621
+ const cb = typeof optionsOrCallback === 'function'
622
+ ? optionsOrCallback
623
+ : callback;
624
+ const options = typeof optionsOrCallback === 'object' && optionsOrCallback
625
+ ? optionsOrCallback
626
+ : {};
621
627
  this.pool_.getSession((err, session, transaction) => {
628
+ if (options.requestOptions) {
629
+ transaction.requestOptions = Object.assign(transaction.requestOptions || {}, options.requestOptions);
630
+ }
631
+ if (options.optimisticLock) {
632
+ transaction.useOptimisticLock();
633
+ }
622
634
  if (!err) {
623
635
  this._releaseOnEnd(session, transaction);
624
636
  }
625
- callback(err, transaction);
637
+ cb(err, transaction);
626
638
  });
627
639
  }
628
640
  async getOperations(optionsOrCallback) {
@@ -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, PGJsonb, SpannerDate, Struct } from './codec';
21
+ import { Float32, Float, Int, Numeric, PGNumeric, PGJsonb, SpannerDate, Struct } from './codec';
22
22
  import { Backup } from './backup';
23
23
  import { Database } from './database';
24
24
  import { Instance, CreateInstanceCallback, CreateInstanceResponse } from './instance';
@@ -885,6 +885,19 @@ declare class Spanner extends GrpcService {
885
885
  * ```
886
886
  */
887
887
  static timestamp(value?: string | number | p.ITimestamp | PreciseDate): PreciseDate;
888
+ /**
889
+ * Helper function to get a Cloud Spanner Float32 object.
890
+ *
891
+ * @param {string|number} value The float as a number or string.
892
+ * @returns {Float32}
893
+ *
894
+ * @example
895
+ * ```
896
+ * const {Spanner} = require('@google-cloud/spanner');
897
+ * const float = Spanner.float32(10);
898
+ * ```
899
+ */
900
+ static float32(value: any): Float32;
888
901
  /**
889
902
  * Helper function to get a Cloud Spanner Float64 object.
890
903
  *
@@ -1110,4 +1123,4 @@ declare const _default: {
1110
1123
  Spanner: typeof Spanner;
1111
1124
  };
1112
1125
  export default _default;
1113
- export { Float, Int, Struct, Numeric, PGNumeric, SpannerDate };
1126
+ export { Float32, Float, Int, Struct, Numeric, PGNumeric, SpannerDate };
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.SpannerDate = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
18
+ exports.SpannerDate = exports.PGNumeric = exports.Numeric = exports.Struct = exports.Int = exports.Float = exports.Float32 = exports.protos = exports.v1 = exports.Transaction = exports.Snapshot = exports.PartitionedDml = exports.Table = exports.SessionPool = exports.Session = exports.Backup = exports.Database = exports.InstanceConfig = exports.Instance = exports.Spanner = void 0;
19
19
  const service_1 = require("./common-grpc/service");
20
20
  const precise_date_1 = require("@google-cloud/precise-date");
21
21
  const projectify_1 = require("@google-cloud/projectify");
@@ -26,6 +26,7 @@ const path = require("path");
26
26
  const streamEvents = require("stream-events");
27
27
  const through = require("through2");
28
28
  const codec_1 = require("./codec");
29
+ Object.defineProperty(exports, "Float32", { enumerable: true, get: function () { return codec_1.Float32; } });
29
30
  Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return codec_1.Float; } });
30
31
  Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return codec_1.Int; } });
31
32
  Object.defineProperty(exports, "Numeric", { enumerable: true, get: function () { return codec_1.Numeric; } });
@@ -825,6 +826,21 @@ class Spanner extends service_1.GrpcService {
825
826
  }
826
827
  return new precise_date_1.PreciseDate(value);
827
828
  }
829
+ /**
830
+ * Helper function to get a Cloud Spanner Float32 object.
831
+ *
832
+ * @param {string|number} value The float as a number or string.
833
+ * @returns {Float32}
834
+ *
835
+ * @example
836
+ * ```
837
+ * const {Spanner} = require('@google-cloud/spanner');
838
+ * const float = Spanner.float32(10);
839
+ * ```
840
+ */
841
+ static float32(value) {
842
+ return new codec_1.codec.Float32(value);
843
+ }
828
844
  /**
829
845
  * Helper function to get a Cloud Spanner Float64 object.
830
846
  *
@@ -946,6 +962,7 @@ Spanner.GOOGLE_STANDARD_SQL = protos_1.google.spanner.admin.database.v1.Database
946
962
  (0, promisify_1.promisifyAll)(Spanner, {
947
963
  exclude: [
948
964
  'date',
965
+ 'float32',
949
966
  'float',
950
967
  'instance',
951
968
  'instanceConfig',
@@ -78,7 +78,7 @@ class DatabaseAdminClient {
78
78
  * ```
79
79
  */
80
80
  constructor(opts, gaxInstance) {
81
- var _a, _b, _c, _d;
81
+ var _a, _b, _c, _d, _e;
82
82
  this._terminated = false;
83
83
  this.descriptors = {
84
84
  page: {},
@@ -93,14 +93,17 @@ class DatabaseAdminClient {
93
93
  (opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== (opts === null || opts === void 0 ? void 0 : opts.universeDomain)) {
94
94
  throw new Error('Please set either universe_domain or universeDomain, but not both.');
95
95
  }
96
+ const universeDomainEnvVar = typeof process === 'object' && typeof process.env === 'object'
97
+ ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
98
+ : undefined;
96
99
  this._universeDomain =
97
- (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : 'googleapis.com';
100
+ (_c = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.universeDomain) !== null && _a !== void 0 ? _a : opts === null || opts === void 0 ? void 0 : opts.universe_domain) !== null && _b !== void 0 ? _b : universeDomainEnvVar) !== null && _c !== void 0 ? _c : 'googleapis.com';
98
101
  this._servicePath = 'spanner.' + this._universeDomain;
99
102
  const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || this._servicePath;
100
103
  this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
101
104
  const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
102
- const clientConfig = (_c = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _c !== void 0 ? _c : {};
103
- const fallback = (_d = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _d !== void 0 ? _d : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
105
+ const clientConfig = (_d = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _d !== void 0 ? _d : {};
106
+ const fallback = (_e = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _e !== void 0 ? _e : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
104
107
  opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
105
108
  // Request numeric enum values if REST transport is used.
106
109
  opts.numericEnums = true;
@@ -130,7 +133,7 @@ class DatabaseAdminClient {
130
133
  }
131
134
  // Determine the client header string.
132
135
  const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
133
- if (typeof process !== 'undefined' && 'versions' in process) {
136
+ if (typeof process === 'object' && 'versions' in process) {
134
137
  clientHeader.push(`gl-node/${process.versions.node}`);
135
138
  }
136
139
  else {
@@ -324,7 +327,7 @@ class DatabaseAdminClient {
324
327
  * @returns {string} The DNS address for this service.
325
328
  */
326
329
  static get servicePath() {
327
- if (typeof process !== undefined &&
330
+ if (typeof process === 'object' &&
328
331
  typeof process.emitWarning === 'function') {
329
332
  process.emitWarning('Static servicePath is deprecated, please use the instance method instead.', 'DeprecationWarning');
330
333
  }
@@ -336,7 +339,7 @@ class DatabaseAdminClient {
336
339
  * @returns {string} The DNS address for this service.
337
340
  */
338
341
  static get apiEndpoint() {
339
- if (typeof process !== undefined &&
342
+ if (typeof process === 'object' &&
340
343
  typeof process.emitWarning === 'function') {
341
344
  process.emitWarning('Static apiEndpoint is deprecated, please use the instance method instead.', 'DeprecationWarning');
342
345
  }
@@ -2,172 +2,24 @@
2
2
  "schema": "1.0",
3
3
  "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
4
4
  "language": "typescript",
5
- "protoPackage": "google.spanner.admin.instance.v1",
6
- "libraryPackage": "@google-cloud/spanner",
5
+ "protoPackage": "google.spanner.executor.v1",
6
+ "libraryPackage": "@google-cloud/executor",
7
7
  "services": {
8
- "InstanceAdmin": {
8
+ "SpannerExecutorProxy": {
9
9
  "clients": {
10
10
  "grpc": {
11
- "libraryClient": "InstanceAdminClient",
11
+ "libraryClient": "SpannerExecutorProxyClient",
12
12
  "rpcs": {
13
- "GetInstanceConfig": {
13
+ "ExecuteActionAsync": {
14
14
  "methods": [
15
- "getInstanceConfig"
16
- ]
17
- },
18
- "DeleteInstanceConfig": {
19
- "methods": [
20
- "deleteInstanceConfig"
21
- ]
22
- },
23
- "GetInstance": {
24
- "methods": [
25
- "getInstance"
26
- ]
27
- },
28
- "DeleteInstance": {
29
- "methods": [
30
- "deleteInstance"
31
- ]
32
- },
33
- "SetIamPolicy": {
34
- "methods": [
35
- "setIamPolicy"
36
- ]
37
- },
38
- "GetIamPolicy": {
39
- "methods": [
40
- "getIamPolicy"
41
- ]
42
- },
43
- "TestIamPermissions": {
44
- "methods": [
45
- "testIamPermissions"
46
- ]
47
- },
48
- "CreateInstanceConfig": {
49
- "methods": [
50
- "createInstanceConfig"
51
- ]
52
- },
53
- "UpdateInstanceConfig": {
54
- "methods": [
55
- "updateInstanceConfig"
56
- ]
57
- },
58
- "CreateInstance": {
59
- "methods": [
60
- "createInstance"
61
- ]
62
- },
63
- "UpdateInstance": {
64
- "methods": [
65
- "updateInstance"
66
- ]
67
- },
68
- "ListInstanceConfigs": {
69
- "methods": [
70
- "listInstanceConfigs",
71
- "listInstanceConfigsStream",
72
- "listInstanceConfigsAsync"
73
- ]
74
- },
75
- "ListInstanceConfigOperations": {
76
- "methods": [
77
- "listInstanceConfigOperations",
78
- "listInstanceConfigOperationsStream",
79
- "listInstanceConfigOperationsAsync"
80
- ]
81
- },
82
- "ListInstances": {
83
- "methods": [
84
- "listInstances",
85
- "listInstancesStream",
86
- "listInstancesAsync"
15
+ "executeActionAsync"
87
16
  ]
88
17
  }
89
18
  }
90
19
  },
91
20
  "grpc-fallback": {
92
- "libraryClient": "InstanceAdminClient",
93
- "rpcs": {
94
- "GetInstanceConfig": {
95
- "methods": [
96
- "getInstanceConfig"
97
- ]
98
- },
99
- "DeleteInstanceConfig": {
100
- "methods": [
101
- "deleteInstanceConfig"
102
- ]
103
- },
104
- "GetInstance": {
105
- "methods": [
106
- "getInstance"
107
- ]
108
- },
109
- "DeleteInstance": {
110
- "methods": [
111
- "deleteInstance"
112
- ]
113
- },
114
- "SetIamPolicy": {
115
- "methods": [
116
- "setIamPolicy"
117
- ]
118
- },
119
- "GetIamPolicy": {
120
- "methods": [
121
- "getIamPolicy"
122
- ]
123
- },
124
- "TestIamPermissions": {
125
- "methods": [
126
- "testIamPermissions"
127
- ]
128
- },
129
- "CreateInstanceConfig": {
130
- "methods": [
131
- "createInstanceConfig"
132
- ]
133
- },
134
- "UpdateInstanceConfig": {
135
- "methods": [
136
- "updateInstanceConfig"
137
- ]
138
- },
139
- "CreateInstance": {
140
- "methods": [
141
- "createInstance"
142
- ]
143
- },
144
- "UpdateInstance": {
145
- "methods": [
146
- "updateInstance"
147
- ]
148
- },
149
- "ListInstanceConfigs": {
150
- "methods": [
151
- "listInstanceConfigs",
152
- "listInstanceConfigsStream",
153
- "listInstanceConfigsAsync"
154
- ]
155
- },
156
- "ListInstanceConfigOperations": {
157
- "methods": [
158
- "listInstanceConfigOperations",
159
- "listInstanceConfigOperationsStream",
160
- "listInstanceConfigOperationsAsync"
161
- ]
162
- },
163
- "ListInstances": {
164
- "methods": [
165
- "listInstances",
166
- "listInstancesStream",
167
- "listInstancesAsync"
168
- ]
169
- }
170
- }
21
+ "libraryClient": "SpannerExecutorProxyClient",
22
+ "rpcs": {}
171
23
  }
172
24
  }
173
25
  }
@@ -1,3 +1,4 @@
1
1
  export { SpannerClient } from './spanner_client';
2
2
  export { DatabaseAdminClient } from './database_admin_client';
3
3
  export { InstanceAdminClient } from './instance_admin_client';
4
+ export { SpannerExecutorProxyClient } from './spanner_executor_proxy_client';
@@ -17,11 +17,13 @@
17
17
  // ** https://github.com/googleapis/gapic-generator-typescript **
18
18
  // ** All changes to this file may be overwritten. **
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.InstanceAdminClient = exports.DatabaseAdminClient = exports.SpannerClient = void 0;
20
+ exports.SpannerExecutorProxyClient = exports.InstanceAdminClient = exports.DatabaseAdminClient = exports.SpannerClient = void 0;
21
21
  var spanner_client_1 = require("./spanner_client");
22
22
  Object.defineProperty(exports, "SpannerClient", { enumerable: true, get: function () { return spanner_client_1.SpannerClient; } });
23
23
  var database_admin_client_1 = require("./database_admin_client");
24
24
  Object.defineProperty(exports, "DatabaseAdminClient", { enumerable: true, get: function () { return database_admin_client_1.DatabaseAdminClient; } });
25
25
  var instance_admin_client_1 = require("./instance_admin_client");
26
26
  Object.defineProperty(exports, "InstanceAdminClient", { enumerable: true, get: function () { return instance_admin_client_1.InstanceAdminClient; } });
27
+ var spanner_executor_proxy_client_1 = require("./spanner_executor_proxy_client");
28
+ Object.defineProperty(exports, "SpannerExecutorProxyClient", { enumerable: true, get: function () { return spanner_executor_proxy_client_1.SpannerExecutorProxyClient; } });
27
29
  //# sourceMappingURL=index.js.map