@authhero/kysely-adapter 11.10.2 → 11.12.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,4 @@
1
+ import { Kysely } from "kysely";
2
+ import { Database } from "../../src/db";
3
+ export declare function up(db: Kysely<Database>): Promise<void>;
4
+ export declare function down(db: Kysely<Database>): Promise<void>;
@@ -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>;
@@ -174,6 +174,8 @@ import * as o075_create_grants from "./2026-06-04T11:00:00_create_grants";
174
174
  import * as o076_default_first_party_true from "./2026-06-04T11:01:00_default_first_party_true";
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
+ 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";
177
179
  declare const _default: {
178
180
  m1_init: typeof m1_init;
179
181
  m2_magicLink: typeof m2_magicLink;
@@ -351,5 +353,7 @@ declare const _default: {
351
353
  o076_default_first_party_true: typeof o076_default_first_party_true;
352
354
  o077_tenant_deployment_fields: typeof o077_tenant_deployment_fields;
353
355
  o078_tenant_database_version: typeof o078_tenant_database_version;
356
+ o079_user_activity_and_user_column_cleanup: typeof o079_user_activity_and_user_column_cleanup;
357
+ o080_drop_user_activity_columns_from_users: typeof o080_drop_user_activity_columns_from_users;
354
358
  };
355
359
  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;
@@ -856,6 +853,15 @@ export interface Database {
856
853
  prompt_settings: z.infer<typeof sqlPromptSettingSchema>;
857
854
  refresh_tokens: z.infer<typeof sqlRefreshTokensSchema>;
858
855
  users: z.infer<typeof sqlUserSchema>;
856
+ user_activity: {
857
+ tenant_id: string;
858
+ user_id: string;
859
+ last_login: string | null;
860
+ last_ip: string | null;
861
+ login_count: number;
862
+ failed_logins: string | null;
863
+ last_password_reset: string | null;
864
+ };
859
865
  sessions: z.infer<typeof sqlSessionSchema>;
860
866
  tenants: z.infer<typeof sqlTenantSchema>;
861
867
  themes: z.infer<typeof sqlThemeSchema>;
@@ -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 { UserActivityAdapter } from "@authhero/adapter-interfaces";
3
+ import { Database } from "../db";
4
+ export declare function createUserActivityAdapter(db: Kysely<Database>): UserActivityAdapter;
@@ -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>;