Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

api-reach

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-reach - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

6

CHANGELOG.md

@@ -6,2 +6,8 @@ All notable changes to this project will be documented in this file.

## [0.11.0] - 2021-05-30
### Added
- caching
### Fixed
- typings for download util
## [0.10.0] - 2021-05-09

@@ -8,0 +14,0 @@ ### Added

9

dist/api-client.d.ts

@@ -1,3 +0,5 @@

import type { PossibleNonErrorResponses } from "./response/response.js";
import type { Data, Options, URLArgument, BodyArgument, AbortablePromise, ConfigureOptions } from "./types";
import type { CustomError } from "better-custom-error";
import type { Data, Options, URLArgument, BodyArgument, AbortablePromise, ConfigureOptions, PossibleCustomErrorsThrown } from "./types";
import type { PossibleNonErrorResponses, PossibleResponses } from "./response/response.js";
import { ClientErrorResponse, ServerErrorResponse } from "./response/response.js";
declare class ApiClient {

@@ -19,2 +21,5 @@ private readonly _options;

private _request;
private static _serveResponse;
static stringifyResponse(response: PossibleResponses | PossibleCustomErrorsThrown, space?: string | number): string;
static parseStringifiedReponse<T>(string: string): CustomError | import("./response/response.js").AbortedResponse | import("./response/response.js").InformationalResponse | import("./response/response.js").SuccessResponse | import("./response/response.js").RedirectResponse | ClientErrorResponse | ServerErrorResponse;
}

@@ -21,0 +26,0 @@ declare const configure: (options: ConfigureOptions) => void;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -7,3 +26,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.configure = exports.ApiClient = void 0;
const light_isomorphic_fetch_1 = __importDefault(require("light-isomorphic-fetch"));
const light_isomorphic_fetch_1 = __importStar(require("light-isomorphic-fetch"));
const qs_1 = __importDefault(require("qs"));

@@ -13,2 +32,3 @@ const url_join_1 = __importDefault(require("url-join"));

const oop_timers_1 = require("oop-timers");
const node_object_hash_1 = __importDefault(require("node-object-hash"));
const errors_js_1 = require("./errors.js");

@@ -22,2 +42,3 @@ const response_js_1 = require("./response/response.js");

let URLParser = URL;
const { hash: ohash } = node_object_hash_1.default({ sort: true, coerce: false });
const safeUrlParse = (url) => {

@@ -43,2 +64,19 @@ try {

totalTimeout: 60000,
cache: null,
cacheKey: (req) => {
if (req.method.toLowerCase() !== "get") {
return;
}
return ohash(req);
},
shouldCacheResponse: (response) => {
var _a;
if (!(response instanceof Error)) {
return true;
}
if (((_a = response.details) === null || _a === void 0 ? void 0 : _a.response) instanceof response_js_1.ClientErrorResponse) {
return true;
}
return false;
},
};

@@ -127,3 +165,5 @@ const noop = () => undefined;

const fineOptions = this._buildFetchOptions(options !== null && options !== void 0 ? options : {}, method, body);
let currentController, globalTimeout, aborted = false, isGlobalTimeouted = false;
const fullUrl = this._buildUrl(url, queryParams, fineOptions);
const request = new request_js_1.ApiRequest(fullUrl, fineOptions, url, queryParams);
let cacheKey = undefined, currentController, globalTimeout, aborted = false, isGlobalTimeouted = false;
const globalBreak = () => {

@@ -136,2 +176,20 @@ isGlobalTimeouted = true;

(async () => {
if (fineOptions.cache && fineOptions.cacheKey) {
cacheKey = fineOptions.cacheKey({
url: fullUrl,
method: request.options.method,
headers: request.options.headers,
body: request.options.body,
});
if (cacheKey) {
const cachedResult = await fineOptions.cache.get(cacheKey);
if (cachedResult) {
const result = ApiClient.parseStringifiedReponse(cachedResult);
if (result instanceof Error) {
throw result;
}
return result;
}
}
}
while (fineOptions.retryPolicy({ count: ++count })) {

@@ -166,3 +224,3 @@ let isTimeouted = false;

singleTimeout.start();
return await this._request(url, queryParams, fineOptions, currentController.signal);
return await this._request(request, fineOptions, currentController.signal);
}

@@ -190,3 +248,19 @@ catch (e) {

throw lastError ? lastError : new Error("No error thrown");
})().then(resolve, reject);
})().then((response) => {
resolve(response);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(response)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(response)).catch(noop);
}
}, (error) => {
reject(error);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(error)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(error)).catch(noop);
}
});
});

