dev testing
This commit is contained in:
33
functions/node_modules/google-gax/build/src/apiCaller.d.ts
generated
vendored
Normal file
33
functions/node_modules/google-gax/build/src/apiCaller.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICallback, CancellableStream, GRPCCall, ResultTuple, SimpleCallbackFunction } from './apitypes';
|
||||
import { CancellablePromise, OngoingCall, OngoingCallPromise } from './call';
|
||||
import { Descriptor } from './descriptor';
|
||||
import { CallSettings } from './gax';
|
||||
import { GoogleError } from './googleError';
|
||||
import { StreamProxy } from './streamingCalls/streaming';
|
||||
/**
|
||||
* An interface for all kinds of API callers (normal, that just calls API, and
|
||||
* all special ones: long-running, paginated, bundled, streaming).
|
||||
*/
|
||||
export interface APICaller {
|
||||
init(callback?: APICallback): OngoingCallPromise | OngoingCall | StreamProxy;
|
||||
wrap(func: GRPCCall): GRPCCall;
|
||||
call(apiCall: SimpleCallbackFunction, argument: {}, settings: {}, canceller: OngoingCallPromise | OngoingCall | StreamProxy): void;
|
||||
fail(canceller: OngoingCallPromise | OngoingCall | CancellableStream, err: GoogleError): void;
|
||||
result(canceller: OngoingCallPromise | OngoingCall | CancellableStream): CancellablePromise<ResultTuple> | CancellableStream;
|
||||
}
|
||||
export declare function createAPICaller(settings: CallSettings, descriptor: Descriptor | undefined): APICaller;
|
||||
26
functions/node_modules/google-gax/build/src/apiCaller.js
generated
vendored
Normal file
26
functions/node_modules/google-gax/build/src/apiCaller.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createAPICaller = createAPICaller;
|
||||
const normalApiCaller_1 = require("./normalCalls/normalApiCaller");
|
||||
function createAPICaller(settings, descriptor) {
|
||||
if (!descriptor) {
|
||||
return new normalApiCaller_1.NormalApiCaller();
|
||||
}
|
||||
return descriptor.getApiCaller(settings);
|
||||
}
|
||||
//# sourceMappingURL=apiCaller.js.map
|
||||
1
functions/node_modules/google-gax/build/src/apiCaller.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/apiCaller.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"apiCaller.js","sourceRoot":"","sources":["../../src/apiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAsCH,0CAQC;AAjCD,mEAA8D;AAyB9D,SAAgB,eAAe,CAC7B,QAAsB,EACtB,UAAkC;IAElC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,iCAAe,EAAE,CAAC;IAC/B,CAAC;IACD,OAAO,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
|
||||
63
functions/node_modules/google-gax/build/src/apitypes.d.ts
generated
vendored
Normal file
63
functions/node_modules/google-gax/build/src/apitypes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Duplex } from 'stream';
|
||||
import { CancellablePromise } from './call';
|
||||
import { CallOptions } from './gax';
|
||||
import { GoogleError } from './googleError';
|
||||
import { Operation } from './longRunningCalls/longrunning';
|
||||
export interface GRPCCallResult {
|
||||
cancel(): void;
|
||||
}
|
||||
export interface RequestType {
|
||||
[index: string]: string | number | RequestType | Array<string | number | RequestType>;
|
||||
}
|
||||
export type ResponseType = {} | null;
|
||||
export type NextPageRequestType = {
|
||||
[index: string]: string | number | {};
|
||||
} | null;
|
||||
export type RawResponseType = Operation | {} | null;
|
||||
export type ResultTuple = [
|
||||
ResponseType | [ResponseType],
|
||||
NextPageRequestType | undefined,
|
||||
RawResponseType | undefined
|
||||
];
|
||||
export interface SimpleCallbackFunction {
|
||||
(request: RequestType, callback: APICallback): GRPCCallResult;
|
||||
}
|
||||
export type APICallback = (err: GoogleError | null, response?: ResponseType, next?: NextPageRequestType, rawResponse?: RawResponseType) => void;
|
||||
export type UnaryCall = (argument: {}, metadata: {}, options: {}, callback: APICallback) => GRPCCallResult;
|
||||
export type ServerStreamingCall = (argument: {}, metadata: {}, options: {}) => Duplex & GRPCCallResult;
|
||||
export type ClientStreamingCall = (metadata: {}, options: {}, callback?: APICallback) => Duplex & GRPCCallResult;
|
||||
export type BiDiStreamingCall = (metadata: {}, options: {}) => Duplex & GRPCCallResult;
|
||||
export type GRPCCall = UnaryCall | ServerStreamingCall | ClientStreamingCall | BiDiStreamingCall;
|
||||
export type CancellableStream = Duplex & GRPCCallResult;
|
||||
export type GaxCallResult = CancellablePromise<ResultTuple> | CancellableStream;
|
||||
export interface GaxCallPromise {
|
||||
(argument: {}, callOptions?: CallOptions, callback?: APICallback): CancellablePromise<ResultTuple>;
|
||||
}
|
||||
export interface GaxCallStream {
|
||||
(argument: {}, callOptions?: CallOptions, callback?: APICallback): CancellableStream;
|
||||
}
|
||||
export interface GaxCall {
|
||||
(argument: {}, callOptions?: CallOptions, callback?: APICallback): GaxCallResult;
|
||||
}
|
||||
export interface GRPCCallOtherArgs {
|
||||
options?: {
|
||||
deadline?: Date;
|
||||
};
|
||||
headers?: {};
|
||||
metadataBuilder: (abTests?: {}, headers?: {}) => {};
|
||||
}
|
||||
18
functions/node_modules/google-gax/build/src/apitypes.js
generated
vendored
Normal file
18
functions/node_modules/google-gax/build/src/apitypes.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=apitypes.js.map
|
||||
1
functions/node_modules/google-gax/build/src/apitypes.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/apitypes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"apitypes.js","sourceRoot":"","sources":["../../src/apitypes.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
||||
34
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.d.ts
generated
vendored
Normal file
34
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
|
||||
import { OngoingCall, OngoingCallPromise } from '../call';
|
||||
import { CallSettings } from '../gax';
|
||||
import { GoogleError } from '../googleError';
|
||||
import { BundleExecutor } from './bundleExecutor';
|
||||
/**
|
||||
* An implementation of APICaller for bundled calls.
|
||||
* Uses BundleExecutor to do bundling.
|
||||
*/
|
||||
export declare class BundleApiCaller implements APICaller {
|
||||
bundler: BundleExecutor;
|
||||
constructor(bundler: BundleExecutor);
|
||||
init(callback?: APICallback): OngoingCallPromise | OngoingCall;
|
||||
wrap(func: GRPCCall): GRPCCall;
|
||||
call(apiCall: SimpleCallbackFunction, argument: {}, settings: CallSettings, status: OngoingCallPromise): void;
|
||||
fail(canceller: OngoingCallPromise, err: GoogleError): void;
|
||||
result(canceller: OngoingCallPromise): import("../call").CancellablePromise<import("../apitypes").ResultTuple>;
|
||||
}
|
||||
55
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js
generated
vendored
Normal file
55
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BundleApiCaller = void 0;
|
||||
const call_1 = require("../call");
|
||||
const googleError_1 = require("../googleError");
|
||||
/**
|
||||
* An implementation of APICaller for bundled calls.
|
||||
* Uses BundleExecutor to do bundling.
|
||||
*/
|
||||
class BundleApiCaller {
|
||||
constructor(bundler) {
|
||||
this.bundler = bundler;
|
||||
}
|
||||
init(callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise();
|
||||
}
|
||||
wrap(func) {
|
||||
return func;
|
||||
}
|
||||
call(apiCall, argument, settings, status) {
|
||||
if (!settings.isBundling) {
|
||||
throw new googleError_1.GoogleError('Bundling enabled with no isBundling!');
|
||||
}
|
||||
status.call((argument, callback) => {
|
||||
this.bundler.schedule(apiCall, argument, callback);
|
||||
return status;
|
||||
}, argument);
|
||||
}
|
||||
fail(canceller, err) {
|
||||
canceller.callback(err);
|
||||
}
|
||||
result(canceller) {
|
||||
return canceller.promise;
|
||||
}
|
||||
}
|
||||
exports.BundleApiCaller = BundleApiCaller;
|
||||
//# sourceMappingURL=bundleApiCaller.js.map
|
||||
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bundleApiCaller.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundleApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,kCAAwD;AAExD,gDAA2C;AAK3C;;;GAGG;AACH,MAAa,eAAe;IAG1B,YAAY,OAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,QAAsB;QACzB,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,yBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACF,OAA+B,EAC/B,QAAY,EACZ,QAAsB,EACtB,MAA0B;QAE1B,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,IAAI,yBAAW,CAAC,sCAAsC,CAAC,CAAC;QAChE,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,CAAC,QAAY,EAAE,QAAsB,EAAE,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACnD,OAAO,MAAM,CAAC;QAChB,CAAC,EAAE,QAAQ,CAAC,CAAC;IACf,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AAzCD,0CAyCC"}
|
||||
57
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.d.ts
generated
vendored
Normal file
57
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Descriptor } from '../descriptor';
|
||||
import { CallSettings } from '../gax';
|
||||
import { NormalApiCaller } from '../normalCalls/normalApiCaller';
|
||||
import { BundleApiCaller } from './bundleApiCaller';
|
||||
/**
|
||||
* A descriptor for calls that can be bundled into one call.
|
||||
*/
|
||||
export declare class BundleDescriptor implements Descriptor {
|
||||
bundledField: string;
|
||||
requestDiscriminatorFields: string[];
|
||||
subresponseField: string | null;
|
||||
byteLengthFunction: Function;
|
||||
/**
|
||||
* Describes the structure of bundled call.
|
||||
*
|
||||
* requestDiscriminatorFields may include '.' as a separator, which is used to
|
||||
* indicate object traversal. This allows fields in nested objects to be used
|
||||
* to determine what request to bundle.
|
||||
*
|
||||
* @property {String} bundledField
|
||||
* @property {String} requestDiscriminatorFields
|
||||
* @property {String} subresponseField
|
||||
* @property {Function} byteLengthFunction
|
||||
*
|
||||
* @param {String} bundledField - the repeated field in the request message
|
||||
* that will have its elements aggregated by bundling.
|
||||
* @param {String} requestDiscriminatorFields - a list of fields in the
|
||||
* target request message class that are used to detemrine which request
|
||||
* messages should be bundled together.
|
||||
* @param {String} subresponseField - an optional field, when present it
|
||||
* indicates the field in the response message that should be used to
|
||||
* demultiplex the response into multiple response messages.
|
||||
* @param {Function} byteLengthFunction - a function to obtain the byte
|
||||
* length to be consumed for the bundled field messages. Because Node.JS
|
||||
* protobuf.js/gRPC uses builtin Objects for the user-visible data and
|
||||
* internally they are encoded/decoded in protobuf manner, this function
|
||||
* is actually necessary to calculate the byte length.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(bundledField: string, requestDiscriminatorFields: string[], subresponseField: string | null, byteLengthFunction: Function);
|
||||
getApiCaller(settings: CallSettings): NormalApiCaller | BundleApiCaller;
|
||||
}
|
||||
73
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js
generated
vendored
Normal file
73
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BundleDescriptor = void 0;
|
||||
const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
|
||||
const bundleApiCaller_1 = require("./bundleApiCaller");
|
||||
const bundleExecutor_1 = require("./bundleExecutor");
|
||||
const util_1 = require("../util");
|
||||
/**
|
||||
* A descriptor for calls that can be bundled into one call.
|
||||
*/
|
||||
class BundleDescriptor {
|
||||
/**
|
||||
* Describes the structure of bundled call.
|
||||
*
|
||||
* requestDiscriminatorFields may include '.' as a separator, which is used to
|
||||
* indicate object traversal. This allows fields in nested objects to be used
|
||||
* to determine what request to bundle.
|
||||
*
|
||||
* @property {String} bundledField
|
||||
* @property {String} requestDiscriminatorFields
|
||||
* @property {String} subresponseField
|
||||
* @property {Function} byteLengthFunction
|
||||
*
|
||||
* @param {String} bundledField - the repeated field in the request message
|
||||
* that will have its elements aggregated by bundling.
|
||||
* @param {String} requestDiscriminatorFields - a list of fields in the
|
||||
* target request message class that are used to detemrine which request
|
||||
* messages should be bundled together.
|
||||
* @param {String} subresponseField - an optional field, when present it
|
||||
* indicates the field in the response message that should be used to
|
||||
* demultiplex the response into multiple response messages.
|
||||
* @param {Function} byteLengthFunction - a function to obtain the byte
|
||||
* length to be consumed for the bundled field messages. Because Node.JS
|
||||
* protobuf.js/gRPC uses builtin Objects for the user-visible data and
|
||||
* internally they are encoded/decoded in protobuf manner, this function
|
||||
* is actually necessary to calculate the byte length.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(bundledField, requestDiscriminatorFields, subresponseField, byteLengthFunction) {
|
||||
if (!byteLengthFunction && typeof subresponseField === 'function') {
|
||||
byteLengthFunction = subresponseField;
|
||||
subresponseField = null;
|
||||
}
|
||||
this.bundledField = bundledField;
|
||||
this.requestDiscriminatorFields =
|
||||
requestDiscriminatorFields.map(util_1.toCamelCase);
|
||||
this.subresponseField = subresponseField;
|
||||
this.byteLengthFunction = byteLengthFunction;
|
||||
}
|
||||
getApiCaller(settings) {
|
||||
if (settings.isBundling === false) {
|
||||
return new normalApiCaller_1.NormalApiCaller();
|
||||
}
|
||||
return new bundleApiCaller_1.BundleApiCaller(new bundleExecutor_1.BundleExecutor(settings.bundleOptions, this));
|
||||
}
|
||||
}
|
||||
exports.BundleDescriptor = BundleDescriptor;
|
||||
//# sourceMappingURL=bundleDescriptor.js.map
|
||||
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bundleDescriptor.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundleDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,oEAA+D;AAE/D,uDAAkD;AAClD,qDAAgD;AAChD,kCAAwD;AAExD;;GAEG;AACH,MAAa,gBAAgB;IAM3B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,YACE,YAAoB,EACpB,0BAAoC,EACpC,gBAA+B,EAC/B,kBAA4B;QAE5B,IAAI,CAAC,kBAAkB,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;YAClE,kBAAkB,GAAG,gBAAgB,CAAC;YACtC,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,0BAA0B;YAC7B,0BAA0B,CAAC,GAAG,CAAC,kBAAgB,CAAC,CAAC;QACnD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC/C,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;YAClC,OAAO,IAAI,iCAAe,EAAE,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,iCAAe,CACxB,IAAI,+BAAc,CAAC,QAAQ,CAAC,aAAc,EAAE,IAAI,CAAC,CAClD,CAAC;IACJ,CAAC;CACF;AA1DD,4CA0DC"}
|
||||
116
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.d.ts
generated
vendored
Normal file
116
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { SimpleCallbackFunction } from '../apitypes';
|
||||
import { BundleDescriptor } from './bundleDescriptor';
|
||||
import { Task, TaskCallback } from './task';
|
||||
/**
|
||||
* Parameter to configure bundling behavior.
|
||||
* @typedef {Object} BundleOptions
|
||||
* @property {number} elementCountThreshold -
|
||||
* the bundled request will be sent once the count of outstanding elements
|
||||
* in the repeated field reaches this value.
|
||||
* @property {number} elementCountLimit -
|
||||
* represents a hard limit on the number of elements in the repeated field
|
||||
* of the bundle; if adding a request to a bundle would exceed this value,
|
||||
* the bundle is sent and the new request is added to a fresh bundle. It is
|
||||
* invalid for a single request to exceed this limit.
|
||||
* @property {number} requestByteThreshold -
|
||||
* the bundled request will be sent once the count of bytes in the request
|
||||
* reaches this value. Note that this value is pessimistically approximated
|
||||
* by summing the bytesizes of the elements in the repeated field, and
|
||||
* therefore may be an under-approximation.
|
||||
* @property {number} requestByteLimit -
|
||||
* represents a hard limit on the size of the bundled request; if adding
|
||||
* a request to a bundle would exceed this value, the bundle is sent and
|
||||
* the new request is added to a fresh bundle. It is invalid for a single
|
||||
* request to exceed this limit. Note that this value is pessimistically
|
||||
* approximated by summing the bytesizes of the elements in the repeated
|
||||
* field, with a buffer applied to correspond to the resulting
|
||||
* under-approximation.
|
||||
* @property {number} delayThreshold -
|
||||
* the bundled request will be sent this amount of time after the first
|
||||
* element in the bundle was added to it.
|
||||
*/
|
||||
export interface BundleOptions {
|
||||
elementCountLimit?: number;
|
||||
requestByteLimit?: number;
|
||||
elementCountThreshold?: number;
|
||||
requestByteThreshold?: number;
|
||||
delayThreshold?: number;
|
||||
}
|
||||
/**
|
||||
* BundleExecutor stores several timers for each bundle (calls are bundled based
|
||||
* on the options passed, each bundle has unique ID that is calculated based on
|
||||
* field values). Each timer fires and sends a call after certain amount of
|
||||
* time, and if a new request comes to the same bundle, the timer can be
|
||||
* restarted.
|
||||
*/
|
||||
export declare class BundleExecutor {
|
||||
_options: BundleOptions;
|
||||
_descriptor: BundleDescriptor;
|
||||
_tasks: {
|
||||
[index: string]: Task;
|
||||
};
|
||||
_timers: {
|
||||
[index: string]: ReturnType<typeof setTimeout>;
|
||||
};
|
||||
_invocations: {
|
||||
[index: string]: string;
|
||||
};
|
||||
_invocationId: number;
|
||||
/**
|
||||
* Organizes requests for an api service that requires to bundle them.
|
||||
*
|
||||
* @param {BundleOptions} bundleOptions - configures strategy this instance
|
||||
* uses when executing bundled functions.
|
||||
* @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(bundleOptions: BundleOptions, bundleDescriptor: BundleDescriptor);
|
||||
/**
|
||||
* Schedule a method call.
|
||||
*
|
||||
* @param {function} apiCall - the function for an API call.
|
||||
* @param {Object} request - the request object to be bundled with others.
|
||||
* @param {APICallback} callback - the callback to be called when the method finished.
|
||||
* @return {function()} - the function to cancel the scheduled invocation.
|
||||
*/
|
||||
schedule(apiCall: SimpleCallbackFunction, request: {
|
||||
[index: string]: Array<{}> | string;
|
||||
}, callback?: TaskCallback): import("../apitypes").GRPCCallResult;
|
||||
/**
|
||||
* Clears scheduled timeout if it exists.
|
||||
*
|
||||
* @param {String} bundleId - the id for the task whose timeout needs to be
|
||||
* cleared.
|
||||
* @private
|
||||
*/
|
||||
private _maybeClearTimeout;
|
||||
/**
|
||||
* Cancels an event.
|
||||
*
|
||||
* @param {String} id - The id for the event in the task.
|
||||
* @private
|
||||
*/
|
||||
private _cancel;
|
||||
/**
|
||||
* Invokes a task.
|
||||
*
|
||||
* @param {String} bundleId - The id for the task.
|
||||
* @private
|
||||
*/
|
||||
_runNow(bundleId: string): void;
|
||||
}
|
||||
195
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js
generated
vendored
Normal file
195
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BundleExecutor = void 0;
|
||||
const status_1 = require("../status");
|
||||
const googleError_1 = require("../googleError");
|
||||
const warnings_1 = require("../warnings");
|
||||
const bundlingUtils_1 = require("./bundlingUtils");
|
||||
const task_1 = require("./task");
|
||||
function noop() { }
|
||||
/**
|
||||
* BundleExecutor stores several timers for each bundle (calls are bundled based
|
||||
* on the options passed, each bundle has unique ID that is calculated based on
|
||||
* field values). Each timer fires and sends a call after certain amount of
|
||||
* time, and if a new request comes to the same bundle, the timer can be
|
||||
* restarted.
|
||||
*/
|
||||
class BundleExecutor {
|
||||
/**
|
||||
* Organizes requests for an api service that requires to bundle them.
|
||||
*
|
||||
* @param {BundleOptions} bundleOptions - configures strategy this instance
|
||||
* uses when executing bundled functions.
|
||||
* @param {BundleDescriptor} bundleDescriptor - the description of the bundling.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(bundleOptions, bundleDescriptor) {
|
||||
this._options = bundleOptions;
|
||||
this._descriptor = bundleDescriptor;
|
||||
this._tasks = {};
|
||||
this._timers = {};
|
||||
this._invocations = {};
|
||||
this._invocationId = 0;
|
||||
}
|
||||
/**
|
||||
* Schedule a method call.
|
||||
*
|
||||
* @param {function} apiCall - the function for an API call.
|
||||
* @param {Object} request - the request object to be bundled with others.
|
||||
* @param {APICallback} callback - the callback to be called when the method finished.
|
||||
* @return {function()} - the function to cancel the scheduled invocation.
|
||||
*/
|
||||
schedule(apiCall, request, callback) {
|
||||
const bundleId = (0, bundlingUtils_1.computeBundleId)(request, this._descriptor.requestDiscriminatorFields);
|
||||
callback = (callback || noop);
|
||||
if (bundleId === undefined) {
|
||||
(0, warnings_1.warn)('bundling_schedule_bundleid_undefined', 'The request does not have enough information for request bundling. ' +
|
||||
`Invoking immediately. Request: ${JSON.stringify(request)} ` +
|
||||
`discriminator fields: ${this._descriptor.requestDiscriminatorFields}`);
|
||||
return apiCall(request, callback);
|
||||
}
|
||||
if (request[this._descriptor.bundledField] === undefined) {
|
||||
(0, warnings_1.warn)('bundling_no_bundled_field', `Request does not contain field ${this._descriptor.bundledField} that must present for bundling. ` +
|
||||
`Invoking immediately. Request: ${JSON.stringify(request)}`);
|
||||
return apiCall(request, callback);
|
||||
}
|
||||
if (!(bundleId in this._tasks)) {
|
||||
this._tasks[bundleId] = new task_1.Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
|
||||
}
|
||||
let task = this._tasks[bundleId];
|
||||
callback.id = String(this._invocationId++);
|
||||
this._invocations[callback.id] = bundleId;
|
||||
const bundledField = request[this._descriptor.bundledField];
|
||||
const elementCount = bundledField.length;
|
||||
let requestBytes = 0;
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
bundledField.forEach(obj => {
|
||||
requestBytes += this._descriptor.byteLengthFunction(obj);
|
||||
});
|
||||
const countLimit = this._options.elementCountLimit || 0;
|
||||
const byteLimit = this._options.requestByteLimit || 0;
|
||||
if ((countLimit > 0 && elementCount > countLimit) ||
|
||||
(byteLimit > 0 && requestBytes >= byteLimit)) {
|
||||
let message;
|
||||
if (countLimit > 0 && elementCount > countLimit) {
|
||||
message =
|
||||
'The number of elements ' +
|
||||
elementCount +
|
||||
' exceeds the limit ' +
|
||||
this._options.elementCountLimit;
|
||||
}
|
||||
else {
|
||||
message =
|
||||
'The required bytes ' +
|
||||
requestBytes +
|
||||
' exceeds the limit ' +
|
||||
this._options.requestByteLimit;
|
||||
}
|
||||
const error = new googleError_1.GoogleError(message);
|
||||
error.code = status_1.Status.INVALID_ARGUMENT;
|
||||
callback(error);
|
||||
return {
|
||||
cancel: noop,
|
||||
};
|
||||
}
|
||||
const existingCount = task.getElementCount();
|
||||
const existingBytes = task.getRequestByteSize();
|
||||
if ((countLimit > 0 && elementCount + existingCount >= countLimit) ||
|
||||
(byteLimit > 0 && requestBytes + existingBytes >= byteLimit)) {
|
||||
this._runNow(bundleId);
|
||||
this._tasks[bundleId] = new task_1.Task(apiCall, request, this._descriptor.bundledField, this._descriptor.subresponseField);
|
||||
task = this._tasks[bundleId];
|
||||
}
|
||||
task.extend(bundledField, requestBytes, callback);
|
||||
const ret = {
|
||||
cancel() {
|
||||
self._cancel(callback.id);
|
||||
},
|
||||
};
|
||||
const countThreshold = this._options.elementCountThreshold || 0;
|
||||
const sizeThreshold = this._options.requestByteThreshold || 0;
|
||||
if ((countThreshold > 0 && task.getElementCount() >= countThreshold) ||
|
||||
(sizeThreshold > 0 && task.getRequestByteSize() >= sizeThreshold)) {
|
||||
this._runNow(bundleId);
|
||||
return ret;
|
||||
}
|
||||
if (!(bundleId in this._timers) && this._options.delayThreshold > 0) {
|
||||
this._timers[bundleId] = setTimeout(() => {
|
||||
delete this._timers[bundleId];
|
||||
this._runNow(bundleId);
|
||||
}, this._options.delayThreshold);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* Clears scheduled timeout if it exists.
|
||||
*
|
||||
* @param {String} bundleId - the id for the task whose timeout needs to be
|
||||
* cleared.
|
||||
* @private
|
||||
*/
|
||||
_maybeClearTimeout(bundleId) {
|
||||
if (bundleId in this._timers) {
|
||||
const timerId = this._timers[bundleId];
|
||||
delete this._timers[bundleId];
|
||||
clearTimeout(timerId);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Cancels an event.
|
||||
*
|
||||
* @param {String} id - The id for the event in the task.
|
||||
* @private
|
||||
*/
|
||||
_cancel(id) {
|
||||
if (!(id in this._invocations)) {
|
||||
return;
|
||||
}
|
||||
const bundleId = this._invocations[id];
|
||||
if (!(bundleId in this._tasks)) {
|
||||
return;
|
||||
}
|
||||
const task = this._tasks[bundleId];
|
||||
delete this._invocations[id];
|
||||
if (task.cancel(id)) {
|
||||
this._maybeClearTimeout(bundleId);
|
||||
delete this._tasks[bundleId];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Invokes a task.
|
||||
*
|
||||
* @param {String} bundleId - The id for the task.
|
||||
* @private
|
||||
*/
|
||||
_runNow(bundleId) {
|
||||
if (!(bundleId in this._tasks)) {
|
||||
(0, warnings_1.warn)('bundle_runnow_bundleid_unknown', `No such bundleid: ${bundleId}`);
|
||||
return;
|
||||
}
|
||||
this._maybeClearTimeout(bundleId);
|
||||
const task = this._tasks[bundleId];
|
||||
delete this._tasks[bundleId];
|
||||
task.run().forEach(id => {
|
||||
delete this._invocations[id];
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.BundleExecutor = BundleExecutor;
|
||||
//# sourceMappingURL=bundleExecutor.js.map
|
||||
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.d.ts
generated
vendored
Normal file
31
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Provides behavior that supports request bundling.
|
||||
*/
|
||||
import { RequestType } from '../apitypes';
|
||||
/**
|
||||
* Compute the identifier of the `obj`. The objects of the same ID
|
||||
* will be bundled together.
|
||||
*
|
||||
* @param {RequestType} obj - The request object.
|
||||
* @param {String[]} discriminatorFields - The array of field names.
|
||||
* A field name may include '.' as a separator, which is used to
|
||||
* indicate object traversal.
|
||||
* @return {String|undefined} - the identifier string, or undefined if any
|
||||
* discriminator fields do not exist.
|
||||
*/
|
||||
export declare function computeBundleId(obj: RequestType, discriminatorFields: string[]): string | undefined;
|
||||
72
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js
generated
vendored
Normal file
72
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.computeBundleId = computeBundleId;
|
||||
/**
|
||||
* Compute the identifier of the `obj`. The objects of the same ID
|
||||
* will be bundled together.
|
||||
*
|
||||
* @param {RequestType} obj - The request object.
|
||||
* @param {String[]} discriminatorFields - The array of field names.
|
||||
* A field name may include '.' as a separator, which is used to
|
||||
* indicate object traversal.
|
||||
* @return {String|undefined} - the identifier string, or undefined if any
|
||||
* discriminator fields do not exist.
|
||||
*/
|
||||
function computeBundleId(obj, discriminatorFields) {
|
||||
const ids = [];
|
||||
let hasIds = false;
|
||||
for (const field of discriminatorFields) {
|
||||
const id = at(obj, field);
|
||||
if (id === undefined) {
|
||||
ids.push(null);
|
||||
}
|
||||
else {
|
||||
hasIds = true;
|
||||
ids.push(id);
|
||||
}
|
||||
}
|
||||
if (!hasIds) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.stringify(ids);
|
||||
}
|
||||
/**
|
||||
* Given an object field path that may contain dots, dig into the obj and find
|
||||
* the value at the given path.
|
||||
* @example
|
||||
* const obj = {
|
||||
* a: {
|
||||
* b: 5
|
||||
* }
|
||||
* }
|
||||
* const id = at(obj, 'a.b');
|
||||
* // id = 5
|
||||
* @param field Path to the property with `.` notation
|
||||
* @param obj The object to traverse
|
||||
* @returns the value at the given path
|
||||
*/
|
||||
function at(obj, field) {
|
||||
const pathParts = field.split('.');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let currentObj = obj;
|
||||
for (const pathPart of pathParts) {
|
||||
currentObj = currentObj === null || currentObj === void 0 ? void 0 : currentObj[pathPart];
|
||||
}
|
||||
return currentObj;
|
||||
}
|
||||
//# sourceMappingURL=bundlingUtils.js.map
|
||||
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bundlingUtils.js","sourceRoot":"","sources":["../../../src/bundlingCalls/bundlingUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAmBH,0CAmBC;AA9BD;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC7B,GAAgB,EAChB,mBAA6B;IAE7B,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,mBAAmB,EAAE,CAAC;QACxC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC1B,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;YACrB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,IAAI,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,EAAE,CAAC,GAAO,EAAE,KAAa;IAChC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,8DAA8D;IAC9D,IAAI,UAAU,GAAQ,GAAG,CAAC;IAC1B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,UAAU,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,QAAQ,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
||||
98
functions/node_modules/google-gax/build/src/bundlingCalls/task.d.ts
generated
vendored
Normal file
98
functions/node_modules/google-gax/build/src/bundlingCalls/task.d.ts
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICallback, GRPCCallResult, SimpleCallbackFunction } from '../apitypes';
|
||||
export interface SubResponseInfo {
|
||||
field: string;
|
||||
start?: number;
|
||||
end?: number;
|
||||
}
|
||||
export interface TaskData {
|
||||
elements: {}[];
|
||||
bytes: number;
|
||||
callback: TaskCallback;
|
||||
cancelled?: boolean;
|
||||
}
|
||||
export interface TaskCallback extends APICallback {
|
||||
id?: string;
|
||||
}
|
||||
/**
|
||||
* Creates a deep copy of the object with the consideration of subresponse
|
||||
* fields for bundling.
|
||||
*
|
||||
* @param {Object} obj - The source object.
|
||||
* @param {Object?} subresponseInfo - The information to copy the subset of
|
||||
* the field for the response. Do nothing if it's null.
|
||||
* @param {String} subresponseInfo.field - The field name.
|
||||
* @param {number} subresponseInfo.start - The offset where the copying
|
||||
* element should starts with.
|
||||
* @param {number} subresponseInfo.end - The ending index where the copying
|
||||
* region of the elements ends.
|
||||
* @return {Object} The copied object.
|
||||
* @private
|
||||
*/
|
||||
export declare function deepCopyForResponse(obj: any, subresponseInfo: SubResponseInfo | null): any;
|
||||
export declare class Task {
|
||||
_apiCall: SimpleCallbackFunction;
|
||||
_request: {
|
||||
[index: string]: {}[];
|
||||
};
|
||||
_bundledField: string;
|
||||
_subresponseField?: string | null;
|
||||
_data: TaskData[];
|
||||
callCanceller?: GRPCCallResult;
|
||||
/**
|
||||
* A task coordinates the execution of a single bundle.
|
||||
*
|
||||
* @param {function} apiCall - The function to conduct calling API.
|
||||
* @param {Object} bundlingRequest - The base request object to be used
|
||||
* for the actual API call.
|
||||
* @param {string} bundledField - The name of the field in bundlingRequest
|
||||
* to be bundled.
|
||||
* @param {string=} subresponseField - The name of the field in the response
|
||||
* to be passed to the callback.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
constructor(apiCall: SimpleCallbackFunction, bundlingRequest: {}, bundledField: string, subresponseField?: string | null);
|
||||
/**
|
||||
* Returns the number of elements in a task.
|
||||
* @return {number} The number of elements.
|
||||
*/
|
||||
getElementCount(): number;
|
||||
/**
|
||||
* Returns the total byte size of the elements in a task.
|
||||
* @return {number} The byte size.
|
||||
*/
|
||||
getRequestByteSize(): number;
|
||||
/**
|
||||
* Invokes the actual API call with current elements.
|
||||
* @return {string[]} - the list of ids for invocations to be run.
|
||||
*/
|
||||
run(): string[];
|
||||
/**
|
||||
* Appends the list of elements into the task.
|
||||
* @param {Object[]} elements - the new list of elements.
|
||||
* @param {number} bytes - the byte size required to encode elements in the API.
|
||||
* @param {APICallback} callback - the callback of the method call.
|
||||
*/
|
||||
extend(elements: {}[], bytes: number, callback: TaskCallback): void;
|
||||
/**
|
||||
* Cancels a part of elements.
|
||||
* @param {string} id - The identifier of the part of elements.
|
||||
* @return {boolean} Whether the entire task will be canceled or not.
|
||||
*/
|
||||
cancel(id: string): boolean;
|
||||
}
|
||||
228
functions/node_modules/google-gax/build/src/bundlingCalls/task.js
generated
vendored
Normal file
228
functions/node_modules/google-gax/build/src/bundlingCalls/task.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Task = void 0;
|
||||
exports.deepCopyForResponse = deepCopyForResponse;
|
||||
const status_1 = require("../status");
|
||||
const googleError_1 = require("../googleError");
|
||||
/**
|
||||
* Creates a deep copy of the object with the consideration of subresponse
|
||||
* fields for bundling.
|
||||
*
|
||||
* @param {Object} obj - The source object.
|
||||
* @param {Object?} subresponseInfo - The information to copy the subset of
|
||||
* the field for the response. Do nothing if it's null.
|
||||
* @param {String} subresponseInfo.field - The field name.
|
||||
* @param {number} subresponseInfo.start - The offset where the copying
|
||||
* element should starts with.
|
||||
* @param {number} subresponseInfo.end - The ending index where the copying
|
||||
* region of the elements ends.
|
||||
* @return {Object} The copied object.
|
||||
* @private
|
||||
*/
|
||||
function deepCopyForResponse(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
obj, subresponseInfo) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let result;
|
||||
if (obj === null) {
|
||||
return null;
|
||||
}
|
||||
if (obj === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
result = [];
|
||||
obj.forEach(element => {
|
||||
result.push(deepCopyForResponse(element, null));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
// Some objects (such as ByteBuffer) have copy method.
|
||||
if (obj.copy !== undefined) {
|
||||
return obj.copy();
|
||||
}
|
||||
// ArrayBuffer should be copied through slice().
|
||||
if (obj instanceof ArrayBuffer) {
|
||||
return obj.slice(0);
|
||||
}
|
||||
if (typeof obj === 'object') {
|
||||
result = {};
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (subresponseInfo &&
|
||||
key === subresponseInfo.field &&
|
||||
Array.isArray(obj[key])) {
|
||||
// Note that subresponses are not deep-copied. This is safe because
|
||||
// those subresponses are not shared among callbacks.
|
||||
result[key] = obj[key].slice(subresponseInfo.start, subresponseInfo.end);
|
||||
}
|
||||
else {
|
||||
result[key] = deepCopyForResponse(obj[key], null);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Task {
|
||||
/**
|
||||
* A task coordinates the execution of a single bundle.
|
||||
*
|
||||
* @param {function} apiCall - The function to conduct calling API.
|
||||
* @param {Object} bundlingRequest - The base request object to be used
|
||||
* for the actual API call.
|
||||
* @param {string} bundledField - The name of the field in bundlingRequest
|
||||
* to be bundled.
|
||||
* @param {string=} subresponseField - The name of the field in the response
|
||||
* to be passed to the callback.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
constructor(apiCall, bundlingRequest, bundledField, subresponseField) {
|
||||
this._apiCall = apiCall;
|
||||
this._request = bundlingRequest;
|
||||
this._bundledField = bundledField;
|
||||
this._subresponseField = subresponseField;
|
||||
this._data = [];
|
||||
}
|
||||
/**
|
||||
* Returns the number of elements in a task.
|
||||
* @return {number} The number of elements.
|
||||
*/
|
||||
getElementCount() {
|
||||
let count = 0;
|
||||
for (let i = 0; i < this._data.length; ++i) {
|
||||
count += this._data[i].elements.length;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
/**
|
||||
* Returns the total byte size of the elements in a task.
|
||||
* @return {number} The byte size.
|
||||
*/
|
||||
getRequestByteSize() {
|
||||
let size = 0;
|
||||
for (let i = 0; i < this._data.length; ++i) {
|
||||
size += this._data[i].bytes;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
/**
|
||||
* Invokes the actual API call with current elements.
|
||||
* @return {string[]} - the list of ids for invocations to be run.
|
||||
*/
|
||||
run() {
|
||||
if (this._data.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const request = this._request;
|
||||
const elements = [];
|
||||
const ids = [];
|
||||
for (let i = 0; i < this._data.length; ++i) {
|
||||
elements.push(...this._data[i].elements);
|
||||
ids.push(this._data[i].callback.id);
|
||||
}
|
||||
request[this._bundledField] = elements;
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
this.callCanceller = this._apiCall(request, (err, response) => {
|
||||
const responses = [];
|
||||
if (err) {
|
||||
self._data.forEach(() => {
|
||||
responses.push(undefined);
|
||||
});
|
||||
}
|
||||
else {
|
||||
let subresponseInfo = null;
|
||||
if (self._subresponseField) {
|
||||
subresponseInfo = {
|
||||
field: self._subresponseField,
|
||||
start: 0,
|
||||
};
|
||||
}
|
||||
self._data.forEach(data => {
|
||||
if (subresponseInfo) {
|
||||
subresponseInfo.end =
|
||||
subresponseInfo.start + data.elements.length;
|
||||
}
|
||||
responses.push(deepCopyForResponse(response, subresponseInfo));
|
||||
if (subresponseInfo) {
|
||||
subresponseInfo.start = subresponseInfo.end;
|
||||
}
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < self._data.length; ++i) {
|
||||
if (self._data[i].cancelled) {
|
||||
const error = new googleError_1.GoogleError('cancelled');
|
||||
error.code = status_1.Status.CANCELLED;
|
||||
self._data[i].callback(error);
|
||||
}
|
||||
else {
|
||||
self._data[i].callback(err, responses[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
/**
|
||||
* Appends the list of elements into the task.
|
||||
* @param {Object[]} elements - the new list of elements.
|
||||
* @param {number} bytes - the byte size required to encode elements in the API.
|
||||
* @param {APICallback} callback - the callback of the method call.
|
||||
*/
|
||||
extend(elements, bytes, callback) {
|
||||
this._data.push({
|
||||
elements,
|
||||
bytes,
|
||||
callback,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Cancels a part of elements.
|
||||
* @param {string} id - The identifier of the part of elements.
|
||||
* @return {boolean} Whether the entire task will be canceled or not.
|
||||
*/
|
||||
cancel(id) {
|
||||
if (this.callCanceller) {
|
||||
let allCancelled = true;
|
||||
this._data.forEach(d => {
|
||||
if (d.callback.id === id) {
|
||||
d.cancelled = true;
|
||||
}
|
||||
if (!d.cancelled) {
|
||||
allCancelled = false;
|
||||
}
|
||||
});
|
||||
if (allCancelled) {
|
||||
this.callCanceller.cancel();
|
||||
}
|
||||
return allCancelled;
|
||||
}
|
||||
for (let i = 0; i < this._data.length; ++i) {
|
||||
if (this._data[i].callback.id === id) {
|
||||
const error = new googleError_1.GoogleError('cancelled');
|
||||
error.code = status_1.Status.CANCELLED;
|
||||
this._data[i].callback(error);
|
||||
this._data.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this._data.length === 0;
|
||||
}
|
||||
}
|
||||
exports.Task = Task;
|
||||
//# sourceMappingURL=task.js.map
|
||||
1
functions/node_modules/google-gax/build/src/bundlingCalls/task.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/bundlingCalls/task.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
60
functions/node_modules/google-gax/build/src/call.d.ts
generated
vendored
Normal file
60
functions/node_modules/google-gax/build/src/call.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICallback, RequestType, ResultTuple, SimpleCallbackFunction } from './apitypes';
|
||||
export declare class OngoingCall {
|
||||
callback: APICallback;
|
||||
cancelFunc?: () => void;
|
||||
completed: boolean;
|
||||
/**
|
||||
* OngoingCall manages callback, API calls, and cancellation
|
||||
* of the API calls.
|
||||
* @param {APICallback=} callback
|
||||
* The callback to be called asynchronously when the API call
|
||||
* finishes.
|
||||
* @constructor
|
||||
* @property {APICallback} callback
|
||||
* The callback function to be called.
|
||||
* @private
|
||||
*/
|
||||
constructor(callback: APICallback);
|
||||
/**
|
||||
* Cancels the ongoing promise.
|
||||
*/
|
||||
cancel(): void;
|
||||
/**
|
||||
* Call calls the specified function. Result will be used to fulfill
|
||||
* the promise.
|
||||
*
|
||||
* @param {SimpleCallbackFunction} func
|
||||
* A function for an API call.
|
||||
* @param {Object} argument
|
||||
* A request object.
|
||||
*/
|
||||
call(func: SimpleCallbackFunction, argument: RequestType): void;
|
||||
}
|
||||
export interface CancellablePromise<T> extends Promise<T> {
|
||||
cancel(): void;
|
||||
}
|
||||
export declare class OngoingCallPromise extends OngoingCall {
|
||||
promise: CancellablePromise<ResultTuple>;
|
||||
/**
|
||||
* GaxPromise is GRPCCallbackWrapper, but it holds a promise when
|
||||
* the API call finishes.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
constructor();
|
||||
}
|
||||
119
functions/node_modules/google-gax/build/src/call.js
generated
vendored
Normal file
119
functions/node_modules/google-gax/build/src/call.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OngoingCallPromise = exports.OngoingCall = void 0;
|
||||
const status_1 = require("./status");
|
||||
const googleError_1 = require("./googleError");
|
||||
class OngoingCall {
|
||||
/**
|
||||
* OngoingCall manages callback, API calls, and cancellation
|
||||
* of the API calls.
|
||||
* @param {APICallback=} callback
|
||||
* The callback to be called asynchronously when the API call
|
||||
* finishes.
|
||||
* @constructor
|
||||
* @property {APICallback} callback
|
||||
* The callback function to be called.
|
||||
* @private
|
||||
*/
|
||||
constructor(callback) {
|
||||
this.callback = callback;
|
||||
this.completed = false;
|
||||
}
|
||||
/**
|
||||
* Cancels the ongoing promise.
|
||||
*/
|
||||
cancel() {
|
||||
if (this.completed) {
|
||||
return;
|
||||
}
|
||||
this.completed = true;
|
||||
if (this.cancelFunc) {
|
||||
this.cancelFunc();
|
||||
}
|
||||
else {
|
||||
const error = new googleError_1.GoogleError('cancelled');
|
||||
error.code = status_1.Status.CANCELLED;
|
||||
this.callback(error);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Call calls the specified function. Result will be used to fulfill
|
||||
* the promise.
|
||||
*
|
||||
* @param {SimpleCallbackFunction} func
|
||||
* A function for an API call.
|
||||
* @param {Object} argument
|
||||
* A request object.
|
||||
*/
|
||||
call(func, argument) {
|
||||
if (this.completed) {
|
||||
return;
|
||||
}
|
||||
const canceller = func(argument, (err, response, next, rawResponse) => {
|
||||
this.completed = true;
|
||||
setImmediate(this.callback, err, response, next, rawResponse);
|
||||
});
|
||||
if (canceller instanceof Promise) {
|
||||
canceller.catch(err => {
|
||||
setImmediate(this.callback, new googleError_1.GoogleError(err), null, null, null);
|
||||
});
|
||||
}
|
||||
this.cancelFunc = () => canceller.cancel();
|
||||
}
|
||||
}
|
||||
exports.OngoingCall = OngoingCall;
|
||||
class OngoingCallPromise extends OngoingCall {
|
||||
/**
|
||||
* GaxPromise is GRPCCallbackWrapper, but it holds a promise when
|
||||
* the API call finishes.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
constructor() {
|
||||
let resolveCallback;
|
||||
let rejectCallback;
|
||||
const callback = (err, response, next, rawResponse) => {
|
||||
if (err) {
|
||||
// If gRPC metadata exist, parsed google.rpc.status details.
|
||||
if (err.metadata) {
|
||||
rejectCallback(googleError_1.GoogleError.parseGRPCStatusDetails(err));
|
||||
}
|
||||
else {
|
||||
rejectCallback(err);
|
||||
}
|
||||
}
|
||||
else if (response !== undefined) {
|
||||
resolveCallback([response, next || null, rawResponse || null]);
|
||||
}
|
||||
else {
|
||||
throw new googleError_1.GoogleError('Neither error nor response are defined');
|
||||
}
|
||||
};
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
resolveCallback = resolve;
|
||||
rejectCallback = reject;
|
||||
});
|
||||
super(callback);
|
||||
this.promise = promise;
|
||||
this.promise.cancel = () => {
|
||||
this.cancel();
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.OngoingCallPromise = OngoingCallPromise;
|
||||
//# sourceMappingURL=call.js.map
|
||||
1
functions/node_modules/google-gax/build/src/call.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/call.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qCAAgC;AAWhC,+CAA0C;AAE1C,MAAa,WAAW;IAKtB;;;;;;;;;;OAUG;IACH,YAAY,QAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,WAAW,CAAC,CAAC;YAC3C,KAAK,CAAC,IAAI,GAAG,eAAM,CAAC,SAAS,CAAC;YAC9B,IAAI,CAAC,QAAS,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,IAA4B,EAAE,QAAqB;QACtD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CACpB,QAAQ,EACR,CACE,GAAuB,EACvB,QAAuB,EACvB,IAA0B,EAC1B,WAA6B,EAC7B,EAAE;YACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,YAAY,CAAC,IAAI,CAAC,QAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QACjE,CAAC,CACF,CAAC;QACF,IAAI,SAAS,YAAY,OAAO,EAAE,CAAC;YACjC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACpB,YAAY,CAAC,IAAI,CAAC,QAAS,EAAE,IAAI,yBAAW,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAC7C,CAAC;CACF;AAtED,kCAsEC;AAMD,MAAa,kBAAmB,SAAQ,WAAW;IAEjD;;;;;OAKG;IACH;QACE,IAAI,eAEK,CAAC;QACV,IAAI,cAAoC,CAAC;QACzC,MAAM,QAAQ,GAAgB,CAC5B,GAAuB,EACvB,QAAuB,EACvB,IAA0B,EAC1B,WAA6B,EAC7B,EAAE;YACF,IAAI,GAAG,EAAE,CAAC;gBACR,4DAA4D;gBAC5D,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;oBACjB,cAAc,CAAC,yBAAW,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC1D,CAAC;qBAAM,CAAC;oBACN,cAAc,CAAC,GAAG,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAClC,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI,EAAE,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC;YACjE,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,yBAAW,CAAC,wCAAwC,CAAC,CAAC;YAClE,CAAC;QACH,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,eAAe,GAAG,OAAO,CAAC;YAC1B,cAAc,GAAG,MAAM,CAAC;QAC1B,CAAC,CAAoC,CAAC;QACtC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE;YACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CACF;AA1CD,gDA0CC"}
|
||||
48
functions/node_modules/google-gax/build/src/clientInterface.d.ts
generated
vendored
Normal file
48
functions/node_modules/google-gax/build/src/clientInterface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import { GrpcClientOptions, ClientStubOptions } from './grpc';
|
||||
import * as gax from './gax';
|
||||
import { GoogleAuthOptions } from 'google-auth-library';
|
||||
import { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor } from './descriptor';
|
||||
import * as longrunning from './longRunningCalls/longrunning';
|
||||
import * as operationProtos from '../protos/operations';
|
||||
export interface ClientOptions extends GrpcClientOptions, GoogleAuthOptions, ClientStubOptions {
|
||||
libName?: string;
|
||||
libVersion?: string;
|
||||
clientConfig?: gax.ClientConfig;
|
||||
fallback?: boolean | 'rest' | 'proto';
|
||||
apiEndpoint?: string;
|
||||
gaxServerStreamingRetries?: boolean;
|
||||
universeDomain?: string;
|
||||
universe_domain?: string;
|
||||
}
|
||||
export interface Descriptors {
|
||||
page: {
|
||||
[name: string]: PageDescriptor;
|
||||
};
|
||||
stream: {
|
||||
[name: string]: StreamDescriptor;
|
||||
};
|
||||
longrunning: {
|
||||
[name: string]: LongrunningDescriptor;
|
||||
};
|
||||
batching?: {
|
||||
[name: string]: BundleDescriptor;
|
||||
};
|
||||
}
|
||||
export interface Callback<ResponseObject, NextRequestObject, RawResponseObject> {
|
||||
(err: Error | null | undefined, value?: ResponseObject | null, nextRequest?: NextRequestObject, rawResponse?: RawResponseObject): void;
|
||||
}
|
||||
export interface LROperation<ResultType, MetadataType> extends longrunning.Operation {
|
||||
promise(): Promise<[
|
||||
ResultType,
|
||||
MetadataType,
|
||||
operationProtos.google.longrunning.Operation
|
||||
]>;
|
||||
}
|
||||
export interface PaginationCallback<RequestObject, ResponseObject, ResponseType> {
|
||||
(err: Error | null, values?: ResponseType[], nextPageRequest?: RequestObject, rawResponse?: ResponseObject): void;
|
||||
}
|
||||
export interface PaginationResponse<RequestObject, ResponseObject, ResponseType> {
|
||||
values?: ResponseType[];
|
||||
nextPageRequest?: RequestObject;
|
||||
rawResponse?: ResponseObject;
|
||||
}
|
||||
20
functions/node_modules/google-gax/build/src/clientInterface.js
generated
vendored
Normal file
20
functions/node_modules/google-gax/build/src/clientInterface.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
// Copyright 2020 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// ** This file is automatically generated by gapic-generator-typescript. **
|
||||
// ** https://github.com/googleapis/gapic-generator-typescript **
|
||||
// ** All changes to this file may be overwritten. **
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=clientInterface.js.map
|
||||
1
functions/node_modules/google-gax/build/src/clientInterface.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/clientInterface.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"clientInterface.js","sourceRoot":"","sources":["../../src/clientInterface.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,iEAAiE;AACjE,qDAAqD"}
|
||||
38
functions/node_modules/google-gax/build/src/createApiCall.d.ts
generated
vendored
Normal file
38
functions/node_modules/google-gax/build/src/createApiCall.d.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { GaxCall, GRPCCall } from './apitypes';
|
||||
import { Descriptor } from './descriptor';
|
||||
import { CallSettings } from './gax';
|
||||
/**
|
||||
* Converts an rpc call into an API call governed by the settings.
|
||||
*
|
||||
* In typical usage, `func` will be a promise to a callable used to make an rpc
|
||||
* request. This will mostly likely be a bound method from a request stub used
|
||||
* to make an rpc call. It is not a direct function but a Promise instance,
|
||||
* because of its asynchronism (typically, obtaining the auth information).
|
||||
*
|
||||
* The result is a function which manages the API call with the given settings
|
||||
* and the options on the invocation.
|
||||
*
|
||||
* @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
|
||||
* a bare RPC call, or just a bare RPC call.
|
||||
* @param {CallSettings} settings - provides the settings for this call
|
||||
* @param {Descriptor} descriptor - optionally specify the descriptor for
|
||||
* the method call.
|
||||
* @return {GaxCall} func - a bound method on a request stub used
|
||||
* to make an rpc call.
|
||||
*/
|
||||
export declare function createApiCall(func: Promise<GRPCCall> | GRPCCall, settings: CallSettings, descriptor?: Descriptor, _fallback?: boolean | 'proto' | 'rest'): GaxCall;
|
||||
122
functions/node_modules/google-gax/build/src/createApiCall.js
generated
vendored
Normal file
122
functions/node_modules/google-gax/build/src/createApiCall.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createApiCall = createApiCall;
|
||||
/**
|
||||
* Provides function wrappers that implement page streaming and retrying.
|
||||
*/
|
||||
const apiCaller_1 = require("./apiCaller");
|
||||
const gax_1 = require("./gax");
|
||||
const retries_1 = require("./normalCalls/retries");
|
||||
const timeout_1 = require("./normalCalls/timeout");
|
||||
const streamingApiCaller_1 = require("./streamingCalls/streamingApiCaller");
|
||||
const warnings_1 = require("./warnings");
|
||||
/**
|
||||
* Converts an rpc call into an API call governed by the settings.
|
||||
*
|
||||
* In typical usage, `func` will be a promise to a callable used to make an rpc
|
||||
* request. This will mostly likely be a bound method from a request stub used
|
||||
* to make an rpc call. It is not a direct function but a Promise instance,
|
||||
* because of its asynchronism (typically, obtaining the auth information).
|
||||
*
|
||||
* The result is a function which manages the API call with the given settings
|
||||
* and the options on the invocation.
|
||||
*
|
||||
* @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
|
||||
* a bare RPC call, or just a bare RPC call.
|
||||
* @param {CallSettings} settings - provides the settings for this call
|
||||
* @param {Descriptor} descriptor - optionally specify the descriptor for
|
||||
* the method call.
|
||||
* @return {GaxCall} func - a bound method on a request stub used
|
||||
* to make an rpc call.
|
||||
*/
|
||||
function createApiCall(func, settings, descriptor,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_fallback // unused here, used in fallback.ts implementation
|
||||
) {
|
||||
// we want to be able to accept both promise resolving to a function and a
|
||||
// function. Currently client librares are only calling this method with a
|
||||
// promise, but it will change.
|
||||
const funcPromise = typeof func === 'function' ? Promise.resolve(func) : func;
|
||||
// the following apiCaller will be used for all calls of this function...
|
||||
const apiCaller = (0, apiCaller_1.createAPICaller)(settings, descriptor);
|
||||
return (request, callOptions, callback) => {
|
||||
var _a, _b;
|
||||
let currentApiCaller = apiCaller;
|
||||
let thisSettings;
|
||||
if (currentApiCaller instanceof streamingApiCaller_1.StreamingApiCaller) {
|
||||
const gaxStreamingRetries = (_b = (_a = currentApiCaller.descriptor) === null || _a === void 0 ? void 0 : _a.gaxStreamingRetries) !== null && _b !== void 0 ? _b : false;
|
||||
// If Gax streaming retries are enabled, check settings passed at call time and convert parameters if needed
|
||||
const convertedRetryOptions = (0, gax_1.convertRetryOptions)(callOptions, gaxStreamingRetries);
|
||||
thisSettings = settings.merge(convertedRetryOptions);
|
||||
}
|
||||
else {
|
||||
thisSettings = settings.merge(callOptions);
|
||||
}
|
||||
// special case: if bundling is disabled for this one call,
|
||||
// use default API caller instead
|
||||
if (settings.isBundling && !thisSettings.isBundling) {
|
||||
currentApiCaller = (0, apiCaller_1.createAPICaller)(settings, undefined);
|
||||
}
|
||||
const ongoingCall = currentApiCaller.init(callback);
|
||||
funcPromise
|
||||
.then((func) => {
|
||||
var _a, _b;
|
||||
var _c;
|
||||
// Initially, the function is just what gRPC server stub contains.
|
||||
func = currentApiCaller.wrap(func);
|
||||
const streaming = (_a = currentApiCaller.descriptor) === null || _a === void 0 ? void 0 : _a.streaming;
|
||||
const retry = thisSettings.retry;
|
||||
if (streaming && retry) {
|
||||
if (retry.retryCodes.length > 0 && retry.shouldRetryFn) {
|
||||
(0, warnings_1.warn)('either_retrycodes_or_shouldretryfn', 'Only one of retryCodes or shouldRetryFn may be defined. Ignoring retryCodes.');
|
||||
retry.retryCodes = [];
|
||||
}
|
||||
if (!currentApiCaller.descriptor
|
||||
.gaxStreamingRetries &&
|
||||
retry.getResumptionRequestFn) {
|
||||
throw new Error('getResumptionRequestFn can only be used when gaxStreamingRetries is set to true.');
|
||||
}
|
||||
}
|
||||
if (!streaming && retry) {
|
||||
if (retry.shouldRetryFn) {
|
||||
throw new Error('Using a function to determine retry eligibility is only supported with server streaming calls');
|
||||
}
|
||||
if (retry.getResumptionRequestFn) {
|
||||
throw new Error('Resumption strategy can only be used with server streaming retries');
|
||||
}
|
||||
if (retry.retryCodes && retry.retryCodes.length > 0) {
|
||||
(_b = (_c = retry.backoffSettings).initialRpcTimeoutMillis) !== null && _b !== void 0 ? _b : (_c.initialRpcTimeoutMillis = thisSettings.timeout);
|
||||
return (0, retries_1.retryable)(func, thisSettings.retry, thisSettings.otherArgs, thisSettings.apiName);
|
||||
}
|
||||
}
|
||||
return (0, timeout_1.addTimeoutArg)(func, thisSettings.timeout, thisSettings.otherArgs);
|
||||
})
|
||||
.then((apiCall) => {
|
||||
// After adding retries / timeouts, the call function becomes simpler:
|
||||
// it only accepts request and callback.
|
||||
currentApiCaller.call(apiCall, request, thisSettings, ongoingCall);
|
||||
})
|
||||
.catch(err => {
|
||||
currentApiCaller.fail(ongoingCall, err);
|
||||
});
|
||||
// Calls normally return a "cancellable promise" that can be used to `await` for the actual result,
|
||||
// or to cancel the ongoing call.
|
||||
return currentApiCaller.result(ongoingCall);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=createApiCall.js.map
|
||||
1
functions/node_modules/google-gax/build/src/createApiCall.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/createApiCall.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"createApiCall.js","sourceRoot":"","sources":["../../src/createApiCall.ts"],"names":[],"mappings":"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"}
|
||||
24
functions/node_modules/google-gax/build/src/descriptor.d.ts
generated
vendored
Normal file
24
functions/node_modules/google-gax/build/src/descriptor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICaller } from './apiCaller';
|
||||
import { CallSettings } from './gax';
|
||||
export interface Descriptor {
|
||||
getApiCaller(settings: CallSettings): APICaller;
|
||||
}
|
||||
export { LongRunningDescriptor as LongrunningDescriptor } from './longRunningCalls/longRunningDescriptor';
|
||||
export { PageDescriptor } from './paginationCalls/pageDescriptor';
|
||||
export { StreamDescriptor } from './streamingCalls/streamDescriptor';
|
||||
export { BundleDescriptor } from './bundlingCalls/bundleDescriptor';
|
||||
27
functions/node_modules/google-gax/build/src/descriptor.js
generated
vendored
Normal file
27
functions/node_modules/google-gax/build/src/descriptor.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BundleDescriptor = exports.StreamDescriptor = exports.PageDescriptor = exports.LongrunningDescriptor = void 0;
|
||||
var longRunningDescriptor_1 = require("./longRunningCalls/longRunningDescriptor");
|
||||
Object.defineProperty(exports, "LongrunningDescriptor", { enumerable: true, get: function () { return longRunningDescriptor_1.LongRunningDescriptor; } });
|
||||
var pageDescriptor_1 = require("./paginationCalls/pageDescriptor");
|
||||
Object.defineProperty(exports, "PageDescriptor", { enumerable: true, get: function () { return pageDescriptor_1.PageDescriptor; } });
|
||||
var streamDescriptor_1 = require("./streamingCalls/streamDescriptor");
|
||||
Object.defineProperty(exports, "StreamDescriptor", { enumerable: true, get: function () { return streamDescriptor_1.StreamDescriptor; } });
|
||||
var bundleDescriptor_1 = require("./bundlingCalls/bundleDescriptor");
|
||||
Object.defineProperty(exports, "BundleDescriptor", { enumerable: true, get: function () { return bundleDescriptor_1.BundleDescriptor; } });
|
||||
//# sourceMappingURL=descriptor.js.map
|
||||
1
functions/node_modules/google-gax/build/src/descriptor.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/descriptor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../src/descriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAeH,kFAAwG;AAAhG,8HAAA,qBAAqB,OAAyB;AACtD,mEAAgE;AAAxD,gHAAA,cAAc,OAAA;AACtB,sEAAmE;AAA3D,oHAAA,gBAAgB,OAAA;AACxB,qEAAkE;AAA1D,oHAAA,gBAAgB,OAAA"}
|
||||
166
functions/node_modules/google-gax/build/src/fallback.d.ts
generated
vendored
Normal file
166
functions/node_modules/google-gax/build/src/fallback.d.ts
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { OutgoingHttpHeaders } from 'http';
|
||||
import * as protobuf from 'protobufjs';
|
||||
import * as gax from './gax';
|
||||
import * as routingHeader from './routingHeader';
|
||||
import { GoogleAuth, OAuth2Client, Compute, JWT, UserRefreshClient, BaseExternalAccountClient } from 'google-auth-library';
|
||||
import { OperationsClientBuilder } from './operationsClient';
|
||||
import type { GrpcClientOptions, ClientStubOptions } from './grpc';
|
||||
import { GaxCall, GRPCCall } from './apitypes';
|
||||
import { Descriptor } from './descriptor';
|
||||
import { FallbackServiceError } from './googleError';
|
||||
import { google } from '../protos/http';
|
||||
import * as IamProtos from '../protos/iam_service';
|
||||
import * as LocationProtos from '../protos/locations';
|
||||
import * as operationsProtos from '../protos/operations';
|
||||
export { FallbackServiceError };
|
||||
export { PathTemplate } from './pathTemplate';
|
||||
export { routingHeader };
|
||||
export { CallSettings, constructSettings, RetryOptions, createDefaultBackoffSettings, } from './gax';
|
||||
export declare const version: string;
|
||||
export { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor, } from './descriptor';
|
||||
export { StreamType } from './streamingCalls/streaming';
|
||||
export { OperationsClient } from './operationsClient';
|
||||
export { IamClient } from './iamService';
|
||||
export { LocationsClient } from './locationService';
|
||||
export { makeUUID } from './util';
|
||||
export declare const defaultToObjectOptions: {
|
||||
keepCase: boolean;
|
||||
longs: StringConstructor;
|
||||
enums: StringConstructor;
|
||||
defaults: boolean;
|
||||
oneofs: boolean;
|
||||
};
|
||||
export interface ServiceMethods {
|
||||
[name: string]: protobuf.Method;
|
||||
}
|
||||
export type AuthClient = OAuth2Client | Compute | JWT | UserRefreshClient | BaseExternalAccountClient;
|
||||
export declare class GrpcClient {
|
||||
auth?: OAuth2Client | GoogleAuth;
|
||||
authClient?: AuthClient;
|
||||
fallback: boolean;
|
||||
grpcVersion: string;
|
||||
private static protoCache;
|
||||
httpRules?: Array<google.api.IHttpRule>;
|
||||
numericEnums: boolean;
|
||||
/**
|
||||
* In rare cases users might need to deallocate all memory consumed by loaded protos.
|
||||
* This method will delete the proto cache content.
|
||||
*/
|
||||
static clearProtoCache(): void;
|
||||
/**
|
||||
* gRPC-fallback version of GrpcClient
|
||||
* Implements GrpcClient API for a browser using grpc-fallback protocol (sends serialized protobuf to HTTP/1 $rpc endpoint).
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of OAuth2Client to use in browser, or an instance of GoogleAuth from google-auth-library
|
||||
* to use in Node.js. Required for browser, optional for Node.js.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options?: (GrpcClientOptions | {
|
||||
auth: OAuth2Client;
|
||||
}) & {
|
||||
/**
|
||||
* Fallback mode to use instead of gRPC.
|
||||
* A string is accepted for compatibility, all non-empty string values enable the HTTP REST fallback.
|
||||
*/
|
||||
fallback?: boolean | string;
|
||||
});
|
||||
/**
|
||||
* gRPC-fallback version of loadProto
|
||||
* Loads the protobuf root object from a JSON object created from a proto file
|
||||
* @param {Object} jsonObject - A JSON version of a protofile created usin protobuf.js
|
||||
* @returns {Object} Root namespace of proto JSON
|
||||
*/
|
||||
loadProto(jsonObject: {}): protobuf.Root;
|
||||
loadProtoJSON(json: protobuf.INamespace, ignoreCache?: boolean): protobuf.Root;
|
||||
private static getServiceMethods;
|
||||
/**
|
||||
* gRPC-fallback version of constructSettings
|
||||
* A wrapper of {@link constructSettings} function under the gRPC context.
|
||||
*
|
||||
* Most of parameters are common among constructSettings, please take a look.
|
||||
* @param {string} serviceName - The fullly-qualified name of the service.
|
||||
* @param {Object} clientConfig - A dictionary of the client config.
|
||||
* @param {Object} configOverrides - A dictionary of overriding configs.
|
||||
* @param {Object} headers - A dictionary of additional HTTP header name to
|
||||
* its value.
|
||||
* @return {Object} A mapping of method names to CallSettings.
|
||||
*/
|
||||
constructSettings(serviceName: string, clientConfig: gax.ClientConfig, configOverrides: gax.ClientConfig, headers: OutgoingHttpHeaders): any;
|
||||
/**
|
||||
* gRPC-fallback version of createStub
|
||||
* Creates a gRPC-fallback stub with authentication headers built from supplied OAuth2Client instance
|
||||
*
|
||||
* @param {function} CreateStub - The constructor function of the stub.
|
||||
* @param {Object} service - A protobufjs Service object (as returned by lookupService)
|
||||
* @param {Object} opts - Connection options, as described below.
|
||||
* @param {string} opts.servicePath - The hostname of the API endpoint service.
|
||||
* @param {number} opts.port - The port of the service.
|
||||
* @return {Promise} A promise which resolves to a gRPC-fallback service stub, which is a protobuf.js service stub instance modified to match the gRPC stub API
|
||||
*/
|
||||
createStub(service: protobuf.Service, opts: ClientStubOptions, customServicePath?: boolean): Promise<import("./fallbackServiceStub").FallbackServiceStub>;
|
||||
/**
|
||||
* Creates a 'bytelength' function for a given proto message class.
|
||||
*
|
||||
* See {@link BundleDescriptor} about the meaning of the return value.
|
||||
*
|
||||
* @param {function} message - a constructor function that is generated by
|
||||
* protobuf.js. Assumes 'encoder' field in the message.
|
||||
* @return {function(Object):number} - a function to compute the byte length
|
||||
* for an object.
|
||||
*/
|
||||
static createByteLengthFunction(message: typeof protobuf.Message): (obj: {}) => number;
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of lro
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* @return {Object} A OperationsClientBuilder that will return a OperationsClient
|
||||
*/
|
||||
export declare function lro(options: GrpcClientOptions): OperationsClientBuilder;
|
||||
export { operationsProtos, IamProtos, LocationProtos };
|
||||
/**
|
||||
* gRPC-fallback version of createApiCall
|
||||
*
|
||||
* Converts an rpc call into an API call governed by the settings.
|
||||
*
|
||||
* In typical usage, `func` will be a promise to a callable used to make an rpc
|
||||
* request. This will mostly likely be a bound method from a request stub used
|
||||
* to make an rpc call. It is not a direct function but a Promise instance,
|
||||
* because of its asynchronism (typically, obtaining the auth information).
|
||||
*
|
||||
* The result is a function which manages the API call with the given settings
|
||||
* and the options on the invocation.
|
||||
*
|
||||
* Throws exception on unsupported streaming calls
|
||||
*
|
||||
* @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
|
||||
* a bare RPC call, or just a bare RPC call.
|
||||
* @param {CallSettings} settings - provides the settings for this call
|
||||
* @param {Descriptor} descriptor - optionally specify the descriptor for
|
||||
* the method call.
|
||||
* @return {GaxCall} func - a bound method on a request stub used
|
||||
* to make an rpc call.
|
||||
*/
|
||||
export declare function createApiCall(func: Promise<GRPCCall> | GRPCCall, settings: gax.CallSettings, descriptor?: Descriptor, _fallback?: boolean | string): GaxCall;
|
||||
export { protobuf };
|
||||
export * as protobufMinimal from 'protobufjs/minimal';
|
||||
export { warn } from './warnings';
|
||||
export { Operation, operation } from './longRunningCalls/longrunning';
|
||||
export { GoogleError } from './googleError';
|
||||
declare const fallback: any;
|
||||
export { fallback };
|
||||
350
functions/node_modules/google-gax/build/src/fallback.js
generated
vendored
Normal file
350
functions/node_modules/google-gax/build/src/fallback.js
generated
vendored
Normal file
@@ -0,0 +1,350 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fallback = exports.GoogleError = exports.operation = exports.Operation = exports.warn = exports.protobufMinimal = exports.protobuf = exports.LocationProtos = exports.IamProtos = exports.operationsProtos = exports.GrpcClient = exports.defaultToObjectOptions = exports.makeUUID = exports.LocationsClient = exports.IamClient = exports.OperationsClient = exports.StreamType = exports.StreamDescriptor = exports.PageDescriptor = exports.LongrunningDescriptor = exports.BundleDescriptor = exports.version = exports.createDefaultBackoffSettings = exports.RetryOptions = exports.constructSettings = exports.CallSettings = exports.routingHeader = exports.PathTemplate = void 0;
|
||||
exports.lro = lro;
|
||||
exports.createApiCall = createApiCall;
|
||||
const objectHash = require("object-hash");
|
||||
const protobuf = require("protobufjs");
|
||||
exports.protobuf = protobuf;
|
||||
const gax = require("./gax");
|
||||
const routingHeader = require("./routingHeader");
|
||||
exports.routingHeader = routingHeader;
|
||||
const status_1 = require("./status");
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const operationsClient_1 = require("./operationsClient");
|
||||
const createApiCall_1 = require("./createApiCall");
|
||||
const fallbackRest = require("./fallbackRest");
|
||||
const featureDetection_1 = require("./featureDetection");
|
||||
const fallbackServiceStub_1 = require("./fallbackServiceStub");
|
||||
const streaming_1 = require("./streamingCalls/streaming");
|
||||
const util_1 = require("./util");
|
||||
const IamProtos = require("../protos/iam_service");
|
||||
exports.IamProtos = IamProtos;
|
||||
const LocationProtos = require("../protos/locations");
|
||||
exports.LocationProtos = LocationProtos;
|
||||
const operationsProtos = require("../protos/operations");
|
||||
exports.operationsProtos = operationsProtos;
|
||||
var pathTemplate_1 = require("./pathTemplate");
|
||||
Object.defineProperty(exports, "PathTemplate", { enumerable: true, get: function () { return pathTemplate_1.PathTemplate; } });
|
||||
var gax_1 = require("./gax");
|
||||
Object.defineProperty(exports, "CallSettings", { enumerable: true, get: function () { return gax_1.CallSettings; } });
|
||||
Object.defineProperty(exports, "constructSettings", { enumerable: true, get: function () { return gax_1.constructSettings; } });
|
||||
Object.defineProperty(exports, "RetryOptions", { enumerable: true, get: function () { return gax_1.RetryOptions; } });
|
||||
Object.defineProperty(exports, "createDefaultBackoffSettings", { enumerable: true, get: function () { return gax_1.createDefaultBackoffSettings; } });
|
||||
exports.version = require('../../package.json').version + '-fallback';
|
||||
var descriptor_1 = require("./descriptor");
|
||||
Object.defineProperty(exports, "BundleDescriptor", { enumerable: true, get: function () { return descriptor_1.BundleDescriptor; } });
|
||||
Object.defineProperty(exports, "LongrunningDescriptor", { enumerable: true, get: function () { return descriptor_1.LongrunningDescriptor; } });
|
||||
Object.defineProperty(exports, "PageDescriptor", { enumerable: true, get: function () { return descriptor_1.PageDescriptor; } });
|
||||
Object.defineProperty(exports, "StreamDescriptor", { enumerable: true, get: function () { return descriptor_1.StreamDescriptor; } });
|
||||
var streaming_2 = require("./streamingCalls/streaming");
|
||||
Object.defineProperty(exports, "StreamType", { enumerable: true, get: function () { return streaming_2.StreamType; } });
|
||||
var operationsClient_2 = require("./operationsClient");
|
||||
Object.defineProperty(exports, "OperationsClient", { enumerable: true, get: function () { return operationsClient_2.OperationsClient; } });
|
||||
var iamService_1 = require("./iamService");
|
||||
Object.defineProperty(exports, "IamClient", { enumerable: true, get: function () { return iamService_1.IamClient; } });
|
||||
var locationService_1 = require("./locationService");
|
||||
Object.defineProperty(exports, "LocationsClient", { enumerable: true, get: function () { return locationService_1.LocationsClient; } });
|
||||
var util_2 = require("./util");
|
||||
Object.defineProperty(exports, "makeUUID", { enumerable: true, get: function () { return util_2.makeUUID; } });
|
||||
exports.defaultToObjectOptions = {
|
||||
keepCase: false,
|
||||
longs: String,
|
||||
enums: String,
|
||||
defaults: true,
|
||||
oneofs: true,
|
||||
};
|
||||
const CLIENT_VERSION_HEADER = 'x-goog-api-client';
|
||||
class GrpcClient {
|
||||
/**
|
||||
* In rare cases users might need to deallocate all memory consumed by loaded protos.
|
||||
* This method will delete the proto cache content.
|
||||
*/
|
||||
static clearProtoCache() {
|
||||
GrpcClient.protoCache.clear();
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of GrpcClient
|
||||
* Implements GrpcClient API for a browser using grpc-fallback protocol (sends serialized protobuf to HTTP/1 $rpc endpoint).
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of OAuth2Client to use in browser, or an instance of GoogleAuth from google-auth-library
|
||||
* to use in Node.js. Required for browser, optional for Node.js.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
var _a;
|
||||
if (!(0, featureDetection_1.isNodeJS)()) {
|
||||
if (!options.auth) {
|
||||
throw new Error(JSON.stringify(options) +
|
||||
'You need to pass auth instance to use gRPC-fallback client in browser or other non-Node.js environments. Use OAuth2Client from google-auth-library.');
|
||||
}
|
||||
this.auth = options.auth;
|
||||
}
|
||||
else {
|
||||
this.auth =
|
||||
options.auth ||
|
||||
new google_auth_library_1.GoogleAuth(options);
|
||||
}
|
||||
this.fallback = options.fallback ? true : false;
|
||||
this.grpcVersion = require('../../package.json').version;
|
||||
this.httpRules = options.httpRules;
|
||||
this.numericEnums = (_a = options.numericEnums) !== null && _a !== void 0 ? _a : false;
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of loadProto
|
||||
* Loads the protobuf root object from a JSON object created from a proto file
|
||||
* @param {Object} jsonObject - A JSON version of a protofile created usin protobuf.js
|
||||
* @returns {Object} Root namespace of proto JSON
|
||||
*/
|
||||
loadProto(jsonObject) {
|
||||
const rootObject = protobuf.Root.fromJSON(jsonObject);
|
||||
return rootObject;
|
||||
}
|
||||
loadProtoJSON(json, ignoreCache = false) {
|
||||
const hash = objectHash(JSON.stringify(json)).toString();
|
||||
const cached = GrpcClient.protoCache.get(hash);
|
||||
if (cached && !ignoreCache) {
|
||||
return cached;
|
||||
}
|
||||
const root = protobuf.Root.fromJSON(json);
|
||||
GrpcClient.protoCache.set(hash, root);
|
||||
return root;
|
||||
}
|
||||
static getServiceMethods(service) {
|
||||
const methods = {};
|
||||
for (const [methodName, methodObject] of Object.entries(service.methods)) {
|
||||
const methodNameLowerCamelCase = (0, util_1.toLowerCamelCase)(methodName);
|
||||
methods[methodNameLowerCamelCase] = methodObject;
|
||||
}
|
||||
return methods;
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of constructSettings
|
||||
* A wrapper of {@link constructSettings} function under the gRPC context.
|
||||
*
|
||||
* Most of parameters are common among constructSettings, please take a look.
|
||||
* @param {string} serviceName - The fullly-qualified name of the service.
|
||||
* @param {Object} clientConfig - A dictionary of the client config.
|
||||
* @param {Object} configOverrides - A dictionary of overriding configs.
|
||||
* @param {Object} headers - A dictionary of additional HTTP header name to
|
||||
* its value.
|
||||
* @return {Object} A mapping of method names to CallSettings.
|
||||
*/
|
||||
constructSettings(serviceName, clientConfig, configOverrides, headers) {
|
||||
function buildMetadata(abTests, moreHeaders) {
|
||||
const metadata = {};
|
||||
if (!headers) {
|
||||
headers = {};
|
||||
}
|
||||
// Since gRPC expects each header to be an array,
|
||||
// we are doing the same for fallback here.
|
||||
for (const key in headers) {
|
||||
metadata[key] = Array.isArray(headers[key])
|
||||
? headers[key]
|
||||
: [headers[key]];
|
||||
}
|
||||
// gRPC-fallback request must have 'grpc-web/' in 'x-goog-api-client'
|
||||
const clientVersions = [];
|
||||
if (metadata[CLIENT_VERSION_HEADER] &&
|
||||
metadata[CLIENT_VERSION_HEADER][0]) {
|
||||
clientVersions.push(...metadata[CLIENT_VERSION_HEADER][0].split(' '));
|
||||
}
|
||||
clientVersions.push(`grpc-web/${exports.version}`);
|
||||
metadata[CLIENT_VERSION_HEADER] = [clientVersions.join(' ')];
|
||||
if (!moreHeaders) {
|
||||
return metadata;
|
||||
}
|
||||
for (const key in moreHeaders) {
|
||||
if (key.toLowerCase() !== CLIENT_VERSION_HEADER) {
|
||||
const value = moreHeaders[key];
|
||||
if (Array.isArray(value)) {
|
||||
if (metadata[key] === undefined) {
|
||||
metadata[key] = value;
|
||||
}
|
||||
else {
|
||||
if (Array.isArray(metadata[key])) {
|
||||
metadata[key].push(...value);
|
||||
}
|
||||
else {
|
||||
throw new Error(`Can not add value ${value} to the call metadata.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
metadata[key] = [value];
|
||||
}
|
||||
}
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
return gax.constructSettings(serviceName, clientConfig, configOverrides, status_1.Status, { metadataBuilder: buildMetadata });
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of createStub
|
||||
* Creates a gRPC-fallback stub with authentication headers built from supplied OAuth2Client instance
|
||||
*
|
||||
* @param {function} CreateStub - The constructor function of the stub.
|
||||
* @param {Object} service - A protobufjs Service object (as returned by lookupService)
|
||||
* @param {Object} opts - Connection options, as described below.
|
||||
* @param {string} opts.servicePath - The hostname of the API endpoint service.
|
||||
* @param {number} opts.port - The port of the service.
|
||||
* @return {Promise} A promise which resolves to a gRPC-fallback service stub, which is a protobuf.js service stub instance modified to match the gRPC stub API
|
||||
*/
|
||||
async createStub(service, opts,
|
||||
// For consistency with createStub in grpc.ts, customServicePath is defined:
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
customServicePath) {
|
||||
if (!this.authClient) {
|
||||
if (this.auth && 'getClient' in this.auth) {
|
||||
this.authClient = (await this.auth.getClient());
|
||||
}
|
||||
else if (this.auth && 'getRequestHeaders' in this.auth) {
|
||||
this.authClient = this.auth;
|
||||
}
|
||||
}
|
||||
if (!this.authClient) {
|
||||
throw new Error('No authentication was provided');
|
||||
}
|
||||
if (!opts.universeDomain) {
|
||||
opts.universeDomain = 'googleapis.com';
|
||||
}
|
||||
if (opts.universeDomain) {
|
||||
const universeFromAuth = this.authClient.universeDomain;
|
||||
if (universeFromAuth && opts.universeDomain !== universeFromAuth) {
|
||||
throw new Error(`The configured universe domain (${opts.universeDomain}) does not match the universe domain found in the credentials (${universeFromAuth}). ` +
|
||||
"If you haven't configured the universe domain explicitly, googleapis.com is the default.");
|
||||
}
|
||||
}
|
||||
service.resolveAll();
|
||||
const methods = GrpcClient.getServiceMethods(service);
|
||||
const protocol = opts.protocol || 'https';
|
||||
let servicePath = opts.servicePath;
|
||||
if (!servicePath &&
|
||||
service.options &&
|
||||
service.options['(google.api.default_host)']) {
|
||||
servicePath = service.options['(google.api.default_host)'];
|
||||
}
|
||||
if (!servicePath) {
|
||||
throw new Error(`Cannot determine service API path for service ${service.name}.`);
|
||||
}
|
||||
let servicePort;
|
||||
const match = servicePath.match(/^(.*):(\d+)$/);
|
||||
if (match) {
|
||||
servicePath = match[1];
|
||||
servicePort = parseInt(match[2]);
|
||||
}
|
||||
if (opts.port) {
|
||||
servicePort = opts.port;
|
||||
}
|
||||
else if (!servicePort) {
|
||||
servicePort = 443;
|
||||
}
|
||||
const encoder = fallbackRest.encodeRequest;
|
||||
const decoder = fallbackRest.decodeResponse;
|
||||
const serviceStub = (0, fallbackServiceStub_1.generateServiceStub)(methods, protocol, servicePath, servicePort, this.authClient, encoder, decoder, this.numericEnums);
|
||||
return serviceStub;
|
||||
}
|
||||
/**
|
||||
* Creates a 'bytelength' function for a given proto message class.
|
||||
*
|
||||
* See {@link BundleDescriptor} about the meaning of the return value.
|
||||
*
|
||||
* @param {function} message - a constructor function that is generated by
|
||||
* protobuf.js. Assumes 'encoder' field in the message.
|
||||
* @return {function(Object):number} - a function to compute the byte length
|
||||
* for an object.
|
||||
*/
|
||||
static createByteLengthFunction(message) {
|
||||
return gax.createByteLengthFunction(message);
|
||||
}
|
||||
}
|
||||
exports.GrpcClient = GrpcClient;
|
||||
GrpcClient.protoCache = new Map();
|
||||
/**
|
||||
* gRPC-fallback version of lro
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* @return {Object} A OperationsClientBuilder that will return a OperationsClient
|
||||
*/
|
||||
function lro(options) {
|
||||
options = Object.assign({ scopes: [] }, options);
|
||||
if (options.protoJson) {
|
||||
options = Object.assign(options, { fallback: true });
|
||||
}
|
||||
const gaxGrpc = new GrpcClient(options);
|
||||
return new operationsClient_1.OperationsClientBuilder(gaxGrpc, options.protoJson);
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of createApiCall
|
||||
*
|
||||
* Converts an rpc call into an API call governed by the settings.
|
||||
*
|
||||
* In typical usage, `func` will be a promise to a callable used to make an rpc
|
||||
* request. This will mostly likely be a bound method from a request stub used
|
||||
* to make an rpc call. It is not a direct function but a Promise instance,
|
||||
* because of its asynchronism (typically, obtaining the auth information).
|
||||
*
|
||||
* The result is a function which manages the API call with the given settings
|
||||
* and the options on the invocation.
|
||||
*
|
||||
* Throws exception on unsupported streaming calls
|
||||
*
|
||||
* @param {Promise<GRPCCall>|GRPCCall} func - is either a promise to be used to make
|
||||
* a bare RPC call, or just a bare RPC call.
|
||||
* @param {CallSettings} settings - provides the settings for this call
|
||||
* @param {Descriptor} descriptor - optionally specify the descriptor for
|
||||
* the method call.
|
||||
* @return {GaxCall} func - a bound method on a request stub used
|
||||
* to make an rpc call.
|
||||
*/
|
||||
function createApiCall(func, settings, descriptor,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
_fallback // unused; for compatibility only
|
||||
) {
|
||||
if (descriptor &&
|
||||
'streaming' in descriptor &&
|
||||
descriptor.type !== streaming_1.StreamType.SERVER_STREAMING) {
|
||||
return () => {
|
||||
throw new Error('The REST transport currently does not support client-streaming or bidi-stream calls.');
|
||||
};
|
||||
}
|
||||
if (descriptor && 'streaming' in descriptor && !(0, featureDetection_1.isNodeJS)()) {
|
||||
return () => {
|
||||
throw new Error('Server streaming over the REST transport is only supported in Node.js.');
|
||||
};
|
||||
}
|
||||
return (0, createApiCall_1.createApiCall)(func, settings, descriptor);
|
||||
}
|
||||
exports.protobufMinimal = require("protobufjs/minimal");
|
||||
var warnings_1 = require("./warnings");
|
||||
Object.defineProperty(exports, "warn", { enumerable: true, get: function () { return warnings_1.warn; } });
|
||||
var longrunning_1 = require("./longRunningCalls/longrunning");
|
||||
Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return longrunning_1.Operation; } });
|
||||
Object.defineProperty(exports, "operation", { enumerable: true, get: function () { return longrunning_1.operation; } });
|
||||
var googleError_1 = require("./googleError");
|
||||
Object.defineProperty(exports, "GoogleError", { enumerable: true, get: function () { return googleError_1.GoogleError; } });
|
||||
// Different environments or bundlers may or may not respect "browser" field
|
||||
// in package.json (e.g. Electron does not respect it, but if you run the code
|
||||
// through webpack first, it will follow the "browser" field).
|
||||
// To make it safer and more compatible, let's make sure that if you do
|
||||
// const gax = require("google-gax");
|
||||
// you can always ask for gax.fallback, regardless of "browser" field being
|
||||
// understood or not.
|
||||
const fallback = module.exports;
|
||||
exports.fallback = fallback;
|
||||
//# sourceMappingURL=fallback.js.map
|
||||
1
functions/node_modules/google-gax/build/src/fallback.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/fallback.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
18
functions/node_modules/google-gax/build/src/fallbackRest.d.ts
generated
vendored
Normal file
18
functions/node_modules/google-gax/build/src/fallbackRest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { FetchParameters } from './fallbackServiceStub';
|
||||
export declare function encodeRequest(rpc: protobuf.Method, protocol: string, servicePath: string, servicePort: number, request: {}, numericEnums: boolean): FetchParameters;
|
||||
export declare function decodeResponse(rpc: protobuf.Method, ok: boolean, response: Buffer | ArrayBuffer): {};
|
||||
78
functions/node_modules/google-gax/build/src/fallbackRest.js
generated
vendored
Normal file
78
functions/node_modules/google-gax/build/src/fallbackRest.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.encodeRequest = encodeRequest;
|
||||
exports.decodeResponse = decodeResponse;
|
||||
// proto-over-HTTP request encoding and decoding
|
||||
const serializer = require("proto3-json-serializer");
|
||||
const fallback_1 = require("./fallback");
|
||||
const googleError_1 = require("./googleError");
|
||||
const transcoding_1 = require("./transcoding");
|
||||
function encodeRequest(rpc, protocol, servicePath, servicePort, request, numericEnums) {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
const message = rpc.resolvedRequestType.fromObject(request);
|
||||
const json = serializer.toProto3JSON(message, {
|
||||
numericEnums,
|
||||
});
|
||||
if (!json) {
|
||||
throw new Error(`Cannot send null request to RPC ${rpc.name}.`);
|
||||
}
|
||||
if (typeof json !== 'object' || Array.isArray(json)) {
|
||||
throw new Error(`Request to RPC ${rpc.name} must be an object.`);
|
||||
}
|
||||
const transcoded = (0, transcoding_1.transcode)(json, rpc.parsedOptions);
|
||||
if (!transcoded) {
|
||||
throw new Error(`Cannot build HTTP request for ${JSON.stringify(json)}, method: ${rpc.name}`);
|
||||
}
|
||||
// If numeric enums feature is requested, add extra parameter to the query string
|
||||
if (numericEnums) {
|
||||
transcoded.queryString =
|
||||
(transcoded.queryString ? `${transcoded.queryString}&` : '') +
|
||||
'$alt=json%3Benum-encoding=int';
|
||||
}
|
||||
// Converts httpMethod to method that permitted in standard Fetch API spec
|
||||
// https://fetch.spec.whatwg.org/#methods
|
||||
const method = transcoded.httpMethod.toUpperCase();
|
||||
const body = JSON.stringify(transcoded.data);
|
||||
const url = `${protocol}://${servicePath}:${servicePort}/${transcoded.url.replace(/^\//, '')}?${transcoded.queryString}`;
|
||||
return {
|
||||
method,
|
||||
url,
|
||||
headers,
|
||||
body,
|
||||
};
|
||||
}
|
||||
function decodeResponse(rpc, ok, response) {
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
const decodedString = new TextDecoder().decode(response);
|
||||
if (!decodedString) {
|
||||
throw new Error(`Received null response from RPC ${rpc.name}`);
|
||||
}
|
||||
const json = JSON.parse(decodedString);
|
||||
if (!ok) {
|
||||
const error = googleError_1.GoogleError.parseHttpError(json);
|
||||
throw error;
|
||||
}
|
||||
const message = serializer.fromProto3JSON(rpc.resolvedResponseType, json);
|
||||
if (!message) {
|
||||
throw new Error(`Received null or malformed response from JSON serializer from RPC ${rpc.name}`);
|
||||
}
|
||||
return rpc.resolvedResponseType.toObject(message, fallback_1.defaultToObjectOptions);
|
||||
}
|
||||
//# sourceMappingURL=fallbackRest.js.map
|
||||
1
functions/node_modules/google-gax/build/src/fallbackRest.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/fallbackRest.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fallbackRest.js","sourceRoot":"","sources":["../../src/fallbackRest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAUH,sCAsDC;AAED,wCAsBC;AAtFD,gDAAgD;AAEhD,qDAAqD;AACrD,yCAAkD;AAElD,+CAA0C;AAC1C,+CAAwC;AAExC,SAAgB,aAAa,CAC3B,GAAoB,EACpB,QAAgB,EAChB,WAAmB,EACnB,WAAmB,EACnB,OAAW,EACX,YAAqB;IAErB,MAAM,OAAO,GAA4B;QACvC,cAAc,EAAE,kBAAkB;KACnC,CAAC;IACF,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE;QAC5C,YAAY;KACb,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,IAAI,qBAAqB,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAEtD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aACnD,GAAG,CAAC,IACN,EAAE,CACH,CAAC;IACJ,CAAC;IAED,iFAAiF;IACjF,IAAI,YAAY,EAAE,CAAC;QACjB,UAAU,CAAC,WAAW;YACpB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5D,+BAA+B,CAAC;IACpC,CAAC;IAED,0EAA0E;IAC1E,yCAAyC;IACzC,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,WAAW,EAA2B,CAAC;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,GAAG,QAAQ,MAAM,WAAW,IAAI,WAAW,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAC/E,KAAK,EACL,EAAE,CACH,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;IAE9B,OAAO;QACL,MAAM;QACN,GAAG;QACH,OAAO;QACP,IAAI;KACL,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc,CAC5B,GAAoB,EACpB,EAAW,EACX,QAA8B;IAE9B,mEAAmE;IACnE,MAAM,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,KAAK,GAAG,yBAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,KAAK,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAqB,EAAE,IAAI,CAAC,CAAC;IAC3E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,qEAAqE,GAAG,CAAC,IAAI,EAAE,CAChF,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,oBAAqB,CAAC,QAAQ,CAAC,OAAO,EAAE,iCAAsB,CAAC,CAAC;AAC7E,CAAC"}
|
||||
34
functions/node_modules/google-gax/build/src/fallbackServiceStub.d.ts
generated
vendored
Normal file
34
functions/node_modules/google-gax/build/src/fallbackServiceStub.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { AuthClient } from './fallback';
|
||||
import { StreamArrayParser } from './streamArrayParser';
|
||||
export interface FallbackServiceStub {
|
||||
[method: string]: (request: {}, options?: {}, metadata?: {}, callback?: (err?: Error, response?: {} | undefined) => void) => StreamArrayParser | {
|
||||
cancel: () => void;
|
||||
};
|
||||
}
|
||||
export type FetchParametersMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||
export interface FetchParameters {
|
||||
headers: {
|
||||
[key: string]: string;
|
||||
};
|
||||
body: Buffer | Uint8Array | string;
|
||||
method: FetchParametersMethod;
|
||||
url: string;
|
||||
}
|
||||
export declare function generateServiceStub(rpcs: {
|
||||
[name: string]: protobuf.Method;
|
||||
}, protocol: string, servicePath: string, servicePort: number, authClient: AuthClient, requestEncoder: (rpc: protobuf.Method, protocol: string, servicePath: string, servicePort: number, request: {}, numericEnums: boolean) => FetchParameters, responseDecoder: (rpc: protobuf.Method, ok: boolean, response: Buffer | ArrayBuffer) => {}, numericEnums: boolean): FallbackServiceStub;
|
||||
152
functions/node_modules/google-gax/build/src/fallbackServiceStub.js
generated
vendored
Normal file
152
functions/node_modules/google-gax/build/src/fallbackServiceStub.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.generateServiceStub = generateServiceStub;
|
||||
/* global window */
|
||||
/* global AbortController */
|
||||
const node_fetch_1 = require("node-fetch");
|
||||
const abort_controller_1 = require("abort-controller");
|
||||
const featureDetection_1 = require("./featureDetection");
|
||||
const streamArrayParser_1 = require("./streamArrayParser");
|
||||
const stream_1 = require("stream");
|
||||
function generateServiceStub(rpcs, protocol, servicePath, servicePort, authClient, requestEncoder, responseDecoder, numericEnums) {
|
||||
const fetch = (0, featureDetection_1.hasWindowFetch)()
|
||||
? window.fetch
|
||||
: node_fetch_1.default;
|
||||
const serviceStub = {
|
||||
// close method should close all cancel controllers. If this feature request in the future, we can have a cancelControllerFactory that tracks created cancel controllers, and abort them all in close method.
|
||||
close: () => {
|
||||
return { cancel: () => { } };
|
||||
},
|
||||
};
|
||||
for (const [rpcName, rpc] of Object.entries(rpcs)) {
|
||||
serviceStub[rpcName] = (request, options, _metadata, callback) => {
|
||||
options !== null && options !== void 0 ? options : (options = {});
|
||||
// We cannot use async-await in this function because we need to return the canceller object as soon as possible.
|
||||
// Using plain old promises instead.
|
||||
let fetchParameters;
|
||||
try {
|
||||
fetchParameters = requestEncoder(rpc, protocol, servicePath, servicePort, request, numericEnums);
|
||||
}
|
||||
catch (err) {
|
||||
// we could not encode parameters; pass error to the callback
|
||||
// and return a no-op canceler object.
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
return {
|
||||
cancel() { },
|
||||
};
|
||||
}
|
||||
const cancelController = (0, featureDetection_1.hasAbortController)()
|
||||
? new AbortController()
|
||||
: new abort_controller_1.AbortController();
|
||||
const cancelSignal = cancelController.signal;
|
||||
let cancelRequested = false;
|
||||
const url = fetchParameters.url;
|
||||
const headers = fetchParameters.headers;
|
||||
for (const key of Object.keys(options)) {
|
||||
headers[key] = options[key][0];
|
||||
}
|
||||
const streamArrayParser = new streamArrayParser_1.StreamArrayParser(rpc);
|
||||
authClient
|
||||
.getRequestHeaders()
|
||||
.then(authHeader => {
|
||||
const fetchRequest = {
|
||||
headers: {
|
||||
...authHeader,
|
||||
...headers,
|
||||
},
|
||||
body: fetchParameters.body,
|
||||
method: fetchParameters.method,
|
||||
signal: cancelSignal,
|
||||
};
|
||||
if (fetchParameters.method === 'GET' ||
|
||||
fetchParameters.method === 'DELETE') {
|
||||
delete fetchRequest['body'];
|
||||
}
|
||||
return fetch(url, fetchRequest);
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok && rpc.responseStream) {
|
||||
(0, stream_1.pipeline)(response.body, streamArrayParser, (err) => {
|
||||
if (err &&
|
||||
(!cancelRequested ||
|
||||
(err instanceof Error && err.name !== 'AbortError'))) {
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
streamArrayParser.emit('error', err);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
return Promise.all([
|
||||
Promise.resolve(response.ok),
|
||||
response.arrayBuffer(),
|
||||
])
|
||||
.then(([ok, buffer]) => {
|
||||
const response = responseDecoder(rpc, ok, buffer);
|
||||
callback(null, response);
|
||||
})
|
||||
.catch((err) => {
|
||||
if (!cancelRequested || err.name !== 'AbortError') {
|
||||
if (rpc.responseStream) {
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
streamArrayParser.emit('error', err);
|
||||
}
|
||||
else if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
if (rpc.responseStream) {
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
streamArrayParser.emit('error', err);
|
||||
}
|
||||
else if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
if (rpc.responseStream) {
|
||||
return streamArrayParser;
|
||||
}
|
||||
return {
|
||||
cancel: () => {
|
||||
cancelRequested = true;
|
||||
cancelController.abort();
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
return serviceStub;
|
||||
}
|
||||
//# sourceMappingURL=fallbackServiceStub.js.map
|
||||
1
functions/node_modules/google-gax/build/src/fallbackServiceStub.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/fallbackServiceStub.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fallbackServiceStub.js","sourceRoot":"","sources":["../../src/fallbackServiceStub.ts"],"names":[],"mappings":"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"}
|
||||
18
functions/node_modules/google-gax/build/src/featureDetection.d.ts
generated
vendored
Normal file
18
functions/node_modules/google-gax/build/src/featureDetection.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export declare function hasWindowFetch(): boolean;
|
||||
export declare function isNodeJS(): string | false;
|
||||
export declare function hasAbortController(): boolean;
|
||||
43
functions/node_modules/google-gax/build/src/featureDetection.js
generated
vendored
Normal file
43
functions/node_modules/google-gax/build/src/featureDetection.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2021 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hasWindowFetch = hasWindowFetch;
|
||||
exports.isNodeJS = isNodeJS;
|
||||
exports.hasAbortController = hasAbortController;
|
||||
/* global window */
|
||||
const features = {
|
||||
windowFetch: typeof window !== 'undefined' &&
|
||||
(window === null || window === void 0 ? void 0 : window.fetch) &&
|
||||
typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function',
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
textEncoder: typeof TextEncoder !== 'undefined',
|
||||
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||
textDecoder: typeof TextDecoder !== 'undefined',
|
||||
nodeJS: typeof process !== 'undefined' && ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node),
|
||||
abortController: typeof AbortController !== 'undefined',
|
||||
};
|
||||
function hasWindowFetch() {
|
||||
return features.windowFetch;
|
||||
}
|
||||
function isNodeJS() {
|
||||
return features.nodeJS;
|
||||
}
|
||||
function hasAbortController() {
|
||||
return features.abortController;
|
||||
}
|
||||
//# sourceMappingURL=featureDetection.js.map
|
||||
1
functions/node_modules/google-gax/build/src/featureDetection.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/featureDetection.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"featureDetection.js","sourceRoot":"","sources":["../../src/featureDetection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAiBH,wCAEC;AAED,4BAEC;AAED,gDAEC;AAzBD,mBAAmB;AAEnB,MAAM,QAAQ,GAAG;IACf,WAAW,EACT,OAAO,MAAM,KAAK,WAAW;SAC7B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAA;QACb,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAA,KAAK,UAAU;IACrC,mEAAmE;IACnE,WAAW,EAAE,OAAO,WAAW,KAAK,WAAW;IAC/C,mEAAmE;IACnE,WAAW,EAAE,OAAO,WAAW,KAAK,WAAW;IAC/C,MAAM,EAAE,OAAO,OAAO,KAAK,WAAW,KAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,IAAI,CAAA;IACjE,eAAe,EAAE,OAAO,eAAe,KAAK,WAAW;CACxD,CAAC;AAEF,SAAgB,cAAc;IAC5B,OAAO,QAAQ,CAAC,WAAW,CAAC;AAC9B,CAAC;AAED,SAAgB,QAAQ;IACtB,OAAO,QAAQ,CAAC,MAAM,CAAC;AACzB,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,QAAQ,CAAC,eAAe,CAAC;AAClC,CAAC"}
|
||||
381
functions/node_modules/google-gax/build/src/gax.d.ts
generated
vendored
Normal file
381
functions/node_modules/google-gax/build/src/gax.d.ts
generated
vendored
Normal file
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Google API Extensions
|
||||
*/
|
||||
import type { Message } from 'protobufjs';
|
||||
import { GoogleError } from './googleError';
|
||||
import { BundleOptions } from './bundlingCalls/bundleExecutor';
|
||||
import { RequestType } from './apitypes';
|
||||
/**
|
||||
* Encapsulates the overridable settings for a particular API call.
|
||||
*
|
||||
* ``CallOptions`` is an optional arg for all GAX API calls. It is used to
|
||||
* configure the settings of a specific API call.
|
||||
*
|
||||
* When provided, its values override the GAX service defaults for that
|
||||
* particular call.
|
||||
*
|
||||
* Typically the API clients will accept this as the second to the last
|
||||
* argument. See the examples below.
|
||||
* @typedef {Object} CallOptions
|
||||
* @property {number=} timeout - The client-side timeout for API calls.
|
||||
* @property {RetryOptions=} retry - determines whether and how to retry
|
||||
* on transient errors. When set to null, the call will not retry.
|
||||
* @property {boolean=} autoPaginate - If set to false and the call is
|
||||
* configured for paged iteration, page unrolling is not performed, instead
|
||||
* the callback will be called with the response object.
|
||||
* @property {Object=} pageToken - If set and the call is configured for
|
||||
* paged iteration, paged iteration is not performed and requested with this
|
||||
* pageToken.
|
||||
* @property {number} maxResults - If set and the call is configured for
|
||||
* paged iteration, the call will stop when the number of response elements
|
||||
* reaches to the specified size. By default, it will unroll the page to
|
||||
* the end of the list.
|
||||
* @property {boolean=} isBundling - If set to false and the call is configured
|
||||
* for bundling, bundling is not performed.
|
||||
* @property {BackoffSettings=} longrunning - BackoffSettings used for polling.
|
||||
* @example
|
||||
* // suppress bundling for bundled method.
|
||||
* api.bundlingMethod(
|
||||
* param, {optParam: aValue, isBundling: false}, function(err, response) {
|
||||
* // handle response.
|
||||
* });
|
||||
* @example
|
||||
* // suppress streaming for page-streaming method.
|
||||
* api.pageStreamingMethod(
|
||||
* param, {optParam: aValue, autoPaginate: false}, function(err, page) {
|
||||
* // not returning a stream, but callback is called with the paged response.
|
||||
* });
|
||||
*/
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
* @implements {RetryOptionsType}
|
||||
* @typedef {Object} RetryOptions
|
||||
* @property {number[]} retryCodes
|
||||
* @property {BackoffSettings} backoffSettings
|
||||
* @property {(function)} shouldRetryFn
|
||||
* @property {(function)} getResumptionRequestFn
|
||||
*/
|
||||
export declare class RetryOptions {
|
||||
retryCodes: number[];
|
||||
backoffSettings: BackoffSettings;
|
||||
shouldRetryFn?: (error: GoogleError) => boolean;
|
||||
getResumptionRequestFn?: (request: RequestType) => RequestType;
|
||||
constructor(retryCodes: number[], backoffSettings: BackoffSettings, shouldRetryFn?: (error: GoogleError) => boolean, getResumptionRequestFn?: (request: RequestType) => RequestType);
|
||||
}
|
||||
/**
|
||||
* Per-call configurable settings for working with retry-request
|
||||
* See the repo README for more about the parameters
|
||||
* https://github.com/googleapis/retry-request
|
||||
* Will be deprecated in a future release. Only relevant to server streaming calls
|
||||
* @typedef {Object} RetryOptions
|
||||
* @property {boolean} objectMode - when true utilizes object mode in streams
|
||||
* @property {request} request - the request to retry
|
||||
* @property {number} noResponseRetries - number of times to retry on no response
|
||||
* @property {number} currentRetryAttempt - what # retry attempt retry-request is on
|
||||
* @property {Function} shouldRetryFn - determines whether to retry, returns a boolean
|
||||
* @property {number} maxRetryDelay - maximum retry delay in seconds
|
||||
* @property {number} retryDelayMultiplier - multiplier to increase the delay in between completion of failed requests
|
||||
* @property {number} totalTimeout - total timeout in seconds
|
||||
*/
|
||||
export interface RetryRequestOptions {
|
||||
objectMode?: boolean;
|
||||
request?: any;
|
||||
retries?: number;
|
||||
noResponseRetries?: number;
|
||||
currentRetryAttempt?: number;
|
||||
shouldRetryFn?: (error: GoogleError) => boolean;
|
||||
maxRetryDelay?: number;
|
||||
retryDelayMultiplier?: number;
|
||||
totalTimeout?: number;
|
||||
}
|
||||
/**
|
||||
* Parameters to the exponential backoff algorithm for retrying.
|
||||
* @typedef {Object} BackoffSettings
|
||||
* @property {number} initialRetryDelayMillis - the initial delay time,
|
||||
* in milliseconds, between the completion of the first failed request and the
|
||||
* initiation of the first retrying request.
|
||||
* @property {number} retryDelayMultiplier - the multiplier by which to
|
||||
* increase the delay time between the completion of failed requests, and the
|
||||
* initiation of the subsequent retrying request.
|
||||
* @property {number} maxRetryDelayMillis - the maximum delay time, in
|
||||
* milliseconds, between requests. When this value is reached,
|
||||
* ``retryDelayMultiplier`` will no longer be used to increase delay time.
|
||||
* @property {number} initialRpcTimeoutMillis - the initial timeout parameter
|
||||
* to the request.
|
||||
* @propetry {number} rpcTimeoutMultiplier - the multiplier by which to
|
||||
* increase the timeout parameter between failed requests.
|
||||
* @property {number} maxRpcTimeoutMillis - the maximum timeout parameter, in
|
||||
* milliseconds, for a request. When this value is reached,
|
||||
* ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout.
|
||||
* @property {number} totalTimeoutMillis - the total time, in milliseconds,
|
||||
* starting from when the initial request is sent, after which an error will
|
||||
* be returned, regardless of the retrying attempts made meanwhile.
|
||||
*/
|
||||
export interface BackoffSettings {
|
||||
maxRetries?: number;
|
||||
initialRetryDelayMillis: number;
|
||||
retryDelayMultiplier: number;
|
||||
maxRetryDelayMillis: number;
|
||||
initialRpcTimeoutMillis?: number | null;
|
||||
maxRpcTimeoutMillis?: number | null;
|
||||
totalTimeoutMillis?: number | null;
|
||||
rpcTimeoutMultiplier?: number | null;
|
||||
}
|
||||
export interface CallOptions {
|
||||
timeout?: number;
|
||||
retry?: Partial<RetryOptions> | null;
|
||||
autoPaginate?: boolean;
|
||||
maxResults?: number;
|
||||
maxRetries?: number;
|
||||
otherArgs?: {
|
||||
[index: string]: any;
|
||||
};
|
||||
bundleOptions?: BundleOptions | null;
|
||||
isBundling?: boolean;
|
||||
longrunning?: BackoffSettings;
|
||||
apiName?: string;
|
||||
retryRequestOptions?: RetryRequestOptions;
|
||||
}
|
||||
export declare class CallSettings {
|
||||
timeout: number;
|
||||
retry?: RetryOptions | null;
|
||||
autoPaginate?: boolean;
|
||||
pageToken?: string;
|
||||
pageSize?: number;
|
||||
maxResults?: number;
|
||||
otherArgs: {
|
||||
[index: string]: any;
|
||||
};
|
||||
bundleOptions?: BundleOptions | null;
|
||||
isBundling: boolean;
|
||||
longrunning?: BackoffSettings;
|
||||
apiName?: string;
|
||||
retryRequestOptions?: RetryRequestOptions;
|
||||
/**
|
||||
* @param {Object} settings - An object containing parameters of this settings.
|
||||
* @param {number} settings.timeout - The client-side timeout for API calls.
|
||||
* This parameter is ignored for retrying calls.
|
||||
* @param {RetryOptions} settings.retry - The configuration for retrying upon
|
||||
* transient error. If set to null, this call will not retry.
|
||||
* @param {boolean} settings.autoPaginate - If there is no `pageDescriptor`,
|
||||
* this attrbute has no meaning. Otherwise, determines whether a page
|
||||
* streamed response should make the page structure transparent to the user by
|
||||
* flattening the repeated field in the returned generator.
|
||||
* @param {number} settings.pageToken - If there is no `pageDescriptor`,
|
||||
* this attribute has no meaning. Otherwise, determines the page token used
|
||||
* in the page streaming request.
|
||||
* @param {Object} settings.otherArgs - Additional arguments to be passed to
|
||||
* the API calls.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(settings?: CallOptions);
|
||||
/**
|
||||
* Returns a new CallSettings merged from this and a CallOptions object.
|
||||
*
|
||||
* @param {CallOptions} options - an instance whose values override
|
||||
* those in this object. If null, ``merge`` returns a copy of this
|
||||
* object
|
||||
* @return {CallSettings} The merged CallSettings instance.
|
||||
*/
|
||||
merge(options?: CallOptions | null): CallSettings;
|
||||
}
|
||||
/**
|
||||
* Validates passed retry options in preparation for eventual parameter deprecation
|
||||
* converts retryRequestOptions to retryOptions
|
||||
* then sets retryRequestOptions to null
|
||||
*
|
||||
* @param {CallOptions} options - a list of passed retry option
|
||||
* @return {CallOptions} A new CallOptions object.
|
||||
*
|
||||
*/
|
||||
export declare function convertRetryOptions(options?: CallOptions, gaxStreamingRetries?: boolean): CallOptions | undefined;
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
* @param {number[]} retryCodes - a list of Google API canonical error codes OR a function that returns a boolean to determine retry behavior
|
||||
* upon which a retry should be attempted.
|
||||
* @param {BackoffSettings} backoffSettings - configures the retry
|
||||
* exponential backoff algorithm.
|
||||
* @param {function} shouldRetryFn - a function that determines whether a call should retry. If this is defined retryCodes must be empty
|
||||
* @param {function} getResumptionRequestFn - a function with a resumption strategy - only used with server streaming retries
|
||||
* @return {RetryOptions} A new RetryOptions object.
|
||||
*
|
||||
*/
|
||||
export declare function createRetryOptions(retryCodes: number[], backoffSettings: BackoffSettings, shouldRetryFn?: (error: GoogleError) => boolean, getResumptionRequestFn?: (request: RequestType) => RequestType): RetryOptions;
|
||||
/**
|
||||
* Parameters to the exponential backoff algorithm for retrying.
|
||||
*
|
||||
* @param {number} initialRetryDelayMillis - the initial delay time,
|
||||
* in milliseconds, between the completion of the first failed request and the
|
||||
* initiation of the first retrying request.
|
||||
* @param {number} retryDelayMultiplier - the multiplier by which to
|
||||
* increase the delay time between the completion of failed requests, and the
|
||||
* initiation of the subsequent retrying request.
|
||||
* @param {number} maxRetryDelayMillis - the maximum delay time, in
|
||||
* milliseconds, between requests. When this value is reached,
|
||||
* ``retryDelayMultiplier`` will no longer be used to increase delay time.
|
||||
* @param {number} initialRpcTimeoutMillis - the initial timeout parameter
|
||||
* to the request.
|
||||
* @param {number} rpcTimeoutMultiplier - the multiplier by which to
|
||||
* increase the timeout parameter between failed requests.
|
||||
* @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in
|
||||
* milliseconds, for a request. When this value is reached,
|
||||
* ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout.
|
||||
* @param {number} totalTimeoutMillis - the total time, in milliseconds,
|
||||
* starting from when the initial request is sent, after which an error will
|
||||
* be returned, regardless of the retrying attempts made meanwhile.
|
||||
* @return {BackoffSettings} a new settings.
|
||||
*
|
||||
*/
|
||||
export declare function createBackoffSettings(initialRetryDelayMillis: number, retryDelayMultiplier: number, maxRetryDelayMillis: number, initialRpcTimeoutMillis: number | null, rpcTimeoutMultiplier: number | null, maxRpcTimeoutMillis: number | null, totalTimeoutMillis: number | null): BackoffSettings;
|
||||
export declare function createDefaultBackoffSettings(): BackoffSettings;
|
||||
/**
|
||||
* Parameters to the exponential backoff algorithm for retrying.
|
||||
* This function is unsupported, and intended for internal use only.
|
||||
*
|
||||
* @param {number} initialRetryDelayMillis - the initial delay time,
|
||||
* in milliseconds, between the completion of the first failed request and the
|
||||
* initiation of the first retrying request.
|
||||
* @param {number} retryDelayMultiplier - the multiplier by which to
|
||||
* increase the delay time between the completion of failed requests, and the
|
||||
* initiation of the subsequent retrying request.
|
||||
* @param {number} maxRetryDelayMillis - the maximum delay time, in
|
||||
* milliseconds, between requests. When this value is reached,
|
||||
* ``retryDelayMultiplier`` will no longer be used to increase delay time.
|
||||
* @param {number} initialRpcTimeoutMillis - the initial timeout parameter
|
||||
* to the request.
|
||||
* @param {number} rpcTimeoutMultiplier - the multiplier by which to
|
||||
* increase the timeout parameter between failed requests.
|
||||
* @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in
|
||||
* milliseconds, for a request. When this value is reached,
|
||||
* ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout.
|
||||
* @param {number} maxRetries - the maximum number of retrying attempts that
|
||||
* will be made. If reached, an error will be returned.
|
||||
* @return {BackoffSettings} a new settings.
|
||||
*
|
||||
*/
|
||||
export declare function createMaxRetriesBackoffSettings(initialRetryDelayMillis: number, retryDelayMultiplier: number, maxRetryDelayMillis: number, initialRpcTimeoutMillis: number, rpcTimeoutMultiplier: number, maxRpcTimeoutMillis: number, maxRetries: number): BackoffSettings;
|
||||
/**
|
||||
* Creates a new {@link BundleOptions}.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} options - An object to hold optional parameters. See
|
||||
* properties for the content of options.
|
||||
* @return {BundleOptions} - A new options.
|
||||
*/
|
||||
export declare function createBundleOptions(options: BundlingConfig): BundleOptions;
|
||||
export interface ServiceConfig {
|
||||
retry_codes?: {
|
||||
[index: string]: string[];
|
||||
};
|
||||
retry_params?: {
|
||||
[index: string]: RetryParamsConfig;
|
||||
};
|
||||
methods: {
|
||||
[index: string]: MethodConfig | null;
|
||||
};
|
||||
}
|
||||
export interface RetryParamsConfig {
|
||||
initial_retry_delay_millis: number;
|
||||
retry_delay_multiplier: number;
|
||||
max_retry_delay_millis: number;
|
||||
initial_rpc_timeout_millis: number;
|
||||
rpc_timeout_multiplier: number;
|
||||
max_rpc_timeout_millis: number;
|
||||
total_timeout_millis: number;
|
||||
}
|
||||
export interface MethodConfig {
|
||||
retry_codes_name?: string;
|
||||
retry_params_name?: string;
|
||||
bundling?: BundlingConfig | null;
|
||||
timeout_millis?: number;
|
||||
}
|
||||
export interface BundlingConfig {
|
||||
element_count_threshold: number;
|
||||
element_count_limit: number;
|
||||
request_byte_threshold?: number;
|
||||
request_byte_limit?: number;
|
||||
delay_threshold_millis?: number;
|
||||
}
|
||||
export interface ClientConfig {
|
||||
interfaces?: {
|
||||
[index: string]: ServiceConfig;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Constructs a dictionary mapping method names to {@link CallSettings}.
|
||||
*
|
||||
* The `clientConfig` parameter is parsed from a client configuration JSON
|
||||
* file of the form:
|
||||
*
|
||||
* {
|
||||
* "interfaces": {
|
||||
* "google.fake.v1.ServiceName": {
|
||||
* "retry_codes": {
|
||||
* "idempotent": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
|
||||
* "non_idempotent": []
|
||||
* },
|
||||
* "retry_params": {
|
||||
* "default": {
|
||||
* "initial_retry_delay_millis": 100,
|
||||
* "retry_delay_multiplier": 1.2,
|
||||
* "max_retry_delay_millis": 1000,
|
||||
* "initial_rpc_timeout_millis": 2000,
|
||||
* "rpc_timeout_multiplier": 1.5,
|
||||
* "max_rpc_timeout_millis": 30000,
|
||||
* "total_timeout_millis": 45000
|
||||
* }
|
||||
* },
|
||||
* "methods": {
|
||||
* "CreateFoo": {
|
||||
* "retry_codes_name": "idempotent",
|
||||
* "retry_params_name": "default"
|
||||
* },
|
||||
* "Publish": {
|
||||
* "retry_codes_name": "non_idempotent",
|
||||
* "retry_params_name": "default",
|
||||
* "bundling": {
|
||||
* "element_count_threshold": 40,
|
||||
* "element_count_limit": 200,
|
||||
* "request_byte_threshold": 90000,
|
||||
* "request_byte_limit": 100000,
|
||||
* "delay_threshold_millis": 100
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param {String} serviceName - The fully-qualified name of this
|
||||
* service, used as a key into the client config file (in the
|
||||
* example above, this value should be 'google.fake.v1.ServiceName').
|
||||
* @param {Object} clientConfig - A dictionary parsed from the
|
||||
* standard API client config file.
|
||||
* @param {Object} configOverrides - A dictionary in the same structure of
|
||||
* client_config to override the settings.
|
||||
* @param {Object.<string, string[]>} retryNames - A dictionary mapping the strings
|
||||
* referring to response status codes to objects representing
|
||||
* those codes.
|
||||
* @param {Object} otherArgs - the non-request arguments to be passed to the API
|
||||
* calls.
|
||||
* @return {Object} A mapping from method name to CallSettings, or null if the
|
||||
* service is not found in the config.
|
||||
*/
|
||||
export declare function constructSettings(serviceName: string, clientConfig: ClientConfig, configOverrides: ClientConfig, retryNames: {}, otherArgs?: {}): any;
|
||||
export declare function createByteLengthFunction(message: typeof Message): (obj: {}) => number;
|
||||
612
functions/node_modules/google-gax/build/src/gax.js
generated
vendored
Normal file
612
functions/node_modules/google-gax/build/src/gax.js
generated
vendored
Normal file
@@ -0,0 +1,612 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CallSettings = exports.RetryOptions = void 0;
|
||||
exports.convertRetryOptions = convertRetryOptions;
|
||||
exports.createRetryOptions = createRetryOptions;
|
||||
exports.createBackoffSettings = createBackoffSettings;
|
||||
exports.createDefaultBackoffSettings = createDefaultBackoffSettings;
|
||||
exports.createMaxRetriesBackoffSettings = createMaxRetriesBackoffSettings;
|
||||
exports.createBundleOptions = createBundleOptions;
|
||||
exports.constructSettings = constructSettings;
|
||||
exports.createByteLengthFunction = createByteLengthFunction;
|
||||
const warnings_1 = require("./warnings");
|
||||
const util_1 = require("./util");
|
||||
const status_1 = require("./status");
|
||||
/**
|
||||
* Encapsulates the overridable settings for a particular API call.
|
||||
*
|
||||
* ``CallOptions`` is an optional arg for all GAX API calls. It is used to
|
||||
* configure the settings of a specific API call.
|
||||
*
|
||||
* When provided, its values override the GAX service defaults for that
|
||||
* particular call.
|
||||
*
|
||||
* Typically the API clients will accept this as the second to the last
|
||||
* argument. See the examples below.
|
||||
* @typedef {Object} CallOptions
|
||||
* @property {number=} timeout - The client-side timeout for API calls.
|
||||
* @property {RetryOptions=} retry - determines whether and how to retry
|
||||
* on transient errors. When set to null, the call will not retry.
|
||||
* @property {boolean=} autoPaginate - If set to false and the call is
|
||||
* configured for paged iteration, page unrolling is not performed, instead
|
||||
* the callback will be called with the response object.
|
||||
* @property {Object=} pageToken - If set and the call is configured for
|
||||
* paged iteration, paged iteration is not performed and requested with this
|
||||
* pageToken.
|
||||
* @property {number} maxResults - If set and the call is configured for
|
||||
* paged iteration, the call will stop when the number of response elements
|
||||
* reaches to the specified size. By default, it will unroll the page to
|
||||
* the end of the list.
|
||||
* @property {boolean=} isBundling - If set to false and the call is configured
|
||||
* for bundling, bundling is not performed.
|
||||
* @property {BackoffSettings=} longrunning - BackoffSettings used for polling.
|
||||
* @example
|
||||
* // suppress bundling for bundled method.
|
||||
* api.bundlingMethod(
|
||||
* param, {optParam: aValue, isBundling: false}, function(err, response) {
|
||||
* // handle response.
|
||||
* });
|
||||
* @example
|
||||
* // suppress streaming for page-streaming method.
|
||||
* api.pageStreamingMethod(
|
||||
* param, {optParam: aValue, autoPaginate: false}, function(err, page) {
|
||||
* // not returning a stream, but callback is called with the paged response.
|
||||
* });
|
||||
*/
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
* @implements {RetryOptionsType}
|
||||
* @typedef {Object} RetryOptions
|
||||
* @property {number[]} retryCodes
|
||||
* @property {BackoffSettings} backoffSettings
|
||||
* @property {(function)} shouldRetryFn
|
||||
* @property {(function)} getResumptionRequestFn
|
||||
*/
|
||||
class RetryOptions {
|
||||
constructor(retryCodes, backoffSettings, shouldRetryFn, getResumptionRequestFn) {
|
||||
this.retryCodes = retryCodes;
|
||||
this.backoffSettings = backoffSettings;
|
||||
this.shouldRetryFn = shouldRetryFn;
|
||||
this.getResumptionRequestFn = getResumptionRequestFn;
|
||||
}
|
||||
}
|
||||
exports.RetryOptions = RetryOptions;
|
||||
class CallSettings {
|
||||
/**
|
||||
* @param {Object} settings - An object containing parameters of this settings.
|
||||
* @param {number} settings.timeout - The client-side timeout for API calls.
|
||||
* This parameter is ignored for retrying calls.
|
||||
* @param {RetryOptions} settings.retry - The configuration for retrying upon
|
||||
* transient error. If set to null, this call will not retry.
|
||||
* @param {boolean} settings.autoPaginate - If there is no `pageDescriptor`,
|
||||
* this attrbute has no meaning. Otherwise, determines whether a page
|
||||
* streamed response should make the page structure transparent to the user by
|
||||
* flattening the repeated field in the returned generator.
|
||||
* @param {number} settings.pageToken - If there is no `pageDescriptor`,
|
||||
* this attribute has no meaning. Otherwise, determines the page token used
|
||||
* in the page streaming request.
|
||||
* @param {Object} settings.otherArgs - Additional arguments to be passed to
|
||||
* the API calls.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(settings) {
|
||||
var _a;
|
||||
settings = settings || {};
|
||||
this.timeout = settings.timeout || 30 * 1000;
|
||||
this.retry = settings.retry;
|
||||
this.autoPaginate =
|
||||
'autoPaginate' in settings ? settings.autoPaginate : true;
|
||||
this.maxResults = settings.maxResults;
|
||||
this.otherArgs = settings.otherArgs || {};
|
||||
this.bundleOptions = settings.bundleOptions;
|
||||
this.isBundling = 'isBundling' in settings ? settings.isBundling : true;
|
||||
this.longrunning =
|
||||
'longrunning' in settings ? settings.longrunning : undefined;
|
||||
this.apiName = (_a = settings.apiName) !== null && _a !== void 0 ? _a : undefined;
|
||||
this.retryRequestOptions = settings.retryRequestOptions;
|
||||
}
|
||||
/**
|
||||
* Returns a new CallSettings merged from this and a CallOptions object.
|
||||
*
|
||||
* @param {CallOptions} options - an instance whose values override
|
||||
* those in this object. If null, ``merge`` returns a copy of this
|
||||
* object
|
||||
* @return {CallSettings} The merged CallSettings instance.
|
||||
*/
|
||||
merge(options) {
|
||||
if (!options) {
|
||||
return new CallSettings(this);
|
||||
}
|
||||
let timeout = this.timeout;
|
||||
let retry = this.retry;
|
||||
let autoPaginate = this.autoPaginate;
|
||||
let maxResults = this.maxResults;
|
||||
let otherArgs = this.otherArgs;
|
||||
let isBundling = this.isBundling;
|
||||
let longrunning = this.longrunning;
|
||||
let apiName = this.apiName;
|
||||
let retryRequestOptions = this.retryRequestOptions;
|
||||
// If the user provides a timeout to the method, that timeout value will be used
|
||||
// to override the backoff settings.
|
||||
if ('timeout' in options) {
|
||||
timeout = options.timeout;
|
||||
}
|
||||
// If a method-specific timeout is set in the service config, and the retry codes for that
|
||||
// method are non-null, then that timeout value will be used to
|
||||
// override backoff settings.
|
||||
if (retry === null || retry === void 0 ? void 0 : retry.retryCodes) {
|
||||
retry.backoffSettings.initialRpcTimeoutMillis = timeout;
|
||||
retry.backoffSettings.maxRpcTimeoutMillis = timeout;
|
||||
retry.backoffSettings.totalTimeoutMillis = timeout;
|
||||
}
|
||||
if ('retry' in options) {
|
||||
retry = mergeRetryOptions(retry || {}, options.retry);
|
||||
}
|
||||
if ('autoPaginate' in options && !options.autoPaginate) {
|
||||
autoPaginate = false;
|
||||
}
|
||||
if ('maxResults' in options) {
|
||||
maxResults = options.maxResults;
|
||||
}
|
||||
if ('otherArgs' in options) {
|
||||
otherArgs = {};
|
||||
for (const key in this.otherArgs) {
|
||||
otherArgs[key] = this.otherArgs[key];
|
||||
}
|
||||
for (const optionsKey in options.otherArgs) {
|
||||
otherArgs[optionsKey] = options.otherArgs[optionsKey];
|
||||
}
|
||||
}
|
||||
if ('isBundling' in options) {
|
||||
isBundling = options.isBundling;
|
||||
}
|
||||
if ('maxRetries' in options && options.maxRetries !== undefined) {
|
||||
retry.backoffSettings.maxRetries = options.maxRetries;
|
||||
delete retry.backoffSettings.totalTimeoutMillis;
|
||||
}
|
||||
if ('longrunning' in options) {
|
||||
longrunning = options.longrunning;
|
||||
}
|
||||
if ('apiName' in options) {
|
||||
apiName = options.apiName;
|
||||
}
|
||||
if ('retryRequestOptions' in options) {
|
||||
retryRequestOptions = options.retryRequestOptions;
|
||||
}
|
||||
return new CallSettings({
|
||||
timeout,
|
||||
retry,
|
||||
bundleOptions: this.bundleOptions,
|
||||
longrunning,
|
||||
autoPaginate,
|
||||
maxResults,
|
||||
otherArgs,
|
||||
isBundling,
|
||||
apiName,
|
||||
retryRequestOptions,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CallSettings = CallSettings;
|
||||
/**
|
||||
* Validates passed retry options in preparation for eventual parameter deprecation
|
||||
* converts retryRequestOptions to retryOptions
|
||||
* then sets retryRequestOptions to null
|
||||
*
|
||||
* @param {CallOptions} options - a list of passed retry option
|
||||
* @return {CallOptions} A new CallOptions object.
|
||||
*
|
||||
*/
|
||||
function convertRetryOptions(options, gaxStreamingRetries) {
|
||||
var _a, _b, _c, _d;
|
||||
// options will be undefined if no CallOptions object is passed at call time
|
||||
if (!options) {
|
||||
return options;
|
||||
}
|
||||
// if a user provided retry AND retryRequestOptions at call time, throw an error
|
||||
// otherwise, convert supported parameters
|
||||
if (!gaxStreamingRetries) {
|
||||
return options;
|
||||
}
|
||||
if (options.retry && options.retryRequestOptions) {
|
||||
throw new Error('Only one of retry or retryRequestOptions may be set');
|
||||
} // handles parameter conversion from retryRequestOptions to retryOptions
|
||||
if (options.retryRequestOptions) {
|
||||
if (options.retryRequestOptions.objectMode !== undefined) {
|
||||
(0, warnings_1.warn)('retry_request_options', 'objectMode override is not supported. It is set to true internally by default in gax.', 'UnsupportedParameterWarning');
|
||||
}
|
||||
if (options.retryRequestOptions.noResponseRetries !== undefined) {
|
||||
(0, warnings_1.warn)('retry_request_options', 'noResponseRetries override is not supported. Please specify retry codes or a function to determine retry eligibility.', 'UnsupportedParameterWarning');
|
||||
}
|
||||
if (options.retryRequestOptions.currentRetryAttempt !== undefined) {
|
||||
(0, warnings_1.warn)('retry_request_options', 'currentRetryAttempt override is not supported. Retry attempts are tracked internally.', 'UnsupportedParameterWarning');
|
||||
}
|
||||
let retryCodes = [status_1.Status.UNAVAILABLE];
|
||||
let shouldRetryFn;
|
||||
if (options.retryRequestOptions.shouldRetryFn) {
|
||||
retryCodes = [];
|
||||
shouldRetryFn = options.retryRequestOptions.shouldRetryFn;
|
||||
}
|
||||
//Backoff settings
|
||||
options.maxRetries =
|
||||
(_b = (_a = options === null || options === void 0 ? void 0 : options.retryRequestOptions) === null || _a === void 0 ? void 0 : _a.retries) !== null && _b !== void 0 ? _b : options.maxRetries;
|
||||
// create a default backoff settings object in case the user didn't provide overrides for everything
|
||||
const backoffSettings = createDefaultBackoffSettings();
|
||||
let maxRetryDelayMillis;
|
||||
let totalTimeoutMillis;
|
||||
// maxRetryDelay - this is in seconds, need to convert to milliseconds
|
||||
if (options.retryRequestOptions.maxRetryDelay !== undefined) {
|
||||
maxRetryDelayMillis = options.retryRequestOptions.maxRetryDelay * 1000;
|
||||
}
|
||||
// retryDelayMultiplier - should be a one to one mapping to retryDelayMultiplier
|
||||
const retryDelayMultiplier = (_d = (_c = options === null || options === void 0 ? void 0 : options.retryRequestOptions) === null || _c === void 0 ? void 0 : _c.retryDelayMultiplier) !== null && _d !== void 0 ? _d : backoffSettings.retryDelayMultiplier;
|
||||
// this is in seconds and needs to be converted to milliseconds and the totalTimeoutMillis parameter
|
||||
if (options.retryRequestOptions.totalTimeout !== undefined) {
|
||||
totalTimeoutMillis = options.retryRequestOptions.totalTimeout * 1000;
|
||||
}
|
||||
else {
|
||||
if (options.maxRetries === undefined) {
|
||||
totalTimeoutMillis = 30000;
|
||||
(0, warnings_1.warn)('retry_request_options_no_max_retries_timeout', 'Neither maxRetries nor totalTimeout were passed. Defaulting to totalTimeout of 30000ms.', 'MissingParameterWarning');
|
||||
}
|
||||
}
|
||||
// for the variables the user wants to override, override in the backoff settings object we made
|
||||
backoffSettings.maxRetryDelayMillis =
|
||||
maxRetryDelayMillis !== null && maxRetryDelayMillis !== void 0 ? maxRetryDelayMillis : backoffSettings.maxRetryDelayMillis;
|
||||
backoffSettings.retryDelayMultiplier =
|
||||
retryDelayMultiplier !== null && retryDelayMultiplier !== void 0 ? retryDelayMultiplier : backoffSettings.retryDelayMultiplier;
|
||||
backoffSettings.totalTimeoutMillis =
|
||||
totalTimeoutMillis !== null && totalTimeoutMillis !== void 0 ? totalTimeoutMillis : backoffSettings.totalTimeoutMillis;
|
||||
const convertedRetryOptions = createRetryOptions(retryCodes, backoffSettings, shouldRetryFn);
|
||||
options.retry = convertedRetryOptions;
|
||||
delete options.retryRequestOptions; // completely remove them to avoid any further confusion
|
||||
(0, warnings_1.warn)('retry_request_options', 'retryRequestOptions will be deprecated in a future release. Please use retryOptions to pass retry options at call time', 'DeprecationWarning');
|
||||
}
|
||||
return options;
|
||||
}
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
* @param {number[]} retryCodes - a list of Google API canonical error codes OR a function that returns a boolean to determine retry behavior
|
||||
* upon which a retry should be attempted.
|
||||
* @param {BackoffSettings} backoffSettings - configures the retry
|
||||
* exponential backoff algorithm.
|
||||
* @param {function} shouldRetryFn - a function that determines whether a call should retry. If this is defined retryCodes must be empty
|
||||
* @param {function} getResumptionRequestFn - a function with a resumption strategy - only used with server streaming retries
|
||||
* @return {RetryOptions} A new RetryOptions object.
|
||||
*
|
||||
*/
|
||||
function createRetryOptions(retryCodes, backoffSettings, shouldRetryFn, getResumptionRequestFn) {
|
||||
return {
|
||||
retryCodes,
|
||||
backoffSettings,
|
||||
shouldRetryFn,
|
||||
getResumptionRequestFn,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Parameters to the exponential backoff algorithm for retrying.
|
||||
*
|
||||
* @param {number} initialRetryDelayMillis - the initial delay time,
|
||||
* in milliseconds, between the completion of the first failed request and the
|
||||
* initiation of the first retrying request.
|
||||
* @param {number} retryDelayMultiplier - the multiplier by which to
|
||||
* increase the delay time between the completion of failed requests, and the
|
||||
* initiation of the subsequent retrying request.
|
||||
* @param {number} maxRetryDelayMillis - the maximum delay time, in
|
||||
* milliseconds, between requests. When this value is reached,
|
||||
* ``retryDelayMultiplier`` will no longer be used to increase delay time.
|
||||
* @param {number} initialRpcTimeoutMillis - the initial timeout parameter
|
||||
* to the request.
|
||||
* @param {number} rpcTimeoutMultiplier - the multiplier by which to
|
||||
* increase the timeout parameter between failed requests.
|
||||
* @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in
|
||||
* milliseconds, for a request. When this value is reached,
|
||||
* ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout.
|
||||
* @param {number} totalTimeoutMillis - the total time, in milliseconds,
|
||||
* starting from when the initial request is sent, after which an error will
|
||||
* be returned, regardless of the retrying attempts made meanwhile.
|
||||
* @return {BackoffSettings} a new settings.
|
||||
*
|
||||
*/
|
||||
function createBackoffSettings(initialRetryDelayMillis, retryDelayMultiplier, maxRetryDelayMillis, initialRpcTimeoutMillis, rpcTimeoutMultiplier, maxRpcTimeoutMillis, totalTimeoutMillis) {
|
||||
return {
|
||||
initialRetryDelayMillis,
|
||||
retryDelayMultiplier,
|
||||
maxRetryDelayMillis,
|
||||
initialRpcTimeoutMillis,
|
||||
rpcTimeoutMultiplier,
|
||||
maxRpcTimeoutMillis,
|
||||
totalTimeoutMillis,
|
||||
};
|
||||
}
|
||||
function createDefaultBackoffSettings() {
|
||||
return createBackoffSettings(100, 1.3, 60000, null, null, null, null);
|
||||
}
|
||||
/**
|
||||
* Parameters to the exponential backoff algorithm for retrying.
|
||||
* This function is unsupported, and intended for internal use only.
|
||||
*
|
||||
* @param {number} initialRetryDelayMillis - the initial delay time,
|
||||
* in milliseconds, between the completion of the first failed request and the
|
||||
* initiation of the first retrying request.
|
||||
* @param {number} retryDelayMultiplier - the multiplier by which to
|
||||
* increase the delay time between the completion of failed requests, and the
|
||||
* initiation of the subsequent retrying request.
|
||||
* @param {number} maxRetryDelayMillis - the maximum delay time, in
|
||||
* milliseconds, between requests. When this value is reached,
|
||||
* ``retryDelayMultiplier`` will no longer be used to increase delay time.
|
||||
* @param {number} initialRpcTimeoutMillis - the initial timeout parameter
|
||||
* to the request.
|
||||
* @param {number} rpcTimeoutMultiplier - the multiplier by which to
|
||||
* increase the timeout parameter between failed requests.
|
||||
* @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in
|
||||
* milliseconds, for a request. When this value is reached,
|
||||
* ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout.
|
||||
* @param {number} maxRetries - the maximum number of retrying attempts that
|
||||
* will be made. If reached, an error will be returned.
|
||||
* @return {BackoffSettings} a new settings.
|
||||
*
|
||||
*/
|
||||
function createMaxRetriesBackoffSettings(initialRetryDelayMillis, retryDelayMultiplier, maxRetryDelayMillis, initialRpcTimeoutMillis, rpcTimeoutMultiplier, maxRpcTimeoutMillis, maxRetries) {
|
||||
return {
|
||||
initialRetryDelayMillis,
|
||||
retryDelayMultiplier,
|
||||
maxRetryDelayMillis,
|
||||
initialRpcTimeoutMillis,
|
||||
rpcTimeoutMultiplier,
|
||||
maxRpcTimeoutMillis,
|
||||
maxRetries,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link BundleOptions}.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} options - An object to hold optional parameters. See
|
||||
* properties for the content of options.
|
||||
* @return {BundleOptions} - A new options.
|
||||
*/
|
||||
function createBundleOptions(options) {
|
||||
const params = [
|
||||
'element_count_threshold',
|
||||
'element_count_limit',
|
||||
'request_byte_threshold',
|
||||
'request_byte_limit',
|
||||
'delay_threshold_millis',
|
||||
];
|
||||
params.forEach(param => {
|
||||
if (param in options && typeof options[param] !== 'number') {
|
||||
throw new Error(`${param} should be a number`);
|
||||
}
|
||||
});
|
||||
const elementCountThreshold = options.element_count_threshold || 0;
|
||||
const elementCountLimit = options.element_count_limit || 0;
|
||||
const requestByteThreshold = options.request_byte_threshold || 0;
|
||||
const requestByteLimit = options.request_byte_limit || 0;
|
||||
const delayThreshold = options.delay_threshold_millis || 0;
|
||||
if (elementCountThreshold === 0 &&
|
||||
requestByteThreshold === 0 &&
|
||||
delayThreshold === 0) {
|
||||
throw new Error('one threshold should be > 0');
|
||||
}
|
||||
return {
|
||||
elementCountThreshold,
|
||||
elementCountLimit,
|
||||
requestByteThreshold,
|
||||
requestByteLimit,
|
||||
delayThreshold,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Helper for {@link constructSettings}
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Object} methodConfig - A dictionary representing a single
|
||||
* `methods` entry of the standard API client config file. (See
|
||||
* {@link constructSettings} for information on this yaml.)
|
||||
* @param {?Object} retryCodes - A dictionary parsed from the
|
||||
* `retry_codes_def` entry of the standard API client config
|
||||
* file. (See {@link constructSettings} for information on this yaml.)
|
||||
* @param {Object} retryParams - A dictionary parsed from the
|
||||
* `retry_params` entry of the standard API client config
|
||||
* file. (See {@link constructSettings} for information on this yaml.)
|
||||
* @param {Object} retryNames - A dictionary mapping the string names
|
||||
* used in the standard API client config file to API response
|
||||
* status codes.
|
||||
* @return {?RetryOptions} The new retry options.
|
||||
*/
|
||||
function constructRetry(methodConfig, retryCodes, retryParams, retryNames) {
|
||||
if (!methodConfig) {
|
||||
return null;
|
||||
}
|
||||
let codes = null; // this is one instance where it will NOT be an array OR a function because we do not allow shouldRetryFn in the client
|
||||
if (retryCodes && 'retry_codes_name' in methodConfig) {
|
||||
const retryCodesName = methodConfig['retry_codes_name'];
|
||||
codes = (retryCodes[retryCodesName] || []).map(name => {
|
||||
return Number(retryNames[name]);
|
||||
});
|
||||
}
|
||||
let backoffSettings = null;
|
||||
if (retryParams && 'retry_params_name' in methodConfig) {
|
||||
const params = retryParams[methodConfig.retry_params_name];
|
||||
backoffSettings = createBackoffSettings(params.initial_retry_delay_millis, params.retry_delay_multiplier, params.max_retry_delay_millis, params.initial_rpc_timeout_millis, params.rpc_timeout_multiplier, params.max_rpc_timeout_millis, params.total_timeout_millis);
|
||||
}
|
||||
return createRetryOptions(codes, backoffSettings);
|
||||
}
|
||||
/**
|
||||
* Helper for {@link constructSettings}
|
||||
*
|
||||
* Takes two retry options, and merges them into a single RetryOption instance.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {RetryOptions} retry - The base RetryOptions.
|
||||
* @param {RetryOptions} overrides - The RetryOptions used for overriding
|
||||
* `retry`. Use the values if it is not null. If entire `overrides` is null,
|
||||
* ignore the base retry and return null.
|
||||
* @return {?RetryOptions} The merged RetryOptions.
|
||||
*/
|
||||
function mergeRetryOptions(retry, overrides) {
|
||||
if (!overrides) {
|
||||
return null;
|
||||
}
|
||||
if (!overrides.retryCodes &&
|
||||
!overrides.backoffSettings &&
|
||||
!overrides.shouldRetryFn &&
|
||||
!overrides.getResumptionRequestFn) {
|
||||
return retry;
|
||||
}
|
||||
const retryCodes = overrides.retryCodes
|
||||
? overrides.retryCodes
|
||||
: retry.retryCodes;
|
||||
const backoffSettings = overrides.backoffSettings
|
||||
? overrides.backoffSettings
|
||||
: retry.backoffSettings;
|
||||
const shouldRetryFn = overrides.shouldRetryFn
|
||||
? overrides.shouldRetryFn
|
||||
: retry.shouldRetryFn;
|
||||
const getResumptionRequestFn = overrides.getResumptionRequestFn
|
||||
? overrides.getResumptionRequestFn
|
||||
: retry.getResumptionRequestFn;
|
||||
return createRetryOptions(retryCodes, backoffSettings, shouldRetryFn, getResumptionRequestFn);
|
||||
}
|
||||
/**
|
||||
* Constructs a dictionary mapping method names to {@link CallSettings}.
|
||||
*
|
||||
* The `clientConfig` parameter is parsed from a client configuration JSON
|
||||
* file of the form:
|
||||
*
|
||||
* {
|
||||
* "interfaces": {
|
||||
* "google.fake.v1.ServiceName": {
|
||||
* "retry_codes": {
|
||||
* "idempotent": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
|
||||
* "non_idempotent": []
|
||||
* },
|
||||
* "retry_params": {
|
||||
* "default": {
|
||||
* "initial_retry_delay_millis": 100,
|
||||
* "retry_delay_multiplier": 1.2,
|
||||
* "max_retry_delay_millis": 1000,
|
||||
* "initial_rpc_timeout_millis": 2000,
|
||||
* "rpc_timeout_multiplier": 1.5,
|
||||
* "max_rpc_timeout_millis": 30000,
|
||||
* "total_timeout_millis": 45000
|
||||
* }
|
||||
* },
|
||||
* "methods": {
|
||||
* "CreateFoo": {
|
||||
* "retry_codes_name": "idempotent",
|
||||
* "retry_params_name": "default"
|
||||
* },
|
||||
* "Publish": {
|
||||
* "retry_codes_name": "non_idempotent",
|
||||
* "retry_params_name": "default",
|
||||
* "bundling": {
|
||||
* "element_count_threshold": 40,
|
||||
* "element_count_limit": 200,
|
||||
* "request_byte_threshold": 90000,
|
||||
* "request_byte_limit": 100000,
|
||||
* "delay_threshold_millis": 100
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param {String} serviceName - The fully-qualified name of this
|
||||
* service, used as a key into the client config file (in the
|
||||
* example above, this value should be 'google.fake.v1.ServiceName').
|
||||
* @param {Object} clientConfig - A dictionary parsed from the
|
||||
* standard API client config file.
|
||||
* @param {Object} configOverrides - A dictionary in the same structure of
|
||||
* client_config to override the settings.
|
||||
* @param {Object.<string, string[]>} retryNames - A dictionary mapping the strings
|
||||
* referring to response status codes to objects representing
|
||||
* those codes.
|
||||
* @param {Object} otherArgs - the non-request arguments to be passed to the API
|
||||
* calls.
|
||||
* @return {Object} A mapping from method name to CallSettings, or null if the
|
||||
* service is not found in the config.
|
||||
*/
|
||||
function constructSettings(serviceName, clientConfig, configOverrides, retryNames, otherArgs) {
|
||||
otherArgs = otherArgs || {};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const defaults = {};
|
||||
const serviceConfig = (clientConfig.interfaces || {})[serviceName];
|
||||
if (!serviceConfig) {
|
||||
return null;
|
||||
}
|
||||
// users can override the config from client side, like bundling options.
|
||||
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/main/src/gax.ts#L546
|
||||
// The way to override bundling options:
|
||||
//
|
||||
// const customConfig = {"interfaces": {"service": {"methods": {"methodName": {"bundling": {..}}}}}}
|
||||
// const client = new Client({ projectId, customConfig });
|
||||
const overrides = (configOverrides.interfaces || {})[serviceName] || {};
|
||||
const methods = serviceConfig.methods;
|
||||
const overridingMethods = overrides.methods || {};
|
||||
for (const methodName in methods) {
|
||||
const methodConfig = methods[methodName];
|
||||
const jsName = (0, util_1.toLowerCamelCase)(methodName);
|
||||
let retry = constructRetry(methodConfig, serviceConfig.retry_codes, serviceConfig.retry_params, retryNames);
|
||||
let bundlingConfig = methodConfig.bundling;
|
||||
let timeout = methodConfig.timeout_millis;
|
||||
if (methodName in overridingMethods) {
|
||||
const overridingMethod = overridingMethods[methodName];
|
||||
if (overridingMethod) {
|
||||
if ('bundling' in overridingMethod) {
|
||||
bundlingConfig = overridingMethod.bundling;
|
||||
}
|
||||
if ('timeout_millis' in overridingMethod) {
|
||||
timeout = overridingMethod.timeout_millis;
|
||||
}
|
||||
}
|
||||
retry = mergeRetryOptions(retry, constructRetry(overridingMethod, overrides.retry_codes, overrides.retry_params, retryNames));
|
||||
}
|
||||
const apiName = serviceName;
|
||||
defaults[jsName] = new CallSettings({
|
||||
timeout,
|
||||
retry,
|
||||
bundleOptions: bundlingConfig
|
||||
? createBundleOptions(bundlingConfig)
|
||||
: null,
|
||||
otherArgs,
|
||||
apiName,
|
||||
});
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
function createByteLengthFunction(message) {
|
||||
return function getByteLength(obj) {
|
||||
try {
|
||||
return message.encode(obj).finish().length;
|
||||
}
|
||||
catch (err) {
|
||||
const stringified = JSON.stringify(obj);
|
||||
(0, warnings_1.warn)('error_encoding_protobufjs_object', `Cannot encode protobuf.js object: ${stringified}: ${err}`);
|
||||
// We failed to encode the object properly, let's just return an upper boundary of its length.
|
||||
// It's only needed for calculating the size of the batch, so it's safe if it's bigger than needed.
|
||||
return stringified.length;
|
||||
}
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=gax.js.map
|
||||
1
functions/node_modules/google-gax/build/src/gax.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/gax.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
74
functions/node_modules/google-gax/build/src/googleError.d.ts
generated
vendored
Normal file
74
functions/node_modules/google-gax/build/src/googleError.d.ts
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Status } from './status';
|
||||
import * as protobuf from 'protobufjs';
|
||||
import { Metadata } from './grpc';
|
||||
import { JSONValue } from 'proto3-json-serializer';
|
||||
export declare class GoogleError extends Error {
|
||||
code?: Status;
|
||||
note?: string;
|
||||
metadata?: Metadata;
|
||||
statusDetails?: string | protobuf.Message<{}>[];
|
||||
reason?: string;
|
||||
domain?: string;
|
||||
errorInfoMetadata?: {
|
||||
[propName: string]: string;
|
||||
};
|
||||
static parseGRPCStatusDetails(err: GoogleError): GoogleError;
|
||||
static parseHttpError(json: any): GoogleError;
|
||||
}
|
||||
export type FallbackServiceError = FallbackStatusObject & Error;
|
||||
interface FallbackStatusObject {
|
||||
code: Status;
|
||||
message: string;
|
||||
statusDetails: Array<{}>;
|
||||
reason?: string;
|
||||
domain?: string;
|
||||
errorInfoMetadata?: {
|
||||
string: string;
|
||||
};
|
||||
}
|
||||
interface ProtobufAny {
|
||||
type_url: string;
|
||||
value: Uint8Array;
|
||||
}
|
||||
interface GRPCStatusDetailsObject {
|
||||
details: protobuf.Message<{}>[];
|
||||
errorInfo?: ErrorInfo;
|
||||
}
|
||||
interface ErrorInfo {
|
||||
reason: string;
|
||||
domain: string;
|
||||
metadata: {
|
||||
string: string;
|
||||
};
|
||||
}
|
||||
export declare class GoogleErrorDecoder {
|
||||
root: protobuf.Root;
|
||||
anyType: protobuf.Type;
|
||||
statusType: protobuf.Type;
|
||||
constructor();
|
||||
decodeProtobufAny(anyValue: ProtobufAny): protobuf.Message<{}>;
|
||||
decodeRpcStatus(buffer: Buffer | ArrayBuffer): FallbackStatusObject;
|
||||
callErrorFromStatus(status: FallbackStatusObject): FallbackServiceError;
|
||||
decodeErrorFromBuffer(buffer: Buffer | ArrayBuffer): Error;
|
||||
decodeGRPCStatusDetails(bufferArr: Buffer[] | ArrayBuffer[]): GRPCStatusDetailsObject;
|
||||
decodeHTTPError(json: JSONValue): {
|
||||
[k: string]: any;
|
||||
};
|
||||
decodeHttpStatusDetails(rawDetails: Array<ProtobufAny>): GRPCStatusDetailsObject;
|
||||
}
|
||||
export {};
|
||||
225
functions/node_modules/google-gax/build/src/googleError.js
generated
vendored
Normal file
225
functions/node_modules/google-gax/build/src/googleError.js
generated
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GoogleErrorDecoder = exports.GoogleError = void 0;
|
||||
const status_1 = require("./status");
|
||||
const protobuf = require("protobufjs");
|
||||
const serializer = require("proto3-json-serializer");
|
||||
const fallback_1 = require("./fallback");
|
||||
class GoogleError extends Error {
|
||||
// Parse details field in google.rpc.status wire over gRPC medatadata.
|
||||
// Promote google.rpc.ErrorInfo if exist.
|
||||
static parseGRPCStatusDetails(err) {
|
||||
const decoder = new GoogleErrorDecoder();
|
||||
try {
|
||||
if (err.metadata && err.metadata.get('grpc-status-details-bin')) {
|
||||
const statusDetailsObj = decoder.decodeGRPCStatusDetails(err.metadata.get('grpc-status-details-bin'));
|
||||
if (statusDetailsObj &&
|
||||
statusDetailsObj.details &&
|
||||
statusDetailsObj.details.length > 0) {
|
||||
err.statusDetails = statusDetailsObj.details;
|
||||
}
|
||||
if (statusDetailsObj && statusDetailsObj.errorInfo) {
|
||||
err.reason = statusDetailsObj.errorInfo.reason;
|
||||
err.domain = statusDetailsObj.errorInfo.domain;
|
||||
err.errorInfoMetadata = statusDetailsObj.errorInfo.metadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (decodeErr) {
|
||||
// ignoring the error
|
||||
}
|
||||
return err;
|
||||
}
|
||||
// Parse http JSON error and promote google.rpc.ErrorInfo if exist.
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
static parseHttpError(json) {
|
||||
if (Array.isArray(json)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
json = json.find((obj) => {
|
||||
return 'error' in obj;
|
||||
});
|
||||
}
|
||||
// fallback logic.
|
||||
// related issue: https://github.com/googleapis/gax-nodejs/issues/1303
|
||||
// google error mapping: https://cloud.google.com/apis/design/errors
|
||||
// if input json doesn't have 'error' fields, wrap the whole object with 'error' field
|
||||
if (!json['error']) {
|
||||
json['error'] = {};
|
||||
Object.keys(json)
|
||||
.filter(key => key !== 'error')
|
||||
.forEach(key => {
|
||||
json['error'][key] = json[key];
|
||||
delete json[key];
|
||||
});
|
||||
}
|
||||
const decoder = new GoogleErrorDecoder();
|
||||
const proto3Error = decoder.decodeHTTPError(json['error']);
|
||||
const error = Object.assign(new GoogleError(json['error']['message']), proto3Error);
|
||||
// Map Http Status Code to gRPC Status Code
|
||||
if (json['error']['code']) {
|
||||
error.code = (0, status_1.rpcCodeFromHttpStatusCode)(json['error']['code']);
|
||||
}
|
||||
else {
|
||||
// If error code is absent, proto3 message default value is 0. We should
|
||||
// keep error code as undefined.
|
||||
delete error.code;
|
||||
}
|
||||
// Keep consistency with gRPC statusDetails fields. gRPC details has been occupied before.
|
||||
// Rename "details" to "statusDetails".
|
||||
if (error.details) {
|
||||
try {
|
||||
const statusDetailsObj = decoder.decodeHttpStatusDetails(error.details);
|
||||
if (statusDetailsObj &&
|
||||
statusDetailsObj.details &&
|
||||
statusDetailsObj.details.length > 0) {
|
||||
error.statusDetails = statusDetailsObj.details;
|
||||
}
|
||||
if (statusDetailsObj && statusDetailsObj.errorInfo) {
|
||||
error.reason = statusDetailsObj.errorInfo.reason;
|
||||
error.domain = statusDetailsObj.errorInfo.domain;
|
||||
// error.metadata has been occupied for gRPC metadata, so we use
|
||||
// errorInfoMetadata to represent ErrorInfo' metadata field. Keep
|
||||
// consistency with gRPC ErrorInfo metadata field name.
|
||||
error.errorInfoMetadata = statusDetailsObj.errorInfo.metadata;
|
||||
}
|
||||
}
|
||||
catch (decodeErr) {
|
||||
// ignoring the error
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
exports.GoogleError = GoogleError;
|
||||
class GoogleErrorDecoder {
|
||||
constructor() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const errorProtoJson = require('../../build/protos/status.json');
|
||||
this.root = protobuf.Root.fromJSON(errorProtoJson);
|
||||
this.anyType = this.root.lookupType('google.protobuf.Any');
|
||||
this.statusType = this.root.lookupType('google.rpc.Status');
|
||||
}
|
||||
decodeProtobufAny(anyValue) {
|
||||
const match = anyValue.type_url.match(/^type.googleapis.com\/(.*)/);
|
||||
if (!match) {
|
||||
throw new Error(`Unknown type encoded in google.protobuf.any: ${anyValue.type_url}`);
|
||||
}
|
||||
const typeName = match[1];
|
||||
const type = this.root.lookupType(typeName);
|
||||
if (!type) {
|
||||
throw new Error(`Cannot lookup type ${typeName}`);
|
||||
}
|
||||
return type.decode(anyValue.value);
|
||||
}
|
||||
// Decodes gRPC-fallback error which is an instance of google.rpc.Status.
|
||||
decodeRpcStatus(buffer) {
|
||||
const uint8array = new Uint8Array(buffer);
|
||||
const status = this.statusType.decode(uint8array);
|
||||
// google.rpc.Status contains an array of google.protobuf.Any
|
||||
// which need a special treatment
|
||||
const details = [];
|
||||
let errorInfo;
|
||||
for (const detail of status.details) {
|
||||
try {
|
||||
const decodedDetail = this.decodeProtobufAny(detail);
|
||||
details.push(decodedDetail);
|
||||
if (detail.type_url === 'type.googleapis.com/google.rpc.ErrorInfo') {
|
||||
errorInfo = decodedDetail;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// cannot decode detail, likely because of the unknown type - just skip it
|
||||
}
|
||||
}
|
||||
const result = {
|
||||
code: status.code,
|
||||
message: status.message,
|
||||
statusDetails: details,
|
||||
reason: errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.reason,
|
||||
domain: errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.domain,
|
||||
errorInfoMetadata: errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.metadata,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
// Construct an Error from a StatusObject.
|
||||
// Adapted from https://github.com/grpc/grpc-node/blob/main/packages/grpc-js/src/call.ts#L79
|
||||
callErrorFromStatus(status) {
|
||||
status.message = `${status.code} ${status_1.Status[status.code]}: ${status.message}`;
|
||||
return Object.assign(new GoogleError(status.message), status);
|
||||
}
|
||||
// Decodes gRPC-fallback error which is an instance of google.rpc.Status,
|
||||
// and puts it into the object similar to gRPC ServiceError object.
|
||||
decodeErrorFromBuffer(buffer) {
|
||||
return this.callErrorFromStatus(this.decodeRpcStatus(buffer));
|
||||
}
|
||||
// Decodes gRPC metadata error details which is an instance of google.rpc.Status.
|
||||
decodeGRPCStatusDetails(bufferArr) {
|
||||
const details = [];
|
||||
let errorInfo;
|
||||
bufferArr.forEach(buffer => {
|
||||
const uint8array = new Uint8Array(buffer);
|
||||
const rpcStatus = this.statusType.decode(uint8array);
|
||||
for (const detail of rpcStatus.details) {
|
||||
try {
|
||||
const decodedDetail = this.decodeProtobufAny(detail);
|
||||
details.push(decodedDetail);
|
||||
if (detail.type_url === 'type.googleapis.com/google.rpc.ErrorInfo') {
|
||||
errorInfo = decodedDetail;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// cannot decode detail, likely because of the unknown type - just skip it
|
||||
}
|
||||
}
|
||||
});
|
||||
const result = {
|
||||
details,
|
||||
errorInfo,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
// Decodes http error which is an instance of google.rpc.Status.
|
||||
decodeHTTPError(json) {
|
||||
const errorMessage = serializer.fromProto3JSON(this.statusType, json);
|
||||
if (!errorMessage) {
|
||||
throw new Error(`Received error message ${json}, but failed to serialize as proto3 message`);
|
||||
}
|
||||
return this.statusType.toObject(errorMessage, fallback_1.defaultToObjectOptions);
|
||||
}
|
||||
// Decodes http error details which is an instance of Array<google.protobuf.Any>.
|
||||
decodeHttpStatusDetails(rawDetails) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const details = [];
|
||||
let errorInfo;
|
||||
for (const detail of rawDetails) {
|
||||
try {
|
||||
const decodedDetail = this.decodeProtobufAny(detail);
|
||||
details.push(decodedDetail);
|
||||
if (detail.type_url === 'type.googleapis.com/google.rpc.ErrorInfo') {
|
||||
errorInfo = decodedDetail;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
// cannot decode detail, likely because of the unknown type - just skip it
|
||||
}
|
||||
}
|
||||
return { details, errorInfo };
|
||||
}
|
||||
}
|
||||
exports.GoogleErrorDecoder = GoogleErrorDecoder;
|
||||
//# sourceMappingURL=googleError.js.map
|
||||
1
functions/node_modules/google-gax/build/src/googleError.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/googleError.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
190
functions/node_modules/google-gax/build/src/grpc.d.ts
generated
vendored
Normal file
190
functions/node_modules/google-gax/build/src/grpc.d.ts
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as grpcProtoLoader from '@grpc/proto-loader';
|
||||
import { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
||||
import * as grpc from '@grpc/grpc-js';
|
||||
import { OutgoingHttpHeaders } from 'http';
|
||||
import * as protobuf from 'protobufjs';
|
||||
import * as gax from './gax';
|
||||
import { ClientOptions } from '@grpc/grpc-js/build/src/client';
|
||||
import { google } from '../protos/http';
|
||||
export interface GrpcClientOptions extends GoogleAuthOptions {
|
||||
auth?: GoogleAuth;
|
||||
grpc?: GrpcModule;
|
||||
protoJson?: protobuf.Root;
|
||||
httpRules?: Array<google.api.IHttpRule>;
|
||||
numericEnums?: boolean;
|
||||
universeDomain?: string;
|
||||
}
|
||||
export interface MetadataValue {
|
||||
equals: Function;
|
||||
}
|
||||
export interface Metadata {
|
||||
new (): Metadata;
|
||||
set: (key: {}, value?: {} | null) => void;
|
||||
clone: () => Metadata;
|
||||
value: MetadataValue;
|
||||
get: (key: {}) => {};
|
||||
}
|
||||
export type GrpcModule = typeof grpc;
|
||||
export interface ClientStubOptions {
|
||||
protocol?: string;
|
||||
servicePath?: string;
|
||||
port?: number;
|
||||
sslCreds?: grpc.ChannelCredentials;
|
||||
[index: string]: string | number | undefined | {};
|
||||
cert?: string;
|
||||
key?: string;
|
||||
universeDomain?: string;
|
||||
}
|
||||
export declare class ClientStub extends grpc.Client {
|
||||
[name: string]: Function;
|
||||
}
|
||||
export declare class GrpcClient {
|
||||
auth: GoogleAuth;
|
||||
grpc: GrpcModule;
|
||||
grpcVersion: string;
|
||||
fallback: boolean | 'rest' | 'proto';
|
||||
private static protoCache;
|
||||
httpRules?: Array<google.api.IHttpRule>;
|
||||
/**
|
||||
* Key for proto cache map. We are doing our best to make sure we respect
|
||||
* the options, so if the same proto file is loaded with different set of
|
||||
* options, the cache won't be used. Since some of the options are
|
||||
* Functions (e.g. `enums: String` - see below in `loadProto()`),
|
||||
* they will be omitted from the cache key. If the cache breaks anything
|
||||
* for you, use the `ignoreCache` parameter of `loadProto()` to disable it.
|
||||
*/
|
||||
private static protoCacheKey;
|
||||
/**
|
||||
* In rare cases users might need to deallocate all memory consumed by loaded protos.
|
||||
* This method will delete the proto cache content.
|
||||
*/
|
||||
static clearProtoCache(): void;
|
||||
/**
|
||||
* A class which keeps the context of gRPC and auth for the gRPC.
|
||||
*
|
||||
* @param {Object=} options - The optional parameters. It will be directly
|
||||
* passed to google-auth-library library, so parameters like keyFile or
|
||||
* credentials will be valid.
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* When specified, this auth instance will be used instead of creating
|
||||
* a new one.
|
||||
* @param {Object=} options.grpc - When specified, this will be used
|
||||
* for the 'grpc' module in this context. By default, it will load the grpc
|
||||
* module in the standard way.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options?: GrpcClientOptions);
|
||||
/**
|
||||
* Creates a gRPC credentials. It asks the auth data if necessary.
|
||||
* @private
|
||||
* @param {Object} opts - options values for configuring credentials.
|
||||
* @param {Object=} opts.sslCreds - when specified, this is used instead
|
||||
* of default channel credentials.
|
||||
* @return {Promise} The promise which will be resolved to the gRPC credential.
|
||||
*/
|
||||
_getCredentials(opts: ClientStubOptions): Promise<grpc.ChannelCredentials>;
|
||||
private static defaultOptions;
|
||||
/**
|
||||
* Loads the gRPC service from the proto file(s) at the given path and with the
|
||||
* given options. Caches the loaded protos so the subsequent loads don't do
|
||||
* any disk reads.
|
||||
* @param filename The path to the proto file(s).
|
||||
* @param options Options for loading the proto file.
|
||||
* @param ignoreCache Defaults to `false`. Set it to `true` if the caching logic
|
||||
* incorrectly decides that the options object is the same, or if you want to
|
||||
* re-read the protos from disk for any other reason.
|
||||
*/
|
||||
loadFromProto(filename: string | string[], options: grpcProtoLoader.Options, ignoreCache?: boolean): grpc.GrpcObject;
|
||||
/**
|
||||
* Load gRPC proto service from a filename looking in googleapis common protos
|
||||
* when necessary. Caches the loaded protos so the subsequent loads don't do
|
||||
* any disk reads.
|
||||
* @param {String} protoPath - The directory to search for the protofile.
|
||||
* @param {String|String[]} filename - The filename(s) of the proto(s) to be loaded.
|
||||
* If omitted, protoPath will be treated as a file path to load.
|
||||
* @param ignoreCache Defaults to `false`. Set it to `true` if the caching logic
|
||||
* incorrectly decides that the options object is the same, or if you want to
|
||||
* re-read the protos from disk for any other reason.
|
||||
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
|
||||
* object).
|
||||
*/
|
||||
loadProto(protoPath: string, filename?: string | string[], ignoreCache?: boolean): grpc.GrpcObject;
|
||||
static _resolveFile(protoPath: string, filename: string): string;
|
||||
loadProtoJSON(json: protobuf.INamespace, ignoreCache?: boolean): grpc.GrpcObject;
|
||||
metadataBuilder(headers: OutgoingHttpHeaders): (abTests?: {}, moreHeaders?: OutgoingHttpHeaders) => grpc.Metadata;
|
||||
/**
|
||||
* A wrapper of {@link constructSettings} function under the gRPC context.
|
||||
*
|
||||
* Most of parameters are common among constructSettings, please take a look.
|
||||
* @param {string} serviceName - The fullly-qualified name of the service.
|
||||
* @param {Object} clientConfig - A dictionary of the client config.
|
||||
* @param {Object} configOverrides - A dictionary of overriding configs.
|
||||
* @param {Object} headers - A dictionary of additional HTTP header name to
|
||||
* its value.
|
||||
* @return {Object} A mapping of method names to CallSettings.
|
||||
*/
|
||||
constructSettings(serviceName: string, clientConfig: gax.ClientConfig, configOverrides: gax.ClientConfig, headers: OutgoingHttpHeaders): any;
|
||||
/**
|
||||
* Creates a gRPC stub with current gRPC and auth.
|
||||
* @param {function} CreateStub - The constructor function of the stub.
|
||||
* @param {Object} options - The optional arguments to customize
|
||||
* gRPC connection. This options will be passed to the constructor of
|
||||
* gRPC client too.
|
||||
* @param {string} options.servicePath - The name of the server of the service.
|
||||
* @param {number} options.port - The port of the service.
|
||||
* @param {grpcTypes.ClientCredentials=} options.sslCreds - The credentials to be used
|
||||
* to set up gRPC connection.
|
||||
* @param {string} defaultServicePath - The default service path.
|
||||
* @return {Promise} A promise which resolves to a gRPC stub instance.
|
||||
*/
|
||||
createStub(CreateStub: typeof ClientStub, options: ClientStubOptions, customServicePath?: boolean): Promise<ClientStub>;
|
||||
/**
|
||||
* Detect mTLS client certificate based on logic described in
|
||||
* https://google.aip.dev/auth/4114.
|
||||
*
|
||||
* @param {object} [options] - The configuration object.
|
||||
* @returns {Promise} Resolves array of strings representing cert and key.
|
||||
*/
|
||||
_detectClientCertificate(opts?: ClientOptions, universeDomain?: string): Promise<any[]>;
|
||||
/**
|
||||
* Return service path, taking into account mTLS logic.
|
||||
* See: https://google.aip.dev/auth/4114
|
||||
*
|
||||
* @param {string|undefined} servicePath - The path of the service.
|
||||
* @param {string|undefined} customServicePath - Did the user provide a custom service URL.
|
||||
* @param {boolean} hasCertificate - Was a certificate found.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
_mtlsServicePath(servicePath: string | undefined, customServicePath: boolean | undefined, hasCertificate: boolean): string | undefined;
|
||||
/**
|
||||
* Creates a 'bytelength' function for a given proto message class.
|
||||
*
|
||||
* See {@link BundleDescriptor} about the meaning of the return value.
|
||||
*
|
||||
* @param {function} message - a constructor function that is generated by
|
||||
* protobuf.js. Assumes 'encoder' field in the message.
|
||||
* @return {function(Object):number} - a function to compute the byte length
|
||||
* for an object.
|
||||
*/
|
||||
static createByteLengthFunction(message: typeof protobuf.Message): (obj: {}) => number;
|
||||
}
|
||||
export declare class GoogleProtoFilesRoot extends protobuf.Root {
|
||||
constructor(...args: Array<{}>);
|
||||
resolvePath(originPath: string, includePath: string): string;
|
||||
static _findIncludePath(originPath: string, includePath: string): string;
|
||||
}
|
||||
469
functions/node_modules/google-gax/build/src/grpc.js
generated
vendored
Normal file
469
functions/node_modules/google-gax/build/src/grpc.js
generated
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GoogleProtoFilesRoot = exports.GrpcClient = exports.ClientStub = void 0;
|
||||
const grpcProtoLoader = require("@grpc/proto-loader");
|
||||
const child_process_1 = require("child_process");
|
||||
const fs = require("fs");
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
const os = require("os");
|
||||
const path_1 = require("path");
|
||||
const path = require("path");
|
||||
const protobuf = require("protobufjs");
|
||||
const objectHash = require("object-hash");
|
||||
const gax = require("./gax");
|
||||
const googleProtoFilesDir = path.join(__dirname, '..', '..', 'build', 'protos');
|
||||
// INCLUDE_DIRS is passed to @grpc/proto-loader
|
||||
const INCLUDE_DIRS = [];
|
||||
INCLUDE_DIRS.push(googleProtoFilesDir);
|
||||
// COMMON_PROTO_FILES logic is here for protobufjs loads (see
|
||||
// GoogleProtoFilesRoot below)
|
||||
const commonProtoFiles = require("./protosList.json");
|
||||
// use the correct path separator for the OS we are running on
|
||||
const COMMON_PROTO_FILES = commonProtoFiles.map(file => file.replace(/[/\\]/g, path.sep));
|
||||
/*
|
||||
* Async version of readFile.
|
||||
*
|
||||
* @returns {Promise} Contents of file at path.
|
||||
*/
|
||||
async function readFileAsync(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(path, 'utf8', (err, content) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
else
|
||||
resolve(content);
|
||||
});
|
||||
});
|
||||
}
|
||||
/*
|
||||
* Async version of execFile.
|
||||
*
|
||||
* @returns {Promise} stdout from command execution.
|
||||
*/
|
||||
async function execFileAsync(command, args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
(0, child_process_1.execFile)(command, args, (err, stdout) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
else
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
}
|
||||
class ClientStub extends grpc.Client {
|
||||
}
|
||||
exports.ClientStub = ClientStub;
|
||||
class GrpcClient {
|
||||
/**
|
||||
* Key for proto cache map. We are doing our best to make sure we respect
|
||||
* the options, so if the same proto file is loaded with different set of
|
||||
* options, the cache won't be used. Since some of the options are
|
||||
* Functions (e.g. `enums: String` - see below in `loadProto()`),
|
||||
* they will be omitted from the cache key. If the cache breaks anything
|
||||
* for you, use the `ignoreCache` parameter of `loadProto()` to disable it.
|
||||
*/
|
||||
static protoCacheKey(filename, options) {
|
||||
if (!filename ||
|
||||
(Array.isArray(filename) && (filename.length === 0 || !filename[0]))) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.stringify(filename) + ' ' + JSON.stringify(options);
|
||||
}
|
||||
/**
|
||||
* In rare cases users might need to deallocate all memory consumed by loaded protos.
|
||||
* This method will delete the proto cache content.
|
||||
*/
|
||||
static clearProtoCache() {
|
||||
GrpcClient.protoCache.clear();
|
||||
}
|
||||
/**
|
||||
* A class which keeps the context of gRPC and auth for the gRPC.
|
||||
*
|
||||
* @param {Object=} options - The optional parameters. It will be directly
|
||||
* passed to google-auth-library library, so parameters like keyFile or
|
||||
* credentials will be valid.
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* When specified, this auth instance will be used instead of creating
|
||||
* a new one.
|
||||
* @param {Object=} options.grpc - When specified, this will be used
|
||||
* for the 'grpc' module in this context. By default, it will load the grpc
|
||||
* module in the standard way.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
var _a;
|
||||
this.auth = options.auth || new google_auth_library_1.GoogleAuth(options);
|
||||
this.fallback = false;
|
||||
const minimumVersion = 10;
|
||||
const major = Number((_a = process.version.match(/^v(\d+)/)) === null || _a === void 0 ? void 0 : _a[1]);
|
||||
if (Number.isNaN(major) || major < minimumVersion) {
|
||||
const errorMessage = `Node.js v${minimumVersion}.0.0 is a minimum requirement. To learn about legacy version support visit: ` +
|
||||
'https://github.com/googleapis/google-cloud-node#supported-nodejs-versions';
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
if ('grpc' in options) {
|
||||
this.grpc = options.grpc;
|
||||
this.grpcVersion = '';
|
||||
}
|
||||
else {
|
||||
this.grpc = grpc;
|
||||
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a gRPC credentials. It asks the auth data if necessary.
|
||||
* @private
|
||||
* @param {Object} opts - options values for configuring credentials.
|
||||
* @param {Object=} opts.sslCreds - when specified, this is used instead
|
||||
* of default channel credentials.
|
||||
* @return {Promise} The promise which will be resolved to the gRPC credential.
|
||||
*/
|
||||
async _getCredentials(opts) {
|
||||
if (opts.sslCreds) {
|
||||
return opts.sslCreds;
|
||||
}
|
||||
const grpc = this.grpc;
|
||||
const sslCreds = opts.cert && opts.key
|
||||
? grpc.credentials.createSsl(null, Buffer.from(opts.key), Buffer.from(opts.cert))
|
||||
: grpc.credentials.createSsl();
|
||||
const client = await this.auth.getClient();
|
||||
const credentials = grpc.credentials.combineChannelCredentials(sslCreds, grpc.credentials.createFromGoogleCredential(client));
|
||||
return credentials;
|
||||
}
|
||||
static defaultOptions() {
|
||||
// This set of @grpc/proto-loader options
|
||||
// 'closely approximates the existing behavior of grpc.load'
|
||||
const includeDirs = INCLUDE_DIRS.slice();
|
||||
const options = {
|
||||
keepCase: false,
|
||||
longs: String,
|
||||
enums: String,
|
||||
defaults: true,
|
||||
oneofs: true,
|
||||
includeDirs,
|
||||
};
|
||||
return options;
|
||||
}
|
||||
/**
|
||||
* Loads the gRPC service from the proto file(s) at the given path and with the
|
||||
* given options. Caches the loaded protos so the subsequent loads don't do
|
||||
* any disk reads.
|
||||
* @param filename The path to the proto file(s).
|
||||
* @param options Options for loading the proto file.
|
||||
* @param ignoreCache Defaults to `false`. Set it to `true` if the caching logic
|
||||
* incorrectly decides that the options object is the same, or if you want to
|
||||
* re-read the protos from disk for any other reason.
|
||||
*/
|
||||
loadFromProto(filename, options, ignoreCache = false) {
|
||||
const cacheKey = GrpcClient.protoCacheKey(filename, options);
|
||||
let grpcPackage = cacheKey
|
||||
? GrpcClient.protoCache.get(cacheKey)
|
||||
: undefined;
|
||||
if (ignoreCache || !grpcPackage) {
|
||||
const packageDef = grpcProtoLoader.loadSync(filename, options);
|
||||
grpcPackage = this.grpc.loadPackageDefinition(packageDef);
|
||||
if (cacheKey) {
|
||||
GrpcClient.protoCache.set(cacheKey, grpcPackage);
|
||||
}
|
||||
}
|
||||
return grpcPackage;
|
||||
}
|
||||
/**
|
||||
* Load gRPC proto service from a filename looking in googleapis common protos
|
||||
* when necessary. Caches the loaded protos so the subsequent loads don't do
|
||||
* any disk reads.
|
||||
* @param {String} protoPath - The directory to search for the protofile.
|
||||
* @param {String|String[]} filename - The filename(s) of the proto(s) to be loaded.
|
||||
* If omitted, protoPath will be treated as a file path to load.
|
||||
* @param ignoreCache Defaults to `false`. Set it to `true` if the caching logic
|
||||
* incorrectly decides that the options object is the same, or if you want to
|
||||
* re-read the protos from disk for any other reason.
|
||||
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
|
||||
* object).
|
||||
*/
|
||||
loadProto(protoPath, filename, ignoreCache = false) {
|
||||
if (!filename) {
|
||||
filename = path.basename(protoPath);
|
||||
protoPath = path.dirname(protoPath);
|
||||
}
|
||||
if (Array.isArray(filename) && filename.length === 0) {
|
||||
return {};
|
||||
}
|
||||
const options = GrpcClient.defaultOptions();
|
||||
options.includeDirs.unshift(protoPath);
|
||||
return this.loadFromProto(filename, options, ignoreCache);
|
||||
}
|
||||
static _resolveFile(protoPath, filename) {
|
||||
if (fs.existsSync(path.join(protoPath, filename))) {
|
||||
return path.join(protoPath, filename);
|
||||
}
|
||||
else if (COMMON_PROTO_FILES.indexOf(filename) > -1) {
|
||||
return path.join(googleProtoFilesDir, filename);
|
||||
}
|
||||
throw new Error(filename + ' could not be found in ' + protoPath);
|
||||
}
|
||||
loadProtoJSON(json, ignoreCache = false) {
|
||||
const hash = objectHash(JSON.stringify(json)).toString();
|
||||
const cached = GrpcClient.protoCache.get(hash);
|
||||
if (cached && !ignoreCache) {
|
||||
return cached;
|
||||
}
|
||||
const options = GrpcClient.defaultOptions();
|
||||
const packageDefinition = grpcProtoLoader.fromJSON(json, options);
|
||||
const grpcPackage = this.grpc.loadPackageDefinition(packageDefinition);
|
||||
GrpcClient.protoCache.set(hash, grpcPackage);
|
||||
return grpcPackage;
|
||||
}
|
||||
metadataBuilder(headers) {
|
||||
const Metadata = this.grpc.Metadata;
|
||||
const baseMetadata = new Metadata();
|
||||
for (const key in headers) {
|
||||
const value = headers[key];
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(v => baseMetadata.add(key, v));
|
||||
}
|
||||
else {
|
||||
baseMetadata.set(key, `${value}`);
|
||||
}
|
||||
}
|
||||
return function buildMetadata(abTests, moreHeaders) {
|
||||
// TODO: bring the A/B testing info into the metadata.
|
||||
let copied = false;
|
||||
let metadata = baseMetadata;
|
||||
if (moreHeaders) {
|
||||
for (const key in moreHeaders) {
|
||||
if (key.toLowerCase() !== 'x-goog-api-client') {
|
||||
if (!copied) {
|
||||
copied = true;
|
||||
metadata = metadata.clone();
|
||||
}
|
||||
const value = moreHeaders[key];
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(v => metadata.add(key, v));
|
||||
}
|
||||
else {
|
||||
metadata.set(key, `${value}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return metadata;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A wrapper of {@link constructSettings} function under the gRPC context.
|
||||
*
|
||||
* Most of parameters are common among constructSettings, please take a look.
|
||||
* @param {string} serviceName - The fullly-qualified name of the service.
|
||||
* @param {Object} clientConfig - A dictionary of the client config.
|
||||
* @param {Object} configOverrides - A dictionary of overriding configs.
|
||||
* @param {Object} headers - A dictionary of additional HTTP header name to
|
||||
* its value.
|
||||
* @return {Object} A mapping of method names to CallSettings.
|
||||
*/
|
||||
constructSettings(serviceName, clientConfig, configOverrides, headers) {
|
||||
return gax.constructSettings(serviceName, clientConfig, configOverrides, this.grpc.status, { metadataBuilder: this.metadataBuilder(headers) });
|
||||
}
|
||||
/**
|
||||
* Creates a gRPC stub with current gRPC and auth.
|
||||
* @param {function} CreateStub - The constructor function of the stub.
|
||||
* @param {Object} options - The optional arguments to customize
|
||||
* gRPC connection. This options will be passed to the constructor of
|
||||
* gRPC client too.
|
||||
* @param {string} options.servicePath - The name of the server of the service.
|
||||
* @param {number} options.port - The port of the service.
|
||||
* @param {grpcTypes.ClientCredentials=} options.sslCreds - The credentials to be used
|
||||
* to set up gRPC connection.
|
||||
* @param {string} defaultServicePath - The default service path.
|
||||
* @return {Promise} A promise which resolves to a gRPC stub instance.
|
||||
*/
|
||||
async createStub(CreateStub, options, customServicePath) {
|
||||
// The following options are understood by grpc-gcp and need a special treatment
|
||||
// (should be passed without a `grpc.` prefix)
|
||||
const grpcGcpOptions = [
|
||||
'grpc.callInvocationTransformer',
|
||||
'grpc.channelFactoryOverride',
|
||||
'grpc.gcpApiConfig',
|
||||
];
|
||||
const [cert, key] = await this._detectClientCertificate(options, options.universeDomain);
|
||||
const servicePath = this._mtlsServicePath(options.servicePath, customServicePath, cert && key);
|
||||
const opts = Object.assign({}, options, { cert, key, servicePath });
|
||||
const serviceAddress = servicePath + ':' + opts.port;
|
||||
if (!options.universeDomain) {
|
||||
options.universeDomain = 'googleapis.com';
|
||||
}
|
||||
if (options.universeDomain) {
|
||||
const universeFromAuth = await this.auth.getUniverseDomain();
|
||||
if (universeFromAuth && options.universeDomain !== universeFromAuth) {
|
||||
throw new Error(`The configured universe domain (${options.universeDomain}) does not match the universe domain found in the credentials (${universeFromAuth}). ` +
|
||||
"If you haven't configured the universe domain explicitly, googleapis.com is the default.");
|
||||
}
|
||||
}
|
||||
const creds = await this._getCredentials(opts);
|
||||
const grpcOptions = {};
|
||||
// @grpc/grpc-js limits max receive/send message length starting from v0.8.0
|
||||
// https://github.com/grpc/grpc-node/releases/tag/%40grpc%2Fgrpc-js%400.8.0
|
||||
// To keep the existing behavior and avoid libraries breakage, we pass -1 there as suggested.
|
||||
grpcOptions['grpc.max_receive_message_length'] = -1;
|
||||
grpcOptions['grpc.max_send_message_length'] = -1;
|
||||
grpcOptions['grpc.initial_reconnect_backoff_ms'] = 1000;
|
||||
Object.keys(opts).forEach(key => {
|
||||
const value = options[key];
|
||||
// the older versions had a bug which required users to call an option
|
||||
// grpc.grpc.* to make it actually pass to gRPC as grpc.*, let's handle
|
||||
// this here until the next major release
|
||||
if (key.startsWith('grpc.grpc.')) {
|
||||
key = key.replace(/^grpc\./, '');
|
||||
}
|
||||
if (key.startsWith('grpc.')) {
|
||||
if (grpcGcpOptions.includes(key)) {
|
||||
key = key.replace(/^grpc\./, '');
|
||||
}
|
||||
grpcOptions[key] = value;
|
||||
}
|
||||
if (key.startsWith('grpc-node.')) {
|
||||
grpcOptions[key] = value;
|
||||
}
|
||||
});
|
||||
const stub = new CreateStub(serviceAddress, creds, grpcOptions);
|
||||
return stub;
|
||||
}
|
||||
/**
|
||||
* Detect mTLS client certificate based on logic described in
|
||||
* https://google.aip.dev/auth/4114.
|
||||
*
|
||||
* @param {object} [options] - The configuration object.
|
||||
* @returns {Promise} Resolves array of strings representing cert and key.
|
||||
*/
|
||||
async _detectClientCertificate(opts, universeDomain) {
|
||||
var _a;
|
||||
const certRegex = /(?<cert>-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----)/s;
|
||||
const keyRegex = /(?<key>-----BEGIN PRIVATE KEY-----.*?-----END PRIVATE KEY-----)/s;
|
||||
// If GOOGLE_API_USE_CLIENT_CERTIFICATE is true...:
|
||||
if (typeof process !== 'undefined' &&
|
||||
((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.GOOGLE_API_USE_CLIENT_CERTIFICATE) === 'true') {
|
||||
if (universeDomain && universeDomain !== 'googleapis.com') {
|
||||
throw new Error('mTLS is not supported outside of googleapis.com universe domain.');
|
||||
}
|
||||
if ((opts === null || opts === void 0 ? void 0 : opts.cert) && (opts === null || opts === void 0 ? void 0 : opts.key)) {
|
||||
return [opts.cert, opts.key];
|
||||
}
|
||||
// If context aware metadata exists, run the cert provider command,
|
||||
// parse the output to extract cert and key, and use this cert/key.
|
||||
const metadataPath = (0, path_1.join)(os.homedir(), '.secureConnect', 'context_aware_metadata.json');
|
||||
const metadata = JSON.parse(await readFileAsync(metadataPath));
|
||||
if (!metadata.cert_provider_command) {
|
||||
throw Error('no cert_provider_command found');
|
||||
}
|
||||
const stdout = await execFileAsync(metadata.cert_provider_command[0], metadata.cert_provider_command.slice(1));
|
||||
const matchCert = stdout.toString().match(certRegex);
|
||||
const matchKey = stdout.toString().match(keyRegex);
|
||||
if (!((matchCert === null || matchCert === void 0 ? void 0 : matchCert.groups) && (matchKey === null || matchKey === void 0 ? void 0 : matchKey.groups))) {
|
||||
throw Error('unable to parse certificate and key');
|
||||
}
|
||||
else {
|
||||
return [matchCert.groups.cert, matchKey.groups.key];
|
||||
}
|
||||
}
|
||||
// If GOOGLE_API_USE_CLIENT_CERTIFICATE is not set or false,
|
||||
// use no cert or key:
|
||||
return [undefined, undefined];
|
||||
}
|
||||
/**
|
||||
* Return service path, taking into account mTLS logic.
|
||||
* See: https://google.aip.dev/auth/4114
|
||||
*
|
||||
* @param {string|undefined} servicePath - The path of the service.
|
||||
* @param {string|undefined} customServicePath - Did the user provide a custom service URL.
|
||||
* @param {boolean} hasCertificate - Was a certificate found.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
_mtlsServicePath(servicePath, customServicePath, hasCertificate) {
|
||||
var _a, _b;
|
||||
// If user provides a custom service path, return the current service
|
||||
// path and do not attempt to add mtls subdomain:
|
||||
if (customServicePath || !servicePath)
|
||||
return servicePath;
|
||||
if (typeof process !== 'undefined' &&
|
||||
((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.GOOGLE_API_USE_MTLS_ENDPOINT) === 'never') {
|
||||
// It was explicitly asked that mtls endpoint not be used:
|
||||
return servicePath;
|
||||
}
|
||||
else if ((typeof process !== 'undefined' &&
|
||||
((_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b.GOOGLE_API_USE_MTLS_ENDPOINT) === 'always') ||
|
||||
hasCertificate) {
|
||||
// Either auto-detect or explicit setting of endpoint:
|
||||
return servicePath.replace('googleapis.com', 'mtls.googleapis.com');
|
||||
}
|
||||
return servicePath;
|
||||
}
|
||||
/**
|
||||
* Creates a 'bytelength' function for a given proto message class.
|
||||
*
|
||||
* See {@link BundleDescriptor} about the meaning of the return value.
|
||||
*
|
||||
* @param {function} message - a constructor function that is generated by
|
||||
* protobuf.js. Assumes 'encoder' field in the message.
|
||||
* @return {function(Object):number} - a function to compute the byte length
|
||||
* for an object.
|
||||
*/
|
||||
static createByteLengthFunction(message) {
|
||||
return gax.createByteLengthFunction(message);
|
||||
}
|
||||
}
|
||||
exports.GrpcClient = GrpcClient;
|
||||
GrpcClient.protoCache = new Map();
|
||||
class GoogleProtoFilesRoot extends protobuf.Root {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
}
|
||||
// Causes the loading of an included proto to check if it is a common
|
||||
// proto. If it is a common proto, use the bundled proto.
|
||||
resolvePath(originPath, includePath) {
|
||||
originPath = path.normalize(originPath);
|
||||
includePath = path.normalize(includePath);
|
||||
// Fully qualified paths don't need to be resolved.
|
||||
if (path.isAbsolute(includePath)) {
|
||||
if (!fs.existsSync(includePath)) {
|
||||
throw new Error('The include `' + includePath + '` was not found.');
|
||||
}
|
||||
return includePath;
|
||||
}
|
||||
if (COMMON_PROTO_FILES.indexOf(includePath) > -1) {
|
||||
return path.join(googleProtoFilesDir, includePath);
|
||||
}
|
||||
return GoogleProtoFilesRoot._findIncludePath(originPath, includePath);
|
||||
}
|
||||
static _findIncludePath(originPath, includePath) {
|
||||
originPath = path.normalize(originPath);
|
||||
includePath = path.normalize(includePath);
|
||||
let current = originPath;
|
||||
let found = fs.existsSync(path.join(current, includePath));
|
||||
while (!found && current.length > 0) {
|
||||
current = current.substring(0, current.lastIndexOf(path.sep));
|
||||
found = fs.existsSync(path.join(current, includePath));
|
||||
}
|
||||
if (!found) {
|
||||
throw new Error('The include `' + includePath + '` was not found.');
|
||||
}
|
||||
return path.join(current, includePath);
|
||||
}
|
||||
}
|
||||
exports.GoogleProtoFilesRoot = GoogleProtoFilesRoot;
|
||||
//# sourceMappingURL=grpc.js.map
|
||||
1
functions/node_modules/google-gax/build/src/grpc.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/grpc.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
89
functions/node_modules/google-gax/build/src/iamService.d.ts
generated
vendored
Normal file
89
functions/node_modules/google-gax/build/src/iamService.d.ts
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import * as gax from './gax';
|
||||
import type { GrpcClient } from './grpc';
|
||||
import type { GrpcClient as FallbackGrpcClient } from './fallback';
|
||||
import { GoogleAuth, OAuth2Client } from 'google-auth-library';
|
||||
import { ProjectIdCallback } from 'google-auth-library/build/src/auth/googleauth';
|
||||
import * as protos from '../protos/iam_service';
|
||||
import type { Descriptors, ClientOptions, Callback } from './clientInterface';
|
||||
/**
|
||||
* Google Cloud IAM Client.
|
||||
* This is manually written for providing methods [setIamPolicy, getIamPolicy, testIamPerssion] to the generated client.
|
||||
*/
|
||||
export declare class IamClient {
|
||||
private _terminated;
|
||||
private _opts;
|
||||
private _defaults;
|
||||
private _protos;
|
||||
auth?: GoogleAuth | OAuth2Client;
|
||||
descriptors: Descriptors;
|
||||
innerApiCalls: {
|
||||
[name: string]: Function;
|
||||
};
|
||||
iamPolicyStub?: Promise<{
|
||||
[name: string]: Function;
|
||||
}>;
|
||||
gaxGrpc: GrpcClient | FallbackGrpcClient;
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient, options: ClientOptions);
|
||||
/**
|
||||
* Initialize the client.
|
||||
* Performs asynchronous operations (such as authentication) and prepares the client.
|
||||
* This function will be called automatically when any class method is called for the
|
||||
* first time, but if you need to initialize it before calling an actual method,
|
||||
* feel free to call initialize() directly.
|
||||
*
|
||||
* You can await on this method if you want to make sure the client is initialized.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
||||
*/
|
||||
initialize(): Promise<{
|
||||
[name: string]: Function;
|
||||
}>;
|
||||
/**
|
||||
* The DNS address for this API service.
|
||||
*/
|
||||
static get servicePath(): string;
|
||||
/**
|
||||
* The DNS address for this API service - same as servicePath(),
|
||||
* exists for compatibility reasons.
|
||||
*/
|
||||
static get apiEndpoint(): string;
|
||||
/**
|
||||
* The port for this API service.
|
||||
*/
|
||||
static get port(): number;
|
||||
/**
|
||||
* The scopes needed to make gRPC calls for every method defined
|
||||
* in this service.
|
||||
*/
|
||||
static get scopes(): string[];
|
||||
/**
|
||||
* Get the project ID used by this class.
|
||||
* @param {function(Error, string)} callback - the callback to be called with
|
||||
* the current project Id.
|
||||
*/
|
||||
getProjectId(): Promise<string>;
|
||||
getProjectId(callback: ProjectIdCallback): void;
|
||||
getIamPolicy(request: protos.google.iam.v1.GetIamPolicyRequest, options?: gax.CallOptions): Promise<[protos.google.iam.v1.Policy]>;
|
||||
getIamPolicy(request: protos.google.iam.v1.GetIamPolicyRequest, options: gax.CallOptions, callback: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
|
||||
getIamPolicy(request: protos.google.iam.v1.GetIamPolicyRequest, callback: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
|
||||
setIamPolicy(request: protos.google.iam.v1.SetIamPolicyRequest, options?: gax.CallOptions): Promise<[protos.google.iam.v1.Policy]>;
|
||||
setIamPolicy(request: protos.google.iam.v1.SetIamPolicyRequest, options: gax.CallOptions, callback: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
|
||||
setIamPolicy(request: protos.google.iam.v1.SetIamPolicyRequest, callback: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
|
||||
testIamPermissions(request: protos.google.iam.v1.TestIamPermissionsRequest, options?: gax.CallOptions): Promise<[protos.google.iam.v1.TestIamPermissionsResponse]>;
|
||||
testIamPermissions(request: protos.google.iam.v1.TestIamPermissionsRequest, callback: Callback<protos.google.iam.v1.TestIamPermissionsResponse, protos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
|
||||
testIamPermissions(request: protos.google.iam.v1.TestIamPermissionsRequest, options: gax.CallOptions, callback: Callback<protos.google.iam.v1.TestIamPermissionsResponse, protos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
|
||||
/**
|
||||
* Terminate the GRPC channel and close the client.
|
||||
*
|
||||
* The client will no longer be usable and all future behavior is undefined.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
}
|
||||
export interface IamClient {
|
||||
getIamPolicy(request: protos.google.iam.v1.GetIamPolicyRequest): void;
|
||||
getIamPolicy(request: protos.google.iam.v1.GetIamPolicyRequest, options?: gax.CallOptions | Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined>, callback?: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined>): Promise<[protos.google.iam.v1.Policy]>;
|
||||
setIamPolicy(request: protos.google.iam.v1.SetIamPolicyRequest): void;
|
||||
setIamPolicy(request: protos.google.iam.v1.SetIamPolicyRequest, options?: gax.CallOptions | Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined>, callback?: Callback<protos.google.iam.v1.Policy, protos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined>): Promise<[protos.google.iam.v1.Policy]>;
|
||||
testIamPermissions(request: protos.google.iam.v1.TestIamPermissionsRequest): void;
|
||||
testIamPermissions(request: protos.google.iam.v1.TestIamPermissionsRequest, options?: gax.CallOptions | Callback<protos.google.iam.v1.TestIamPermissionsResponse, protos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined>, callback?: Callback<protos.google.iam.v1.TestIamPermissionsResponse, protos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined>): Promise<[protos.google.iam.v1.TestIamPermissionsResponse]>;
|
||||
}
|
||||
232
functions/node_modules/google-gax/build/src/iamService.js
generated
vendored
Normal file
232
functions/node_modules/google-gax/build/src/iamService.js
generated
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
"use strict";
|
||||
// Copyright 2020 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// ** This file is automatically generated by gapic-generator-typescript. **
|
||||
// ** https://github.com/googleapis/gapic-generator-typescript **
|
||||
// ** All changes to this file may be overwritten. **
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IamClient = void 0;
|
||||
const createApiCall_1 = require("./createApiCall");
|
||||
const routingHeader = require("./routingHeader");
|
||||
const gapicConfig = require("./iam_policy_service_client_config.json");
|
||||
const fallback = require("./fallback");
|
||||
let version = require('../../package.json').version;
|
||||
const jsonProtos = require("../protos/iam_service.json");
|
||||
/**
|
||||
* Google Cloud IAM Client.
|
||||
* This is manually written for providing methods [setIamPolicy, getIamPolicy, testIamPerssion] to the generated client.
|
||||
*/
|
||||
class IamClient {
|
||||
constructor(gaxGrpc,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
options) {
|
||||
this._terminated = false;
|
||||
this.descriptors = { page: {}, stream: {}, longrunning: {} };
|
||||
this.innerApiCalls = {};
|
||||
this.gaxGrpc = gaxGrpc;
|
||||
// Ensure that options include the service address and port.
|
||||
const opts = Object.assign({
|
||||
servicePath: options.servicePath,
|
||||
port: options.port,
|
||||
clientConfig: options.clientConfig,
|
||||
apiEndpoint: options.apiEndpoint,
|
||||
fallback: options.fallback,
|
||||
}, options);
|
||||
version = opts.fallback ? fallback.version : version;
|
||||
opts.scopes = this.constructor.scopes;
|
||||
// Save options to use in initialize() method.
|
||||
this._opts = opts;
|
||||
// Save the auth object to the client, for use by other methods.
|
||||
this.auth = gaxGrpc.auth;
|
||||
// Determine the client header string.
|
||||
const clientHeader = [`gax/${version}`, `gapic/${version}`];
|
||||
if (typeof process !== 'undefined' && 'versions' in process) {
|
||||
clientHeader.push(`gl-node/${process.versions.node}`);
|
||||
}
|
||||
else {
|
||||
clientHeader.push(`gl-web/${version}`);
|
||||
}
|
||||
if (!opts.fallback) {
|
||||
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
|
||||
}
|
||||
if (opts.libName && opts.libVersion) {
|
||||
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
||||
}
|
||||
// Load the applicable protos.
|
||||
this._protos = this.gaxGrpc.loadProtoJSON(jsonProtos);
|
||||
// Put together the default options sent with requests.
|
||||
this._defaults = gaxGrpc.constructSettings('google.iam.v1.IAMPolicy', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
||||
this.innerApiCalls = {};
|
||||
}
|
||||
/**
|
||||
* Initialize the client.
|
||||
* Performs asynchronous operations (such as authentication) and prepares the client.
|
||||
* This function will be called automatically when any class method is called for the
|
||||
* first time, but if you need to initialize it before calling an actual method,
|
||||
* feel free to call initialize() directly.
|
||||
*
|
||||
* You can await on this method if you want to make sure the client is initialized.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
||||
*/
|
||||
initialize() {
|
||||
// If the client stub promise is already initialized, return immediately.
|
||||
if (this.iamPolicyStub) {
|
||||
return this.iamPolicyStub;
|
||||
}
|
||||
// Put together the "service stub" for
|
||||
// google.iam.v1.IAMPolicy.
|
||||
this.iamPolicyStub = this.gaxGrpc.createStub(this._opts.fallback
|
||||
? this._protos.lookupService('google.iam.v1.IAMPolicy')
|
||||
: this._protos.google.iam.v1.IAMPolicy, this._opts);
|
||||
// Iterate over each of the methods that the service provides
|
||||
// and create an API call method for each.
|
||||
const iamPolicyStubMethods = [
|
||||
'getIamPolicy',
|
||||
'setIamPolicy',
|
||||
'testIamPermissions',
|
||||
];
|
||||
for (const methodName of iamPolicyStubMethods) {
|
||||
const innerCallPromise = this.iamPolicyStub.then(stub => (...args) => {
|
||||
if (this._terminated) {
|
||||
return Promise.reject('The client has already been closed.');
|
||||
}
|
||||
const func = stub[methodName];
|
||||
return func.apply(stub, args);
|
||||
}, (err) => () => {
|
||||
throw err;
|
||||
});
|
||||
this.innerApiCalls[methodName] = (0, createApiCall_1.createApiCall)(innerCallPromise, this._defaults[methodName], this.descriptors.page[methodName]);
|
||||
}
|
||||
return this.iamPolicyStub;
|
||||
}
|
||||
/**
|
||||
* The DNS address for this API service.
|
||||
*/
|
||||
static get servicePath() {
|
||||
return 'cloudkms.googleapis.com';
|
||||
}
|
||||
/**
|
||||
* The DNS address for this API service - same as servicePath(),
|
||||
* exists for compatibility reasons.
|
||||
*/
|
||||
static get apiEndpoint() {
|
||||
return 'cloudkms.googleapis.com';
|
||||
}
|
||||
/**
|
||||
* The port for this API service.
|
||||
*/
|
||||
static get port() {
|
||||
return 443;
|
||||
}
|
||||
/**
|
||||
* The scopes needed to make gRPC calls for every method defined
|
||||
* in this service.
|
||||
*/
|
||||
static get scopes() {
|
||||
return [
|
||||
'https://www.googleapis.com/auth/cloud-platform',
|
||||
'https://www.googleapis.com/auth/cloudkms',
|
||||
];
|
||||
}
|
||||
getProjectId(callback) {
|
||||
if (this.auth && 'getProjectId' in this.auth) {
|
||||
return this.auth.getProjectId(callback);
|
||||
}
|
||||
if (callback) {
|
||||
callback(new Error('Cannot determine project ID.'));
|
||||
}
|
||||
else {
|
||||
return Promise.reject('Cannot determine project ID.');
|
||||
}
|
||||
}
|
||||
getIamPolicy(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
resource: request.resource,
|
||||
});
|
||||
this.initialize();
|
||||
return this.innerApiCalls.getIamPolicy(request, options, callback);
|
||||
}
|
||||
setIamPolicy(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
resource: request.resource,
|
||||
});
|
||||
this.initialize();
|
||||
return this.innerApiCalls.setIamPolicy(request, options, callback);
|
||||
}
|
||||
testIamPermissions(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
resource: request.resource,
|
||||
});
|
||||
this.initialize();
|
||||
return this.innerApiCalls.testIamPermissions(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Terminate the GRPC channel and close the client.
|
||||
*
|
||||
* The client will no longer be usable and all future behavior is undefined.
|
||||
*/
|
||||
close() {
|
||||
this.initialize();
|
||||
if (!this._terminated) {
|
||||
return this.iamPolicyStub.then(stub => {
|
||||
this._terminated = true;
|
||||
stub.close();
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
exports.IamClient = IamClient;
|
||||
//# sourceMappingURL=iamService.js.map
|
||||
1
functions/node_modules/google-gax/build/src/iamService.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/iamService.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
38
functions/node_modules/google-gax/build/src/iam_policy_service_client_config.json
generated
vendored
Normal file
38
functions/node_modules/google-gax/build/src/iam_policy_service_client_config.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"interfaces": {
|
||||
"google.iam.v1.IAMPolicy": {
|
||||
"retry_codes": {
|
||||
"non_idempotent": [],
|
||||
"idempotent": [
|
||||
"DEADLINE_EXCEEDED",
|
||||
"UNAVAILABLE"
|
||||
]
|
||||
},
|
||||
"retry_params": {
|
||||
"default": {
|
||||
"initial_retry_delay_millis": 100,
|
||||
"retry_delay_multiplier": 1.3,
|
||||
"max_retry_delay_millis": 60000,
|
||||
"initial_rpc_timeout_millis": 20000,
|
||||
"rpc_timeout_multiplier": 1,
|
||||
"max_rpc_timeout_millis": 20000,
|
||||
"total_timeout_millis": 600000
|
||||
}
|
||||
},
|
||||
"methods": {
|
||||
"GetIamPolicy": {
|
||||
"retry_codes_name": "non_idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"SetIamPolicy": {
|
||||
"retry_codes_name": "non_idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"TestIamPermissions": {
|
||||
"retry_codes_name": "non_idempotent",
|
||||
"retry_params_name": "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
58
functions/node_modules/google-gax/build/src/index.d.ts
generated
vendored
Normal file
58
functions/node_modules/google-gax/build/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as grpc from '@grpc/grpc-js';
|
||||
import { GrpcClient, GrpcClientOptions } from './grpc';
|
||||
import * as IamProtos from '../protos/iam_service';
|
||||
import * as LocationProtos from '../protos/locations';
|
||||
import * as operationsProtos from '../protos/operations';
|
||||
import * as operationsClient from './operationsClient';
|
||||
import * as routingHeader from './routingHeader';
|
||||
export { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
||||
export { grpc };
|
||||
export { CancellablePromise, OngoingCall } from './call';
|
||||
export { createApiCall } from './createApiCall';
|
||||
export { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor, } from './descriptor';
|
||||
export { CallOptions, CallSettings, ClientConfig, constructSettings, RetryOptions, ServiceConfig, createRetryOptions, createBundleOptions, createBackoffSettings, createDefaultBackoffSettings, createMaxRetriesBackoffSettings, } from './gax';
|
||||
export { GoogleError } from './googleError';
|
||||
export { ClientStub, ClientStubOptions, GoogleProtoFilesRoot, GrpcClient, GrpcClientOptions, GrpcModule, Metadata, MetadataValue, } from './grpc';
|
||||
export { Operation, operation } from './longRunningCalls/longrunning';
|
||||
export { PathTemplate } from './pathTemplate';
|
||||
export { Status } from './status';
|
||||
export { StreamType } from './streamingCalls/streaming';
|
||||
export { routingHeader };
|
||||
declare function lro(options: GrpcClientOptions): operationsClient.OperationsClientBuilder;
|
||||
declare namespace lro {
|
||||
var SERVICE_ADDRESS: string;
|
||||
var ALL_SCOPES: string[];
|
||||
}
|
||||
export { lro, operationsProtos, IamProtos, LocationProtos };
|
||||
export { OperationsClient } from './operationsClient';
|
||||
export { IamClient } from './iamService';
|
||||
export { LocationsClient } from './locationService';
|
||||
export declare const createByteLengthFunction: typeof GrpcClient.createByteLengthFunction;
|
||||
export declare const version: any;
|
||||
import * as protobuf from 'protobufjs';
|
||||
export { protobuf };
|
||||
export * as protobufMinimal from 'protobufjs/minimal';
|
||||
import * as fallback from './fallback';
|
||||
export { fallback };
|
||||
export { APICallback, GRPCCallResult, ServerStreamingCall, ClientStreamingCall, BiDiStreamingCall, UnaryCall, GRPCCall, GaxCall, CancellableStream, } from './apitypes';
|
||||
export { ClientOptions, Descriptors, Callback, LROperation, PaginationCallback, PaginationResponse, } from './clientInterface';
|
||||
export { makeUUID } from './util';
|
||||
export { ServiceError, ChannelCredentials } from '@grpc/grpc-js';
|
||||
export { warn } from './warnings';
|
||||
import * as serializer from 'proto3-json-serializer';
|
||||
export { serializer };
|
||||
95
functions/node_modules/google-gax/build/src/index.js
generated
vendored
Normal file
95
functions/node_modules/google-gax/build/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.serializer = exports.warn = exports.ChannelCredentials = exports.makeUUID = exports.fallback = exports.protobufMinimal = exports.protobuf = exports.version = exports.createByteLengthFunction = exports.LocationsClient = exports.IamClient = exports.OperationsClient = exports.LocationProtos = exports.IamProtos = exports.operationsProtos = exports.routingHeader = exports.StreamType = exports.Status = exports.PathTemplate = exports.operation = exports.Operation = exports.GrpcClient = exports.GoogleProtoFilesRoot = exports.ClientStub = exports.GoogleError = exports.createMaxRetriesBackoffSettings = exports.createDefaultBackoffSettings = exports.createBackoffSettings = exports.createBundleOptions = exports.createRetryOptions = exports.RetryOptions = exports.constructSettings = exports.CallSettings = exports.StreamDescriptor = exports.PageDescriptor = exports.LongrunningDescriptor = exports.BundleDescriptor = exports.createApiCall = exports.OngoingCall = exports.grpc = exports.GoogleAuth = void 0;
|
||||
exports.lro = lro;
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
exports.grpc = grpc;
|
||||
const grpc_1 = require("./grpc");
|
||||
const IamProtos = require("../protos/iam_service");
|
||||
exports.IamProtos = IamProtos;
|
||||
const LocationProtos = require("../protos/locations");
|
||||
exports.LocationProtos = LocationProtos;
|
||||
const operationsProtos = require("../protos/operations");
|
||||
exports.operationsProtos = operationsProtos;
|
||||
const operationsClient = require("./operationsClient");
|
||||
const routingHeader = require("./routingHeader");
|
||||
exports.routingHeader = routingHeader;
|
||||
var google_auth_library_1 = require("google-auth-library");
|
||||
Object.defineProperty(exports, "GoogleAuth", { enumerable: true, get: function () { return google_auth_library_1.GoogleAuth; } });
|
||||
var call_1 = require("./call");
|
||||
Object.defineProperty(exports, "OngoingCall", { enumerable: true, get: function () { return call_1.OngoingCall; } });
|
||||
var createApiCall_1 = require("./createApiCall");
|
||||
Object.defineProperty(exports, "createApiCall", { enumerable: true, get: function () { return createApiCall_1.createApiCall; } });
|
||||
var descriptor_1 = require("./descriptor");
|
||||
Object.defineProperty(exports, "BundleDescriptor", { enumerable: true, get: function () { return descriptor_1.BundleDescriptor; } });
|
||||
Object.defineProperty(exports, "LongrunningDescriptor", { enumerable: true, get: function () { return descriptor_1.LongrunningDescriptor; } });
|
||||
Object.defineProperty(exports, "PageDescriptor", { enumerable: true, get: function () { return descriptor_1.PageDescriptor; } });
|
||||
Object.defineProperty(exports, "StreamDescriptor", { enumerable: true, get: function () { return descriptor_1.StreamDescriptor; } });
|
||||
var gax_1 = require("./gax");
|
||||
Object.defineProperty(exports, "CallSettings", { enumerable: true, get: function () { return gax_1.CallSettings; } });
|
||||
Object.defineProperty(exports, "constructSettings", { enumerable: true, get: function () { return gax_1.constructSettings; } });
|
||||
Object.defineProperty(exports, "RetryOptions", { enumerable: true, get: function () { return gax_1.RetryOptions; } });
|
||||
Object.defineProperty(exports, "createRetryOptions", { enumerable: true, get: function () { return gax_1.createRetryOptions; } });
|
||||
Object.defineProperty(exports, "createBundleOptions", { enumerable: true, get: function () { return gax_1.createBundleOptions; } });
|
||||
Object.defineProperty(exports, "createBackoffSettings", { enumerable: true, get: function () { return gax_1.createBackoffSettings; } });
|
||||
Object.defineProperty(exports, "createDefaultBackoffSettings", { enumerable: true, get: function () { return gax_1.createDefaultBackoffSettings; } });
|
||||
Object.defineProperty(exports, "createMaxRetriesBackoffSettings", { enumerable: true, get: function () { return gax_1.createMaxRetriesBackoffSettings; } });
|
||||
var googleError_1 = require("./googleError");
|
||||
Object.defineProperty(exports, "GoogleError", { enumerable: true, get: function () { return googleError_1.GoogleError; } });
|
||||
var grpc_2 = require("./grpc");
|
||||
Object.defineProperty(exports, "ClientStub", { enumerable: true, get: function () { return grpc_2.ClientStub; } });
|
||||
Object.defineProperty(exports, "GoogleProtoFilesRoot", { enumerable: true, get: function () { return grpc_2.GoogleProtoFilesRoot; } });
|
||||
Object.defineProperty(exports, "GrpcClient", { enumerable: true, get: function () { return grpc_2.GrpcClient; } });
|
||||
var longrunning_1 = require("./longRunningCalls/longrunning");
|
||||
Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return longrunning_1.Operation; } });
|
||||
Object.defineProperty(exports, "operation", { enumerable: true, get: function () { return longrunning_1.operation; } });
|
||||
var pathTemplate_1 = require("./pathTemplate");
|
||||
Object.defineProperty(exports, "PathTemplate", { enumerable: true, get: function () { return pathTemplate_1.PathTemplate; } });
|
||||
var status_1 = require("./status");
|
||||
Object.defineProperty(exports, "Status", { enumerable: true, get: function () { return status_1.Status; } });
|
||||
var streaming_1 = require("./streamingCalls/streaming");
|
||||
Object.defineProperty(exports, "StreamType", { enumerable: true, get: function () { return streaming_1.StreamType; } });
|
||||
function lro(options) {
|
||||
options = Object.assign({ scopes: lro.ALL_SCOPES }, options);
|
||||
const gaxGrpc = new grpc_1.GrpcClient(options);
|
||||
return new operationsClient.OperationsClientBuilder(gaxGrpc);
|
||||
}
|
||||
lro.SERVICE_ADDRESS = operationsClient.SERVICE_ADDRESS;
|
||||
lro.ALL_SCOPES = operationsClient.ALL_SCOPES;
|
||||
var operationsClient_1 = require("./operationsClient");
|
||||
Object.defineProperty(exports, "OperationsClient", { enumerable: true, get: function () { return operationsClient_1.OperationsClient; } });
|
||||
var iamService_1 = require("./iamService");
|
||||
Object.defineProperty(exports, "IamClient", { enumerable: true, get: function () { return iamService_1.IamClient; } });
|
||||
var locationService_1 = require("./locationService");
|
||||
Object.defineProperty(exports, "LocationsClient", { enumerable: true, get: function () { return locationService_1.LocationsClient; } });
|
||||
exports.createByteLengthFunction = grpc_1.GrpcClient.createByteLengthFunction;
|
||||
exports.version = require('../../package.json').version;
|
||||
const protobuf = require("protobufjs");
|
||||
exports.protobuf = protobuf;
|
||||
exports.protobufMinimal = require("protobufjs/minimal");
|
||||
const fallback = require("./fallback");
|
||||
exports.fallback = fallback;
|
||||
var util_1 = require("./util");
|
||||
Object.defineProperty(exports, "makeUUID", { enumerable: true, get: function () { return util_1.makeUUID; } });
|
||||
var grpc_js_1 = require("@grpc/grpc-js");
|
||||
Object.defineProperty(exports, "ChannelCredentials", { enumerable: true, get: function () { return grpc_js_1.ChannelCredentials; } });
|
||||
var warnings_1 = require("./warnings");
|
||||
Object.defineProperty(exports, "warn", { enumerable: true, get: function () { return warnings_1.warn; } });
|
||||
const serializer = require("proto3-json-serializer");
|
||||
exports.serializer = serializer;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
functions/node_modules/google-gax/build/src/index.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA2DK,kBAAG;AAzDX,sCAAsC;AAS9B,oBAAI;AARZ,iCAAqD;AACrD,mDAAmD;AAuDpB,8BAAS;AAtDxC,sDAAsD;AAsDZ,wCAAc;AArDxD,yDAAyD;AAqD5C,4CAAgB;AApD7B,uDAAuD;AACvD,iDAAiD;AAwCzC,sCAAa;AAtCrB,2DAAkE;AAA1D,iHAAA,UAAU,OAAA;AAElB,+BAAuD;AAA3B,mGAAA,WAAW,OAAA;AACvC,iDAA8C;AAAtC,8GAAA,aAAa,OAAA;AACrB,2CAKsB;AAJpB,8GAAA,gBAAgB,OAAA;AAChB,mHAAA,qBAAqB,OAAA;AACrB,4GAAA,cAAc,OAAA;AACd,8GAAA,gBAAgB,OAAA;AAElB,6BAYe;AAVb,mGAAA,YAAY,OAAA;AAEZ,wGAAA,iBAAiB,OAAA;AACjB,mGAAA,YAAY,OAAA;AAEZ,yGAAA,kBAAkB,OAAA;AAClB,0GAAA,mBAAmB,OAAA;AACnB,4GAAA,qBAAqB,OAAA;AACrB,mHAAA,4BAA4B,OAAA;AAC5B,sHAAA,+BAA+B,OAAA;AAEjC,6CAA0C;AAAlC,0GAAA,WAAW,OAAA;AACnB,+BASgB;AARd,kGAAA,UAAU,OAAA;AAEV,4GAAA,oBAAoB,OAAA;AACpB,kGAAA,UAAU,OAAA;AAMZ,8DAAoE;AAA5D,wGAAA,SAAS,OAAA;AAAE,wGAAA,SAAS,OAAA;AAC5B,+CAA4C;AAApC,4GAAA,YAAY,OAAA;AACpB,mCAAgC;AAAxB,gGAAA,MAAM,OAAA;AACd,wDAAsD;AAA9C,uGAAA,UAAU,OAAA;AAGlB,SAAS,GAAG,CAAC,OAA0B;IACrC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAC,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,IAAI,iBAAU,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,IAAI,gBAAgB,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,GAAG,CAAC,eAAe,GAAG,gBAAgB,CAAC,eAAe,CAAC;AACvD,GAAG,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC;AAG7C,uDAAoD;AAA5C,oHAAA,gBAAgB,OAAA;AACxB,2CAAuC;AAA/B,uGAAA,SAAS,OAAA;AACjB,qDAAkD;AAA1C,kHAAA,eAAe,OAAA;AAEV,QAAA,wBAAwB,GAAG,iBAAU,CAAC,wBAAwB,CAAC;AAC/D,QAAA,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAE7D,uCAAuC;AAC/B,4BAAQ;AAChB,wDAAsD;AAEtD,uCAAuC;AAC/B,4BAAQ;AAuBhB,+BAAgC;AAAxB,gGAAA,QAAQ,OAAA;AAEhB,yCAA+D;AAAzC,6GAAA,kBAAkB,OAAA;AACxC,uCAAgC;AAAxB,gGAAA,IAAI,OAAA;AAEZ,qDAAqD;AAC7C,gCAAU"}
|
||||
127
functions/node_modules/google-gax/build/src/locationService.d.ts
generated
vendored
Normal file
127
functions/node_modules/google-gax/build/src/locationService.d.ts
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import * as gax from './gax';
|
||||
import type { GrpcClient } from './grpc';
|
||||
import type { GrpcClient as FallbackGrpcClient } from './fallback';
|
||||
import type { GoogleAuth } from 'google-auth-library';
|
||||
import * as protos from '../protos/locations';
|
||||
import type { Descriptors, ClientOptions, Callback, PaginationCallback } from './clientInterface';
|
||||
/**
|
||||
* Google Cloud Locations Client.
|
||||
* This is manually written for providing methods [listLocations, getLocations] to the generated client.
|
||||
*/
|
||||
export declare class LocationsClient {
|
||||
private _terminated;
|
||||
private _opts;
|
||||
private _providedCustomServicePath;
|
||||
private _protos;
|
||||
private _defaults;
|
||||
auth: GoogleAuth;
|
||||
descriptors: Descriptors;
|
||||
warn: (code: string, message: string, warnType?: string) => void;
|
||||
innerApiCalls: {
|
||||
[name: string]: Function;
|
||||
};
|
||||
locationsStub?: Promise<{
|
||||
[name: string]: Function;
|
||||
}>;
|
||||
gaxGrpc: GrpcClient | FallbackGrpcClient;
|
||||
PageDescriptor: any;
|
||||
/**
|
||||
* Construct an instance of LocationsClient.
|
||||
*
|
||||
* @param {object} [options] - The configuration object.
|
||||
* The options accepted by the constructor are described in detail
|
||||
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
||||
* The common options are:
|
||||
* @param {object} [options.credentials] - Credentials object.
|
||||
* @param {string} [options.credentials.client_email]
|
||||
* @param {string} [options.credentials.private_key]
|
||||
* @param {string} [options.email] - Account email address. Required when
|
||||
* using a .pem or .p12 keyFilename.
|
||||
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
||||
* .p12 key downloaded from the Google Developers Console. If you provide
|
||||
* a path to a JSON file, the projectId option below is not necessary.
|
||||
* NOTE: .pem and .p12 require you to specify options.email as well.
|
||||
* @param {number} [options.port] - The port on which to connect to
|
||||
* the remote host.
|
||||
* @param {string} [options.projectId] - The project ID from the Google
|
||||
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
||||
* the environment variable GCLOUD_PROJECT for your project ID. If your
|
||||
* app is running in an environment which supports
|
||||
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
|
||||
* your project ID will be detected automatically.
|
||||
* @param {string} [options.apiEndpoint] - The domain name of the
|
||||
* API remote host.
|
||||
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
||||
* Follows the structure of {@link gapicConfig}.
|
||||
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
|
||||
* In fallback mode, a special browser-compatible transport implementation is used
|
||||
* instead of gRPC transport. In browser context (if the `window` object is defined)
|
||||
* the fallback mode is enabled automatically; set `options.fallback` to `false`
|
||||
* if you need to override this behavior.
|
||||
*/
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient, opts: ClientOptions);
|
||||
/**
|
||||
* Initialize the client.
|
||||
* Performs asynchronous operations (such as authentication) and prepares the client.
|
||||
* This function will be called automatically when any class method is called for the
|
||||
* first time, but if you need to initialize it before calling an actual method,
|
||||
* feel free to call initialize() directly.
|
||||
*
|
||||
* You can await on this method if you want to make sure the client is initialized.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
||||
*/
|
||||
initialize(): Promise<{
|
||||
[name: string]: Function;
|
||||
}>;
|
||||
/**
|
||||
* The DNS address for this API service.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
static get servicePath(): string;
|
||||
/**
|
||||
* The DNS address for this API service - same as servicePath(),
|
||||
* exists for compatibility reasons.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
static get apiEndpoint(): string;
|
||||
/**
|
||||
* The port for this API service.
|
||||
* @returns {number} The default port for this service.
|
||||
*/
|
||||
static get port(): number;
|
||||
/**
|
||||
* The scopes needed to make gRPC calls for every method defined
|
||||
* in this service.
|
||||
* @returns {string[]} List of default scopes.
|
||||
*/
|
||||
static get scopes(): string[];
|
||||
/**
|
||||
* Return the project ID used by this class.
|
||||
* @returns {Promise} A promise that resolves to string containing the project ID.
|
||||
*/
|
||||
getProjectId(): Promise<string>;
|
||||
getProjectId(callback: Callback<string, undefined, undefined>): void;
|
||||
getLocation(request?: protos.google.cloud.location.IGetLocationRequest, options?: gax.CallOptions): Promise<protos.google.cloud.location.ILocation>;
|
||||
getLocation(request: protos.google.cloud.location.IGetLocationRequest, options: gax.CallOptions, callback: Callback<protos.google.cloud.location.ILocation, protos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): void;
|
||||
getLocation(request: protos.google.cloud.location.IGetLocationRequest, callback: Callback<protos.google.cloud.location.ILocation, protos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): void;
|
||||
listLocations(request?: protos.google.cloud.location.IListLocationsRequest, options?: gax.CallOptions): Promise<[
|
||||
protos.google.cloud.location.ILocation[],
|
||||
protos.google.cloud.location.IListLocationsRequest | null,
|
||||
protos.google.cloud.location.IListLocationsResponse
|
||||
]>;
|
||||
listLocations(request: protos.google.cloud.location.IListLocationsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.cloud.location.IListLocationsRequest, protos.google.cloud.location.IListLocationsResponse | null | undefined, protos.google.cloud.location.ILocation>): void;
|
||||
listLocations(request: protos.google.cloud.location.IListLocationsRequest, callback: PaginationCallback<protos.google.cloud.location.IListLocationsRequest, protos.google.cloud.location.IListLocationsResponse | null | undefined, protos.google.cloud.location.ILocation>): void;
|
||||
/**
|
||||
* Terminate the gRPC channel and close the client.
|
||||
*
|
||||
* The client will no longer be usable and all future behavior is undefined.
|
||||
* @returns {Promise} A promise that resolves when the client is closed.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
}
|
||||
export interface LocationsClient {
|
||||
getLocation(request: protos.google.cloud.location.IGetLocationRequest): void;
|
||||
getLocation(request: protos.google.cloud.location.IGetLocationRequest, options?: gax.CallOptions | Callback<protos.google.cloud.location.ILocation, protos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>, callback?: Callback<protos.google.cloud.location.ILocation, protos.google.cloud.location.IGetLocationRequest | null | undefined, {} | null | undefined>): Promise<protos.google.cloud.location.ILocation>;
|
||||
listLocationsAsync(request: protos.google.cloud.location.IListLocationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.cloud.location.ILocation>;
|
||||
}
|
||||
357
functions/node_modules/google-gax/build/src/locationService.js
generated
vendored
Normal file
357
functions/node_modules/google-gax/build/src/locationService.js
generated
vendored
Normal file
@@ -0,0 +1,357 @@
|
||||
"use strict";
|
||||
// Copyright 2021 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LocationsClient = void 0;
|
||||
/* global window */
|
||||
const gax = require("./gax");
|
||||
const warnings_1 = require("./warnings");
|
||||
const createApiCall_1 = require("./createApiCall");
|
||||
const routingHeader = require("./routingHeader");
|
||||
const pageDescriptor_1 = require("./paginationCalls/pageDescriptor");
|
||||
const jsonProtos = require("../protos/locations.json");
|
||||
/**
|
||||
* This file defines retry strategy and timeouts for all API methods in this library.
|
||||
*/
|
||||
const gapicConfig = require("./locations_client_config.json");
|
||||
const version = require('../../package.json').version;
|
||||
/**
|
||||
* Google Cloud Locations Client.
|
||||
* This is manually written for providing methods [listLocations, getLocations] to the generated client.
|
||||
*/
|
||||
class LocationsClient {
|
||||
/**
|
||||
* Construct an instance of LocationsClient.
|
||||
*
|
||||
* @param {object} [options] - The configuration object.
|
||||
* The options accepted by the constructor are described in detail
|
||||
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
|
||||
* The common options are:
|
||||
* @param {object} [options.credentials] - Credentials object.
|
||||
* @param {string} [options.credentials.client_email]
|
||||
* @param {string} [options.credentials.private_key]
|
||||
* @param {string} [options.email] - Account email address. Required when
|
||||
* using a .pem or .p12 keyFilename.
|
||||
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
|
||||
* .p12 key downloaded from the Google Developers Console. If you provide
|
||||
* a path to a JSON file, the projectId option below is not necessary.
|
||||
* NOTE: .pem and .p12 require you to specify options.email as well.
|
||||
* @param {number} [options.port] - The port on which to connect to
|
||||
* the remote host.
|
||||
* @param {string} [options.projectId] - The project ID from the Google
|
||||
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
|
||||
* the environment variable GCLOUD_PROJECT for your project ID. If your
|
||||
* app is running in an environment which supports
|
||||
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
|
||||
* your project ID will be detected automatically.
|
||||
* @param {string} [options.apiEndpoint] - The domain name of the
|
||||
* API remote host.
|
||||
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
|
||||
* Follows the structure of {@link gapicConfig}.
|
||||
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
|
||||
* In fallback mode, a special browser-compatible transport implementation is used
|
||||
* instead of gRPC transport. In browser context (if the `window` object is defined)
|
||||
* the fallback mode is enabled automatically; set `options.fallback` to `false`
|
||||
* if you need to override this behavior.
|
||||
*/
|
||||
constructor(gaxGrpc,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
opts) {
|
||||
var _a, _b;
|
||||
this._terminated = false;
|
||||
this.descriptors = {
|
||||
page: {},
|
||||
stream: {},
|
||||
longrunning: {},
|
||||
batching: {},
|
||||
};
|
||||
// Ensure that options include all the required fields.
|
||||
this.gaxGrpc = gaxGrpc;
|
||||
const staticMembers = this.constructor;
|
||||
const servicePath = (opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || staticMembers.servicePath;
|
||||
this._providedCustomServicePath = !!((opts === null || opts === void 0 ? void 0 : opts.servicePath) || (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint));
|
||||
const port = (opts === null || opts === void 0 ? void 0 : opts.port) || staticMembers.port;
|
||||
const clientConfig = (_a = opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== null && _a !== void 0 ? _a : {};
|
||||
const fallback = (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== null && _b !== void 0 ? _b : (typeof window !== 'undefined' && typeof (window === null || window === void 0 ? void 0 : window.fetch) === 'function');
|
||||
opts = Object.assign({ servicePath, port, clientConfig, fallback }, opts);
|
||||
// If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
|
||||
if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) {
|
||||
opts['scopes'] = staticMembers.scopes;
|
||||
}
|
||||
// Save options to use in initialize() method.
|
||||
this._opts = opts;
|
||||
// Save the auth object to the client, for use by other methods.
|
||||
this.auth = gaxGrpc.auth;
|
||||
// Set the default scopes in auth client if needed.
|
||||
if (servicePath === staticMembers.servicePath) {
|
||||
this.auth.defaultScopes = staticMembers.scopes;
|
||||
}
|
||||
// Determine the client header string.
|
||||
const clientHeader = [`gax/${version}`, `gapic/${version}`];
|
||||
if (typeof process !== 'undefined' && 'versions' in process) {
|
||||
clientHeader.push(`gl-node/${process.versions.node}`);
|
||||
}
|
||||
else {
|
||||
clientHeader.push(`gl-web/${version}`);
|
||||
}
|
||||
if (!opts.fallback) {
|
||||
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
|
||||
}
|
||||
else if (opts.fallback === 'rest') {
|
||||
clientHeader.push(`rest/${gaxGrpc.grpcVersion}`);
|
||||
}
|
||||
if (opts.libName && opts.libVersion) {
|
||||
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
|
||||
}
|
||||
// Load the applicable protos.
|
||||
this._protos = gaxGrpc.loadProtoJSON(jsonProtos);
|
||||
// Some of the methods on this service return "paged" results,
|
||||
// (e.g. 50 results at a time, with tokens to get subsequent
|
||||
// pages). Denote the keys used for pagination and results.
|
||||
this.descriptors.page = {
|
||||
listLocations: new pageDescriptor_1.PageDescriptor('pageToken', 'nextPageToken', 'locations'),
|
||||
};
|
||||
// Put together the default options sent with requests.
|
||||
this._defaults = gaxGrpc.constructSettings('google.cloud.location.Locations', gapicConfig, opts.clientConfig || {}, { 'x-goog-api-client': clientHeader.join(' ') });
|
||||
// Set up a dictionary of "inner API calls"; the core implementation
|
||||
// of calling the API is handled in `google-gax`, with this code
|
||||
// merely providing the destination and request information.
|
||||
this.innerApiCalls = {};
|
||||
// Add a warn function to the client constructor so it can be easily tested.
|
||||
this.warn = warnings_1.warn;
|
||||
}
|
||||
/**
|
||||
* Initialize the client.
|
||||
* Performs asynchronous operations (such as authentication) and prepares the client.
|
||||
* This function will be called automatically when any class method is called for the
|
||||
* first time, but if you need to initialize it before calling an actual method,
|
||||
* feel free to call initialize() directly.
|
||||
*
|
||||
* You can await on this method if you want to make sure the client is initialized.
|
||||
*
|
||||
* @returns {Promise} A promise that resolves to an authenticated service stub.
|
||||
*/
|
||||
initialize() {
|
||||
// If the client stub promise is already initialized, return immediately.
|
||||
if (this.locationsStub) {
|
||||
return this.locationsStub;
|
||||
}
|
||||
// Put together the "service stub" for
|
||||
// google.cloud.location.Locations.
|
||||
this.locationsStub = this.gaxGrpc.createStub(this._opts.fallback
|
||||
? this._protos.lookupService('google.cloud.location.Locations')
|
||||
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this._protos.google.cloud.location.Locations, this._opts, this._providedCustomServicePath);
|
||||
// Iterate over each of the methods that the service provides
|
||||
// and create an API call method for each.
|
||||
const locationsStubMethods = ['listLocations', 'getLocation'];
|
||||
for (const methodName of locationsStubMethods) {
|
||||
const callPromise = this.locationsStub.then(stub => (...args) => {
|
||||
if (this._terminated) {
|
||||
return Promise.reject('The client has already been closed.');
|
||||
}
|
||||
const func = stub[methodName];
|
||||
return func.apply(stub, args);
|
||||
}, (err) => () => {
|
||||
throw err;
|
||||
});
|
||||
const descriptor = this.descriptors.page[methodName] || undefined;
|
||||
const apiCall = (0, createApiCall_1.createApiCall)(callPromise, this._defaults[methodName], descriptor);
|
||||
this.innerApiCalls[methodName] = apiCall;
|
||||
}
|
||||
return this.locationsStub;
|
||||
}
|
||||
/**
|
||||
* The DNS address for this API service.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
static get servicePath() {
|
||||
return 'cloud.googleapis.com';
|
||||
}
|
||||
/**
|
||||
* The DNS address for this API service - same as servicePath(),
|
||||
* exists for compatibility reasons.
|
||||
* @returns {string} The DNS address for this service.
|
||||
*/
|
||||
static get apiEndpoint() {
|
||||
return 'cloud.googleapis.com';
|
||||
}
|
||||
/**
|
||||
* The port for this API service.
|
||||
* @returns {number} The default port for this service.
|
||||
*/
|
||||
static get port() {
|
||||
return 443;
|
||||
}
|
||||
/**
|
||||
* The scopes needed to make gRPC calls for every method defined
|
||||
* in this service.
|
||||
* @returns {string[]} List of default scopes.
|
||||
*/
|
||||
static get scopes() {
|
||||
return ['https://www.googleapis.com/auth/cloud-platform'];
|
||||
}
|
||||
getProjectId(callback) {
|
||||
if (callback) {
|
||||
this.auth.getProjectId(callback);
|
||||
return;
|
||||
}
|
||||
return this.auth.getProjectId();
|
||||
}
|
||||
/**
|
||||
* Gets information about a location.
|
||||
*
|
||||
* @param {Object} request
|
||||
* The request object that will be sent.
|
||||
* @param {string} request.name
|
||||
* Resource name for the location.
|
||||
* @param {object} [options]
|
||||
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
||||
* @returns {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is an object representing [Location]{@link google.cloud.location.Location}.
|
||||
* Please see the
|
||||
* [documentation](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#regular-methods)
|
||||
* for more details and examples.
|
||||
* @example
|
||||
* const [response] = await client.getLocation(request);
|
||||
*/
|
||||
getLocation(request, optionsOrCallback, callback) {
|
||||
request = request || {};
|
||||
let options;
|
||||
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
name: request.name || '',
|
||||
});
|
||||
this.initialize();
|
||||
return this.innerApiCalls.getLocation(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Lists information about the supported locations for this service.
|
||||
*
|
||||
* @param {Object} request
|
||||
* The request object that will be sent.
|
||||
* @param {string} request.name
|
||||
* The resource that owns the locations collection, if applicable.
|
||||
* @param {string} request.filter
|
||||
* The standard list filter.
|
||||
* @param {number} request.pageSize
|
||||
* The standard list page size.
|
||||
* @param {string} request.pageToken
|
||||
* The standard list page token.
|
||||
* @param {object} [options]
|
||||
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
||||
* @returns {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is Array of [Location]{@link google.cloud.location.Location}.
|
||||
* The client library will perform auto-pagination by default: it will call the API as many
|
||||
* times as needed and will merge results from all the pages into this array.
|
||||
* Note that it can affect your quota.
|
||||
* We recommend using `listLocationsAsync()`
|
||||
* method described below for async iteration which you can stop as needed.
|
||||
* Please see the
|
||||
* [documentation](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#auto-pagination)
|
||||
* for more details and examples.
|
||||
*/
|
||||
listLocations(request, optionsOrCallback, callback) {
|
||||
request = request || {};
|
||||
let options;
|
||||
if (typeof optionsOrCallback === 'function' && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
name: request.name || '',
|
||||
});
|
||||
this.initialize();
|
||||
return this.innerApiCalls.listLocations(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Equivalent to `listLocations`, but returns an iterable object.
|
||||
*
|
||||
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
|
||||
* @param {Object} request
|
||||
* The request object that will be sent.
|
||||
* @param {string} request.name
|
||||
* The resource that owns the locations collection, if applicable.
|
||||
* @param {string} request.filter
|
||||
* The standard list filter.
|
||||
* @param {number} request.pageSize
|
||||
* The standard list page size.
|
||||
* @param {string} request.pageToken
|
||||
* The standard list page token.
|
||||
* @param {object} [options]
|
||||
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
|
||||
* @returns {Object}
|
||||
* An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
|
||||
* When you iterate the returned iterable, each element will be an object representing
|
||||
* [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page,
|
||||
* so you can stop the iteration when you don't need more results.
|
||||
* Please see the
|
||||
* [documentation](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#auto-pagination)
|
||||
* for more details and examples.
|
||||
* @example
|
||||
* const iterable = client.listLocationsAsync(request);
|
||||
* for await (const response of iterable) {
|
||||
* // process response
|
||||
* }
|
||||
*/
|
||||
listLocationsAsync(request, options) {
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
options.otherArgs = options.otherArgs || {};
|
||||
options.otherArgs.headers = options.otherArgs.headers || {};
|
||||
options.otherArgs.headers['x-goog-request-params'] =
|
||||
routingHeader.fromParams({
|
||||
name: request.name || '',
|
||||
});
|
||||
options = options || {};
|
||||
const callSettings = new gax.CallSettings(options);
|
||||
this.initialize();
|
||||
return this.descriptors.page.listLocations.asyncIterate(this.innerApiCalls['listLocations'], request, callSettings);
|
||||
}
|
||||
/**
|
||||
* Terminate the gRPC channel and close the client.
|
||||
*
|
||||
* The client will no longer be usable and all future behavior is undefined.
|
||||
* @returns {Promise} A promise that resolves when the client is closed.
|
||||
*/
|
||||
close() {
|
||||
this.initialize();
|
||||
if (!this._terminated) {
|
||||
return this.locationsStub.then(stub => {
|
||||
this._terminated = true;
|
||||
stub.close();
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
exports.LocationsClient = LocationsClient;
|
||||
//# sourceMappingURL=locationService.js.map
|
||||
1
functions/node_modules/google-gax/build/src/locationService.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/locationService.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
35
functions/node_modules/google-gax/build/src/locations_client_config.json
generated
vendored
Normal file
35
functions/node_modules/google-gax/build/src/locations_client_config.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"interfaces": {
|
||||
"google.cloud.location.Locations": {
|
||||
"retry_codes": {
|
||||
"non_idempotent": [],
|
||||
"idempotent": [
|
||||
"DEADLINE_EXCEEDED",
|
||||
"UNAVAILABLE"
|
||||
]
|
||||
},
|
||||
"retry_params": {
|
||||
"default": {
|
||||
"initial_retry_delay_millis": 100,
|
||||
"retry_delay_multiplier": 1.3,
|
||||
"max_retry_delay_millis": 60000,
|
||||
"initial_rpc_timeout_millis": 60000,
|
||||
"rpc_timeout_multiplier": 1,
|
||||
"max_rpc_timeout_millis": 60000,
|
||||
"total_timeout_millis": 600000
|
||||
}
|
||||
},
|
||||
"methods": {
|
||||
"ListLocations": {
|
||||
"retry_codes_name": "non_idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"GetLocation": {
|
||||
"retry_codes_name": "non_idempotent",
|
||||
"retry_params_name": "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.d.ts
generated
vendored
Normal file
40
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
|
||||
import { OngoingCall, OngoingCallPromise } from '../call';
|
||||
import { CallOptions } from '../gax';
|
||||
import { GoogleError } from '../googleError';
|
||||
import { LongRunningDescriptor } from './longRunningDescriptor';
|
||||
export declare class LongrunningApiCaller implements APICaller {
|
||||
longrunningDescriptor: LongRunningDescriptor;
|
||||
/**
|
||||
* Creates an API caller that performs polling on a long running operation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - Holds the
|
||||
* decoders used for unpacking responses and the operationsClient
|
||||
* used for polling the operation.
|
||||
*/
|
||||
constructor(longrunningDescriptor: LongRunningDescriptor);
|
||||
init(callback?: APICallback): OngoingCallPromise | OngoingCall;
|
||||
wrap(func: GRPCCall): GRPCCall;
|
||||
call(apiCall: SimpleCallbackFunction, argument: {}, settings: CallOptions, canceller: OngoingCallPromise): void;
|
||||
private _wrapOperation;
|
||||
fail(canceller: OngoingCallPromise, err: GoogleError): void;
|
||||
result(canceller: OngoingCallPromise): import("../call").CancellablePromise<import("../apitypes").ResultTuple>;
|
||||
}
|
||||
72
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js
generated
vendored
Normal file
72
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LongrunningApiCaller = void 0;
|
||||
const call_1 = require("../call");
|
||||
const gax_1 = require("../gax");
|
||||
const longrunning_1 = require("./longrunning");
|
||||
class LongrunningApiCaller {
|
||||
/**
|
||||
* Creates an API caller that performs polling on a long running operation.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - Holds the
|
||||
* decoders used for unpacking responses and the operationsClient
|
||||
* used for polling the operation.
|
||||
*/
|
||||
constructor(longrunningDescriptor) {
|
||||
this.longrunningDescriptor = longrunningDescriptor;
|
||||
}
|
||||
init(callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise();
|
||||
}
|
||||
wrap(func) {
|
||||
return func;
|
||||
}
|
||||
call(apiCall, argument, settings, canceller) {
|
||||
canceller.call((argument, callback) => {
|
||||
return this._wrapOperation(apiCall, settings, argument, callback);
|
||||
}, argument);
|
||||
}
|
||||
_wrapOperation(apiCall, settings, argument, callback) {
|
||||
let backoffSettings = settings.longrunning;
|
||||
if (!backoffSettings) {
|
||||
backoffSettings = (0, gax_1.createDefaultBackoffSettings)();
|
||||
}
|
||||
const longrunningDescriptor = this.longrunningDescriptor;
|
||||
return apiCall(argument, (err, rawResponse) => {
|
||||
if (err) {
|
||||
callback(err, null, null, rawResponse);
|
||||
return;
|
||||
}
|
||||
const operation = new longrunning_1.Operation(rawResponse, longrunningDescriptor, backoffSettings, settings);
|
||||
callback(null, operation, rawResponse);
|
||||
});
|
||||
}
|
||||
fail(canceller, err) {
|
||||
canceller.callback(err);
|
||||
}
|
||||
result(canceller) {
|
||||
return canceller.promise;
|
||||
}
|
||||
}
|
||||
exports.LongrunningApiCaller = LongrunningApiCaller;
|
||||
//# sourceMappingURL=longRunningApiCaller.js.map
|
||||
1
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"longRunningApiCaller.js","sourceRoot":"","sources":["../../../src/longRunningCalls/longRunningApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,kCAAwD;AACxD,gCAIgB;AAGhB,+CAAwC;AAIxC,MAAa,oBAAoB;IAE/B;;;;;;;;OAQG;IACH,YAAY,qBAA4C;QACtD,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,QAAsB;QACzB,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,yBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACF,OAA+B,EAC/B,QAAY,EACZ,QAAqB,EACrB,SAA6B;QAE7B,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACpC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpE,CAAC,EAAE,QAAQ,CAAC,CAAC;IACf,CAAC;IAEO,cAAc,CACpB,OAA+B,EAC/B,QAAqB,EACrB,QAAY,EACZ,QAAqB;QAErB,IAAI,eAAe,GAAgC,QAAQ,CAAC,WAAW,CAAC;QACxE,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,eAAe,GAAG,IAAA,kCAA4B,GAAE,CAAC;QACnD,CAAC;QAED,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACzD,OAAO,OAAO,CACZ,QAAQ,EACR,CAAC,GAAuB,EAAE,WAAkC,EAAE,EAAE;YAC9D,IAAI,GAAG,EAAE,CAAC;gBACR,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAwB,CAAC,CAAC;gBACpD,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,IAAI,uBAAS,CAC7B,WAA2D,EAC3D,qBAAqB,EACrB,eAAgB,EAChB,QAAQ,CACT,CAAC;YAEF,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC,CACF,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AA5ED,oDA4EC"}
|
||||
35
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.d.ts
generated
vendored
Normal file
35
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as protobuf from 'protobufjs';
|
||||
import { Descriptor } from '../descriptor';
|
||||
import { OperationsClient } from '../operationsClient';
|
||||
import { LongrunningApiCaller } from './longRunningApiCaller';
|
||||
/**
|
||||
* A callback to upack a google.protobuf.Any message.
|
||||
*/
|
||||
export interface AnyDecoder {
|
||||
(reader: protobuf.Reader | Uint8Array, length?: number): protobuf.Message<{}>;
|
||||
}
|
||||
/**
|
||||
* A descriptor for long-running operations.
|
||||
*/
|
||||
export declare class LongRunningDescriptor implements Descriptor {
|
||||
operationsClient: OperationsClient;
|
||||
responseDecoder: AnyDecoder;
|
||||
metadataDecoder: AnyDecoder;
|
||||
constructor(operationsClient: OperationsClient, responseDecoder: AnyDecoder, metadataDecoder: AnyDecoder);
|
||||
getApiCaller(): LongrunningApiCaller;
|
||||
}
|
||||
34
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js
generated
vendored
Normal file
34
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LongRunningDescriptor = void 0;
|
||||
const longRunningApiCaller_1 = require("./longRunningApiCaller");
|
||||
/**
|
||||
* A descriptor for long-running operations.
|
||||
*/
|
||||
class LongRunningDescriptor {
|
||||
constructor(operationsClient, responseDecoder, metadataDecoder) {
|
||||
this.operationsClient = operationsClient;
|
||||
this.responseDecoder = responseDecoder;
|
||||
this.metadataDecoder = metadataDecoder;
|
||||
}
|
||||
getApiCaller() {
|
||||
return new longRunningApiCaller_1.LongrunningApiCaller(this);
|
||||
}
|
||||
}
|
||||
exports.LongRunningDescriptor = LongRunningDescriptor;
|
||||
//# sourceMappingURL=longRunningDescriptor.js.map
|
||||
1
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"longRunningDescriptor.js","sourceRoot":"","sources":["../../../src/longRunningCalls/longRunningDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,iEAA4D;AAS5D;;GAEG;AACH,MAAa,qBAAqB;IAKhC,YACE,gBAAkC,EAClC,eAA2B,EAC3B,eAA2B;QAE3B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,YAAY;QACV,OAAO,IAAI,2CAAoB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAlBD,sDAkBC"}
|
||||
132
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.d.ts
generated
vendored
Normal file
132
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.d.ts
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { EventEmitter } from 'events';
|
||||
import { ResultTuple } from '../apitypes';
|
||||
import { CancellablePromise } from '../call';
|
||||
import { BackoffSettings, CallOptions } from '../gax';
|
||||
import { GoogleError } from '../googleError';
|
||||
import { Metadata } from '../grpc';
|
||||
import { LongRunningDescriptor } from './longRunningDescriptor';
|
||||
import * as operationProtos from '../../protos/operations';
|
||||
/**
|
||||
* @callback GetOperationCallback
|
||||
* @param {?Error} error
|
||||
* @param {?Object} result
|
||||
* @param {?Object} metadata
|
||||
* @param {?google.longrunning.Operation} rawResponse
|
||||
*/
|
||||
export interface GetOperationCallback {
|
||||
(err?: Error | null, result?: {}, metadata?: {}, rawResponse?: LROOperation): void;
|
||||
}
|
||||
type LROOperation = operationProtos.google.longrunning.Operation;
|
||||
export declare class Operation extends EventEmitter {
|
||||
completeListeners: number;
|
||||
hasActiveListeners: boolean;
|
||||
latestResponse: LROOperation;
|
||||
longrunningDescriptor: LongRunningDescriptor;
|
||||
result: {} | null;
|
||||
metadata: Metadata | null;
|
||||
backoffSettings: BackoffSettings;
|
||||
_callOptions?: CallOptions;
|
||||
currentCallPromise_?: CancellablePromise<ResultTuple>;
|
||||
name?: string;
|
||||
done?: boolean;
|
||||
error?: GoogleError;
|
||||
response?: {};
|
||||
/**
|
||||
* Wrapper for a google.longrunnung.Operation.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - This defines the
|
||||
* operations service client and unpacking mechanisms for the operation.
|
||||
* @param {BackoffSettings} backoffSettings - The backoff settings used in
|
||||
* in polling the operation.
|
||||
* @param {CallOptions} callOptions - CallOptions used in making get operation
|
||||
* requests.
|
||||
*/
|
||||
constructor(grpcOp: LROOperation, longrunningDescriptor: LongRunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions);
|
||||
/**
|
||||
* Begin listening for events on the operation. This method keeps track of how
|
||||
* many "complete" listeners are registered and removed, making sure polling
|
||||
* is handled automatically.
|
||||
*
|
||||
* As long as there is one active "complete" listener, the connection is open.
|
||||
* When there are no more listeners, the polling stops.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_listenForEvents(): void;
|
||||
/**
|
||||
* Cancels current polling api call and cancels the operation.
|
||||
*
|
||||
* @return {Promise} the promise of the OperationsClient#cancelOperation api
|
||||
* request.
|
||||
*/
|
||||
cancel(): Promise<operationProtos.google.protobuf.Empty>;
|
||||
/**
|
||||
* Get the updated status of the operation. If the Operation has previously
|
||||
* completed, this will use the status of the cached completed operation.
|
||||
*
|
||||
* - callback(err): Operation failed
|
||||
* - callback(null, result, metadata, rawResponse): Operation complete
|
||||
* - callback(null, null, metadata, rawResponse): Operation incomplete
|
||||
*
|
||||
* @param {getOperationCallback} callback - Callback to handle the polled
|
||||
* operation result and metadata.
|
||||
* @return {Promise|undefined} - This returns a promise if a callback is not specified.
|
||||
* The promise resolves to an array where the first element is the unpacked
|
||||
* result, the second element is the metadata, and the third element is the
|
||||
* raw response of the api call. The promise rejects if the operation returns
|
||||
* an error.
|
||||
*/
|
||||
getOperation(): Promise<{}>;
|
||||
getOperation(callback: GetOperationCallback): void;
|
||||
_unpackResponse(op: LROOperation, callback?: GetOperationCallback): void;
|
||||
/**
|
||||
* Poll `getOperation` to check the operation's status. This runs a loop to
|
||||
* ping using the backoff strategy specified at initialization.
|
||||
*
|
||||
* Note: This method is automatically called once a "complete" event handler
|
||||
* is registered on the operation.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
startPolling_(): void;
|
||||
/**
|
||||
* Wraps the `complete` and `error` events in a Promise.
|
||||
*
|
||||
* @return {promise} - Promise that resolves on operation completion and rejects
|
||||
* on operation error.
|
||||
*/
|
||||
promise(): Promise<unknown>;
|
||||
}
|
||||
/**
|
||||
* Method used to create Operation objects.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {google.longrunning.Operation} op - The operation to be wrapped.
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - This defines the
|
||||
* operations service client and unpacking mechanisms for the operation.
|
||||
* @param {BackoffSettings} backoffSettings - The backoff settings used in
|
||||
* in polling the operation.
|
||||
* @param {CallOptions=} callOptions - CallOptions used in making get operation
|
||||
* requests.
|
||||
*/
|
||||
export declare function operation(op: LROOperation, longrunningDescriptor: LongRunningDescriptor, backoffSettings: BackoffSettings, callOptions?: CallOptions): Operation;
|
||||
export {};
|
||||
280
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.js
generated
vendored
Normal file
280
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.js
generated
vendored
Normal file
@@ -0,0 +1,280 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Operation = void 0;
|
||||
exports.operation = operation;
|
||||
const events_1 = require("events");
|
||||
const status_1 = require("../status");
|
||||
const googleError_1 = require("../googleError");
|
||||
const operationProtos = require("../../protos/operations");
|
||||
class Operation extends events_1.EventEmitter {
|
||||
/**
|
||||
* Wrapper for a google.longrunnung.Operation.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {google.longrunning.Operation} grpcOp - The operation to be wrapped.
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - This defines the
|
||||
* operations service client and unpacking mechanisms for the operation.
|
||||
* @param {BackoffSettings} backoffSettings - The backoff settings used in
|
||||
* in polling the operation.
|
||||
* @param {CallOptions} callOptions - CallOptions used in making get operation
|
||||
* requests.
|
||||
*/
|
||||
constructor(grpcOp, longrunningDescriptor, backoffSettings, callOptions) {
|
||||
super();
|
||||
this.completeListeners = 0;
|
||||
this.hasActiveListeners = false;
|
||||
this.latestResponse = grpcOp;
|
||||
this.name = this.latestResponse.name;
|
||||
this.done = this.latestResponse.done;
|
||||
this.error = this.latestResponse.error;
|
||||
this.longrunningDescriptor = longrunningDescriptor;
|
||||
this.result = null;
|
||||
this.metadata = null;
|
||||
this.backoffSettings = backoffSettings;
|
||||
this._unpackResponse(grpcOp);
|
||||
this._listenForEvents();
|
||||
this._callOptions = callOptions;
|
||||
}
|
||||
/**
|
||||
* Begin listening for events on the operation. This method keeps track of how
|
||||
* many "complete" listeners are registered and removed, making sure polling
|
||||
* is handled automatically.
|
||||
*
|
||||
* As long as there is one active "complete" listener, the connection is open.
|
||||
* When there are no more listeners, the polling stops.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_listenForEvents() {
|
||||
this.on('newListener', event => {
|
||||
if (event === 'complete') {
|
||||
this.completeListeners++;
|
||||
if (!this.hasActiveListeners) {
|
||||
this.hasActiveListeners = true;
|
||||
this.startPolling_();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.on('removeListener', event => {
|
||||
if (event === 'complete' && --this.completeListeners === 0) {
|
||||
this.hasActiveListeners = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Cancels current polling api call and cancels the operation.
|
||||
*
|
||||
* @return {Promise} the promise of the OperationsClient#cancelOperation api
|
||||
* request.
|
||||
*/
|
||||
cancel() {
|
||||
if (this.currentCallPromise_) {
|
||||
this.currentCallPromise_.cancel();
|
||||
}
|
||||
const operationsClient = this.longrunningDescriptor.operationsClient;
|
||||
const cancelRequest = new operationProtos.google.longrunning.CancelOperationRequest();
|
||||
cancelRequest.name = this.latestResponse.name;
|
||||
return operationsClient.cancelOperation(cancelRequest);
|
||||
}
|
||||
getOperation(callback) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
const operationsClient = this.longrunningDescriptor.operationsClient;
|
||||
function promisifyResponse() {
|
||||
if (!callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (self.latestResponse.error) {
|
||||
const error = new googleError_1.GoogleError(self.latestResponse.error.message);
|
||||
error.code = self.latestResponse.error.code;
|
||||
reject(error);
|
||||
}
|
||||
else {
|
||||
resolve([self.result, self.metadata, self.latestResponse]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.latestResponse.done) {
|
||||
this._unpackResponse(this.latestResponse, callback);
|
||||
return promisifyResponse();
|
||||
}
|
||||
const request = new operationProtos.google.longrunning.GetOperationRequest();
|
||||
request.name = this.latestResponse.name;
|
||||
this.currentCallPromise_ = operationsClient.getOperationInternal(request, this._callOptions);
|
||||
const noCallbackPromise = this.currentCallPromise_.then(responses => {
|
||||
self.latestResponse = responses[0];
|
||||
self._unpackResponse(responses[0], callback);
|
||||
return promisifyResponse();
|
||||
}, (err) => {
|
||||
if (callback) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
return Promise.reject(err);
|
||||
});
|
||||
if (!callback) {
|
||||
return noCallbackPromise;
|
||||
}
|
||||
}
|
||||
_unpackResponse(op, callback) {
|
||||
const responseDecoder = this.longrunningDescriptor.responseDecoder;
|
||||
const metadataDecoder = this.longrunningDescriptor.metadataDecoder;
|
||||
let response;
|
||||
let metadata;
|
||||
if (op.done) {
|
||||
if (op.result === 'error') {
|
||||
const error = new googleError_1.GoogleError(op.error.message);
|
||||
error.code = op.error.code;
|
||||
this.error = error;
|
||||
if (callback) {
|
||||
callback(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (responseDecoder && op.response) {
|
||||
this.response = op.response;
|
||||
response = responseDecoder(op.response.value);
|
||||
this.result = response;
|
||||
this.done = true;
|
||||
}
|
||||
}
|
||||
if (metadataDecoder && op.metadata) {
|
||||
metadata = metadataDecoder(op.metadata.value);
|
||||
this.metadata = metadata;
|
||||
}
|
||||
if (callback) {
|
||||
callback(null, response, metadata, op);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Poll `getOperation` to check the operation's status. This runs a loop to
|
||||
* ping using the backoff strategy specified at initialization.
|
||||
*
|
||||
* Note: This method is automatically called once a "complete" event handler
|
||||
* is registered on the operation.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
startPolling_() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
let now = new Date();
|
||||
const delayMult = this.backoffSettings.retryDelayMultiplier;
|
||||
const maxDelay = this.backoffSettings.maxRetryDelayMillis;
|
||||
let delay = this.backoffSettings.initialRetryDelayMillis;
|
||||
let deadline = Infinity;
|
||||
if (this.backoffSettings.totalTimeoutMillis) {
|
||||
deadline = now.getTime() + this.backoffSettings.totalTimeoutMillis;
|
||||
}
|
||||
let previousMetadataBytes;
|
||||
if (this.latestResponse.metadata) {
|
||||
previousMetadataBytes = this.latestResponse.metadata.value;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function emit(event, ...args) {
|
||||
self.emit(event, ...args);
|
||||
}
|
||||
// Helper function to replace nodejs buffer's equals()
|
||||
function arrayEquals(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < a.byteLength; ++i) {
|
||||
if (a[i] !== b[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function retry() {
|
||||
if (!self.hasActiveListeners) {
|
||||
return;
|
||||
}
|
||||
if (now.getTime() >= deadline) {
|
||||
const error = new googleError_1.GoogleError('Total timeout exceeded before any response was received');
|
||||
error.code = status_1.Status.DEADLINE_EXCEEDED;
|
||||
setImmediate(emit, 'error', error);
|
||||
return;
|
||||
}
|
||||
self.getOperation((err, result, metadata, rawResponse) => {
|
||||
if (err) {
|
||||
setImmediate(emit, 'error', err);
|
||||
return;
|
||||
}
|
||||
if (!result) {
|
||||
if (rawResponse.metadata &&
|
||||
(!previousMetadataBytes ||
|
||||
(rawResponse &&
|
||||
!arrayEquals(rawResponse.metadata.value, previousMetadataBytes)))) {
|
||||
setImmediate(emit, 'progress', metadata, rawResponse);
|
||||
previousMetadataBytes = rawResponse.metadata.value;
|
||||
}
|
||||
// special case: some APIs fail to set either result or error
|
||||
// but set done = true (e.g. speech with silent file).
|
||||
// Some APIs just use this for the normal completion
|
||||
// (e.g. nodejs-contact-center-insights), so let's just return
|
||||
// an empty response in this case.
|
||||
if (rawResponse.done) {
|
||||
setImmediate(emit, 'complete', {}, metadata, rawResponse);
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
now = new Date();
|
||||
delay = Math.min(delay * delayMult, maxDelay);
|
||||
retry();
|
||||
}, delay);
|
||||
return;
|
||||
}
|
||||
setImmediate(emit, 'complete', result, metadata, rawResponse);
|
||||
});
|
||||
}
|
||||
retry();
|
||||
}
|
||||
/**
|
||||
* Wraps the `complete` and `error` events in a Promise.
|
||||
*
|
||||
* @return {promise} - Promise that resolves on operation completion and rejects
|
||||
* on operation error.
|
||||
*/
|
||||
promise() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.on('error', reject).on('complete', (result, metadata, rawResponse) => {
|
||||
resolve([result, metadata, rawResponse]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Operation = Operation;
|
||||
/**
|
||||
* Method used to create Operation objects.
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @param {google.longrunning.Operation} op - The operation to be wrapped.
|
||||
* @param {LongRunningDescriptor} longrunningDescriptor - This defines the
|
||||
* operations service client and unpacking mechanisms for the operation.
|
||||
* @param {BackoffSettings} backoffSettings - The backoff settings used in
|
||||
* in polling the operation.
|
||||
* @param {CallOptions=} callOptions - CallOptions used in making get operation
|
||||
* requests.
|
||||
*/
|
||||
function operation(op, longrunningDescriptor, backoffSettings, callOptions) {
|
||||
return new Operation(op, longrunningDescriptor, backoffSettings, callOptions);
|
||||
}
|
||||
//# sourceMappingURL=longrunning.js.map
|
||||
1
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/longRunningCalls/longrunning.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
29
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.d.ts
generated
vendored
Normal file
29
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
|
||||
import { OngoingCall, OngoingCallPromise } from '../call';
|
||||
import { GoogleError } from '../googleError';
|
||||
/**
|
||||
* Creates an API caller for regular unary methods.
|
||||
*/
|
||||
export declare class NormalApiCaller implements APICaller {
|
||||
init(callback?: APICallback): OngoingCallPromise | OngoingCall;
|
||||
wrap(func: GRPCCall): GRPCCall;
|
||||
call(apiCall: SimpleCallbackFunction, argument: {}, settings: {}, canceller: OngoingCallPromise): void;
|
||||
fail(canceller: OngoingCallPromise, err: GoogleError): void;
|
||||
result(canceller: OngoingCallPromise): import("../call").CancellablePromise<import("../apitypes").ResultTuple>;
|
||||
}
|
||||
44
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js
generated
vendored
Normal file
44
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NormalApiCaller = void 0;
|
||||
const call_1 = require("../call");
|
||||
/**
|
||||
* Creates an API caller for regular unary methods.
|
||||
*/
|
||||
class NormalApiCaller {
|
||||
init(callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise();
|
||||
}
|
||||
wrap(func) {
|
||||
return func;
|
||||
}
|
||||
call(apiCall, argument, settings, canceller) {
|
||||
canceller.call(apiCall, argument);
|
||||
}
|
||||
fail(canceller, err) {
|
||||
canceller.callback(err);
|
||||
}
|
||||
result(canceller) {
|
||||
return canceller.promise;
|
||||
}
|
||||
}
|
||||
exports.NormalApiCaller = NormalApiCaller;
|
||||
//# sourceMappingURL=normalApiCaller.js.map
|
||||
1
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/normalCalls/normalApiCaller.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"normalApiCaller.js","sourceRoot":"","sources":["../../../src/normalCalls/normalApiCaller.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,kCAAwD;AAGxD;;GAEG;AACH,MAAa,eAAe;IAC1B,IAAI,CAAC,QAAsB;QACzB,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,yBAAkB,EAAE,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,IAAc;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACF,OAA+B,EAC/B,QAAY,EACZ,QAAY,EACZ,SAA6B;QAE7B,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,SAA6B,EAAE,GAAgB;QAClD,SAAS,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,SAA6B;QAClC,OAAO,SAAS,CAAC,OAAO,CAAC;IAC3B,CAAC;CACF;AA5BD,0CA4BC"}
|
||||
31
functions/node_modules/google-gax/build/src/normalCalls/retries.d.ts
generated
vendored
Normal file
31
functions/node_modules/google-gax/build/src/normalCalls/retries.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { GRPCCall, GRPCCallOtherArgs, SimpleCallbackFunction } from '../apitypes';
|
||||
import { RetryOptions } from '../gax';
|
||||
/**
|
||||
* Creates a function equivalent to func, but that retries on certain
|
||||
* exceptions.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {GRPCCall} func - A function.
|
||||
* @param {RetryOptions} retry - Configures the exceptions upon which the
|
||||
* function eshould retry, and the parameters to the exponential backoff retry
|
||||
* algorithm.
|
||||
* @param {GRPCCallOtherArgs} otherArgs - the additional arguments to be passed to func.
|
||||
* @return {SimpleCallbackFunction} A function that will retry.
|
||||
*/
|
||||
export declare function retryable(func: GRPCCall, retry: RetryOptions, otherArgs: GRPCCallOtherArgs, apiName?: string): SimpleCallbackFunction;
|
||||
144
functions/node_modules/google-gax/build/src/normalCalls/retries.js
generated
vendored
Normal file
144
functions/node_modules/google-gax/build/src/normalCalls/retries.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.retryable = retryable;
|
||||
const status_1 = require("../status");
|
||||
const googleError_1 = require("../googleError");
|
||||
const timeout_1 = require("./timeout");
|
||||
/**
|
||||
* Creates a function equivalent to func, but that retries on certain
|
||||
* exceptions.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {GRPCCall} func - A function.
|
||||
* @param {RetryOptions} retry - Configures the exceptions upon which the
|
||||
* function eshould retry, and the parameters to the exponential backoff retry
|
||||
* algorithm.
|
||||
* @param {GRPCCallOtherArgs} otherArgs - the additional arguments to be passed to func.
|
||||
* @return {SimpleCallbackFunction} A function that will retry.
|
||||
*/
|
||||
function retryable(func, retry, otherArgs, apiName) {
|
||||
const delayMult = retry.backoffSettings.retryDelayMultiplier;
|
||||
const maxDelay = retry.backoffSettings.maxRetryDelayMillis;
|
||||
const timeoutMult = retry.backoffSettings.rpcTimeoutMultiplier;
|
||||
const maxTimeout = retry.backoffSettings.maxRpcTimeoutMillis;
|
||||
let delay = retry.backoffSettings.initialRetryDelayMillis;
|
||||
let timeout = retry.backoffSettings.initialRpcTimeoutMillis;
|
||||
/**
|
||||
* Equivalent to ``func``, but retries upon transient failure.
|
||||
*
|
||||
* Retrying is done through an exponential backoff algorithm configured
|
||||
* by the options in ``retry``.
|
||||
* @param {RequestType} argument The request object.
|
||||
* @param {APICallback} callback The callback.
|
||||
* @return {GRPCCall}
|
||||
*/
|
||||
return (argument, callback) => {
|
||||
let canceller;
|
||||
let timeoutId;
|
||||
let now = new Date();
|
||||
let deadline;
|
||||
if (retry.backoffSettings.totalTimeoutMillis) {
|
||||
deadline = now.getTime() + retry.backoffSettings.totalTimeoutMillis;
|
||||
}
|
||||
let retries = 0;
|
||||
const maxRetries = retry.backoffSettings.maxRetries;
|
||||
// TODO: define A/B testing values for retry behaviors.
|
||||
/** Repeat the API call as long as necessary. */
|
||||
function repeat(err) {
|
||||
timeoutId = null;
|
||||
if (deadline && now.getTime() >= deadline) {
|
||||
const error = new googleError_1.GoogleError(`Total timeout of API ${apiName} exceeded ${retry.backoffSettings.totalTimeoutMillis} milliseconds ${err ? `retrying error ${err} ` : ''} before any response was received.`);
|
||||
error.code = status_1.Status.DEADLINE_EXCEEDED;
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
if (retries && retries >= maxRetries) {
|
||||
const error = new googleError_1.GoogleError('Exceeded maximum number of retries ' +
|
||||
(err ? `retrying error ${err} ` : '') +
|
||||
'before any response was received');
|
||||
error.code = status_1.Status.DEADLINE_EXCEEDED;
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
retries++;
|
||||
let lastError = err;
|
||||
const toCall = (0, timeout_1.addTimeoutArg)(func, timeout, otherArgs);
|
||||
canceller = toCall(argument, (err, response, next, rawResponse) => {
|
||||
// Save only the error before deadline exceeded
|
||||
if (err && err.code !== 4) {
|
||||
lastError = err;
|
||||
}
|
||||
if (!err) {
|
||||
callback(null, response, next, rawResponse);
|
||||
return;
|
||||
}
|
||||
canceller = null;
|
||||
if (retry.retryCodes.length > 0 &&
|
||||
retry.retryCodes.indexOf(err.code) < 0) {
|
||||
err.note =
|
||||
'Exception occurred in retry method that was ' +
|
||||
'not classified as transient';
|
||||
callback(err);
|
||||
}
|
||||
else {
|
||||
const toSleep = Math.random() * delay;
|
||||
timeoutId = setTimeout(() => {
|
||||
now = new Date();
|
||||
delay = Math.min(delay * delayMult, maxDelay);
|
||||
const timeoutCal = timeout && timeoutMult ? timeout * timeoutMult : 0;
|
||||
const rpcTimeout = maxTimeout ? maxTimeout : 0;
|
||||
const newDeadline = deadline ? deadline - now.getTime() : 0;
|
||||
timeout = Math.min(timeoutCal, rpcTimeout, newDeadline);
|
||||
repeat(lastError);
|
||||
}, toSleep);
|
||||
}
|
||||
});
|
||||
if (canceller instanceof Promise) {
|
||||
canceller.catch(err => {
|
||||
callback(new googleError_1.GoogleError(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
if (maxRetries && deadline) {
|
||||
const error = new googleError_1.GoogleError('Cannot set both totalTimeoutMillis and maxRetries ' +
|
||||
'in backoffSettings.');
|
||||
error.code = status_1.Status.INVALID_ARGUMENT;
|
||||
callback(error);
|
||||
}
|
||||
else {
|
||||
repeat();
|
||||
}
|
||||
return {
|
||||
cancel() {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
if (canceller) {
|
||||
canceller.cancel();
|
||||
}
|
||||
else {
|
||||
const error = new googleError_1.GoogleError('cancelled');
|
||||
error.code = status_1.Status.CANCELLED;
|
||||
callback(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=retries.js.map
|
||||
1
functions/node_modules/google-gax/build/src/normalCalls/retries.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/normalCalls/retries.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"retries.js","sourceRoot":"","sources":["../../../src/normalCalls/retries.ts"],"names":[],"mappings":"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"}
|
||||
32
functions/node_modules/google-gax/build/src/normalCalls/timeout.d.ts
generated
vendored
Normal file
32
functions/node_modules/google-gax/build/src/normalCalls/timeout.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { GRPCCall, GRPCCallOtherArgs, SimpleCallbackFunction } from '../apitypes';
|
||||
/**
|
||||
* Updates func so that it gets called with the timeout as its final arg.
|
||||
*
|
||||
* This converts a function, func, into another function with updated deadline.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {GRPCCall} func - a function to be updated.
|
||||
* @param {number} timeout - to be added to the original function as it final
|
||||
* positional arg.
|
||||
* @param {Object} otherArgs - the additional arguments to be passed to func.
|
||||
* @param {Object=} abTests - the A/B testing key/value pairs.
|
||||
* @return {function(Object, APICallback)}
|
||||
* the function with other arguments and the timeout.
|
||||
*/
|
||||
export declare function addTimeoutArg(func: GRPCCall, timeout: number, otherArgs: GRPCCallOtherArgs, abTests?: {}): SimpleCallbackFunction;
|
||||
47
functions/node_modules/google-gax/build/src/normalCalls/timeout.js
generated
vendored
Normal file
47
functions/node_modules/google-gax/build/src/normalCalls/timeout.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addTimeoutArg = addTimeoutArg;
|
||||
/**
|
||||
* Updates func so that it gets called with the timeout as its final arg.
|
||||
*
|
||||
* This converts a function, func, into another function with updated deadline.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {GRPCCall} func - a function to be updated.
|
||||
* @param {number} timeout - to be added to the original function as it final
|
||||
* positional arg.
|
||||
* @param {Object} otherArgs - the additional arguments to be passed to func.
|
||||
* @param {Object=} abTests - the A/B testing key/value pairs.
|
||||
* @return {function(Object, APICallback)}
|
||||
* the function with other arguments and the timeout.
|
||||
*/
|
||||
function addTimeoutArg(func, timeout, otherArgs, abTests) {
|
||||
// TODO: this assumes the other arguments consist of metadata and options,
|
||||
// which is specific to gRPC calls. Remove the hidden dependency on gRPC.
|
||||
return (argument, callback) => {
|
||||
const now = new Date();
|
||||
const options = otherArgs.options || {};
|
||||
options.deadline = new Date(now.getTime() + timeout);
|
||||
const metadata = otherArgs.metadataBuilder
|
||||
? otherArgs.metadataBuilder(abTests, otherArgs.headers || {})
|
||||
: null;
|
||||
return func(argument, metadata, options, callback);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=timeout.js.map
|
||||
1
functions/node_modules/google-gax/build/src/normalCalls/timeout.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/normalCalls/timeout.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../../src/normalCalls/timeout.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAwBH,sCAiBC;AAhCD;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CAC3B,IAAc,EACd,OAAe,EACf,SAA4B,EAC5B,OAAY;IAEZ,0EAA0E;IAC1E,yEAAyE;IACzE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;QAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAe;YACxC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC;YAC7D,CAAC,CAAC,IAAI,CAAC;QACT,OAAQ,IAAkB,CAAC,QAAQ,EAAE,QAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC"}
|
||||
315
functions/node_modules/google-gax/build/src/operationsClient.d.ts
generated
vendored
Normal file
315
functions/node_modules/google-gax/build/src/operationsClient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import type { GoogleAuth, OAuth2Client } from 'google-auth-library';
|
||||
import { ProjectIdCallback } from 'google-auth-library/build/src/auth/googleauth';
|
||||
import type { ClientOptions, Callback } from './clientInterface';
|
||||
import { ResultTuple } from './apitypes';
|
||||
import { PageDescriptor } from './descriptor';
|
||||
import * as gax from './gax';
|
||||
import type { GrpcClient } from './grpc';
|
||||
import type { GrpcClient as FallbackGrpcClient } from './fallback';
|
||||
import * as protos from '../protos/operations';
|
||||
import { Transform } from 'stream';
|
||||
import { CancellablePromise } from './call';
|
||||
export declare const SERVICE_ADDRESS = "longrunning.googleapis.com";
|
||||
/**
|
||||
* The scopes needed to make gRPC calls to all of the methods defined in
|
||||
* this service.
|
||||
*/
|
||||
export declare const ALL_SCOPES: string[];
|
||||
/**
|
||||
* Manages long-running operations with an API service.
|
||||
*
|
||||
* When an API method normally takes long time to complete, it can be designed
|
||||
* to return {@link Operation} to the client, and the client can use this
|
||||
* interface to receive the real response asynchronously by polling the
|
||||
* operation resource, or pass the operation resource to another API (such as
|
||||
* Google Cloud Pub/Sub API) to receive the response. Any API service that
|
||||
* returns long-running operations should implement the `Operations` interface
|
||||
* so developers can have a consistent client experience.
|
||||
*
|
||||
* This will be created through a builder function which can be obtained by the
|
||||
* module. See the following example of how to initialize the module and how to
|
||||
* access to the builder.
|
||||
* @see {@link operationsClient}
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
export declare class OperationsClient {
|
||||
auth?: GoogleAuth | OAuth2Client;
|
||||
innerApiCalls: {
|
||||
[name: string]: Function;
|
||||
};
|
||||
descriptor: {
|
||||
[method: string]: PageDescriptor;
|
||||
};
|
||||
operationsStub: Promise<{
|
||||
[method: string]: Function;
|
||||
}>;
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient, operationsProtos: any, options: ClientOptions);
|
||||
/** Closes this operations client. */
|
||||
close(): void;
|
||||
/**
|
||||
* Get the project ID used by this class.
|
||||
* @param {function(Error, string)} callback - the callback to be called with
|
||||
* the current project Id.
|
||||
*/
|
||||
getProjectId(): Promise<string>;
|
||||
getProjectId(callback: ProjectIdCallback): void;
|
||||
getOperationInternal(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): CancellablePromise<ResultTuple>;
|
||||
/**
|
||||
* Gets the latest state of a long-running operation. Clients can use this
|
||||
* method to poll the operation result at intervals as recommended by the API
|
||||
* service.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error, ?Object)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
*
|
||||
* The second parameter to the callback is an object representing
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
* @return {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is an object representing
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}. The promise has a method named
|
||||
* "cancel" which cancels the ongoing API call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const name = '';
|
||||
* const [response] = await client.getOperation({name});
|
||||
* // doThingsWith(response)
|
||||
*/
|
||||
getOperation(request: protos.google.longrunning.GetOperationRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;
|
||||
/**
|
||||
* Lists operations that match the specified filter in the request. If the
|
||||
* server doesn't support this method, it returns `UNIMPLEMENTED`.
|
||||
*
|
||||
* NOTE: the `name` binding below allows API services to override the binding
|
||||
* to use different resource name schemes.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error, ?Array, ?Object, ?Object)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
*
|
||||
* The second parameter to the callback is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
*
|
||||
* When autoPaginate: false is specified through options, it contains the
|
||||
* result in a single response. If the response indicates the next page
|
||||
* exists, the third parameter is set to be used for the next request object.
|
||||
* The fourth parameter keeps the raw response object of an object
|
||||
* representing [google.longrunning.ListOperationsResponse]{@link
|
||||
* external:"google.longrunning.ListOperationsResponse"}.
|
||||
* @return {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
*
|
||||
* When autoPaginate: false is specified through options, the array has
|
||||
* three elements. The first element is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"} in a single response. The second
|
||||
* element is the next request object if the response indicates the next page
|
||||
* exists, or null. The third element is an object representing
|
||||
* [google.longrunning.ListOperationsResponse]{@link
|
||||
* external:"google.longrunning.ListOperationsResponse"}.
|
||||
*
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const request = {
|
||||
* name: '',
|
||||
* filter: ''
|
||||
* };
|
||||
* // Iterate over all elements.
|
||||
* const [resources] = await client.listOperations(request);
|
||||
* for (const resource of resources) {
|
||||
* console.log(resources);
|
||||
* }
|
||||
*
|
||||
* // Or obtain the paged response.
|
||||
* const options = {autoPaginate: false};
|
||||
* let nextRequest = request;
|
||||
* while(nextRequest) {
|
||||
* const response = await client.listOperations(nextRequest, options);
|
||||
* const resources = response[0];
|
||||
* nextRequest = response[1];
|
||||
* const rawResponse = response[2];
|
||||
* for (const resource of resources) {
|
||||
* // doThingsWith(resource);
|
||||
* }
|
||||
* };
|
||||
*/
|
||||
listOperations(request: protos.google.longrunning.ListOperationsRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.longrunning.ListOperationsResponse, protos.google.longrunning.ListOperationsRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.ListOperationsResponse, protos.google.longrunning.ListOperationsRequest, {} | null | undefined>): Promise<protos.google.longrunning.ListOperationsResponse>;
|
||||
/**
|
||||
* Equivalent to {@link listOperations}, but returns a NodeJS Stream object.
|
||||
*
|
||||
* This fetches the paged responses for {@link listOperations} continuously
|
||||
* and invokes the callback registered for 'data' event for each element in
|
||||
* the responses.
|
||||
*
|
||||
* The returned object has 'end' method when no more elements are required.
|
||||
*
|
||||
* autoPaginate option will be ignored.
|
||||
*
|
||||
* @see {@link https://nodejs.org/api/stream.html}
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize -
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @return {Stream} - An object stream which emits an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"} on 'data' event.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const request = {
|
||||
* name: '',
|
||||
* filter: ''
|
||||
* };
|
||||
* client.listOperationsStream(request)
|
||||
* .on('data', element => {
|
||||
* // doThingsWith(element)
|
||||
* })
|
||||
* .on('error', err => {
|
||||
* console.error(err);
|
||||
* });
|
||||
*/
|
||||
listOperationsStream(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): Transform;
|
||||
/**
|
||||
* Equivalent to {@link listOperations}, but returns an iterable object.
|
||||
*
|
||||
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize -
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @returns {Object}
|
||||
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
|
||||
*/
|
||||
listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;
|
||||
/**
|
||||
* Starts asynchronous cancellation on a long-running operation. The server
|
||||
* makes a best effort to cancel the operation, but success is not
|
||||
* guaranteed. If the server doesn't support this method, it returns
|
||||
* `google.rpc.Code.UNIMPLEMENTED`. Clients can use
|
||||
* {@link Operations.GetOperation} or
|
||||
* other methods to check whether the cancellation succeeded or whether the
|
||||
* operation completed despite cancellation. On successful cancellation,
|
||||
* the operation is not deleted; instead, it becomes an operation with
|
||||
* an {@link Operation.error} value with a {@link google.rpc.Status.code} of
|
||||
* 1, corresponding to `Code.CANCELLED`.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource to be cancelled.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
* @return {Promise} - The promise which resolves when API call finishes.
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* await client.cancelOperation({name: ''});
|
||||
*/
|
||||
cancelOperation(request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;
|
||||
/**
|
||||
* Deletes a long-running operation. This method indicates that the client is
|
||||
* no longer interested in the operation result. It does not cancel the
|
||||
* operation. If the server doesn't support this method, it returns
|
||||
* `google.rpc.Code.UNIMPLEMENTED`.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource to be deleted.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
* @return {Promise} - The promise which resolves when API call finishes.
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* await client.deleteOperation({name: ''});
|
||||
*/
|
||||
deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;
|
||||
}
|
||||
export declare class OperationsClientBuilder {
|
||||
operationsClient: (opts: ClientOptions) => OperationsClient;
|
||||
/**
|
||||
* Builds a new Operations Client
|
||||
* @param gaxGrpc {GrpcClient}
|
||||
*/
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient, protoJson?: protobuf.Root);
|
||||
}
|
||||
445
functions/node_modules/google-gax/build/src/operationsClient.js
generated
vendored
Normal file
445
functions/node_modules/google-gax/build/src/operationsClient.js
generated
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OperationsClientBuilder = exports.OperationsClient = exports.ALL_SCOPES = exports.SERVICE_ADDRESS = void 0;
|
||||
const createApiCall_1 = require("./createApiCall");
|
||||
const descriptor_1 = require("./descriptor");
|
||||
const gax = require("./gax");
|
||||
const configData = require("./operations_client_config.json");
|
||||
const operationProtoJson = require("../protos/operations.json");
|
||||
const transcoding_1 = require("./transcoding");
|
||||
exports.SERVICE_ADDRESS = 'longrunning.googleapis.com';
|
||||
const version = require('../../package.json').version;
|
||||
const DEFAULT_SERVICE_PORT = 443;
|
||||
const CODE_GEN_NAME_VERSION = 'gapic/0.7.1';
|
||||
/**
|
||||
* The scopes needed to make gRPC calls to all of the methods defined in
|
||||
* this service.
|
||||
*/
|
||||
exports.ALL_SCOPES = [];
|
||||
/**
|
||||
* Manages long-running operations with an API service.
|
||||
*
|
||||
* When an API method normally takes long time to complete, it can be designed
|
||||
* to return {@link Operation} to the client, and the client can use this
|
||||
* interface to receive the real response asynchronously by polling the
|
||||
* operation resource, or pass the operation resource to another API (such as
|
||||
* Google Cloud Pub/Sub API) to receive the response. Any API service that
|
||||
* returns long-running operations should implement the `Operations` interface
|
||||
* so developers can have a consistent client experience.
|
||||
*
|
||||
* This will be created through a builder function which can be obtained by the
|
||||
* module. See the following example of how to initialize the module and how to
|
||||
* access to the builder.
|
||||
* @see {@link operationsClient}
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
class OperationsClient {
|
||||
constructor(gaxGrpc,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
operationsProtos, options) {
|
||||
const opts = Object.assign({
|
||||
servicePath: exports.SERVICE_ADDRESS,
|
||||
port: DEFAULT_SERVICE_PORT,
|
||||
clientConfig: {},
|
||||
}, options);
|
||||
const googleApiClient = ['gl-node/' + process.versions.node];
|
||||
if (opts.libName && opts.libVersion) {
|
||||
googleApiClient.push(opts.libName + '/' + opts.libVersion);
|
||||
}
|
||||
googleApiClient.push(CODE_GEN_NAME_VERSION, 'gax/' + version);
|
||||
if (opts.fallback) {
|
||||
googleApiClient.push('gl-web/' + version);
|
||||
}
|
||||
else {
|
||||
googleApiClient.push('grpc/' + gaxGrpc.grpcVersion);
|
||||
}
|
||||
const defaults = gaxGrpc.constructSettings('google.longrunning.Operations', configData, opts.clientConfig || {}, { 'x-goog-api-client': googleApiClient.join(' ') });
|
||||
this.auth = gaxGrpc.auth;
|
||||
// Set up a dictionary of "inner API calls"; the core implementation
|
||||
// of calling the API is handled in `google-gax`, with this code
|
||||
// merely providing the destination and request information.
|
||||
this.innerApiCalls = {};
|
||||
this.descriptor = {
|
||||
listOperations: new descriptor_1.PageDescriptor('pageToken', 'nextPageToken', 'operations'),
|
||||
};
|
||||
// Put together the "service stub" for
|
||||
// google.longrunning.Operations.
|
||||
this.operationsStub = gaxGrpc.createStub(opts.fallback
|
||||
? operationsProtos.lookupService('google.longrunning.Operations')
|
||||
: operationsProtos.google.longrunning.Operations, opts);
|
||||
const operationsStubMethods = [
|
||||
'getOperation',
|
||||
'listOperations',
|
||||
'cancelOperation',
|
||||
'deleteOperation',
|
||||
];
|
||||
for (const methodName of operationsStubMethods) {
|
||||
const innerCallPromise = this.operationsStub.then(stub => (...args) => {
|
||||
const func = stub[methodName];
|
||||
return func.apply(stub, args);
|
||||
}, err => () => {
|
||||
throw err;
|
||||
});
|
||||
this.innerApiCalls[methodName] = (0, createApiCall_1.createApiCall)(innerCallPromise, defaults[methodName], this.descriptor[methodName]);
|
||||
}
|
||||
}
|
||||
/** Closes this operations client. */
|
||||
close() {
|
||||
this.operationsStub.then(stub => stub.close());
|
||||
}
|
||||
getProjectId(callback) {
|
||||
if (this.auth && 'getProjectId' in this.auth) {
|
||||
return this.auth.getProjectId(callback);
|
||||
}
|
||||
if (callback) {
|
||||
callback(new Error('Cannot determine project ID.'));
|
||||
}
|
||||
else {
|
||||
return Promise.reject('Cannot determine project ID.');
|
||||
}
|
||||
}
|
||||
// Service calls
|
||||
getOperationInternal(request, options, callback) {
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
return this.innerApiCalls.getOperation(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Gets the latest state of a long-running operation. Clients can use this
|
||||
* method to poll the operation result at intervals as recommended by the API
|
||||
* service.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error, ?Object)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
*
|
||||
* The second parameter to the callback is an object representing
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
* @return {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is an object representing
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}. The promise has a method named
|
||||
* "cancel" which cancels the ongoing API call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const name = '';
|
||||
* const [response] = await client.getOperation({name});
|
||||
* // doThingsWith(response)
|
||||
*/
|
||||
getOperation(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
return this.innerApiCalls.getOperation(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Lists operations that match the specified filter in the request. If the
|
||||
* server doesn't support this method, it returns `UNIMPLEMENTED`.
|
||||
*
|
||||
* NOTE: the `name` binding below allows API services to override the binding
|
||||
* to use different resource name schemes.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error, ?Array, ?Object, ?Object)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
*
|
||||
* The second parameter to the callback is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
*
|
||||
* When autoPaginate: false is specified through options, it contains the
|
||||
* result in a single response. If the response indicates the next page
|
||||
* exists, the third parameter is set to be used for the next request object.
|
||||
* The fourth parameter keeps the raw response object of an object
|
||||
* representing [google.longrunning.ListOperationsResponse]{@link
|
||||
* external:"google.longrunning.ListOperationsResponse"}.
|
||||
* @return {Promise} - The promise which resolves to an array.
|
||||
* The first element of the array is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"}.
|
||||
*
|
||||
* When autoPaginate: false is specified through options, the array has
|
||||
* three elements. The first element is Array of
|
||||
* [google.longrunning.Operation]{@link
|
||||
* external:"google.longrunning.Operation"} in a single response. The second
|
||||
* element is the next request object if the response indicates the next page
|
||||
* exists, or null. The third element is an object representing
|
||||
* [google.longrunning.ListOperationsResponse]{@link
|
||||
* external:"google.longrunning.ListOperationsResponse"}.
|
||||
*
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const request = {
|
||||
* name: '',
|
||||
* filter: ''
|
||||
* };
|
||||
* // Iterate over all elements.
|
||||
* const [resources] = await client.listOperations(request);
|
||||
* for (const resource of resources) {
|
||||
* console.log(resources);
|
||||
* }
|
||||
*
|
||||
* // Or obtain the paged response.
|
||||
* const options = {autoPaginate: false};
|
||||
* let nextRequest = request;
|
||||
* while(nextRequest) {
|
||||
* const response = await client.listOperations(nextRequest, options);
|
||||
* const resources = response[0];
|
||||
* nextRequest = response[1];
|
||||
* const rawResponse = response[2];
|
||||
* for (const resource of resources) {
|
||||
* // doThingsWith(resource);
|
||||
* }
|
||||
* };
|
||||
*/
|
||||
listOperations(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
return this.innerApiCalls.listOperations(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Equivalent to {@link listOperations}, but returns a NodeJS Stream object.
|
||||
*
|
||||
* This fetches the paged responses for {@link listOperations} continuously
|
||||
* and invokes the callback registered for 'data' event for each element in
|
||||
* the responses.
|
||||
*
|
||||
* The returned object has 'end' method when no more elements are required.
|
||||
*
|
||||
* autoPaginate option will be ignored.
|
||||
*
|
||||
* @see {@link https://nodejs.org/api/stream.html}
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize -
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @return {Stream} - An object stream which emits an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"} on 'data' event.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* const request = {
|
||||
* name: '',
|
||||
* filter: ''
|
||||
* };
|
||||
* client.listOperationsStream(request)
|
||||
* .on('data', element => {
|
||||
* // doThingsWith(element)
|
||||
* })
|
||||
* .on('error', err => {
|
||||
* console.error(err);
|
||||
* });
|
||||
*/
|
||||
listOperationsStream(request, options) {
|
||||
const callSettings = new gax.CallSettings(options);
|
||||
return this.descriptor.listOperations.createStream(this.innerApiCalls.listOperations, request, callSettings);
|
||||
}
|
||||
/**
|
||||
* Equivalent to {@link listOperations}, but returns an iterable object.
|
||||
*
|
||||
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation collection.
|
||||
* @param {string} request.filter - The standard list filter.
|
||||
* @param {number=} request.pageSize -
|
||||
* The maximum number of resources contained in the underlying API
|
||||
* response. If page streaming is performed per-resource, this
|
||||
* parameter does not affect the return value. If page streaming is
|
||||
* performed per-page, this determines the maximum number of
|
||||
* resources in a page.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @returns {Object}
|
||||
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
|
||||
*/
|
||||
listOperationsAsync(request, options) {
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
const callSettings = new gax.CallSettings(options);
|
||||
return this.descriptor.listOperations.asyncIterate(this.innerApiCalls.listOperations, request, callSettings);
|
||||
}
|
||||
/**
|
||||
* Starts asynchronous cancellation on a long-running operation. The server
|
||||
* makes a best effort to cancel the operation, but success is not
|
||||
* guaranteed. If the server doesn't support this method, it returns
|
||||
* `google.rpc.Code.UNIMPLEMENTED`. Clients can use
|
||||
* {@link Operations.GetOperation} or
|
||||
* other methods to check whether the cancellation succeeded or whether the
|
||||
* operation completed despite cancellation. On successful cancellation,
|
||||
* the operation is not deleted; instead, it becomes an operation with
|
||||
* an {@link Operation.error} value with a {@link google.rpc.Status.code} of
|
||||
* 1, corresponding to `Code.CANCELLED`.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource to be cancelled.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
* @return {Promise} - The promise which resolves when API call finishes.
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* await client.cancelOperation({name: ''});
|
||||
*/
|
||||
cancelOperation(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
return this.innerApiCalls.cancelOperation(request, options, callback);
|
||||
}
|
||||
/**
|
||||
* Deletes a long-running operation. This method indicates that the client is
|
||||
* no longer interested in the operation result. It does not cancel the
|
||||
* operation. If the server doesn't support this method, it returns
|
||||
* `google.rpc.Code.UNIMPLEMENTED`.
|
||||
*
|
||||
* @param {Object} request - The request object that will be sent.
|
||||
* @param {string} request.name - The name of the operation resource to be deleted.
|
||||
* @param {Object=} options
|
||||
* Optional parameters. You can override the default settings for this call,
|
||||
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
|
||||
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
|
||||
* details.
|
||||
* @param {function(?Error)=} callback
|
||||
* The function which will be called with the result of the API call.
|
||||
* @return {Promise} - The promise which resolves when API call finishes.
|
||||
* The promise has a method named "cancel" which cancels the ongoing API
|
||||
* call.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* const client = longrunning.operationsClient();
|
||||
* await client.deleteOperation({name: ''});
|
||||
*/
|
||||
deleteOperation(request, optionsOrCallback, callback) {
|
||||
let options;
|
||||
if (optionsOrCallback instanceof Function && callback === undefined) {
|
||||
callback = optionsOrCallback;
|
||||
options = {};
|
||||
}
|
||||
else {
|
||||
options = optionsOrCallback;
|
||||
}
|
||||
request = request || {};
|
||||
options = options || {};
|
||||
return this.innerApiCalls.deleteOperation(request, options, callback);
|
||||
}
|
||||
}
|
||||
exports.OperationsClient = OperationsClient;
|
||||
class OperationsClientBuilder {
|
||||
/**
|
||||
* Builds a new Operations Client
|
||||
* @param gaxGrpc {GrpcClient}
|
||||
*/
|
||||
constructor(gaxGrpc, protoJson) {
|
||||
if (protoJson && gaxGrpc.httpRules) {
|
||||
// overwrite the http rules if provide in service yaml.
|
||||
(0, transcoding_1.overrideHttpRules)(gaxGrpc.httpRules, protoJson);
|
||||
}
|
||||
const operationsProtos = protoJson !== null && protoJson !== void 0 ? protoJson : gaxGrpc.loadProtoJSON(operationProtoJson);
|
||||
/**
|
||||
* Build a new instance of {@link OperationsClient}.
|
||||
*
|
||||
* @param {Object=} opts - The optional parameters.
|
||||
* @param {String=} opts.servicePath - Domain name of the API remote host.
|
||||
* @param {number=} opts.port - The port on which to connect to the remote host.
|
||||
* @param {grpc.ClientCredentials=} opts.sslCreds - A ClientCredentials for use with an SSL-enabled channel.
|
||||
* @param {Object=} opts.clientConfig - The customized config to build the call settings. See {@link gax.constructSettings} for the format.
|
||||
*/
|
||||
this.operationsClient = opts => {
|
||||
if (gaxGrpc.fallback) {
|
||||
opts.fallback = gaxGrpc.fallback;
|
||||
}
|
||||
return new OperationsClient(gaxGrpc, operationsProtos, opts);
|
||||
};
|
||||
Object.assign(this.operationsClient, OperationsClient);
|
||||
}
|
||||
}
|
||||
exports.OperationsClientBuilder = OperationsClientBuilder;
|
||||
//# sourceMappingURL=operationsClient.js.map
|
||||
1
functions/node_modules/google-gax/build/src/operationsClient.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/operationsClient.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
46
functions/node_modules/google-gax/build/src/operations_client_config.json
generated
vendored
Normal file
46
functions/node_modules/google-gax/build/src/operations_client_config.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"interfaces": {
|
||||
"google.longrunning.Operations": {
|
||||
"retry_codes": {
|
||||
"idempotent": [
|
||||
"DEADLINE_EXCEEDED",
|
||||
"UNAVAILABLE"
|
||||
],
|
||||
"non_idempotent": []
|
||||
},
|
||||
"retry_params": {
|
||||
"default": {
|
||||
"initial_retry_delay_millis": 100,
|
||||
"retry_delay_multiplier": 1.3,
|
||||
"max_retry_delay_millis": 60000,
|
||||
"initial_rpc_timeout_millis": 90000,
|
||||
"rpc_timeout_multiplier": 1.0,
|
||||
"max_rpc_timeout_millis": 90000,
|
||||
"total_timeout_millis": 600000
|
||||
}
|
||||
},
|
||||
"methods": {
|
||||
"GetOperation": {
|
||||
"timeout_millis": 60000,
|
||||
"retry_codes_name": "idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"ListOperations": {
|
||||
"timeout_millis": 60000,
|
||||
"retry_codes_name": "idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"CancelOperation": {
|
||||
"timeout_millis": 60000,
|
||||
"retry_codes_name": "idempotent",
|
||||
"retry_params_name": "default"
|
||||
},
|
||||
"DeleteOperation": {
|
||||
"timeout_millis": 60000,
|
||||
"retry_codes_name": "idempotent",
|
||||
"retry_params_name": "default"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.d.ts
generated
vendored
Normal file
43
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Transform } from 'stream';
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { GaxCall, RequestType } from '../apitypes';
|
||||
import { Descriptor } from '../descriptor';
|
||||
import { CallSettings } from '../gax';
|
||||
export interface ResponseType {
|
||||
[index: string]: string;
|
||||
}
|
||||
/**
|
||||
* A descriptor for methods that support pagination.
|
||||
*/
|
||||
export declare class PageDescriptor implements Descriptor {
|
||||
requestPageTokenField: string;
|
||||
responsePageTokenField: string;
|
||||
requestPageSizeField?: string;
|
||||
resourceField: string;
|
||||
constructor(requestPageTokenField: string, responsePageTokenField: string, resourceField: string);
|
||||
/**
|
||||
* Creates a new object Stream which emits the resource on 'data' event.
|
||||
*/
|
||||
createStream(apiCall: GaxCall, request: {}, options: CallSettings): Transform;
|
||||
/**
|
||||
* Create an async iterable which can be recursively called for data on-demand.
|
||||
*/
|
||||
asyncIterate(apiCall: GaxCall, request: RequestType, options?: CallSettings): AsyncIterable<{} | undefined>;
|
||||
createIterator(apiCall: GaxCall, request: RequestType, options: CallSettings): AsyncIterable<{} | undefined>;
|
||||
getApiCaller(settings: CallSettings): APICaller;
|
||||
}
|
||||
159
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js
generated
vendored
Normal file
159
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PageDescriptor = void 0;
|
||||
const stream_1 = require("stream");
|
||||
const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
|
||||
const warnings_1 = require(".././warnings");
|
||||
const pagedApiCaller_1 = require("./pagedApiCaller");
|
||||
const maxAttemptsEmptyResponse = 10;
|
||||
/**
|
||||
* A descriptor for methods that support pagination.
|
||||
*/
|
||||
class PageDescriptor {
|
||||
constructor(requestPageTokenField, responsePageTokenField, resourceField) {
|
||||
this.requestPageTokenField = requestPageTokenField;
|
||||
this.responsePageTokenField = responsePageTokenField;
|
||||
this.resourceField = resourceField;
|
||||
}
|
||||
/**
|
||||
* Creates a new object Stream which emits the resource on 'data' event.
|
||||
*/
|
||||
createStream(apiCall, request, options) {
|
||||
if (options === null || options === void 0 ? void 0 : options.autoPaginate) {
|
||||
(0, warnings_1.warn)('autoPaginate true', 'Autopaginate will always be set to false in stream paging methods. See more info at https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#auto-pagination for more information on how to configure paging calls', 'AutopaginateTrueWarning');
|
||||
}
|
||||
const stream = new stream_1.PassThrough({ objectMode: true });
|
||||
options = Object.assign({}, options, { autoPaginate: false });
|
||||
const maxResults = 'maxResults' in options ? options.maxResults : -1;
|
||||
let pushCount = 0;
|
||||
let started = false;
|
||||
function callback(err, resources, next, apiResp) {
|
||||
if (err) {
|
||||
stream.emit('error', err);
|
||||
return;
|
||||
}
|
||||
// emit full api response with every page.
|
||||
stream.emit('response', apiResp);
|
||||
for (let i = 0; i < resources.length; ++i) {
|
||||
// TODO: rewrite without accessing stream internals
|
||||
if (stream
|
||||
._readableState.ended) {
|
||||
return;
|
||||
}
|
||||
if (resources[i] === null) {
|
||||
continue;
|
||||
}
|
||||
stream.push(resources[i]);
|
||||
pushCount++;
|
||||
if (pushCount === maxResults) {
|
||||
stream.end();
|
||||
}
|
||||
}
|
||||
// TODO: rewrite without accessing stream internals
|
||||
if (stream._readableState
|
||||
.ended) {
|
||||
return;
|
||||
}
|
||||
if (!next) {
|
||||
stream.end();
|
||||
return;
|
||||
}
|
||||
// When pageToken is specified in the original options, it will overwrite
|
||||
// the page token field in the next request. Therefore it must be cleared.
|
||||
if ('pageToken' in options) {
|
||||
delete options.pageToken;
|
||||
}
|
||||
if (stream.isPaused()) {
|
||||
request = next;
|
||||
started = false;
|
||||
}
|
||||
else {
|
||||
setImmediate(apiCall, next, options, callback);
|
||||
}
|
||||
}
|
||||
stream.on('resume', () => {
|
||||
if (!started) {
|
||||
started = true;
|
||||
apiCall(request, options, callback);
|
||||
}
|
||||
});
|
||||
return stream;
|
||||
}
|
||||
/**
|
||||
* Create an async iterable which can be recursively called for data on-demand.
|
||||
*/
|
||||
asyncIterate(apiCall, request, options) {
|
||||
if (options === null || options === void 0 ? void 0 : options.autoPaginate) {
|
||||
(0, warnings_1.warn)('autoPaginate true', 'Autopaginate will always be set to false in Async paging methods. See more info at https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#auto-pagination for more information on how to configure paging calls', 'AutopaginateTrueWarning');
|
||||
}
|
||||
options = Object.assign({}, options, { autoPaginate: false });
|
||||
const iterable = this.createIterator(apiCall, request, options);
|
||||
return iterable;
|
||||
}
|
||||
createIterator(apiCall, request, options) {
|
||||
const asyncIterable = {
|
||||
[Symbol.asyncIterator]() {
|
||||
let nextPageRequest = request;
|
||||
const cache = [];
|
||||
return {
|
||||
async next() {
|
||||
if (cache.length > 0) {
|
||||
return Promise.resolve({
|
||||
done: false,
|
||||
value: cache.shift(),
|
||||
});
|
||||
}
|
||||
let attempts = 0;
|
||||
while (cache.length === 0 && nextPageRequest) {
|
||||
let result;
|
||||
[result, nextPageRequest] = (await apiCall(nextPageRequest, options));
|
||||
// For pagination response with protobuf map type, use tuple as representation.
|
||||
if (result && !Array.isArray(result)) {
|
||||
for (const [key, value] of Object.entries(result)) {
|
||||
cache.push([key, value]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cache.push(...result);
|
||||
}
|
||||
if (cache.length === 0) {
|
||||
++attempts;
|
||||
if (attempts > maxAttemptsEmptyResponse) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cache.length === 0) {
|
||||
return Promise.resolve({ done: true, value: undefined });
|
||||
}
|
||||
return Promise.resolve({ done: false, value: cache.shift() });
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
return asyncIterable;
|
||||
}
|
||||
getApiCaller(settings) {
|
||||
if (!settings.autoPaginate) {
|
||||
return new normalApiCaller_1.NormalApiCaller();
|
||||
}
|
||||
return new pagedApiCaller_1.PagedApiCaller(this);
|
||||
}
|
||||
}
|
||||
exports.PageDescriptor = PageDescriptor;
|
||||
//# sourceMappingURL=pageDescriptor.js.map
|
||||
1
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pageDescriptor.js","sourceRoot":"","sources":["../../../src/paginationCalls/pageDescriptor.ts"],"names":[],"mappings":"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"}
|
||||
80
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.d.ts
generated
vendored
Normal file
80
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.d.ts
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { GRPCCall, SimpleCallbackFunction, RequestType } from '../apitypes';
|
||||
import { APICallback } from '../apitypes';
|
||||
import { OngoingCall, OngoingCallPromise } from '../call';
|
||||
import { CallOptions } from '../gax';
|
||||
import { GoogleError } from '../googleError';
|
||||
import { PageDescriptor } from './pageDescriptor';
|
||||
export declare class PagedApiCaller implements APICaller {
|
||||
pageDescriptor: PageDescriptor;
|
||||
/**
|
||||
* Creates an API caller that returns a stream to performs page-streaming.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {PageDescriptor} pageDescriptor - indicates the structure
|
||||
* of page streaming to be performed.
|
||||
*/
|
||||
constructor(pageDescriptor: PageDescriptor);
|
||||
/**
|
||||
* This function translates between regular gRPC calls (that accepts a request and returns a response,
|
||||
* and does not know anything about pages and page tokens) and the users' callback (that expects
|
||||
* to see resources from one page, a request to get the next page, and the raw response from the server).
|
||||
*
|
||||
* It generates a function that can be passed as a callback function to a gRPC call, will understand
|
||||
* pagination-specific fields in the response, and call the users' callback after having those fields
|
||||
* parsed.
|
||||
*
|
||||
* @param request Request object. It needs to be passed to all subsequent next page requests
|
||||
* (the main content of the request object stays unchanged, only the next page token changes)
|
||||
* @param callback The user's callback that expects the page content, next page request, and raw response.
|
||||
*/
|
||||
private generateParseResponseCallback;
|
||||
/**
|
||||
* Adds a special ability to understand pagination-specific fields to the existing gRPC call.
|
||||
* The original gRPC call just calls callback(err, result).
|
||||
* The wrapped one will call callback(err, resources, nextPageRequest, rawResponse) instead.
|
||||
*
|
||||
* @param func gRPC call (normally, a service stub call). The gRPC call is expected to accept four parameters:
|
||||
* request, metadata, call options, and callback.
|
||||
*/
|
||||
wrap(func: GRPCCall): GRPCCall;
|
||||
/**
|
||||
* Makes it possible to use both callback-based and promise-based calls.
|
||||
* Returns an OngoingCall or OngoingCallPromise object.
|
||||
* Regardless of which one is returned, it always has a `.callback` to call.
|
||||
*
|
||||
* @param settings Call settings. Can only be used to replace Promise with another promise implementation.
|
||||
* @param [callback] Callback to be called, if any.
|
||||
*/
|
||||
init(callback?: APICallback): OngoingCall;
|
||||
/**
|
||||
* Implements auto-pagination logic.
|
||||
*
|
||||
* @param apiCall A function that performs gRPC request and calls its callback with a response or an error.
|
||||
* It's supposed to be a gRPC service stub function wrapped into several layers of wrappers that make it
|
||||
* accept just two parameters: (request, callback).
|
||||
* @param request A request object that came from the user.
|
||||
* @param settings Call settings. We are interested in `maxResults` and `autoPaginate` (they are optional).
|
||||
* @param ongoingCall An instance of OngoingCall or OngoingCallPromise that can be used for call cancellation,
|
||||
* and is used to return results to the user.
|
||||
*/
|
||||
call(apiCall: SimpleCallbackFunction, request: RequestType, settings: CallOptions, ongoingCall: OngoingCall): void;
|
||||
fail(ongoingCall: OngoingCallPromise, err: GoogleError): void;
|
||||
result(ongoingCall: OngoingCallPromise): import("../call").CancellablePromise<import("../apitypes").ResultTuple>;
|
||||
}
|
||||
137
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js
generated
vendored
Normal file
137
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PagedApiCaller = void 0;
|
||||
const call_1 = require("../call");
|
||||
const googleError_1 = require("../googleError");
|
||||
const resourceCollector_1 = require("./resourceCollector");
|
||||
const warnings_1 = require(".././warnings");
|
||||
class PagedApiCaller {
|
||||
/**
|
||||
* Creates an API caller that returns a stream to performs page-streaming.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {PageDescriptor} pageDescriptor - indicates the structure
|
||||
* of page streaming to be performed.
|
||||
*/
|
||||
constructor(pageDescriptor) {
|
||||
this.pageDescriptor = pageDescriptor;
|
||||
}
|
||||
/**
|
||||
* This function translates between regular gRPC calls (that accepts a request and returns a response,
|
||||
* and does not know anything about pages and page tokens) and the users' callback (that expects
|
||||
* to see resources from one page, a request to get the next page, and the raw response from the server).
|
||||
*
|
||||
* It generates a function that can be passed as a callback function to a gRPC call, will understand
|
||||
* pagination-specific fields in the response, and call the users' callback after having those fields
|
||||
* parsed.
|
||||
*
|
||||
* @param request Request object. It needs to be passed to all subsequent next page requests
|
||||
* (the main content of the request object stays unchanged, only the next page token changes)
|
||||
* @param callback The user's callback that expects the page content, next page request, and raw response.
|
||||
*/
|
||||
generateParseResponseCallback(request, callback) {
|
||||
const resourceFieldName = this.pageDescriptor.resourceField;
|
||||
const responsePageTokenFieldName = this.pageDescriptor.responsePageTokenField;
|
||||
const requestPageTokenFieldName = this.pageDescriptor.requestPageTokenField;
|
||||
return (err, response) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
if (!request) {
|
||||
callback(new googleError_1.GoogleError('Undefined request in pagination method callback.'));
|
||||
return;
|
||||
}
|
||||
if (!response) {
|
||||
callback(new googleError_1.GoogleError('Undefined response in pagination method callback.'));
|
||||
return;
|
||||
}
|
||||
const resources = response[resourceFieldName] || [];
|
||||
const pageToken = response[responsePageTokenFieldName];
|
||||
let nextPageRequest = null;
|
||||
if (pageToken) {
|
||||
nextPageRequest = Object.assign({}, request);
|
||||
nextPageRequest[requestPageTokenFieldName] = pageToken;
|
||||
}
|
||||
callback(err, resources, nextPageRequest, response);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds a special ability to understand pagination-specific fields to the existing gRPC call.
|
||||
* The original gRPC call just calls callback(err, result).
|
||||
* The wrapped one will call callback(err, resources, nextPageRequest, rawResponse) instead.
|
||||
*
|
||||
* @param func gRPC call (normally, a service stub call). The gRPC call is expected to accept four parameters:
|
||||
* request, metadata, call options, and callback.
|
||||
*/
|
||||
wrap(func) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
return function wrappedCall(argument, metadata, options, callback) {
|
||||
return func(argument, metadata, options, self.generateParseResponseCallback(argument, callback));
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Makes it possible to use both callback-based and promise-based calls.
|
||||
* Returns an OngoingCall or OngoingCallPromise object.
|
||||
* Regardless of which one is returned, it always has a `.callback` to call.
|
||||
*
|
||||
* @param settings Call settings. Can only be used to replace Promise with another promise implementation.
|
||||
* @param [callback] Callback to be called, if any.
|
||||
*/
|
||||
init(callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise();
|
||||
}
|
||||
/**
|
||||
* Implements auto-pagination logic.
|
||||
*
|
||||
* @param apiCall A function that performs gRPC request and calls its callback with a response or an error.
|
||||
* It's supposed to be a gRPC service stub function wrapped into several layers of wrappers that make it
|
||||
* accept just two parameters: (request, callback).
|
||||
* @param request A request object that came from the user.
|
||||
* @param settings Call settings. We are interested in `maxResults` and `autoPaginate` (they are optional).
|
||||
* @param ongoingCall An instance of OngoingCall or OngoingCallPromise that can be used for call cancellation,
|
||||
* and is used to return results to the user.
|
||||
*/
|
||||
call(apiCall, request, settings, ongoingCall) {
|
||||
request = Object.assign({}, request);
|
||||
if (!settings.autoPaginate) {
|
||||
// they don't want auto-pagination this time - okay, just call once
|
||||
ongoingCall.call(apiCall, request);
|
||||
return;
|
||||
}
|
||||
if (request.pageSize && settings.autoPaginate) {
|
||||
(0, warnings_1.warn)('autoPaginate true', 'Providing a pageSize without setting autoPaginate to false will still return all results. See https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#auto-pagination for more information on how to configure manual paging', 'AutopaginateTrueWarning');
|
||||
}
|
||||
const maxResults = settings.maxResults || -1;
|
||||
const resourceCollector = new resourceCollector_1.ResourceCollector(apiCall, maxResults);
|
||||
resourceCollector.processAllPages(request).then(resources => ongoingCall.callback(null, resources), err => ongoingCall.callback(err));
|
||||
}
|
||||
fail(ongoingCall, err) {
|
||||
ongoingCall.callback(err);
|
||||
}
|
||||
result(ongoingCall) {
|
||||
return ongoingCall.promise;
|
||||
}
|
||||
}
|
||||
exports.PagedApiCaller = PagedApiCaller;
|
||||
//# sourceMappingURL=pagedApiCaller.js.map
|
||||
1
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pagedApiCaller.js","sourceRoot":"","sources":["../../../src/paginationCalls/pagedApiCaller.ts"],"names":[],"mappings":"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"}
|
||||
34
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.d.ts
generated
vendored
Normal file
34
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.d.ts
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { SimpleCallbackFunction, RequestType } from '../apitypes';
|
||||
/**
|
||||
* ResourceCollector class implements asynchronous logic of calling the API call that supports pagination,
|
||||
* page by page, collecting all resources (up to `maxResults`) in the array.
|
||||
*
|
||||
* Usage:
|
||||
* const resourceCollector = new ResourceCollector(apiCall, maxResults); // -1 for unlimited
|
||||
* resourceCollector.processAllPages(request).then(resources => ...);
|
||||
*/
|
||||
export declare class ResourceCollector {
|
||||
apiCall: SimpleCallbackFunction;
|
||||
resources: Array<{}>;
|
||||
maxResults: number;
|
||||
resolveCallback?: (resources: Array<{}>) => void;
|
||||
rejectCallback?: (err: Error) => void;
|
||||
constructor(apiCall: SimpleCallbackFunction, maxResults?: number);
|
||||
private callback;
|
||||
processAllPages(firstRequest: RequestType): Promise<Array<{}>>;
|
||||
}
|
||||
67
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.js
generated
vendored
Normal file
67
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ResourceCollector = void 0;
|
||||
/**
|
||||
* ResourceCollector class implements asynchronous logic of calling the API call that supports pagination,
|
||||
* page by page, collecting all resources (up to `maxResults`) in the array.
|
||||
*
|
||||
* Usage:
|
||||
* const resourceCollector = new ResourceCollector(apiCall, maxResults); // -1 for unlimited
|
||||
* resourceCollector.processAllPages(request).then(resources => ...);
|
||||
*/
|
||||
class ResourceCollector {
|
||||
constructor(apiCall, maxResults = -1) {
|
||||
this.apiCall = apiCall;
|
||||
this.resources = [];
|
||||
this.maxResults = maxResults;
|
||||
}
|
||||
callback(err, resources, nextPageRequest) {
|
||||
if (err) {
|
||||
// Something went wrong with this request - failing everything
|
||||
this.rejectCallback(err);
|
||||
return;
|
||||
}
|
||||
// Process one page
|
||||
for (const resource of resources) {
|
||||
this.resources.push(resource);
|
||||
if (this.resources.length === this.maxResults) {
|
||||
nextPageRequest = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// All done?
|
||||
if (!nextPageRequest) {
|
||||
this.resolveCallback(this.resources);
|
||||
return;
|
||||
}
|
||||
// Schedule the next call
|
||||
const callback = (...args) => this.callback(...args);
|
||||
setImmediate(this.apiCall, nextPageRequest, callback);
|
||||
}
|
||||
processAllPages(firstRequest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resolveCallback = resolve;
|
||||
this.rejectCallback = reject;
|
||||
// Schedule the first call
|
||||
const callback = (...args) => this.callback(...args);
|
||||
setImmediate(this.apiCall, firstRequest, callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.ResourceCollector = ResourceCollector;
|
||||
//# sourceMappingURL=resourceCollector.js.map
|
||||
1
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/paginationCalls/resourceCollector.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"resourceCollector.js","sourceRoot":"","sources":["../../../src/paginationCalls/resourceCollector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH;;;;;;;GAOG;AACH,MAAa,iBAAiB;IAO5B,YAAY,OAA+B,EAAE,UAAU,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEO,QAAQ,CACd,GAAiB,EACjB,SAAoB,EACpB,eAAoC;QAEpC,IAAI,GAAG,EAAE,CAAC;YACR,8DAA8D;YAC9D,IAAI,CAAC,cAAe,CAAC,GAAG,CAAC,CAAC;YAC1B,OAAO;QACT,CAAC;QAED,mBAAmB;QACnB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC9C,eAAe,GAAG,IAAI,CAAC;gBACvB,MAAM;YACR,CAAC;QACH,CAAC;QAED,YAAY;QACZ,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,CAAC,eAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACtC,OAAO;QACT,CAAC;QAED,yBAAyB;QACzB,MAAM,QAAQ,GAAG,CACf,GAAG,IAAoD,EACvD,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5B,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,QAAuB,CAAC,CAAC;IACvE,CAAC;IAED,eAAe,CAAC,YAAyB;QACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;YAC/B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;YAE7B,0BAA0B;YAC1B,MAAM,QAAQ,GAAG,CACf,GAAG,IAAoD,EACvD,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YAC5B,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,QAAuB,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1DD,8CA0DC"}
|
||||
60
functions/node_modules/google-gax/build/src/pathTemplate.d.ts
generated
vendored
Normal file
60
functions/node_modules/google-gax/build/src/pathTemplate.d.ts
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export interface Bindings {
|
||||
[index: string]: string | number;
|
||||
}
|
||||
export declare class PathTemplate {
|
||||
private data;
|
||||
private bindings;
|
||||
segments: string[];
|
||||
size: number;
|
||||
/**
|
||||
* @param {String} data the of the template
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(data: string);
|
||||
/**
|
||||
* Matches a fully-qualified path template string.
|
||||
*
|
||||
* @param {String} path a fully-qualified path template string
|
||||
* @return {Object} contains const names matched to binding values
|
||||
* @throws {TypeError} if path can't be matched to this template
|
||||
*/
|
||||
match(path: string): Bindings;
|
||||
/**
|
||||
* Renders a path template using the provided bindings.
|
||||
*
|
||||
* @param {Object} bindings a mapping of const names to binding strings
|
||||
* @return {String} a rendered representation of the path template
|
||||
* @throws {TypeError} if a key is missing, or if a sub-template cannot be
|
||||
* parsed
|
||||
*/
|
||||
render(bindings: Bindings): string;
|
||||
/**
|
||||
* Renders the path template.
|
||||
*
|
||||
* @return {string} contains const names matched to binding values
|
||||
*/
|
||||
inspect(): string;
|
||||
/**
|
||||
* Parse the path template.
|
||||
*
|
||||
* @return {string[]} return segments of the input path.
|
||||
* For example: 'buckets/{hello}'' will give back ['buckets', {hello=*}]
|
||||
*/
|
||||
private parsePathTemplate;
|
||||
}
|
||||
237
functions/node_modules/google-gax/build/src/pathTemplate.js
generated
vendored
Normal file
237
functions/node_modules/google-gax/build/src/pathTemplate.js
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PathTemplate = void 0;
|
||||
class PathTemplate {
|
||||
/**
|
||||
* @param {String} data the of the template
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(data) {
|
||||
this.bindings = {};
|
||||
this.data = data;
|
||||
this.segments = this.parsePathTemplate(data);
|
||||
this.size = this.segments.length;
|
||||
}
|
||||
/**
|
||||
* Matches a fully-qualified path template string.
|
||||
*
|
||||
* @param {String} path a fully-qualified path template string
|
||||
* @return {Object} contains const names matched to binding values
|
||||
* @throws {TypeError} if path can't be matched to this template
|
||||
*/
|
||||
match(path) {
|
||||
let pathSegments = path.split('/');
|
||||
const bindings = {};
|
||||
if (pathSegments.length !== this.segments.length) {
|
||||
// if the path contains a wildcard, then the length may differ by 1.
|
||||
if (!this.data.includes('**')) {
|
||||
throw new TypeError(`This path ${path} does not match path template ${this.data}, the number of parameters is not same.`);
|
||||
}
|
||||
else if (pathSegments.length !== this.segments.length + 1) {
|
||||
throw new TypeError(`This path ${path} does not match path template ${this.data}, the number of parameters is not same with one wildcard.`);
|
||||
}
|
||||
}
|
||||
for (let index = 0; index < this.segments.length && pathSegments.length > 0; index++) {
|
||||
if (this.segments[index] !== pathSegments[0]) {
|
||||
if (!this.segments[index].includes('*')) {
|
||||
throw new TypeError(`segment does not match, ${this.segments[index]} and ${pathSegments[index]}.`);
|
||||
}
|
||||
else {
|
||||
let segment = this.segments[index];
|
||||
const matches = segment.match(/\{[$0-9a-zA-Z_]+=.*?\}/g);
|
||||
if (!matches) {
|
||||
throw new Error(`Error processing path template segment ${segment}`);
|
||||
}
|
||||
const variables = matches.map(str => str.replace(/^\{/, '').replace(/=.*/, ''));
|
||||
if (segment.includes('**')) {
|
||||
bindings[variables[0]] = pathSegments[0] + '/' + pathSegments[1];
|
||||
pathSegments = pathSegments.slice(2);
|
||||
}
|
||||
else {
|
||||
// atomic resource
|
||||
if (variables.length === 1) {
|
||||
bindings[variables[0]] = pathSegments[0];
|
||||
}
|
||||
else {
|
||||
// non-slash resource
|
||||
// segment: {blurb_id=*}.{legacy_user=*} to match pathSegments: ['bar.user2']
|
||||
// split the match pathSegments[0] -> value: ['bar', 'user2']
|
||||
// compare the length of two arrays, and compare array items
|
||||
const value = pathSegments[0].split(/[-_.~]/);
|
||||
if (value.length !== variables.length) {
|
||||
throw new Error(`segment ${segment} does not match ${pathSegments[0]}`);
|
||||
}
|
||||
for (const v of variables) {
|
||||
bindings[v] = value[0];
|
||||
segment = segment.replace(`{${v}=*}`, `${value[0]}`);
|
||||
value.shift();
|
||||
}
|
||||
// segment: {blurb_id=*}.{legacy_user=*} matching pathSegments: ['bar~user2'] should fail
|
||||
if (segment !== pathSegments[0]) {
|
||||
throw new TypeError(`non slash resource pattern ${this.segments[index]} and ${pathSegments[0]} should have same separator`);
|
||||
}
|
||||
}
|
||||
pathSegments.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
pathSegments.shift();
|
||||
}
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
/**
|
||||
* Renders a path template using the provided bindings.
|
||||
*
|
||||
* @param {Object} bindings a mapping of const names to binding strings
|
||||
* @return {String} a rendered representation of the path template
|
||||
* @throws {TypeError} if a key is missing, or if a sub-template cannot be
|
||||
* parsed
|
||||
*/
|
||||
render(bindings) {
|
||||
if (Object.keys(bindings).length !== Object.keys(this.bindings).length) {
|
||||
throw new TypeError(`The number of variables ${Object.keys(bindings).length} does not match the number of needed variables ${Object.keys(this.bindings).length}`);
|
||||
}
|
||||
let path = this.inspect();
|
||||
for (const key of Object.keys(bindings)) {
|
||||
const b = bindings[key].toString();
|
||||
if (!this.bindings[key]) {
|
||||
throw new TypeError(`render fails for not matching ${bindings[key]}`);
|
||||
}
|
||||
const variable = this.bindings[key];
|
||||
if (variable === '*') {
|
||||
if (!b.match(/[^/{}]+/)) {
|
||||
throw new TypeError(`render fails for not matching ${b}`);
|
||||
}
|
||||
path = path.replace(`{${key}=*}`, `${b}`);
|
||||
}
|
||||
else if (variable === '**') {
|
||||
if (!b.match(/[^{}]+/)) {
|
||||
throw new TypeError(`render fails for not matching ${b}`);
|
||||
}
|
||||
path = path.replace(`{${key}=**}`, `${b}`);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
/**
|
||||
* Renders the path template.
|
||||
*
|
||||
* @return {string} contains const names matched to binding values
|
||||
*/
|
||||
inspect() {
|
||||
return this.segments.join('/');
|
||||
}
|
||||
/**
|
||||
* Parse the path template.
|
||||
*
|
||||
* @return {string[]} return segments of the input path.
|
||||
* For example: 'buckets/{hello}'' will give back ['buckets', {hello=*}]
|
||||
*/
|
||||
parsePathTemplate(data) {
|
||||
const pathSegments = splitPathTemplate(data);
|
||||
let index = 0;
|
||||
let wildCardCount = 0;
|
||||
const segments = [];
|
||||
let matches;
|
||||
pathSegments.forEach(segment => {
|
||||
// * or ** -> segments.push('{$0=*}');
|
||||
// -> bindings['$0'] = '*'
|
||||
if (segment === '*' || segment === '**') {
|
||||
this.bindings[`$${index}`] = segment;
|
||||
segments.push(`{$${index}=${segment}}`);
|
||||
index = index + 1;
|
||||
if (segment === '**') {
|
||||
++wildCardCount;
|
||||
}
|
||||
}
|
||||
else if ((matches = segment.match(/\{[0-9a-zA-Z-.~_]+(?:=.*?)?\}/g))) {
|
||||
for (const subsegment of matches) {
|
||||
const pairMatch = subsegment.match(/^\{([0-9a-zA-Z-.~_]+)(?:=(.*?))?\}$/);
|
||||
if (!pairMatch) {
|
||||
throw new Error(`Cannot process path template segment ${subsegment}`);
|
||||
}
|
||||
const key = pairMatch[1];
|
||||
let value = pairMatch[2];
|
||||
if (!value) {
|
||||
value = '*';
|
||||
segment = segment.replace(key, key + '=*');
|
||||
this.bindings[key] = value;
|
||||
}
|
||||
else if (value === '*') {
|
||||
this.bindings[key] = value;
|
||||
}
|
||||
else if (value === '**') {
|
||||
++wildCardCount;
|
||||
this.bindings[key] = value;
|
||||
}
|
||||
}
|
||||
segments.push(segment);
|
||||
}
|
||||
else if (segment.match(/[0-9a-zA-Z-.~_]+/)) {
|
||||
segments.push(segment);
|
||||
}
|
||||
});
|
||||
if (wildCardCount > 1) {
|
||||
throw new TypeError('Can not have more than one wildcard.');
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
}
|
||||
exports.PathTemplate = PathTemplate;
|
||||
/**
|
||||
* Split the path template by `/`.
|
||||
* It can not be simply splitted by `/` because there might be `/` in the segments.
|
||||
* For example: 'a/b/{a=hello/world}' we do not want to break the brackets pair
|
||||
* so above path will be splitted as ['a', 'b', '{a=hello/world}']
|
||||
*/
|
||||
function splitPathTemplate(data) {
|
||||
let left = 0;
|
||||
let right = 0;
|
||||
let bracketCount = 0;
|
||||
const segments = [];
|
||||
while (right >= left && right < data.length) {
|
||||
if (data.charAt(right) === '{') {
|
||||
bracketCount = bracketCount + 1;
|
||||
}
|
||||
else if (data.charAt(right) === '}') {
|
||||
bracketCount = bracketCount - 1;
|
||||
}
|
||||
else if (data.charAt(right) === '/') {
|
||||
if (right === data.length - 1) {
|
||||
throw new TypeError('Invalid path, it can not be ended by /');
|
||||
}
|
||||
if (bracketCount === 0) {
|
||||
// complete bracket, to avoid the case a/b/**/*/{a=hello/world}
|
||||
segments.push(data.substring(left, right));
|
||||
left = right + 1;
|
||||
}
|
||||
}
|
||||
if (right === data.length - 1) {
|
||||
if (bracketCount !== 0) {
|
||||
throw new TypeError('Brackets are invalid.');
|
||||
}
|
||||
segments.push(data.substring(left));
|
||||
}
|
||||
right = right + 1;
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
//# sourceMappingURL=pathTemplate.js.map
|
||||
1
functions/node_modules/google-gax/build/src/pathTemplate.js.map
generated
vendored
Normal file
1
functions/node_modules/google-gax/build/src/pathTemplate.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
16
functions/node_modules/google-gax/build/src/protobuf.d.ts
generated
vendored
Normal file
16
functions/node_modules/google-gax/build/src/protobuf.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2022 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export * as protobufMinimal from 'protobufjs/minimal';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user