import type { AnswerCallbackQueryParams, TelegramUser } from '@puregram/api'; import type { DefaultParams } from './api/default-params.js'; import type { HttpClient } from './http/client.js'; /** failure classes the retry logic may act on — `flood` = 429+retry_after, `server` = api 5xx, `network` = transport */ export type RetryReason = 'flood' | 'server' | 'network'; /** opt-in auto-retry config — `true` => one retry on flood waits, no wait cap. object form overrides the knobs */ export interface RetryOnFloodWaitOptions { /** maximum number of retries on a single api call (default 1) */ max?: number; /** if `retry_after × 1000` exceeds this, propagate the error instead of sleeping (default Infinity) */ maxWaitMs?: number; /** which failure classes to retry. defaults to `['flood']`, preserving the original 429-only behavior */ on?: RetryReason[]; /** exponential backoff for `server`/`network` retries — `base × 2 ** attempt`, capped at `max` */ backoff?: { /** first-retry delay in ms (default 3000) */ base?: number; /** maximum backoff delay in ms (default 3_600_000, one hour) */ max?: number; }; } export interface TelegramOptions { token: string; httpClient?: HttpClient; /** pre-populate `tg.bot` and skip the start-time getMe call */ bot?: TelegramUser; /** update kinds to subscribe to, or `'auto'` to derive the minimal set from registered handlers */ allowedUpdates?: string[] | 'auto'; apiBaseUrl?: string; apiTimeout?: number; apiWait?: number; apiRetryLimit?: number; apiHeaders?: Record; useTestDc?: boolean; useLocal?: boolean; /** * per-call params merged into every outgoing api call. `'*'` applies to any method * that accepts the param; a per-method key overrides `'*'`; an explicit call-site * value wins over both. set once here — there is no runtime setter */ defaultParams?: DefaultParams; /** * when the bot api answers with 429 + `parameters.retry_after`, sleep that many * seconds and retry the same call. defaults to `false` — opt-in to preserve * existing error propagation. pass an object to bound retries or wait time */ retryOnFloodWait?: boolean | RetryOnFloodWaitOptions; /** * when a dispatched update handler throws, the default behavior is to rethrow * on a microtask so node's `uncaughtException` kicks in. set to `true` to * suppress that fallback — errors only reach handlers registered via `tg.catch` */ swallowDispatchErrors?: boolean; /** * auto-answer `callback_query` updates after dispatch when no handler called `update.answer(...)`. * `true` answers with no params; an object answers with those params. defaults to `false` */ autoAnswerCallbackQuery?: boolean | Omit; /** * drop updates whose `update_id` was seen recently (webhook retries, polling overlap). `true` keeps * the last 1000 ids; pass `{ max }` to size the window. defaults to `false` */ dedupeUpdates?: boolean | { max?: number; }; } export interface ResolvedTelegramOptions extends Required> { httpClient: HttpClient | undefined; bot?: TelegramUser; retryOnFloodWait: boolean | RetryOnFloodWaitOptions; swallowDispatchErrors: boolean; } export declare const DEFAULT_OPTIONS: Omit; export declare function resolveOptions(input: TelegramOptions): ResolvedTelegramOptions; //# sourceMappingURL=options.d.ts.map