@google-cloud/spanner 8.0.0 → 8.2.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.
Files changed (54) hide show
  1. package/README.md +2 -0
  2. package/build/protos/google/spanner/admin/database/v1/spanner_database_admin.proto +35 -0
  3. package/build/protos/google/spanner/v1/change_stream.proto +451 -0
  4. package/build/protos/google/spanner/v1/commit_response.proto +9 -4
  5. package/build/protos/google/spanner/v1/transaction.proto +40 -356
  6. package/build/protos/protos.d.ts +2087 -4
  7. package/build/protos/protos.js +6191 -349
  8. package/build/protos/protos.json +556 -25
  9. package/build/src/batch-transaction.js +2 -2
  10. package/build/src/codec.js +20 -21
  11. package/build/src/common-grpc/service.js +10 -10
  12. package/build/src/common.d.ts +1 -0
  13. package/build/src/common.js +9 -1
  14. package/build/src/database.d.ts +3 -2
  15. package/build/src/database.js +16 -14
  16. package/build/src/helper.d.ts +90 -0
  17. package/build/src/helper.js +154 -0
  18. package/build/src/index.d.ts +36 -1
  19. package/build/src/index.js +179 -8
  20. package/build/src/instrument.js +3 -2
  21. package/build/src/metrics/constants.d.ts +36 -0
  22. package/build/src/metrics/constants.js +106 -0
  23. package/build/src/metrics/external-types.d.ts +20 -0
  24. package/build/src/metrics/external-types.js +32 -0
  25. package/build/src/metrics/interceptor.d.ts +13 -0
  26. package/build/src/metrics/interceptor.js +87 -0
  27. package/build/src/metrics/metrics-tracer-factory.d.ts +165 -0
  28. package/build/src/metrics/metrics-tracer-factory.js +389 -0
  29. package/build/src/metrics/metrics-tracer.d.ts +204 -0
  30. package/build/src/metrics/metrics-tracer.js +371 -0
  31. package/build/src/metrics/spanner-metrics-exporter.d.ts +35 -0
  32. package/build/src/metrics/spanner-metrics-exporter.js +119 -0
  33. package/build/src/metrics/transform.d.ts +144 -0
  34. package/build/src/metrics/transform.js +272 -0
  35. package/build/src/multiplexed-session.d.ts +1 -1
  36. package/build/src/multiplexed-session.js +2 -4
  37. package/build/src/partial-result-stream.js +9 -5
  38. package/build/src/session-factory.d.ts +34 -0
  39. package/build/src/session-factory.js +30 -0
  40. package/build/src/session-pool.js +1 -2
  41. package/build/src/table.d.ts +2 -0
  42. package/build/src/table.js +5 -0
  43. package/build/src/transaction-runner.d.ts +6 -0
  44. package/build/src/transaction-runner.js +8 -0
  45. package/build/src/transaction.d.ts +44 -1
  46. package/build/src/transaction.js +202 -49
  47. package/build/src/v1/database_admin_client.d.ts +34 -0
  48. package/build/src/v1/database_admin_client.js +167 -1
  49. package/build/src/v1/database_admin_client_config.json +4 -0
  50. package/build/src/v1/instance_admin_client.d.ts +120 -0
  51. package/build/src/v1/instance_admin_client.js +312 -13
  52. package/build/src/v1/spanner_client.js +108 -0
  53. package/build/src/v1/spanner_proto_list.json +1 -0
  54. package/package.json +15 -8
@@ -23,6 +23,7 @@ import { Json, JSONOptions, Type, Value } from './codec';
23
23
  import { PartialResultStream, ResumeToken, Row } from './partial-result-stream';
24
24
  import { Session } from './session';
25
25
  import { Key } from './table';
26
+ import { Span } from './instrument';
26
27
  import { google as spannerClient } from '../protos/protos';
27
28
  import { NormalCallback } from './common';
28
29
  import { google } from '../protos/protos';
@@ -173,6 +174,7 @@ export interface RunUpdateCallback {
173
174
  (err: null | grpc.ServiceError, rowCount: number): void;
174
175
  }
175
176
  export type CommitCallback = NormalCallback<spannerClient.spanner.v1.ICommitResponse>;
