export type Body = { json: Record; } | { [key: string]: unknown; }; export type Payload = { method: "GET" | "DELETE"; body?: never; } | { method: "POST" | "PUT" | "PATCH"; body: B; }; export type HttpMethod = Payload["method"]; /** * Interface describing the unwrapper object returned by the `requestWithUnwrapper` method. */ interface Unwrapper { json: () => Promise; text: () => Promise; blob: () => Promise; } /** * Interface describing the options for the BaseHttpClient. */ export interface HttpClientOptions { prefixUrl?: string; defaultHeaders?: Record; credentials?: "include" | "omit"; } /** * A basic HTTP client supporting various HTTP methods and isomorphic in nature. * Uses `isomorphic-unfetch` as the underlying fetch implementation. */ export declare class HttpClient { private prefixUrl; private defaultHeaders; private credentials; /** * Creates a new instance of the BaseHttpClient. * @param options - Configuration options for the client. */ constructor(options?: HttpClientOptions); /** * Creates and returns a new BaseHttpClient instance with the provided options. * @param options - Configuration options to extend the client with. */ static extend(options: HttpClientOptions): HttpClient; /** * Internal method to make the actual fetch request. * @param path - The API endpoint path. * @param method - The HTTP method to use. * @param body - The request body (if any). */ private request; /** * Makes a GET request. * @param path - The API endpoint path. * @returns Object with a method `json` that can be used to retrieve the parsed response. */ get(path: string): Unwrapper; /** * Makes a POST request. * @param path - The API endpoint path. * @param body - The request body to send. * @returns Object with a method `json` that can be used to retrieve the parsed response. */ post(path: string, body?: B): Unwrapper; /** * Makes a PUT request. * @param path - The API endpoint path. * @param body - The request body to send. * @returns Object with a method `json` that can be used to retrieve the parsed response. */ put(path: string, body?: B): Unwrapper; /** * Makes a PATCH request. * @param path - The API endpoint path. * @param body - The request body to send. * @returns Object with a method `json` that can be used to retrieve the parsed response. */ patch(path: string, body?: B): Unwrapper; /** * Makes a DELETE request. * @param path - The API endpoint path. * @returns Object with a method `json` that can be used to retrieve the parsed response. */ delete(path: string): Unwrapper; /** * Internal method to wrap the fetch request and provide a `.json()` method for parsing. * @param path - The API endpoint path. * @parm payload - The request payload with the HTTP method and body. */ private requestWithUnwrapper; } export {};