/** * Pagination utilities * * Helpers for working with paginated API responses. * Includes async iterators for automatic pagination. */ import type { PaginatedResponse, PaginationInput } from "@artu-ai/shared"; /** * Default page size for paginated requests */ export declare const DEFAULT_PAGE_SIZE = 20; /** * Maximum page size allowed by the API */ export declare const MAX_PAGE_SIZE = 200; /** * Creates an async iterator for paginated results. * Automatically fetches subsequent pages as you iterate. * * @param fetchPage - Function that fetches a page of results * @param options - Iterator options * @returns Async generator yielding individual items * * @example * ```typescript * const iterator = createPaginatedIterator( * (pagination) => client.clients.list.query(pagination) * ); * * for await (const client of iterator) { * console.log(client.name); * } * ``` */ export declare function createPaginatedIterator(fetchPage: (pagination: PaginationInput) => Promise>, options?: { limit?: number; }): AsyncGenerator; /** * Collects all items from a paginated iterator into an array. * Use with caution on large datasets. * * @param iterator - Async iterator to collect from * @returns Array of all items * * @example * ```typescript * const allClients = await collectAll( * createPaginatedIterator((p) => client.clients.list.query(p)) * ); * ``` */ export declare function collectAll(iterator: AsyncGenerator): Promise; /** * Collects items from a paginated iterator up to a maximum count. * Useful when you only need a subset of results. * * @param iterator - Async iterator to collect from * @param maxItems - Maximum number of items to collect * @returns Array of collected items * * @example * ```typescript * // Get first 100 clients * const clients = await collectUpTo( * createPaginatedIterator((p) => client.clients.list.query(p)), * 100 * ); * ``` */ export declare function collectUpTo(iterator: AsyncGenerator, maxItems: number): Promise; /** * Gets the first item from a paginated iterator, or undefined if empty. * * @param iterator - Async iterator to get first item from * @returns First item or undefined * * @example * ```typescript * const firstClient = await getFirst( * createPaginatedIterator((p) => client.clients.list.query({ ...p, limit: 1 })) * ); * ``` */ export declare function getFirst(iterator: AsyncGenerator): Promise;