@commonpub/schema 0.17.0 → 0.18.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.
@@ -36,6 +36,13 @@
36
36
  "when": 1778123373396,
37
37
  "tag": "0004_federated_oauth_tokens",
38
38
  "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "7",
43
+ "when": 1779839080979,
44
+ "tag": "0005_wonderful_blue_marvel",
45
+ "breakpoints": true
39
46
  }
40
47
  ]
41
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonpub/schema",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Drizzle ORM tables and Zod validators for CommonPub",
6
6
  "license": "AGPL-3.0-or-later",
@@ -1,119 +0,0 @@
1
- -- Layout engine — four tables for the page composition system.
2
- -- Spec: docs/plans/layout-and-pages.md §3 + §4. Drizzle source: src/layout.ts.
3
- --
4
- -- One `layouts` row per scope: a built-in route ('route'), virtual surface
5
- -- like footer/404 ('virtual'), or a DB-stored custom page ('custom-page').
6
- -- Each layout has zones; each zone has rows; each row has sections that
7
- -- snap to a 12-column grid. On publish, the entire layout is snapshotted
8
- -- into `layout_versions` for revert + audit.
9
- --
10
- -- Why normalised tables (vs JSON-in-instance_settings like homepage today):
11
- -- reorders + section-level RLS + per-section-type config migrations are
12
- -- all cheap. See §4.2 of the plan.
13
- --
14
- -- All FKs cascade DELETE so removing a layout cleans up rows + sections +
15
- -- versions automatically; user FKs `SET NULL` so user delete doesn't
16
- -- destroy audit history.
17
-
18
- CREATE TABLE "layouts" (
19
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
20
- "scope_type" varchar(32) NOT NULL,
21
- "scope_key" varchar(512) NOT NULL,
22
- "name" varchar(256) NOT NULL,
23
- "page_meta" jsonb,
24
- "state" varchar(16) DEFAULT 'draft' NOT NULL,
25
- "published_version_id" uuid,
26
- "created_by" uuid,
27
- "updated_by" uuid,
28
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
29
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
30
- CONSTRAINT "layouts_scope_unique" UNIQUE("scope_type","scope_key")
31
- );
32
- --> statement-breakpoint
33
-
34
- CREATE TABLE "layout_rows" (
35
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
36
- "layout_id" uuid NOT NULL,
37
- "zone" varchar(64) NOT NULL,
38
- "position" integer NOT NULL,
39
- "config" jsonb,
40
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
41
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
42
- CONSTRAINT "layout_rows_position_unique" UNIQUE("layout_id","zone","position")
43
- );
44
- --> statement-breakpoint
45
-
46
- CREATE TABLE "layout_sections" (
47
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
48
- "row_id" uuid NOT NULL,
49
- "position" integer NOT NULL,
50
- "enabled" boolean DEFAULT true NOT NULL,
51
- "type" varchar(128) NOT NULL,
52
- "config" jsonb DEFAULT '{}' NOT NULL,
53
- "col_span" integer DEFAULT 12 NOT NULL,
54
- "responsive" jsonb,
55
- "visibility" jsonb,
56
- "schema_version" integer DEFAULT 1 NOT NULL,
57
- "created_at" timestamp with time zone DEFAULT now() NOT NULL,
58
- "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
59
- CONSTRAINT "layout_sections_position_unique" UNIQUE("row_id","position"),
60
- CONSTRAINT "layout_sections_col_span_check" CHECK ("col_span" between 1 and 12)
61
- );
62
- --> statement-breakpoint
63
-
64
- CREATE TABLE "layout_versions" (
65
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
66
- "layout_id" uuid NOT NULL,
67
- "version" integer NOT NULL,
68
- "snapshot" jsonb NOT NULL,
69
- "published_by" uuid,
70
- "published_at" timestamp with time zone DEFAULT now() NOT NULL,
71
- CONSTRAINT "layout_versions_version_unique" UNIQUE("layout_id","version")
72
- );
73
- --> statement-breakpoint
74
-
75
- DO $$ BEGIN
76
- ALTER TABLE "layouts" ADD CONSTRAINT "layouts_created_by_users_id_fk"
77
- FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE set null ON UPDATE no action;
78
- EXCEPTION WHEN duplicate_object THEN null; END $$;
79
- --> statement-breakpoint
80
-
81
- DO $$ BEGIN
82
- ALTER TABLE "layouts" ADD CONSTRAINT "layouts_updated_by_users_id_fk"
83
- FOREIGN KEY ("updated_by") REFERENCES "users"("id") ON DELETE set null ON UPDATE no action;
84
- EXCEPTION WHEN duplicate_object THEN null; END $$;
85
- --> statement-breakpoint
86
-
87
- DO $$ BEGIN
88
- ALTER TABLE "layout_rows" ADD CONSTRAINT "layout_rows_layout_id_layouts_id_fk"
89
- FOREIGN KEY ("layout_id") REFERENCES "layouts"("id") ON DELETE cascade ON UPDATE no action;
90
- EXCEPTION WHEN duplicate_object THEN null; END $$;
91
- --> statement-breakpoint
92
-
93
- DO $$ BEGIN
94
- ALTER TABLE "layout_sections" ADD CONSTRAINT "layout_sections_row_id_layout_rows_id_fk"
95
- FOREIGN KEY ("row_id") REFERENCES "layout_rows"("id") ON DELETE cascade ON UPDATE no action;
96
- EXCEPTION WHEN duplicate_object THEN null; END $$;
97
- --> statement-breakpoint
98
-
99
- DO $$ BEGIN
100
- ALTER TABLE "layout_versions" ADD CONSTRAINT "layout_versions_layout_id_layouts_id_fk"
101
- FOREIGN KEY ("layout_id") REFERENCES "layouts"("id") ON DELETE cascade ON UPDATE no action;
102
- EXCEPTION WHEN duplicate_object THEN null; END $$;
103
- --> statement-breakpoint
104
-
105
- DO $$ BEGIN
106
- ALTER TABLE "layout_versions" ADD CONSTRAINT "layout_versions_published_by_users_id_fk"
107
- FOREIGN KEY ("published_by") REFERENCES "users"("id") ON DELETE set null ON UPDATE no action;
108
- EXCEPTION WHEN duplicate_object THEN null; END $$;
109
- --> statement-breakpoint
110
-
111
- CREATE INDEX "idx_layouts_scope" ON "layouts" ("scope_type","scope_key");
112
- --> statement-breakpoint
113
- CREATE INDEX "idx_layout_rows_layout" ON "layout_rows" ("layout_id","zone","position");
114
- --> statement-breakpoint
115
- CREATE INDEX "idx_layout_sections_row" ON "layout_sections" ("row_id","position");
116
- --> statement-breakpoint
117
- CREATE INDEX "idx_layout_sections_type" ON "layout_sections" ("type");
118
- --> statement-breakpoint
119
- CREATE INDEX "idx_layout_versions_layout" ON "layout_versions" ("layout_id","version");