/** * Paginated response containing a page of results. * * @template T The type of items in the page */ export interface Page { /** * Items in this page. */ readonly values: readonly T[]; /** * Whether there are more pages available. * If true, use the last item in `values` as the cursor for the next page. */ readonly hasMore: boolean; } /** * A function that fetches a single page of results. * @template TItem The type of items in the page * @template TArgs The query arguments type (excluding startAfter) */ export type PageFetcher = (args: TArgs & { startAfter?: string; }) => Promise<{ items: TItem[]; hasMore: boolean; }>; /** * Arguments for listAll pagination methods. * Omits startAfter since pagination is handled automatically. * Adds includeDeleted option to include resources pending deletion. */ export type ListAllArgs = Omit & { /** Include resources that are pending deletion (default: false). */ includeDeleted?: boolean; }; /** * Creates a lazy async iterable that automatically paginates through all results. * * @template TItem The type of items being paginated * @template TArgs The query arguments type * @param fetcher Function that fetches a single page of results * @param args Query arguments (startAfter is managed internally) * @param getCursor Function to extract the cursor value from an item for the next page * @returns An async iterable that yields items one at a time, fetching pages as needed * * @example * ```ts * const allBasins = paginate( * (args) => this.list(args).then(r => ({ items: r.basins, hasMore: r.hasMore })), * { prefix: "my-" }, * (basin) => basin.name * ); * * for await (const basin of allBasins) { * console.log(basin.name); * } * ``` */ export declare function paginate(fetcher: PageFetcher, args: TArgs, getCursor: (item: TItem) => string): AsyncIterable; /** * Filters an async iterable, yielding only items that match the predicate. * * @template T The type of items in the iterable * @param source The async iterable to filter * @param predicate Function that returns true for items to keep * @returns A new async iterable yielding only matching items */ export declare function filterAsync(source: AsyncIterable, predicate: (item: T) => boolean): AsyncIterable; //# sourceMappingURL=paginate.d.ts.map