/** * Retry Utility * * Provides retry logic with exponential backoff for failed operations. */ /** * Options for retry behavior. */ export interface RetryOptions { /** * Maximum number of retry attempts. * @default 3 */ maxAttempts?: number; /** * Base delay in milliseconds before first retry. * @default 1000 */ baseDelayMs?: number; /** * Maximum delay in milliseconds between retries. * @default 10000 */ maxDelayMs?: number; /** * Multiplier for exponential backoff. * @default 2 */ backoffMultiplier?: number; /** * Function to determine if an error should trigger a retry. * By default, retries on all errors. */ shouldRetry?: (error: Error, attempt: number) => boolean; /** * Callback invoked before each retry attempt. */ onRetry?: (error: Error, attempt: number, delayMs: number) => void; } /** * Executes a function with retry logic and exponential backoff. * * @param fn - The async function to execute * @param options - Retry configuration options * @returns The result of the function * @throws The last error if all retries are exhausted * * @example * ```typescript * const result = await withRetry( * () => fetchData(), * { maxAttempts: 3, baseDelayMs: 1000 } * ); * ``` */ export declare function withRetry(fn: () => Promise, options?: RetryOptions): Promise;