@rimelight/cms 0.0.3 → 0.0.4

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.
@@ -0,0 +1,176 @@
1
+ import { sql } from "drizzle-orm";
2
+ import { customType, foreignKey, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
3
+ //#region src/schema/page_versions.ts
4
+ const pageVersions = pgTable("page_versions", {
5
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
6
+ pageId: uuid("page_id").notNull(),
7
+ versionNumber: integer("version_number").notNull(),
8
+ status: text("status").$type().default("pending").notNull(),
9
+ slug: text("slug").notNull(),
10
+ type: text("type").$type().notNull(),
11
+ title: jsonb("title").$type().notNull(),
12
+ description: jsonb("description").$type(),
13
+ tags: jsonb("tags").$type().default([]).notNull(),
14
+ authorIds: jsonb("author_ids").$type().default([]),
15
+ bylines: jsonb("bylines").$type().default([]),
16
+ content: jsonb("content").$type().notNull(),
17
+ createdBy: text("created_by").notNull(),
18
+ approvedBy: jsonb("approved_by").$type().default([]).notNull(),
19
+ approvedAt: timestamp("approved_at", { withTimezone: true }),
20
+ changeSummary: text("change_summary"),
21
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull()
22
+ }, (table) => [uniqueIndex("page_versions_page_id_version_idx").on(table.pageId, table.versionNumber)]);
23
+ //#endregion
24
+ //#region src/schema/page_templates.ts
25
+ const pageTemplates = pgTable("page_templates", {
26
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
27
+ slug: text("slug").notNull().unique(),
28
+ title: jsonb("title").$type().notNull(),
29
+ description: jsonb("description").$type(),
30
+ pageType: text("page_type").$type().notNull(),
31
+ version: integer("version").default(1).notNull(),
32
+ allowedRoles: jsonb("allowed_roles").$type().default([]).notNull(),
33
+ rolePermissions: jsonb("role_permissions").$type().default({
34
+ whoCanCreate: [],
35
+ whoCanEdit: [],
36
+ whoCanReview: [],
37
+ whoCanView: []
38
+ }).notNull(),
39
+ requiredPermission: text("required_permission"),
40
+ approvalRules: jsonb("approval_rules").$type().default({
41
+ allowSelfApproval: true,
42
+ minApprovals: 1
43
+ }).notNull(),
44
+ defaultProperties: jsonb("default_properties").default({}).notNull(),
45
+ initialBlocks: jsonb("initial_blocks").$type().default([]).notNull(),
46
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
47
+ updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate(() => /* @__PURE__ */ new Date())
48
+ });
49
+ //#endregion
50
+ //#region src/schema/pages.ts
51
+ const pages = pgTable("pages", {
52
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
53
+ slug: text("slug").notNull(),
54
+ type: text("type").$type().notNull(),
55
+ templateId: uuid("template_id").references(() => pageTemplates.id, { onDelete: "set null" }),
56
+ templateVersion: integer("template_version").default(1).notNull(),
57
+ title: jsonb("title").$type().notNull(),
58
+ description: jsonb("description").$type(),
59
+ tags: jsonb("tags").$type().default([]).notNull(),
60
+ authorIds: jsonb("author_ids").$type().default([]),
61
+ bylines: jsonb("bylines").$type().default([]),
62
+ /**
63
+ * Denormalized read-cache of the active published version content (NULL if unpublished draft)
64
+ */
65
+ content: jsonb("content").$type().notNull(),
66
+ publishedVersionId: uuid("published_version_id").references(() => pageVersions.id, { onDelete: "set null" }),
67
+ postedAt: timestamp("posted_at", { withTimezone: true }),
68
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
69
+ updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate(() => /* @__PURE__ */ new Date()),
70
+ deletedAt: timestamp("deleted_at", { withTimezone: true })
71
+ }, (table) => [uniqueIndex("pages_slug_active_unique_idx").on(table.slug).where(sql`deleted_at IS NULL`)]);
72
+ //#endregion
73
+ //#region src/schema/page_drafts.ts
74
+ const pageDrafts = pgTable("page_drafts", {
75
+ pageId: uuid("page_id").notNull().primaryKey().references(() => pages.id, { onDelete: "cascade" }),
76
+ content: jsonb("content").$type().notNull(),
77
+ updatedBy: text("updated_by").notNull(),
78
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull()
79
+ });
80
+ //#endregion
81
+ //#region src/schema/page_draft_locks.ts
82
+ const pageDraftLocks = pgTable("page_draft_locks", {
83
+ pageId: uuid("page_id").notNull().primaryKey().references(() => pages.id, { onDelete: "cascade" }),
84
+ lockedByUserId: text("locked_by_user_id").notNull(),
85
+ lockedByUserName: text("locked_by_user_name").notNull(),
86
+ acquiredAt: timestamp("acquired_at", { withTimezone: true }).defaultNow().notNull(),
87
+ expiresAt: timestamp("expires_at", { withTimezone: true }).notNull()
88
+ });
89
+ //#endregion
90
+ //#region src/schema/page_version_comments.ts
91
+ const pageVersionComments = pgTable("page_version_comments", {
92
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
93
+ versionId: uuid("version_id").notNull().references(() => pageVersions.id, { onDelete: "cascade" }),
94
+ userId: text("user_id").notNull(),
95
+ userRole: text("user_role").notNull(),
96
+ content: text("content").notNull(),
97
+ blockId: text("block_id"),
98
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull()
99
+ });
100
+ //#endregion
101
+ //#region src/schema/page_version_approvals.ts
102
+ const pageVersionApprovals = pgTable("page_version_approvals", {
103
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
104
+ versionId: uuid("version_id").notNull().references(() => pageVersions.id, { onDelete: "cascade" }),
105
+ userId: text("user_id").notNull(),
106
+ userRole: text("user_role").notNull(),
107
+ approvedAt: timestamp("approved_at", { withTimezone: true }).defaultNow().notNull()
108
+ });
109
+ //#endregion
110
+ //#region src/schema/search.ts
111
+ const tsvector = customType({ dataType() {
112
+ return "tsvector";
113
+ } });
114
+ const contentSearchIndex = pgTable("content_search_index", {
115
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
116
+ pageId: uuid("page_id").notNull().references(() => pages.id, { onDelete: "cascade" }),
117
+ locale: text("locale").notNull(),
118
+ titleText: text("title_text").notNull(),
119
+ contentText: text("content_text").notNull(),
120
+ searchVector: tsvector("search_vector")
121
+ }, (table) => [index("search_vector_gin_idx").using("gin", table.searchVector)]);
122
+ //#endregion
123
+ //#region src/schema/site_settings.ts
124
+ const siteSettings = pgTable("site_settings", {
125
+ id: text("id").primaryKey().default("default"),
126
+ name: text("name").notNull(),
127
+ description: text("description").notNull(),
128
+ url: text("url").notNull(),
129
+ ogImage: text("og_image").notNull(),
130
+ author: text("author").notNull(),
131
+ email: text("email").notNull().default(""),
132
+ branding: jsonb("branding").$type().notNull(),
133
+ seo: jsonb("seo").$type().notNull(),
134
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
135
+ updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
136
+ });
137
+ //#endregion
138
+ //#region src/schema/taxonomies.ts
139
+ const taxonomyTerms = pgTable("taxonomy_terms", {
140
+ id: uuid("id").defaultRandom().notNull().primaryKey(),
141
+ taxonomy: text("taxonomy").notNull(),
142
+ slug: text("slug").notNull(),
143
+ label: jsonb("label").$type().notNull(),
144
+ description: jsonb("description").$type(),
145
+ parentId: uuid("parent_id"),
146
+ displayOrder: integer("display_order").default(0).notNull(),
147
+ createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
148
+ updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate(() => /* @__PURE__ */ new Date())
149
+ }, (table) => [uniqueIndex("taxonomy_terms_tax_slug_idx").on(table.taxonomy, table.slug), foreignKey({
150
+ columns: [table.parentId],
151
+ foreignColumns: [table.id],
152
+ name: "taxonomy_terms_parent_id_fk"
153
+ }).onDelete("cascade")]);
154
+ const pageTaxonomyTerms = pgTable("page_taxonomy_terms", {
155
+ pageId: uuid("page_id").notNull().references(() => pages.id, { onDelete: "cascade" }),
156
+ termId: uuid("term_id").notNull().references(() => taxonomyTerms.id, { onDelete: "cascade" }),
157
+ assignedAt: timestamp("assigned_at", { withTimezone: true }).defaultNow().notNull()
158
+ }, (table) => [uniqueIndex("page_taxonomy_terms_page_term_idx").on(table.pageId, table.termId)]);
159
+ //#endregion
160
+ //#region src/schema/bylines.ts
161
+ const bylines = pgTable("bylines", {
162
+ id: uuid("id").primaryKey().defaultRandom(),
163
+ name: text("name").notNull(),
164
+ slug: text("slug").notNull(),
165
+ websiteUrl: text("website_url"),
166
+ bio: text("bio"),
167
+ avatar: text("avatar"),
168
+ userId: text("user_id"),
169
+ socials: jsonb("socials").$type().default({}),
170
+ metadata: jsonb("metadata").$type().default({}),
171
+ createdAt: timestamp("created_at").defaultNow().notNull(),
172
+ updatedAt: timestamp("updated_at").defaultNow().notNull(),
173
+ deletedAt: timestamp("deleted_at")
174
+ }, (table) => [uniqueIndex("bylines_slug_idx").on(table.slug)]);
175
+ //#endregion
176
+ export { bylines, contentSearchIndex, pageDraftLocks, pageDrafts, pageTaxonomyTerms, pageTemplates, pageVersionApprovals, pageVersionComments, pageVersions, pages, siteSettings, taxonomyTerms };