import type { FetchFn } from "./types.js"; /** * Configuration for the retry-on-429 fetch wrapper. */ export interface RetryFetchOptions { /** * Maximum number of retry attempts after a `429 Too Many Requests`. * @default 3 */ maxRetries?: number; /** * Delay schedule in milliseconds for each retry attempt (index-based). * If the server sends a `Retry-After` header, the *larger* of the * scheduled delay and the server hint is used. * * @default [1000, 2000, 3000] */ delays?: number[]; /** * Optional `AbortSignal` to cancel pending retries. * Already-in-flight fetch calls are also forwarded the signal. */ signal?: AbortSignal; /** * Optional callback invoked before each retry wait. * Return `false` to cancel the retry loop immediately. */ onRetry?: (attempt: number, delayMs: number, response: Response) => boolean | void; } /** * Wrap a `FetchFn` with automatic retry on HTTP 429 (Too Many Requests). * * - Retries up to `maxRetries` times (default 3). * - Uses a linear backoff of 1 s → 2 s → 3 s (configurable via `delays`). * - Respects the `Retry-After` header — uses `max(scheduled, server hint)`. * - Supports cancellation via `AbortSignal` or the `onRetry` callback. * * Usage: * ```ts * const fetchFn = retryFetch(globalThis.fetch, { signal: controller.signal }); * const reader = new FhirResourceReader(baseUrl, "Patient", fetchFn); * ``` */ export declare function retryFetch(inner: FetchFn, options?: RetryFetchOptions): FetchFn; //# sourceMappingURL=retry-fetch.d.ts.map