@hollware/server 0.6.0 → 0.8.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/dist/{ceremonies-6mZ3u32c.mjs → ceremonies-D5dIEbha.mjs} +1 -1
- package/dist/index.d.mts +76 -3
- package/dist/index.mjs +564 -39
- package/dist/{store-CYMjP0iN.mjs → store-C2hiR0yd.mjs} +54 -6
- package/migrations/0011_structure.sql +20 -0
- package/migrations/0012_site_secrets.sql +12 -0
- package/migrations/meta/0011_snapshot.json +2532 -0
- package/migrations/meta/0012_snapshot.json +2615 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +3 -3
|
@@ -70,7 +70,7 @@ function id(prefix) {
|
|
|
70
70
|
return text("id").primaryKey().$defaultFn(() => newId(prefix));
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* The site a row belongs to: the site's key
|
|
73
|
+
* The site a row belongs to: the site's key, which is also the id of its
|
|
74
74
|
* row in `sites`. Every table but the deployment-wide ones carries it (ADR-006).
|
|
75
75
|
*/
|
|
76
76
|
function siteId() {
|
|
@@ -87,9 +87,21 @@ sqliteTable("_hollware_meta", {
|
|
|
87
87
|
key: text("key").primaryKey().notNull(),
|
|
88
88
|
value: text("value").notNull()
|
|
89
89
|
});
|
|
90
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The sites of the deployment, and their structure (ADR-033). The id is the site's key. Its
|
|
92
|
+
* definition is the JSON that `siteDefinitionData` of `@hollware/core` checks, and `version` moves
|
|
93
|
+
* with every change of it, which is what a Worker compares to know its copy is current. A row
|
|
94
|
+
* without a definition is a site the deployment does not serve yet: the CLI made it before its
|
|
95
|
+
* owner gave it one, or a 0.x deployment has not moved its config. A site in the trash has
|
|
96
|
+
* `deleted_at`, and is served no more. The columns came by `ADD COLUMN`, with no CHECK: a CHECK
|
|
97
|
+
* on them would rebuild the table, which D1 refuses while other tables point at it; the store
|
|
98
|
+
* writes only definitions it has checked.
|
|
99
|
+
*/
|
|
91
100
|
const sites = sqliteTable("sites", {
|
|
92
101
|
id: text("id").primaryKey(),
|
|
102
|
+
definition: text("definition"),
|
|
103
|
+
version: integer("version").notNull().default(0),
|
|
104
|
+
deletedAt: text("deleted_at"),
|
|
93
105
|
...timestamps()
|
|
94
106
|
});
|
|
95
107
|
/**
|
|
@@ -599,10 +611,46 @@ const entryEmbeddings = sqliteTable("entry_embeddings", {
|
|
|
599
611
|
}),
|
|
600
612
|
check("entry_embeddings_pieces", sql`${t.pieces} >= 1`)
|
|
601
613
|
]);
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
614
|
+
sqliteTable("site_changes", {
|
|
615
|
+
id: id("sit"),
|
|
616
|
+
siteId: siteId(),
|
|
617
|
+
version: integer("version").notNull(),
|
|
618
|
+
actorUserId: text("actor_user_id"),
|
|
619
|
+
/** What the client that made it said about itself, as JSON, or `null`. */
|
|
620
|
+
actorMeta: text("actor_meta"),
|
|
621
|
+
before: text("before"),
|
|
622
|
+
after: text("after"),
|
|
623
|
+
...timestamps()
|
|
624
|
+
}, (t) => [
|
|
625
|
+
unique("site_changes_id_site").on(t.id, t.siteId),
|
|
626
|
+
unique("site_changes_version").on(t.siteId, t.version),
|
|
627
|
+
foreignKey({
|
|
628
|
+
name: "site_changes_site",
|
|
629
|
+
columns: [t.siteId],
|
|
630
|
+
foreignColumns: [sites.id]
|
|
631
|
+
}),
|
|
632
|
+
foreignKey({
|
|
633
|
+
name: "site_changes_user",
|
|
634
|
+
columns: [t.actorUserId],
|
|
635
|
+
foreignColumns: [users.id]
|
|
636
|
+
}),
|
|
637
|
+
check("site_changes_json", sql`(${t.before} IS NULL OR json_valid(${t.before})) AND (${t.after} IS NULL OR json_valid(${t.after})) AND (${t.actorMeta} IS NULL OR json_valid(${t.actorMeta}))`)
|
|
638
|
+
]);
|
|
639
|
+
sqliteTable("site_secrets", {
|
|
640
|
+
id: id("sec"),
|
|
641
|
+
siteId: siteId(),
|
|
642
|
+
name: text("name").notNull(),
|
|
643
|
+
sealed: text("sealed").notNull(),
|
|
644
|
+
...timestamps()
|
|
645
|
+
}, (t) => [
|
|
646
|
+
unique("site_secrets_id_site").on(t.id, t.siteId),
|
|
647
|
+
unique("site_secrets_name").on(t.siteId, t.name),
|
|
648
|
+
foreignKey({
|
|
649
|
+
name: "site_secrets_site",
|
|
650
|
+
columns: [t.siteId],
|
|
651
|
+
foreignColumns: [sites.id]
|
|
652
|
+
})
|
|
653
|
+
]);
|
|
606
654
|
const reviewComments = sqliteTable("review_comments", {
|
|
607
655
|
id: id("rvc"),
|
|
608
656
|
siteId: siteId(),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
CREATE TABLE `site_changes` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`site_id` text NOT NULL,
|
|
4
|
+
`version` integer NOT NULL,
|
|
5
|
+
`actor_user_id` text,
|
|
6
|
+
`actor_meta` text,
|
|
7
|
+
`before` text,
|
|
8
|
+
`after` text,
|
|
9
|
+
`created_at` text NOT NULL,
|
|
10
|
+
`updated_at` text NOT NULL,
|
|
11
|
+
FOREIGN KEY (`site_id`) REFERENCES `sites`(`id`) ON UPDATE no action ON DELETE no action,
|
|
12
|
+
FOREIGN KEY (`actor_user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
|
|
13
|
+
CONSTRAINT "site_changes_json" CHECK(("site_changes"."before" IS NULL OR json_valid("site_changes"."before")) AND ("site_changes"."after" IS NULL OR json_valid("site_changes"."after")) AND ("site_changes"."actor_meta" IS NULL OR json_valid("site_changes"."actor_meta")))
|
|
14
|
+
);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
CREATE UNIQUE INDEX `site_changes_id_site` ON `site_changes` (`id`,`site_id`);--> statement-breakpoint
|
|
17
|
+
CREATE UNIQUE INDEX `site_changes_version` ON `site_changes` (`site_id`,`version`);--> statement-breakpoint
|
|
18
|
+
ALTER TABLE `sites` ADD `definition` text;--> statement-breakpoint
|
|
19
|
+
ALTER TABLE `sites` ADD `version` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
|
20
|
+
ALTER TABLE `sites` ADD `deleted_at` text;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
CREATE TABLE `site_secrets` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`site_id` text NOT NULL,
|
|
4
|
+
`name` text NOT NULL,
|
|
5
|
+
`sealed` text NOT NULL,
|
|
6
|
+
`created_at` text NOT NULL,
|
|
7
|
+
`updated_at` text NOT NULL,
|
|
8
|
+
FOREIGN KEY (`site_id`) REFERENCES `sites`(`id`) ON UPDATE no action ON DELETE no action
|
|
9
|
+
);
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
CREATE UNIQUE INDEX `site_secrets_id_site` ON `site_secrets` (`id`,`site_id`);--> statement-breakpoint
|
|
12
|
+
CREATE UNIQUE INDEX `site_secrets_name` ON `site_secrets` (`site_id`,`name`);
|