import { type Deadline } from "./deadline.js"; import { type Outcome } from "./result.js"; export interface Page { items: T[]; /** Cursor for the next page, when more results exist. */ cursor?: string; } interface RawResult { data?: D | undefined; error?: unknown; response?: Response | undefined; } /** * A lazy, cursor-paginated list. `page()` / `all()` follow the resolved `throwOnError` * policy exactly like every other method: bare value (throwing on failure) when it is on, * `{ data, error }` envelope when it is off. The async iterator always throws on a * page-fetch error — a stream has no envelope form. * * `waitForReadiness` is not applied: list responses carry no `operations`. */ export interface Paginated extends AsyncIterable { /** Fetch a single page (optionally from a cursor). */ page(cursor?: string): Promise, Throw>>; /** Fetch and concatenate every page. */ all(): Promise>; } /** * Build a {@link Paginated} list from a page fetcher and a page mapper. The response-body * type `D` is inferred and erased from the public `Paginated` return. * * `newDeadline` is called once per consumption — each `page()`, each `all()`, each * iteration — because a `Paginated` is lazy and may be consumed more than once, so a * deadline created when the list was built would already be spent. * * `shouldThrow` is the policy resolved when the list is built (per-call override, else * the client default), the same rule the execution core uses for every other method. */ export declare function paginate(fetchPage: (cursor: string | undefined, signal?: AbortSignal) => Promise>, mapPage: (data: D) => Page, newDeadline: () => Deadline, shouldThrow: boolean): Paginated; export {}; //# sourceMappingURL=paginate.d.ts.map