import type { Page } from "./types.js"; /** * Walking a cursor-paginated list. * * The list endpoints are keyset paginated: `?cursor=` carries where the last * page ended, and the response is `{ data, pagination: { nextCursor?, limit } }` * with `nextCursor` absent on the last page. The absence is the ONLY stop * signal - an empty `data` array is not the same thing, because a page can * come back empty when everything in it was filtered after the fetch while * more pages remain. A client that stops on an empty page silently truncates * the user's results and nothing anywhere reports an error. * * That rule is easy to state and easy to get wrong once per call site, which * is why every list method returns one of these instead of leaving the loop to * the caller. * * Not every list is paginated. `spaces/{id}/memories` and * `entities/{id}/memories` return a `pagination` block with no cursor at all, * so iterating them yields exactly one page and stops - which is correct, and * costs a caller nothing for using the same shape everywhere. */ export declare class Paginated implements AsyncIterable { #private; constructor(fetchPage: (cursor: string | undefined) => Promise>); /** The first page, and nothing more. For a UI that renders one page at a time. */ first(): Promise>; /** * Page by page, for a caller that wants the cursors or wants to stop early. * * A generator rather than an array of pages: fetching them all up front * would make "show me the first ten" cost every page in the account. */ pages(): AsyncGenerator, void, undefined>; /** Every item across every page. `for await (const memory of ...)`. */ [Symbol.asyncIterator](): AsyncGenerator; /** * Everything, in one array. * * `maxItems` is not optional, and that is the point. An unbounded `all()` on * an account with two hundred thousand memories is a request loop that runs * for minutes and an array that exhausts the heap, and the call site that * does it reads as innocently as any other. Ask for a number you can hold. */ all(maxItems: number): Promise; }