declare class HttpError extends Error { status: number; constructor(status: number, message?: string); } /** Consumes the response body. */ declare function safeGetJson(response: Response): Promise; /** Consumes the response text. */ declare function safeGetText(response: Response): Promise; /** Consumes the response body. */ declare function safeGetErrorMessage(response: Response): Promise; declare function throwIfError(response: Response): Promise; type HttpBodyInit = BodyInit | object | null; type RequestInitNoBody = Omit; type HttpRequestInit = RequestInitNoBody & { body?: HttpBodyInit; }; declare function normalizeBody(body: HttpBodyInit | undefined): { body?: BodyInit | null; headers?: Record; }; type HttpMiddleware = (request: Request, next: (req: Request) => Promise) => Promise; /** Throw on non-OK responses. */ declare const throwOnError: HttpMiddleware; /** * Add retries. If you also use throwOnError, the sequence should be * `http.use(throwOnError).use(retries())` so that throwOnError runs outside of * the retry loops. */ declare const retries: (options?: { maxTries?: number; delayMs?: number; backoffMultiplier?: number; }) => HttpMiddleware; declare class HttpFetch { private readonly middlewares; constructor(middlewares?: HttpMiddleware[]); /** Add a middleware to the chain. */ use(middleware: HttpMiddleware): HttpFetch; /** * Main fetch method with middleware support. Supports auto-conversion of * JSON bodies to JSON strings, and adding the JSON Content-Type. */ fetch(input: RequestInfo | URL, init?: HttpRequestInit): Promise; get(input: RequestInfo | URL, init?: HttpRequestInit): Promise; post(input: RequestInfo | URL, body?: HttpBodyInit, init?: RequestInitNoBody): Promise; put(input: RequestInfo | URL, body?: HttpBodyInit, init?: RequestInitNoBody): Promise; patch(input: RequestInfo | URL, body?: HttpBodyInit, init?: RequestInitNoBody): Promise; delete(input: RequestInfo | URL, init?: HttpRequestInit): Promise; head(input: RequestInfo | URL, init?: HttpRequestInit): Promise; } /** * Standard http instance that can be used for most purposes. * - To add retries, use `http.use(retries())` * - To throw on errors, use `http.use(throwOnError)` * - To do both, use `http.use(throwOnError).use(retries())` */ declare const http: HttpFetch; export { type HttpBodyInit, HttpError, HttpFetch, type HttpMiddleware, type HttpRequestInit, type RequestInitNoBody, http, normalizeBody, retries, safeGetErrorMessage, safeGetJson, safeGetText, throwIfError, throwOnError };