import type { Misina, MisinaRequestInit, MisinaResponse } from "../types.mjs"; export interface PollOptions { /** * Predicate run on each polled response. Return `true` to resolve with the * current data; `false` to keep polling. */ until: (data: T) => boolean | Promise; /** Delay between attempts in ms. Default: 1000. */ interval?: number | ((attempt: number) => number); /** Total wall-clock deadline in ms. Throws TimeoutError if exceeded. */ timeout?: number; /** Cap on number of poll attempts. Default: Infinity. */ maxAttempts?: number; /** External abort signal — composes with the timeout. */ signal?: AbortSignal; /** Per-request init forwarded to misina (headers, query, etc). */ init?: MisinaRequestInit; } export declare class PollExhaustedError extends Error { readonly attempts: number; override readonly name = "PollExhaustedError"; constructor(attempts: number); } /** * Poll a URL until `until(data)` returns true. Resolves with the matching * `data`. Throws on timeout, abort, or attempt exhaustion. * * ```ts * const job = await poll(misina, "/jobs/42", { * interval: 1000, * timeout: 60_000, * until: (j) => j.state === "done", * }) * ``` */ export declare function poll(misina: Misina, url: string, options: PollOptions): Promise; export interface FollowAcceptedOptions extends Omit, "until"> { /** * Trigger the long-running operation. Should return a Response (or * MisinaResponse) with `202 Accepted` and a `Location` header pointing * at the status endpoint to poll. */ trigger: () => Promise>; /** Predicate that decides when polling is done. */ until: (data: T) => boolean | Promise; } /** * Common async-job pattern: POST → `202 Accepted` + `Location` → poll * the location URL until `until(data)` is satisfied. Resolves with the * final data. * * ```ts * const result = await followAccepted(misina, { * trigger: () => misina.post("/jobs", body), * interval: 2000, * timeout: 5 * 60_000, * until: (data) => data.status === "completed", * }) * ``` */ export declare function followAccepted(misina: Misina, options: FollowAcceptedOptions): Promise;