@authhero/drizzle 0.53.8 → 0.54.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.
@@ -5,51 +5,9 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "6",
8
- "when": 1778321558011,
9
- "tag": "0000_sloppy_forge",
10
- "breakpoints": true
11
- },
12
- {
13
- "idx": 1,
14
- "version": "6",
15
- "when": 1778477498497,
16
- "tag": "0001_branding_dark_mode",
17
- "breakpoints": true
18
- },
19
- {
20
- "idx": 2,
21
- "version": "6",
22
- "when": 1778800000000,
23
- "tag": "0002_client_disable_sign_ups",
24
- "breakpoints": true
25
- },
26
- {
27
- "idx": 3,
28
- "version": "6",
29
- "when": 1778890000000,
30
- "tag": "0003_move_disable_signup_to_connection",
31
- "breakpoints": true
32
- },
33
- {
34
- "idx": 4,
35
- "version": "6",
36
- "when": 1779000000000,
37
- "tag": "0004_proxy_routes",
38
- "breakpoints": true
39
- },
40
- {
41
- "idx": 5,
42
- "version": "6",
43
- "when": 1779200000000,
44
- "tag": "0005_proxy_routes_v2",
45
- "breakpoints": true
46
- },
47
- {
48
- "idx": 6,
49
- "version": "6",
50
- "when": 1780000000000,
51
- "tag": "0006_tenant_deployment_fields",
8
+ "when": 1781946733503,
9
+ "tag": "0000_init",
52
10
  "breakpoints": true
53
11
  }
54
12
  ]
