import { ClarionError, type ClarionWarning } from '@clarionhq/core'; import type { AzureAutoRetryConfig } from './AzureEngineConfig'; export interface TokenRefreshCallbacks { /** Fetch a fresh token from the user-supplied provider. */ fetch: () => Promise; /** Apply the fresh token to the live engine. */ apply: (token: string) => Promise; /** Emit a non-fatal warning (e.g. "refreshing soon"). */ warn: (w: ClarionWarning) => void; /** Emit a hard error (e.g. provider threw). */ error: (e: ClarionError) => void; } /** * Background timer that keeps an Azure auth token fresh. * * Lifecycle: * 1. `start(initialToken, ttlMs)` — schedule refresh at (TTL − lead). * 2. On fire: emit `TOKEN_NEAR_EXPIRY` warning, call `fetch()`, call `apply()`, * reschedule. * 3. `refreshNow()` — used after a `TOKEN_EXPIRED` mid-session error. * 4. `stop()` — cancel any pending timer. */ export declare class TokenRefreshTimer { private readonly cb; private timer; private inflight; private lastRefreshAt; constructor(cb: TokenRefreshCallbacks); /** Schedule the next refresh `(ttlMs - lead)` from now. Idempotent. */ start(ttlMs?: number): void; /** Run a refresh immediately. De-duped if one is already inflight. */ refreshNow(): Promise; stop(): void; } export interface RetryEmissions { /** Emit a warning for each retry attempt (so devs can show "retrying…" UI). */ warn: (w: ClarionWarning) => void; } /** * Run `fn`. If it throws a `ClarionError` whose code is in `retryOn`, retry * with exponential backoff up to `maxAttempts` additional times. * * Each retry emits a `RETRY_ATTEMPTED` warning with `attempt` and `maxAttempts` * in `details` so a UI can show a "retrying…" indicator. * * If the final attempt still fails, the original error is re-thrown. */ export declare const withAutoRetry: (fn: () => Promise, config: AzureAutoRetryConfig | undefined, emissions: RetryEmissions, context: string) => Promise; //# sourceMappingURL=AzureEngineSupport.d.ts.map