mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 10:46:01 +00:00
Modules
This commit is contained in:
104
node_modules/gaxios/build/src/common.d.ts
generated
vendored
Normal file
104
node_modules/gaxios/build/src/common.d.ts
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
/// <reference types="node" />
|
||||
import { AbortSignal } from 'abort-controller';
|
||||
import { Agent } from 'http';
|
||||
import { URL } from 'url';
|
||||
export declare class GaxiosError<T = any> extends Error {
|
||||
code?: string;
|
||||
response?: GaxiosResponse<T>;
|
||||
config: GaxiosOptions;
|
||||
constructor(message: string, options: GaxiosOptions, response: GaxiosResponse<T>);
|
||||
}
|
||||
export interface Headers {
|
||||
[index: string]: any;
|
||||
}
|
||||
export declare type GaxiosPromise<T = any> = Promise<GaxiosResponse<T>>;
|
||||
export interface GaxiosXMLHttpRequest {
|
||||
responseURL: string;
|
||||
}
|
||||
export interface GaxiosResponse<T = any> {
|
||||
config: GaxiosOptions;
|
||||
data: T;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: Headers;
|
||||
request: GaxiosXMLHttpRequest;
|
||||
}
|
||||
/**
|
||||
* Request options that are used to form the request.
|
||||
*/
|
||||
export interface GaxiosOptions {
|
||||
/**
|
||||
* Optional method to override making the actual HTTP request. Useful
|
||||
* for writing tests.
|
||||
*/
|
||||
adapter?: <T = any>(options: GaxiosOptions) => GaxiosPromise<T>;
|
||||
url?: string;
|
||||
baseUrl?: string;
|
||||
baseURL?: string;
|
||||
method?: 'GET' | 'HEAD' | 'POST' | 'DELETE' | 'PUT' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
|
||||
headers?: Headers;
|
||||
data?: any;
|
||||
body?: any;
|
||||
/**
|
||||
* The maximum size of the http response content in bytes allowed.
|
||||
*/
|
||||
maxContentLength?: number;
|
||||
/**
|
||||
* The maximum number of redirects to follow. Defaults to 20.
|
||||
*/
|
||||
maxRedirects?: number;
|
||||
follow?: number;
|
||||
params?: any;
|
||||
paramsSerializer?: (params: {
|
||||
[index: string]: string | number;
|
||||
}) => string;
|
||||
timeout?: number;
|
||||
onUploadProgress?: (progressEvent: any) => void;
|
||||
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream';
|
||||
agent?: Agent | ((parsedUrl: URL) => Agent);
|
||||
validateStatus?: (status: number) => boolean;
|
||||
retryConfig?: RetryConfig;
|
||||
retry?: boolean;
|
||||
signal?: AbortSignal;
|
||||
size?: number;
|
||||
}
|
||||
/**
|
||||
* Configuration for the Gaxios `request` method.
|
||||
*/
|
||||
export interface RetryConfig {
|
||||
/**
|
||||
* The number of times to retry the request. Defaults to 3.
|
||||
*/
|
||||
retry?: number;
|
||||
/**
|
||||
* The number of retries already attempted.
|
||||
*/
|
||||
currentRetryAttempt?: number;
|
||||
/**
|
||||
* The amount of time to initially delay the retry. Defaults to 100.
|
||||
* @deprecated
|
||||
*/
|
||||
retryDelay?: number;
|
||||
/**
|
||||
* The HTTP Methods that will be automatically retried.
|
||||
* Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
|
||||
*/
|
||||
httpMethodsToRetry?: string[];
|
||||
/**
|
||||
* The HTTP response status codes that will automatically be retried.
|
||||
* Defaults to: [[100, 199], [429, 429], [500, 599]]
|
||||
*/
|
||||
statusCodesToRetry?: number[][];
|
||||
/**
|
||||
* Function to invoke when a retry attempt is made.
|
||||
*/
|
||||
onRetryAttempt?: (err: GaxiosError) => Promise<void> | void;
|
||||
/**
|
||||
* Function to invoke which determines if you should retry
|
||||
*/
|
||||
shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;
|
||||
/**
|
||||
* When there is no response, the number of retries to attempt. Defaults to 2.
|
||||
*/
|
||||
noResponseRetries?: number;
|
||||
}
|
25
node_modules/gaxios/build/src/common.js
generated
vendored
Normal file
25
node_modules/gaxios/build/src/common.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
// Copyright 2018 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 });
|
||||
// tslint:disable no-any
|
||||
class GaxiosError extends Error {
|
||||
constructor(message, options, response) {
|
||||
super(message);
|
||||
this.response = response;
|
||||
this.config = options;
|
||||
this.code = response.status.toString();
|
||||
}
|
||||
}
|
||||
exports.GaxiosError = GaxiosError;
|
||||
//# sourceMappingURL=common.js.map
|
1
node_modules/gaxios/build/src/common.js.map
generated
vendored
Normal file
1
node_modules/gaxios/build/src/common.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAMjC,wBAAwB;AAExB,MAAa,WAAqB,SAAQ,KAAK;IAI7C,YACE,OAAe,EACf,OAAsB,EACtB,QAA2B;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACzC,CAAC;CACF;AAdD,kCAcC"}
|
40
node_modules/gaxios/build/src/gaxios.d.ts
generated
vendored
Normal file
40
node_modules/gaxios/build/src/gaxios.d.ts
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
import { GaxiosOptions, GaxiosPromise } from './common';
|
||||
export declare class Gaxios {
|
||||
private agentCache;
|
||||
/**
|
||||
* Default HTTP options that will be used for every HTTP request.
|
||||
*/
|
||||
defaults: GaxiosOptions;
|
||||
/**
|
||||
* The Gaxios class is responsible for making HTTP requests.
|
||||
* @param defaults The default set of options to be used for this instance.
|
||||
*/
|
||||
constructor(defaults?: GaxiosOptions);
|
||||
/**
|
||||
* Perform an HTTP request with the given options.
|
||||
* @param opts Set of HTTP options that will be used for this HTTP request.
|
||||
*/
|
||||
request<T = any>(opts?: GaxiosOptions): GaxiosPromise<T>;
|
||||
/**
|
||||
* Internal, retryable version of the `request` method.
|
||||
* @param opts Set of HTTP options that will be used for this HTTP request.
|
||||
*/
|
||||
private _request;
|
||||
private getResponseData;
|
||||
/**
|
||||
* Validates the options, and merges them with defaults.
|
||||
* @param opts The original options passed from the client.
|
||||
*/
|
||||
private validateOpts;
|
||||
/**
|
||||
* By default, throw for any non-2xx status code
|
||||
* @param status status code from the HTTP response
|
||||
*/
|
||||
private validateStatus;
|
||||
/**
|
||||
* Encode a set of key/value pars into a querystring format (?foo=bar&baz=boo)
|
||||
* @param params key value pars to encode
|
||||
*/
|
||||
private paramsSerializer;
|
||||
private translateResponse;
|
||||
}
|
213
node_modules/gaxios/build/src/gaxios.js
generated
vendored
Normal file
213
node_modules/gaxios/build/src/gaxios.js
generated
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
"use strict";
|
||||
// Copyright 2018 Google LLC
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const extend_1 = __importDefault(require("extend"));
|
||||
const node_fetch_1 = __importDefault(require("node-fetch"));
|
||||
const querystring_1 = __importDefault(require("querystring"));
|
||||
const is_stream_1 = __importDefault(require("is-stream"));
|
||||
const url_1 = __importDefault(require("url"));
|
||||
const common_1 = require("./common");
|
||||
const retry_1 = require("./retry");
|
||||
// tslint:disable no-any
|
||||
const URL = hasURL() ? window.URL : url_1.default.URL;
|
||||
const fetch = hasFetch() ? window.fetch : node_fetch_1.default;
|
||||
function hasWindow() {
|
||||
return typeof window !== 'undefined' && !!window;
|
||||
}
|
||||
function hasURL() {
|
||||
return hasWindow() && !!window.URL;
|
||||
}
|
||||
function hasFetch() {
|
||||
return hasWindow() && !!window.fetch;
|
||||
}
|
||||
// tslint:disable-next-line variable-name
|
||||
let HttpsProxyAgent;
|
||||
// Figure out if we should be using a proxy. Only if it's required, load
|
||||
// the https-proxy-agent module as it adds startup cost.
|
||||
function loadProxy() {
|
||||
const proxy = process.env.HTTPS_PROXY ||
|
||||
process.env.https_proxy ||
|
||||
process.env.HTTP_PROXY ||
|
||||
process.env.http_proxy;
|
||||
if (proxy) {
|
||||
HttpsProxyAgent = require('https-proxy-agent');
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
loadProxy();
|
||||
class Gaxios {
|
||||
/**
|
||||
* The Gaxios class is responsible for making HTTP requests.
|
||||
* @param defaults The default set of options to be used for this instance.
|
||||
*/
|
||||
constructor(defaults) {
|
||||
this.agentCache = new Map();
|
||||
this.defaults = defaults || {};
|
||||
}
|
||||
/**
|
||||
* Perform an HTTP request with the given options.
|
||||
* @param opts Set of HTTP options that will be used for this HTTP request.
|
||||
*/
|
||||
async request(opts = {}) {
|
||||
opts = this.validateOpts(opts);
|
||||
return this._request(opts);
|
||||
}
|
||||
/**
|
||||
* Internal, retryable version of the `request` method.
|
||||
* @param opts Set of HTTP options that will be used for this HTTP request.
|
||||
*/
|
||||
async _request(opts = {}) {
|
||||
try {
|
||||
let translatedResponse;
|
||||
if (opts.adapter) {
|
||||
translatedResponse = await opts.adapter(opts);
|
||||
}
|
||||
else {
|
||||
const res = await fetch(opts.url, opts);
|
||||
const data = await this.getResponseData(opts, res);
|
||||
translatedResponse = this.translateResponse(opts, res, data);
|
||||
}
|
||||
if (!opts.validateStatus(translatedResponse.status)) {
|
||||
throw new common_1.GaxiosError(`Request failed with status code ${translatedResponse.status}`, opts, translatedResponse);
|
||||
}
|
||||
return translatedResponse;
|
||||
}
|
||||
catch (e) {
|
||||
const err = e;
|
||||
err.config = opts;
|
||||
const { shouldRetry, config } = await retry_1.getRetryConfig(e);
|
||||
if (shouldRetry && config) {
|
||||
err.config.retryConfig.currentRetryAttempt = config.retryConfig.currentRetryAttempt;
|
||||
return this._request(err.config);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async getResponseData(opts, res) {
|
||||
switch (opts.responseType) {
|
||||
case 'stream':
|
||||
return res.body;
|
||||
case 'json':
|
||||
let data = await res.text();
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
catch (e) { }
|
||||
return data;
|
||||
case 'arraybuffer':
|
||||
return res.arrayBuffer();
|
||||
case 'blob':
|
||||
return res.blob();
|
||||
default:
|
||||
return res.text();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates the options, and merges them with defaults.
|
||||
* @param opts The original options passed from the client.
|
||||
*/
|
||||
validateOpts(options) {
|
||||
const opts = extend_1.default(true, {}, this.defaults, options);
|
||||
if (!opts.url) {
|
||||
throw new Error('URL is required.');
|
||||
}
|
||||
// baseUrl has been deprecated, remove in 2.0
|
||||
const baseUrl = opts.baseUrl || opts.baseURL;
|
||||
if (baseUrl) {
|
||||
opts.url = baseUrl + opts.url;
|
||||
}
|
||||
const parsedUrl = new URL(opts.url);
|
||||
opts.url = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
||||
opts.params = extend_1.default(querystring_1.default.parse(parsedUrl.search.substr(1)), // removes leading ?
|
||||
opts.params);
|
||||
opts.paramsSerializer = opts.paramsSerializer || this.paramsSerializer;
|
||||
if (opts.params) {
|
||||
parsedUrl.search = opts.paramsSerializer(opts.params);
|
||||
}
|
||||
opts.url = parsedUrl.href;
|
||||
if (typeof options.maxContentLength === 'number') {
|
||||
opts.size = options.maxContentLength;
|
||||
}
|
||||
if (typeof options.maxRedirects === 'number') {
|
||||
opts.follow = options.maxRedirects;
|
||||
}
|
||||
opts.headers = opts.headers || {};
|
||||
if (opts.data) {
|
||||
if (is_stream_1.default.readable(opts.data)) {
|
||||
opts.body = opts.data;
|
||||
}
|
||||
else if (typeof opts.data === 'object') {
|
||||
opts.body = JSON.stringify(opts.data);
|
||||
opts.headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
else {
|
||||
opts.body = opts.data;
|
||||
}
|
||||
}
|
||||
opts.validateStatus = opts.validateStatus || this.validateStatus;
|
||||
opts.responseType = opts.responseType || 'json';
|
||||
if (!opts.headers['Accept'] && opts.responseType === 'json') {
|
||||
opts.headers['Accept'] = 'application/json';
|
||||
}
|
||||
opts.method = opts.method || 'GET';
|
||||
const proxy = loadProxy();
|
||||
if (proxy) {
|
||||
if (this.agentCache.has(proxy)) {
|
||||
opts.agent = this.agentCache.get(proxy);
|
||||
}
|
||||
else {
|
||||
opts.agent = new HttpsProxyAgent(proxy);
|
||||
this.agentCache.set(proxy, opts.agent);
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
/**
|
||||
* By default, throw for any non-2xx status code
|
||||
* @param status status code from the HTTP response
|
||||
*/
|
||||
validateStatus(status) {
|
||||
return status >= 200 && status < 300;
|
||||
}
|
||||
/**
|
||||
* Encode a set of key/value pars into a querystring format (?foo=bar&baz=boo)
|
||||
* @param params key value pars to encode
|
||||
*/
|
||||
paramsSerializer(params) {
|
||||
return querystring_1.default.stringify(params);
|
||||
}
|
||||
translateResponse(opts, res, data) {
|
||||
// headers need to be converted from a map to an obj
|
||||
const headers = {};
|
||||
res.headers.forEach((value, key) => {
|
||||
headers[key] = value;
|
||||
});
|
||||
return {
|
||||
config: opts,
|
||||
data: data,
|
||||
headers,
|
||||
status: res.status,
|
||||
statusText: res.statusText,
|
||||
// XMLHttpRequestLike
|
||||
request: {
|
||||
responseURL: res.url,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.Gaxios = Gaxios;
|
||||
//# sourceMappingURL=gaxios.js.map
|
1
node_modules/gaxios/build/src/gaxios.js.map
generated
vendored
Normal file
1
node_modules/gaxios/build/src/gaxios.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/gaxios/build/src/index.d.ts
generated
vendored
Normal file
14
node_modules/gaxios/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { GaxiosOptions } from './common';
|
||||
import { Gaxios } from './gaxios';
|
||||
export { GaxiosError, GaxiosPromise, GaxiosResponse, Headers, RetryConfig, } from './common';
|
||||
export { Gaxios, GaxiosOptions };
|
||||
/**
|
||||
* The default instance used when the `request` method is directly
|
||||
* invoked.
|
||||
*/
|
||||
export declare const instance: Gaxios;
|
||||
/**
|
||||
* Make an HTTP request using the given options.
|
||||
* @param opts Options for the request
|
||||
*/
|
||||
export declare function request<T>(opts: GaxiosOptions): Promise<import("./common").GaxiosResponse<T>>;
|
32
node_modules/gaxios/build/src/index.js
generated
vendored
Normal file
32
node_modules/gaxios/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
// Copyright 2018 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 gaxios_1 = require("./gaxios");
|
||||
exports.Gaxios = gaxios_1.Gaxios;
|
||||
var common_1 = require("./common");
|
||||
exports.GaxiosError = common_1.GaxiosError;
|
||||
/**
|
||||
* The default instance used when the `request` method is directly
|
||||
* invoked.
|
||||
*/
|
||||
exports.instance = new gaxios_1.Gaxios();
|
||||
/**
|
||||
* Make an HTTP request using the given options.
|
||||
* @param opts Options for the request
|
||||
*/
|
||||
async function request(opts) {
|
||||
return exports.instance.request(opts);
|
||||
}
|
||||
exports.request = request;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/gaxios/build/src/index.js.map
generated
vendored
Normal file
1
node_modules/gaxios/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,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,qCAAgC;AASxB,iBATA,eAAM,CASA;AAPd,mCAMkB;AALhB,+BAAA,WAAW,CAAA;AAQb;;;GAGG;AACU,QAAA,QAAQ,GAAG,IAAI,eAAM,EAAE,CAAC;AAErC;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAI,IAAmB;IAClD,OAAO,gBAAQ,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;AACnC,CAAC;AAFD,0BAEC"}
|
8
node_modules/gaxios/build/src/retry.d.ts
generated
vendored
Normal file
8
node_modules/gaxios/build/src/retry.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { GaxiosError } from './common';
|
||||
export declare function getRetryConfig(err: GaxiosError): Promise<{
|
||||
shouldRetry: boolean;
|
||||
config?: undefined;
|
||||
} | {
|
||||
shouldRetry: boolean;
|
||||
config: import("./common").GaxiosOptions;
|
||||
}>;
|
132
node_modules/gaxios/build/src/retry.js
generated
vendored
Normal file
132
node_modules/gaxios/build/src/retry.js
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
"use strict";
|
||||
// Copyright 2018 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 });
|
||||
async function getRetryConfig(err) {
|
||||
let config = getConfig(err);
|
||||
if (!err || !err.config || (!config && !err.config.retry)) {
|
||||
return { shouldRetry: false };
|
||||
}
|
||||
config = config || {};
|
||||
config.currentRetryAttempt = config.currentRetryAttempt || 0;
|
||||
config.retry =
|
||||
config.retry === undefined || config.retry === null ? 3 : config.retry;
|
||||
config.httpMethodsToRetry = config.httpMethodsToRetry || [
|
||||
'GET',
|
||||
'HEAD',
|
||||
'PUT',
|
||||
'OPTIONS',
|
||||
'DELETE',
|
||||
];
|
||||
config.noResponseRetries =
|
||||
config.noResponseRetries === undefined || config.noResponseRetries === null
|
||||
? 2
|
||||
: config.noResponseRetries;
|
||||
// If this wasn't in the list of status codes where we want
|
||||
// to automatically retry, return.
|
||||
const retryRanges = [
|
||||
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
||||
// 1xx - Retry (Informational, request still processing)
|
||||
// 2xx - Do not retry (Success)
|
||||
// 3xx - Do not retry (Redirect)
|
||||
// 4xx - Do not retry (Client errors)
|
||||
// 429 - Retry ("Too Many Requests")
|
||||
// 5xx - Retry (Server errors)
|
||||
[100, 199],
|
||||
[429, 429],
|
||||
[500, 599],
|
||||
];
|
||||
config.statusCodesToRetry = config.statusCodesToRetry || retryRanges;
|
||||
// Put the config back into the err
|
||||
err.config.retryConfig = config;
|
||||
// Determine if we should retry the request
|
||||
const shouldRetryFn = config.shouldRetry || shouldRetryRequest;
|
||||
if (!(await shouldRetryFn(err))) {
|
||||
return { shouldRetry: false, config: err.config };
|
||||
}
|
||||
// Calculate time to wait with exponential backoff.
|
||||
// Formula: (2^c - 1 / 2) * 1000
|
||||
const delay = ((Math.pow(2, config.currentRetryAttempt) - 1) / 2) * 1000;
|
||||
// We're going to retry! Incremenent the counter.
|
||||
err.config.retryConfig.currentRetryAttempt += 1;
|
||||
// Create a promise that invokes the retry after the backOffDelay
|
||||
const backoff = new Promise(resolve => {
|
||||
setTimeout(resolve, delay);
|
||||
});
|
||||
// Notify the user if they added an `onRetryAttempt` handler
|
||||
if (config.onRetryAttempt) {
|
||||
config.onRetryAttempt(err);
|
||||
}
|
||||
// Return the promise in which recalls Gaxios to retry the request
|
||||
await backoff;
|
||||
return { shouldRetry: true, config: err.config };
|
||||
}
|
||||
exports.getRetryConfig = getRetryConfig;
|
||||
/**
|
||||
* Determine based on config if we should retry the request.
|
||||
* @param err The GaxiosError passed to the interceptor.
|
||||
*/
|
||||
function shouldRetryRequest(err) {
|
||||
const config = getConfig(err);
|
||||
// node-fetch raises an AbortError if signaled:
|
||||
// https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
|
||||
if (err.name === 'AbortError') {
|
||||
return false;
|
||||
}
|
||||
// If there's no config, or retries are disabled, return.
|
||||
if (!config || config.retry === 0) {
|
||||
return false;
|
||||
}
|
||||
// Check if this error has no response (ETIMEDOUT, ENOTFOUND, etc)
|
||||
if (!err.response &&
|
||||
(config.currentRetryAttempt || 0) >= config.noResponseRetries) {
|
||||
return false;
|
||||
}
|
||||
// Only retry with configured HttpMethods.
|
||||
if (!err.config.method ||
|
||||
config.httpMethodsToRetry.indexOf(err.config.method.toUpperCase()) < 0) {
|
||||
return false;
|
||||
}
|
||||
// If this wasn't in the list of status codes where we want
|
||||
// to automatically retry, return.
|
||||
if (err.response && err.response.status) {
|
||||
let isInRange = false;
|
||||
for (const [min, max] of config.statusCodesToRetry) {
|
||||
const status = err.response.status;
|
||||
if (status >= min && status <= max) {
|
||||
isInRange = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isInRange) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If we are out of retry attempts, return
|
||||
config.currentRetryAttempt = config.currentRetryAttempt || 0;
|
||||
if (config.currentRetryAttempt >= config.retry) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Acquire the raxConfig object from an GaxiosError if available.
|
||||
* @param err The Gaxios error with a config object.
|
||||
*/
|
||||
function getConfig(err) {
|
||||
if (err && err.config && err.config.retryConfig) {
|
||||
return err.config.retryConfig;
|
||||
}
|
||||
return;
|
||||
}
|
||||
//# sourceMappingURL=retry.js.map
|
1
node_modules/gaxios/build/src/retry.js.map
generated
vendored
Normal file
1
node_modules/gaxios/build/src/retry.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/retry.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAI1B,KAAK,UAAU,cAAc,CAAC,GAAgB;IACnD,IAAI,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAA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,OAAO,KAAK,CAAC;KACd;IAED,0CAA0C;IAC1C,IACE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM;QAClB,MAAM,CAAC,kBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EACvE;QACA,OAAO,KAAK,CAAC;KACd;IAED,2DAA2D;IAC3D,kCAAkC;IAClC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE;QACvC,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,kBAAmB,EAAE;YACnD,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACnC,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,EAAE;gBAClC,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;aACP;SACF;QACD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,KAAK,CAAC;SACd;KACF;IAED,0CAA0C;IAC1C,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAC;IAC7D,IAAI,MAAM,CAAC,mBAAmB,IAAI,MAAM,CAAC,KAAM,EAAE;QAC/C,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,SAAS,CAAC,GAAgB;IACjC,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE;QAC/C,OAAO,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;KAC/B;IACD,OAAO;AACT,CAAC"}
|
0
node_modules/gaxios/build/src/web.d.ts
generated
vendored
Normal file
0
node_modules/gaxios/build/src/web.d.ts
generated
vendored
Normal file
2
node_modules/gaxios/build/src/web.js
generated
vendored
Normal file
2
node_modules/gaxios/build/src/web.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
//# sourceMappingURL=web.js.map
|
1
node_modules/gaxios/build/src/web.js.map
generated
vendored
Normal file
1
node_modules/gaxios/build/src/web.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":""}
|
Reference in New Issue
Block a user