import { SelectQueryBuilder } from "kysely"; import { ListParams } from "@authhero/adapter-interfaces"; /** * Keyset (checkpoint) pagination for list queries — the Auth0 `from`/`take` * style. `from` is an OPAQUE cursor (see encodeCursor), decoded to a * `(sortValue, id)` position; `take` is the page size. We fetch `take + 1` * rows to detect whether another page follows and emit a `next` cursor, * absent on the last page. * * This is intentionally keyset-only. Offset pagination (page/per_page + total), * which the admin UI uses and which honors arbitrary user sort, stays in each * adapter untouched. Callers branch to this helper only when `from`/`take` is * present. The helper owns ORDER BY (sortColumn then idColumn as a unique * tiebreaker), so the passed query must not be pre-ordered. */ export declare function isKeysetRequest(params?: ListParams): boolean; export interface KeysetOptions { /** * Column to sort by. Must be a real column on the queried table. May be * table-qualified (`users.created_at`) when the query joins other tables; * the row property is read from the segment after the last dot. */ sortColumn: string; sortOrder: "asc" | "desc"; /** Unique tiebreaker column (may be table-qualified); defaults to "id". */ idColumn?: string; /** * Sort spec (e.g. `date:desc`) for endpoints that honor a caller-chosen sort * in checkpoint mode. Minted into the cursor; a cursor presented under a * different sort spec is rejected with a 400, because its keyset position is * meaningless in the new order. Omit on fixed-sort endpoints. */ sortKey?: string; } export interface KeysetResult { rows: Row[]; /** Page size actually applied. */ limit: number; /** Opaque cursor for the next page; set only when more rows follow. */ next?: string; } export declare function keysetPaginate(query: SelectQueryBuilder, params: ListParams | undefined, options: KeysetOptions): Promise>;