export interface PaginationState { cursor: string | null | undefined; hasMore: boolean; hasPrevious: boolean; currentPage: number; totalPages: number; hasMorePagesAvailable: boolean; } export interface PaginationCallbacks { onNext: () => Promise; onPrevious: () => Promise; onExit: () => void; } /** * Setup interactive pagination listener */ export declare const setupPaginationListener: (state: PaginationState, callbacks: PaginationCallbacks) => (() => void); /** * Show pagination state info */ export declare const showPaginationState: (state: PaginationState) => void; /** * Page data structure for caching paginated results */ export interface PageData { data: T[]; cursor: string | null | undefined; hasMore: boolean; pageInfo?: AnalyticsPageInfo; /** * False when `--cursor` on a new invocation would not reach the read path * that produced this cursor, so printing it would hand back a cursor the * next call sends to the wrong backend. That is the case for a page served * by the storage fallback of a listing that otherwise reads analytics: a * new call given a cursor goes to analytics. Omitted means reusable. */ cursorReusable?: boolean; } /** * The line a listing prints when it stopped with more rows behind it. * * It names the next page's cursor, since `--interactive` needs a TTY and * `--json` ignores it: without the cursor, a script had no way past the * first page of a listing whose JSON output is a bare array. */ export declare const moreResultsMessage: (page: Pick, "cursor" | "cursorReusable">, options?: { supportsAll?: boolean; json?: boolean; }) => string; /** * Follow cursors from `initialCursor` until the backend reports no more * rows, and return every row as one page. * * Throws rather than return a short answer: a backend that claims more rows * but gives no cursor would end the read early while looking complete, and * one that repeats a cursor would loop forever. */ export declare function fetchAllPages(fetchPage: (cursor: string | undefined) => Promise>, initialCursor?: string): Promise>; export interface AnalyticsPageInfo { currentLookbackDays: number; maxLookbackDays: number; currentWindowStart: Date | string; maxWindowStart: Date | string; upgradeAvailable: boolean; } export declare const getPageInfoUpgradeHint: (pageInfo: AnalyticsPageInfo | undefined) => string | undefined; /** * Generic pagination handler for list operations */ export interface ListPaginationOptions { /** * Initial cursor from CLI options */ initialCursor?: string; /** * Fetch function that returns paginated data */ fetchPage: (cursor: string | undefined) => Promise>; /** * Display function that renders the current page */ displayPage: (data: TData[], pageIndex: number, page: PageData) => void | Promise; /** * Optional callback for when fetching starts */ onFetchStart?: (pageIndex: number) => void; /** * Enable interactive pagination with keyboard controls */ interactive?: boolean; /** * Read every page from `initialCursor` on and display them as one page * (`--all`). Never combined with `interactive`; the command rejects that. */ all?: boolean; /** * Whether this listing accepts `--all`, so the more-results hint can * offer it. */ supportsAll?: boolean; } /** * Setup pagination for list operations with page caching */ export declare function setupListPagination(options: ListPaginationOptions): Promise; //# sourceMappingURL=pagination.d.ts.map