import type { Client } from "../client/client/index.js"; import type { Operation } from "../client/types.gen.js"; import { type NeonResult } from "./result.js"; export interface WaitBudget { /** How often to poll each pending operation. Default 1000ms. */ pollIntervalMs?: number; /** Overall deadline before giving up. Default 300000ms (5 min). */ timeoutMs?: number; } export interface WaitForOptions extends WaitBudget { signal?: AbortSignal; } /** * Poll the given operations until each reaches a terminal `finished`/`skipped` state. * Returns an error result carrying {@link NeonOperationError} if any operation ends in * `failed`/`error`/`cancelled`, {@link NeonWaitTimeoutError} if the deadline is exceeded, or * {@link NeonAbortError} if the caller's signal fired. * * `timeoutMs` is a real deadline rather than a check between polls. Each poll runs under * it, so a request that hangs cannot outlast the budget, and the budget is re-examined * after every operation rather than once per round — a round polls each pending operation * in turn, so checking only at the top let a long round overrun the timeout arbitrarily. * * Composable: usable directly with operations obtained from the raw layer. */ export declare function waitForOperations(client: Client, operations: readonly Operation[], options?: WaitForOptions): Promise>; interface PolledRead { data?: T | undefined; error?: unknown; response?: Response | undefined; } /** * Poll `read` until `settled` accepts its body, under the same budget and error contract * as {@link waitForOperations}. For resources whose asynchronous changes report a pending * flag instead of returning operations. A timeout carries no operations to resume from. * * The first read is immediate and later reads are `pollIntervalMs` apart, so a budget * shorter than one interval still observes the state once. */ export declare function pollUntil(read: (signal: AbortSignal | undefined) => Promise>, settled: (data: T) => boolean, what: string, options?: WaitForOptions): Promise>; /** Type guard: does a response body carry an `operations` array we can wait on? */ export declare function hasOperations(data: unknown): data is { operations: Operation[]; }; export {}; //# sourceMappingURL=wait.d.ts.map