import type { AnyStringRecord } from '../../@types'; import type { ResponseUnion, ErrorResponseData } from '../response'; import type { BiuRequestSupportEnvironments } from './const.request'; import type { ConstructorOfRequestEngine } from './engine.request'; export declare type BiuRequestResource = string; export declare type BiuRequestMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK'; export declare type BiuRequestHeaders = Record; export declare type BiuRequestBody = ReadableStream | Blob | BufferSource | FormData | URLSearchParams | string; export declare type BiuRequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'; export declare type BiuRequestCredentials = 'include' | 'omit' | 'same-origin'; export declare type BiuResponseType = 'text' | 'json' | 'arraybuffer' | 'formdata' | 'blob' | 'stream'; export declare type BiuReceivedDataType = 'json' | 'custom' | 'other'; export interface BiuOptions { resource: BiuRequestResource; method?: BiuRequestMethod; headers?: BiuRequestHeaders; body?: BiuRequestBody; mode?: BiuRequestMode; credentials?: BiuRequestCredentials; /** * In millisecond. */ timeout?: number; data?: SendData; responseType?: BiuResponseType; dataType?: BiuReceivedDataType; dataParser?: (data: any) => SuccessData; responseModifier?: (response: ResponseUnion) => any; } /** * */ export declare class Biutor { _options: Required>; _response: Promise>; private readonly _resolve; private readonly _reject; constructor(options: BiuOptions); get options(): BiuOptions; get response(): Promise>; get modifiedResponse(): Promise; get data(): Promise; get successData(): Promise; get failData(): Promise; get errorData(): Promise; /** * Set options by key. */ setOptions>>(key: K, value: Required>[K]): this; /** * The default request engine for environments will be resigtered automatically when script is loaded, * there is no need to invoke `initialize` method manually except for reset engines to defaults. */ static initialize(options?: { isForceInitialize?: boolean; }): void; static registerGlobalEngine(requestEngine: ConstructorOfRequestEngine, options?: { isForceReplace?: boolean; }): void; static of(options: BiuOptions): Biutor; sendEnvironmentalRequest(env: BiuRequestSupportEnvironments): this; sendWXMINARequest(): this; sendWebRequest(): this; sendNodeRequest(): this; sendDefaultRequest(): this; sendRequest(): this; } /****************************************************************************************************** * * biu * ******************************************************************************************************/ /** * - use fetch for web or node environment * - use wx.request for wechat miniapp environment * - other environment need to register a request engine manually */ export declare const biu: (options: BiuOptions, any>) => Promise>>; export declare const modifyBiuConfig: any; export declare const asPostRequest: any; export declare const asGetRequest: any; export declare const withJSONContent: any; //# sourceMappingURL=base.request.d.ts.map