@authhero/kysely-adapter 11.11.0 → 11.13.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,14 @@
1
+ import { Kysely } from "kysely";
2
+ import { Database } from "../../src/db";
3
+ /**
4
+ * Contract phase of the user_activity split (issue #1003): the counters were
5
+ * backfilled into `user_activity` and all reads/writes have been cut over, so
6
+ * the legacy `users` columns can go. Requires the backfill script to have run
7
+ * against the environment first — dropping the columns discards any values
8
+ * that were never copied.
9
+ *
10
+ * Plain DROP COLUMN works on both dialects (SQLite ≥3.35 / D1 / MySQL); none
11
+ * of these columns are indexed.
12
+ */
13
+ export declare function up(db: Kysely<Database>): Promise<void>;
14
+ export declare function down(db: Kysely<Database>): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import { Kysely } from "kysely";
2
+ /**
3
+ * Durable tenant lifecycle operations with append-only history, plus fleet
4
+ * rollouts (issue #1026). `tenant_operations` intentionally has no FK to
5
+ * `tenants`: the log must survive tenant deletion and `tenant_id` is NULL
6
+ * for fleet-level operations.
7
+ */
8
+ export declare function up(db: Kysely<unknown>): Promise<void>;
9
+ export declare function down(db: Kysely<unknown>): Promise<void>;
@@ -175,6 +175,8 @@ import * as o076_default_first_party_true from "./2026-06-04T11:01:00_default_fi
175
175
  import * as o077_tenant_deployment_fields from "./2026-06-06T12:00:00_tenant_deployment_fields";
176
176
  import * as o078_tenant_database_version from "./2026-06-27T12:00:00_tenant_database_version";
177
177
  import * as o079_user_activity_and_user_column_cleanup from "./2026-06-30T12:00:00_user_activity_and_user_column_cleanup";