177
+ type PrecommitTokenProvider = spannerClient.spanner.v1.ITransaction | spannerClient.spanner.v1.IPartialResultSet | spannerClient.spanner.v1.IExecuteBatchDmlResponse | spannerClient.spanner.v1.ICommitResponse;
176
178
  /**
177
179
  * @typedef {object} TimestampBounds
178
180
  * @property {boolean} [strong=true] Read at a timestamp where all previously
@@ -233,7 +235,9 @@ export declare class Snapshot extends EventEmitter {
233
235
  protected _waitingRequests: Array<() => void>;
234
236
  protected _inlineBeginStarted: any;
235
237
  protected _useInRunner: boolean;
238
+ protected _latestPreCommitToken: spannerClient.spanner.v1.IMultiplexedSessionPrecommitToken | undefined | null;
236
239
  id?: Uint8Array | string;
240
+ multiplexedSessionPreviousTransactionId?: Uint8Array | string;
237
241
  ended: boolean;
238
242
  metadata?: spannerClient.spanner.v1.ITransaction;
239
243
  readTimestamp?: PreciseDate;
@@ -249,6 +253,7 @@ export declare class Snapshot extends EventEmitter {
249
253
  _observabilityOptions?: ObservabilityOptions;
250
254
  _traceConfig: traceConfig;
251
255
  protected _dbName?: string;
256
+ protected _mutationKey: spannerClient.spanner.v1.Mutation | null;
252
257
  /**
253
258
  * The transaction ID.
254
259
  *
@@ -293,6 +298,40 @@ export declare class Snapshot extends EventEmitter {
293
298
  * are specified for a query.
294
299
  */
295
300
  constructor(session: Session, options?: TimestampBounds, queryOptions?: IQueryOptions);
301
+ protected _updatePrecommitToken(resp: PrecommitTokenProvider): void;
302
+ /**
303
+ * Selects a single representative mutation from a list to be used as the
304
+ * transaction's `mutationKey`.
305
+ *
306
+ * This key is required by Spanner and is sent in the `BeginTransactionRequest`
307
+ * for read-write transactions that only contain mutations. The selection follows
308
+ * a two-tiered heuristic to choose the most significant mutation.
309
+ *
310
+ * The selection heuristic is as follows:
311
+ *
312
+ * 1. Priority of Operation Type: High-priority mutations (`delete`, `update`,
313
+ * `replace`, `insertOrUpdate`) are always chosen over low-priority
314
+ * (`insert`) mutations.
315
+ *
316
+ * 2. Selection Strategy:
317
+ * - If any high-priority mutations exist, one is chosen randomly from
318
+ * that group, ignoring the number of rows.
319
+ * - If only `insert` mutations exist, the one(s) with the largest number
320
+ * of rows are identified, and one is chosen randomly from that subset.
321
+ *
322
+ * @protected
323
+ * @param mutations The list of mutations from which to select the key.
324
+ */
325
+ protected _setMutationKey(mutations: spannerClient.spanner.v1.Mutation[]): void;
326
+ /**
327
+ * Modifies transaction selector to include the multiplexed session previous
328
+ * transaction id.
329
+ * This is essential for operations that use an `inline begin`.
330
+ * @protected
331
+ * @param transaction The transaction selector object that will be mutated
332
+ * to include the multiplexed session previous transaction id.
333
+ */
334
+ protected _setPreviousTransactionId(transaction: spannerClient.spanner.v1.ITransactionSelector): void;
296
335
  /**
297
336
  * @typedef {object} TransactionResponse
298
337
  * @property {string|Buffer} id The transaction ID.
@@ -909,7 +948,7 @@ export declare class Snapshot extends EventEmitter {
909
948
  *
910
949
  * @param {spannerClient.spanner.v1.ITransaction} resp Response object.
911
950
  */
912
- protected _update(resp: spannerClient.spanner.v1.ITransaction): void;
951
+ protected _update(resp: spannerClient.spanner.v1.ITransaction, span: Span): void;
913
952
  /**
914
953
  * Wrap `makeRequest` function with the lock to make sure the inline begin
915
954
  * transaction can happen only once.
@@ -1012,6 +1051,7 @@ export declare class Transaction extends Dml {
1012
1051
  commitTimestamp?: PreciseDate;
1013
1052
  commitTimestampProto?: spannerClient.protobuf.ITimestamp;
1014
1053
  private _queuedMutations;
1054
+ private _retryCommit;
1015
1055
  /**
1016
1056
  * Timestamp at which the transaction was committed. Will be populated once
1017
1057
  * {@link Transaction#commit} is called.
@@ -1506,6 +1546,8 @@ export declare class Transaction extends Dml {
1506
1546
  * (when any needed locks are acquired). The validation process succeeds only
1507
1547
  * if there are no conflicting committed transactions (that committed
1508
1548
  * mutations to the read data at a commit timestamp after the read timestamp).
1549
+ *
1550
+ * @deprecated Set readLockMode through setReadWriteTransactionOptions instead.
1509
1551
  */
1510
1552
  useOptimisticLock(): void;
1511
1553
  /**
@@ -1695,3 +1737,4 @@ export declare class PartitionedDml extends Dml {
1695
1737
  runUpdate(query: string | ExecuteSqlRequest): Promise<RunUpdateResponse>;
1696
1738
  runUpdate(query: string | ExecuteSqlRequest, callback: RunUpdateCallback): void;
1697
1739
  }
1740
+ export {};