import { HttpHeaders } from './headers'; export type ResponseType = 'json' | 'text' | 'blob' | 'arraybuffer' | 'none'; export interface OnResponseArgs { /** null on a transport-level failure */ response: Response | null; /** 500 on a transport-level failure */ status: number; /** the URL exactly as the caller passed it, before any baseUrl join */ requestUrl: string; } export interface FetchClientOptions { baseUrl?: string; /** headers that never change for the lifetime of the client */ staticHeaders?: Record; /** evaluated per request */ headers?: () => Record; /** invoked for every outcome, before any throw */ onResponse?: (args: OnResponseArgs) => void; } export interface FetchRequestOptions { method?: string; /** merged over the client-wide headers, case-insensitively */ headers?: HeadersInit; params?: Record; /** JSON-encoded unless it is already a BodyInit */ body?: unknown; responseType?: ResponseType; signal?: AbortSignal; /** default true; false returns the envelope for non-2xx instead of throwing */ throwOnError?: boolean; } export interface HttpResponse { data: T; status: number; statusText: string; headers: HttpHeaders; }