import { IPromise } from './IPromise' export const enum HttpMethod { GET = 'GET', DELETE = 'DELETE', HEAD = 'HEAD', OPTIONS = 'OPTIONS', POST = 'POST', PUT = 'PUT', PATCH = 'PATCH', } export type IHttpMethodV2 = | 'GET' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'POST' | 'PUT' | 'PATCH' export type IHttpHeaders = Record export interface IHttpResponse { status: number statusText: string headers: IHttpHeaders data: D } export interface IFetchResponse { status: number statusText: string headers: any json(): IPromise body: any } export interface IHttpRequest { url?: string method?: HttpMethod | IHttpMethodV2 headers?: IHttpHeaders params?: any body?: any data?: any } export interface IFetch< Req extends IHttpRequest = IHttpRequest, Res extends IFetchResponse = IFetchResponse, > { ( url: string, req?: Req, ): IPromise & IFetchResponse> } export interface IHttpReqPerform { ( url: string, body?: any, req?: Req, ): IPromise & IHttpResponse> ( url: string, req?: Req, ): IPromise & IHttpResponse> } export interface IHttpClient< Req extends IHttpRequest = IHttpRequest, Res extends IHttpResponse = IHttpResponse, > { (req: Req): IPromise & IHttpResponse> ( url: string, req?: Req, ): IPromise & IHttpResponse> get: IHttpReqPerform post: IHttpReqPerform put: IHttpReqPerform patch: IHttpReqPerform head: IHttpReqPerform delete: IHttpReqPerform options: IHttpReqPerform } export type IHttpRequestProvider = IFetch | IHttpClient