type TPageOptions = TOptions extends undefined ? { cursor?: string; maxItems?: number; pageSize?: number; } : TOptions & { cursor?: string; maxItems?: number; pageSize?: number; }; export declare function decodeIncomingCursor(incoming?: string): { offset: number; cursor: string | undefined; }; export declare function createPrefixedCursor(prefix: string, cursor: string | undefined): string; export declare function splitPrefixedCursor(cursor: string | undefined, prefixes?: string[]): [string | undefined, string | undefined]; /** * Utility for paginating through API endpoints that return cursor-based pages. * Accepts and yields SDK-encoded cursor envelopes. Any incoming cursor is decoded * before being passed to the page function; all outgoing cursors are encoded. * * @param pageFunction - Function that fetches a single page with {data, nextCursor} structure * @param pageOptions - Options to pass to the page function (cursor will be managed automatically) * @returns Async iterator that yields pages with encoded cursors */ export declare function paginateMaxItems(pageFunction: (options: TOptions & { cursor?: string; maxItems?: number; pageSize?: number; }) => Promise, pageOptions?: TPageOptions): AsyncIterableIterator; export declare function paginateBuffered(pageFunction: (options: TOptions & { cursor?: string; maxItems?: number; pageSize?: number; }) => Promise, pageOptions?: TPageOptions): AsyncIterableIterator; export declare const paginate: typeof paginateBuffered; interface PaginatedResult { data: TItem[]; nextCursor?: string; } type PaginatedSource = () => PromiseLike> & AsyncIterable>; /** * Concatenate multiple paginated SDK results into a single paginated stream. * Each source is a function returning a dual Promise+AsyncIterable (as SDK * paginated methods return). Sources are drained in order. * * The optional `dedupe` key extractor filters items from source N against * all items seen in sources 0 through N-1. * * Uses paginateBuffered internally to normalize page sizes across source * boundaries — e.g. if the first source only has 2 items, they'll be * buffered with items from the next source into a full page. * * Returns the same dual Promise+AsyncIterable shape that resolvers expect. */ export declare function concatPaginated({ sources, dedupe, pageSize, }: { sources: PaginatedSource[]; dedupe?: (item: TItem) => string; pageSize?: number; }): PromiseLike> & AsyncIterable>; /** * Strip the PromiseLike from an async iterable, returning a plain * AsyncIterable. This prevents async functions from unwrapping the * iterable (since async only unwraps PromiseLike, not AsyncIterable). */ export declare function toIterable(source: AsyncIterable): AsyncIterable; export {}; //# sourceMappingURL=pagination-utils.d.ts.map