/** Duck-typed shape check — used by the response serializer (P4) to * detect a paginator-shaped return value from an action. */ export declare function isPaginator(value: unknown): value is Paginator; /** Duck-typed shape check for the simple paginator. */ export declare function isSimplePaginator(value: unknown): value is SimplePaginator; /** Duck-typed shape check for the cursor paginator. */ export declare function isCursorPaginator(value: unknown): value is CursorPaginator; /** * Convert bun-query-builder's `paginate()` output (`{ data, meta: * { perPage, page, total, lastPage } }`) into the canonical Stacks * shape. P1 of the migration — the URL fields stay undefined until * P2 wires the request-context resolver. */ export declare function toPaginator(result: { data: T[], meta: { perPage: number, page: number, total: number, lastPage: number } }): Paginator; /** Convert bqb's `simplePaginate()` output to the canonical * {@link SimplePaginator} shape. */ export declare function toSimplePaginator(result: { data: T[], meta: { perPage: number, page: number, hasMore: boolean } }): SimplePaginator; /** Convert bqb's `cursorPaginate()` output to the canonical * {@link CursorPaginator} shape. Cursors are serialized to strings * via JSON — composite cursors (arrays) survive the round-trip. */ export declare function toCursorPaginator(result: { data: T[], meta: { perPage: number, nextCursor: unknown, prevCursor: unknown } }): CursorPaginator; /** * Canonical paginator types + adapters (stacksjs/stacks#1905, P1 from #1910). * * Four pagination shapes used to ship across the framework — bqb's SQL * client `{ data, meta }`, bqb's sync ORM `{ data, total, page, ... }`, * the search-engine's `{ hits, total, page, perPage }`, and a fifth * declared-but-not-implemented Stacks shape (`{ data, paging, next_cursor }`) * that the runtime never actually produced. This module unifies them * to the Laravel-flavored, snake_case shapes below. * * P1 ships only `data` + counts; the URL fields are declared but left * `undefined` by default. P2 (stacksjs/stacks#1906) wires them in when * a request is in scope. * * Shape choices: * - snake_case for JSON friendliness (matches Laravel's serialized * paginator + the existing REST convention across the Stacks API) * - `from` / `to` are 1-indexed offsets of the first/last row on the * current page; `null` when the page is empty * - `has_more_pages` is the cheap boolean apps actually want — saves * `current_page < last_page` checks everywhere */ /** * Full paginator — knows the total row count so it can compute * `last_page`, supports "jump to page N" UI patterns. Costs an extra * `COUNT(*)` query; use {@link SimplePaginator} or {@link CursorPaginator} * for very large tables. */ export declare interface Paginator { data: T[] current_page: number per_page: number total: number last_page: number from: number | null to: number | null has_more_pages: boolean prev_page_url?: string | null next_page_url?: string | null first_page_url?: string last_page_url?: string path?: string } /** * Simple paginator — drops the `COUNT(*)` query. Faster on large tables * but can't render "jump to page 5" UIs since `last_page` / `total` are * unknown. Suitable for infinite-scroll feeds. */ export declare interface SimplePaginator { data: T[] current_page: number per_page: number has_more_pages: boolean prev_page_url?: string | null next_page_url?: string | null path?: string } /** * Cursor (keyset) paginator — uses `WHERE id > :cursor` ordering rather * than `LIMIT/OFFSET`, so query cost stays constant regardless of how * deep the user has paged. The trade-off is no random-access ("jump to * page N"); only prev/next. * * Cursor values are opaque to the caller — serialize as JSON, send to * the client, accept back unchanged. Implementations (cursorPaginate) * decide the cursor shape (single column value, base64 tuple for * composite keys, etc.). */ export declare interface CursorPaginator { data: T[] per_page: number next_cursor: string | null prev_cursor: string | null has_more_pages: boolean prev_page_url?: string | null next_page_url?: string | null path?: string }