/** * Configuration options for retry behavior. */ export type RetryConfig = { /** Maximum number of retry attempts. Default: 3 */ maxRetries?: number; /** Initial delay between retries in milliseconds. Default: 1000 */ initialDelayMs?: number; /** Maximum delay between retries in milliseconds. Default: 10000 */ maxDelayMs?: number; /** Backoff multiplier for exponential backoff. Default: 2 */ backoffMultiplier?: number; /** Whether to add jitter to prevent thundering herd. Default: true */ jitter?: boolean; /** Custom function to determine if error is retryable. Default uses isTransientError */ isRetryable?: (error: unknown) => boolean; /** Callback invoked before each retry attempt */ onRetry?: (error: unknown, attempt: number, delayMs: number) => void; /** Custom random number generator for deterministic testing. Must return values in [0, 1]. Default: Math.random */ randomFn?: () => number; }; /** * Default retry configuration values. */ export declare const DEFAULT_RETRY_CONFIG: Required>; /** * Determines if an error is transient and should be retried. * * @param error - The error to check * @returns true if the error is likely transient and retry may succeed * * @example * ```typescript * try { * await connection.query(soql); * } catch (error) { * if (isTransientError(error)) { * // Safe to retry * } * } * ``` */ export declare function isTransientError(error: unknown): boolean; /** * Calculates the delay before the next retry attempt using exponential backoff. * * @param attempt - The current attempt number (0-based) * @param config - The retry configuration * @returns Delay in milliseconds */ export declare function calculateBackoffDelay(attempt: number, config: Required): number; /** * Executes a function with retry logic for transient failures. * * Uses exponential backoff with configurable jitter to prevent thundering herd. * * @param fn - The async function to execute * @param config - Optional retry configuration * @returns The result of the function * @throws The last error if all retries are exhausted * * @example * ```typescript * const result = await withRetry( * () => connection.query(soql), * { * maxRetries: 3, * onRetry: (error, attempt) => console.log(`Retry ${attempt}...`), * } * ); * ``` */ export declare function withRetry(fn: () => Promise, config?: RetryConfig): Promise; /** * Creates a retry-enabled wrapper for an async function. * * @param fn - The async function to wrap * @param config - Retry configuration * @returns A new function that wraps the original with retry logic * * @example * ```typescript * const retryableQuery = createRetryWrapper( * (soql: string) => connection.query(soql), * { maxRetries: 3 } * ); * * const result = await retryableQuery('SELECT Id FROM Account'); * ``` */ export declare function createRetryWrapper(fn: (...args: TArgs) => Promise, config?: RetryConfig): (...args: TArgs) => Promise;