/// import type { Agent } from 'http'; import type { HTTPError } from './utils/error'; import type { Headers } from './utils'; export interface IFZ { response(): Promise; text(): Promise; json(): Promise; arrayBuffer(): Promise; blob(): Promise; } export interface FZResponse { status: number; headers: Record; data: T; statusText: string; } export interface FzConfig { url: Url; method?: Method; query?: Record; params?: Record; body?: Record | FormData; credentials?: Credentials; headers?: Record; engine?: Fetch; retry?: number; timeout?: number; prefix?: string; suffix?: string; hooks?: Hooks; throwHttpErrors?: boolean; cache?: boolean | ICacheOptions; showLoading?: boolean; agent?: Agent | ((parsedUrl: URL) => Agent); } export declare type RequestConfig = Omit & { body?: string; headers?: Headers; }; export interface ICacheOptions { maxAge?: number; } export declare type Url = string; export declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'HEAD' | 'DELETE'; export declare type Credentials = 'same-origin' | 'include'; export interface Hooks { beforeRequest: BeforeRequest[]; afterResponse: AfterResponse[]; } export declare type BeforeRequest = (options: FzConfig) => Promise; export declare type AfterResponse = (response: FZResponse, options: FzConfig) => Promise; export declare const enum ResponseTypes { json = "json", text = "text", formData = "formData", arrayBuffer = "arrayBuffer", blob = "blob" } export declare type Fetch = (input?: string | Request | undefined, init?: RequestInit | undefined) => Promise; export declare type StatusCode = 400 | 401 | 403 | 404 | 405 | 429 | 500 | 502 | 503 | 504; export declare type StatusHandler = AfterResponse; export declare type ErrorHandler = (error: HTTPError) => Promise;