/** * Shared retry / sleep / stop helpers for SIEM connectors. * * Everything here is deliberately tiny and stateless so connectors can * orchestrate retries and stop conditions without pulling in a full * retry library. The AWS SDK / Elasticsearch SDK / Azure SDK each have * their own built-in retry; this file wraps user-facing operations * (pagination loops, transient failures) where the SDK doesn't retry * for us. */ /** Sleep for N milliseconds. */ export declare function sleep(ms: number): Promise; /** Jittered exponential backoff — ms = base * 2^attempt +/- up to 20%. */ export declare function backoffMs(attempt: number, baseMs?: number, capMs?: number): number; /** * Parse a window expression like `1h`, `24h`, `7d`, `30d` into milliseconds. * Accepts minute/hour/day suffixes. Throws on invalid input. * * Lives here (not in the registry index) to avoid circular imports between * connectors and the registry. */ export declare function parseWindowMs(expr: string): number; /** Stop-condition: either deadline reached or event target reached. */ export declare function shouldStop(deadline: number, fetched: number, target: number): boolean; export interface RetryOptions { maxAttempts?: number; baseMs?: number; capMs?: number; /** Hook to decide whether a specific error is retryable (default: everything). */ isRetryable?: (err: unknown) => boolean; /** Called after each retry attempt with the attempt number and error. */ onRetry?: (attempt: number, err: unknown, waitMs: number) => void; /** Respect `Retry-After` header if the error exposes it (429 handling). */ extractRetryAfterMs?: (err: unknown) => number | undefined; } /** * Run `fn` with bounded exponential backoff. Up to maxAttempts tries; returns * the last error when all attempts fail. The caller should catch and decide * whether the failure is fatal (bail out of the pull) or per-page (move on). */ export declare function retryWithBackoff(fn: () => Promise, opts?: RetryOptions): Promise;