55
- }
13
+ }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "0.53.8",
14
+ "version": "0.54.0",
15
15
  "files": [
16
16
  "dist",
17
17
  "src/schema",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "drizzle-orm": "^0.44.2",
36
36
  "nanoid": "^5.1.11",
37
- "@authhero/proxy": "0.7.1",
38
- "@authhero/adapter-interfaces": "3.1.1"
37
+ "@authhero/adapter-interfaces": "3.1.1",
38
+ "@authhero/proxy": "0.7.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@hono/zod-openapi": "^1.4.0",
@@ -0,0 +1,99 @@
1
+ import {
2
+ sqliteTable,
3
+ text,
4
+ integer,
5
+ primaryKey,
6
+ index,
7
+ uniqueIndex,
8
+ } from "drizzle-orm/sqlite-core";
9
+ import { tenants } from "./tenants";
10
+
11
+ // Mirrors the kysely `actions` table. Dates are stored as epoch-millisecond
12
+ // integers (`_ts` suffix) and surfaced as ISO strings by the adapter, matching
13
+ // the kysely backend. JSON-valued columns (secrets/dependencies/
14
+ // supported_triggers) are stored as serialized text.
15
+ export const actions = sqliteTable(
16
+ "actions",
17
+ {
18
+ id: text("id", { length: 255 }).notNull(),
19
+ tenant_id: text("tenant_id", { length: 191 })
20
+ .notNull()
21
+ .references(() => tenants.id, { onDelete: "cascade" }),
22
+ name: text("name", { length: 255 }).notNull(),
23
+ code: text("code").notNull(),
24
+ runtime: text("runtime", { length: 50 }),
25
+ status: text("status", { length: 16 }),
26
+ secrets: text("secrets"),
27
+ dependencies: text("dependencies"),
28
+ supported_triggers: text("supported_triggers"),
29
+ deployed_at_ts: integer("deployed_at_ts"),
30
+ is_system: integer("is_system"),
31
+ inherit: integer("inherit"),
32
+ created_at_ts: integer("created_at_ts").notNull(),
33
+ updated_at_ts: integer("updated_at_ts").notNull(),
34
+ },
35
+ (table) => [
36
+ primaryKey({ columns: [table.tenant_id, table.id], name: "actions_pk" }),
37
+ index("idx_actions_tenant_id").on(table.tenant_id),
38
+ index("idx_actions_name").on(table.tenant_id, table.name),
39
+ ],
40
+ );
41
+
42
+ export const actionVersions = sqliteTable(
43
+ "action_versions",
44
+ {
45
+ id: text("id", { length: 255 }).notNull(),
46
+ tenant_id: text("tenant_id", { length: 191 })
47
+ .notNull()
48
+ .references(() => tenants.id, { onDelete: "cascade" }),
49
+ action_id: text("action_id", { length: 255 }).notNull(),
50
+ number: integer("number").notNull(),
51
+ code: text("code").notNull(),
52
+ runtime: text("runtime", { length: 50 }),
53
+ secrets: text("secrets"),
54
+ dependencies: text("dependencies"),
55
+ supported_triggers: text("supported_triggers"),
56
+ deployed: integer("deployed").notNull(),
57
+ created_at_ts: integer("created_at_ts").notNull(),
58
+ updated_at_ts: integer("updated_at_ts").notNull(),
59
+ },
60
+ (table) => [
61
+ primaryKey({
62
+ columns: [table.tenant_id, table.id],
63
+ name: "action_versions_pk",
64
+ }),
65
+ // Serializes concurrent creates and enforces sequential version numbers
66
+ // per action, mirroring the kysely unique index.
67
+ uniqueIndex("uq_action_versions_number").on(
68
+ table.tenant_id,
69
+ table.action_id,
70
+ table.number,
71
+ ),
72
+ index("idx_action_versions_action_id").on(
73
+ table.tenant_id,
74
+ table.action_id,
75
+ ),
76
+ ],
77
+ );
78
+
79
+ export const actionExecutions = sqliteTable(
80
+ "action_executions",
81
+ {
82
+ id: text("id", { length: 255 }).notNull(),
83
+ tenant_id: text("tenant_id", { length: 191 })
84
+ .notNull()
85
+ .references(() => tenants.id, { onDelete: "cascade" }),
86
+ trigger_id: text("trigger_id", { length: 255 }).notNull(),
87
+ status: text("status", { length: 32 }).notNull(),
88
+ results: text("results").notNull(),
89
+ logs: text("logs"),
90
+ created_at_ts: integer("created_at_ts").notNull(),
91
+ updated_at_ts: integer("updated_at_ts").notNull(),
92
+ },
93
+ (table) => [
94
+ primaryKey({
95
+ columns: [table.tenant_id, table.id],
96
+ name: "action_executions_pk",
97
+ }),
98
+ ],
99
+ );
@@ -11,6 +11,9 @@
11
11
  // Tenants
12
12
  export * from "./tenants";
13
13
 
14
+ // Actions (actions, versions, executions)
15
+ export * from "./actions";
16
+
14
17
  // Users & Authentication
15
18
  export * from "./users";
16
19
  export * from "./sessions";
@@ -1 +0,0 @@
1
- ALTER TABLE `branding` ADD `dark_mode` text(8);
@@ -1,4 +0,0 @@
1
- ALTER TABLE `clients` ADD `disable_sign_ups` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
2
- ALTER TABLE `clients` ADD `hide_sign_up_disabled_error` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
3
- UPDATE `clients` SET `disable_sign_ups` = 1, `client_metadata` = json_remove(`client_metadata`, '$.disable_sign_ups') WHERE json_extract(`client_metadata`, '$.disable_sign_ups') = 'true';--> statement-breakpoint
4
- UPDATE `clients` SET `client_metadata` = json_remove(`client_metadata`, '$.disable_sign_ups') WHERE json_extract(`client_metadata`, '$.disable_sign_ups') IS NOT NULL;
@@ -1,17 +0,0 @@
1
- -- Backfill: for every client with disable_sign_ups=1, set the new
2
- -- connection-level disable_signup=true on every connection whose id appears
3
- -- in the client's `connections` JSON array. After the backfill, drop the
4
- -- client column. See packages/kysely/migrate/migrations/2026-05-13T10:00:00_move_disable_signup_to_connection.ts
5
- -- for the matching kysely migration and rationale.
6
-
7
- UPDATE `connections`
8
- SET `options` = json_set(coalesce(`options`, '{}'), '$.disable_signup', json('true'))
9
- WHERE EXISTS (
10
- SELECT 1
11
- FROM `clients`, json_each(`clients`.`connections`)
12
- WHERE `clients`.`tenant_id` = `connections`.`tenant_id`
13
- AND `clients`.`disable_sign_ups` = 1
14
- AND json_each.value = `connections`.`id`
15
- );
16
- --> statement-breakpoint
17
- ALTER TABLE `clients` DROP COLUMN `disable_sign_ups`;
@@ -1,16 +0,0 @@
1
- CREATE TABLE `proxy_routes` (
2
- `id` text(64) PRIMARY KEY NOT NULL,
3
- `tenant_id` text(255) NOT NULL,
4
- `custom_domain_id` text(256) NOT NULL,
5
- `priority` integer DEFAULT 100 NOT NULL,
6
- `path_pattern` text(512) NOT NULL,
7
- `upstream_type` text(32) NOT NULL,
8
- `upstream_url` text(2048) NOT NULL,
9
- `preserve_host` integer DEFAULT 0 NOT NULL,
10
- `middleware` text(8192) DEFAULT '[]' NOT NULL,
11
- `created_at` text(35) NOT NULL,
12
- `updated_at` text(35) NOT NULL
13
- );
14
- --> statement-breakpoint
15
- CREATE INDEX `proxy_routes_tenant_id_idx` ON `proxy_routes` (`tenant_id`);--> statement-breakpoint
16
- CREATE INDEX `proxy_routes_custom_domain_id_idx` ON `proxy_routes` (`custom_domain_id`);
@@ -1,62 +0,0 @@
1
- -- Migrate proxy_routes to the v2 schema (match + handlers).
2
- -- Add the new columns, backfill via JSON functions, then drop the old ones.
3
-
4
- ALTER TABLE `proxy_routes` ADD COLUMN `match` text(2048) DEFAULT '{"path":"/*"}' NOT NULL;
5
- --> statement-breakpoint
6
- ALTER TABLE `proxy_routes` ADD COLUMN `handlers` text(16384) DEFAULT '[]' NOT NULL;
7
- --> statement-breakpoint
8
- UPDATE `proxy_routes`
9
- SET
10
- `match` = json_object('path', `path_pattern`),
11
- `handlers` = (
12
- SELECT json_group_array(
13
- CASE
14
- WHEN json_extract(value, '$.type') IS NOT NULL THEN
15
- json_object(
16
- 'type', json_extract(value, '$.type'),
17
- 'options', (
18
- SELECT json_group_object(key, val)
19
- FROM (
20
- SELECT key, value AS val
21
- FROM json_each(value)
22
- WHERE key != 'type'
23
- )
24
- )
25
- )
26
- ELSE value
27
- END
28
- )
29
- FROM json_each(
30
- CASE WHEN json_valid(`middleware`) THEN `middleware` ELSE '[]' END
31
- )
32
- ) || ''
33
- ;
34
- --> statement-breakpoint
35
- -- json_group_array returns NULL for an empty array; reset to []
36
- UPDATE `proxy_routes` SET `handlers` = '[]' WHERE `handlers` IS NULL OR `handlers` = '';
37
- --> statement-breakpoint
38
- -- Append the terminal handler derived from upstream_type/upstream_url/preserve_host.
39
- UPDATE `proxy_routes`
40
- SET `handlers` = json_insert(
41
- `handlers`,
42
- '$[#]',
43
- json(
44
- json_object(
45
- 'type', CASE WHEN `upstream_type` = 'authhero' THEN 'http' ELSE `upstream_type` END,
46
- 'options', json_object(
47
- 'upstream_url', `upstream_url`,
48
- 'preserve_host', `preserve_host` != 0
49
- )
50
- )
51
- )
52
- );
53
- --> statement-breakpoint
54
- ALTER TABLE `proxy_routes` DROP COLUMN `path_pattern`;
55
- --> statement-breakpoint
56
- ALTER TABLE `proxy_routes` DROP COLUMN `upstream_type`;
57
- --> statement-breakpoint
58
- ALTER TABLE `proxy_routes` DROP COLUMN `upstream_url`;
59
- --> statement-breakpoint
60
- ALTER TABLE `proxy_routes` DROP COLUMN `preserve_host`;
61
- --> statement-breakpoint
62
- ALTER TABLE `proxy_routes` DROP COLUMN `middleware`;
@@ -1,9 +0,0 @@
1
- ALTER TABLE `tenants` ADD `deployment_type` text(16) DEFAULT 'shared' NOT NULL;--> statement-breakpoint
2
- ALTER TABLE `tenants` ADD `provisioning_state` text(16) DEFAULT 'ready' NOT NULL;--> statement-breakpoint
3
- ALTER TABLE `tenants` ADD `provisioning_error` text;--> statement-breakpoint
4
- ALTER TABLE `tenants` ADD `provisioning_state_changed_at` text(35);--> statement-breakpoint
5
- ALTER TABLE `tenants` ADD `bundle_configuration` text(64);--> statement-breakpoint
6
- ALTER TABLE `tenants` ADD `worker_version` text(64);--> statement-breakpoint
7
- ALTER TABLE `tenants` ADD `worker_script_name` text(255);--> statement-breakpoint
8
- ALTER TABLE `tenants` ADD `storage_kind` text(32);--> statement-breakpoint
9
- ALTER TABLE `tenants` ADD `d1_database_id` text(64);