@authhero/kysely-adapter 11.15.0 → 11.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +16 -16
- package/dist/kysely-adapter.mjs +2090 -2019
- package/dist/types/src/helpers/paginate.d.ts +31 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SelectQueryBuilder } from "kysely";
|
|
2
|
+
import { ListParams } from "@authhero/adapter-interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Keyset (checkpoint) pagination for list queries — the Auth0 `from`/`take`
|
|
5
|
+
* style. `from` is an OPAQUE cursor (see encodeCursor), decoded to a
|
|
6
|
+
* `(sortValue, id)` position; `take` is the page size. We fetch `take + 1`
|
|
7
|
+
* rows to detect whether another page follows and emit a `next` cursor,
|
|
8
|
+
* absent on the last page.
|
|
9
|
+
*
|
|
10
|
+
* This is intentionally keyset-only. Offset pagination (page/per_page + total),
|
|
11
|
+
* which the admin UI uses and which honors arbitrary user sort, stays in each
|
|
12
|
+
* adapter untouched. Callers branch to this helper only when `from`/`take` is
|
|
13
|
+
* present. The helper owns ORDER BY (sortColumn then idColumn as a unique
|
|
14
|
+
* tiebreaker), so the passed query must not be pre-ordered.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isKeysetRequest(params?: ListParams): boolean;
|
|
17
|
+
export interface KeysetOptions {
|
|
18
|
+
/** Column to sort by. Must be a real column on the queried table. */
|
|
19
|
+
sortColumn: string;
|
|
20
|
+
sortOrder: "asc" | "desc";
|
|
21
|
+
/** Unique tiebreaker column; defaults to "id". */
|
|
22
|
+
idColumn?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface KeysetResult<Row> {
|
|
25
|
+
rows: Row[];
|
|
26
|
+
/** Page size actually applied. */
|
|
27
|
+
limit: number;
|
|
28
|
+
/** Opaque cursor for the next page; set only when more rows follow. */
|
|
29
|
+
next?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function keysetPaginate<DB, TB extends keyof DB, O>(query: SelectQueryBuilder<DB, TB, O>, params: ListParams | undefined, options: KeysetOptions): Promise<KeysetResult<O>>;
|