@authhero/drizzle 0.51.2 → 0.52.1
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/dist/drizzle-adapter.cjs +6 -6
- package/dist/drizzle-adapter.mjs +3361 -3182
- package/drizzle/0004_proxy_routes.sql +16 -0
- package/drizzle/0005_proxy_routes_v2.sql +62 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +3 -2
- package/src/schema/sqlite/index.ts +3 -0
- package/src/schema/sqlite/proxyRoutes.ts +19 -0
|
@@ -0,0 +1,16 @@
|
|
|
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`);
|
|
@@ -0,0 +1,62 @@
|
|
|
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`;
|
|
@@ -29,6 +29,20 @@
|
|
|
29
29
|
"when": 1778890000000,
|
|
30
30
|
"tag": "0003_move_disable_signup_to_connection",
|
|
31
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
|
|
32
46
|
}
|
|
33
47
|
]
|
|
34
48
|
}
|
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.
|
|
14
|
+
"version": "0.52.1",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"src/schema",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"drizzle-orm": "^0.44.2",
|
|
36
36
|
"nanoid": "^5.1.11",
|
|
37
|
-
"@authhero/adapter-interfaces": "2.
|
|
37
|
+
"@authhero/adapter-interfaces": "2.9.0",
|
|
38
|
+
"@authhero/proxy": "0.3.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@hono/zod-openapi": "^1.4.0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { sqliteTable, text, integer, index } from "drizzle-orm/sqlite-core";
|
|
2
|
+
|
|
3
|
+
export const proxyRoutes = sqliteTable(
|
|
4
|
+
"proxy_routes",
|
|
5
|
+
{
|
|
6
|
+
id: text("id", { length: 64 }).primaryKey(),
|
|
7
|
+
tenant_id: text("tenant_id", { length: 255 }).notNull(),
|
|
8
|
+
custom_domain_id: text("custom_domain_id", { length: 256 }).notNull(),
|
|
9
|
+
priority: integer("priority").notNull().default(100),
|
|
10
|
+
match: text("match", { length: 2048 }).notNull().default('{"path":"/*"}'),
|
|
11
|
+
handlers: text("handlers", { length: 16384 }).notNull().default("[]"),
|
|
12
|
+
created_at: text("created_at", { length: 35 }).notNull(),
|
|
13
|
+
updated_at: text("updated_at", { length: 35 }).notNull(),
|
|
14
|
+
},
|
|
15
|
+
(table) => [
|
|
16
|
+
index("proxy_routes_tenant_id_idx").on(table.tenant_id),
|
|
17
|
+
index("proxy_routes_custom_domain_id_idx").on(table.custom_domain_id),
|
|
18
|
+
],
|
|
19
|
+
);
|