mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 10:46:01 +00:00
Modules
This commit is contained in:
36
node_modules/google-gax/build/src/apiCaller.d.ts
generated
vendored
Normal file
36
node_modules/google-gax/build/src/apiCaller.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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';
|
||||
export interface ApiCallerSettings {
|
||||
promise: PromiseConstructor;
|
||||
}
|
||||
/**
|
||||
* 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(settings: ApiCallerSettings, 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
node_modules/google-gax/build/src/apiCaller.js
generated
vendored
Normal file
26
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 });
|
||||
const normalApiCaller_1 = require("./normalCalls/normalApiCaller");
|
||||
function createAPICaller(settings, descriptor) {
|
||||
if (!descriptor) {
|
||||
return new normalApiCaller_1.NormalApiCaller();
|
||||
}
|
||||
return descriptor.getApiCaller(settings);
|
||||
}
|
||||
exports.createAPICaller = createAPICaller;
|
||||
//# sourceMappingURL=apiCaller.js.map
|
1
node_modules/google-gax/build/src/apiCaller.js.map
generated
vendored
Normal file
1
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;;AAaH,mEAA8D;AAgC9D,SAAgB,eAAe,CAC7B,QAAsB,EACtB,UAAkC;IAElC,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,iCAAe,EAAE,CAAC;KAC9B;IACD,OAAO,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AARD,0CAQC"}
|
60
node_modules/google-gax/build/src/apitypes.d.ts
generated
vendored
Normal file
60
node_modules/google-gax/build/src/apitypes.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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
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 | {};
|
||||
}
|
||||
export declare type ResponseType = {} | null;
|
||||
export declare type NextPageRequestType = {
|
||||
[index: string]: string | number | {};
|
||||
} | null;
|
||||
export declare type RawResponseType = Operation | {} | null;
|
||||
export declare type ResultTuple = [ResponseType, NextPageRequestType | undefined, RawResponseType | undefined];
|
||||
export interface SimpleCallbackFunction {
|
||||
(request: RequestType, callback: APICallback): GRPCCallResult;
|
||||
}
|
||||
export declare type APICallback = (err: GoogleError | null, response?: ResponseType, next?: NextPageRequestType, rawResponse?: RawResponseType) => void;
|
||||
export declare type UnaryCall = (argument: {}, metadata: {}, options: {}, callback: APICallback) => GRPCCallResult;
|
||||
export declare type ServerStreamingCall = (argument: {}, metadata: {}, options: {}) => Duplex & GRPCCallResult;
|
||||
export declare type ClientStreamingCall = (metadata: {}, options: {}, callback?: APICallback) => Duplex & GRPCCallResult;
|
||||
export declare type BiDiStreamingCall = (metadata: {}, options: {}) => Duplex & GRPCCallResult;
|
||||
export declare type GRPCCall = UnaryCall | ServerStreamingCall | ClientStreamingCall | BiDiStreamingCall;
|
||||
export declare type CancellableStream = Duplex & GRPCCallResult;
|
||||
export declare 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
node_modules/google-gax/build/src/apitypes.js
generated
vendored
Normal file
18
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
node_modules/google-gax/build/src/apitypes.js.map
generated
vendored
Normal file
1
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"}
|
36
node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.d.ts
generated
vendored
Normal file
36
node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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, ApiCallerSettings } 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(settings: ApiCallerSettings, 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").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import("..").Operation | null | undefined]>;
|
||||
}
|
54
node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js
generated
vendored
Normal file
54
node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
"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 });
|
||||
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(settings, callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise(settings.promise);
|
||||
}
|
||||
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
node_modules/google-gax/build/src/bundlingCalls/bundleApiCaller.js.map
generated
vendored
Normal file
1
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,CACF,QAA2B,EAC3B,QAAsB;QAEtB,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,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;YACxB,MAAM,IAAI,yBAAW,CAAC,sCAAsC,CAAC,CAAC;SAC/D;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;AA5CD,0CA4CC"}
|
57
node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.d.ts
generated
vendored
Normal file
57
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;
|
||||
}
|
70
node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js
generated
vendored
Normal file
70
node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
"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 });
|
||||
const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
|
||||
const bundleApiCaller_1 = require("./bundleApiCaller");
|
||||
const bundleExecutor_1 = require("./bundleExecutor");
|
||||
/**
|
||||
* 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;
|
||||
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
node_modules/google-gax/build/src/bundlingCalls/bundleDescriptor.js.map
generated
vendored
Normal file
1
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;AAEhD;;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;YACjE,kBAAkB,GAAG,gBAAgB,CAAC;YACtC,gBAAgB,GAAG,IAAI,CAAC;SACzB;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;QAC7D,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;YACjC,OAAO,IAAI,iCAAe,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,iCAAe,CACxB,IAAI,+BAAc,CAAC,QAAQ,CAAC,aAAc,EAAE,IAAI,CAAC,CAClD,CAAC;IACJ,CAAC;CACF;AAzDD,4CAyDC"}
|
116
node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.d.ts
generated
vendored
Normal file
116
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;
|
||||
}
|
193
node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js
generated
vendored
Normal file
193
node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js
generated
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
"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 });
|
||||
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 = bundlingUtils_1.computeBundleId(request, this._descriptor.requestDiscriminatorFields);
|
||||
callback = (callback || noop);
|
||||
if (bundleId === undefined) {
|
||||
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) {
|
||||
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;
|
||||
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)) {
|
||||
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
node_modules/google-gax/build/src/bundlingCalls/bundleExecutor.js.map
generated
vendored
Normal file
1
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
28
node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.d.ts
generated
vendored
Normal file
28
node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.d.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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 { 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;
|
52
node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js
generated
vendored
Normal file
52
node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"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 });
|
||||
/**
|
||||
* Provides behavior that supports request bundling.
|
||||
*/
|
||||
const at = require("lodash.at");
|
||||
/**
|
||||
* 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 (let i = 0; i < discriminatorFields.length; ++i) {
|
||||
const id = at(obj, discriminatorFields[i])[0];
|
||||
if (id === undefined) {
|
||||
ids.push(null);
|
||||
}
|
||||
else {
|
||||
hasIds = true;
|
||||
ids.push(id);
|
||||
}
|
||||
}
|
||||
if (!hasIds) {
|
||||
return undefined;
|
||||
}
|
||||
return JSON.stringify(ids);
|
||||
}
|
||||
exports.computeBundleId = computeBundleId;
|
||||
//# sourceMappingURL=bundlingUtils.js.map
|
1
node_modules/google-gax/build/src/bundlingCalls/bundlingUtils.js.map
generated
vendored
Normal file
1
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;;AAEH;;GAEG;AAEH,gCAAiC;AAIjC;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC7B,GAAgB,EAChB,mBAA6B;IAE7B,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,GAAG,EAAE,CAAC,GAA0B,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,EAAE,KAAK,SAAS,EAAE;YACpB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAChB;aAAM;YACL,MAAM,GAAG,IAAI,CAAC;YACd,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACd;KACF;IACD,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAnBD,0CAmBC"}
|
100
node_modules/google-gax/build/src/bundlingCalls/task.d.ts
generated
vendored
Normal file
100
node_modules/google-gax/build/src/bundlingCalls/task.d.ts
generated
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
* 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 TaskElement {
|
||||
}
|
||||
export interface TaskData {
|
||||
elements: TaskElement[];
|
||||
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]: TaskElement[];
|
||||
};
|
||||
_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: TaskElement[], 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;
|
||||
}
|
226
node_modules/google-gax/build/src/bundlingCalls/task.js
generated
vendored
Normal file
226
node_modules/google-gax/build/src/bundlingCalls/task.js
generated
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
"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 });
|
||||
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(
|
||||
// tslint:disable-next-line no-any
|
||||
obj, subresponseInfo) {
|
||||
// tslint:disable-next-line no-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;
|
||||
}
|
||||
exports.deepCopyForResponse = deepCopyForResponse;
|
||||
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.apply(elements, this._data[i].elements);
|
||||
ids.push(this._data[i].callback.id);
|
||||
}
|
||||
request[this._bundledField] = elements;
|
||||
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
node_modules/google-gax/build/src/bundlingCalls/task.js.map
generated
vendored
Normal file
1
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
62
node_modules/google-gax/build/src/call.d.ts
generated
vendored
Normal file
62
node_modules/google-gax/build/src/call.d.ts
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function} PromiseCtor - A constructor for a promise that implements
|
||||
* the ES6 specification of promise.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
constructor(PromiseCtor: PromiseConstructor);
|
||||
}
|
111
node_modules/google-gax/build/src/call.js
generated
vendored
Normal file
111
node_modules/google-gax/build/src/call.js
generated
vendored
Normal file
@ -0,0 +1,111 @@
|
||||
"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 });
|
||||
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;
|
||||
}
|
||||
// tslint:disable-next-line no-any
|
||||
const canceller = func(argument, (...args) => {
|
||||
this.completed = true;
|
||||
setImmediate(this.callback, ...args);
|
||||
});
|
||||
this.cancelFunc = () => canceller.cancel();
|
||||
}
|
||||
}
|
||||
exports.OngoingCall = OngoingCall;
|
||||
class OngoingCallPromise extends OngoingCall {
|
||||
/**
|
||||
* GaxPromise is GRPCCallbackWrapper, but it holds a promise when
|
||||
* the API call finishes.
|
||||
* @param {Function} PromiseCtor - A constructor for a promise that implements
|
||||
* the ES6 specification of promise.
|
||||
* @constructor
|
||||
* @private
|
||||
*/
|
||||
// tslint:disable-next-line variable-name
|
||||
constructor(PromiseCtor) {
|
||||
let resolveCallback;
|
||||
let rejectCallback;
|
||||
const callback = (err, response, next, rawResponse) => {
|
||||
if (err) {
|
||||
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 PromiseCtor((resolve, reject) => {
|
||||
resolveCallback = resolve;
|
||||
rejectCallback = reject;
|
||||
});
|
||||
super(callback);
|
||||
this.promise = promise;
|
||||
this.promise.cancel = () => {
|
||||
this.cancel();
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.OngoingCallPromise = OngoingCallPromise;
|
||||
//# sourceMappingURL=call.js.map
|
1
node_modules/google-gax/build/src/call.js.map
generated
vendored
Normal file
1
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;YAClB,OAAO;SACR;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;aAAM;YACL,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;SACvB;IACH,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,IAA4B,EAAE,QAAqB;QACtD,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO;SACR;QACD,kCAAkC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;YAClD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,YAAY,CAAC,IAAI,CAAC,QAAS,EAAE,GAAG,IAAI,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAC7C,CAAC;CACF;AA1DD,kCA0DC;AAMD,MAAa,kBAAmB,SAAQ,WAAW;IAEjD;;;;;;;OAOG;IACH,yCAAyC;IACzC,YAAY,WAA+B;QACzC,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;gBACP,cAAc,CAAC,GAAG,CAAC,CAAC;aACrB;iBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACjC,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAI,EAAE,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC;aAChE;iBAAM;gBACL,MAAM,IAAI,yBAAW,CAAC,wCAAwC,CAAC,CAAC;aACjE;QACH,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,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;AAxCD,gDAwCC"}
|
38
node_modules/google-gax/build/src/createApiCall.d.ts
generated
vendored
Normal file
38
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): GaxCall;
|
83
node_modules/google-gax/build/src/createApiCall.js
generated
vendored
Normal file
83
node_modules/google-gax/build/src/createApiCall.js
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
"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 });
|
||||
/**
|
||||
* Provides function wrappers that implement page streaming and retrying.
|
||||
*/
|
||||
const apiCaller_1 = require("./apiCaller");
|
||||
const retries_1 = require("./normalCalls/retries");
|
||||
const timeout_1 = require("./normalCalls/timeout");
|
||||
/**
|
||||
* 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) {
|
||||
// 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 = apiCaller_1.createAPICaller(settings, descriptor);
|
||||
return (request, callOptions, callback) => {
|
||||
const thisSettings = settings.merge(callOptions);
|
||||
let currentApiCaller = apiCaller;
|
||||
// special case: if bundling is disabled for this one call,
|
||||
// use default API caller instead
|
||||
if (settings.isBundling && !thisSettings.isBundling) {
|
||||
currentApiCaller = apiCaller_1.createAPICaller(settings, undefined);
|
||||
}
|
||||
const ongoingCall = currentApiCaller.init(thisSettings, callback);
|
||||
funcPromise
|
||||
.then((func) => {
|
||||
// Initially, the function is just what gRPC server stub contains.
|
||||
func = currentApiCaller.wrap(func);
|
||||
const retry = thisSettings.retry;
|
||||
if (retry && retry.retryCodes && retry.retryCodes.length > 0) {
|
||||
return retries_1.retryable(func, thisSettings.retry, thisSettings.otherArgs);
|
||||
}
|
||||
return 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);
|
||||
};
|
||||
}
|
||||
exports.createApiCall = createApiCall;
|
||||
//# sourceMappingURL=createApiCall.js.map
|
1
node_modules/google-gax/build/src/createApiCall.js.map
generated
vendored
Normal file
1
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":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;GAEG;AAEH,2CAA4C;AAW5C,mDAAgD;AAChD,mDAAoD;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa,CAC3B,IAAkC,EAClC,QAAsB,EACtB,UAAuB;IAEvB,0EAA0E;IAC1E,0EAA0E;IAC1E,+BAA+B;IAC/B,MAAM,WAAW,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9E,yEAAyE;IACzE,MAAM,SAAS,GAAG,2BAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAExD,OAAO,CACL,OAAoB,EACpB,WAAyB,EACzB,QAAsB,EACtB,EAAE;QACF,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAEjD,IAAI,gBAAgB,GAAG,SAAS,CAAC;QACjC,2DAA2D;QAC3D,iCAAiC;QACjC,IAAI,QAAQ,CAAC,UAAU,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE;YACnD,gBAAgB,GAAG,2BAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;SACzD;QAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAClE,WAAW;aACR,IAAI,CAAC,CAAC,IAAc,EAAE,EAAE;YACvB,kEAAkE;YAClE,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;YACjC,IAAI,KAAK,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5D,OAAO,mBAAS,CACd,IAAI,EACJ,YAAY,CAAC,KAAM,EACnB,YAAY,CAAC,SAA8B,CAC5C,CAAC;aACH;YACD,OAAO,uBAAa,CAClB,IAAI,EACJ,YAAY,CAAC,OAAO,EACpB,YAAY,CAAC,SAA8B,CAC5C,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,OAA+B,EAAE,EAAE;YACxC,sEAAsE;YACtE,wCAAwC;YACxC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;QACrE,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,CAAC,EAAE;YACX,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEL,mGAAmG;QACnG,iCAAiC;QACjC,OAAO,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC;AA3DD,sCA2DC"}
|
24
node_modules/google-gax/build/src/descriptor.d.ts
generated
vendored
Normal file
24
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';
|
26
node_modules/google-gax/build/src/descriptor.js
generated
vendored
Normal file
26
node_modules/google-gax/build/src/descriptor.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 });
|
||||
var longRunningDescriptor_1 = require("./longRunningCalls/longRunningDescriptor");
|
||||
exports.LongrunningDescriptor = longRunningDescriptor_1.LongRunningDescriptor;
|
||||
var pageDescriptor_1 = require("./paginationCalls/pageDescriptor");
|
||||
exports.PageDescriptor = pageDescriptor_1.PageDescriptor;
|
||||
var streamDescriptor_1 = require("./streamingCalls/streamDescriptor");
|
||||
exports.StreamDescriptor = streamDescriptor_1.StreamDescriptor;
|
||||
var bundleDescriptor_1 = require("./bundlingCalls/bundleDescriptor");
|
||||
exports.BundleDescriptor = bundleDescriptor_1.BundleDescriptor;
|
||||
//# sourceMappingURL=descriptor.js.map
|
1
node_modules/google-gax/build/src/descriptor.js.map
generated
vendored
Normal file
1
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,wDAAA,qBAAqB,CAAyB;AACtD,mEAAgE;AAAxD,0CAAA,cAAc,CAAA;AACtB,sEAAmE;AAA3D,8CAAA,gBAAgB,CAAA;AACxB,qEAAkE;AAA1D,8CAAA,gBAAgB,CAAA"}
|
121
node_modules/google-gax/build/src/fallback.d.ts
generated
vendored
Normal file
121
node_modules/google-gax/build/src/fallback.d.ts
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import * as protobuf from 'protobufjs';
|
||||
import * as gax from './gax';
|
||||
import * as routingHeader from './routingHeader';
|
||||
import { OutgoingHttpHeaders } from 'http';
|
||||
import { GoogleAuth, OAuth2Client, Compute, JWT, UserRefreshClient } from 'google-auth-library';
|
||||
import { OperationsClientBuilder } from './operationsClient';
|
||||
import { GrpcClientOptions, ClientStubOptions } from './grpc';
|
||||
import { GaxCall, GRPCCall } from './apitypes';
|
||||
import { Descriptor } from './descriptor';
|
||||
export { PathTemplate } from './pathTemplate';
|
||||
export { routingHeader };
|
||||
export { CallSettings, constructSettings, RetryOptions } from './gax';
|
||||
export declare const version: string;
|
||||
export { BundleDescriptor, LongrunningDescriptor, PageDescriptor, StreamDescriptor, } from './descriptor';
|
||||
export { StreamType } from './streamingCalls/streaming';
|
||||
interface FallbackServiceStub {
|
||||
[method: string]: Function;
|
||||
}
|
||||
export declare class GrpcClient {
|
||||
auth?: OAuth2Client | GoogleAuth;
|
||||
authClient?: OAuth2Client | Compute | JWT | UserRefreshClient;
|
||||
promise?: PromiseConstructor;
|
||||
fallback: boolean;
|
||||
grpcVersion: string;
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options?: GrpcClientOptions | {
|
||||
auth: OAuth2Client;
|
||||
});
|
||||
/**
|
||||
* 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;
|
||||
private 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): Promise<FallbackServiceStub>;
|
||||
}
|
||||
/**
|
||||
* gRPC-fallback version of lro
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise.
|
||||
* @return {Object} A OperationsClientBuilder that will return a OperationsClient
|
||||
*/
|
||||
export declare function lro(options: GrpcClientOptions): OperationsClientBuilder;
|
||||
/**
|
||||
* 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): GaxCall;
|
||||
export { protobuf };
|
329
node_modules/google-gax/build/src/fallback.js
generated
vendored
Normal file
329
node_modules/google-gax/build/src/fallback.js
generated
vendored
Normal file
@ -0,0 +1,329 @@
|
||||
"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 });
|
||||
const protobuf = require("protobufjs");
|
||||
exports.protobuf = protobuf;
|
||||
const gax = require("./gax");
|
||||
const nodeFetch = require("node-fetch");
|
||||
const routingHeader = require("./routingHeader");
|
||||
exports.routingHeader = routingHeader;
|
||||
const abort_controller_1 = require("abort-controller");
|
||||
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 isbrowser_1 = require("./isbrowser");
|
||||
const fallbackError_1 = require("./fallbackError");
|
||||
var pathTemplate_1 = require("./pathTemplate");
|
||||
exports.PathTemplate = pathTemplate_1.PathTemplate;
|
||||
var gax_1 = require("./gax");
|
||||
exports.CallSettings = gax_1.CallSettings;
|
||||
exports.constructSettings = gax_1.constructSettings;
|
||||
exports.RetryOptions = gax_1.RetryOptions;
|
||||
exports.version = require('../../package.json').version + '-fallback';
|
||||
var descriptor_1 = require("./descriptor");
|
||||
exports.BundleDescriptor = descriptor_1.BundleDescriptor;
|
||||
exports.LongrunningDescriptor = descriptor_1.LongrunningDescriptor;
|
||||
exports.PageDescriptor = descriptor_1.PageDescriptor;
|
||||
exports.StreamDescriptor = descriptor_1.StreamDescriptor;
|
||||
var streaming_1 = require("./streamingCalls/streaming");
|
||||
exports.StreamType = streaming_1.StreamType;
|
||||
const CLIENT_VERSION_HEADER = 'x-goog-api-client';
|
||||
class GrpcClient {
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
if (isbrowser_1.isBrowser()) {
|
||||
if (!options.auth) {
|
||||
throw new Error(JSON.stringify(options) +
|
||||
'You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library.');
|
||||
}
|
||||
this.auth = options.auth;
|
||||
}
|
||||
else {
|
||||
this.auth =
|
||||
options.auth ||
|
||||
new google_auth_library_1.GoogleAuth(options);
|
||||
}
|
||||
this.promise = 'promise' in options ? options.promise : Promise;
|
||||
this.fallback = true;
|
||||
this.grpcVersion = 'fallback'; // won't be used anywhere but we need it to exist in the class
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
getServiceMethods(service) {
|
||||
const methods = Object.keys(service.methods);
|
||||
const methodsLowerCamelCase = methods.map(method => {
|
||||
return method[0].toLowerCase() + method.substring(1);
|
||||
});
|
||||
return methodsLowerCamelCase;
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
if (headers.hasOwnProperty(key)) {
|
||||
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 &&
|
||||
moreHeaders.hasOwnProperty(key)) {
|
||||
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 }, this.promise);
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
// an RPC function to be passed to protobufjs RPC API
|
||||
function serviceClientImpl(method, requestData, callback) {
|
||||
return [method, requestData, callback];
|
||||
}
|
||||
// decoder for google.rpc.Status messages
|
||||
const statusDecoder = new fallbackError_1.FallbackErrorDecoder();
|
||||
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');
|
||||
}
|
||||
const authHeader = await this.authClient.getRequestHeaders();
|
||||
const serviceStub = service.create(serviceClientImpl, false, false);
|
||||
const methods = this.getServiceMethods(service);
|
||||
const newServiceStub = service.create(serviceClientImpl, false, false);
|
||||
for (const methodName of methods) {
|
||||
newServiceStub[methodName] = (req, options, metadata, callback) => {
|
||||
const [method, requestData, serviceCallback] = serviceStub[methodName].apply(serviceStub, [req, callback]);
|
||||
// tslint:disable-next-line no-any
|
||||
let cancelController, cancelSignal;
|
||||
if (isbrowser_1.isBrowser && typeof AbortController !== 'undefined') {
|
||||
cancelController = new AbortController();
|
||||
}
|
||||
else {
|
||||
cancelController = new abort_controller_1.AbortController();
|
||||
}
|
||||
if (cancelController) {
|
||||
cancelSignal = cancelController.signal;
|
||||
}
|
||||
let cancelRequested = false;
|
||||
const headers = Object.assign({}, authHeader);
|
||||
headers['Content-Type'] = 'application/x-protobuf';
|
||||
for (const key of Object.keys(options)) {
|
||||
headers[key] = options[key][0];
|
||||
}
|
||||
const grpcFallbackProtocol = 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) {
|
||||
serviceCallback(new Error('Service path is undefined'));
|
||||
return;
|
||||
}
|
||||
let servicePort;
|
||||
const match = servicePath.match(/^(.*):(\d+)$/);
|
||||
if (match) {
|
||||
servicePath = match[1];
|
||||
servicePort = match[2];
|
||||
}
|
||||
if (opts.port) {
|
||||
servicePort = opts.port;
|
||||
}
|
||||
else if (!servicePort) {
|
||||
servicePort = 443;
|
||||
}
|
||||
const protoNamespaces = [];
|
||||
let currNamespace = method.parent;
|
||||
while (currNamespace.name !== '') {
|
||||
protoNamespaces.unshift(currNamespace.name);
|
||||
currNamespace = currNamespace.parent;
|
||||
}
|
||||
const protoServiceName = protoNamespaces.join('.');
|
||||
const rpcName = method.name;
|
||||
const url = `${grpcFallbackProtocol}://${servicePath}:${servicePort}/$rpc/${protoServiceName}/${rpcName}`;
|
||||
const fetch = isbrowser_1.isBrowser()
|
||||
? window.fetch
|
||||
: nodeFetch;
|
||||
fetch(url, {
|
||||
headers,
|
||||
method: 'post',
|
||||
body: requestData,
|
||||
signal: cancelSignal,
|
||||
})
|
||||
.then((response) => {
|
||||
return Promise.all([
|
||||
Promise.resolve(response.ok),
|
||||
response.arrayBuffer(),
|
||||
]);
|
||||
})
|
||||
.then(([ok, buffer]) => {
|
||||
if (!ok) {
|
||||
const status = statusDecoder.decodeRpcStatus(buffer);
|
||||
throw new Error(JSON.stringify(status));
|
||||
}
|
||||
serviceCallback(null, new Uint8Array(buffer));
|
||||
})
|
||||
.catch((err) => {
|
||||
if (!cancelRequested || err.name !== 'AbortError') {
|
||||
serviceCallback(err);
|
||||
}
|
||||
});
|
||||
return {
|
||||
cancel: () => {
|
||||
if (!cancelController) {
|
||||
console.warn('AbortController not found: Cancellation is not supported in this environment');
|
||||
return;
|
||||
}
|
||||
cancelRequested = true;
|
||||
cancelController.abort();
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
return newServiceStub;
|
||||
}
|
||||
}
|
||||
exports.GrpcClient = GrpcClient;
|
||||
/**
|
||||
* gRPC-fallback version of lro
|
||||
*
|
||||
* @param {Object=} options.auth - An instance of google-auth-library.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise.
|
||||
* @return {Object} A OperationsClientBuilder that will return a OperationsClient
|
||||
*/
|
||||
function lro(options) {
|
||||
options = Object.assign({ scopes: [] }, options);
|
||||
const gaxGrpc = new GrpcClient(options);
|
||||
return new operationsClient_1.OperationsClientBuilder(gaxGrpc);
|
||||
}
|
||||
exports.lro = lro;
|
||||
/**
|
||||
* 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) {
|
||||
if (descriptor && 'streaming' in descriptor) {
|
||||
return () => {
|
||||
throw new Error('The gRPC-fallback client library (e.g. browser version of the library) currently does not support streaming calls.');
|
||||
};
|
||||
}
|
||||
return createApiCall_1.createApiCall(func, settings, descriptor);
|
||||
}
|
||||
exports.createApiCall = createApiCall;
|
||||
//# sourceMappingURL=fallback.js.map
|
1
node_modules/google-gax/build/src/fallback.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/fallback.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
35
node_modules/google-gax/build/src/fallbackError.d.ts
generated
vendored
Normal file
35
node_modules/google-gax/build/src/fallbackError.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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import * as protobuf from 'protobufjs';
|
||||
interface ProtobufAny {
|
||||
type_url: string;
|
||||
value: Uint8Array;
|
||||
}
|
||||
interface DecodedRpcStatus {
|
||||
code: number;
|
||||
message: string;
|
||||
details: Array<{}>;
|
||||
}
|
||||
export declare class FallbackErrorDecoder {
|
||||
root: protobuf.Root;
|
||||
anyType: protobuf.Type;
|
||||
statusType: protobuf.Type;
|
||||
constructor();
|
||||
decodeProtobufAny(anyValue: ProtobufAny): protobuf.Message<{}>;
|
||||
decodeRpcStatus(buffer: Buffer | ArrayBuffer): DecodedRpcStatus;
|
||||
}
|
||||
export {};
|
53
node_modules/google-gax/build/src/fallbackError.js
generated
vendored
Normal file
53
node_modules/google-gax/build/src/fallbackError.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
"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 });
|
||||
const protobuf = require("protobufjs");
|
||||
class FallbackErrorDecoder {
|
||||
constructor() {
|
||||
const errorProtoJson = require('../../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 result = {
|
||||
code: status.code,
|
||||
message: status.message,
|
||||
details: status.details.map(detail => this.decodeProtobufAny(detail)),
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.FallbackErrorDecoder = FallbackErrorDecoder;
|
||||
//# sourceMappingURL=fallbackError.js.map
|
1
node_modules/google-gax/build/src/fallbackError.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/fallbackError.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"fallbackError.js","sourceRoot":"","sources":["../../src/fallbackError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,uCAAuC;AAmBvC,MAAa,oBAAoB;IAK/B;QACE,MAAM,cAAc,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC9D,CAAC;IAED,iBAAiB,CAAC,QAAqB;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CACb,gDAAgD,QAAQ,CAAC,QAAQ,EAAE,CACpE,CAAC;SACH;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;SACnD;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,yEAAyE;IACzE,eAAe,CAAC,MAA4B;QAC1C,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAA0B,CAAC;QAE5E,6DAA6D;QAC7D,iCAAiC;QACjC,MAAM,MAAM,GAAG;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;SACtE,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzCD,oDAyCC"}
|
343
node_modules/google-gax/build/src/gax.d.ts
generated
vendored
Normal file
343
node_modules/google-gax/build/src/gax.d.ts
generated
vendored
Normal file
@ -0,0 +1,343 @@
|
||||
/**
|
||||
* 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 { BundleOptions } from './bundlingCalls/bundleExecutor';
|
||||
/**
|
||||
* 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.
|
||||
* @property {Function=} promise - A constructor for a promise that implements the ES6
|
||||
* specification of promise which will be used to create promises. If not
|
||||
* provided, native promises will be used.
|
||||
* @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.
|
||||
* @typedef {Object} RetryOptions
|
||||
* @property {String[]} retryCodes
|
||||
* @property {BackoffSettings} backoffSettings
|
||||
*/
|
||||
export declare class RetryOptions {
|
||||
retryCodes: number[];
|
||||
backoffSettings: BackoffSettings;
|
||||
constructor(retryCodes: number[], backoffSettings: BackoffSettings);
|
||||
}
|
||||
/**
|
||||
* 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?: RetryOptions | null;
|
||||
autoPaginate?: boolean;
|
||||
pageToken?: string;
|
||||
pageSize?: number;
|
||||
maxResults?: number;
|
||||
maxRetries?: number;
|
||||
otherArgs?: {
|
||||
[index: string]: any;
|
||||
};
|
||||
bundleOptions?: BundleOptions | null;
|
||||
isBundling?: boolean;
|
||||
longrunning?: BackoffSettings;
|
||||
promise?: PromiseConstructor;
|
||||
}
|
||||
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;
|
||||
promise: PromiseConstructor;
|
||||
/**
|
||||
* @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.
|
||||
* @param {Function=} settings.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise. If not provided, native
|
||||
* promises will be used.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
*
|
||||
* @param {number[]} retryCodes - a list of Google API canonical error codes
|
||||
* upon which a retry should be attempted.
|
||||
* @param {BackoffSettings} backoffSettings - configures the retry
|
||||
* exponential backoff algorithm.
|
||||
* @return {RetryOptions} A new RetryOptions object.
|
||||
*
|
||||
*/
|
||||
export declare function createRetryOptions(retryCodes: number[], backoffSettings: BackoffSettings): 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.
|
||||
* @param {Function=} promise - A constructor for a promise that implements the
|
||||
* ES6 specification of promise. If not provided, native promises will be used.
|
||||
* @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?: {}, promise?: PromiseConstructor): any;
|
500
node_modules/google-gax/build/src/gax.js
generated
vendored
Normal file
500
node_modules/google-gax/build/src/gax.js
generated
vendored
Normal file
@ -0,0 +1,500 @@
|
||||
"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 });
|
||||
/**
|
||||
* 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.
|
||||
* @property {Function=} promise - A constructor for a promise that implements the ES6
|
||||
* specification of promise which will be used to create promises. If not
|
||||
* provided, native promises will be used.
|
||||
* @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.
|
||||
* @typedef {Object} RetryOptions
|
||||
* @property {String[]} retryCodes
|
||||
* @property {BackoffSettings} backoffSettings
|
||||
*/
|
||||
class RetryOptions {
|
||||
constructor(retryCodes, backoffSettings) {
|
||||
this.retryCodes = retryCodes;
|
||||
this.backoffSettings = backoffSettings;
|
||||
}
|
||||
}
|
||||
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.
|
||||
* @param {Function=} settings.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise. If not provided, native
|
||||
* promises will be used.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(settings) {
|
||||
settings = settings || {};
|
||||
this.timeout = settings.timeout || 30 * 1000;
|
||||
this.retry = settings.retry;
|
||||
this.autoPaginate =
|
||||
'autoPaginate' in settings ? settings.autoPaginate : true;
|
||||
this.pageToken = settings.pageToken;
|
||||
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.promise = 'promise' in settings ? settings.promise : Promise;
|
||||
}
|
||||
/**
|
||||
* 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 pageToken = this.pageToken;
|
||||
let pageSize = this.pageSize;
|
||||
let maxResults = this.maxResults;
|
||||
let otherArgs = this.otherArgs;
|
||||
let isBundling = this.isBundling;
|
||||
let longrunning = this.longrunning;
|
||||
let promise = this.promise;
|
||||
if ('timeout' in options) {
|
||||
timeout = options.timeout;
|
||||
}
|
||||
if ('retry' in options) {
|
||||
retry = options.retry;
|
||||
}
|
||||
if ('autoPaginate' in options && !options.autoPaginate) {
|
||||
autoPaginate = false;
|
||||
}
|
||||
if ('pageToken' in options) {
|
||||
autoPaginate = false;
|
||||
pageToken = options.pageToken;
|
||||
}
|
||||
if ('pageSize' in options) {
|
||||
pageSize = options.pageSize;
|
||||
}
|
||||
if ('maxResults' in options) {
|
||||
maxResults = options.maxResults;
|
||||
}
|
||||
if ('otherArgs' in options) {
|
||||
otherArgs = {};
|
||||
// tslint:disable-next-line forin
|
||||
for (const key in this.otherArgs) {
|
||||
otherArgs[key] = this.otherArgs[key];
|
||||
}
|
||||
// tslint:disable-next-line forin
|
||||
for (const optionsKey in options.otherArgs) {
|
||||
otherArgs[optionsKey] = options.otherArgs[optionsKey];
|
||||
}
|
||||
}
|
||||
if ('isBundling' in options) {
|
||||
isBundling = options.isBundling;
|
||||
}
|
||||
if ('maxRetries' in options) {
|
||||
retry.backoffSettings.maxRetries = options.maxRetries;
|
||||
delete retry.backoffSettings.totalTimeoutMillis;
|
||||
}
|
||||
if ('longrunning' in options) {
|
||||
longrunning = options.longrunning;
|
||||
}
|
||||
if ('promise' in options) {
|
||||
promise = options.promise;
|
||||
}
|
||||
return new CallSettings({
|
||||
timeout,
|
||||
retry,
|
||||
bundleOptions: this.bundleOptions,
|
||||
longrunning,
|
||||
autoPaginate,
|
||||
pageToken,
|
||||
pageSize,
|
||||
maxResults,
|
||||
otherArgs,
|
||||
isBundling,
|
||||
promise,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.CallSettings = CallSettings;
|
||||
/**
|
||||
* Per-call configurable settings for retrying upon transient failure.
|
||||
*
|
||||
* @param {number[]} retryCodes - a list of Google API canonical error codes
|
||||
* upon which a retry should be attempted.
|
||||
* @param {BackoffSettings} backoffSettings - configures the retry
|
||||
* exponential backoff algorithm.
|
||||
* @return {RetryOptions} A new RetryOptions object.
|
||||
*
|
||||
*/
|
||||
function createRetryOptions(retryCodes, backoffSettings) {
|
||||
return {
|
||||
retryCodes,
|
||||
backoffSettings,
|
||||
};
|
||||
}
|
||||
exports.createRetryOptions = createRetryOptions;
|
||||
/**
|
||||
* 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,
|
||||
};
|
||||
}
|
||||
exports.createBackoffSettings = createBackoffSettings;
|
||||
function createDefaultBackoffSettings() {
|
||||
return createBackoffSettings(100, 1.3, 60000, null, null, null, null);
|
||||
}
|
||||
exports.createDefaultBackoffSettings = createDefaultBackoffSettings;
|
||||
/**
|
||||
* 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,
|
||||
};
|
||||
}
|
||||
exports.createMaxRetriesBackoffSettings = createMaxRetriesBackoffSettings;
|
||||
/**
|
||||
* 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,
|
||||
};
|
||||
}
|
||||
exports.createBundleOptions = createBundleOptions;
|
||||
/**
|
||||
* 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;
|
||||
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) {
|
||||
return retry;
|
||||
}
|
||||
let codes = retry.retryCodes;
|
||||
if (overrides.retryCodes) {
|
||||
codes = overrides.retryCodes;
|
||||
}
|
||||
let backoffSettings = retry.backoffSettings;
|
||||
if (overrides.backoffSettings) {
|
||||
backoffSettings = overrides.backoffSettings;
|
||||
}
|
||||
return createRetryOptions(codes, backoffSettings);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function=} promise - A constructor for a promise that implements the
|
||||
* ES6 specification of promise. If not provided, native promises will be used.
|
||||
* @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, promise) {
|
||||
otherArgs = otherArgs || {};
|
||||
// tslint:disable-next-line no-any
|
||||
const defaults = {};
|
||||
const serviceConfig = (clientConfig.interfaces || {})[serviceName];
|
||||
if (!serviceConfig) {
|
||||
return null;
|
||||
}
|
||||
const overrides = (configOverrides.interfaces || {})[serviceName] || {};
|
||||
const methods = serviceConfig.methods;
|
||||
const overridingMethods = overrides.methods || {};
|
||||
// tslint:disable-next-line forin
|
||||
for (const methodName in methods) {
|
||||
const methodConfig = methods[methodName];
|
||||
const jsName = methodName[0].toLowerCase() + methodName.slice(1);
|
||||
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));
|
||||
}
|
||||
defaults[jsName] = new CallSettings({
|
||||
timeout,
|
||||
retry,
|
||||
bundleOptions: bundlingConfig
|
||||
? createBundleOptions(bundlingConfig)
|
||||
: null,
|
||||
otherArgs,
|
||||
promise: promise || Promise,
|
||||
});
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
exports.constructSettings = constructSettings;
|
||||
//# sourceMappingURL=gax.js.map
|
1
node_modules/google-gax/build/src/gax.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/gax.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
20
node_modules/google-gax/build/src/googleError.d.ts
generated
vendored
Normal file
20
node_modules/google-gax/build/src/googleError.d.ts
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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';
|
||||
export declare class GoogleError extends Error {
|
||||
code?: Status;
|
||||
note?: string;
|
||||
}
|
21
node_modules/google-gax/build/src/googleError.js
generated
vendored
Normal file
21
node_modules/google-gax/build/src/googleError.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"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 });
|
||||
class GoogleError extends Error {
|
||||
}
|
||||
exports.GoogleError = GoogleError;
|
||||
//# sourceMappingURL=googleError.js.map
|
1
node_modules/google-gax/build/src/googleError.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/googleError.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"googleError.js","sourceRoot":"","sources":["../../src/googleError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAIH,MAAa,WAAY,SAAQ,KAAK;CAGrC;AAHD,kCAGC"}
|
146
node_modules/google-gax/build/src/grpc.d.ts
generated
vendored
Normal file
146
node_modules/google-gax/build/src/grpc.d.ts
generated
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
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';
|
||||
export interface GrpcClientOptions extends GoogleAuthOptions {
|
||||
auth?: GoogleAuth;
|
||||
promise?: PromiseConstructor;
|
||||
grpc?: GrpcModule;
|
||||
}
|
||||
export interface MetadataValue {
|
||||
equals: Function;
|
||||
}
|
||||
export interface Metadata {
|
||||
new (): Metadata;
|
||||
set: (key: {}, value?: {} | null) => void;
|
||||
clone: () => Metadata;
|
||||
value: MetadataValue;
|
||||
get: (key: {}) => {};
|
||||
}
|
||||
export declare type GrpcModule = typeof grpc;
|
||||
export interface ClientStubOptions {
|
||||
protocol?: string;
|
||||
servicePath?: string;
|
||||
port?: number;
|
||||
sslCreds?: any;
|
||||
[index: string]: string | number | undefined | {};
|
||||
}
|
||||
export declare class ClientStub extends grpc.Client {
|
||||
[name: string]: Function;
|
||||
}
|
||||
export declare class GrpcClient {
|
||||
auth: GoogleAuth;
|
||||
promise: PromiseConstructor;
|
||||
grpc: GrpcModule;
|
||||
grpcVersion: string;
|
||||
fallback: boolean;
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise. If not provided, native
|
||||
* promises will be used.
|
||||
* @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<any>;
|
||||
/**
|
||||
* Loads the gRPC service from the proto file(s) at the given path and with the
|
||||
* given options.
|
||||
* @param filename The path to the proto file(s).
|
||||
* @param options Options for loading the proto file.
|
||||
*/
|
||||
loadFromProto(filename: string | string[], options: grpcProtoLoader.Options): grpc.GrpcObject;
|
||||
/**
|
||||
* Load grpc proto service from a filename hooking in googleapis common protos
|
||||
* when necessary.
|
||||
* @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.
|
||||
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
|
||||
* object).
|
||||
*/
|
||||
loadProto(protoPath: string, filename?: string | string[]): grpc.GrpcObject;
|
||||
static _resolveFile(protoPath: string, filename: string): string;
|
||||
metadataBuilder(headers: OutgoingHttpHeaders): (abTests?: {} | undefined, moreHeaders?: OutgoingHttpHeaders | undefined) => 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.
|
||||
* @return {Promise} A promise which resolves to a gRPC stub instance.
|
||||
*/
|
||||
createStub(CreateStub: typeof ClientStub, options: ClientStubOptions): Promise<ClientStub>;
|
||||
/**
|
||||
* 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: {
|
||||
encode: (obj: {}) => {
|
||||
finish: () => Array<{}>;
|
||||
};
|
||||
}): (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;
|
||||
}
|
277
node_modules/google-gax/build/src/grpc.js
generated
vendored
Normal file
277
node_modules/google-gax/build/src/grpc.js
generated
vendored
Normal file
@ -0,0 +1,277 @@
|
||||
"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 });
|
||||
const grpcProtoLoader = require("@grpc/proto-loader");
|
||||
const fs = require("fs");
|
||||
const google_auth_library_1 = require("google-auth-library");
|
||||
const grpc = require("@grpc/grpc-js");
|
||||
const path = require("path");
|
||||
const protobuf = require("protobufjs");
|
||||
const semver = require("semver");
|
||||
const walk = require("walkdir");
|
||||
const gax = require("./gax");
|
||||
const googleProtoFilesDir = path.join(__dirname, '..', '..', '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 COMMON_PROTO_FILES = walk
|
||||
.sync(googleProtoFilesDir)
|
||||
.filter(f => path.extname(f) === '.proto')
|
||||
.map(f => path.normalize(f).substring(googleProtoFilesDir.length + 1));
|
||||
class ClientStub extends grpc.Client {
|
||||
}
|
||||
exports.ClientStub = ClientStub;
|
||||
class GrpcClient {
|
||||
/**
|
||||
* 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.
|
||||
* @param {Function=} options.promise - A constructor for a promise that
|
||||
* implements the ES6 specification of promise. If not provided, native
|
||||
* promises will be used.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(options = {}) {
|
||||
this.auth = options.auth || new google_auth_library_1.GoogleAuth(options);
|
||||
this.promise = options.promise || Promise;
|
||||
this.fallback = false;
|
||||
if ('grpc' in options) {
|
||||
this.grpc = options.grpc;
|
||||
this.grpcVersion = '';
|
||||
}
|
||||
else {
|
||||
if (semver.gte(process.version, '8.13.0')) {
|
||||
this.grpc = grpc;
|
||||
this.grpcVersion = require('@grpc/grpc-js/package.json').version;
|
||||
}
|
||||
else {
|
||||
const errorMessage = 'To use @grpc/grpc-js you must run your code on Node.js v8.13.0 or newer. Please see README if you need to use an older version. ' +
|
||||
'https://github.com/googleapis/gax-nodejs/blob/master/README.md';
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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 = grpc.credentials.createSsl();
|
||||
const client = await this.auth.getClient();
|
||||
const credentials = grpc.credentials.combineChannelCredentials(sslCreds, grpc.credentials.createFromGoogleCredential(client));
|
||||
return credentials;
|
||||
}
|
||||
/**
|
||||
* Loads the gRPC service from the proto file(s) at the given path and with the
|
||||
* given options.
|
||||
* @param filename The path to the proto file(s).
|
||||
* @param options Options for loading the proto file.
|
||||
*/
|
||||
loadFromProto(filename, options) {
|
||||
const packageDef = grpcProtoLoader.loadSync(filename, options);
|
||||
return this.grpc.loadPackageDefinition(packageDef);
|
||||
}
|
||||
/**
|
||||
* Load grpc proto service from a filename hooking in googleapis common protos
|
||||
* when necessary.
|
||||
* @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.
|
||||
* @return {Object<string, *>} The gRPC loaded result (the toplevel namespace
|
||||
* object).
|
||||
*/
|
||||
loadProto(protoPath, filename) {
|
||||
if (!filename) {
|
||||
filename = path.basename(protoPath);
|
||||
protoPath = path.dirname(protoPath);
|
||||
}
|
||||
if (Array.isArray(filename) && filename.length === 0) {
|
||||
return {};
|
||||
}
|
||||
// This set of @grpc/proto-loader options
|
||||
// 'closely approximates the existing behavior of grpc.load'
|
||||
const includeDirs = INCLUDE_DIRS.slice();
|
||||
includeDirs.unshift(protoPath);
|
||||
const options = {
|
||||
keepCase: false,
|
||||
longs: String,
|
||||
enums: String,
|
||||
defaults: true,
|
||||
oneofs: true,
|
||||
includeDirs,
|
||||
};
|
||||
return this.loadFromProto(filename, options);
|
||||
}
|
||||
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);
|
||||
}
|
||||
metadataBuilder(headers) {
|
||||
const Metadata = this.grpc.Metadata;
|
||||
const baseMetadata = new Metadata();
|
||||
// tslint:disable-next-line forin
|
||||
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' &&
|
||||
moreHeaders.hasOwnProperty(key)) {
|
||||
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) }, this.promise);
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* @return {Promise} A promise which resolves to a gRPC stub instance.
|
||||
*/
|
||||
// tslint:disable-next-line variable-name
|
||||
async createStub(CreateStub, options) {
|
||||
const serviceAddress = options.servicePath + ':' + options.port;
|
||||
const creds = await this._getCredentials(options);
|
||||
const grpcOptions = {};
|
||||
Object.keys(options).forEach(key => {
|
||||
if (key.startsWith('grpc.')) {
|
||||
grpcOptions[key.replace(/^grpc\./, '')] = options[key];
|
||||
}
|
||||
});
|
||||
const stub = new CreateStub(serviceAddress, creds, grpcOptions);
|
||||
return stub;
|
||||
}
|
||||
/**
|
||||
* 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 function getByteLength(obj) {
|
||||
return message.encode(obj).finish().length;
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.GrpcClient = GrpcClient;
|
||||
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
node_modules/google-gax/build/src/grpc.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/grpc.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
81
node_modules/google-gax/build/src/index.d.ts
generated
vendored
Normal file
81
node_modules/google-gax/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* 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 { GrpcClient, GrpcClientOptions, ClientStubOptions } from './grpc';
|
||||
import { GoogleAuthOptions } from 'google-auth-library';
|
||||
import { LongrunningDescriptor, PageDescriptor, StreamDescriptor } from './descriptor';
|
||||
import * as longrunning from './longRunningCalls/longrunning';
|
||||
import * as operationProtos from '../protos/operations';
|
||||
import * as operationsClient from './operationsClient';
|
||||
import * as routingHeader from './routingHeader';
|
||||
import * as gax from './gax';
|
||||
export { GoogleAuth, GoogleAuthOptions } from 'google-auth-library';
|
||||
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 };
|
||||
export { OperationsClient } from './operationsClient';
|
||||
export declare const createByteLengthFunction: typeof GrpcClient.createByteLengthFunction;
|
||||
export declare const version: any;
|
||||
import * as protobuf from 'protobufjs';
|
||||
export { protobuf };
|
||||
import * as fallback from './fallback';
|
||||
export { fallback };
|
||||
export { APICallback, GRPCCallResult, ServerStreamingCall, ClientStreamingCall, BiDiStreamingCall, UnaryCall, GRPCCall, GaxCall, CancellableStream, } from './apitypes';
|
||||
export interface ClientOptions extends GrpcClientOptions, GoogleAuthOptions, ClientStubOptions {
|
||||
libName?: string;
|
||||
libVersion?: string;
|
||||
clientConfig?: gax.ClientConfig;
|
||||
fallback?: boolean;
|
||||
apiEndpoint?: string;
|
||||
}
|
||||
export interface Descriptors {
|
||||
page: {
|
||||
[name: string]: PageDescriptor;
|
||||
};
|
||||
stream: {
|
||||
[name: string]: StreamDescriptor;
|
||||
};
|
||||
longrunning: {
|
||||
[name: string]: LongrunningDescriptor;
|
||||
};
|
||||
}
|
||||
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;
|
||||
}
|
73
node_modules/google-gax/build/src/index.js
generated
vendored
Normal file
73
node_modules/google-gax/build/src/index.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 });
|
||||
const grpc_1 = require("./grpc");
|
||||
const operationsClient = require("./operationsClient");
|
||||
const routingHeader = require("./routingHeader");
|
||||
exports.routingHeader = routingHeader;
|
||||
var google_auth_library_1 = require("google-auth-library");
|
||||
exports.GoogleAuth = google_auth_library_1.GoogleAuth;
|
||||
var call_1 = require("./call");
|
||||
exports.OngoingCall = call_1.OngoingCall;
|
||||
var createApiCall_1 = require("./createApiCall");
|
||||
exports.createApiCall = createApiCall_1.createApiCall;
|
||||
var descriptor_1 = require("./descriptor");
|
||||
exports.BundleDescriptor = descriptor_1.BundleDescriptor;
|
||||
exports.LongrunningDescriptor = descriptor_1.LongrunningDescriptor;
|
||||
exports.PageDescriptor = descriptor_1.PageDescriptor;
|
||||
exports.StreamDescriptor = descriptor_1.StreamDescriptor;
|
||||
var gax_1 = require("./gax");
|
||||
exports.CallSettings = gax_1.CallSettings;
|
||||
exports.constructSettings = gax_1.constructSettings;
|
||||
exports.RetryOptions = gax_1.RetryOptions;
|
||||
exports.createRetryOptions = gax_1.createRetryOptions;
|
||||
exports.createBundleOptions = gax_1.createBundleOptions;
|
||||
exports.createBackoffSettings = gax_1.createBackoffSettings;
|
||||
exports.createDefaultBackoffSettings = gax_1.createDefaultBackoffSettings;
|
||||
exports.createMaxRetriesBackoffSettings = gax_1.createMaxRetriesBackoffSettings;
|
||||
var googleError_1 = require("./googleError");
|
||||
exports.GoogleError = googleError_1.GoogleError;
|
||||
var grpc_2 = require("./grpc");
|
||||
exports.ClientStub = grpc_2.ClientStub;
|
||||
exports.GoogleProtoFilesRoot = grpc_2.GoogleProtoFilesRoot;
|
||||
exports.GrpcClient = grpc_2.GrpcClient;
|
||||
var longrunning_1 = require("./longRunningCalls/longrunning");
|
||||
exports.Operation = longrunning_1.Operation;
|
||||
exports.operation = longrunning_1.operation;
|
||||
var pathTemplate_1 = require("./pathTemplate");
|
||||
exports.PathTemplate = pathTemplate_1.PathTemplate;
|
||||
var status_1 = require("./status");
|
||||
exports.Status = status_1.Status;
|
||||
var streaming_1 = require("./streamingCalls/streaming");
|
||||
exports.StreamType = 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);
|
||||
}
|
||||
exports.lro = lro;
|
||||
lro.SERVICE_ADDRESS = operationsClient.SERVICE_ADDRESS;
|
||||
lro.ALL_SCOPES = operationsClient.ALL_SCOPES;
|
||||
var operationsClient_1 = require("./operationsClient");
|
||||
exports.OperationsClient = operationsClient_1.OperationsClient;
|
||||
exports.createByteLengthFunction = grpc_1.GrpcClient.createByteLengthFunction;
|
||||
exports.version = require('../../package.json').version;
|
||||
const protobuf = require("protobufjs");
|
||||
exports.protobuf = protobuf;
|
||||
const fallback = require("./fallback");
|
||||
exports.fallback = fallback;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/google-gax/build/src/index.js.map
generated
vendored
Normal file
1
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;;AAEH,iCAAwE;AASxE,uDAAuD;AACvD,iDAAiD;AAwCzC,sCAAa;AArCrB,2DAAkE;AAA1D,2CAAA,UAAU,CAAA;AAClB,+BAAuD;AAA3B,6BAAA,WAAW,CAAA;AACvC,iDAA8C;AAAtC,wCAAA,aAAa,CAAA;AACrB,2CAKsB;AAJpB,wCAAA,gBAAgB,CAAA;AAChB,6CAAA,qBAAqB,CAAA;AACrB,sCAAA,cAAc,CAAA;AACd,wCAAA,gBAAgB,CAAA;AAElB,6BAYe;AAVb,6BAAA,YAAY,CAAA;AAEZ,kCAAA,iBAAiB,CAAA;AACjB,6BAAA,YAAY,CAAA;AAEZ,mCAAA,kBAAkB,CAAA;AAClB,oCAAA,mBAAmB,CAAA;AACnB,sCAAA,qBAAqB,CAAA;AACrB,6CAAA,4BAA4B,CAAA;AAC5B,gDAAA,+BAA+B,CAAA;AAEjC,6CAA0C;AAAlC,oCAAA,WAAW,CAAA;AACnB,+BASgB;AARd,4BAAA,UAAU,CAAA;AAEV,sCAAA,oBAAoB,CAAA;AACpB,4BAAA,UAAU,CAAA;AAMZ,8DAAoE;AAA5D,kCAAA,SAAS,CAAA;AAAE,kCAAA,SAAS,CAAA;AAC5B,+CAA4C;AAApC,sCAAA,YAAY,CAAA;AACpB,mCAAgC;AAAxB,0BAAA,MAAM,CAAA;AACd,wDAAsD;AAA9C,iCAAA,UAAU,CAAA;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;AAKO,kBAAG;AAHX,GAAG,CAAC,eAAe,GAAG,gBAAgB,CAAC,eAAe,CAAC;AACvD,GAAG,CAAC,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC;AAG7C,uDAAoD;AAA5C,8CAAA,gBAAgB,CAAA;AACX,QAAA,wBAAwB,GAAG,iBAAU,CAAC,wBAAwB,CAAC;AAC/D,QAAA,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAE7D,uCAAuC;AAC/B,4BAAQ;AAEhB,uCAAuC;AAC/B,4BAAQ"}
|
16
node_modules/google-gax/build/src/isbrowser.d.ts
generated
vendored
Normal file
16
node_modules/google-gax/build/src/isbrowser.d.ts
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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 declare function isBrowser(): boolean;
|
22
node_modules/google-gax/build/src/isbrowser.js
generated
vendored
Normal file
22
node_modules/google-gax/build/src/isbrowser.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"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 });
|
||||
function isBrowser() {
|
||||
return typeof window !== 'undefined';
|
||||
}
|
||||
exports.isBrowser = isBrowser;
|
||||
//# sourceMappingURL=isbrowser.js.map
|
1
node_modules/google-gax/build/src/isbrowser.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/isbrowser.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"isbrowser.js","sourceRoot":"","sources":["../../src/isbrowser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,SAAgB,SAAS;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACvC,CAAC;AAFD,8BAEC"}
|
43
node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.d.ts
generated
vendored
Normal file
43
node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.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 { APICaller, ApiCallerSettings } from '../apiCaller';
|
||||
import { APICallback, GRPCCall, SimpleCallbackFunction } from '../apitypes';
|
||||
import { OngoingCall, OngoingCallPromise } from '../call';
|
||||
import { CallOptions } from '../gax';
|
||||
import { GoogleError } from '../googleError';
|
||||
import { Operation } from './longrunning';
|
||||
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(settings: ApiCallerSettings, 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").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | Operation | null | undefined]>;
|
||||
}
|
71
node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js
generated
vendored
Normal file
71
node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
"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 });
|
||||
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(settings, callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise(settings.promise);
|
||||
}
|
||||
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 = 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
node_modules/google-gax/build/src/longRunningCalls/longRunningApiCaller.js.map
generated
vendored
Normal file
1
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,gCAMgB;AAGhB,+CAAwC;AAIxC,MAAa,oBAAoB;IAE/B;;;;;;;;OAQG;IACH,YAAY,qBAA4C;QACtD,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;IACrD,CAAC;IAED,IAAI,CACF,QAA2B,EAC3B,QAAsB;QAEtB,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,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;YACpB,eAAe,GAAG,kCAA4B,EAAE,CAAC;SAClD;QAED,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACzD,OAAO,OAAO,CACZ,QAAQ,EACR,CAAC,GAAuB,EAAE,WAAkC,EAAE,EAAE;YAC9D,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAwB,CAAC,CAAC;gBACpD,OAAO;aACR;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;AA/ED,oDA+EC"}
|
36
node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.d.ts
generated
vendored
Normal file
36
node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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 { CallSettings } from '../gax';
|
||||
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(settings: CallSettings): LongrunningApiCaller;
|
||||
}
|
33
node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js
generated
vendored
Normal file
33
node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"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 });
|
||||
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(settings) {
|
||||
return new longRunningApiCaller_1.LongrunningApiCaller(this);
|
||||
}
|
||||
}
|
||||
exports.LongRunningDescriptor = LongRunningDescriptor;
|
||||
//# sourceMappingURL=longRunningDescriptor.js.map
|
1
node_modules/google-gax/build/src/longRunningCalls/longRunningDescriptor.js.map
generated
vendored
Normal file
1
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;;AAOH,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,CAAC,QAAsB;QACjC,OAAO,IAAI,2CAAoB,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAlBD,sDAkBC"}
|
135
node_modules/google-gax/build/src/longRunningCalls/longrunning.d.ts
generated
vendored
Normal file
135
node_modules/google-gax/build/src/longRunningCalls/longrunning.d.ts
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
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;
|
||||
}
|
||||
declare 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(): CancellablePromise<[import("../apitypes").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | Operation | null | undefined]>;
|
||||
/**
|
||||
* 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 {};
|
272
node_modules/google-gax/build/src/longRunningCalls/longrunning.js
generated
vendored
Normal file
272
node_modules/google-gax/build/src/longRunningCalls/longrunning.js
generated
vendored
Normal file
@ -0,0 +1,272 @@
|
||||
"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 });
|
||||
const events_1 = require("events");
|
||||
const status_1 = require("../status");
|
||||
const googleError_1 = require("../googleError");
|
||||
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;
|
||||
return operationsClient.cancelOperation({
|
||||
name: this.latestResponse.name,
|
||||
});
|
||||
}
|
||||
getOperation(callback) {
|
||||
const self = this;
|
||||
const operationsClient = this.longrunningDescriptor.operationsClient;
|
||||
function promisifyResponse() {
|
||||
if (!callback) {
|
||||
// tslint:disable-next-line variable-name
|
||||
const PromiseCtor = self._callOptions.promise;
|
||||
return new PromiseCtor((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();
|
||||
}
|
||||
this.currentCallPromise_ = operationsClient.getOperation({ name: this.latestResponse.name }, this._callOptions);
|
||||
const noCallbackPromise = this.currentCallPromise_.then(responses => {
|
||||
self.latestResponse = responses[0];
|
||||
self._unpackResponse(responses[0], callback);
|
||||
return promisifyResponse();
|
||||
});
|
||||
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_() {
|
||||
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;
|
||||
}
|
||||
// tslint:disable-next-line no-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).
|
||||
// Don't hang forever in this case.
|
||||
if (rawResponse.done) {
|
||||
const error = new googleError_1.GoogleError('Long running operation has finished but there was no result');
|
||||
error.code = status_1.Status.UNKNOWN;
|
||||
setImmediate(emit, 'error', error);
|
||||
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() {
|
||||
// tslint:disable-next-line variable-name
|
||||
const PromiseCtor = this._callOptions.promise;
|
||||
return new PromiseCtor((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);
|
||||
}
|
||||
exports.operation = operation;
|
||||
//# sourceMappingURL=longrunning.js.map
|
1
node_modules/google-gax/build/src/longRunningCalls/longrunning.js.map
generated
vendored
Normal file
1
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
31
node_modules/google-gax/build/src/normalCalls/normalApiCaller.d.ts
generated
vendored
Normal file
31
node_modules/google-gax/build/src/normalCalls/normalApiCaller.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 { APICaller, ApiCallerSettings } 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(settings: ApiCallerSettings, 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").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import("..").Operation | null | undefined]>;
|
||||
}
|
43
node_modules/google-gax/build/src/normalCalls/normalApiCaller.js
generated
vendored
Normal file
43
node_modules/google-gax/build/src/normalCalls/normalApiCaller.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
"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 });
|
||||
const call_1 = require("../call");
|
||||
/**
|
||||
* Creates an API caller for regular unary methods.
|
||||
*/
|
||||
class NormalApiCaller {
|
||||
init(settings, callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise(settings.promise);
|
||||
}
|
||||
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
node_modules/google-gax/build/src/normalCalls/normalApiCaller.js.map
generated
vendored
Normal file
1
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,CACF,QAA2B,EAC3B,QAAsB;QAEtB,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,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;AA/BD,0CA+BC"}
|
31
node_modules/google-gax/build/src/normalCalls/retries.d.ts
generated
vendored
Normal file
31
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): SimpleCallbackFunction;
|
132
node_modules/google-gax/build/src/normalCalls/retries.js
generated
vendored
Normal file
132
node_modules/google-gax/build/src/normalCalls/retries.js
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
"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 });
|
||||
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) {
|
||||
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() {
|
||||
timeoutId = null;
|
||||
if (deadline && now.getTime() >= deadline) {
|
||||
const error = new googleError_1.GoogleError('Retry total timeout exceeded 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 before any ' +
|
||||
'response was received');
|
||||
error.code = status_1.Status.DEADLINE_EXCEEDED;
|
||||
callback(error);
|
||||
return;
|
||||
}
|
||||
retries++;
|
||||
const toCall = timeout_1.addTimeoutArg(func, timeout, otherArgs);
|
||||
canceller = toCall(argument, (err, response, next, rawResponse) => {
|
||||
if (!err) {
|
||||
callback(null, response, next, rawResponse);
|
||||
return;
|
||||
}
|
||||
canceller = null;
|
||||
if (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();
|
||||
}, toSleep);
|
||||
}
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.retryable = retryable;
|
||||
//# sourceMappingURL=retries.js.map
|
1
node_modules/google-gax/build/src/normalCalls/retries.js.map
generated
vendored
Normal file
1
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":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,sCAAiC;AAWjC,gDAA2C;AAE3C,uCAAwC;AAExC;;;;;;;;;;;;GAYG;AACH,SAAgB,SAAS,CACvB,IAAc,EACd,KAAmB,EACnB,SAA4B;IAE5B,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,CAAC,oBAAoB,CAAC;IAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC;IAC3D,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,CAAC,oBAAoB,CAAC;IAC/D,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,mBAAmB,CAAC;IAE7D,IAAI,KAAK,GAAG,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC;IAC1D,IAAI,OAAO,GAAG,KAAK,CAAC,eAAe,CAAC,uBAAuB,CAAC;IAE5D;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAqB,EAAE,QAAqB,EAAE,EAAE;QACtD,IAAI,SAAgC,CAAC;QACrC,IAAI,SAA+C,CAAC;QACpD,IAAI,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,QAAgB,CAAC;QACrB,IAAI,KAAK,CAAC,eAAe,CAAC,kBAAkB,EAAE;YAC5C,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,eAAe,CAAC,kBAAkB,CAAC;SACrE;QACD,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,UAAW,CAAC;QACrD,uDAAuD;QAEvD,gDAAgD;QAChD,SAAS,MAAM;YACb,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,QAAQ,EAAE;gBACzC,MAAM,KAAK,GAAG,IAAI,yBAAW,CAC3B,+DAA+D,CAChE,CAAC;gBACF,KAAK,CAAC,IAAI,GAAG,eAAM,CAAC,iBAAiB,CAAC;gBACtC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAChB,OAAO;aACR;YAED,IAAI,OAAO,IAAI,OAAO,IAAI,UAAU,EAAE;gBACpC,MAAM,KAAK,GAAG,IAAI,yBAAW,CAC3B,gDAAgD;oBAC9C,uBAAuB,CAC1B,CAAC;gBACF,KAAK,CAAC,IAAI,GAAG,eAAM,CAAC,iBAAiB,CAAC;gBACtC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAChB,OAAO;aACR;YAED,OAAO,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,uBAAa,CAAC,IAAI,EAAE,OAAQ,EAAE,SAAS,CAAC,CAAC;YACxD,SAAS,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;gBAChE,IAAI,CAAC,GAAG,EAAE;oBACR,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;oBAC5C,OAAO;iBACR;gBACD,SAAS,GAAG,IAAI,CAAC;gBACjB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAI,CAAC,IAAK,CAAC,GAAG,CAAC,EAAE;oBAC5C,GAAG,CAAC,IAAI;wBACN,8CAA8C;4BAC9C,6BAA6B,CAAC;oBAChC,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACf;qBAAM;oBACL,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;oBACtC,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;wBAC1B,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;wBACjB,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAC;wBAC9C,MAAM,UAAU,GACd,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;wBACrD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/C,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC5D,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;wBACxD,MAAM,EAAE,CAAC;oBACX,CAAC,EAAE,OAAO,CAAC,CAAC;iBACb;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,UAAU,IAAI,QAAS,EAAE;YAC3B,MAAM,KAAK,GAAG,IAAI,yBAAW,CAC3B,oDAAoD;gBAClD,qBAAqB,CACxB,CAAC;YACF,KAAK,CAAC,IAAI,GAAG,eAAM,CAAC,gBAAgB,CAAC;YACrC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM;YACL,MAAM,EAAE,CAAC;SACV;QAED,OAAO;YACL,MAAM;gBACJ,IAAI,SAAS,EAAE;oBACb,YAAY,CAAC,SAAS,CAAC,CAAC;iBACzB;gBACD,IAAI,SAAS,EAAE;oBACb,SAAS,CAAC,MAAM,EAAE,CAAC;iBACpB;qBAAM;oBACL,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,WAAW,CAAC,CAAC;oBAC3C,KAAK,CAAC,IAAI,GAAG,eAAM,CAAC,SAAS,CAAC;oBAC9B,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACjB;YACH,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA/GD,8BA+GC"}
|
32
node_modules/google-gax/build/src/normalCalls/timeout.d.ts
generated
vendored
Normal file
32
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
node_modules/google-gax/build/src/normalCalls/timeout.js
generated
vendored
Normal file
47
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 });
|
||||
/**
|
||||
* 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);
|
||||
};
|
||||
}
|
||||
exports.addTimeoutArg = addTimeoutArg;
|
||||
//# sourceMappingURL=timeout.js.map
|
1
node_modules/google-gax/build/src/normalCalls/timeout.js.map
generated
vendored
Normal file
1
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;;AASH;;;;;;;;;;;;;;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;AAjBD,sCAiBC"}
|
291
node_modules/google-gax/build/src/operationsClient.d.ts
generated
vendored
Normal file
291
node_modules/google-gax/build/src/operationsClient.d.ts
generated
vendored
Normal file
@ -0,0 +1,291 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { GoogleAuth, OAuth2Client } from 'google-auth-library';
|
||||
import { ProjectIdCallback } from 'google-auth-library/build/src/auth/googleauth';
|
||||
import * as gax from './gax';
|
||||
import { GrpcClient } from './grpc';
|
||||
import { GrpcClient as FallbackGrpcClient } from './fallback';
|
||||
import { APICallback } from './apitypes';
|
||||
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[];
|
||||
export interface OperationsClientOptions {
|
||||
libName?: string;
|
||||
libVersion?: string;
|
||||
clientConfig?: gax.ClientConfig;
|
||||
fallback?: boolean;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
private _innerApiCalls;
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient, operationsProtos: any, options: OperationsClientOptions);
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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: {}, options: {}, callback?: APICallback): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import(".").Operation | null | undefined]> | import("./apitypes").CancellableStream;
|
||||
/**
|
||||
* 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: {}, options: {}, callback: APICallback): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import(".").Operation | null | undefined]> | import("./apitypes").CancellableStream;
|
||||
/**
|
||||
* 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: gax.CallSettings): import("stream").Transform;
|
||||
/**
|
||||
* 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: {}, options?: {}, callback?: APICallback): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import(".").Operation | null | undefined]> | import("./apitypes").CancellableStream;
|
||||
/**
|
||||
* 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: {}, options: {}, callback: APICallback): import("./call").CancellablePromise<[import("./apitypes").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import(".").Operation | null | undefined]> | import("./apitypes").CancellableStream;
|
||||
}
|
||||
export declare class OperationsClientBuilder {
|
||||
operationsClient: (opts: OperationsClientOptions) => OperationsClient;
|
||||
/**
|
||||
* Builds a new Operations Client
|
||||
* @param gaxGrpc {GrpcClient}
|
||||
*/
|
||||
constructor(gaxGrpc: GrpcClient | FallbackGrpcClient);
|
||||
}
|
384
node_modules/google-gax/build/src/operationsClient.js
generated
vendored
Normal file
384
node_modules/google-gax/build/src/operationsClient.js
generated
vendored
Normal file
@ -0,0 +1,384 @@
|
||||
"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 });
|
||||
const path = require("path");
|
||||
const createApiCall_1 = require("./createApiCall");
|
||||
const descriptor_1 = require("./descriptor");
|
||||
const configData = require('./operations_client_config');
|
||||
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';
|
||||
const PAGE_DESCRIPTORS = {
|
||||
listOperations: new descriptor_1.PageDescriptor('pageToken', 'nextPageToken', 'operations'),
|
||||
};
|
||||
/**
|
||||
* 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,
|
||||
// tslint:disable-next-line no-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 = {};
|
||||
// Put together the "service stub" for
|
||||
// google.longrunning.Operations.
|
||||
const 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 = operationsStub.then(stub => (...args) => {
|
||||
return stub[methodName].apply(stub, args);
|
||||
}, err => () => {
|
||||
throw err;
|
||||
});
|
||||
this._innerApiCalls[methodName] = createApiCall_1.createApiCall(innerCallPromise, defaults[methodName], PAGE_DESCRIPTORS[methodName]);
|
||||
}
|
||||
}
|
||||
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
|
||||
/**
|
||||
* 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, options, callback) {
|
||||
if (options instanceof Function && callback === undefined) {
|
||||
return this._innerApiCalls.getOperation(request, {}, options);
|
||||
}
|
||||
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, options, callback) {
|
||||
if (options instanceof Function && callback === undefined) {
|
||||
return this._innerApiCalls.listOperations(request, {}, options);
|
||||
}
|
||||
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) {
|
||||
return PAGE_DESCRIPTORS.listOperations.createStream(this._innerApiCalls.listOperations, request, options);
|
||||
}
|
||||
/**
|
||||
* 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, options, callback) {
|
||||
if (options instanceof Function && callback === undefined) {
|
||||
return this._innerApiCalls.cancelOperation(request, {}, options);
|
||||
}
|
||||
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, options, callback) {
|
||||
if (options instanceof Function && callback === undefined) {
|
||||
return this._innerApiCalls.deleteOperation(request, {}, options);
|
||||
}
|
||||
options = options || {};
|
||||
return this._innerApiCalls.deleteOperation(request, options, callback);
|
||||
}
|
||||
}
|
||||
exports.OperationsClient = OperationsClient;
|
||||
class OperationsClientBuilder {
|
||||
/**
|
||||
* Builds a new Operations Client
|
||||
* @param gaxGrpc {GrpcClient}
|
||||
*/
|
||||
constructor(gaxGrpc) {
|
||||
// tslint:disable-next-line no-any
|
||||
let operationsProtos; // loaded protos have any type
|
||||
if (gaxGrpc.fallback) {
|
||||
const protoJson = require('../../protos/operations.json');
|
||||
operationsProtos = gaxGrpc.loadProto(protoJson);
|
||||
}
|
||||
else {
|
||||
operationsProtos = gaxGrpc.loadProto(path.join(__dirname, '..', '..', 'protos', 'operations.json'));
|
||||
Object.assign(this, operationsProtos.google.longrunning);
|
||||
}
|
||||
/**
|
||||
* 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 = true;
|
||||
}
|
||||
return new OperationsClient(gaxGrpc, operationsProtos, opts);
|
||||
};
|
||||
Object.assign(this.operationsClient, OperationsClient);
|
||||
}
|
||||
}
|
||||
exports.OperationsClientBuilder = OperationsClientBuilder;
|
||||
//# sourceMappingURL=operationsClient.js.map
|
1
node_modules/google-gax/build/src/operationsClient.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/operationsClient.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"operationsClient.js","sourceRoot":"","sources":["../../src/operationsClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAIH,6BAA6B;AAG7B,mDAA8C;AAC9C,6CAA4C;AAM5C,MAAM,UAAU,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAE5C,QAAA,eAAe,GAAG,4BAA4B,CAAC;AAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAEtD,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAC5C,MAAM,gBAAgB,GAAuC;IAC3D,cAAc,EAAE,IAAI,2BAAc,CAChC,WAAW,EACX,eAAe,EACf,YAAY,CACb;CACF,CAAC;AAEF;;;GAGG;AACU,QAAA,UAAU,GAAa,EAAE,CAAC;AASvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,gBAAgB;IAI3B,YACE,OAAwC;IACxC,kCAAkC;IAClC,gBAAqB,EACrB,OAAgC;QAEhC,MAAM,IAAI,GAAgD,MAAM,CAAC,MAAM,CACrE;YACE,WAAW,EAAE,uBAAe;YAC5B,IAAI,EAAE,oBAAoB;YAC1B,YAAY,EAAE,EAAE;SACjB,EACD,OAAO,CACR,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,EAAE;YACnC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;SAC5D;QACD,eAAe,CAAC,IAAI,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,eAAe,CAAC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC;SAC3C;aAAM;YACL,eAAe,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;SACrD;QAED,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CACxC,+BAA+B,EAC/B,UAAU,EACV,IAAI,CAAC,YAAY,IAAI,EAAE,EACvB,EAAC,mBAAmB,EAAE,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAC,CACjD,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAEzB,oEAAoE;QACpE,gEAAgE;QAChE,4DAA4D;QAC5D,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QAEzB,sCAAsC;QACtC,iCAAiC;QACjC,MAAM,cAAc,GAAG,OAAO,CAAC,UAAU,CACvC,IAAI,CAAC,QAAQ;YACX,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,+BAA+B,CAAC;YACjE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,EAClD,IAAI,CACoC,CAAC;QAC3C,MAAM,qBAAqB,GAAG;YAC5B,cAAc;YACd,gBAAgB;YAChB,iBAAiB;YACjB,iBAAiB;SAClB,CAAC;QAEF,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE;YAC9C,MAAM,gBAAgB,GAAG,cAAc,CAAC,IAAI,CAC1C,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE;gBAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC5C,CAAC,EACD,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE;gBACV,MAAM,GAAG,CAAC;YACZ,CAAC,CACF,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,6BAAa,CAC7C,gBAAgB,EAChB,QAAQ,CAAC,UAAU,CAAC,EACpB,gBAAgB,CAAC,UAAU,CAAC,CAC7B,CAAC;SACH;IACH,CAAC;IASD,YAAY,CAAC,QAA4B;QACvC,IAAI,IAAI,CAAC,IAAI,IAAI,cAAc,IAAI,IAAI,CAAC,IAAI,EAAE;YAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAS,CAAC,CAAC;SAC1C;QACD,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;SACrD;aAAM;YACL,OAAO,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC;SACvD;IACH,CAAC;IAED,gBAAgB;IAEhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,YAAY,CAAC,OAAW,EAAE,OAAW,EAAE,QAAsB;QAC3D,IAAI,OAAO,YAAY,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YACzD,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CACrC,OAAO,EACP,EAAE,EACF,OAAsB,CACvB,CAAC;SACH;QACD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4EG;IACH,cAAc,CAAC,OAAW,EAAE,OAAW,EAAE,QAAqB;QAC5D,IAAI,OAAO,YAAY,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YACzD,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CACvC,OAAO,EACP,EAAE,EACF,OAAsB,CACvB,CAAC;SACH;QACD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,oBAAoB,CAAC,OAAW,EAAE,OAAyB;QACzD,OAAO,gBAAgB,CAAC,cAAc,CAAC,YAAY,CACjD,IAAI,CAAC,cAAc,CAAC,cAAc,EAClC,OAAO,EACP,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,eAAe,CAAC,OAAW,EAAE,OAAY,EAAE,QAAsB;QAC/D,IAAI,OAAO,YAAY,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YACzD,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CACxC,OAAO,EACP,EAAE,EACF,OAAsB,CACvB,CAAC;SACH;QACD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,eAAe,CAAC,OAAW,EAAE,OAAW,EAAE,QAAqB;QAC7D,IAAI,OAAO,YAAY,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YACzD,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CACxC,OAAO,EACP,EAAE,EACF,OAAsB,CACvB,CAAC;SACH;QACD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;CACF;AArWD,4CAqWC;AAED,MAAa,uBAAuB;IAGlC;;;OAGG;IACH,YAAY,OAAwC;QAClD,kCAAkC;QAClC,IAAI,gBAAqB,CAAC,CAAC,8BAA8B;QACzD,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpB,MAAM,SAAS,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;YAC1D,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;SACjD;aAAM;YACL,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAClC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAC9D,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC1D;QAED;;;;;;;;WAQG;QACH,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE;YAC7B,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;aACtB;YACD,OAAO,IAAI,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QAC/D,CAAC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACzD,CAAC;CACF;AArCD,0DAqCC"}
|
46
node_modules/google-gax/build/src/operations_client_config.json
generated
vendored
Normal file
46
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
node_modules/google-gax/build/src/paginationCalls/pageDescriptor.d.ts
generated
vendored
Normal file
36
node_modules/google-gax/build/src/paginationCalls/pageDescriptor.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { Transform } from 'stream';
|
||||
import { APICaller } from '../apiCaller';
|
||||
import { GaxCall } from '../apitypes';
|
||||
import { Descriptor } from '../descriptor';
|
||||
import { CallSettings } from '../gax';
|
||||
/**
|
||||
* 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;
|
||||
getApiCaller(settings: CallSettings): APICaller;
|
||||
}
|
94
node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js
generated
vendored
Normal file
94
node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
"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 });
|
||||
const ended = require("is-stream-ended");
|
||||
const stream_1 = require("stream");
|
||||
const normalApiCaller_1 = require("../normalCalls/normalApiCaller");
|
||||
const pagedApiCaller_1 = require("./pagedApiCaller");
|
||||
/**
|
||||
* 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) {
|
||||
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) {
|
||||
if (err) {
|
||||
stream.emit('error', err);
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < resources.length; ++i) {
|
||||
if (ended(stream)) {
|
||||
return;
|
||||
}
|
||||
if (resources[i] === null) {
|
||||
continue;
|
||||
}
|
||||
stream.push(resources[i]);
|
||||
pushCount++;
|
||||
if (pushCount === maxResults) {
|
||||
stream.end();
|
||||
}
|
||||
}
|
||||
if (ended(stream)) {
|
||||
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;
|
||||
}
|
||||
getApiCaller(settings) {
|
||||
if (!settings.autoPaginate) {
|
||||
return new normalApiCaller_1.NormalApiCaller();
|
||||
}
|
||||
return new pagedApiCaller_1.PagedApiCaller(this);
|
||||
}
|
||||
}
|
||||
exports.PageDescriptor = PageDescriptor;
|
||||
//# sourceMappingURL=pageDescriptor.js.map
|
1
node_modules/google-gax/build/src/paginationCalls/pageDescriptor.js.map
generated
vendored
Normal file
1
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":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,yCAAyC;AACzC,mCAA8C;AAM9C,oEAA+D;AAE/D,qDAAgD;AAEhD;;GAEG;AACH,MAAa,cAAc;IAMzB,YACE,qBAA6B,EAC7B,sBAA8B,EAC9B,aAAqB;QAErB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,YAAY,CACV,OAAgB,EAChB,OAAW,EACX,OAAqB;QAErB,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;QACnD,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAC,YAAY,EAAE,KAAK,EAAC,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,YAAY,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrE,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,SAAS,QAAQ,CAAC,GAAiB,EAAE,SAAoB,EAAE,IAAQ;YACjE,IAAI,GAAG,EAAE;gBACP,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC1B,OAAO;aACR;YACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBACzC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;oBACjB,OAAO;iBACR;gBACD,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;oBACzB,SAAS;iBACV;gBACD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1B,SAAS,EAAE,CAAC;gBACZ,IAAI,SAAS,KAAK,UAAU,EAAE;oBAC5B,MAAM,CAAC,GAAG,EAAE,CAAC;iBACd;aACF;YACD,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;gBACjB,OAAO;aACR;YACD,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,CAAC,GAAG,EAAE,CAAC;gBACb,OAAO;aACR;YACD,yEAAyE;YACzE,0EAA0E;YAC1E,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,OAAO,OAAO,CAAC,SAAS,CAAC;aAC1B;YACD,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE;gBACrB,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,GAAG,KAAK,CAAC;aACjB;iBAAM;gBACL,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aAChD;QACH,CAAC;QACD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,GAAG,IAAI,CAAC;gBACf,OAAO,CAAC,OAAO,EAAE,OAAO,EAAG,QAAmC,CAAC,CAAC;aACjE;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;YAC1B,OAAO,IAAI,iCAAe,EAAE,CAAC;SAC9B;QACD,OAAO,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAjFD,wCAiFC"}
|
83
node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.d.ts
generated
vendored
Normal file
83
node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.d.ts
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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, ApiCallerSettings } 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(settings: ApiCallerSettings, 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`, autoPaginate`, `pageToken`, and `pageSize`
|
||||
* (they are all 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").ResponseType, {
|
||||
[index: string]: string | number | {};
|
||||
} | null | undefined, {} | import("..").Operation | null | undefined]>;
|
||||
}
|
140
node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js
generated
vendored
Normal file
140
node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js
generated
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
"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 });
|
||||
const call_1 = require("../call");
|
||||
const googleError_1 = require("../googleError");
|
||||
const resourceCollector_1 = require("./resourceCollector");
|
||||
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) {
|
||||
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(settings, callback) {
|
||||
if (callback) {
|
||||
return new call_1.OngoingCall(callback);
|
||||
}
|
||||
return new call_1.OngoingCallPromise(settings.promise);
|
||||
}
|
||||
/**
|
||||
* 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`, autoPaginate`, `pageToken`, and `pageSize`
|
||||
* (they are all 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 object contain pageToken or pageSize, override the corresponding fields in the request object.
|
||||
if (settings.pageToken) {
|
||||
request[this.pageDescriptor.requestPageTokenField] = settings.pageToken;
|
||||
}
|
||||
if (settings.pageSize) {
|
||||
request[this.pageDescriptor.requestPageSizeField] = settings.pageSize;
|
||||
}
|
||||
if (!settings.autoPaginate) {
|
||||
// they don't want auto-pagination this time - okay, just call once
|
||||
ongoingCall.call(apiCall, request);
|
||||
return;
|
||||
}
|
||||
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
node_modules/google-gax/build/src/paginationCalls/pagedApiCaller.js.map
generated
vendored
Normal file
1
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":";AAAA;;;;;;;;;;;;;;GAcG;;AAWH,kCAAwD;AAExD,gDAA2C;AAE3C,2DAAsD;AAEtD,MAAa,cAAc;IAEzB;;;;;;;OAOG;IACH,YAAY,cAA8B;QACxC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;OAYG;IACK,6BAA6B,CACnC,OAA4B,EAC5B,QAAqB;QAErB,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC;QAC5D,MAAM,0BAA0B,GAAG,IAAI,CAAC,cAAc;aACnD,sBAAsB,CAAC;QAC1B,MAAM,yBAAyB,GAAG,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC;QAC5E,OAAO,CAAC,GAAiB,EAAE,QAAyC,EAAE,EAAE;YACtE,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACd,OAAO;aACR;YACD,IAAI,CAAC,OAAO,EAAE;gBACZ,QAAQ,CACN,IAAI,yBAAW,CAAC,kDAAkD,CAAC,CACpE,CAAC;gBACF,OAAO;aACR;YACD,IAAI,CAAC,QAAQ,EAAE;gBACb,QAAQ,CACN,IAAI,yBAAW,CAAC,mDAAmD,CAAC,CACrE,CAAC;gBACF,OAAO;aACR;YACD,MAAM,SAAS,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;YAC9C,MAAM,SAAS,GAAG,QAAQ,CAAC,0BAA0B,CAAC,CAAC;YACvD,IAAI,eAAe,GAAG,IAAI,CAAC;YAC3B,IAAI,SAAS,EAAE;gBACb,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC7C,eAAe,CAAC,yBAAyB,CAAC,GAAG,SAAS,CAAC;aACxD;YACD,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,IAAc;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,OAAO,SAAS,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ;YAC/D,OAAQ,IAAkB,CACxB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACvD,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,QAA2B,EAAE,QAAsB;QACtD,IAAI,QAAQ,EAAE;YACZ,OAAO,IAAI,kBAAW,CAAC,QAAQ,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,yBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAI,CACF,OAA+B,EAC/B,OAAoB,EACpB,QAAqB,EACrB,WAAwB;QAExB,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAErC,6GAA6G;QAC7G,IAAI,QAAQ,CAAC,SAAS,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC;SACzE;QACD,IAAI,QAAQ,CAAC,QAAQ,EAAE;YACrB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,oBAAqB,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;SACxE;QAED,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE;YAC1B,mEAAmE;YACnE,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACnC,OAAO;SACR;QAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QAE7C,MAAM,iBAAiB,GAAG,IAAI,qCAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACrE,iBAAiB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAC7C,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,EAClD,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CACjC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,WAA+B,EAAE,GAAgB;QACpD,WAAW,CAAC,QAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,WAA+B;QACpC,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;CACF;AApJD,wCAoJC"}
|
34
node_modules/google-gax/build/src/paginationCalls/resourceCollector.d.ts
generated
vendored
Normal file
34
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<{}>>;
|
||||
}
|
66
node_modules/google-gax/build/src/paginationCalls/resourceCollector.js
generated
vendored
Normal file
66
node_modules/google-gax/build/src/paginationCalls/resourceCollector.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
"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 });
|
||||
/**
|
||||
* 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, rawResponse) {
|
||||
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
node_modules/google-gax/build/src/paginationCalls/resourceCollector.js.map
generated
vendored
Normal file
1
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,EACpC,WAA4B;QAE5B,IAAI,GAAG,EAAE;YACP,8DAA8D;YAC9D,IAAI,CAAC,cAAe,CAAC,GAAG,CAAC,CAAC;YAC1B,OAAO;SACR;QAED,mBAAmB;QACnB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;YAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,EAAE;gBAC7C,eAAe,GAAG,IAAI,CAAC;gBACvB,MAAM;aACP;SACF;QAED,YAAY;QACZ,IAAI,CAAC,eAAe,EAAE;YACpB,IAAI,CAAC,eAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACtC,OAAO;SACR;QAED,yBAAyB;QACzB,MAAM,QAAQ,GAAG,CACf,GAAG,IAAqE,EACxE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5B,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IACxD,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,IAAqE,EACxE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;YAC5B,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3DD,8CA2DC"}
|
36
node_modules/google-gax/build/src/parserExtras.d.ts
generated
vendored
Normal file
36
node_modules/google-gax/build/src/parserExtras.d.ts
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 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 { Segment } from './pathTemplate';
|
||||
export declare const BINDING = 1;
|
||||
export declare const END_BINDING = 2;
|
||||
export declare const TERMINAL = 3;
|
||||
/**
|
||||
* Completes the parsing of the segments
|
||||
*
|
||||
* Validates them, and transforms them into the object used by the
|
||||
* PathTemplate class.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Segments[]} segments the parsed segments
|
||||
* @param {Object} initializes the attributes of a PathTemplate
|
||||
* @return {Object} Returns segments and size
|
||||
* @throws {TypeError} if multiple path wildcards exist
|
||||
*/
|
||||
export declare function finishParse(segments: Segment[]): {
|
||||
segments: Segment[];
|
||||
size: number;
|
||||
};
|
94
node_modules/google-gax/build/src/parserExtras.js
generated
vendored
Normal file
94
node_modules/google-gax/build/src/parserExtras.js
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
"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 });
|
||||
const util = require("util");
|
||||
/* constants used in the pegjs parser */
|
||||
exports.BINDING = 1;
|
||||
exports.END_BINDING = 2;
|
||||
exports.TERMINAL = 3;
|
||||
/**
|
||||
* Checks that segments only has one terminal segment that is a path wildcard.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Segments[]} segments the parsed segments
|
||||
* @throws {TypeError} if there are too many
|
||||
*/
|
||||
function allowOnePathWildcard(segments) {
|
||||
let hasPathWildcard = false;
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
const s = segments[i];
|
||||
if (s.kind !== exports.TERMINAL || s.literal !== '**') {
|
||||
continue;
|
||||
}
|
||||
if (hasPathWildcard) {
|
||||
const tooManyWildcards = 'cannot contain more than one path wildcard';
|
||||
throw new TypeError(tooManyWildcards);
|
||||
}
|
||||
hasPathWildcard = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Counts the number of terminal segments.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Segments[]} segments the parsed segments
|
||||
* @return {number} the number of terminal segments in the template
|
||||
*/
|
||||
function countTerminals(segments) {
|
||||
return segments.filter(x => x.kind === exports.TERMINAL).length;
|
||||
}
|
||||
/**
|
||||
* Updates missing literals of each of the binding segments.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Segments[]} segments the parsed segments
|
||||
*/
|
||||
function updateBindingLiterals(segments) {
|
||||
let bindingIndex = 0;
|
||||
segments.forEach(s => {
|
||||
if (s.kind === exports.BINDING && !s.literal) {
|
||||
s.literal = util.format('$%d', bindingIndex);
|
||||
bindingIndex += 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Completes the parsing of the segments
|
||||
*
|
||||
* Validates them, and transforms them into the object used by the
|
||||
* PathTemplate class.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {Segments[]} segments the parsed segments
|
||||
* @param {Object} initializes the attributes of a PathTemplate
|
||||
* @return {Object} Returns segments and size
|
||||
* @throws {TypeError} if multiple path wildcards exist
|
||||
*/
|
||||
function finishParse(segments) {
|
||||
allowOnePathWildcard(segments);
|
||||
updateBindingLiterals(segments);
|
||||
return {
|
||||
segments,
|
||||
size: countTerminals(segments),
|
||||
};
|
||||
}
|
||||
exports.finishParse = finishParse;
|
||||
//# sourceMappingURL=parserExtras.js.map
|
1
node_modules/google-gax/build/src/parserExtras.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/parserExtras.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"parserExtras.js","sourceRoot":"","sources":["../../src/parserExtras.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,6BAA6B;AAG7B,wCAAwC;AAC3B,QAAA,OAAO,GAAG,CAAC,CAAC;AACZ,QAAA,WAAW,GAAG,CAAC,CAAC;AAChB,QAAA,QAAQ,GAAG,CAAC,CAAC;AAE1B;;;;;;;GAOG;AACH,SAAS,oBAAoB,CAAC,QAAmB;IAC/C,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAQ,IAAI,CAAC,CAAC,OAAO,KAAK,IAAI,EAAE;YAC7C,SAAS;SACV;QACD,IAAI,eAAe,EAAE;YACnB,MAAM,gBAAgB,GAAG,4CAA4C,CAAC;YACtE,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;SACvC;QACD,eAAe,GAAG,IAAI,CAAC;KACxB;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,QAAmB;IACzC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAQ,CAAC,CAAC,MAAM,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,QAAmB;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACnB,IAAI,CAAC,CAAC,IAAI,KAAK,eAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;YACpC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YAC7C,YAAY,IAAI,CAAC,CAAC;SACnB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,WAAW,CAAC,QAAmB;IAC7C,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/B,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO;QACL,QAAQ;QACR,IAAI,EAAE,cAAc,CAAC,QAAQ,CAAC;KAC/B,CAAC;AACJ,CAAC;AAPD,kCAOC"}
|
60
node_modules/google-gax/build/src/pathTemplate.d.ts
generated
vendored
Normal file
60
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 ParseResult {
|
||||
size: number;
|
||||
segments: Segment[];
|
||||
}
|
||||
export interface Segment {
|
||||
kind: number;
|
||||
literal: string;
|
||||
}
|
||||
export interface Bindings {
|
||||
[index: string]: string;
|
||||
}
|
||||
export declare class PathTemplate {
|
||||
private readonly parseResult;
|
||||
readonly size: number;
|
||||
readonly segments: Segment[];
|
||||
/**
|
||||
* @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;
|
||||
}
|
159
node_modules/google-gax/build/src/pathTemplate.js
generated
vendored
Normal file
159
node_modules/google-gax/build/src/pathTemplate.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 });
|
||||
/*
|
||||
* Path template utility.
|
||||
*/
|
||||
const has = require("lodash.has");
|
||||
const util = require("util");
|
||||
const extras = require("./parserExtras");
|
||||
const parser = require('./pathTemplateParser');
|
||||
class PathTemplate {
|
||||
/**
|
||||
* @param {String} data the of the template
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(data) {
|
||||
this.parseResult = extras.finishParse(parser.parse(data));
|
||||
}
|
||||
get size() {
|
||||
return this.parseResult.size;
|
||||
}
|
||||
get segments() {
|
||||
return this.parseResult.segments;
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
const pathSegments = path.split('/');
|
||||
const bindings = {};
|
||||
let segmentCount = this.size;
|
||||
let current;
|
||||
let index = 0;
|
||||
this.segments.forEach(segment => {
|
||||
if (index > pathSegments.length) {
|
||||
return;
|
||||
}
|
||||
if (segment.kind === extras.BINDING) {
|
||||
current = segment.literal;
|
||||
}
|
||||
else if (segment.kind === extras.TERMINAL) {
|
||||
if (segment.literal === '*') {
|
||||
bindings[current] = pathSegments[index];
|
||||
index += 1;
|
||||
}
|
||||
else if (segment.literal === '**') {
|
||||
const size = pathSegments.length - segmentCount + 1;
|
||||
segmentCount += size - 1;
|
||||
bindings[current] = pathSegments.slice(index, index + size).join('/');
|
||||
index += size;
|
||||
}
|
||||
else if (segment.literal === pathSegments[index]) {
|
||||
index += 1;
|
||||
}
|
||||
else {
|
||||
const msg = util.format("mismatched literal (index=%d): '%s' != '%s'", index, segment.literal, pathSegments[index]);
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (index !== pathSegments.length || index !== segmentCount) {
|
||||
const msg = util.format('match error: could not instantiate a path template from %s', path);
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
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) {
|
||||
const out = [];
|
||||
let inABinding = false;
|
||||
this.segments.forEach(segment => {
|
||||
if (segment.kind === extras.BINDING) {
|
||||
if (!has(bindings, segment.literal)) {
|
||||
const msg = util.format('Value for key %s is not provided in %s', segment.literal, bindings);
|
||||
throw new TypeError(msg);
|
||||
}
|
||||
const tmp = new PathTemplate(bindings[segment.literal]);
|
||||
Array.prototype.push.apply(out, tmp.segments);
|
||||
inABinding = true;
|
||||
}
|
||||
else if (segment.kind === extras.END_BINDING) {
|
||||
inABinding = false;
|
||||
}
|
||||
else if (inABinding) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
out.push(segment);
|
||||
}
|
||||
});
|
||||
const result = formatSegments(out);
|
||||
this.match(result);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Renders the path template.
|
||||
*
|
||||
* @return {string} contains const names matched to binding values
|
||||
*/
|
||||
inspect() {
|
||||
return formatSegments(this.segments);
|
||||
}
|
||||
}
|
||||
exports.PathTemplate = PathTemplate;
|
||||
/**
|
||||
* Creates the string representattion for the segments.
|
||||
* @param {Object[]} segments - The array of segments.
|
||||
* @return {string} - A string representing segments in the path template
|
||||
* format.
|
||||
*/
|
||||
function formatSegments(segments) {
|
||||
let out = '';
|
||||
let slash = true;
|
||||
segments.forEach(segment => {
|
||||
if (segment.kind === extras.TERMINAL) {
|
||||
if (slash) {
|
||||
out += '/';
|
||||
}
|
||||
out += segment.literal;
|
||||
return;
|
||||
}
|
||||
slash = true;
|
||||
if (segment.kind === extras.BINDING) {
|
||||
out += '/{' + segment.literal + '=';
|
||||
slash = false;
|
||||
}
|
||||
else {
|
||||
out += segment.literal + '}';
|
||||
}
|
||||
});
|
||||
return out.substring(1);
|
||||
}
|
||||
//# sourceMappingURL=pathTemplate.js.map
|
1
node_modules/google-gax/build/src/pathTemplate.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/pathTemplate.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"pathTemplate.js","sourceRoot":"","sources":["../../src/pathTemplate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;GAEG;AAEH,kCAAmC;AACnC,6BAA6B;AAC7B,yCAAyC;AACzC,MAAM,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAgB/C,MAAa,YAAY;IAWvB;;;;OAIG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,CAAC;IAfD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC;IACnC,CAAC;IAWD;;;;;;OAMG;IACH,KAAK,CAAC,IAAY;QAChB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,IAAI,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC;QAC7B,IAAI,OAAe,CAAC;QACpB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC9B,IAAI,KAAK,GAAG,YAAY,CAAC,MAAM,EAAE;gBAC/B,OAAO;aACR;YACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE;gBACnC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;aAC3B;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,QAAQ,EAAE;gBAC3C,IAAI,OAAO,CAAC,OAAO,KAAK,GAAG,EAAE;oBAC3B,QAAQ,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;oBACxC,KAAK,IAAI,CAAC,CAAC;iBACZ;qBAAM,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE;oBACnC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC;oBACpD,YAAY,IAAI,IAAI,GAAG,CAAC,CAAC;oBACzB,QAAQ,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACtE,KAAK,IAAI,IAAI,CAAC;iBACf;qBAAM,IAAI,OAAO,CAAC,OAAO,KAAK,YAAY,CAAC,KAAK,CAAC,EAAE;oBAClD,KAAK,IAAI,CAAC,CAAC;iBACZ;qBAAM;oBACL,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CACrB,6CAA6C,EAC7C,KAAK,EACL,OAAO,CAAC,OAAO,EACf,YAAY,CAAC,KAAK,CAAC,CACpB,CAAC;oBACF,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;iBAC1B;aACF;QACH,CAAC,CAAC,CAAC;QACH,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,IAAI,KAAK,KAAK,YAAY,EAAE;YAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CACrB,4DAA4D,EAC5D,IAAI,CACL,CAAC;YACF,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;SAC1B;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,QAAkB;QACvB,MAAM,GAAG,GAAc,EAAE,CAAC;QAC1B,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC9B,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE;gBACnC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;oBACnC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CACrB,wCAAwC,EACxC,OAAO,CAAC,OAAO,EACf,QAAQ,CACT,CAAC;oBACF,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;iBAC1B;gBACD,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxD,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC9C,UAAU,GAAG,IAAI,CAAC;aACnB;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,WAAW,EAAE;gBAC9C,UAAU,GAAG,KAAK,CAAC;aACpB;iBAAM,IAAI,UAAU,EAAE;gBACrB,OAAO;aACR;iBAAM;gBACL,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aACnB;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;CACF;AArHD,oCAqHC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CAAC,QAAmB;IACzC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,QAAQ,EAAE;YACpC,IAAI,KAAK,EAAE;gBACT,GAAG,IAAI,GAAG,CAAC;aACZ;YACD,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;YACvB,OAAO;SACR;QACD,KAAK,GAAG,IAAI,CAAC;QACb,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE;YACnC,GAAG,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;YACpC,KAAK,GAAG,KAAK,CAAC;SACf;aAAM;YACL,GAAG,IAAI,OAAO,CAAC,OAAO,GAAG,GAAG,CAAC;SAC9B;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
673
node_modules/google-gax/build/src/pathTemplateParser.js
generated
vendored
Normal file
673
node_modules/google-gax/build/src/pathTemplateParser.js
generated
vendored
Normal file
@ -0,0 +1,673 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = (() => {
|
||||
/*
|
||||
* Generated by PEG.js 0.9.0.
|
||||
*
|
||||
* http://pegjs.org/
|
||||
*/
|
||||
|
||||
function peg$subclass(child, parent) {
|
||||
function ctor() {
|
||||
this.constructor = child;
|
||||
}
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
}
|
||||
|
||||
function peg$SyntaxError(message, expected, found, location) {
|
||||
this.message = message;
|
||||
this.expected = expected;
|
||||
this.found = found;
|
||||
this.location = location;
|
||||
this.name = 'SyntaxError';
|
||||
|
||||
if (typeof Error.captureStackTrace === 'function') {
|
||||
Error.captureStackTrace(this, peg$SyntaxError);
|
||||
}
|
||||
}
|
||||
|
||||
peg$subclass(peg$SyntaxError, Error);
|
||||
|
||||
function peg$parse(input) {
|
||||
const options = arguments.length > 1 ? arguments[1] : {};
|
||||
const parser = this;
|
||||
const peg$FAILED = {};
|
||||
const peg$startRuleFunctions = {template: peg$parsetemplate};
|
||||
let peg$startRuleFunction = peg$parsetemplate;
|
||||
const peg$c0 = '/';
|
||||
const peg$c1 = {type: 'literal', value: '/', description: '"/"'};
|
||||
const peg$c2 = segments => {
|
||||
return segments;
|
||||
};
|
||||
const peg$c3 = (s, segments) => {
|
||||
return s.concat(segments);
|
||||
};
|
||||
const peg$c4 = s => {
|
||||
return s;
|
||||
};
|
||||
const peg$c5 = '{';
|
||||
const peg$c6 = {type: 'literal', value: '{', description: '"{"'};
|
||||
const peg$c7 = '=';
|
||||
const peg$c8 = {type: 'literal', value: '=', description: '"="'};
|
||||
const peg$c9 = '}';
|
||||
const peg$c10 = {type: 'literal', value: '}', description: '"}"'};
|
||||
const peg$c11 = (l, segments) => {
|
||||
return [
|
||||
{kind: extras.BINDING, literal: l},
|
||||
segments,
|
||||
{kind: extras.END_BINDING, literal: ''},
|
||||
].reduce((a, b) => a.concat(b), []);
|
||||
};
|
||||
const peg$c12 = l => {
|
||||
return [
|
||||
{kind: extras.BINDING, literal: l},
|
||||
{kind: extras.TERMINAL, literal: '*'},
|
||||
{kind: extras.END_BINDING, literal: ''},
|
||||
];
|
||||
};
|
||||
const peg$c13 = (t, segments) => {
|
||||
return t.concat(segments);
|
||||
};
|
||||
const peg$c14 = t => {
|
||||
if (t[0].literal === '*' || t[0].literal === '**') {
|
||||
return [
|
||||
{
|
||||
kind: extras.BINDING,
|
||||
},
|
||||
t[0],
|
||||
{kind: extras.END_BINDING, literal: ''},
|
||||
];
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
const peg$c15 = '**';
|
||||
const peg$c16 = {type: 'literal', value: '**', description: '"**"'};
|
||||
const peg$c17 = '*';
|
||||
const peg$c18 = {type: 'literal', value: '*', description: '"*"'};
|
||||
const peg$c19 = l => {
|
||||
return [{kind: extras.TERMINAL, literal: l}];
|
||||
};
|
||||
const peg$c20 = /^[^*=}{\/]/;
|
||||
const peg$c21 = {type: 'class', value: '[^*=}{/]', description: '[^*=}{/]'};
|
||||
const peg$c22 = cs => {
|
||||
return cs.join('');
|
||||
};
|
||||
let peg$currPos = 0;
|
||||
let peg$savedPos = 0;
|
||||
const peg$posDetailsCache = [{line: 1, column: 1, seenCR: false}];
|
||||
let peg$maxFailPos = 0;
|
||||
let peg$maxFailExpected = [];
|
||||
const peg$silentFails = 0;
|
||||
let peg$result;
|
||||
|
||||
if ('startRule' in options) {
|
||||
if (!(options.startRule in peg$startRuleFunctions)) {
|
||||
throw new Error(
|
||||
'Can\'t start parsing from rule "' + options.startRule + '".'
|
||||
);
|
||||
}
|
||||
|
||||
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
||||
}
|
||||
|
||||
function text() {
|
||||
return input.substring(peg$savedPos, peg$currPos);
|
||||
}
|
||||
|
||||
function location() {
|
||||
return peg$computeLocation(peg$savedPos, peg$currPos);
|
||||
}
|
||||
|
||||
function expected(description) {
|
||||
throw peg$buildException(
|
||||
null,
|
||||
[{type: 'other', description}],
|
||||
input.substring(peg$savedPos, peg$currPos),
|
||||
peg$computeLocation(peg$savedPos, peg$currPos)
|
||||
);
|
||||
}
|
||||
|
||||
function error(message) {
|
||||
throw peg$buildException(
|
||||
message,
|
||||
null,
|
||||
input.substring(peg$savedPos, peg$currPos),
|
||||
peg$computeLocation(peg$savedPos, peg$currPos)
|
||||
);
|
||||
}
|
||||
|
||||
function peg$computePosDetails(pos) {
|
||||
let details = peg$posDetailsCache[pos],
|
||||
p,
|
||||
ch;
|
||||
|
||||
if (details) {
|
||||
return details;
|
||||
} else {
|
||||
p = pos - 1;
|
||||
while (!peg$posDetailsCache[p]) {
|
||||
p--;
|
||||
}
|
||||
|
||||
details = peg$posDetailsCache[p];
|
||||
details = {
|
||||
line: details.line,
|
||||
column: details.column,
|
||||
seenCR: details.seenCR,
|
||||
};
|
||||
|
||||
while (p < pos) {
|
||||
ch = input.charAt(p);
|
||||
if (ch === '\n') {
|
||||
if (!details.seenCR) {
|
||||
details.line++;
|
||||
}
|
||||
details.column = 1;
|
||||
details.seenCR = false;
|
||||
} else if (ch === '\r' || ch === '\u2028' || ch === '\u2029') {
|
||||
details.line++;
|
||||
details.column = 1;
|
||||
details.seenCR = true;
|
||||
} else {
|
||||
details.column++;
|
||||
details.seenCR = false;
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
|
||||
peg$posDetailsCache[pos] = details;
|
||||
return details;
|
||||
}
|
||||
}
|
||||
|
||||
function peg$computeLocation(startPos, endPos) {
|
||||
const startPosDetails = peg$computePosDetails(startPos),
|
||||
endPosDetails = peg$computePosDetails(endPos);
|
||||
|
||||
return {
|
||||
start: {
|
||||
offset: startPos,
|
||||
line: startPosDetails.line,
|
||||
column: startPosDetails.column,
|
||||
},
|
||||
end: {
|
||||
offset: endPos,
|
||||
line: endPosDetails.line,
|
||||
column: endPosDetails.column,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function peg$fail(expected) {
|
||||
if (peg$currPos < peg$maxFailPos) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (peg$currPos > peg$maxFailPos) {
|
||||
peg$maxFailPos = peg$currPos;
|
||||
peg$maxFailExpected = [];
|
||||
}
|
||||
|
||||
peg$maxFailExpected.push(expected);
|
||||
}
|
||||
|
||||
function peg$buildException(message, expected, found, location) {
|
||||
function cleanupExpected(expected) {
|
||||
let i = 1;
|
||||
|
||||
expected.sort((a, b) => {
|
||||
if (a.description < b.description) {
|
||||
return -1;
|
||||
} else if (a.description > b.description) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
while (i < expected.length) {
|
||||
if (expected[i - 1] === expected[i]) {
|
||||
expected.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildMessage(expected, found) {
|
||||
function stringEscape(s) {
|
||||
function hex(ch) {
|
||||
return ch
|
||||
.charCodeAt(0)
|
||||
.toString(16)
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
return s
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/"/g, '\\"')
|
||||
.replace(/\x08/g, '\\b')
|
||||
.replace(/\t/g, '\\t')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/\f/g, '\\f')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, ch => {
|
||||
return '\\x0' + hex(ch);
|
||||
})
|
||||
.replace(/[\x10-\x1F\x80-\xFF]/g, ch => {
|
||||
return '\\x' + hex(ch);
|
||||
})
|
||||
.replace(/[\u0100-\u0FFF]/g, ch => {
|
||||
return '\\u0' + hex(ch);
|
||||
})
|
||||
.replace(/[\u1000-\uFFFF]/g, ch => {
|
||||
return '\\u' + hex(ch);
|
||||
});
|
||||
}
|
||||
|
||||
const expectedDescs = new Array(expected.length);
|
||||
let expectedDesc, foundDesc, i;
|
||||
|
||||
for (i = 0; i < expected.length; i++) {
|
||||
expectedDescs[i] = expected[i].description;
|
||||
}
|
||||
|
||||
expectedDesc =
|
||||
expected.length > 1
|
||||
? expectedDescs.slice(0, -1).join(', ') +
|
||||
' or ' +
|
||||
expectedDescs[expected.length - 1]
|
||||
: expectedDescs[0];
|
||||
|
||||
foundDesc = found ? '"' + stringEscape(found) + '"' : 'end of input';
|
||||
|
||||
return 'Expected ' + expectedDesc + ' but ' + foundDesc + ' found.';
|
||||
}
|
||||
|
||||
if (expected !== null) {
|
||||
cleanupExpected(expected);
|
||||
}
|
||||
|
||||
return new peg$SyntaxError(
|
||||
message !== null ? message : buildMessage(expected, found),
|
||||
expected,
|
||||
found,
|
||||
location
|
||||
);
|
||||
}
|
||||
|
||||
function peg$parsetemplate() {
|
||||
let s0, s1, s2;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.charCodeAt(peg$currPos) === 47) {
|
||||
s1 = peg$c0;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c1);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parsebound_segments();
|
||||
if (s2 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c2(s2);
|
||||
s0 = s1;
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parsebound_segments();
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c2(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsebound_segments() {
|
||||
let s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parsebound_segment();
|
||||
if (s1 !== peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 47) {
|
||||
s2 = peg$c0;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c1);
|
||||
}
|
||||
}
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = peg$parsebound_segments();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c3(s1, s3);
|
||||
s0 = s1;
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$parsebound_segment();
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsebound_segment() {
|
||||
let s0, s1;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parsebound_terminal();
|
||||
if (s1 === peg$FAILED) {
|
||||
s1 = peg$parsevariable();
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c4(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsevariable() {
|
||||
let s0, s1, s2, s3, s4, s5;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.charCodeAt(peg$currPos) === 123) {
|
||||
s1 = peg$c5;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c6);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parseliteral();
|
||||
if (s2 !== peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 61) {
|
||||
s3 = peg$c7;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c8);
|
||||
}
|
||||
}
|
||||
if (s3 !== peg$FAILED) {
|
||||
s4 = peg$parseunbound_segments();
|
||||
if (s4 !== peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 125) {
|
||||
s5 = peg$c9;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s5 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c10);
|
||||
}
|
||||
}
|
||||
if (s5 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c11(s2, s4);
|
||||
s0 = s1;
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$currPos;
|
||||
if (input.charCodeAt(peg$currPos) === 123) {
|
||||
s1 = peg$c5;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c6);
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
s2 = peg$parseliteral();
|
||||
if (s2 !== peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 125) {
|
||||
s3 = peg$c9;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s3 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c10);
|
||||
}
|
||||
}
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c12(s2);
|
||||
s0 = s1;
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseunbound_segments() {
|
||||
let s0, s1, s2, s3;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parseunbound_terminal();
|
||||
if (s1 !== peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 47) {
|
||||
s2 = peg$c0;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c1);
|
||||
}
|
||||
}
|
||||
if (s2 !== peg$FAILED) {
|
||||
s3 = peg$parseunbound_segments();
|
||||
if (s3 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c13(s1, s3);
|
||||
s0 = s1;
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
} else {
|
||||
peg$currPos = s0;
|
||||
s0 = peg$FAILED;
|
||||
}
|
||||
if (s0 === peg$FAILED) {
|
||||
s0 = peg$parseunbound_terminal();
|
||||
}
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parsebound_terminal() {
|
||||
let s0, s1;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = peg$parseunbound_terminal();
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c14(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseunbound_terminal() {
|
||||
let s0, s1;
|
||||
|
||||
s0 = peg$currPos;
|
||||
if (input.substr(peg$currPos, 2) === peg$c15) {
|
||||
s1 = peg$c15;
|
||||
peg$currPos += 2;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c16);
|
||||
}
|
||||
}
|
||||
if (s1 === peg$FAILED) {
|
||||
if (input.charCodeAt(peg$currPos) === 42) {
|
||||
s1 = peg$c17;
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c18);
|
||||
}
|
||||
}
|
||||
if (s1 === peg$FAILED) {
|
||||
s1 = peg$parseliteral();
|
||||
}
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c19(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
function peg$parseliteral() {
|
||||
let s0, s1, s2;
|
||||
|
||||
s0 = peg$currPos;
|
||||
s1 = [];
|
||||
if (peg$c20.test(input.charAt(peg$currPos))) {
|
||||
s2 = input.charAt(peg$currPos);
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c21);
|
||||
}
|
||||
}
|
||||
if (s2 !== peg$FAILED) {
|
||||
while (s2 !== peg$FAILED) {
|
||||
s1.push(s2);
|
||||
if (peg$c20.test(input.charAt(peg$currPos))) {
|
||||
s2 = input.charAt(peg$currPos);
|
||||
peg$currPos++;
|
||||
} else {
|
||||
s2 = peg$FAILED;
|
||||
if (peg$silentFails === 0) {
|
||||
peg$fail(peg$c21);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s1 = peg$FAILED;
|
||||
}
|
||||
if (s1 !== peg$FAILED) {
|
||||
peg$savedPos = s0;
|
||||
s1 = peg$c22(s1);
|
||||
}
|
||||
s0 = s1;
|
||||
|
||||
return s0;
|
||||
}
|
||||
|
||||
const extras = require('./parserExtras');
|
||||
|
||||
peg$result = peg$startRuleFunction();
|
||||
|
||||
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
||||
return peg$result;
|
||||
} else {
|
||||
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
||||
peg$fail({type: 'end', description: 'end of input'});
|
||||
}
|
||||
|
||||
throw peg$buildException(
|
||||
null,
|
||||
peg$maxFailExpected,
|
||||
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
||||
peg$maxFailPos < input.length
|
||||
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
|
||||
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
SyntaxError: peg$SyntaxError,
|
||||
parse: peg$parse,
|
||||
};
|
||||
})();
|
32
node_modules/google-gax/build/src/routingHeader.d.ts
generated
vendored
Normal file
32
node_modules/google-gax/build/src/routingHeader.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.
|
||||
*/
|
||||
/**
|
||||
* Helpers for constructing routing headers.
|
||||
*
|
||||
* These headers are used by Google infrastructure to determine how to route
|
||||
* requests, especially for services that are regional.
|
||||
*
|
||||
* Generally, these headers are specified as gRPC metadata.
|
||||
*/
|
||||
/**
|
||||
* Constructs the routing header from the given params
|
||||
*
|
||||
* @param {Object} params - the request header parameters.
|
||||
* @return {string} the routing header value.
|
||||
*/
|
||||
export declare function fromParams(params: {
|
||||
[index: string]: string | number | boolean;
|
||||
}): string;
|
37
node_modules/google-gax/build/src/routingHeader.js
generated
vendored
Normal file
37
node_modules/google-gax/build/src/routingHeader.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"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 });
|
||||
const querystring = require("querystring");
|
||||
/**
|
||||
* Helpers for constructing routing headers.
|
||||
*
|
||||
* These headers are used by Google infrastructure to determine how to route
|
||||
* requests, especially for services that are regional.
|
||||
*
|
||||
* Generally, these headers are specified as gRPC metadata.
|
||||
*/
|
||||
/**
|
||||
* Constructs the routing header from the given params
|
||||
*
|
||||
* @param {Object} params - the request header parameters.
|
||||
* @return {string} the routing header value.
|
||||
*/
|
||||
function fromParams(params) {
|
||||
return querystring.stringify(params);
|
||||
}
|
||||
exports.fromParams = fromParams;
|
||||
//# sourceMappingURL=routingHeader.js.map
|
1
node_modules/google-gax/build/src/routingHeader.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/routingHeader.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"routingHeader.js","sourceRoot":"","sources":["../../src/routingHeader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,2CAA2C;AAE3C;;;;;;;GAOG;AAEH;;;;;GAKG;AAEH,SAAgB,UAAU,CAAC,MAE1B;IACC,OAAO,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAJD,gCAIC"}
|
34
node_modules/google-gax/build/src/status.d.ts
generated
vendored
Normal file
34
node_modules/google-gax/build/src/status.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.
|
||||
*/
|
||||
export declare enum Status {
|
||||
OK = 0,
|
||||
CANCELLED = 1,
|
||||
UNKNOWN = 2,
|
||||
INVALID_ARGUMENT = 3,
|
||||
DEADLINE_EXCEEDED = 4,
|
||||
NOT_FOUND = 5,
|
||||
ALREADY_EXISTS = 6,
|
||||
PERMISSION_DENIED = 7,
|
||||
RESOURCE_EXHAUSTED = 8,
|
||||
FAILED_PRECONDITION = 9,
|
||||
ABORTED = 10,
|
||||
OUT_OF_RANGE = 11,
|
||||
UNIMPLEMENTED = 12,
|
||||
INTERNAL = 13,
|
||||
UNAVAILABLE = 14,
|
||||
DATA_LOSS = 15,
|
||||
UNAUTHENTICATED = 16
|
||||
}
|
42
node_modules/google-gax/build/src/status.js
generated
vendored
Normal file
42
node_modules/google-gax/build/src/status.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"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 });
|
||||
// The following is a copy of the Status enum defined in @grpc/grpc-js,
|
||||
// src/constants.ts. We need to use some of these statuses here and there,
|
||||
// but we don't want to include the whole @grpc/grpc-js into the browser
|
||||
// bundle just to have this small enum.
|
||||
var Status;
|
||||
(function (Status) {
|
||||
Status[Status["OK"] = 0] = "OK";
|
||||
Status[Status["CANCELLED"] = 1] = "CANCELLED";
|
||||
Status[Status["UNKNOWN"] = 2] = "UNKNOWN";
|
||||
Status[Status["INVALID_ARGUMENT"] = 3] = "INVALID_ARGUMENT";
|
||||
Status[Status["DEADLINE_EXCEEDED"] = 4] = "DEADLINE_EXCEEDED";
|
||||
Status[Status["NOT_FOUND"] = 5] = "NOT_FOUND";
|
||||
Status[Status["ALREADY_EXISTS"] = 6] = "ALREADY_EXISTS";
|
||||
Status[Status["PERMISSION_DENIED"] = 7] = "PERMISSION_DENIED";
|
||||
Status[Status["RESOURCE_EXHAUSTED"] = 8] = "RESOURCE_EXHAUSTED";
|
||||
Status[Status["FAILED_PRECONDITION"] = 9] = "FAILED_PRECONDITION";
|
||||
Status[Status["ABORTED"] = 10] = "ABORTED";
|
||||
Status[Status["OUT_OF_RANGE"] = 11] = "OUT_OF_RANGE";
|
||||
Status[Status["UNIMPLEMENTED"] = 12] = "UNIMPLEMENTED";
|
||||
Status[Status["INTERNAL"] = 13] = "INTERNAL";
|
||||
Status[Status["UNAVAILABLE"] = 14] = "UNAVAILABLE";
|
||||
Status[Status["DATA_LOSS"] = 15] = "DATA_LOSS";
|
||||
Status[Status["UNAUTHENTICATED"] = 16] = "UNAUTHENTICATED";
|
||||
})(Status = exports.Status || (exports.Status = {}));
|
||||
//# sourceMappingURL=status.js.map
|
1
node_modules/google-gax/build/src/status.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/status.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/status.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,uEAAuE;AACvE,0EAA0E;AAC1E,wEAAwE;AACxE,uCAAuC;AAEvC,IAAY,MAkBX;AAlBD,WAAY,MAAM;IAChB,+BAAM,CAAA;IACN,6CAAS,CAAA;IACT,yCAAO,CAAA;IACP,2DAAgB,CAAA;IAChB,6DAAiB,CAAA;IACjB,6CAAS,CAAA;IACT,uDAAc,CAAA;IACd,6DAAiB,CAAA;IACjB,+DAAkB,CAAA;IAClB,iEAAmB,CAAA;IACnB,0CAAO,CAAA;IACP,oDAAY,CAAA;IACZ,sDAAa,CAAA;IACb,4CAAQ,CAAA;IACR,kDAAW,CAAA;IACX,8CAAS,CAAA;IACT,0DAAe,CAAA;AACjB,CAAC,EAlBW,MAAM,GAAN,cAAM,KAAN,cAAM,QAkBjB"}
|
28
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.d.ts
generated
vendored
Normal file
28
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.d.ts
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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 { Descriptor } from '../descriptor';
|
||||
import { CallSettings } from '../gax';
|
||||
import { StreamType } from './streaming';
|
||||
/**
|
||||
* A descriptor for streaming calls.
|
||||
*/
|
||||
export declare class StreamDescriptor implements Descriptor {
|
||||
type: StreamType;
|
||||
streaming: boolean;
|
||||
constructor(streamType: StreamType);
|
||||
getApiCaller(settings: CallSettings): APICaller;
|
||||
}
|
37
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.js
generated
vendored
Normal file
37
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"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 });
|
||||
const streamingApiCaller_1 = require("./streamingApiCaller");
|
||||
/**
|
||||
* A descriptor for streaming calls.
|
||||
*/
|
||||
class StreamDescriptor {
|
||||
constructor(streamType) {
|
||||
this.type = streamType;
|
||||
this.streaming = true;
|
||||
}
|
||||
getApiCaller(settings) {
|
||||
// Right now retrying does not work with gRPC-streaming, because retryable
|
||||
// assumes an API call returns an event emitter while gRPC-streaming methods
|
||||
// return Stream.
|
||||
// TODO: support retrying.
|
||||
settings.retry = null;
|
||||
return new streamingApiCaller_1.StreamingApiCaller(this);
|
||||
}
|
||||
}
|
||||
exports.StreamDescriptor = StreamDescriptor;
|
||||
//# sourceMappingURL=streamDescriptor.js.map
|
1
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.js.map
generated
vendored
Normal file
1
node_modules/google-gax/build/src/streamingCalls/streamDescriptor.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"streamDescriptor.js","sourceRoot":"","sources":["../../../src/streamingCalls/streamDescriptor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAOH,6DAAwD;AAExD;;GAEG;AACH,MAAa,gBAAgB;IAI3B,YAAY,UAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,YAAY,CAAC,QAAsB;QACjC,0EAA0E;QAC1E,4EAA4E;QAC5E,iBAAiB;QACjB,0BAA0B;QAC1B,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,uCAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AAjBD,4CAiBC"}
|
73
node_modules/google-gax/build/src/streamingCalls/streaming.d.ts
generated
vendored
Normal file
73
node_modules/google-gax/build/src/streamingCalls/streaming.d.ts
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
/// <reference types="node" />
|
||||
import { Duplex, DuplexOptions, Readable, Stream, Writable } from 'stream';
|
||||
import { APICallback, CancellableStream, GRPCCallResult, SimpleCallbackFunction } from '../apitypes';
|
||||
declare const duplexify: DuplexifyConstructor;
|
||||
export interface DuplexifyOptions extends DuplexOptions {
|
||||
autoDestroy?: boolean;
|
||||
end?: boolean;
|
||||
}
|
||||
export interface Duplexify extends Duplex {
|
||||
readonly destroyed: boolean;
|
||||
setWritable(writable: Writable | false | null): void;
|
||||
setReadable(readable: Readable | false | null): void;
|
||||
}
|
||||
export interface DuplexifyConstructor {
|
||||
obj(writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
|
||||
new (writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
|
||||
(writable?: Writable | false | null, readable?: Readable | false | null, options?: DuplexifyOptions): Duplexify;
|
||||
}
|
||||
/**
|
||||
* The type of gRPC streaming.
|
||||
* @enum {number}
|
||||
*/
|
||||
export declare enum StreamType {
|
||||
/** Client sends a single request, server streams responses. */
|
||||
SERVER_STREAMING = 1,
|
||||
/** Client streams requests, server returns a single response. */
|
||||
CLIENT_STREAMING = 2,
|
||||
/** Both client and server stream objects. */
|
||||
BIDI_STREAMING = 3
|
||||
}
|
||||
export declare class StreamProxy extends duplexify implements GRPCCallResult {
|
||||
type: StreamType;
|
||||
private _callback;
|
||||
private _isCancelCalled;
|
||||
stream?: CancellableStream;
|
||||
/**
|
||||
* StreamProxy is a proxy to gRPC-streaming method.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {StreamType} type - the type of gRPC stream.
|
||||
* @param {ApiCallback} callback - the callback for further API call.
|
||||
*/
|
||||
constructor(type: StreamType, callback: APICallback);
|
||||
cancel(): void;
|
||||
/**
|
||||
* Forward events from an API request stream to the user's stream.
|
||||
* @param {Stream} stream - The API request stream.
|
||||
*/
|
||||
forwardEvents(stream: Stream): void;
|
||||
/**
|
||||
* Specifies the target stream.
|
||||
* @param {ApiCall} apiCall - the API function to be called.
|
||||
* @param {Object} argument - the argument to be passed to the apiCall.
|
||||
*/
|
||||
setStream(apiCall: SimpleCallbackFunction, argument: {}): void;
|
||||
}
|
||||
export {};
|
127
node_modules/google-gax/build/src/streamingCalls/streaming.js
generated
vendored
Normal file
127
node_modules/google-gax/build/src/streamingCalls/streaming.js
generated
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
"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 });
|
||||
const duplexify = require('duplexify');
|
||||
const retryRequest = require('retry-request');
|
||||
/**
|
||||
* The type of gRPC streaming.
|
||||
* @enum {number}
|
||||
*/
|
||||
var StreamType;
|
||||
(function (StreamType) {
|
||||
/** Client sends a single request, server streams responses. */
|
||||
StreamType[StreamType["SERVER_STREAMING"] = 1] = "SERVER_STREAMING";
|
||||
/** Client streams requests, server returns a single response. */
|
||||
StreamType[StreamType["CLIENT_STREAMING"] = 2] = "CLIENT_STREAMING";
|
||||
/** Both client and server stream objects. */
|
||||
StreamType[StreamType["BIDI_STREAMING"] = 3] = "BIDI_STREAMING";
|
||||
})(StreamType = exports.StreamType || (exports.StreamType = {}));
|
||||
class StreamProxy extends duplexify {
|
||||
/**
|
||||
* StreamProxy is a proxy to gRPC-streaming method.
|
||||
*
|
||||
* @private
|
||||
* @constructor
|
||||
* @param {StreamType} type - the type of gRPC stream.
|
||||
* @param {ApiCallback} callback - the callback for further API call.
|
||||
*/
|
||||
constructor(type, callback) {
|
||||
super(undefined, undefined, {
|
||||
objectMode: true,
|
||||
readable: type !== StreamType.CLIENT_STREAMING,
|
||||
writable: type !== StreamType.SERVER_STREAMING,
|
||||
});
|
||||
this.type = type;
|
||||
this._callback = callback;
|
||||
this._isCancelCalled = false;
|
||||
}
|
||||
cancel() {
|
||||
if (this.stream) {
|
||||
this.stream.cancel();
|
||||
}
|
||||
else {
|
||||
this._isCancelCalled = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Forward events from an API request stream to the user's stream.
|
||||
* @param {Stream} stream - The API request stream.
|
||||
*/
|
||||
forwardEvents(stream) {
|
||||
const eventsToForward = ['metadata', 'response', 'status'];
|
||||
eventsToForward.forEach(event => {
|
||||
stream.on(event, this.emit.bind(this, event));
|
||||
});
|
||||
// We also want to supply the status data as 'response' event to support
|
||||
// the behavior of google-cloud-node expects.
|
||||
// see:
|
||||
// https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1775#issuecomment-259141029
|
||||
// https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355
|
||||
stream.on('metadata', metadata => {
|
||||
// Create a response object with succeeds.
|
||||
// TODO: unify this logic with the decoration of gRPC response when it's
|
||||
// added. see: https://github.com/googleapis/gax-nodejs/issues/65
|
||||
stream.emit('response', {
|
||||
code: 200,
|
||||
details: '',
|
||||
message: 'OK',
|
||||
metadata,
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Specifies the target stream.
|
||||
* @param {ApiCall} apiCall - the API function to be called.
|
||||
* @param {Object} argument - the argument to be passed to the apiCall.
|
||||
*/
|
||||
setStream(apiCall, argument) {
|
||||
if (this.type === StreamType.SERVER_STREAMING) {
|
||||
const retryStream = retryRequest(null, {
|
||||
objectMode: true,
|
||||
request: () => {
|
||||
if (this._isCancelCalled) {
|
||||
if (this.stream) {
|
||||
this.stream.cancel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
const stream = apiCall(argument, this._callback);
|
||||
this.stream = stream;
|
||||
this.forwardEvents(stream);
|
||||
return stream;
|
||||
},
|
||||
});
|
||||
this.setReadable(retryStream);
|
||||
return;
|
||||
}
|
||||
const stream = apiCall(argument, this._callback);
|
||||
this.stream = stream;
|
||||
this.forwardEvents(stream);
|
||||
if (this.type === StreamType.CLIENT_STREAMING) {
|
||||
this.setWritable(stream);
|
||||
}
|
||||
if (this.type === StreamType.BIDI_STREAMING) {
|
||||
this.setReadable(stream);
|
||||
this.setWritable(stream);
|
||||
}
|
||||
if (this._isCancelCalled && this.stream) {
|
||||
this.stream.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.StreamProxy = StreamProxy;
|
||||
//# sourceMappingURL=streaming.js.map
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user