@rimelight/cms 0.0.9 → 0.0.10
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/index.d.mts +1832 -16
- package/dist/index.mjs +1534 -218
- package/dist/schema/index.d.mts +257 -0
- package/dist/schema/index.mjs +18 -2
- package/dist/schema/sqlite.d.mts +232 -0
- package/dist/schema/sqlite.mjs +15 -1
- package/package.json +29 -16
- package/src/admin/api/media-file.ts +0 -1
- package/src/admin/api/media.ts +0 -2
- package/src/admin/layouts/CMSDashboardLayout.astro +7 -1
- package/src/admin/layouts/DefaultParentLayout.astro +0 -1
- package/src/admin/pages/pages-edit.astro +4 -1
- package/src/admin/pages/pages-index.astro +262 -101
- package/src/admin/pages/pages-preview.astro +5 -2
- package/src/admin/pages/templates-index.astro +224 -54
- package/src/admin/pages/users.astro +96 -50
- package/src/admin/pages/versions.astro +49 -37
- package/src/astro/blocks/DialogueBlock.astro +25 -0
- package/src/astro/blocks/LivePreviewBlock.astro +33 -0
- package/src/astro/blocks/SceneBlock.astro +39 -0
- package/src/astro/blocks/ScriptBlock.astro +77 -0
- package/src/astro/blocks/TableBlock.astro +30 -37
- package/src/astro/blocks/index.ts +9 -1
- package/src/env.d.ts +7 -1
- package/src/loader/live.ts +1 -2
- package/src/mcp/index.ts +1290 -32
- package/src/schema/content_types.ts +59 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/sqlite.ts +35 -0
- package/src/services/search-indexer.ts +20 -9
- package/src/services/site-settings.ts +18 -14
- package/src/services/template-seeder.ts +249 -0
- package/src/storage/index.ts +0 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { boolean, jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"
|
|
2
|
+
import type { Localized } from "../core/types/pages"
|
|
3
|
+
import type { BaseBlock } from "../core/types/blocks"
|
|
4
|
+
|
|
5
|
+
export type CollectionMode = "document" | "data" | "singleton"
|
|
6
|
+
|
|
7
|
+
export interface DynamicFieldDefinition {
|
|
8
|
+
type:
|
|
9
|
+
| "text"
|
|
10
|
+
| "number"
|
|
11
|
+
| "boolean"
|
|
12
|
+
| "enum"
|
|
13
|
+
| "media"
|
|
14
|
+
| "relation"
|
|
15
|
+
| "currency"
|
|
16
|
+
| "array"
|
|
17
|
+
| "json"
|
|
18
|
+
label: Localized
|
|
19
|
+
description?: Localized
|
|
20
|
+
required?: boolean
|
|
21
|
+
defaultValue?: any
|
|
22
|
+
options?: { label: Localized; value: string }[]
|
|
23
|
+
allowedCollections?: string[]
|
|
24
|
+
validation?: {
|
|
25
|
+
min?: number
|
|
26
|
+
max?: number
|
|
27
|
+
pattern?: string
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface EcomSettings {
|
|
32
|
+
enabled: boolean
|
|
33
|
+
currencyDefault: string
|
|
34
|
+
trackInventory: boolean
|
|
35
|
+
hasVariants: boolean
|
|
36
|
+
allowDigitalDownloads: boolean
|
|
37
|
+
stripeSync?: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const contentTypes = pgTable("content_types", {
|
|
41
|
+
id: uuid("id").defaultRandom().notNull().primaryKey(),
|
|
42
|
+
slug: text("slug").notNull().unique(),
|
|
43
|
+
name: jsonb("name").$type<Localized>().notNull(),
|
|
44
|
+
description: jsonb("description").$type<Localized>(),
|
|
45
|
+
icon: text("icon").default("i-lucide-box").notNull(),
|
|
46
|
+
mode: text("mode").$type<CollectionMode>().default("document").notNull(),
|
|
47
|
+
|
|
48
|
+
fieldSchema: jsonb("field_schema")
|
|
49
|
+
.$type<Record<string, { label: Localized; fields: Record<string, DynamicFieldDefinition> }>>()
|
|
50
|
+
.default({})
|
|
51
|
+
.notNull(),
|
|
52
|
+
|
|
53
|
+
ecomSettings: jsonb("ecom_settings").$type<EcomSettings>(),
|
|
54
|
+
initialBlocks: jsonb("initial_blocks").$type<BaseBlock[]>().default([]).notNull(),
|
|
55
|
+
isSystem: boolean("is_system").default(false).notNull(),
|
|
56
|
+
|
|
57
|
+
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
|
58
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).$onUpdate(() => new Date())
|
|
59
|
+
})
|
package/src/schema/index.ts
CHANGED
package/src/schema/sqlite.ts
CHANGED
|
@@ -342,3 +342,38 @@ export type Byline = typeof bylines.$inferSelect
|
|
|
342
342
|
export type NewByline = typeof bylines.$inferInsert
|
|
343
343
|
export type SiteSettings = typeof siteSettings.$inferSelect
|
|
344
344
|
export type InsertSiteSettings = typeof siteSettings.$inferInsert
|
|
345
|
+
|
|
346
|
+
// 12. Dynamic Content Types
|
|
347
|
+
export const contentTypes = sqliteTable(
|
|
348
|
+
"content_types",
|
|
349
|
+
{
|
|
350
|
+
id: text("id")
|
|
351
|
+
.$defaultFn(() => crypto.randomUUID())
|
|
352
|
+
.primaryKey(),
|
|
353
|
+
slug: text("slug").notNull(),
|
|
354
|
+
name: text("name", { mode: "json" }).$type<Localized>().notNull(),
|
|
355
|
+
description: text("description", { mode: "json" }).$type<Localized>(),
|
|
356
|
+
icon: text("icon").default("i-lucide-box").notNull(),
|
|
357
|
+
mode: text("mode").$type<"document" | "data" | "singleton">().default("document").notNull(),
|
|
358
|
+
fieldSchema: text("field_schema", { mode: "json" })
|
|
359
|
+
.$type<Record<string, any>>()
|
|
360
|
+
.default(sql`'{}'`)
|
|
361
|
+
.notNull(),
|
|
362
|
+
ecomSettings: text("ecom_settings", { mode: "json" }).$type<Record<string, any>>(),
|
|
363
|
+
initialBlocks: text("initial_blocks", { mode: "json" })
|
|
364
|
+
.$type<BaseBlock[]>()
|
|
365
|
+
.default(sql`'[]'`)
|
|
366
|
+
.notNull(),
|
|
367
|
+
isSystem: integer("is_system", { mode: "boolean" }).default(false).notNull(),
|
|
368
|
+
createdAt: integer("created_at", { mode: "timestamp" })
|
|
369
|
+
.$defaultFn(() => new Date())
|
|
370
|
+
.notNull(),
|
|
371
|
+
updatedAt: integer("updated_at", { mode: "timestamp" })
|
|
372
|
+
.$defaultFn(() => new Date())
|
|
373
|
+
.$onUpdate(() => new Date())
|
|
374
|
+
},
|
|
375
|
+
(table) => [uniqueIndex("content_types_slug_idx").on(table.slug)]
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
export type ContentType = typeof contentTypes.$inferSelect
|
|
379
|
+
export type InsertContentType = typeof contentTypes.$inferInsert
|
|
@@ -36,23 +36,34 @@ export async function indexPageForSearch(
|
|
|
36
36
|
.where(and(eq(contentSearchIndex.pageId, page.id), eq(contentSearchIndex.locale, locale)))
|
|
37
37
|
.limit(1)
|
|
38
38
|
|
|
39
|
+
const hasSearchVector = "searchVector" in contentSearchIndex
|
|
40
|
+
|
|
41
|
+
const updatePayload: Record<string, any> = {
|
|
42
|
+
titleText,
|
|
43
|
+
contentText
|
|
44
|
+
}
|
|
45
|
+
if (hasSearchVector) {
|
|
46
|
+
updatePayload["searchVector"] =
|
|
47
|
+
sql`to_tsvector('english', ${titleText} || ' ' || ${contentText})`
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
if (existing.length > 0) {
|
|
40
51
|
await db
|
|
41
52
|
.update(contentSearchIndex)
|
|
42
|
-
.set(
|
|
43
|
-
titleText,
|
|
44
|
-
contentText,
|
|
45
|
-
searchVector: sql`to_tsvector('english', ${titleText} || ' ' || ${contentText})`
|
|
46
|
-
})
|
|
53
|
+
.set(updatePayload)
|
|
47
54
|
.where(eq(contentSearchIndex.id, existing[0].id))
|
|
48
55
|
} else {
|
|
49
|
-
|
|
56
|
+
const insertPayload: Record<string, any> = {
|
|
50
57
|
pageId: page.id,
|
|
51
58
|
locale,
|
|
52
59
|
titleText,
|
|
53
|
-
contentText
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
contentText
|
|
61
|
+
}
|
|
62
|
+
if (hasSearchVector) {
|
|
63
|
+
insertPayload["searchVector"] =
|
|
64
|
+
sql`to_tsvector('english', ${titleText} || ' ' || ${contentText})`
|
|
65
|
+
}
|
|
66
|
+
await db.insert(contentSearchIndex).values(insertPayload)
|
|
56
67
|
}
|
|
57
68
|
} catch (err) {
|
|
58
69
|
console.error(`[Search Indexer] Failed to index page ${page.id} for locale ${locale}:`, err)
|
|
@@ -32,6 +32,22 @@ export const DEFAULT_SITE_SETTINGS: InsertSiteSettings = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
function fallbackSettings(overrides?: Partial<InsertSiteSettings>): SiteSettings {
|
|
36
|
+
return {
|
|
37
|
+
id: overrides?.id ?? "default",
|
|
38
|
+
name: overrides?.name ?? DEFAULT_SITE_SETTINGS.name,
|
|
39
|
+
description: overrides?.description ?? DEFAULT_SITE_SETTINGS.description,
|
|
40
|
+
url: overrides?.url ?? DEFAULT_SITE_SETTINGS.url,
|
|
41
|
+
ogImage: overrides?.ogImage ?? DEFAULT_SITE_SETTINGS.ogImage,
|
|
42
|
+
author: overrides?.author ?? DEFAULT_SITE_SETTINGS.author,
|
|
43
|
+
email: overrides?.email ?? "",
|
|
44
|
+
branding: overrides?.branding ?? DEFAULT_SITE_SETTINGS.branding,
|
|
45
|
+
seo: overrides?.seo ?? DEFAULT_SITE_SETTINGS.seo,
|
|
46
|
+
createdAt: new Date(),
|
|
47
|
+
updatedAt: new Date()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
35
51
|
/**
|
|
36
52
|
* Retrieves the dynamic site settings from the database. If no settings are found, seeds the
|
|
37
53
|
* default record and returns it.
|
|
@@ -41,13 +57,7 @@ export async function getSiteSettings(
|
|
|
41
57
|
fallbackDefaults?: Partial<InsertSiteSettings>
|
|
42
58
|
): Promise<SiteSettings> {
|
|
43
59
|
if (!db) {
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
...DEFAULT_SITE_SETTINGS,
|
|
47
|
-
...fallbackDefaults,
|
|
48
|
-
createdAt: new Date(),
|
|
49
|
-
updatedAt: new Date()
|
|
50
|
-
} as SiteSettings
|
|
60
|
+
return fallbackSettings(fallbackDefaults)
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
try {
|
|
@@ -71,13 +81,7 @@ export async function getSiteSettings(
|
|
|
71
81
|
return inserted[0]
|
|
72
82
|
} catch (error) {
|
|
73
83
|
console.warn("Failed to fetch site settings from DB, using fallback:", error)
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
...DEFAULT_SITE_SETTINGS,
|
|
77
|
-
...fallbackDefaults,
|
|
78
|
-
createdAt: new Date(),
|
|
79
|
-
updatedAt: new Date()
|
|
80
|
-
} as SiteSettings
|
|
84
|
+
return fallbackSettings(fallbackDefaults)
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { pageTemplates } from "../schema/page_templates.ts"
|
|
2
|
+
import {
|
|
3
|
+
BLOG_POST_DEFINITION,
|
|
4
|
+
DOCUMENT_DEFINITION,
|
|
5
|
+
CHARACTER_DEFINITION,
|
|
6
|
+
HERO_DEFINITION,
|
|
7
|
+
SERIES_DEFINITION,
|
|
8
|
+
PATCH_NOTE_DEFINITION,
|
|
9
|
+
LOCATION_DEFINITION,
|
|
10
|
+
ITEM_DEFINITION,
|
|
11
|
+
SPECIES_DEFINITION,
|
|
12
|
+
SKILL_DEFINITION
|
|
13
|
+
} from "../core/page-definitions.ts"
|
|
14
|
+
|
|
15
|
+
export interface BuiltinTemplate {
|
|
16
|
+
slug: string
|
|
17
|
+
title: { en: string }
|
|
18
|
+
description: { en: string }
|
|
19
|
+
pageType: string
|
|
20
|
+
version: number
|
|
21
|
+
allowedRoles: string[]
|
|
22
|
+
rolePermissions: {
|
|
23
|
+
whoCanCreate: string[]
|
|
24
|
+
whoCanEdit: string[]
|
|
25
|
+
whoCanReview: string[]
|
|
26
|
+
whoCanView: string[]
|
|
27
|
+
}
|
|
28
|
+
approvalRules: {
|
|
29
|
+
allowSelfApproval: boolean
|
|
30
|
+
minApprovals: number
|
|
31
|
+
}
|
|
32
|
+
defaultProperties: Record<string, any>
|
|
33
|
+
initialBlocks: any[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getBuiltinTemplates(): BuiltinTemplate[] {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
slug: "blog-post",
|
|
40
|
+
title: { en: "Blog Post" },
|
|
41
|
+
description: {
|
|
42
|
+
en: "Standard blog article with category metadata, author attribution, and formatted headings"
|
|
43
|
+
},
|
|
44
|
+
pageType: "blog",
|
|
45
|
+
version: 1,
|
|
46
|
+
allowedRoles: [],
|
|
47
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
48
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
49
|
+
defaultProperties: BLOG_POST_DEFINITION.properties,
|
|
50
|
+
initialBlocks: [
|
|
51
|
+
{
|
|
52
|
+
id: crypto.randomUUID(),
|
|
53
|
+
type: "HeadingBlock",
|
|
54
|
+
props: { level: 2, text: "Introduction" },
|
|
55
|
+
isTemplated: false
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: crypto.randomUUID(),
|
|
59
|
+
type: "ParagraphBlock",
|
|
60
|
+
props: { content: "Start writing your blog article here..." },
|
|
61
|
+
isTemplated: false
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
slug: "documentation",
|
|
67
|
+
title: { en: "Documentation Guide" },
|
|
68
|
+
description: {
|
|
69
|
+
en: "Technical documentation page with structured sections, callouts, and code blocks"
|
|
70
|
+
},
|
|
71
|
+
pageType: "doc",
|
|
72
|
+
version: 1,
|
|
73
|
+
allowedRoles: [],
|
|
74
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
75
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
76
|
+
defaultProperties: DOCUMENT_DEFINITION.properties,
|
|
77
|
+
initialBlocks: [
|
|
78
|
+
{
|
|
79
|
+
id: crypto.randomUUID(),
|
|
80
|
+
type: "HeadingBlock",
|
|
81
|
+
props: { level: 2, text: "Overview" },
|
|
82
|
+
isTemplated: false
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: crypto.randomUUID(),
|
|
86
|
+
type: "CalloutBlock",
|
|
87
|
+
props: { variant: "info", content: "Key guide details and prerequisites go here." },
|
|
88
|
+
isTemplated: false
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: crypto.randomUUID(),
|
|
92
|
+
type: "HeadingBlock",
|
|
93
|
+
props: { level: 2, text: "Usage" },
|
|
94
|
+
isTemplated: false
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
slug: "character-profile",
|
|
100
|
+
title: { en: "Character Profile" },
|
|
101
|
+
description: {
|
|
102
|
+
en: "Franchise character sheet with identity, characteristics, inventory, and backstory lore"
|
|
103
|
+
},
|
|
104
|
+
pageType: "character",
|
|
105
|
+
version: 1,
|
|
106
|
+
allowedRoles: [],
|
|
107
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
108
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
109
|
+
defaultProperties: CHARACTER_DEFINITION.properties,
|
|
110
|
+
initialBlocks: CHARACTER_DEFINITION.initialBlocks ? CHARACTER_DEFINITION.initialBlocks() : []
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
slug: "hero-sheet",
|
|
114
|
+
title: { en: "Hero Combat Sheet" },
|
|
115
|
+
description: {
|
|
116
|
+
en: "Hero character with combat stats, progression mechanics, and playstyle lore"
|
|
117
|
+
},
|
|
118
|
+
pageType: "hero",
|
|
119
|
+
version: 1,
|
|
120
|
+
allowedRoles: [],
|
|
121
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
122
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
123
|
+
defaultProperties: HERO_DEFINITION.properties,
|
|
124
|
+
initialBlocks: HERO_DEFINITION.initialBlocks ? HERO_DEFINITION.initialBlocks() : []
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
slug: "series-overview",
|
|
128
|
+
title: { en: "Series Overview" },
|
|
129
|
+
description: {
|
|
130
|
+
en: "Media show / series page with genre, season metadata, and episode overviews"
|
|
131
|
+
},
|
|
132
|
+
pageType: "series",
|
|
133
|
+
version: 1,
|
|
134
|
+
allowedRoles: [],
|
|
135
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
136
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
137
|
+
defaultProperties: SERIES_DEFINITION.properties,
|
|
138
|
+
initialBlocks: SERIES_DEFINITION.initialBlocks ? SERIES_DEFINITION.initialBlocks() : []
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
slug: "patch-note",
|
|
142
|
+
title: { en: "Release / Patch Note" },
|
|
143
|
+
description: {
|
|
144
|
+
en: "Version changelog, release highlights, balance adjustments, and bug fixes"
|
|
145
|
+
},
|
|
146
|
+
pageType: "patchnote",
|
|
147
|
+
version: 1,
|
|
148
|
+
allowedRoles: [],
|
|
149
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
150
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
151
|
+
defaultProperties: PATCH_NOTE_DEFINITION.properties,
|
|
152
|
+
initialBlocks: [
|
|
153
|
+
{
|
|
154
|
+
id: crypto.randomUUID(),
|
|
155
|
+
type: "HeadingBlock",
|
|
156
|
+
props: { level: 2, text: "Release Highlights" },
|
|
157
|
+
isTemplated: false
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: crypto.randomUUID(),
|
|
161
|
+
type: "HeadingBlock",
|
|
162
|
+
props: { level: 3, text: "Bug Fixes & Improvements" },
|
|
163
|
+
isTemplated: false
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
slug: "location-guide",
|
|
169
|
+
title: { en: "World Location" },
|
|
170
|
+
description: { en: "Worldbuilding geography, climate conditions, and notable landmarks" },
|
|
171
|
+
pageType: "location",
|
|
172
|
+
version: 1,
|
|
173
|
+
allowedRoles: [],
|
|
174
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
175
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
176
|
+
defaultProperties: LOCATION_DEFINITION.properties,
|
|
177
|
+
initialBlocks: []
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
slug: "game-item",
|
|
181
|
+
title: { en: "Item & Equipment" },
|
|
182
|
+
description: { en: "Item rarity, pricing, quest associations, and equipment stats" },
|
|
183
|
+
pageType: "item",
|
|
184
|
+
version: 1,
|
|
185
|
+
allowedRoles: [],
|
|
186
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
187
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
188
|
+
defaultProperties: ITEM_DEFINITION.properties,
|
|
189
|
+
initialBlocks: []
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
slug: "species-entry",
|
|
193
|
+
title: { en: "Species Entry" },
|
|
194
|
+
description: { en: "Biological taxonomy, lifespan, and homeworld association" },
|
|
195
|
+
pageType: "species",
|
|
196
|
+
version: 1,
|
|
197
|
+
allowedRoles: [],
|
|
198
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
199
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
200
|
+
defaultProperties: SPECIES_DEFINITION.properties,
|
|
201
|
+
initialBlocks: []
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
slug: "skill-entry",
|
|
205
|
+
title: { en: "Skill & Ability" },
|
|
206
|
+
description: { en: "Ability cooldown, mana cost, and damage type mechanics" },
|
|
207
|
+
pageType: "skill",
|
|
208
|
+
version: 1,
|
|
209
|
+
allowedRoles: [],
|
|
210
|
+
rolePermissions: { whoCanCreate: [], whoCanEdit: [], whoCanReview: [], whoCanView: [] },
|
|
211
|
+
approvalRules: { allowSelfApproval: true, minApprovals: 1 },
|
|
212
|
+
defaultProperties: SKILL_DEFINITION.properties,
|
|
213
|
+
initialBlocks: []
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Ensures built-in page templates exist in the database. If page_templates table is empty,
|
|
220
|
+
* populates it with starter templates.
|
|
221
|
+
*/
|
|
222
|
+
export async function ensureDefaultTemplates(
|
|
223
|
+
dbInstance: any,
|
|
224
|
+
templateTable = pageTemplates
|
|
225
|
+
): Promise<number> {
|
|
226
|
+
if (!dbInstance) return 0
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
const existing = await dbInstance.select({ id: templateTable.id }).from(templateTable)
|
|
230
|
+
if (existing.length > 0) {
|
|
231
|
+
return existing.length
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const defaultTemplates = getBuiltinTemplates()
|
|
235
|
+
for (const tmpl of defaultTemplates) {
|
|
236
|
+
try {
|
|
237
|
+
await dbInstance.insert(templateTable).values(tmpl)
|
|
238
|
+
} catch (insertErr) {
|
|
239
|
+
console.warn(`Failed to seed template ${tmpl.slug}:`, insertErr)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const seeded = await dbInstance.select().from(templateTable)
|
|
244
|
+
return seeded.length
|
|
245
|
+
} catch (err) {
|
|
246
|
+
console.warn("Error checking or seeding default templates:", err)
|
|
247
|
+
return 0
|
|
248
|
+
}
|
|
249
|
+
}
|
package/src/storage/index.ts
CHANGED
|
@@ -58,7 +58,6 @@ export function r2(options: R2StorageOptions = {}): StorageConfig {
|
|
|
58
58
|
export async function getR2Bucket(locals?: any, bindingName = "BLOB"): Promise<any> {
|
|
59
59
|
// 1. Try cloudflare:workers standard export (Astro v6+)
|
|
60
60
|
try {
|
|
61
|
-
// @ts-ignore
|
|
62
61
|
const cf = await import("cloudflare:workers")
|
|
63
62
|
if (cf?.env && cf.env[bindingName]) {
|
|
64
63
|
return cf.env[bindingName]
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Rimelight Entertainment
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|