@authhero/kysely-adapter 10.68.0 → 10.69.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/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # @authhero/kysely-adater
1
+ # @authhero/kysely-adapter
2
2
 
3
- A kysely-based adapter for connecting AuthHero to SQLite, postgres and MySQL.
3
+ A Kysely-based adapter for connecting AuthHero to SQLite, PostgreSQL, and MySQL.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @authhero/kysely-adapter
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { Kysely } from "kysely";
15
+ import { createAdapters, migrateToLatest } from "@authhero/kysely-adapter";
16
+
17
+ // Create your Kysely instance with your preferred dialect
18
+ const db = new Kysely<Database>({
19
+ dialect: yourDialect,
20
+ });
21
+
22
+ // Run migrations
23
+ await migrateToLatest(db);
24
+
25
+ // Create adapters
26
+ const adapters = createAdapters(db);
27
+ ```
28
+
29
+ ## Exporting SQL for D1
30
+
31
+ If you're using Cloudflare D1 and prefer to use D1's native migration system instead of running Kysely migrations at runtime, you can export the migrations as raw SQL files:
32
+
33
+ ```bash
34
+ # Generate individual D1 migration files
35
+ pnpm run export-sql:d1
36
+
37
+ # Generate combined SQL file
38
+ pnpm run export-sql:combined
39
+
40
+ # Output to stdout
41
+ pnpm run export-sql
42
+ ```
43
+
44
+ The `export-sql:d1` command generates numbered SQL files in the `migrations/` directory that are compatible with `wrangler d1 migrations apply`.
45
+
46
+ ## Supported Databases
47
+
48
+ - SQLite (including Cloudflare D1)
49
+ - PostgreSQL
50
+ - MySQL
@@ -139,6 +139,50 @@ declare const flowInsertSchema: z.ZodObject<{
139
139
  alias?: string | undefined;
140
140
  allow_failure?: boolean | undefined;
141
141
  mask_output?: boolean | undefined;
142
+ }>,
143
+ z.ZodObject<{
144
+ id: z.ZodString;
145
+ alias: z.ZodOptional<z.ZodString>;
146
+ type: z.ZodLiteral<"REDIRECT">;
147
+ action: z.ZodLiteral<"REDIRECT_USER">;
148
+ allow_failure: z.ZodOptional<z.ZodBoolean>;
149
+ mask_output: z.ZodOptional<z.ZodBoolean>;
150
+ params: z.ZodObject<{
151
+ target: z.ZodEnum<[
152
+ "change-email",
153
+ "account",
154
+ "custom"
155
+ ]>;
156
+ custom_url: z.ZodOptional<z.ZodString>;
157
+ }, "strip", z.ZodTypeAny, {
158
+ target: "custom" | "change-email" | "account";
159
+ custom_url?: string | undefined;
160
+ }, {
161
+ target: "custom" | "change-email" | "account";
162
+ custom_url?: string | undefined;
163
+ }>;
164
+ }, "strip", z.ZodTypeAny, {
165
+ params: {
166
+ target: "custom" | "change-email" | "account";
167
+ custom_url?: string | undefined;
168
+ };
169
+ type: "REDIRECT";
170
+ id: string;
171
+ action: "REDIRECT_USER";
172
+ alias?: string | undefined;
173
+ allow_failure?: boolean | undefined;
174
+ mask_output?: boolean | undefined;
175
+ }, {
176
+ params: {
177
+ target: "custom" | "change-email" | "account";
178
+ custom_url?: string | undefined;
179
+ };
180
+ type: "REDIRECT";
181
+ id: string;
182
+ action: "REDIRECT_USER";
183
+ alias?: string | undefined;
184
+ allow_failure?: boolean | undefined;
185
+ mask_output?: boolean | undefined;
142
186
  }>
143
187
  ]>, "many">>>;
144
188
  }, "strip", z.ZodTypeAny, {
@@ -173,6 +217,17 @@ declare const flowInsertSchema: z.ZodObject<{
173
217
  alias?: string | undefined;
174
218
  allow_failure?: boolean | undefined;
175
219
  mask_output?: boolean | undefined;
220
+ } | {
221
+ params: {
222
+ target: "custom" | "change-email" | "account";
223
+ custom_url?: string | undefined;
224
+ };
225
+ type: "REDIRECT";
226
+ id: string;
227
+ action: "REDIRECT_USER";
228
+ alias?: string | undefined;
229
+ allow_failure?: boolean | undefined;
230
+ mask_output?: boolean | undefined;
176
231
  })[];
177
232
  }, {
178
233
  name: string;
@@ -206,6 +261,17 @@ declare const flowInsertSchema: z.ZodObject<{
206
261
  alias?: string | undefined;
207
262
  allow_failure?: boolean | undefined;
208
263
  mask_output?: boolean | undefined;
264
+ } | {
265
+ params: {
266
+ target: "custom" | "change-email" | "account";
267
+ custom_url?: string | undefined;
268
+ };
269
+ type: "REDIRECT";
270
+ id: string;
271
+ action: "REDIRECT_USER";
272
+ alias?: string | undefined;
273
+ allow_failure?: boolean | undefined;
274
+ mask_output?: boolean | undefined;
209
275
  })[] | undefined;
210
276
  }>;
211
277
  export type FlowInsert = z.infer<typeof flowInsertSchema>;
@@ -345,6 +411,50 @@ declare const flowSchema: z.ZodObject<{
345
411
  alias?: string | undefined;
346
412
  allow_failure?: boolean | undefined;
347
413
  mask_output?: boolean | undefined;
414
+ }>,
415
+ z.ZodObject<{
416
+ id: z.ZodString;
417
+ alias: z.ZodOptional<z.ZodString>;
418
+ type: z.ZodLiteral<"REDIRECT">;
419
+ action: z.ZodLiteral<"REDIRECT_USER">;
420
+ allow_failure: z.ZodOptional<z.ZodBoolean>;
421
+ mask_output: z.ZodOptional<z.ZodBoolean>;
422
+ params: z.ZodObject<{
423
+ target: z.ZodEnum<[
424
+ "change-email",
425
+ "account",
426
+ "custom"
427
+ ]>;
428
+ custom_url: z.ZodOptional<z.ZodString>;
429
+ }, "strip", z.ZodTypeAny, {
430
+ target: "custom" | "change-email" | "account";
431
+ custom_url?: string | undefined;
432
+ }, {
433
+ target: "custom" | "change-email" | "account";
434
+ custom_url?: string | undefined;
435
+ }>;
436
+ }, "strip", z.ZodTypeAny, {
437
+ params: {
438
+ target: "custom" | "change-email" | "account";
439
+ custom_url?: string | undefined;
440
+ };
441
+ type: "REDIRECT";
442
+ id: string;
443
+ action: "REDIRECT_USER";
444
+ alias?: string | undefined;
445
+ allow_failure?: boolean | undefined;
446
+ mask_output?: boolean | undefined;
447
+ }, {
448
+ params: {
449
+ target: "custom" | "change-email" | "account";
450
+ custom_url?: string | undefined;
451
+ };
452
+ type: "REDIRECT";
453
+ id: string;
454
+ action: "REDIRECT_USER";
455
+ alias?: string | undefined;
456
+ allow_failure?: boolean | undefined;
457
+ mask_output?: boolean | undefined;
348
458
  }>
349
459
  ]>, "many">>>;
350
460
  } & {
@@ -386,6 +496,17 @@ declare const flowSchema: z.ZodObject<{
386
496
  alias?: string | undefined;
387
497
  allow_failure?: boolean | undefined;
388
498
  mask_output?: boolean | undefined;
499
+ } | {
500
+ params: {
501
+ target: "custom" | "change-email" | "account";
502
+ custom_url?: string | undefined;
503
+ };
504
+ type: "REDIRECT";
505
+ id: string;
506
+ action: "REDIRECT_USER";
507
+ alias?: string | undefined;
508
+ allow_failure?: boolean | undefined;
509
+ mask_output?: boolean | undefined;
389
510
  })[];
390
511
  }, {
391
512
  created_at: string;
@@ -422,6 +543,17 @@ declare const flowSchema: z.ZodObject<{
422
543
  alias?: string | undefined;
423
544
  allow_failure?: boolean | undefined;
424
545
  mask_output?: boolean | undefined;
546
+ } | {
547
+ params: {
548
+ target: "custom" | "change-email" | "account";
549
+ custom_url?: string | undefined;
550
+ };
551
+ type: "REDIRECT";
552
+ id: string;
553
+ action: "REDIRECT_USER";
554
+ alias?: string | undefined;
555
+ allow_failure?: boolean | undefined;
556
+ mask_output?: boolean | undefined;
425
557
  })[] | undefined;
426
558
  }>;
427
559
  export type Flow = z.infer<typeof flowSchema>;
@@ -3781,11 +3913,11 @@ declare const formInsertSchema: z.ZodObject<{
3781
3913
  delay: z.ZodOptional<z.ZodNumber>;
3782
3914
  target: z.ZodOptional<z.ZodString>;
3783
3915
  }, "strip", z.ZodTypeAny, {
3784
- delay?: number | undefined;
3785
3916
  target?: string | undefined;
3786
- }, {
3787
3917
  delay?: number | undefined;
3918
+ }, {
3788
3919
  target?: string | undefined;
3920
+ delay?: number | undefined;
3789
3921
  }>>;
3790
3922
  after_submit: z.ZodOptional<z.ZodObject<{
3791
3923
  flow_id: z.ZodOptional<z.ZodString>;
@@ -3812,8 +3944,8 @@ declare const formInsertSchema: z.ZodObject<{
3812
3944
  } | undefined;
3813
3945
  resume_flow?: boolean | undefined;
3814
3946
  redirection?: {
3815
- delay?: number | undefined;
3816
3947
  target?: string | undefined;
3948
+ delay?: number | undefined;
3817
3949
  } | undefined;
3818
3950
  after_submit?: {
3819
3951
  flow_id?: string | undefined;
@@ -3825,8 +3957,8 @@ declare const formInsertSchema: z.ZodObject<{
3825
3957
  } | undefined;
3826
3958
  resume_flow?: boolean | undefined;
3827
3959
  redirection?: {
3828
- delay?: number | undefined;
3829
3960
  target?: string | undefined;
3961
+ delay?: number | undefined;
3830
3962
  } | undefined;
3831
3963
  after_submit?: {
3832
3964
  flow_id?: string | undefined;
@@ -3985,8 +4117,8 @@ declare const formInsertSchema: z.ZodObject<{
3985
4117
  } | undefined;
3986
4118
  resume_flow?: boolean | undefined;
3987
4119
  redirection?: {
3988
- delay?: number | undefined;
3989
4120
  target?: string | undefined;
4121
+ delay?: number | undefined;
3990
4122
  } | undefined;
3991
4123
  after_submit?: {
3992
4124
  flow_id?: string | undefined;
@@ -4143,8 +4275,8 @@ declare const formInsertSchema: z.ZodObject<{
4143
4275
  } | undefined;
4144
4276
  resume_flow?: boolean | undefined;
4145
4277
  redirection?: {
4146
- delay?: number | undefined;
4147
4278
  target?: string | undefined;
4279
+ delay?: number | undefined;
4148
4280
  } | undefined;
4149
4281
  after_submit?: {
4150
4282
  flow_id?: string | undefined;
@@ -5013,11 +5145,11 @@ declare const formSchema: z.ZodObject<{
5013
5145
  delay: z.ZodOptional<z.ZodNumber>;
5014
5146
  target: z.ZodOptional<z.ZodString>;
5015
5147
  }, "strip", z.ZodTypeAny, {
5016
- delay?: number | undefined;
5017
5148
  target?: string | undefined;
5018
- }, {
5019
5149
  delay?: number | undefined;
5150
+ }, {
5020
5151
  target?: string | undefined;
5152
+ delay?: number | undefined;
5021
5153
  }>>;
5022
5154
  after_submit: z.ZodOptional<z.ZodObject<{
5023
5155
  flow_id: z.ZodOptional<z.ZodString>;
@@ -5044,8 +5176,8 @@ declare const formSchema: z.ZodObject<{
5044
5176
  } | undefined;
5045
5177
  resume_flow?: boolean | undefined;
5046
5178
  redirection?: {
5047
- delay?: number | undefined;
5048
5179
  target?: string | undefined;
5180
+ delay?: number | undefined;
5049
5181
  } | undefined;
5050
5182
  after_submit?: {
5051
5183
  flow_id?: string | undefined;
@@ -5057,8 +5189,8 @@ declare const formSchema: z.ZodObject<{
5057
5189
  } | undefined;
5058
5190
  resume_flow?: boolean | undefined;
5059
5191
  redirection?: {
5060
- delay?: number | undefined;
5061
5192
  target?: string | undefined;
5193
+ delay?: number | undefined;
5062
5194
  } | undefined;
5063
5195
  after_submit?: {
5064
5196
  flow_id?: string | undefined;
@@ -5222,8 +5354,8 @@ declare const formSchema: z.ZodObject<{
5222
5354
  } | undefined;
5223
5355
  resume_flow?: boolean | undefined;
5224
5356
  redirection?: {
5225
- delay?: number | undefined;
5226
5357
  target?: string | undefined;
5358
+ delay?: number | undefined;
5227
5359
  } | undefined;
5228
5360
  after_submit?: {
5229
5361
  flow_id?: string | undefined;
@@ -5383,8 +5515,8 @@ declare const formSchema: z.ZodObject<{
5383
5515
  } | undefined;
5384
5516
  resume_flow?: boolean | undefined;
5385
5517
  redirection?: {
5386
- delay?: number | undefined;
5387
5518
  target?: string | undefined;
5519
+ delay?: number | undefined;
5388
5520
  } | undefined;
5389
5521
  after_submit?: {
5390
5522
  flow_id?: string | undefined;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "10.68.0",
14
+ "version": "10.69.0",
15
15
  "files": [
16
16
  "dist"
17
17
  ],
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "kysely": "^0.27.4",
44
44
  "nanoid": "^5.0.8",
45
- "@authhero/adapter-interfaces": "0.110.0"
45
+ "@authhero/adapter-interfaces": "0.111.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@hono/zod-openapi": "^0.19.2",
@@ -52,6 +52,10 @@
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",
55
- "test": "vitest run"
55
+ "test": "vitest run",
56
+ "export-sql": "npx tsx scripts/export-sql.ts",
57
+ "export-sql:d1": "npx tsx scripts/export-sql.ts --d1",
58
+ "export-sql:combined": "npx tsx scripts/export-sql.ts --split",
59
+ "export-sql:squash": "npx tsx scripts/export-sql.ts --squash"
56
60
  }
57
61
  }