@authhero/kysely-adapter 11.14.2 → 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.
@@ -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>>;
@@ -1,4 +1,11 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { AuditEventInsert } from "@authhero/adapter-interfaces";
3
3
  import { Database } from "../db";
4
+ /**
5
+ * Insert a single outbox event using the provided Kysely instance — which may
6
+ * be a transaction (`trx`). Shared by `createOutboxEvent` (standalone insert)
7
+ * and the user write adapters, which call it inside their own transaction so
8
+ * the event row commits together with the business row (issue #1057).
9
+ */
10
+ export declare function insertOutboxEvent(db: Kysely<Database>, tenantId: string, id: string, event: AuditEventInsert): Promise<void>;
4
11
  export declare function createOutboxEvent(db: Kysely<Database>): (tenantId: string, event: AuditEventInsert) => Promise<string>;
@@ -1,4 +1,4 @@
1
1
  import { Kysely } from "kysely";
2
2
  import { Database } from "../db";
3
- import { User, UserInsert, CreateOptions } from "@authhero/adapter-interfaces";
4
- export declare function create(db: Kysely<Database>): (tenantId: string, user: UserInsert, options?: CreateOptions) => Promise<User>;
3
+ import { User, UserInsert, CreateOptions, WriteOptions } from "@authhero/adapter-interfaces";
4
+ export declare function create(db: Kysely<Database>): (tenantId: string, user: UserInsert, options?: CreateOptions & WriteOptions) => Promise<User>;
@@ -1,3 +1,4 @@
1
1
  import { Kysely } from "kysely";
2
+ import { WriteOptions } from "@authhero/adapter-interfaces";
2
3
  import { Database } from "../db";
3
- export declare function remove(db: Kysely<Database>): (tenant_id: string, user_id: string) => Promise<boolean>;
4
+ export declare function remove(db: Kysely<Database>): (tenant_id: string, user_id: string, options?: WriteOptions) => Promise<boolean>;
@@ -1,4 +1,4 @@
1
- import { PostUsersBody, User } from "@authhero/adapter-interfaces";
1
+ import { PostUsersBody, User, WriteOptions } from "@authhero/adapter-interfaces";
2
2
  import { Kysely } from "kysely";
3
3
  import { Database } from "../db";
4
- export declare function update(db: Kysely<Database>): (tenant_id: string, user_id: string, user: Partial<PostUsersBody> & Partial<Pick<User, "last_login" | "last_ip" | "login_count">>) => Promise<boolean>;
4
+ export declare function update(db: Kysely<Database>): (tenant_id: string, user_id: string, user: Partial<PostUsersBody> & Partial<Pick<User, "last_login" | "last_ip" | "login_count">>, options?: WriteOptions) => Promise<boolean>;