@hollware/server 0.5.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-BM9G03lZ.mjs → ceremonies-D5dIEbha.mjs} +1 -1
- package/dist/index.d.mts +108 -3
- package/dist/index.mjs +715 -57
- package/dist/{store-DiS8UFI2.mjs → store-C2hiR0yd.mjs} +84 -3
- package/migrations/0010_review_comments.sql +17 -0
- package/migrations/0011_structure.sql +20 -0
- package/migrations/0012_site_secrets.sql +12 -0
- package/migrations/meta/0010_snapshot.json +2388 -0
- package/migrations/meta/0011_snapshot.json +2532 -0
- package/migrations/meta/0012_snapshot.json +2615 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +3 -2
|
@@ -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,6 +611,75 @@ const entryEmbeddings = sqliteTable("entry_embeddings", {
|
|
|
599
611
|
}),
|
|
600
612
|
check("entry_embeddings_pieces", sql`${t.pieces} >= 1`)
|
|
601
613
|
]);
|
|
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
|
+
]);
|
|
654
|
+
const reviewComments = sqliteTable("review_comments", {
|
|
655
|
+
id: id("rvc"),
|
|
656
|
+
siteId: siteId(),
|
|
657
|
+
reviewId: text("review_id").notNull(),
|
|
658
|
+
authorId: text("author_id").notNull(),
|
|
659
|
+
/** What the client that wrote it said about itself, as JSON, or `null`. */
|
|
660
|
+
authorMeta: text("author_meta"),
|
|
661
|
+
body: text("body").notNull(),
|
|
662
|
+
...timestamps()
|
|
663
|
+
}, (t) => [
|
|
664
|
+
unique("review_comments_id_site").on(t.id, t.siteId),
|
|
665
|
+
index("review_comments_review").on(t.siteId, t.reviewId, t.createdAt),
|
|
666
|
+
foreignKey({
|
|
667
|
+
name: "review_comments_site",
|
|
668
|
+
columns: [t.siteId],
|
|
669
|
+
foreignColumns: [sites.id]
|
|
670
|
+
}),
|
|
671
|
+
foreignKey({
|
|
672
|
+
name: "review_comments_review_fk",
|
|
673
|
+
columns: [t.reviewId, t.siteId],
|
|
674
|
+
foreignColumns: [reviews.id, reviews.siteId]
|
|
675
|
+
}),
|
|
676
|
+
foreignKey({
|
|
677
|
+
name: "review_comments_author",
|
|
678
|
+
columns: [t.authorId],
|
|
679
|
+
foreignColumns: [users.id]
|
|
680
|
+
}),
|
|
681
|
+
check("review_comments_body", sql`length(${t.body}) BETWEEN 1 AND 4000`)
|
|
682
|
+
]);
|
|
602
683
|
//#endregion
|
|
603
684
|
//#region src/identity/secrets.ts
|
|
604
685
|
/**
|
|
@@ -798,4 +879,4 @@ async function invitationById(db, id) {
|
|
|
798
879
|
};
|
|
799
880
|
}
|
|
800
881
|
//#endregion
|
|
801
|
-
export {
|
|
882
|
+
export { users as A, reviewComments as C, schedules as D, revisions as E, effectiveScopes as M, isRole as N, sites as O, publications as S, revisionTags as T, entries as _, findInvitation as a, members as b, invitationById as c, redeemInvitation as d, saveChallenge as f, deliveries as g, userHandle as h, createUser as i, ROLE_SCOPES as j, tokens as k, membershipsOf as l, touchPasskey as m, createInvitation as n, findPasskey as o, takeChallenge as p, createSession as r, findSession as s, addPasskey as t, passkeysOf as u, entryEmbeddings as v, reviews as w, outbox as x, invitations as y };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE `review_comments` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`site_id` text NOT NULL,
|
|
4
|
+
`review_id` text NOT NULL,
|
|
5
|
+
`author_id` text NOT NULL,
|
|
6
|
+
`author_meta` text,
|
|
7
|
+
`body` text NOT NULL,
|
|
8
|
+
`created_at` text NOT NULL,
|
|
9
|
+
`updated_at` text NOT NULL,
|
|
10
|
+
FOREIGN KEY (`site_id`) REFERENCES `sites`(`id`) ON UPDATE no action ON DELETE no action,
|
|
11
|
+
FOREIGN KEY (`review_id`,`site_id`) REFERENCES `reviews`(`id`,`site_id`) ON UPDATE no action ON DELETE no action,
|
|
12
|
+
FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
|
|
13
|
+
CONSTRAINT "review_comments_body" CHECK(length("review_comments"."body") BETWEEN 1 AND 4000)
|
|
14
|
+
);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
CREATE INDEX `review_comments_review` ON `review_comments` (`site_id`,`review_id`,`created_at`);--> statement-breakpoint
|
|
17
|
+
CREATE UNIQUE INDEX `review_comments_id_site` ON `review_comments` (`id`,`site_id`);
|
|
@@ -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`);
|