@google-cloud/spanner
Advanced tools
Comparing version 5.11.1 to 5.12.0
@@ -26,2 +26,3 @@ /*! | ||
import { grpc, CallOptions } from 'google-gax'; | ||
import IRequestOptions = google.spanner.v1.IRequestOptions; | ||
export declare type GetSessionResponse = [Session, r.Response]; | ||
@@ -128,3 +129,3 @@ /** | ||
*/ | ||
transaction(queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions): Transaction; | ||
transaction(queryOptions?: google.spanner.v1.ExecuteSqlRequest.IQueryOptions, requestOptions?: Pick<IRequestOptions, 'transactionTag'>): Transaction; | ||
/** | ||
@@ -131,0 +132,0 @@ * Format the session name to include the parent database's name. |
@@ -362,4 +362,4 @@ "use strict"; | ||
*/ | ||
transaction(queryOptions) { | ||
return new transaction_1.Transaction(this, undefined, queryOptions); | ||
transaction(queryOptions, requestOptions) { | ||
return new transaction_1.Transaction(this, undefined, queryOptions, requestOptions); | ||
} | ||
@@ -366,0 +366,0 @@ /** |
@@ -22,2 +22,3 @@ /*! | ||
import { Schema, LongRunningCallback } from './common'; | ||
import IRequestOptions = databaseAdmin.spanner.v1.IRequestOptions; | ||
export declare type Key = string | string[]; | ||
@@ -28,17 +29,20 @@ export declare type CreateTableResponse = [Table, GaxOperation, databaseAdmin.longrunning.IOperation]; | ||
export declare type DropTableCallback = UpdateSchemaCallback; | ||
interface MutateRowsOptions extends CommitOptions { | ||
requestOptions?: Omit<IRequestOptions, 'requestTag'>; | ||
} | ||
export declare type DeleteRowsCallback = CommitCallback; | ||
export declare type DeleteRowsResponse = CommitResponse; | ||
export declare type DeleteRowsOptions = CommitOptions; | ||
export declare type DeleteRowsOptions = MutateRowsOptions; | ||
export declare type InsertRowsCallback = CommitCallback; | ||
export declare type InsertRowsResponse = CommitResponse; | ||
export declare type InsertRowsOptions = CommitOptions; | ||
export declare type InsertRowsOptions = MutateRowsOptions; | ||
export declare type ReplaceRowsCallback = CommitCallback; | ||
export declare type ReplaceRowsResponse = CommitResponse; | ||
export declare type ReplaceRowsOptions = CommitOptions; | ||
export declare type ReplaceRowsOptions = MutateRowsOptions; | ||
export declare type UpdateRowsCallback = CommitCallback; | ||
export declare type UpdateRowsResponse = CommitResponse; | ||
export declare type UpdateRowsOptions = CommitOptions; | ||
export declare type UpdateRowsOptions = MutateRowsOptions; | ||
export declare type UpsertRowsCallback = CommitCallback; | ||
export declare type UpsertRowsResponse = CommitResponse; | ||
export declare type UpsertRowsOptions = CommitOptions; | ||
export declare type UpsertRowsOptions = MutateRowsOptions; | ||
/** | ||
@@ -45,0 +49,0 @@ * Create a Table object to interact with a table in a Cloud Spanner |
@@ -821,4 +821,5 @@ "use strict"; | ||
*/ | ||
_mutate(method, rows, options, callback) { | ||
this.database.runTransaction((err, transaction) => { | ||
_mutate(method, rows, options = {}, callback) { | ||
const requestOptions = 'requestOptions' in options ? options.requestOptions : {}; | ||
this.database.runTransaction({ requestOptions }, (err, transaction) => { | ||
if (err) { | ||
@@ -825,0 +826,0 @@ callback(err); |
@@ -20,2 +20,4 @@ /*! | ||
import { NormalCallback } from './common'; | ||
import { google } from '../protos/protos'; | ||
import IRequestOptions = google.spanner.v1.IRequestOptions; | ||
/** | ||
@@ -28,2 +30,3 @@ * @typedef {object} RunTransactionOptions | ||
timeout?: number; | ||
requestOptions?: Pick<IRequestOptions, 'transactionTag'>; | ||
} | ||
@@ -30,0 +33,0 @@ /** |
@@ -98,2 +98,6 @@ /*! | ||
export declare type RunUpdateResponse = [number]; | ||
export interface BatchUpdateOptions { | ||
requestOptions?: Omit<IRequestOptions, 'transactionTag'>; | ||
gaxOptions?: CallOptions; | ||
} | ||
export interface BatchUpdateCallback { | ||
@@ -181,2 +185,3 @@ (err: null | BatchUpdateError, rowCounts: number[], response?: spannerClient.spanner.v1.ExecuteBatchDmlResponse): void; | ||
}; | ||
requestOptions?: Pick<IRequestOptions, 'transactionTag'>; | ||
/** | ||
@@ -529,2 +534,7 @@ * The transaction ID. | ||
/** | ||
* | ||
* @private | ||
*/ | ||
configureTagOptions(singleUse?: boolean, transactionTag?: string, requestOptions?: {}): IRequestOptions | null; | ||
/** | ||
* Transforms convenience options `keys` and `ranges` into a KeySet object. | ||
@@ -659,3 +669,3 @@ * | ||
*/ | ||
constructor(session: Session, options?: spannerClient.spanner.v1.TransactionOptions.ReadWrite, queryOptions?: IQueryOptions); | ||
constructor(session: Session, options?: spannerClient.spanner.v1.TransactionOptions.ReadWrite, queryOptions?: IQueryOptions, requestOptions?: Pick<IRequestOptions, 'transactionTag'>); | ||
batchUpdate(queries: Array<string | Statement>, options?: BatchUpdateOptions | CallOptions): Promise<BatchUpdateResponse>; | ||
@@ -662,0 +672,0 @@ batchUpdate(queries: Array<string | Statement>, callback: BatchUpdateCallback): void; |
@@ -191,2 +191,9 @@ "use strict"; | ||
}; | ||
// Only hand crafted read-write transactions will be able to set a | ||
// transaction tag for the BeginTransaction RPC. Also, this.requestOptions | ||
// is only set in the constructor of Transaction, which is the constructor | ||
// for read/write transactions. | ||
if (this.requestOptions) { | ||
reqOpts.requestOptions = this.requestOptions; | ||
} | ||
this.request({ | ||
@@ -372,3 +379,4 @@ client: 'SpannerClient', | ||
createReadStream(table, request = {}) { | ||
const { gaxOptions, json, jsonOptions, maxResumeRetries } = request; | ||
var _a; | ||
const { gaxOptions, json, jsonOptions, maxResumeRetries, requestOptions } = request; | ||
const keySet = Snapshot.encodeKeySet(request); | ||
@@ -389,4 +397,6 @@ const transaction = {}; | ||
delete request.ranges; | ||
delete request.requestOptions; | ||
const reqOpts = Object.assign(request, { | ||
session: this.session.formattedName_, | ||
requestOptions: this.configureTagOptions(typeof transaction.singleUse !== 'undefined', (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag, requestOptions), | ||
transaction, | ||
@@ -771,5 +781,6 @@ table, | ||
query.queryOptions = Object.assign(Object.assign({}, this.queryOptions), query.queryOptions); | ||
const { gaxOptions, json, jsonOptions, maxResumeRetries } = query; | ||
const { gaxOptions, json, jsonOptions, maxResumeRetries, requestOptions } = query; | ||
let reqOpts; | ||
const sanitizeRequest = () => { | ||
var _a; | ||
query = query; | ||
@@ -788,2 +799,3 @@ const { params, paramTypes } = Snapshot.encodeParams(query); | ||
delete query.maxResumeRetries; | ||
delete query.requestOptions; | ||
delete query.types; | ||
@@ -793,2 +805,3 @@ reqOpts = Object.assign(query, { | ||
seqno: this._seqno++, | ||
requestOptions: this.configureTagOptions(typeof transaction.singleUse !== 'undefined', (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag, requestOptions), | ||
transaction, | ||
@@ -825,2 +838,12 @@ params, | ||
/** | ||
* | ||
* @private | ||
*/ | ||
configureTagOptions(singleUse, transactionTag, requestOptions = {}) { | ||
if (!singleUse && transactionTag) { | ||
requestOptions.transactionTag = transactionTag; | ||
} | ||
return requestOptions; | ||
} | ||
/** | ||
* Transforms convenience options `keys` and `ranges` into a KeySet object. | ||
@@ -925,3 +948,3 @@ * | ||
promisify_1.promisifyAll(Snapshot, { | ||
exclude: ['end'], | ||
exclude: ['configureTagOptions', 'end'], | ||
}); | ||
@@ -1060,6 +1083,7 @@ /** | ||
*/ | ||
constructor(session, options = {}, queryOptions) { | ||
constructor(session, options = {}, queryOptions, requestOptions) { | ||
super(session, undefined, queryOptions); | ||
this._queuedMutations = []; | ||
this._options = { readWrite: options }; | ||
this.requestOptions = requestOptions; | ||
} | ||
@@ -1132,2 +1156,3 @@ /** | ||
batchUpdate(queries, optionsOrCallback, cb) { | ||
var _a; | ||
const options = typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; | ||
@@ -1158,5 +1183,5 @@ const callback = typeof optionsOrCallback === 'function' ? optionsOrCallback : cb; | ||
session: this.session.formattedName_, | ||
requestOptions: this.configureTagOptions(false, (_a = this.requestOptions) === null || _a === void 0 ? void 0 : _a.transactionTag, options.requestOptions), | ||
transaction: { id: this.id }, | ||
seqno: this._seqno++, | ||
requestOptions: options.requestOptions, | ||
statements, | ||
@@ -1285,2 +1310,3 @@ }; | ||
} | ||
reqOpts.requestOptions = Object.assign(requestOptions || {}, this.requestOptions); | ||
this.request({ | ||
@@ -1287,0 +1313,0 @@ client: 'SpannerClient', |
{ | ||
"name": "@google-cloud/spanner", | ||
"description": "Cloud Spanner Client Library for Node.js", | ||
"version": "5.11.1", | ||
"version": "5.12.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "author": "Google Inc.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5131106
86798