import { FinalRequestOptions } from "../internal/request-options.js"; import { type Orb } from "../client.js"; import { APIPromise } from "./api-promise.js"; import { type APIResponseProps } from "../internal/parse.js"; export type PageRequestOptions = Pick; export declare abstract class AbstractPage implements AsyncIterable { #private; protected options: FinalRequestOptions; protected response: Response; protected body: unknown; constructor(client: Orb, response: Response, body: unknown, options: FinalRequestOptions); abstract nextPageRequestOptions(): PageRequestOptions | null; abstract getPaginatedItems(): Item[]; hasNextPage(): boolean; getNextPage(): Promise; iterPages(): AsyncGenerator; [Symbol.asyncIterator](): AsyncGenerator; } /** * This subclass of Promise will resolve to an instantiated Page once the request completes. * * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg: * * for await (const item of client.items.list()) { * console.log(item) * } */ export declare class PagePromise, Item = ReturnType[number]> extends APIPromise implements AsyncIterable { constructor(client: Orb, request: Promise, Page: new (...args: ConstructorParameters) => PageClass); /** * Allow auto-paginating iteration on an unawaited list call, eg: * * for await (const item of client.items.list()) { * console.log(item) * } */ [Symbol.asyncIterator](): AsyncGenerator; } export interface PageResponse { data: Array; pagination_metadata: PageResponse.PaginationMetadata; } export declare namespace PageResponse { interface PaginationMetadata { has_more: boolean; next_cursor: string | null; } } export interface PageParams { /** * Cursor for pagination. This can be populated by the `next_cursor` value returned * from the initial request. */ cursor?: string | null; /** * The number of items to fetch. Defaults to 20. */ limit?: number; } export declare class Page extends AbstractPage implements PageResponse { data: Array; pagination_metadata: PageResponse.PaginationMetadata; constructor(client: Orb, response: Response, body: PageResponse, options: FinalRequestOptions); getPaginatedItems(): Item[]; nextPageRequestOptions(): PageRequestOptions | null; } //# sourceMappingURL=pagination.d.ts.map