import { AnyQb, DbRef } from './util.js'; type KeysetCursor = { primary: string; secondary: string; }; type KeysetLabeledResult = { primary: string | number; secondary: string | number; }; /** * The GenericKeyset is an abstract class that sets-up the interface and partial implementation * of a keyset-paginated cursor with two parts. There are three types involved: * - Result: a raw result (i.e. a row from the db) containing data that will make-up a cursor. * - E.g. { createdAt: '2022-01-01T12:00:00Z', cid: 'bafyx' } * - LabeledResult: a Result processed such that the "primary" and "secondary" parts of the cursor are labeled. * - E.g. { primary: '2022-01-01T12:00:00Z', secondary: 'bafyx' } * - Cursor: the two string parts that make-up the packed/string cursor. * - E.g. packed cursor '1641038400000__bafyx' in parts { primary: '1641038400000', secondary: 'bafyx' } * * These types relate as such. Implementers define the relations marked with a *: * Result -*-> LabeledResult <-*-> Cursor <--> packed/string cursor * ↳ SQL Condition */ export declare abstract class GenericKeyset { primary: DbRef; secondary: DbRef; constructor(primary: DbRef, secondary: DbRef); abstract labelResult(result: R): LR; abstract labeledResultToCursor(labeled: LR): KeysetCursor; abstract cursorToLabeledResult(cursor: KeysetCursor): LR; packFromResult(results: R | R[]): string | undefined; pack(labeled?: LR): string | undefined; unpack(cursorStr?: string): LR | undefined; packCursor(cursor?: KeysetCursor): string | undefined; unpackCursor(cursorStr?: string): KeysetCursor | undefined; getSql(labeled?: LR, direction?: 'asc' | 'desc', tryIndex?: boolean): import("kysely").RawBuilder | undefined; paginate(qb: QB, opts: { limit?: number; cursor?: string; direction?: 'asc' | 'desc'; tryIndex?: boolean; nullsLast?: boolean; }): QB; } type SortAtCidResult = { sortAt: string; cid: string; }; type TimeCidLabeledResult = KeysetCursor; export declare class TimeCidKeyset extends GenericKeyset { labelResult(result: TimeCidResult): TimeCidLabeledResult; labeledResultToCursor(labeled: TimeCidLabeledResult): { primary: string; secondary: string; }; cursorToLabeledResult(cursor: KeysetCursor): { primary: string; secondary: string; }; } export declare class CreatedAtDidKeyset extends TimeCidKeyset<{ createdAt: string; did: string; }> { labelResult(result: { createdAt: string; did: string; }): { primary: string; secondary: string; }; } export declare class IndexedAtDidKeyset extends TimeCidKeyset<{ indexedAt: string; did: string; }> { labelResult(result: { indexedAt: string; did: string; }): { primary: string; secondary: string; }; } /** * This is being deprecated. Use {@link GenericKeyset#paginate} instead. */ export declare const paginate: >(qb: QB, opts: { limit?: number; cursor?: string; direction?: "asc" | "desc"; keyset: K; tryIndex?: boolean; nullsLast?: boolean; }) => QB; type SingleKeyCursor = { primary: string; }; type SingleKeyLabeledResult = { primary: string | number; }; /** * GenericSingleKey is similar to {@link GenericKeyset} but for a single key cursor. */ export declare abstract class GenericSingleKey { primary: DbRef; constructor(primary: DbRef); abstract labelResult(result: R): LR; abstract labeledResultToCursor(labeled: LR): SingleKeyCursor; abstract cursorToLabeledResult(cursor: SingleKeyCursor): LR; packFromResult(results: R | R[]): string | undefined; pack(labeled?: LR): string | undefined; unpack(cursorStr?: string): LR | undefined; packCursor(cursor?: SingleKeyCursor): string | undefined; unpackCursor(cursorStr?: string): SingleKeyCursor | undefined; getSql(labeled?: LR, direction?: 'asc' | 'desc'): import("kysely").RawBuilder | undefined; paginate(qb: QB, opts: { limit?: number; cursor?: string; direction?: 'asc' | 'desc'; nullsLast?: boolean; }): QB; } type SortAtResult = { sortAt: string; }; type TimeLabeledResult = SingleKeyCursor; export declare class IsoTimeKey extends GenericSingleKey { labelResult(result: TimeResult): TimeLabeledResult; labeledResultToCursor(labeled: TimeLabeledResult): { primary: string; }; cursorToLabeledResult(cursor: SingleKeyCursor): { primary: string; }; } export declare class IsoSortAtKey extends IsoTimeKey<{ sortAt: string; }> { labelResult(result: { sortAt: string; }): { primary: string; }; } export declare class IsoUpdatedAtKey extends IsoTimeKey<{ updatedAt: string; }> { labelResult(result: { updatedAt: string; }): { primary: string; }; } type KeyResult = { key: string; }; type RkeyLabeledResult = SingleKeyCursor; export declare class RkeyKey extends GenericSingleKey { labelResult(result: RkeyResult): RkeyLabeledResult; labeledResultToCursor(labeled: RkeyLabeledResult): { primary: string; }; cursorToLabeledResult(cursor: SingleKeyCursor): { primary: string; }; } export declare class StashKeyKey extends RkeyKey<{ key: string; }> { labelResult(result: { key: string; }): { primary: string; }; } export {}; //# sourceMappingURL=pagination.d.ts.map