codekingpro/portable-devtools
114k
1interface RawAxiosHeaders {2 [key: string]: axios.AxiosHeaderValue;3}4 5type MethodsHeaders = Partial<{6 [Key in axios.Method as Lowercase<Key>]: AxiosHeaders;7} & {common: AxiosHeaders}>;8 9type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean;10 11type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;12 13type CommonRequestHeadersList = 'Accept' | 'Content-Length' | 'User-Agent'| 'Content-Encoding' | 'Authorization';14 15type ContentType = axios.AxiosHeaderValue | 'text/html' | 'text/plain' | 'multipart/form-data' | 'application/json' | 'application/x-www-form-urlencoded' | 'application/octet-stream';16 17type CommonResponseHeadersList = 'Server' | 'Content-Type' | 'Content-Length' | 'Cache-Control'| 'Content-Encoding';18 19declare class AxiosHeaders {20 constructor(21 headers?: RawAxiosHeaders | AxiosHeaders | string22 );23 24 [key: string]: any;25 26 set(headerName?: string, value?: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;27 set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders;28 29 get(headerName: string, parser: RegExp): RegExpExecArray | null;30 get(headerName: string, matcher?: true | AxiosHeaderParser): axios.AxiosHeaderValue;31 32 has(header: string, matcher?: AxiosHeaderMatcher): boolean;33 34 delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean;35 36 clear(matcher?: AxiosHeaderMatcher): boolean;37 38 normalize(format: boolean): AxiosHeaders;39 40 concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;41 42 toJSON(asStrings?: boolean): RawAxiosHeaders;43 44 static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders;45 46 static accessor(header: string | string[]): AxiosHeaders;47 48 static concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders;49 50 setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;51 getContentType(parser?: RegExp): RegExpExecArray | null;52 getContentType(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;53 hasContentType(matcher?: AxiosHeaderMatcher): boolean;54 55 setContentLength(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;56 getContentLength(parser?: RegExp): RegExpExecArray | null;57 getContentLength(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;58 hasContentLength(matcher?: AxiosHeaderMatcher): boolean;59 60 setAccept(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;61 getAccept(parser?: RegExp): RegExpExecArray | null;62 getAccept(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;63 hasAccept(matcher?: AxiosHeaderMatcher): boolean;64 65 setUserAgent(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;66 getUserAgent(parser?: RegExp): RegExpExecArray | null;67 getUserAgent(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;68 hasUserAgent(matcher?: AxiosHeaderMatcher): boolean;69 70 setContentEncoding(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;71 getContentEncoding(parser?: RegExp): RegExpExecArray | null;72 getContentEncoding(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;73 hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean;74 75 setAuthorization(value: axios.AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders;76 getAuthorization(parser?: RegExp): RegExpExecArray | null;77 getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;78 hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;79 80 [Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;81}82 83declare class AxiosError<T = unknown, D = any> extends Error {84 constructor(85 message?: string,86 code?: string,87 config?: axios.InternalAxiosRequestConfig<D>,88 request?: any,89 response?: axios.AxiosResponse<T, D>90 );91 92 config?: axios.InternalAxiosRequestConfig<D>;93 code?: string;94 request?: any;95 response?: axios.AxiosResponse<T, D>;96 isAxiosError: boolean;97 status?: number;98 toJSON: () => object;99 cause?: Error;100 static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";101 static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";102 static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";103 static readonly ERR_NETWORK = "ERR_NETWORK";104 static readonly ERR_DEPRECATED = "ERR_DEPRECATED";105 static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";106 static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST";107 static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";108 static readonly ERR_INVALID_URL = "ERR_INVALID_URL";109 static readonly ERR_CANCELED = "ERR_CANCELED";110 static readonly ECONNABORTED = "ECONNABORTED";111 static readonly ETIMEDOUT = "ETIMEDOUT";112}113 114declare class CanceledError<T> extends AxiosError<T> {115}116 117declare class Axios {118 constructor(config?: axios.AxiosRequestConfig);119 defaults: axios.AxiosDefaults;120 interceptors: {121 request: axios.AxiosInterceptorManager<axios.InternalAxiosRequestConfig>;122 response: axios.AxiosInterceptorManager<axios.AxiosResponse>;123 };124 getUri(config?: axios.AxiosRequestConfig): string;125 request<T = any, R = axios.AxiosResponse<T>, D = any>(config: axios.AxiosRequestConfig<D>): Promise<R>;126 get<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;127 delete<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;128 head<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;129 options<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, config?: axios.AxiosRequestConfig<D>): Promise<R>;130 post<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;131 put<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;132 patch<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;133 postForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;134 putForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;135 patchForm<T = any, R = axios.AxiosResponse<T>, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig<D>): Promise<R>;136}137 138declare enum HttpStatusCode {139 Continue = 100,140 SwitchingProtocols = 101,141 Processing = 102,142 EarlyHints = 103,143 Ok = 200,144 Created = 201,145 Accepted = 202,146 NonAuthoritativeInformation = 203,147 NoContent = 204,148 ResetContent = 205,149 PartialContent = 206,150 MultiStatus = 207,151 AlreadyReported = 208,152 ImUsed = 226,153 MultipleChoices = 300,154 MovedPermanently = 301,155 Found = 302,156 SeeOther = 303,157 NotModified = 304,158 UseProxy = 305,159 Unused = 306,160 TemporaryRedirect = 307,161 PermanentRedirect = 308,162 BadRequest = 400,163 Unauthorized = 401,164 PaymentRequired = 402,165 Forbidden = 403,166 NotFound = 404,167 MethodNotAllowed = 405,168 NotAcceptable = 406,169 ProxyAuthenticationRequired = 407,170 RequestTimeout = 408,171 Conflict = 409,172 Gone = 410,173 LengthRequired = 411,174 PreconditionFailed = 412,175 PayloadTooLarge = 413,176 UriTooLong = 414,177 UnsupportedMediaType = 415,178 RangeNotSatisfiable = 416,179 ExpectationFailed = 417,180 ImATeapot = 418,181 MisdirectedRequest = 421,182 UnprocessableEntity = 422,183 Locked = 423,184 FailedDependency = 424,185 TooEarly = 425,186 UpgradeRequired = 426,187 PreconditionRequired = 428,188 TooManyRequests = 429,189 RequestHeaderFieldsTooLarge = 431,190 UnavailableForLegalReasons = 451,191 InternalServerError = 500,192 NotImplemented = 501,193 BadGateway = 502,194 ServiceUnavailable = 503,195 GatewayTimeout = 504,196 HttpVersionNotSupported = 505,197 VariantAlsoNegotiates = 506,198 InsufficientStorage = 507,199 LoopDetected = 508,200 NotExtended = 510,201 NetworkAuthenticationRequired = 511,202}203 204type InternalAxiosError<T = unknown, D = any> = AxiosError<T, D>;205 206declare namespace axios {207 type AxiosError<T = unknown, D = any> = InternalAxiosError<T, D>;208 209 type RawAxiosRequestHeaders = Partial<RawAxiosHeaders & {210 [Key in CommonRequestHeadersList]: AxiosHeaderValue;211 } & {212 'Content-Type': ContentType213 }>;214 215 type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders;216 217 type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null;218 219 type RawCommonResponseHeaders = {220 [Key in CommonResponseHeadersList]: AxiosHeaderValue;221 } & {222 "set-cookie": string[];223 };224 225 type RawAxiosResponseHeaders = Partial<RawAxiosHeaders & RawCommonResponseHeaders>;226 227 type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders;228 229 interface AxiosRequestTransformer {230 (this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any;231 }232 233 interface AxiosResponseTransformer {234 (this: InternalAxiosRequestConfig, data: any, headers: AxiosResponseHeaders, status?: number): any;235 }236 237 interface AxiosAdapter {238 (config: InternalAxiosRequestConfig): AxiosPromise;239 }240 241 interface AxiosBasicCredentials {242 username: string;243 password: string;244 }245 246 interface AxiosProxyConfig {247 host: string;248 port: number;249 auth?: AxiosBasicCredentials;250 protocol?: string;251 }252 253 type Method =254 | 'get' | 'GET'255 | 'delete' | 'DELETE'256 | 'head' | 'HEAD'257 | 'options' | 'OPTIONS'258 | 'post' | 'POST'259 | 'put' | 'PUT'260 | 'patch' | 'PATCH'261 | 'purge' | 'PURGE'262 | 'link' | 'LINK'263 | 'unlink' | 'UNLINK';264 265 type ResponseType =266 | 'arraybuffer'267 | 'blob'268 | 'document'269 | 'json'270 | 'text'271 | 'stream';272 273 type responseEncoding =274 | 'ascii' | 'ASCII'275 | 'ansi' | 'ANSI'276 | 'binary' | 'BINARY'277 | 'base64' | 'BASE64'278 | 'base64url' | 'BASE64URL'279 | 'hex' | 'HEX'280 | 'latin1' | 'LATIN1'281 | 'ucs-2' | 'UCS-2'282 | 'ucs2' | 'UCS2'283 | 'utf-8' | 'UTF-8'284 | 'utf8' | 'UTF8'285 | 'utf16le' | 'UTF16LE';286 287 interface TransitionalOptions {288 silentJSONParsing?: boolean;289 forcedJSONParsing?: boolean;290 clarifyTimeoutError?: boolean;291 }292 293 interface GenericAbortSignal {294 readonly aborted: boolean;295 onabort?: ((...args: any) => any) | null;296 addEventListener?: (...args: any) => any;297 removeEventListener?: (...args: any) => any;298 }299 300 interface FormDataVisitorHelpers {301 defaultVisitor: SerializerVisitor;302 convertValue: (value: any) => any;303 isVisitable: (value: any) => boolean;304 }305 306 interface SerializerVisitor {307 (308 this: GenericFormData,309 value: any,310 key: string | number,311 path: null | Array<string | number>,312 helpers: FormDataVisitorHelpers313 ): boolean;314 }315 316 interface SerializerOptions {317 visitor?: SerializerVisitor;318 dots?: boolean;319 metaTokens?: boolean;320 indexes?: boolean | null;321 }322 323 // tslint:disable-next-line324 interface FormSerializerOptions extends SerializerOptions {325 }326 327 interface ParamEncoder {328 (value: any, defaultEncoder: (value: any) => any): any;329 }330 331 interface CustomParamsSerializer {332 (params: Record<string, any>, options?: ParamsSerializerOptions): string;333 }334 335 interface ParamsSerializerOptions extends SerializerOptions {336 encode?: ParamEncoder;337 serialize?: CustomParamsSerializer;338 }339 340 type MaxUploadRate = number;341 342 type MaxDownloadRate = number;343 344 type BrowserProgressEvent = any;345 346 interface AxiosProgressEvent {347 loaded: number;348 total?: number;349 progress?: number;350 bytes: number;351 rate?: number;352 estimated?: number;353 upload?: boolean;354 download?: boolean;355 event?: BrowserProgressEvent;356 }357 358 type Milliseconds = number;359 360 type AxiosAdapterName = 'xhr' | 'http' | string;361 362 type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName;363 364 type AddressFamily = 4 | 6 | undefined;365 366 interface LookupAddressEntry {367 address: string;368 family?: AddressFamily;369 }370 371 type LookupAddress = string | LookupAddressEntry;372 373 interface AxiosRequestConfig<D = any> {374 url?: string;375 method?: Method | string;376 baseURL?: string;377 transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];378 transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];379 headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;380 params?: any;381 paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;382 data?: D;383 timeout?: Milliseconds;384 timeoutErrorMessage?: string;385 withCredentials?: boolean;386 adapter?: AxiosAdapterConfig | AxiosAdapterConfig[];387 auth?: AxiosBasicCredentials;388 responseType?: ResponseType;389 responseEncoding?: responseEncoding | string;390 xsrfCookieName?: string;391 xsrfHeaderName?: string;392 onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;393 onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void;394 maxContentLength?: number;395 validateStatus?: ((status: number) => boolean) | null;396 maxBodyLength?: number;397 maxRedirects?: number;398 maxRate?: number | [MaxUploadRate, MaxDownloadRate];399 beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;400 socketPath?: string | null;401 transport?: any;402 httpAgent?: any;403 httpsAgent?: any;404 proxy?: AxiosProxyConfig | false;405 cancelToken?: CancelToken;406 decompress?: boolean;407 transitional?: TransitionalOptions;408 signal?: GenericAbortSignal;409 insecureHTTPParser?: boolean;410 env?: {411 FormData?: new (...args: any[]) => object;412 };413 formSerializer?: FormSerializerOptions;414 family?: AddressFamily;415 lookup?: ((hostname: string, options: object, cb: (err: Error | null, address: LookupAddress | LookupAddress[], family?: AddressFamily) => void) => void) |416 ((hostname: string, options: object) => Promise<[address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] | LookupAddress>);417 withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined);418 }419 420 // Alias421 type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;422 423 interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {424 headers: AxiosRequestHeaders;425 }426 427 interface HeadersDefaults {428 common: RawAxiosRequestHeaders;429 delete: RawAxiosRequestHeaders;430 get: RawAxiosRequestHeaders;431 head: RawAxiosRequestHeaders;432 post: RawAxiosRequestHeaders;433 put: RawAxiosRequestHeaders;434 patch: RawAxiosRequestHeaders;435 options?: RawAxiosRequestHeaders;436 purge?: RawAxiosRequestHeaders;437 link?: RawAxiosRequestHeaders;438 unlink?: RawAxiosRequestHeaders;439 }440 441 interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {442 headers: HeadersDefaults;443 }444 445 interface CreateAxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {446 headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial<HeadersDefaults>;447 }448 449 interface AxiosResponse<T = any, D = any> {450 data: T;451 status: number;452 statusText: string;453 headers: RawAxiosResponseHeaders | AxiosResponseHeaders;454 config: InternalAxiosRequestConfig<D>;455 request?: any;456 }457 458 type AxiosPromise<T = any> = Promise<AxiosResponse<T>>;459 460 interface CancelStatic {461 new (message?: string): Cancel;462 }463 464 interface Cancel {465 message: string | undefined;466 }467 468 interface Canceler {469 (message?: string, config?: AxiosRequestConfig, request?: any): void;470 }471 472 interface CancelTokenStatic {473 new (executor: (cancel: Canceler) => void): CancelToken;474 source(): CancelTokenSource;475 }476 477 interface CancelToken {478 promise: Promise<Cancel>;479 reason?: Cancel;480 throwIfRequested(): void;481 }482 483 interface CancelTokenSource {484 token: CancelToken;485 cancel: Canceler;486 }487 488 interface AxiosInterceptorOptions {489 synchronous?: boolean;490 runWhen?: (config: InternalAxiosRequestConfig) => boolean;491 }492 493 interface AxiosInterceptorManager<V> {494 use(onFulfilled?: (value: V) => V | Promise<V>, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number;495 eject(id: number): void;496 clear(): void;497 }498 499 interface AxiosInstance extends Axios {500 <T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;501 <T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;502 503 defaults: Omit<AxiosDefaults, 'headers'> & {504 headers: HeadersDefaults & {505 [key: string]: AxiosHeaderValue506 }507 };508 }509 510 interface GenericFormData {511 append(name: string, value: any, options?: any): any;512 }513 514 interface GenericHTMLFormElement {515 name: string;516 method: string;517 submit(): void;518 }519 520 interface AxiosStatic extends AxiosInstance {521 create(config?: CreateAxiosDefaults): AxiosInstance;522 Cancel: CancelStatic;523 CancelToken: CancelTokenStatic;524 Axios: typeof Axios;525 AxiosError: typeof AxiosError;526 CanceledError: typeof CanceledError;527 HttpStatusCode: typeof HttpStatusCode;528 readonly VERSION: string;529 isCancel(value: any): value is Cancel;530 all<T>(values: Array<T | Promise<T>>): Promise<T[]>;531 spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;532 isAxiosError<T = any, D = any>(payload: any): payload is AxiosError<T, D>;533 toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData;534 formToJSON(form: GenericFormData|GenericHTMLFormElement): object;535 getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;536 AxiosHeaders: typeof AxiosHeaders;537 }538}539 540declare const axios: axios.AxiosStatic;541 542export = axios;543 