178
+ import * as o080_drop_user_activity_columns_from_users from "./2026-07-02T12:00:00_drop_user_activity_columns_from_users";
179
+ import * as o081_tenant_operations from "./2026-07-04T12:00:00_tenant_operations";
178
180
  declare const _default: {
179
181
  m1_init: typeof m1_init;
180
182
  m2_magicLink: typeof m2_magicLink;
@@ -353,5 +355,7 @@ declare const _default: {
353
355
  o077_tenant_deployment_fields: typeof o077_tenant_deployment_fields;
354
356
  o078_tenant_database_version: typeof o078_tenant_database_version;
355
357
  o079_user_activity_and_user_column_cleanup: typeof o079_user_activity_and_user_column_cleanup;
358
+ o080_drop_user_activity_columns_from_users: typeof o080_drop_user_activity_columns_from_users;
359
+ o081_tenant_operations: typeof o081_tenant_operations;
356
360
  };
357
361
  export default _default;
@@ -72,11 +72,16 @@ declare const sqlPasswordSchema: z.ZodObject<{
72
72
  is_current: z.ZodNumber;
73
73
  }, z.core.$strip>;
74
74
  export declare const sqlUserSchema: z.ZodObject<{
75
+ username: z.ZodOptional<z.ZodString>;
76
+ user_id: z.ZodString;
77
+ created_at: z.ZodString;
78
+ updated_at: z.ZodString;
75
79
  name: z.ZodOptional<z.ZodString>;
80
+ provider: z.ZodString;
81
+ email: z.ZodOptional<z.ZodString>;
82
+ phone_number: z.ZodOptional<z.ZodString>;
76
83
  connection: z.ZodString;
77
- username: z.ZodOptional<z.ZodString>;
78
84
  given_name: z.ZodOptional<z.ZodString>;
79
- phone_number: z.ZodOptional<z.ZodString>;
80
85
  family_name: z.ZodOptional<z.ZodString>;
81
86
  profileData: z.ZodOptional<z.ZodString>;
82
87
  nickname: z.ZodOptional<z.ZodString>;
@@ -91,15 +96,7 @@ export declare const sqlUserSchema: z.ZodObject<{
91
96
  birthdate: z.ZodOptional<z.ZodString>;
92
97
  zoneinfo: z.ZodOptional<z.ZodString>;
93
98
  verify_email: z.ZodOptional<z.ZodBoolean>;
94
- last_ip: z.ZodOptional<z.ZodString>;
95
- last_login: z.ZodOptional<z.ZodString>;
96
99
  registration_completed_at: z.ZodOptional<z.ZodString>;
97
- created_at: z.ZodString;
98
- updated_at: z.ZodString;
99
- user_id: z.ZodString;
100
- provider: z.ZodString;
101
- email: z.ZodOptional<z.ZodString>;
102
- login_count: z.ZodDefault<z.ZodNumber>;
103
100
  identities: z.ZodOptional<z.ZodArray<z.ZodObject<{
104
101
  connection: z.ZodString;
105
102
  user_id: z.ZodString;
@@ -124,6 +121,7 @@ export declare const sqlUserSchema: z.ZodObject<{
124
121
  family_name: z.ZodOptional<z.ZodString>;
125
122
  }, z.core.$catchall<z.ZodAny>>>;
126
123
  }, z.core.$strip>>>;
124
+ login_count: z.ZodOptional<z.ZodNumber>;
127
125
  email_verified: z.ZodNumber;
128
126
  phone_verified: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
129
127
  is_social: z.ZodNumber;
@@ -941,5 +939,45 @@ export interface Database {
941
939
  created_at: string;
942
940
  updated_at: string;
943
941
  };
942
+ tenant_operations: {
943
+ id: string;
944
+ tenant_id: string | null;
945
+ rollout_id: string | null;
946
+ kind: string;
947
+ status: string;
948
+ current_step: string | null;
949
+ engine: string;
950
+ engine_instance_id: string | null;
951
+ target_worker_version: string | null;
952
+ target_database_version: string | null;
953
+ error: string | null;
954
+ initiated_by: string | null;
955
+ created_at: string;
956
+ updated_at: string;
957
+ finished_at: string | null;
958
+ };
959
+ tenant_operation_events: {
960
+ id: string;
961
+ operation_id: string;
962
+ step: string;
963
+ outcome: string;
964
+ detail: string | null;
965
+ attempt: number;
966
+ created_at: string;
967
+ };
968
+ rollouts: {
969
+ id: string;
970
+ kind: string;
971
+ status: string;
972
+ target_worker_version: string | null;
973
+ target_database_version: string | null;
974
+ wave_size: number;
975
+ canary_tenant_ids: string | null;
976
+ filter: string | null;
977
+ initiated_by: string | null;
978
+ created_at: string;
979
+ updated_at: string;
980
+ finished_at: string | null;
981
+ };
944
982
  }
945
983
  export {};
@@ -1,4 +1,10 @@
1
1
  import { Kysely, SelectQueryBuilder } from "kysely";
2
2
  import { Database } from "../db";
3
+ export type CoalescedNumericField = {
4
+ column: string;
5
+ defaultValue: number;
6
+ };
7
+ export type FieldMapping = string | CoalescedNumericField;
8
+ export declare function coalescedRef(field: CoalescedNumericField): import("kysely").RawBuilder<unknown>;
3
9
  export declare function sanitizeLuceneQuery(query: string, allowedFields: string[]): string;
4
- export declare function luceneFilter<TB extends keyof Database>(db: Kysely<Database>, qb: SelectQueryBuilder<Database, TB, {}>, query: string, searchableColumns: string[], likeFields?: string[]): SelectQueryBuilder<Database, TB, {}>;
10
+ export declare function luceneFilter<DB, TB extends keyof DB, O>(db: Kysely<Database>, qb: SelectQueryBuilder<DB, TB, O>, query: string, searchableColumns: string[], likeFields?: string[], fieldMap?: Record<string, FieldMapping>): SelectQueryBuilder<DB, TB, O>;
@@ -0,0 +1,4 @@
1
+ import { Kysely } from "kysely";
2
+ import { RolloutsAdapter } from "@authhero/adapter-interfaces";
3
+ import { Database } from "../db";
4
+ export declare function createRolloutsAdapter(db: Kysely<Database>): RolloutsAdapter;
@@ -0,0 +1,4 @@
1
+ import { Kysely } from "kysely";
2
+ import { TenantOperationEventsAdapter } from "@authhero/adapter-interfaces";
3
+ import { Database } from "../db";
4
+ export declare function createTenantOperationEventsAdapter(db: Kysely<Database>): TenantOperationEventsAdapter;
@@ -0,0 +1,4 @@
1
+ import { Kysely } from "kysely";
2
+ import { TenantOperationsAdapter } from "@authhero/adapter-interfaces";
3
+ import { Database } from "../db";
4
+ export declare function createTenantOperationsAdapter(db: Kysely<Database>): TenantOperationsAdapter;
@@ -1,4 +1,4 @@
1
- import { PostUsersBody } from "@authhero/adapter-interfaces";
1
+ import { PostUsersBody, User } 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>) => 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">>) => Promise<boolean>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Lexicographically sortable id that is strictly increasing within a
3
+ * process, even for ids generated in the same millisecond (a per-ms
4
+ * sequence follows the time component). Used for append-only logs where
5
+ * insertion order must survive an `ORDER BY id` tiebreak — `created_at`
6
+ * only has millisecond precision.
7
+ */
8
+ export declare function monotonicId(): string;