@@ -205,8 +279,8 @@ future.finally(() => {

}
async _request(originalUrl, queryParams, options, signal) {
const fetchOptions = options;
const url = this._buildUrl(originalUrl, queryParams, fetchOptions);
const request = new request_js_1.ApiRequest(url, fetchOptions, originalUrl, queryParams);
async _request(request, options, signal) {
const result = (await fetch(request.url, Object.assign(Object.assign({}, request.options), { signal })));
const type = this._getType(options);
return ApiClient._serveResponse(result, type, request);
}
static async _serveResponse(result, type, request) {
const response = await response_js_1.createResponse(result, type, request);

@@ -231,2 +305,47 @@ if ("rawBody" in response) {

}
static stringifyResponse(response, space) {
var _a;
const objToStringify = response instanceof Error
? {
error: response.name,
message: response.message,
details: Object.assign(Object.assign({}, response.details), { response: (_a = response.details) === null || _a === void 0 ? void 0 : _a.response }),
}
: response;
return JSON.stringify(objToStringify, function replacer(key, value) {
if (value instanceof light_isomorphic_fetch_1.Headers) {
const h = {};
Array.from(value.keys()).forEach(mapKey => {
h[mapKey] = value.get(mapKey);
});
return h;
}
if (typeof value === "function") {
return `[Function: ${value.name}]`;
}
return value;
}, space);
}
static parseStringifiedReponse(string) {
const parsedData = JSON.parse(string);
const all = "error" in parsedData ? parsedData.details.response : parsedData;
const status = all.status;
const statusText = all.statusText;
const headers = new light_isomorphic_fetch_1.Headers(all.headers);
const request = new request_js_1.ApiRequest(all.request.url, Object.assign(Object.assign({}, all.request.options), { retryPolicy: helpers_js_1.createNoopFunctionFromString(all.request.options.retryPolicy), retryWaitPolicy: helpers_js_1.createNoopFunctionFromString(all.request.options.retryWaitPolicy) }), all.request.originalUrl, all.request.queryParams);
const body = all.body;
const rawBody = all.rawBody;
const type = all.type;
const data = {
type, body, rawBody,
};
if (rawBody == null) {
delete data.rawBody;
}
const response = response_js_1.createResponseWithData({ status, statusText, headers }, type, request, data);
if (!("error" in parsedData)) {
return response;
}
return new errors_js_1.ResponseDataTypeMismatchError(parsedData.message, Object.assign(Object.assign({}, parsedData.details), { response }));
}
}

@@ -233,0 +352,0 @@ exports.ApiClient = ApiClient;

declare const getJoinedUrl: (url: string | string[]) => string;
declare const wait: (time: number) => Promise<unknown>;
export { getJoinedUrl, wait, };
declare const createNoopFunctionFromString: (s: string) => () => undefined;
export { getJoinedUrl, wait, createNoopFunctionFromString, };
//# sourceMappingURL=helpers.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.wait = exports.getJoinedUrl = void 0;
exports.createNoopFunctionFromString = exports.wait = exports.getJoinedUrl = void 0;
const url_join_1 = __importDefault(require("url-join"));

@@ -18,2 +18,14 @@ const getJoinedUrl = (url) => {

exports.wait = wait;
const FUNCTION_NAME_BEGIN_INDEX = 11;
const FUNCTION_NAME_END_INDEX = -1;
const getFunctionNameFromString = (s) => {
return s.substring(FUNCTION_NAME_BEGIN_INDEX, s.length + (FUNCTION_NAME_END_INDEX - 1));
};
const createNoopFunctionFromString = (s) => {
const name = getFunctionNameFromString(s);
const fn = () => undefined;
Object.defineProperty(fn, "name", { value: name });
return fn;
};
exports.createNoopFunctionFromString = createNoopFunctionFromString;
//# sourceMappingURL=helpers.js.map
import type { Response as NodeFetchResponse, Headers as NodeFetchHeaders } from "node-fetch";
import type { RequestType } from "../const.js";
import type { ApiRequest } from "../request/request.js";
import type { ResponseData } from "../types.js";
import type { FetchLikeData, ResponseData } from "../types.js";
declare class ApiResponse {

@@ -13,3 +13,3 @@ readonly status: number;

readonly type: RequestType;
constructor(result: NodeFetchResponse, data: ResponseData<unknown>, request: ApiRequest);
constructor(result: FetchLikeData, data: ResponseData<unknown>, request: ApiRequest);
}

@@ -28,8 +28,10 @@ declare class AbortedResponse extends ApiResponse {

}
declare const createResponseWithData: <Format>(result: FetchLikeData, type: RequestType, request: ApiRequest, data: ResponseData<Format>) => AbortedResponse | InformationalResponse | SuccessResponse | RedirectResponse | ClientErrorResponse | ServerErrorResponse;
declare const createResponse: <Format>(result: NodeFetchResponse, type: RequestType, request: ApiRequest) => Promise<AbortedResponse | InformationalResponse | SuccessResponse | RedirectResponse | ClientErrorResponse | ServerErrorResponse>;
declare type PossibleResponses = ReturnType<typeof createResponse>;
declare type Await<T> = T extends Promise<infer U> ? U : T;
declare type PossibleResponses = Await<ReturnType<typeof createResponse>>;
declare type PossibleNonErrorResponses = InformationalResponse | SuccessResponse | RedirectResponse;
declare type PossibleErrorResponses = AbortedResponse | ClientErrorResponse | ServerErrorResponse;
export { createResponse, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
export { createResponse, createResponseWithData, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
export type { PossibleResponses, PossibleNonErrorResponses, PossibleErrorResponses, };
//# sourceMappingURL=response.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerErrorResponse = exports.ClientErrorResponse = exports.RedirectResponse = exports.SuccessResponse = exports.InformationalResponse = exports.AbortedResponse = exports.ApiResponse = exports.createResponse = void 0;
exports.ServerErrorResponse = exports.ClientErrorResponse = exports.RedirectResponse = exports.SuccessResponse = exports.InformationalResponse = exports.AbortedResponse = exports.ApiResponse = exports.createResponseWithData = exports.createResponse = void 0;
const const_js_1 = require("../const.js");

@@ -43,5 +43,4 @@ const matchStatus_js_1 = require("./matchStatus.js");

exports.ServerErrorResponse = ServerErrorResponse;
const createResponse = async (result, type, request) => {
const createResponseWithData = (result, type, request, data) => {
const statusType = matchStatus_js_1.matchStatus(result.status);
const data = await decodeData_js_1.default(result, type);
if (statusType === const_js_1.ResponseStatusGroup.Aborted) {

@@ -64,3 +63,8 @@ return new AbortedResponse(result, data, request);

};
exports.createResponseWithData = createResponseWithData;
const createResponse = async (result, type, request) => {
const data = await decodeData_js_1.default(result, type);
return createResponseWithData(result, type, request, data);
};
exports.createResponse = createResponse;
//# sourceMappingURL=response.js.map
/// <reference types="node" />
import type { RequestType } from "./const";
import type { Response as NodeFetchResponse } from "node-fetch";
import type { ClientHttpError, ResponseDataTypeMismatchError, ServerHttpError } from "./errors";
import type { PossibleNonErrorResponses } from "./response/response";
declare type Data = object;

@@ -8,2 +10,16 @@ interface RetryInfo {

}
interface CacheInterface {
get: (key: string) => Promise<string | undefined>;
set: (key: string, value: string) => Promise<boolean>;
delete: (key: string) => Promise<boolean>;
clear: () => Promise<void>;
}
interface RequestInformation {
method: string;
url: string;
body?: string;
headers: object;
}
declare type CacheGetKey = (reqInfo: RequestInformation) => string | undefined;
declare type CacheShouldCache = (response: PossibleNonErrorResponses | PossibleCustomErrorsThrown) => boolean;
interface Options {

@@ -19,2 +35,5 @@ base?: string;

totalTimeout?: number;
cache?: CacheInterface | null;
cacheKey?: CacheGetKey;
shouldCacheResponse?: CacheShouldCache;
}

@@ -65,3 +84,34 @@ declare type FetchOptions = Omit<Required<Options>, "base"> & {

}
export type { Data, Options, FetchOptions, URLArgument, BodyArgument, AbortErrorDetails, AbortErrorObject, AbortablePromise, ResponseData, ResponseDataJSON, ResponseDataText, ResponseDataBinary, ResponseDataStream, ConfigureOptions, };
declare type FetchLikeData = Pick<NodeFetchResponse, "status" | "statusText" | "headers">;
interface ParsedResponse {
status: NodeFetchResponse["status"];
statusText: NodeFetchResponse["statusText"];
headers: {
[key: string]: string;
};
request: {
url: string;
originalUrl: string;
queryParams: {
[key: string]: string;
};
options: FetchOptions & {
retryPolicy: string;
retryWaitPolicy: string;
};
};
type: RequestType.text;
body: string;
rawBody?: string;
}
interface ParsedError {
error: string;
message: string;
details: {
response: ParsedResponse;
[s: string]: unknown;
};
}
declare type PossibleCustomErrorsThrown = ReturnType<typeof ResponseDataTypeMismatchError> | ReturnType<typeof ClientHttpError> | ReturnType<typeof ServerHttpError>;
export type { Data, Options, FetchOptions, URLArgument, BodyArgument, AbortErrorDetails, AbortErrorObject, AbortablePromise, ResponseData, ResponseDataJSON, ResponseDataText, ResponseDataBinary, ResponseDataStream, ConfigureOptions, FetchLikeData, ParsedResponse, ParsedError, PossibleCustomErrorsThrown, };
//# sourceMappingURL=types.d.ts.map
import type stream from "stream";
import type { ApiClient } from "./api-client.js";
import type { Data, Options, URLArgument } from "./types";
declare const download: (api: ApiClient, method: string, url: URLArgument, queryParams: Data, body: Data, options: Options, writableStream: stream.Writable) => Promise<unknown>;
declare const download: (writableStream: stream.Writable, api: ApiClient, method: string, url: URLArgument, queryParams: Data | null, body: Data | null, options: Options | null) => Promise<unknown>;
export { download, };
//# sourceMappingURL=utils.d.ts.map

@@ -6,3 +6,3 @@ "use strict";

const const_js_1 = require("./const.js");
const download = async (api, method, url, queryParams, body, options, writableStream) => {
const download = async (writableStream, api, method, url, queryParams, body, options) => {
const res = await api.request(method, url, queryParams, body, Object.assign(Object.assign({}, options), { type: const_js_1.RequestType.stream }));

@@ -9,0 +9,0 @@ return new Promise((resolve, reject) => {

@@ -1,1 +0,1 @@

window.searchData = {"kinds":{"4":"Enumeration","16":"Enumeration member","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal"},"rows":[{"id":0,"kind":4,"name":"RequestType","url":"enums/requesttype.html","classes":"tsd-kind-enum"},{"id":1,"kind":16,"name":"json","url":"enums/requesttype.html#json","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":2,"kind":16,"name":"text","url":"enums/requesttype.html#text","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":3,"kind":16,"name":"binary","url":"enums/requesttype.html#binary","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":4,"kind":16,"name":"stream","url":"enums/requesttype.html#stream","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":5,"kind":128,"name":"AbortedResponse","url":"classes/abortedresponse.html","classes":"tsd-kind-class"},{"id":6,"kind":512,"name":"constructor","url":"classes/abortedresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":7,"kind":1024,"name":"status","url":"classes/abortedresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":8,"kind":1024,"name":"statusText","url":"classes/abortedresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":9,"kind":1024,"name":"headers","url":"classes/abortedresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":10,"kind":1024,"name":"request","url":"classes/abortedresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":11,"kind":1024,"name":"body","url":"classes/abortedresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":12,"kind":1024,"name":"rawBody","url":"classes/abortedresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":13,"kind":1024,"name":"type","url":"classes/abortedresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":14,"kind":128,"name":"InformationalResponse","url":"classes/informationalresponse.html","classes":"tsd-kind-class"},{"id":15,"kind":512,"name":"constructor","url":"classes/informationalresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":16,"kind":1024,"name":"status","url":"classes/informationalresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":17,"kind":1024,"name":"statusText","url":"classes/informationalresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":18,"kind":1024,"name":"headers","url":"classes/informationalresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":19,"kind":1024,"name":"request","url":"classes/informationalresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":20,"kind":1024,"name":"body","url":"classes/informationalresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":21,"kind":1024,"name":"rawBody","url":"classes/informationalresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":22,"kind":1024,"name":"type","url":"classes/informationalresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":23,"kind":128,"name":"SuccessResponse","url":"classes/successresponse.html","classes":"tsd-kind-class"},{"id":24,"kind":512,"name":"constructor","url":"classes/successresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":25,"kind":1024,"name":"status","url":"classes/successresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":26,"kind":1024,"name":"statusText","url":"classes/successresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":27,"kind":1024,"name":"headers","url":"classes/successresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":28,"kind":1024,"name":"request","url":"classes/successresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":29,"kind":1024,"name":"body","url":"classes/successresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":30,"kind":1024,"name":"rawBody","url":"classes/successresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":31,"kind":1024,"name":"type","url":"classes/successresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":32,"kind":128,"name":"RedirectResponse","url":"classes/redirectresponse.html","classes":"tsd-kind-class"},{"id":33,"kind":512,"name":"constructor","url":"classes/redirectresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":34,"kind":1024,"name":"status","url":"classes/redirectresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":35,"kind":1024,"name":"statusText","url":"classes/redirectresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":36,"kind":1024,"name":"headers","url":"classes/redirectresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":37,"kind":1024,"name":"request","url":"classes/redirectresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":38,"kind":1024,"name":"body","url":"classes/redirectresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":39,"kind":1024,"name":"rawBody","url":"classes/redirectresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":40,"kind":1024,"name":"type","url":"classes/redirectresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":41,"kind":128,"name":"ClientErrorResponse","url":"classes/clienterrorresponse.html","classes":"tsd-kind-class"},{"id":42,"kind":512,"name":"constructor","url":"classes/clienterrorresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":43,"kind":1024,"name":"status","url":"classes/clienterrorresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":44,"kind":1024,"name":"statusText","url":"classes/clienterrorresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":45,"kind":1024,"name":"headers","url":"classes/clienterrorresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":46,"kind":1024,"name":"request","url":"classes/clienterrorresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":47,"kind":1024,"name":"body","url":"classes/clienterrorresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":48,"kind":1024,"name":"rawBody","url":"classes/clienterrorresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":49,"kind":1024,"name":"type","url":"classes/clienterrorresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":50,"kind":128,"name":"ServerErrorResponse","url":"classes/servererrorresponse.html","classes":"tsd-kind-class"},{"id":51,"kind":512,"name":"constructor","url":"classes/servererrorresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":52,"kind":1024,"name":"status","url":"classes/servererrorresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":53,"kind":1024,"name":"statusText","url":"classes/servererrorresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":54,"kind":1024,"name":"headers","url":"classes/servererrorresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":55,"kind":1024,"name":"request","url":"classes/servererrorresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":56,"kind":1024,"name":"body","url":"classes/servererrorresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":57,"kind":1024,"name":"rawBody","url":"classes/servererrorresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":58,"kind":1024,"name":"type","url":"classes/servererrorresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":59,"kind":256,"name":"Options","url":"interfaces/options.html","classes":"tsd-kind-interface"},{"id":60,"kind":1024,"name":"base","url":"interfaces/options.html#base","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":61,"kind":1024,"name":"type","url":"interfaces/options.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":62,"kind":1024,"name":"headers","url":"interfaces/options.html#headers","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":63,"kind":1024,"name":"retry","url":"interfaces/options.html#retry","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":64,"kind":1024,"name":"retryInterval","url":"interfaces/options.html#retryinterval","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":65,"kind":1024,"name":"retryPolicy","url":"interfaces/options.html#retrypolicy","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":66,"kind":65536,"name":"__type","url":"interfaces/options.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-interface","parent":"Options"},{"id":67,"kind":1024,"name":"retryWaitPolicy","url":"interfaces/options.html#retrywaitpolicy","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":68,"kind":65536,"name":"__type","url":"interfaces/options.html#__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-interface","parent":"Options"},{"id":69,"kind":1024,"name":"timeout","url":"interfaces/options.html#timeout","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":70,"kind":1024,"name":"totalTimeout","url":"interfaces/options.html#totaltimeout","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":71,"kind":256,"name":"ResponseDataJSON","url":"interfaces/responsedatajson.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":72,"kind":1024,"name":"type","url":"interfaces/responsedatajson.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataJSON"},{"id":73,"kind":1024,"name":"body","url":"interfaces/responsedatajson.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataJSON"},{"id":74,"kind":256,"name":"ResponseDataText","url":"interfaces/responsedatatext.html","classes":"tsd-kind-interface"},{"id":75,"kind":1024,"name":"type","url":"interfaces/responsedatatext.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":76,"kind":1024,"name":"body","url":"interfaces/responsedatatext.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":77,"kind":1024,"name":"rawBody","url":"interfaces/responsedatatext.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":78,"kind":256,"name":"ResponseDataBinary","url":"interfaces/responsedatabinary.html","classes":"tsd-kind-interface"},{"id":79,"kind":1024,"name":"type","url":"interfaces/responsedatabinary.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataBinary"},{"id":80,"kind":1024,"name":"body","url":"interfaces/responsedatabinary.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataBinary"},{"id":81,"kind":256,"name":"ResponseDataStream","url":"interfaces/responsedatastream.html","classes":"tsd-kind-interface"},{"id":82,"kind":1024,"name":"type","url":"interfaces/responsedatastream.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataStream"},{"id":83,"kind":1024,"name":"body","url":"interfaces/responsedatastream.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataStream"},{"id":84,"kind":128,"name":"ApiClient","url":"classes/apiclient.html","classes":"tsd-kind-class"},{"id":85,"kind":512,"name":"constructor","url":"classes/apiclient.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"ApiClient"},{"id":86,"kind":1024,"name":"_options","url":"classes/apiclient.html#_options","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":87,"kind":2048,"name":"_getType","url":"classes/apiclient.html#_gettype","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":88,"kind":2048,"name":"_getContentType","url":"classes/apiclient.html#_getcontenttype","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":89,"kind":2048,"name":"_getBody","url":"classes/apiclient.html#_getbody","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":90,"kind":2048,"name":"_buildFetchOptions","url":"classes/apiclient.html#_buildfetchoptions","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":91,"kind":2048,"name":"_buildUrlBase","url":"classes/apiclient.html#_buildurlbase","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":92,"kind":2048,"name":"_buildUrl","url":"classes/apiclient.html#_buildurl","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":93,"kind":2048,"name":"get","url":"classes/apiclient.html#get","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":94,"kind":2048,"name":"post","url":"classes/apiclient.html#post","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":95,"kind":2048,"name":"patch","url":"classes/apiclient.html#patch","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":96,"kind":2048,"name":"delete","url":"classes/apiclient.html#delete","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":97,"kind":2048,"name":"head","url":"classes/apiclient.html#head","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":98,"kind":2048,"name":"request","url":"classes/apiclient.html#request","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":99,"kind":2048,"name":"_request","url":"classes/apiclient.html#_request","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-private","parent":"ApiClient"},{"id":100,"kind":64,"name":"configure","url":"modules.html#configure","classes":"tsd-kind-function"},{"id":101,"kind":64,"name":"download","url":"modules.html#download","classes":"tsd-kind-function"},{"id":102,"kind":32,"name":"HttpError","url":"modules.html#httperror","classes":"tsd-kind-variable"},{"id":103,"kind":32,"name":"ClientHttpError","url":"modules.html#clienthttperror","classes":"tsd-kind-variable"},{"id":104,"kind":32,"name":"ServerHttpError","url":"modules.html#serverhttperror","classes":"tsd-kind-variable"},{"id":105,"kind":32,"name":"TimeoutHttpError","url":"modules.html#timeouthttperror","classes":"tsd-kind-variable"},{"id":106,"kind":32,"name":"AbortedHttpError","url":"modules.html#abortedhttperror","classes":"tsd-kind-variable"},{"id":107,"kind":32,"name":"ResponseDataTypeMismatchError","url":"modules.html#responsedatatypemismatcherror","classes":"tsd-kind-variable"},{"id":108,"kind":32,"name":"DownloadError","url":"modules.html#downloaderror","classes":"tsd-kind-variable"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,29.957]],["parent/0",[]],["name/1",[1,42.95]],["parent/1",[0,2.715]],["name/2",[2,42.95]],["parent/2",[0,2.715]],["name/3",[3,42.95]],["parent/3",[0,2.715]],["name/4",[4,42.95]],["parent/4",[0,2.715]],["name/5",[5,24.492]],["parent/5",[]],["name/6",[6,26.856]],["parent/6",[5,2.22]],["name/7",[7,28.287]],["parent/7",[5,2.22]],["name/8",[8,28.287]],["parent/8",[5,2.22]],["name/9",[9,26.856]],["parent/9",[5,2.22]],["name/10",[10,26.856]],["parent/10",[5,2.22]],["name/11",[11,23.491]],["parent/11",[5,2.22]],["name/12",[12,26.856]],["parent/12",[5,2.22]],["name/13",[13,22.581]],["parent/13",[5,2.22]],["name/14",[14,24.492]],["parent/14",[]],["name/15",[6,26.856]],["parent/15",[14,2.22]],["name/16",[7,28.287]],["parent/16",[14,2.22]],["name/17",[8,28.287]],["parent/17",[14,2.22]],["name/18",[9,26.856]],["parent/18",[14,2.22]],["name/19",[10,26.856]],["parent/19",[14,2.22]],["name/20",[11,23.491]],["parent/20",[14,2.22]],["name/21",[12,26.856]],["parent/21",[14,2.22]],["name/22",[13,22.581]],["parent/22",[14,2.22]],["name/23",[15,24.492]],["parent/23",[]],["name/24",[6,26.856]],["parent/24",[15,2.22]],["name/25",[7,28.287]],["parent/25",[15,2.22]],["name/26",[8,28.287]],["parent/26",[15,2.22]],["name/27",[9,26.856]],["parent/27",[15,2.22]],["name/28",[10,26.856]],["parent/28",[15,2.22]],["name/29",[11,23.491]],["parent/29",[15,2.22]],["name/30",[12,26.856]],["parent/30",[15,2.22]],["name/31",[13,22.581]],["parent/31",[15,2.22]],["name/32",[16,24.492]],["parent/32",[]],["name/33",[6,26.856]],["parent/33",[16,2.22]],["name/34",[7,28.287]],["parent/34",[16,2.22]],["name/35",[8,28.287]],["parent/35",[16,2.22]],["name/36",[9,26.856]],["parent/36",[16,2.22]],["name/37",[10,26.856]],["parent/37",[16,2.22]],["name/38",[11,23.491]],["parent/38",[16,2.22]],["name/39",[12,26.856]],["parent/39",[16,2.22]],["name/40",[13,22.581]],["parent/40",[16,2.22]],["name/41",[17,24.492]],["parent/41",[]],["name/42",[6,26.856]],["parent/42",[17,2.22]],["name/43",[7,28.287]],["parent/43",[17,2.22]],["name/44",[8,28.287]],["parent/44",[17,2.22]],["name/45",[9,26.856]],["parent/45",[17,2.22]],["name/46",[10,26.856]],["parent/46",[17,2.22]],["name/47",[11,23.491]],["parent/47",[17,2.22]],["name/48",[12,26.856]],["parent/48",[17,2.22]],["name/49",[13,22.581]],["parent/49",[17,2.22]],["name/50",[18,24.492]],["parent/50",[]],["name/51",[6,26.856]],["parent/51",[18,2.22]],["name/52",[7,28.287]],["parent/52",[18,2.22]],["name/53",[8,28.287]],["parent/53",[18,2.22]],["name/54",[9,26.856]],["parent/54",[18,2.22]],["name/55",[10,26.856]],["parent/55",[18,2.22]],["name/56",[11,23.491]],["parent/56",[18,2.22]],["name/57",[12,26.856]],["parent/57",[18,2.22]],["name/58",[13,22.581]],["parent/58",[18,2.22]],["name/59",[19,21.748]],["parent/59",[]],["name/60",[20,42.95]],["parent/60",[19,1.971]],["name/61",[13,22.581]],["parent/61",[19,1.971]],["name/62",[9,26.856]],["parent/62",[19,1.971]],["name/63",[21,42.95]],["parent/63",[19,1.971]],["name/64",[22,42.95]],["parent/64",[19,1.971]],["name/65",[23,42.95]],["parent/65",[19,1.971]],["name/66",[24,37.842]],["parent/66",[19,1.971]],["name/67",[25,42.95]],["parent/67",[19,1.971]],["name/68",[24,37.842]],["parent/68",[19,1.971]],["name/69",[26,42.95]],["parent/69",[19,1.971]],["name/70",[27,42.95]],["parent/70",[19,1.971]],["name/71",[28,34.477]],["parent/71",[]],["name/72",[13,22.581]],["parent/72",[28,3.124]],["name/73",[11,23.491]],["parent/73",[28,3.124]],["name/74",[29,31.964]],["parent/74",[]],["name/75",[13,22.581]],["parent/75",[29,2.897]],["name/76",[11,23.491]],["parent/76",[29,2.897]],["name/77",[12,26.856]],["parent/77",[29,2.897]],["name/78",[30,34.477]],["parent/78",[]],["name/79",[13,22.581]],["parent/79",[30,3.124]],["name/80",[11,23.491]],["parent/80",[30,3.124]],["name/81",[31,34.477]],["parent/81",[]],["name/82",[13,22.581]],["parent/82",[31,3.124]],["name/83",[11,23.491]],["parent/83",[31,3.124]],["name/84",[32,18.971]],["parent/84",[]],["name/85",[6,26.856]],["parent/85",[32,1.719]],["name/86",[33,42.95]],["parent/86",[32,1.719]],["name/87",[34,42.95]],["parent/87",[32,1.719]],["name/88",[35,42.95]],["parent/88",[32,1.719]],["name/89",[36,42.95]],["parent/89",[32,1.719]],["name/90",[37,42.95]],["parent/90",[32,1.719]],["name/91",[38,42.95]],["parent/91",[32,1.719]],["name/92",[39,42.95]],["parent/92",[32,1.719]],["name/93",[40,42.95]],["parent/93",[32,1.719]],["name/94",[41,42.95]],["parent/94",[32,1.719]],["name/95",[42,42.95]],["parent/95",[32,1.719]],["name/96",[43,42.95]],["parent/96",[32,1.719]],["name/97",[44,42.95]],["parent/97",[32,1.719]],["name/98",[10,26.856]],["parent/98",[32,1.719]],["name/99",[45,42.95]],["parent/99",[32,1.719]],["name/100",[46,42.95]],["parent/100",[]],["name/101",[47,42.95]],["parent/101",[]],["name/102",[48,42.95]],["parent/102",[]],["name/103",[49,42.95]],["parent/103",[]],["name/104",[50,42.95]],["parent/104",[]],["name/105",[51,42.95]],["parent/105",[]],["name/106",[52,42.95]],["parent/106",[]],["name/107",[53,42.95]],["parent/107",[]],["name/108",[54,42.95]],["parent/108",[]]],"invertedIndex":[["__type",{"_index":24,"name":{"66":{},"68":{}},"parent":{}}],["_buildfetchoptions",{"_index":37,"name":{"90":{}},"parent":{}}],["_buildurl",{"_index":39,"name":{"92":{}},"parent":{}}],["_buildurlbase",{"_index":38,"name":{"91":{}},"parent":{}}],["_getbody",{"_index":36,"name":{"89":{}},"parent":{}}],["_getcontenttype",{"_index":35,"name":{"88":{}},"parent":{}}],["_gettype",{"_index":34,"name":{"87":{}},"parent":{}}],["_options",{"_index":33,"name":{"86":{}},"parent":{}}],["_request",{"_index":45,"name":{"99":{}},"parent":{}}],["abortedhttperror",{"_index":52,"name":{"106":{}},"parent":{}}],["abortedresponse",{"_index":5,"name":{"5":{}},"parent":{"6":{},"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{}}}],["apiclient",{"_index":32,"name":{"84":{}},"parent":{"85":{},"86":{},"87":{},"88":{},"89":{},"90":{},"91":{},"92":{},"93":{},"94":{},"95":{},"96":{},"97":{},"98":{},"99":{}}}],["base",{"_index":20,"name":{"60":{}},"parent":{}}],["binary",{"_index":3,"name":{"3":{}},"parent":{}}],["body",{"_index":11,"name":{"11":{},"20":{},"29":{},"38":{},"47":{},"56":{},"73":{},"76":{},"80":{},"83":{}},"parent":{}}],["clienterrorresponse",{"_index":17,"name":{"41":{}},"parent":{"42":{},"43":{},"44":{},"45":{},"46":{},"47":{},"48":{},"49":{}}}],["clienthttperror",{"_index":49,"name":{"103":{}},"parent":{}}],["configure",{"_index":46,"name":{"100":{}},"parent":{}}],["constructor",{"_index":6,"name":{"6":{},"15":{},"24":{},"33":{},"42":{},"51":{},"85":{}},"parent":{}}],["delete",{"_index":43,"name":{"96":{}},"parent":{}}],["download",{"_index":47,"name":{"101":{}},"parent":{}}],["downloaderror",{"_index":54,"name":{"108":{}},"parent":{}}],["get",{"_index":40,"name":{"93":{}},"parent":{}}],["head",{"_index":44,"name":{"97":{}},"parent":{}}],["headers",{"_index":9,"name":{"9":{},"18":{},"27":{},"36":{},"45":{},"54":{},"62":{}},"parent":{}}],["httperror",{"_index":48,"name":{"102":{}},"parent":{}}],["informationalresponse",{"_index":14,"name":{"14":{}},"parent":{"15":{},"16":{},"17":{},"18":{},"19":{},"20":{},"21":{},"22":{}}}],["json",{"_index":1,"name":{"1":{}},"parent":{}}],["options",{"_index":19,"name":{"59":{}},"parent":{"60":{},"61":{},"62":{},"63":{},"64":{},"65":{},"66":{},"67":{},"68":{},"69":{},"70":{}}}],["patch",{"_index":42,"name":{"95":{}},"parent":{}}],["post",{"_index":41,"name":{"94":{}},"parent":{}}],["rawbody",{"_index":12,"name":{"12":{},"21":{},"30":{},"39":{},"48":{},"57":{},"77":{}},"parent":{}}],["redirectresponse",{"_index":16,"name":{"32":{}},"parent":{"33":{},"34":{},"35":{},"36":{},"37":{},"38":{},"39":{},"40":{}}}],["request",{"_index":10,"name":{"10":{},"19":{},"28":{},"37":{},"46":{},"55":{},"98":{}},"parent":{}}],["requesttype",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{}}}],["responsedatabinary",{"_index":30,"name":{"78":{}},"parent":{"79":{},"80":{}}}],["responsedatajson",{"_index":28,"name":{"71":{}},"parent":{"72":{},"73":{}}}],["responsedatastream",{"_index":31,"name":{"81":{}},"parent":{"82":{},"83":{}}}],["responsedatatext",{"_index":29,"name":{"74":{}},"parent":{"75":{},"76":{},"77":{}}}],["responsedatatypemismatcherror",{"_index":53,"name":{"107":{}},"parent":{}}],["retry",{"_index":21,"name":{"63":{}},"parent":{}}],["retryinterval",{"_index":22,"name":{"64":{}},"parent":{}}],["retrypolicy",{"_index":23,"name":{"65":{}},"parent":{}}],["retrywaitpolicy",{"_index":25,"name":{"67":{}},"parent":{}}],["servererrorresponse",{"_index":18,"name":{"50":{}},"parent":{"51":{},"52":{},"53":{},"54":{},"55":{},"56":{},"57":{},"58":{}}}],["serverhttperror",{"_index":50,"name":{"104":{}},"parent":{}}],["status",{"_index":7,"name":{"7":{},"16":{},"25":{},"34":{},"43":{},"52":{}},"parent":{}}],["statustext",{"_index":8,"name":{"8":{},"17":{},"26":{},"35":{},"44":{},"53":{}},"parent":{}}],["stream",{"_index":4,"name":{"4":{}},"parent":{}}],["successresponse",{"_index":15,"name":{"23":{}},"parent":{"24":{},"25":{},"26":{},"27":{},"28":{},"29":{},"30":{},"31":{}}}],["text",{"_index":2,"name":{"2":{}},"parent":{}}],["timeout",{"_index":26,"name":{"69":{}},"parent":{}}],["timeouthttperror",{"_index":51,"name":{"105":{}},"parent":{}}],["totaltimeout",{"_index":27,"name":{"70":{}},"parent":{}}],["type",{"_index":13,"name":{"13":{},"22":{},"31":{},"40":{},"49":{},"58":{},"61":{},"72":{},"75":{},"79":{},"82":{}},"parent":{}}]],"pipeline":[]}}
window.searchData = {"kinds":{"4":"Enumeration","16":"Enumeration member","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal"},"rows":[{"id":0,"kind":4,"name":"RequestType","url":"enums/requesttype.html","classes":"tsd-kind-enum"},{"id":1,"kind":16,"name":"json","url":"enums/requesttype.html#json","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":2,"kind":16,"name":"text","url":"enums/requesttype.html#text","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":3,"kind":16,"name":"binary","url":"enums/requesttype.html#binary","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":4,"kind":16,"name":"stream","url":"enums/requesttype.html#stream","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"RequestType"},{"id":5,"kind":128,"name":"AbortedResponse","url":"classes/abortedresponse.html","classes":"tsd-kind-class"},{"id":6,"kind":512,"name":"constructor","url":"classes/abortedresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":7,"kind":1024,"name":"status","url":"classes/abortedresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":8,"kind":1024,"name":"statusText","url":"classes/abortedresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":9,"kind":1024,"name":"headers","url":"classes/abortedresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":10,"kind":1024,"name":"request","url":"classes/abortedresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":11,"kind":1024,"name":"body","url":"classes/abortedresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":12,"kind":1024,"name":"rawBody","url":"classes/abortedresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":13,"kind":1024,"name":"type","url":"classes/abortedresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"AbortedResponse"},{"id":14,"kind":128,"name":"InformationalResponse","url":"classes/informationalresponse.html","classes":"tsd-kind-class"},{"id":15,"kind":512,"name":"constructor","url":"classes/informationalresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":16,"kind":1024,"name":"status","url":"classes/informationalresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":17,"kind":1024,"name":"statusText","url":"classes/informationalresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":18,"kind":1024,"name":"headers","url":"classes/informationalresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":19,"kind":1024,"name":"request","url":"classes/informationalresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":20,"kind":1024,"name":"body","url":"classes/informationalresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":21,"kind":1024,"name":"rawBody","url":"classes/informationalresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":22,"kind":1024,"name":"type","url":"classes/informationalresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"InformationalResponse"},{"id":23,"kind":128,"name":"SuccessResponse","url":"classes/successresponse.html","classes":"tsd-kind-class"},{"id":24,"kind":512,"name":"constructor","url":"classes/successresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":25,"kind":1024,"name":"status","url":"classes/successresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":26,"kind":1024,"name":"statusText","url":"classes/successresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":27,"kind":1024,"name":"headers","url":"classes/successresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":28,"kind":1024,"name":"request","url":"classes/successresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":29,"kind":1024,"name":"body","url":"classes/successresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":30,"kind":1024,"name":"rawBody","url":"classes/successresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":31,"kind":1024,"name":"type","url":"classes/successresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"SuccessResponse"},{"id":32,"kind":128,"name":"RedirectResponse","url":"classes/redirectresponse.html","classes":"tsd-kind-class"},{"id":33,"kind":512,"name":"constructor","url":"classes/redirectresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":34,"kind":1024,"name":"status","url":"classes/redirectresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":35,"kind":1024,"name":"statusText","url":"classes/redirectresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":36,"kind":1024,"name":"headers","url":"classes/redirectresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":37,"kind":1024,"name":"request","url":"classes/redirectresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":38,"kind":1024,"name":"body","url":"classes/redirectresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":39,"kind":1024,"name":"rawBody","url":"classes/redirectresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":40,"kind":1024,"name":"type","url":"classes/redirectresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"RedirectResponse"},{"id":41,"kind":128,"name":"ClientErrorResponse","url":"classes/clienterrorresponse.html","classes":"tsd-kind-class"},{"id":42,"kind":512,"name":"constructor","url":"classes/clienterrorresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":43,"kind":1024,"name":"status","url":"classes/clienterrorresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":44,"kind":1024,"name":"statusText","url":"classes/clienterrorresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":45,"kind":1024,"name":"headers","url":"classes/clienterrorresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":46,"kind":1024,"name":"request","url":"classes/clienterrorresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":47,"kind":1024,"name":"body","url":"classes/clienterrorresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":48,"kind":1024,"name":"rawBody","url":"classes/clienterrorresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":49,"kind":1024,"name":"type","url":"classes/clienterrorresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ClientErrorResponse"},{"id":50,"kind":128,"name":"ServerErrorResponse","url":"classes/servererrorresponse.html","classes":"tsd-kind-class"},{"id":51,"kind":512,"name":"constructor","url":"classes/servererrorresponse.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":52,"kind":1024,"name":"status","url":"classes/servererrorresponse.html#status","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":53,"kind":1024,"name":"statusText","url":"classes/servererrorresponse.html#statustext","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":54,"kind":1024,"name":"headers","url":"classes/servererrorresponse.html#headers","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":55,"kind":1024,"name":"request","url":"classes/servererrorresponse.html#request","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":56,"kind":1024,"name":"body","url":"classes/servererrorresponse.html#body","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":57,"kind":1024,"name":"rawBody","url":"classes/servererrorresponse.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":58,"kind":1024,"name":"type","url":"classes/servererrorresponse.html#type","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited","parent":"ServerErrorResponse"},{"id":59,"kind":256,"name":"Options","url":"interfaces/options.html","classes":"tsd-kind-interface"},{"id":60,"kind":1024,"name":"base","url":"interfaces/options.html#base","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":61,"kind":1024,"name":"type","url":"interfaces/options.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":62,"kind":1024,"name":"headers","url":"interfaces/options.html#headers","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":63,"kind":1024,"name":"retry","url":"interfaces/options.html#retry","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":64,"kind":1024,"name":"retryInterval","url":"interfaces/options.html#retryinterval","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":65,"kind":1024,"name":"retryPolicy","url":"interfaces/options.html#retrypolicy","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":66,"kind":65536,"name":"__type","url":"interfaces/options.html#__type","classes":"tsd-kind-type-literal tsd-parent-kind-interface","parent":"Options"},{"id":67,"kind":1024,"name":"retryWaitPolicy","url":"interfaces/options.html#retrywaitpolicy","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":68,"kind":65536,"name":"__type","url":"interfaces/options.html#__type-1","classes":"tsd-kind-type-literal tsd-parent-kind-interface","parent":"Options"},{"id":69,"kind":1024,"name":"timeout","url":"interfaces/options.html#timeout","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":70,"kind":1024,"name":"totalTimeout","url":"interfaces/options.html#totaltimeout","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":71,"kind":1024,"name":"cache","url":"interfaces/options.html#cache","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":72,"kind":1024,"name":"cacheKey","url":"interfaces/options.html#cachekey","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":73,"kind":1024,"name":"shouldCacheResponse","url":"interfaces/options.html#shouldcacheresponse","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Options"},{"id":74,"kind":256,"name":"ResponseDataJSON","url":"interfaces/responsedatajson.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":75,"kind":1024,"name":"type","url":"interfaces/responsedatajson.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataJSON"},{"id":76,"kind":1024,"name":"body","url":"interfaces/responsedatajson.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataJSON"},{"id":77,"kind":256,"name":"ResponseDataText","url":"interfaces/responsedatatext.html","classes":"tsd-kind-interface"},{"id":78,"kind":1024,"name":"type","url":"interfaces/responsedatatext.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":79,"kind":1024,"name":"body","url":"interfaces/responsedatatext.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":80,"kind":1024,"name":"rawBody","url":"interfaces/responsedatatext.html#rawbody","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataText"},{"id":81,"kind":256,"name":"ResponseDataBinary","url":"interfaces/responsedatabinary.html","classes":"tsd-kind-interface"},{"id":82,"kind":1024,"name":"type","url":"interfaces/responsedatabinary.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataBinary"},{"id":83,"kind":1024,"name":"body","url":"interfaces/responsedatabinary.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataBinary"},{"id":84,"kind":256,"name":"ResponseDataStream","url":"interfaces/responsedatastream.html","classes":"tsd-kind-interface"},{"id":85,"kind":1024,"name":"type","url":"interfaces/responsedatastream.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataStream"},{"id":86,"kind":1024,"name":"body","url":"interfaces/responsedatastream.html#body","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ResponseDataStream"},{"id":87,"kind":128,"name":"ApiClient","url":"classes/apiclient.html","classes":"tsd-kind-class"},{"id":88,"kind":2048,"name":"_serveResponse","url":"classes/apiclient.html#_serveresponse","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-private tsd-is-static","parent":"ApiClient"},{"id":89,"kind":2048,"name":"stringifyResponse","url":"classes/apiclient.html#stringifyresponse","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"ApiClient"},{"id":90,"kind":2048,"name":"parseStringifiedReponse","url":"classes/apiclient.html#parsestringifiedreponse","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"ApiClient"},{"id":91,"kind":512,"name":"constructor","url":"classes/apiclient.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"ApiClient"},{"id":92,"kind":1024,"name":"_options","url":"classes/apiclient.html#_options","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":93,"kind":2048,"name":"_getType","url":"classes/apiclient.html#_gettype","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":94,"kind":2048,"name":"_getContentType","url":"classes/apiclient.html#_getcontenttype","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":95,"kind":2048,"name":"_getBody","url":"classes/apiclient.html#_getbody","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":96,"kind":2048,"name":"_buildFetchOptions","url":"classes/apiclient.html#_buildfetchoptions","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":97,"kind":2048,"name":"_buildUrlBase","url":"classes/apiclient.html#_buildurlbase","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":98,"kind":2048,"name":"_buildUrl","url":"classes/apiclient.html#_buildurl","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"ApiClient"},{"id":99,"kind":2048,"name":"get","url":"classes/apiclient.html#get","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":100,"kind":2048,"name":"post","url":"classes/apiclient.html#post","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":101,"kind":2048,"name":"patch","url":"classes/apiclient.html#patch","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":102,"kind":2048,"name":"delete","url":"classes/apiclient.html#delete","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":103,"kind":2048,"name":"head","url":"classes/apiclient.html#head","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":104,"kind":2048,"name":"request","url":"classes/apiclient.html#request","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"ApiClient"},{"id":105,"kind":2048,"name":"_request","url":"classes/apiclient.html#_request","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-private","parent":"ApiClient"},{"id":106,"kind":64,"name":"configure","url":"modules.html#configure","classes":"tsd-kind-function"},{"id":107,"kind":64,"name":"download","url":"modules.html#download","classes":"tsd-kind-function"},{"id":108,"kind":32,"name":"HttpError","url":"modules.html#httperror","classes":"tsd-kind-variable"},{"id":109,"kind":32,"name":"ClientHttpError","url":"modules.html#clienthttperror","classes":"tsd-kind-variable"},{"id":110,"kind":32,"name":"ServerHttpError","url":"modules.html#serverhttperror","classes":"tsd-kind-variable"},{"id":111,"kind":32,"name":"TimeoutHttpError","url":"modules.html#timeouthttperror","classes":"tsd-kind-variable"},{"id":112,"kind":32,"name":"AbortedHttpError","url":"modules.html#abortedhttperror","classes":"tsd-kind-variable"},{"id":113,"kind":32,"name":"ResponseDataTypeMismatchError","url":"modules.html#responsedatatypemismatcherror","classes":"tsd-kind-variable"},{"id":114,"kind":32,"name":"DownloadError","url":"modules.html#downloaderror","classes":"tsd-kind-variable"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,30.488]],["parent/0",[]],["name/1",[1,43.481]],["parent/1",[0,2.78]],["name/2",[2,43.481]],["parent/2",[0,2.78]],["name/3",[3,43.481]],["parent/3",[0,2.78]],["name/4",[4,43.481]],["parent/4",[0,2.78]],["name/5",[5,25.023]],["parent/5",[]],["name/6",[6,27.387]],["parent/6",[5,2.282]],["name/7",[7,28.818]],["parent/7",[5,2.282]],["name/8",[8,28.818]],["parent/8",[5,2.282]],["name/9",[9,27.387]],["parent/9",[5,2.282]],["name/10",[10,27.387]],["parent/10",[5,2.282]],["name/11",[11,24.022]],["parent/11",[5,2.282]],["name/12",[12,27.387]],["parent/12",[5,2.282]],["name/13",[13,23.112]],["parent/13",[5,2.282]],["name/14",[14,25.023]],["parent/14",[]],["name/15",[6,27.387]],["parent/15",[14,2.282]],["name/16",[7,28.818]],["parent/16",[14,2.282]],["name/17",[8,28.818]],["parent/17",[14,2.282]],["name/18",[9,27.387]],["parent/18",[14,2.282]],["name/19",[10,27.387]],["parent/19",[14,2.282]],["name/20",[11,24.022]],["parent/20",[14,2.282]],["name/21",[12,27.387]],["parent/21",[14,2.282]],["name/22",[13,23.112]],["parent/22",[14,2.282]],["name/23",[15,25.023]],["parent/23",[]],["name/24",[6,27.387]],["parent/24",[15,2.282]],["name/25",[7,28.818]],["parent/25",[15,2.282]],["name/26",[8,28.818]],["parent/26",[15,2.282]],["name/27",[9,27.387]],["parent/27",[15,2.282]],["name/28",[10,27.387]],["parent/28",[15,2.282]],["name/29",[11,24.022]],["parent/29",[15,2.282]],["name/30",[12,27.387]],["parent/30",[15,2.282]],["name/31",[13,23.112]],["parent/31",[15,2.282]],["name/32",[16,25.023]],["parent/32",[]],["name/33",[6,27.387]],["parent/33",[16,2.282]],["name/34",[7,28.818]],["parent/34",[16,2.282]],["name/35",[8,28.818]],["parent/35",[16,2.282]],["name/36",[9,27.387]],["parent/36",[16,2.282]],["name/37",[10,27.387]],["parent/37",[16,2.282]],["name/38",[11,24.022]],["parent/38",[16,2.282]],["name/39",[12,27.387]],["parent/39",[16,2.282]],["name/40",[13,23.112]],["parent/40",[16,2.282]],["name/41",[17,25.023]],["parent/41",[]],["name/42",[6,27.387]],["parent/42",[17,2.282]],["name/43",[7,28.818]],["parent/43",[17,2.282]],["name/44",[8,28.818]],["parent/44",[17,2.282]],["name/45",[9,27.387]],["parent/45",[17,2.282]],["name/46",[10,27.387]],["parent/46",[17,2.282]],["name/47",[11,24.022]],["parent/47",[17,2.282]],["name/48",[12,27.387]],["parent/48",[17,2.282]],["name/49",[13,23.112]],["parent/49",[17,2.282]],["name/50",[18,25.023]],["parent/50",[]],["name/51",[6,27.387]],["parent/51",[18,2.282]],["name/52",[7,28.818]],["parent/52",[18,2.282]],["name/53",[8,28.818]],["parent/53",[18,2.282]],["name/54",[9,27.387]],["parent/54",[18,2.282]],["name/55",[10,27.387]],["parent/55",[18,2.282]],["name/56",[11,24.022]],["parent/56",[18,2.282]],["name/57",[12,27.387]],["parent/57",[18,2.282]],["name/58",[13,23.112]],["parent/58",[18,2.282]],["name/59",[19,20.128]],["parent/59",[]],["name/60",[20,43.481]],["parent/60",[19,1.835]],["name/61",[13,23.112]],["parent/61",[19,1.835]],["name/62",[9,27.387]],["parent/62",[19,1.835]],["name/63",[21,43.481]],["parent/63",[19,1.835]],["name/64",[22,43.481]],["parent/64",[19,1.835]],["name/65",[23,43.481]],["parent/65",[19,1.835]],["name/66",[24,38.373]],["parent/66",[19,1.835]],["name/67",[25,43.481]],["parent/67",[19,1.835]],["name/68",[24,38.373]],["parent/68",[19,1.835]],["name/69",[26,43.481]],["parent/69",[19,1.835]],["name/70",[27,43.481]],["parent/70",[19,1.835]],["name/71",[28,43.481]],["parent/71",[19,1.835]],["name/72",[29,43.481]],["parent/72",[19,1.835]],["name/73",[30,43.481]],["parent/73",[19,1.835]],["name/74",[31,35.008]],["parent/74",[]],["name/75",[13,23.112]],["parent/75",[31,3.192]],["name/76",[11,24.022]],["parent/76",[31,3.192]],["name/77",[32,32.495]],["parent/77",[]],["name/78",[13,23.112]],["parent/78",[32,2.963]],["name/79",[11,24.022]],["parent/79",[32,2.963]],["name/80",[12,27.387]],["parent/80",[32,2.963]],["name/81",[33,35.008]],["parent/81",[]],["name/82",[13,23.112]],["parent/82",[33,3.192]],["name/83",[11,24.022]],["parent/83",[33,3.192]],["name/84",[34,35.008]],["parent/84",[]],["name/85",[13,23.112]],["parent/85",[34,3.192]],["name/86",[11,24.022]],["parent/86",[34,3.192]],["name/87",[35,17.832]],["parent/87",[]],["name/88",[36,43.481]],["parent/88",[35,1.626]],["name/89",[37,43.481]],["parent/89",[35,1.626]],["name/90",[38,43.481]],["parent/90",[35,1.626]],["name/91",[6,27.387]],["parent/91",[35,1.626]],["name/92",[39,43.481]],["parent/92",[35,1.626]],["name/93",[40,43.481]],["parent/93",[35,1.626]],["name/94",[41,43.481]],["parent/94",[35,1.626]],["name/95",[42,43.481]],["parent/95",[35,1.626]],["name/96",[43,43.481]],["parent/96",[35,1.626]],["name/97",[44,43.481]],["parent/97",[35,1.626]],["name/98",[45,43.481]],["parent/98",[35,1.626]],["name/99",[46,43.481]],["parent/99",[35,1.626]],["name/100",[47,43.481]],["parent/100",[35,1.626]],["name/101",[48,43.481]],["parent/101",[35,1.626]],["name/102",[49,43.481]],["parent/102",[35,1.626]],["name/103",[50,43.481]],["parent/103",[35,1.626]],["name/104",[10,27.387]],["parent/104",[35,1.626]],["name/105",[51,43.481]],["parent/105",[35,1.626]],["name/106",[52,43.481]],["parent/106",[]],["name/107",[53,43.481]],["parent/107",[]],["name/108",[54,43.481]],["parent/108",[]],["name/109",[55,43.481]],["parent/109",[]],["name/110",[56,43.481]],["parent/110",[]],["name/111",[57,43.481]],["parent/111",[]],["name/112",[58,43.481]],["parent/112",[]],["name/113",[59,43.481]],["parent/113",[]],["name/114",[60,43.481]],["parent/114",[]]],"invertedIndex":[["__type",{"_index":24,"name":{"66":{},"68":{}},"parent":{}}],["_buildfetchoptions",{"_index":43,"name":{"96":{}},"parent":{}}],["_buildurl",{"_index":45,"name":{"98":{}},"parent":{}}],["_buildurlbase",{"_index":44,"name":{"97":{}},"parent":{}}],["_getbody",{"_index":42,"name":{"95":{}},"parent":{}}],["_getcontenttype",{"_index":41,"name":{"94":{}},"parent":{}}],["_gettype",{"_index":40,"name":{"93":{}},"parent":{}}],["_options",{"_index":39,"name":{"92":{}},"parent":{}}],["_request",{"_index":51,"name":{"105":{}},"parent":{}}],["_serveresponse",{"_index":36,"name":{"88":{}},"parent":{}}],["abortedhttperror",{"_index":58,"name":{"112":{}},"parent":{}}],["abortedresponse",{"_index":5,"name":{"5":{}},"parent":{"6":{},"7":{},"8":{},"9":{},"10":{},"11":{},"12":{},"13":{}}}],["apiclient",{"_index":35,"name":{"87":{}},"parent":{"88":{},"89":{},"90":{},"91":{},"92":{},"93":{},"94":{},"95":{},"96":{},"97":{},"98":{},"99":{},"100":{},"101":{},"102":{},"103":{},"104":{},"105":{}}}],["base",{"_index":20,"name":{"60":{}},"parent":{}}],["binary",{"_index":3,"name":{"3":{}},"parent":{}}],["body",{"_index":11,"name":{"11":{},"20":{},"29":{},"38":{},"47":{},"56":{},"76":{},"79":{},"83":{},"86":{}},"parent":{}}],["cache",{"_index":28,"name":{"71":{}},"parent":{}}],["cachekey",{"_index":29,"name":{"72":{}},"parent":{}}],["clienterrorresponse",{"_index":17,"name":{"41":{}},"parent":{"42":{},"43":{},"44":{},"45":{},"46":{},"47":{},"48":{},"49":{}}}],["clienthttperror",{"_index":55,"name":{"109":{}},"parent":{}}],["configure",{"_index":52,"name":{"106":{}},"parent":{}}],["constructor",{"_index":6,"name":{"6":{},"15":{},"24":{},"33":{},"42":{},"51":{},"91":{}},"parent":{}}],["delete",{"_index":49,"name":{"102":{}},"parent":{}}],["download",{"_index":53,"name":{"107":{}},"parent":{}}],["downloaderror",{"_index":60,"name":{"114":{}},"parent":{}}],["get",{"_index":46,"name":{"99":{}},"parent":{}}],["head",{"_index":50,"name":{"103":{}},"parent":{}}],["headers",{"_index":9,"name":{"9":{},"18":{},"27":{},"36":{},"45":{},"54":{},"62":{}},"parent":{}}],["httperror",{"_index":54,"name":{"108":{}},"parent":{}}],["informationalresponse",{"_index":14,"name":{"14":{}},"parent":{"15":{},"16":{},"17":{},"18":{},"19":{},"20":{},"21":{},"22":{}}}],["json",{"_index":1,"name":{"1":{}},"parent":{}}],["options",{"_index":19,"name":{"59":{}},"parent":{"60":{},"61":{},"62":{},"63":{},"64":{},"65":{},"66":{},"67":{},"68":{},"69":{},"70":{},"71":{},"72":{},"73":{}}}],["parsestringifiedreponse",{"_index":38,"name":{"90":{}},"parent":{}}],["patch",{"_index":48,"name":{"101":{}},"parent":{}}],["post",{"_index":47,"name":{"100":{}},"parent":{}}],["rawbody",{"_index":12,"name":{"12":{},"21":{},"30":{},"39":{},"48":{},"57":{},"80":{}},"parent":{}}],["redirectresponse",{"_index":16,"name":{"32":{}},"parent":{"33":{},"34":{},"35":{},"36":{},"37":{},"38":{},"39":{},"40":{}}}],["request",{"_index":10,"name":{"10":{},"19":{},"28":{},"37":{},"46":{},"55":{},"104":{}},"parent":{}}],["requesttype",{"_index":0,"name":{"0":{}},"parent":{"1":{},"2":{},"3":{},"4":{}}}],["responsedatabinary",{"_index":33,"name":{"81":{}},"parent":{"82":{},"83":{}}}],["responsedatajson",{"_index":31,"name":{"74":{}},"parent":{"75":{},"76":{}}}],["responsedatastream",{"_index":34,"name":{"84":{}},"parent":{"85":{},"86":{}}}],["responsedatatext",{"_index":32,"name":{"77":{}},"parent":{"78":{},"79":{},"80":{}}}],["responsedatatypemismatcherror",{"_index":59,"name":{"113":{}},"parent":{}}],["retry",{"_index":21,"name":{"63":{}},"parent":{}}],["retryinterval",{"_index":22,"name":{"64":{}},"parent":{}}],["retrypolicy",{"_index":23,"name":{"65":{}},"parent":{}}],["retrywaitpolicy",{"_index":25,"name":{"67":{}},"parent":{}}],["servererrorresponse",{"_index":18,"name":{"50":{}},"parent":{"51":{},"52":{},"53":{},"54":{},"55":{},"56":{},"57":{},"58":{}}}],["serverhttperror",{"_index":56,"name":{"110":{}},"parent":{}}],["shouldcacheresponse",{"_index":30,"name":{"73":{}},"parent":{}}],["status",{"_index":7,"name":{"7":{},"16":{},"25":{},"34":{},"43":{},"52":{}},"parent":{}}],["statustext",{"_index":8,"name":{"8":{},"17":{},"26":{},"35":{},"44":{},"53":{}},"parent":{}}],["stream",{"_index":4,"name":{"4":{}},"parent":{}}],["stringifyresponse",{"_index":37,"name":{"89":{}},"parent":{}}],["successresponse",{"_index":15,"name":{"23":{}},"parent":{"24":{},"25":{},"26":{},"27":{},"28":{},"29":{},"30":{},"31":{}}}],["text",{"_index":2,"name":{"2":{}},"parent":{}}],["timeout",{"_index":26,"name":{"69":{}},"parent":{}}],["timeouthttperror",{"_index":57,"name":{"111":{}},"parent":{}}],["totaltimeout",{"_index":27,"name":{"70":{}},"parent":{}}],["type",{"_index":13,"name":{"13":{},"22":{},"31":{},"40":{},"49":{},"58":{},"61":{},"75":{},"78":{},"82":{},"85":{}},"parent":{}}]],"pipeline":[]}}

@@ -1,3 +0,5 @@

import type { PossibleNonErrorResponses } from "./response/response.js";
import type { Data, Options, URLArgument, BodyArgument, AbortablePromise, ConfigureOptions } from "./types";
import type { CustomError } from "better-custom-error";
import type { Data, Options, URLArgument, BodyArgument, AbortablePromise, ConfigureOptions, PossibleCustomErrorsThrown } from "./types";
import type { PossibleNonErrorResponses, PossibleResponses } from "./response/response.js";
import { ClientErrorResponse, ServerErrorResponse } from "./response/response.js";
declare class ApiClient {

@@ -19,2 +21,5 @@ private readonly _options;

private _request;
private static _serveResponse;
static stringifyResponse(response: PossibleResponses | PossibleCustomErrorsThrown, space?: string | number): string;
static parseStringifiedReponse<T>(string: string): CustomError | import("./response/response.js").AbortedResponse | import("./response/response.js").InformationalResponse | import("./response/response.js").SuccessResponse | import("./response/response.js").RedirectResponse | ClientErrorResponse | ServerErrorResponse;
}

@@ -21,0 +26,0 @@ declare const configure: (options: ConfigureOptions) => void;

@@ -1,2 +0,2 @@

import f from "light-isomorphic-fetch";
import f, { Headers } from "light-isomorphic-fetch";
import qs from "qs";

@@ -6,6 +6,7 @@ import urlJoin from "url-join";

import { Timeout } from "oop-timers";
import hasher from "node-object-hash";
import { ClientHttpError, ServerHttpError, ResponseDataTypeMismatchError, AbortedHttpError, TimeoutHttpError } from "./errors.js";
import { ClientErrorResponse, createResponse, ServerErrorResponse } from "./response/response.js";
import { ClientErrorResponse, createResponse, createResponseWithData, ServerErrorResponse, } from "./response/response.js";
import { contentTypeMap, RequestType } from "./const.js";
import { getJoinedUrl, wait } from "./helpers.js";
import { createNoopFunctionFromString, getJoinedUrl, wait } from "./helpers.js";
import { ApiRequest } from "./request/request.js";

@@ -15,2 +16,3 @@ const stringify = qs.stringify;

let URLParser = URL;
const { hash: ohash } = hasher({ sort: true, coerce: false });
const safeUrlParse = (url) => {

@@ -36,2 +38,19 @@ try {

totalTimeout: 60000,
cache: null,
cacheKey: (req) => {
if (req.method.toLowerCase() !== "get") {
return;
}
return ohash(req);
},
shouldCacheResponse: (response) => {
var _a;
if (!(response instanceof Error)) {
return true;
}
if (((_a = response.details) === null || _a === void 0 ? void 0 : _a.response) instanceof ClientErrorResponse) {
return true;
}
return false;
},
};

@@ -131,3 +150,5 @@ const noop = () => undefined;

const fineOptions = this._buildFetchOptions(options !== null && options !== void 0 ? options : {}, method, body);
let currentController, globalTimeout, aborted = false, isGlobalTimeouted = false;
const fullUrl = this._buildUrl(url, queryParams, fineOptions);
const request = new ApiRequest(fullUrl, fineOptions, url, queryParams);
let cacheKey = undefined, currentController, globalTimeout, aborted = false, isGlobalTimeouted = false;
const globalBreak = () => {

@@ -140,2 +161,20 @@ isGlobalTimeouted = true;

(async () => {
if (fineOptions.cache && fineOptions.cacheKey) {
cacheKey = fineOptions.cacheKey({
url: fullUrl,
method: request.options.method,
headers: request.options.headers,
body: request.options.body,
});
if (cacheKey) {
const cachedResult = await fineOptions.cache.get(cacheKey);
if (cachedResult) {
const result = ApiClient.parseStringifiedReponse(cachedResult);
if (result instanceof Error) {
throw result;
}
return result;
}
}
}
while (fineOptions.retryPolicy({ count: ++count })) {

@@ -170,3 +209,3 @@ let isTimeouted = false;

singleTimeout.start();
return await this._request(url, queryParams, fineOptions, currentController.signal);
return await this._request(request, fineOptions, currentController.signal);
}

@@ -194,3 +233,19 @@ catch (e) {

throw lastError ? lastError : new Error("No error thrown");
})().then(resolve, reject);
})().then((response) => {
resolve(response);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(response)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(response)).catch(noop);
}
}, (error) => {
reject(error);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(error)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(error)).catch(noop);
}
});
});

@@ -209,6 +264,3 @@ future.finally(() => {

}
async _request(originalUrl, queryParams, options, signal) {
const fetchOptions = options;
const url = this._buildUrl(originalUrl, queryParams, fetchOptions);
const request = new ApiRequest(url, fetchOptions, originalUrl, queryParams);
async _request(request, options, signal) {
const result = (await fetch(request.url, {

@@ -219,2 +271,5 @@ ...request.options,

const type = this._getType(options);
return ApiClient._serveResponse(result, type, request);
}
static async _serveResponse(result, type, request) {
const response = await createResponse(result, type, request);

@@ -239,2 +294,57 @@ if ("rawBody" in response) {

}
static stringifyResponse(response, space) {
var _a;
const objToStringify = response instanceof Error
? {
error: response.name,
message: response.message,
details: {
...response.details,
response: (_a = response.details) === null || _a === void 0 ? void 0 : _a.response,
},
}
: response;
return JSON.stringify(objToStringify, function replacer(key, value) {
if (value instanceof Headers) {
const h = {};
Array.from(value.keys()).forEach(mapKey => {
h[mapKey] = value.get(mapKey);
});
return h;
}
if (typeof value === "function") {
return `[Function: ${value.name}]`;
}
return value;
}, space);
}
static parseStringifiedReponse(string) {
const parsedData = JSON.parse(string);
const all = "error" in parsedData ? parsedData.details.response : parsedData;
const status = all.status;
const statusText = all.statusText;
const headers = new Headers(all.headers);
const request = new ApiRequest(all.request.url, {
...all.request.options,
retryPolicy: createNoopFunctionFromString(all.request.options.retryPolicy),
retryWaitPolicy: createNoopFunctionFromString(all.request.options.retryWaitPolicy),
}, all.request.originalUrl, all.request.queryParams);
const body = all.body;
const rawBody = all.rawBody;
const type = all.type;
const data = {
type, body, rawBody,
};
if (rawBody == null) {
delete data.rawBody;
}
const response = createResponseWithData({ status, statusText, headers }, type, request, data);
if (!("error" in parsedData)) {
return response;
}
return new ResponseDataTypeMismatchError(parsedData.message, {
...parsedData.details,
response,
});
}
}

@@ -241,0 +351,0 @@ const configure = (options) => {

declare const getJoinedUrl: (url: string | string[]) => string;
declare const wait: (time: number) => Promise<unknown>;
export { getJoinedUrl, wait, };
declare const createNoopFunctionFromString: (s: string) => () => undefined;
export { getJoinedUrl, wait, createNoopFunctionFromString, };
//# sourceMappingURL=helpers.d.ts.map

@@ -9,3 +9,14 @@ import urlJoin from "url-join";

const wait = async (time) => new Promise(resolve => setTimeout(resolve, time));
export { getJoinedUrl, wait, };
const FUNCTION_NAME_BEGIN_INDEX = 11;
const FUNCTION_NAME_END_INDEX = -1;
const getFunctionNameFromString = (s) => {
return s.substring(FUNCTION_NAME_BEGIN_INDEX, s.length + (FUNCTION_NAME_END_INDEX - 1));
};
const createNoopFunctionFromString = (s) => {
const name = getFunctionNameFromString(s);
const fn = () => undefined;
Object.defineProperty(fn, "name", { value: name });
return fn;
};
export { getJoinedUrl, wait, createNoopFunctionFromString, };
//# sourceMappingURL=helpers.js.map
import type { Response as NodeFetchResponse, Headers as NodeFetchHeaders } from "node-fetch";
import type { RequestType } from "../const.js";
import type { ApiRequest } from "../request/request.js";
import type { ResponseData } from "../types.js";
import type { FetchLikeData, ResponseData } from "../types.js";
declare class ApiResponse {

@@ -13,3 +13,3 @@ readonly status: number;

readonly type: RequestType;
constructor(result: NodeFetchResponse, data: ResponseData<unknown>, request: ApiRequest);
constructor(result: FetchLikeData, data: ResponseData<unknown>, request: ApiRequest);
}

@@ -28,8 +28,10 @@ declare class AbortedResponse extends ApiResponse {

}
declare const createResponseWithData: <Format>(result: FetchLikeData, type: RequestType, request: ApiRequest, data: ResponseData<Format>) => AbortedResponse | InformationalResponse | SuccessResponse | RedirectResponse | ClientErrorResponse | ServerErrorResponse;
declare const createResponse: <Format>(result: NodeFetchResponse, type: RequestType, request: ApiRequest) => Promise<AbortedResponse | InformationalResponse | SuccessResponse | RedirectResponse | ClientErrorResponse | ServerErrorResponse>;
declare type PossibleResponses = ReturnType<typeof createResponse>;
declare type Await<T> = T extends Promise<infer U> ? U : T;
declare type PossibleResponses = Await<ReturnType<typeof createResponse>>;
declare type PossibleNonErrorResponses = InformationalResponse | SuccessResponse | RedirectResponse;
declare type PossibleErrorResponses = AbortedResponse | ClientErrorResponse | ServerErrorResponse;
export { createResponse, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
export { createResponse, createResponseWithData, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
export type { PossibleResponses, PossibleNonErrorResponses, PossibleErrorResponses, };
//# sourceMappingURL=response.d.ts.map

@@ -29,5 +29,4 @@ import { ResponseStatusGroup } from "../const.js";

}
const createResponse = async (result, type, request) => {
const createResponseWithData = (result, type, request, data) => {
const statusType = matchStatus(result.status);
const data = await decodeData(result, type);
if (statusType === ResponseStatusGroup.Aborted) {

@@ -50,3 +49,7 @@ return new AbortedResponse(result, data, request);

};
export { createResponse, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
const createResponse = async (result, type, request) => {
const data = await decodeData(result, type);
return createResponseWithData(result, type, request, data);
};
export { createResponse, createResponseWithData, ApiResponse, AbortedResponse, InformationalResponse, SuccessResponse, RedirectResponse, ClientErrorResponse, ServerErrorResponse, };
//# sourceMappingURL=response.js.map
/// <reference types="node" />
import type { RequestType } from "./const";
import type { Response as NodeFetchResponse } from "node-fetch";
import type { ClientHttpError, ResponseDataTypeMismatchError, ServerHttpError } from "./errors";
import type { PossibleNonErrorResponses } from "./response/response";
declare type Data = object;

@@ -8,2 +10,16 @@ interface RetryInfo {

}
interface CacheInterface {
get: (key: string) => Promise<string | undefined>;
set: (key: string, value: string) => Promise<boolean>;
delete: (key: string) => Promise<boolean>;
clear: () => Promise<void>;
}
interface RequestInformation {
method: string;
url: string;
body?: string;
headers: object;
}
declare type CacheGetKey = (reqInfo: RequestInformation) => string | undefined;
declare type CacheShouldCache = (response: PossibleNonErrorResponses | PossibleCustomErrorsThrown) => boolean;
interface Options {

@@ -19,2 +35,5 @@ base?: string;

totalTimeout?: number;
cache?: CacheInterface | null;
cacheKey?: CacheGetKey;
shouldCacheResponse?: CacheShouldCache;
}

@@ -65,3 +84,34 @@ declare type FetchOptions = Omit<Required<Options>, "base"> & {

}
export type { Data, Options, FetchOptions, URLArgument, BodyArgument, AbortErrorDetails, AbortErrorObject, AbortablePromise, ResponseData, ResponseDataJSON, ResponseDataText, ResponseDataBinary, ResponseDataStream, ConfigureOptions, };
declare type FetchLikeData = Pick<NodeFetchResponse, "status" | "statusText" | "headers">;
interface ParsedResponse {
status: NodeFetchResponse["status"];
statusText: NodeFetchResponse["statusText"];
headers: {
[key: string]: string;
};
request: {
url: string;
originalUrl: string;
queryParams: {
[key: string]: string;
};
options: FetchOptions & {
retryPolicy: string;
retryWaitPolicy: string;
};
};
type: RequestType.text;
body: string;
rawBody?: string;
}
interface ParsedError {
error: string;
message: string;
details: {
response: ParsedResponse;
[s: string]: unknown;
};
}
declare type PossibleCustomErrorsThrown = ReturnType<typeof ResponseDataTypeMismatchError> | ReturnType<typeof ClientHttpError> | ReturnType<typeof ServerHttpError>;
export type { Data, Options, FetchOptions, URLArgument, BodyArgument, AbortErrorDetails, AbortErrorObject, AbortablePromise, ResponseData, ResponseDataJSON, ResponseDataText, ResponseDataBinary, ResponseDataStream, ConfigureOptions, FetchLikeData, ParsedResponse, ParsedError, PossibleCustomErrorsThrown, };
//# sourceMappingURL=types.d.ts.map
import type stream from "stream";
import type { ApiClient } from "./api-client.js";
import type { Data, Options, URLArgument } from "./types";
declare const download: (api: ApiClient, method: string, url: URLArgument, queryParams: Data, body: Data, options: Options, writableStream: stream.Writable) => Promise<unknown>;
declare const download: (writableStream: stream.Writable, api: ApiClient, method: string, url: URLArgument, queryParams: Data | null, body: Data | null, options: Options | null) => Promise<unknown>;
export { download, };
//# sourceMappingURL=utils.d.ts.map
import { DownloadError } from "./errors.js";
import { RequestType } from "./const.js";
const download = async (api, method, url, queryParams, body, options, writableStream) => {
const download = async (writableStream, api, method, url, queryParams, body, options) => {
const res = await api.request(method, url, queryParams, body, {

@@ -5,0 +5,0 @@ ...options,

{
"name": "api-reach",
"version": "0.10.0",
"version": "0.11.0",
"repository": "git@github.com:dzek69/api-reach.git",

@@ -18,3 +18,4 @@ "author": "Jacek Nowacki @dzek69 <git-public@dzek.eu>",

"prepublishOnly": "yarn lint && yarn test && yarn docs",
"start:dev": "nodemon"
"start:dev": "nodemon",
"start:dev:compatibility": "TS_NODE_FILES=true yarn start:dev"
},

@@ -33,6 +34,7 @@ "exports": {

"abort-controller": "^3.0.0",
"better-custom-error": "^4.0.1",
"better-custom-error": "^4.0.5",
"isomorphic-abort-controller": "^2.0.0-beta.3",
"light-isomorphic-fetch": "^2.0.0-beta.2",
"oop-timers": "^4.0.0",
"light-isomorphic-fetch": "^2.0.0-beta.3",
"node-object-hash": "^2.3.2",
"oop-timers": "^4.0.1",
"qs": "^6.9.6",

@@ -47,2 +49,3 @@ "url-join": "^4.0.1"

"@dzek69/eslint-config-typescript": "^0.3.2",
"@types/keyv": "^3.1.1",
"@types/node-fetch": "^2.5.8",

@@ -53,2 +56,3 @@ "@types/qs": "^6.9.5",

"@typescript-eslint/parser": "^4.11.1",
"babel-plugin-module-extension": "^0.1.3",
"eslint": "^7.14.0",

@@ -58,2 +62,3 @@ "fs-extra": "^9.0.1",

"jest": "^26.6.3",
"keyv": "^4.0.3",
"must": "^0.13.4",

@@ -64,4 +69,3 @@ "node-fetch": "^2.6.0",

"typedoc": "^0.20.35",
"typescript": "^4.2.4",
"babel-plugin-module-extension": "^0.1.3"
"typescript": "^4.2.4"
},

@@ -77,3 +81,3 @@ "peerDependencies": {

"libraryTemplate": {
"version": "3.1.0",
"version": "3.1.1",
"language": "typescript",

@@ -80,0 +84,0 @@ "fixDefaultForCommonJS": true,

# api-reach
JavaScript universal API Client that is easy, just-works and is feature rich/pluggable. Based on `fetch`.
JavaScript universal API Client that is easy, just-works and is feature rich. Based on `fetch`.
WIP.
TypeScript support is very limited.
TypeScript support is limited.

@@ -17,3 +17,2 @@ ## Features

- better TS support
- add cache support
- methods alternative parameters input (single object instead of sequenced params)

@@ -20,0 +19,0 @@

/* eslint-disable max-lines */
import f from "light-isomorphic-fetch";
// eslint-disable-next-line @typescript-eslint/no-shadow
import f, { Headers } from "light-isomorphic-fetch";
import qs from "qs";

@@ -8,7 +9,7 @@ import urlJoin from "url-join";

import { Timeout } from "oop-timers";
import hasher from "node-object-hash";
import { ClientHttpError, ServerHttpError, ResponseDataTypeMismatchError, AbortedHttpError, TimeoutHttpError }
from "./errors.js";
import type { PossibleNonErrorResponses } from "./response/response.js";
import { ClientErrorResponse, createResponse, ServerErrorResponse } from "./response/response.js";
import type { CustomError } from "better-custom-error";
import type { Response as NodeFetchResponse } from "node-fetch";
import type {

@@ -23,14 +24,29 @@ AbortErrorDetails,

AbortablePromise,
ConfigureOptions,
ConfigureOptions, ParsedResponse, ParsedError, PossibleCustomErrorsThrown,
ResponseData,
} from "./types";
import type { PossibleNonErrorResponses, PossibleResponses } from "./response/response.js";
import { ClientHttpError, ServerHttpError, ResponseDataTypeMismatchError, AbortedHttpError, TimeoutHttpError }
from "./errors.js";
import {
ClientErrorResponse,
createResponse,
createResponseWithData,
ServerErrorResponse,
} from "./response/response.js";
import { contentTypeMap, RequestType } from "./const.js";
import { getJoinedUrl, wait } from "./helpers.js";
import { createNoopFunctionFromString, getJoinedUrl, wait } from "./helpers.js";
import { ApiRequest } from "./request/request.js";
const stringify = qs.stringify;
// @ts-expect-error see todo - it's needed for max compatibility
// @ts-expect-error see todo - it's needed for max compatibility -- todo maybe not needed anymore?
const fetch = (f.default || f) as typeof f; // @todo verify if it's needed for stable v3 of node-fetch when its released
let URLParser = URL;
// eslint-disable-next-line @typescript-eslint/unbound-method
const { hash: ohash } = hasher({ sort: true, coerce: false });
// @TODO add hash support, currently it's a bit broken, test.com/?t=true#test { x: false } will append query after hash!
const safeUrlParse = (url?: string) => {

@@ -57,2 +73,19 @@ try {

totalTimeout: 60000,
cache: null,
cacheKey: (req) => {
if (req.method.toLowerCase() !== "get") {
return;
}
return ohash(req);
},
shouldCacheResponse: (response) => {
if (!(response instanceof Error)) { // any non error can be cached
return true;
}
if ((response.details?.response as PossibleResponses) instanceof ClientErrorResponse) {
// client error can be cached
return true;
}
return false;
},
};

@@ -65,3 +98,2 @@

if (useTimeoutError) {
// @TODO do something with errorDetails typecasting
return new TimeoutHttpError(`Request aborted because of timeout`, lastError, errorDetails);

@@ -89,3 +121,3 @@ }

const type = this._getType(options);
return contentTypeMap[type]; // @todo handle unknown type
return contentTypeMap[type]; // @todo handle unknown type on runtime?
}

@@ -285,3 +317,8 @@

const fineOptions = this._buildFetchOptions(options ?? {}, method, body);
let currentController: AbortController,
const fullUrl = this._buildUrl(url, queryParams, fineOptions);
const request = new ApiRequest(fullUrl, fineOptions, url, queryParams);
let cacheKey: string | undefined = undefined,
currentController: AbortController,
globalTimeout: Timeout,

@@ -301,2 +338,22 @@ aborted = false,

(async () => { // eslint-disable-line max-statements
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (fineOptions.cache && fineOptions.cacheKey) {
cacheKey = fineOptions.cacheKey({
url: fullUrl,
method: request.options.method,
headers: request.options.headers,
body: request.options.body,
});
if (cacheKey) {
const cachedResult = await fineOptions.cache.get(cacheKey);
if (cachedResult) {
const result = ApiClient.parseStringifiedReponse(cachedResult);
if (result instanceof Error) {
throw result;
}
return result; // @todo ts omit error responses here
}
}
}
while (fineOptions.retryPolicy({ count: ++count })) {

@@ -309,2 +366,3 @@ let isTimeouted = false;

}, fineOptions.timeout);
try {

@@ -335,5 +393,3 @@ if (count > 1) {

return await this._request<T>(
url, queryParams, fineOptions, currentController.signal,
);
return await this._request<T>(request, fineOptions, currentController.signal);
}

@@ -365,3 +421,20 @@ catch (e: unknown) {

throw lastError ? lastError : new Error("No error thrown"); // @todo what to do if no error saved?
})().then(resolve, reject);
})().then((response) => {
// @TODO add option to wait for cache before resolving
resolve(response);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(response)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(response)).catch(noop);
}
}, (error: unknown) => {
reject(error);
if (!fineOptions.cache || !cacheKey) {
return;
}
if (fineOptions.shouldCacheResponse(error as CustomError)) {
fineOptions.cache.set(cacheKey, ApiClient.stringifyResponse(error as CustomError)).catch(noop);
}
});
});

@@ -386,13 +459,6 @@ future.finally(() => {

private async _request<T>(
originalUrl: URLArgument,
queryParams: Data | null | undefined,
request: ApiRequest,
options: FetchOptions,
signal: AbortSignal,
): Promise<PossibleNonErrorResponses> {
const fetchOptions = options;
const url = this._buildUrl(originalUrl, queryParams, fetchOptions);
const request = new ApiRequest(url, fetchOptions, originalUrl, queryParams);
const result = (await fetch(request.url, {

@@ -405,3 +471,6 @@ ...request.options,

const type = this._getType(options);
return ApiClient._serveResponse<T>(result, type, request);
}
private static async _serveResponse<T>(result: NodeFetchResponse, type: RequestType, request: ApiRequest) {
const response = await createResponse<T>(result, type, request);

@@ -428,2 +497,81 @@ if ("rawBody" in response) {

}
public static stringifyResponse(
response: PossibleResponses | PossibleCustomErrorsThrown, space?: string | number,
): string {
const objToStringify = response instanceof Error
? {
error: response.name,
message: response.message,
details: {
...response.details,
response: response.details?.response,
},
}
: response;
return JSON.stringify(objToStringify, function replacer(key, value: unknown) {
if (value instanceof Headers) {
const h: { [key: string]: unknown } = {};
Array.from(value.keys()).forEach(mapKey => {
h[mapKey] = value.get(mapKey);
});
return h;
}
if (typeof value === "function") {
return `[Function: ${value.name}]`;
}
return value;
}, space);
}
// eslint-disable-next-line max-statements
public static parseStringifiedReponse<T>(string: string) {
const parsedData = JSON.parse(string) as ParsedResponse | ParsedError;
const all = "error" in parsedData ? parsedData.details.response : parsedData;
const status = all.status;
const statusText = all.statusText;
const headers = new Headers(all.headers);
const request = new ApiRequest(
all.request.url,
{
...all.request.options,
retryPolicy: createNoopFunctionFromString(all.request.options.retryPolicy) as unknown as () => boolean,
retryWaitPolicy: createNoopFunctionFromString(
all.request.options.retryWaitPolicy,
) as unknown as () => number,
},
all.request.originalUrl,
all.request.queryParams,
);
const body = all.body;
const rawBody = all.rawBody;
const type = all.type;
const data: ResponseData<T> = {
type, body, rawBody,
};
if (rawBody == null) {
delete data.rawBody;
}
const response = createResponseWithData(
{ status, statusText, headers },
type,
request,
data,
);
if (!("error" in parsedData)) {
return response;
}
// @TODO return correct error type!
return new ResponseDataTypeMismatchError(parsedData.message, {
...parsedData.details,
response,
});
}
}

@@ -430,0 +578,0 @@

@@ -13,5 +13,20 @@ import urlJoin from "url-join";

const FUNCTION_NAME_BEGIN_INDEX = 11;
const FUNCTION_NAME_END_INDEX = -1;
const getFunctionNameFromString = (s: string) => {
return s.substring(FUNCTION_NAME_BEGIN_INDEX, s.length + (FUNCTION_NAME_END_INDEX - 1));
};
const createNoopFunctionFromString = (s: string) => {
const name = getFunctionNameFromString(s);
const fn = () => undefined;
Object.defineProperty(fn, "name", { value: name });
return fn;
};
export {
getJoinedUrl,
wait,
createNoopFunctionFromString,
};

@@ -9,3 +9,3 @@ import type { Response as NodeFetchResponse, Headers as NodeFetchHeaders } from "node-fetch";

import type { ApiRequest } from "../request/request.js";
import type { ResponseData } from "../types.js";
import type { FetchLikeData, ResponseData } from "../types.js";

@@ -37,3 +37,3 @@ /**

public constructor(result: NodeFetchResponse, data: ResponseData<unknown>, request: ApiRequest) {
public constructor(result: FetchLikeData, data: ResponseData<unknown>, request: ApiRequest) {
this.status = result.status;

@@ -59,5 +59,6 @@ this.statusText = result.statusText;

const createResponse = async <Format>(result: NodeFetchResponse, type: RequestType, request: ApiRequest) => {
const createResponseWithData = <Format>(
result: FetchLikeData, type: RequestType, request: ApiRequest, data: ResponseData<Format>,
) => {
const statusType = matchStatus(result.status);
const data = await decodeData<Format>(result, type);

@@ -82,3 +83,10 @@ if (statusType === ResponseStatusGroup.Aborted) {

type PossibleResponses = ReturnType<typeof createResponse>;
const createResponse = async <Format>(result: NodeFetchResponse, type: RequestType, request: ApiRequest) => {
const data = await decodeData<Format>(result, type);
return createResponseWithData<Format>(result, type, request, data);
};
type Await<T> = T extends Promise<infer U> ? U : T;
type PossibleResponses = Await<ReturnType<typeof createResponse>>;
type PossibleNonErrorResponses = InformationalResponse | SuccessResponse | RedirectResponse;

@@ -89,2 +97,3 @@ type PossibleErrorResponses = AbortedResponse | ClientErrorResponse | ServerErrorResponse;

createResponse,
createResponseWithData,
ApiResponse,

@@ -91,0 +100,0 @@ AbortedResponse,

import type { RequestType } from "./const";
import type { Response as NodeFetchResponse } from "node-fetch";
import type { ClientHttpError, ResponseDataTypeMismatchError, ServerHttpError } from "./errors";
import type { PossibleNonErrorResponses } from "./response/response";

@@ -10,2 +12,20 @@ type Data = object;

interface CacheInterface {
get: (key: string) => Promise<string | undefined>;
set: (key: string, value: string) => Promise<boolean>;
delete: (key: string) => Promise<boolean>;
clear: () => Promise<void>;
}
interface RequestInformation {
method: string;
url: string;
body?: string;
headers: object;
}
type CacheGetKey = (reqInfo: RequestInformation) => string | undefined;
type CacheShouldCache = (response: PossibleNonErrorResponses | PossibleCustomErrorsThrown) => boolean;
/**

@@ -34,2 +54,5 @@ * @typedef {Object} Options

totalTimeout?: number;
cache?: CacheInterface | null;
cacheKey?: CacheGetKey;
shouldCacheResponse?: CacheShouldCache;
}

@@ -92,2 +115,35 @@

type FetchLikeData = Pick<NodeFetchResponse, "status" | "statusText" | "headers">;
interface ParsedResponse {
status: NodeFetchResponse["status"];
statusText: NodeFetchResponse["statusText"];
headers: { [key: string]: string };
request: {
url: string;
originalUrl: string;
queryParams: { [key: string]: string };
options: FetchOptions & {
retryPolicy: string;
retryWaitPolicy: string;
};
};
type: RequestType.text;
body: string;
rawBody?: string;
}
interface ParsedError {
error: string;
message: string;
details: {
response: ParsedResponse;
[s: string]: unknown;
};
}
type PossibleCustomErrorsThrown = ReturnType<typeof ResponseDataTypeMismatchError>
| ReturnType<typeof ClientHttpError>
| ReturnType<typeof ServerHttpError>;
export type {

@@ -108,2 +164,6 @@ Data,

ConfigureOptions,
FetchLikeData,
ParsedResponse,
ParsedError,
PossibleCustomErrorsThrown,
};

@@ -11,2 +11,3 @@ import type stream from "stream";

*
* @param {stream.Writable} writableStream
* @param {ApiClient} api

@@ -19,15 +20,14 @@ * @param {string} method - method to use

* @param {Options} [options] - options that will override defaults and options specified in the constructor
* @param {stream.Writable} writableStream
* @returns {Promise<Response>}
*/
const download = async (
writableStream: stream.Writable,
api: ApiClient,
method: string,
url: URLArgument,
queryParams: Data,
body: Data,
options: Options,
writableStream: stream.Writable,
queryParams: Data | null,
body: Data | null,
options: Options | null,
) => {
const res = await api.request<{ elo: true }>(method, url, queryParams, body, {
const res = await api.request(method, url, queryParams, body, {
...options,

@@ -34,0 +34,0 @@ type: RequestType.stream,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc