@rimelight/cms 0.0.3 → 0.0.5
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/bylines-Csggkl-g.d.mts +405 -0
- package/dist/index.d.mts +724 -0
- package/dist/index.mjs +2382 -0
- package/dist/integration.d.mts +33 -0
- package/dist/integration.mjs +161 -0
- package/dist/schema/index.d.mts +2063 -0
- package/dist/schema/index.mjs +176 -0
- package/dist/schema/sqlite.d.mts +2132 -0
- package/dist/schema/sqlite.mjs +137 -0
- package/dist/storage/index.d.mts +59 -0
- package/dist/storage/index.mjs +133 -0
- package/package.json +35 -14
- package/src/admin/api/media-file.ts +1 -1
- package/src/admin/api/media.ts +28 -3
- package/src/admin/layouts/CMSDashboardLayout.astro +16 -3
- package/src/admin/pages/assets.astro +11 -11
- package/src/admin/pages/pages-edit.astro +3 -3
- package/src/admin/pages/pages-index.astro +2 -2
- package/src/admin/pages/pages-preview.astro +3 -3
- package/src/admin/pages/pages-review.astro +2 -2
- package/src/admin/pages/templates-edit.astro +1 -1
- package/src/admin/pages/templates-index.astro +1 -1
- package/src/astro/BlockRenderer.astro +1 -1
- package/src/astro/PageRenderer.astro +4 -4
- package/src/astro/blocks/CalloutBlock.astro +1 -1
- package/src/astro/blocks/OrderedListBlock.astro +2 -2
- package/src/astro/blocks/ParagraphBlock.astro +1 -1
- package/src/astro/blocks/TabsBlock.astro +5 -5
- package/src/astro/blocks/UnorderedListBlock.astro +2 -2
- package/src/auth/editor-guards.ts +1 -1
- package/src/cache/purge.ts +2 -2
- package/src/client/components/RimelightBlock.tsx +1 -1
- package/src/client/components/RimelightBlockPicker.tsx +1 -1
- package/src/client/components/RimelightPreview.tsx +27 -27
- package/src/client/components/RimelightPropertiesPanel.tsx +4 -4
- package/src/client/components/RimelightTemplateEditor.tsx +9 -5
- package/src/client/components/editors/CalloutEditor.tsx +10 -10
- package/src/client/components/editors/CardEditor.tsx +5 -5
- package/src/client/components/editors/CardsEditor.tsx +2 -2
- package/src/client/components/editors/CodeEditor.tsx +5 -5
- package/src/client/components/editors/DialogueEditor.tsx +6 -6
- package/src/client/components/editors/FileTreeEditor.tsx +1 -1
- package/src/client/components/editors/ImageEditor.tsx +9 -9
- package/src/client/components/editors/ParagraphEditor.tsx +1 -1
- package/src/client/components/editors/SceneEditor.tsx +9 -9
- package/src/client/components/editors/ScriptEditor.tsx +8 -8
- package/src/client/components/editors/SectionEditor.tsx +3 -3
- package/src/client/components/editors/StepItemEditor.tsx +6 -5
- package/src/client/components/editors/StepsEditor.tsx +1 -1
- package/src/client/components/editors/TabItemEditor.tsx +3 -3
- package/src/client/components/editors/TableEditor.tsx +4 -4
- package/src/client/components/editors/TabsEditor.tsx +1 -1
- package/src/client/state/editor-store.ts +23 -23
- package/src/client/utils/sortable.ts +13 -12
- package/src/client/utils/tree-sanitizer.ts +1 -1
- package/src/core/excerpt.ts +16 -16
- package/src/core/page-definitions.ts +2 -2
- package/src/docs/agent.ts +1 -1
- package/src/docs/routing.ts +2 -2
- package/src/env.d.ts +6 -0
- package/src/index.ts +17 -4
- package/src/integration.ts +54 -0
- package/src/loader/live.ts +1 -1
- package/src/markdown/serializer.ts +26 -26
- package/src/schema/sqlite.ts +344 -0
- package/src/storage/index.ts +4 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StorageConfig } from "./storage/index.mjs";
|
|
2
|
+
import { AuthAdapter } from "@rimelight/auth";
|
|
3
|
+
import { AstroIntegration } from "astro";
|
|
4
|
+
//#region src/integration.d.ts
|
|
5
|
+
interface RimelightCmsOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Route prefix for CMS admin pages. Defaults to "/[locale]/cms" (or "/cms" if no locale routing).
|
|
8
|
+
*/
|
|
9
|
+
routePrefix?: string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Optional outer layout to wrap the CMS dashboard in (e.g. "./src/layouts/AppLayout.astro"). When
|
|
12
|
+
* omitted, renders as a dedicated standalone full-viewport dashboard.
|
|
13
|
+
*/
|
|
14
|
+
parentLayout?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the app database instance module exporting `db`. Defaults to "./src/db/index.ts" or
|
|
17
|
+
* "./src/db".
|
|
18
|
+
*/
|
|
19
|
+
db?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Storage backend configuration (e.g. r2({ binding: "BLOB", publicUrl:
|
|
22
|
+
* "https://media.example.com" })).
|
|
23
|
+
*/
|
|
24
|
+
storage?: StorageConfig | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Pluggable Auth Adapter instance or module path (RFC-0004 / RFC-0006). E.g. cfAccessAuth({ ...
|
|
27
|
+
* }), auth0Auth({ ... }), or mockAuth().
|
|
28
|
+
*/
|
|
29
|
+
auth?: AuthAdapter | string | undefined;
|
|
30
|
+
}
|
|
31
|
+
declare function rimelightCms(options?: RimelightCmsOptions): AstroIntegration;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { RimelightCmsOptions, rimelightCms };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region src/integration.ts
|
|
5
|
+
function rimelightCms(options = {}) {
|
|
6
|
+
const routePrefix = options.routePrefix ?? "/[locale]/cms";
|
|
7
|
+
const storageConfig = {
|
|
8
|
+
provider: options.storage?.provider ?? "r2",
|
|
9
|
+
binding: options.storage?.binding ?? "BLOB",
|
|
10
|
+
publicUrl: options.storage?.publicUrl,
|
|
11
|
+
prefix: options.storage?.prefix ?? "media/"
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
name: "@rimelight/cms",
|
|
15
|
+
hooks: { "astro:config:setup": ({ injectRoute, updateConfig, config }) => {
|
|
16
|
+
const rootDir = fileURLToPath(config.root);
|
|
17
|
+
let resolvedParentLayout = null;
|
|
18
|
+
if (options.parentLayout) resolvedParentLayout = path.isAbsolute(options.parentLayout) ? options.parentLayout : path.resolve(rootDir, options.parentLayout);
|
|
19
|
+
let resolvedDb = null;
|
|
20
|
+
if (options.db) resolvedDb = path.isAbsolute(options.db) ? options.db : path.resolve(rootDir, options.db);
|
|
21
|
+
else {
|
|
22
|
+
const defaultDbTs = path.resolve(rootDir, "src/db/index.ts");
|
|
23
|
+
const defaultDbJs = path.resolve(rootDir, "src/db/index.js");
|
|
24
|
+
if (fs.existsSync(defaultDbTs)) resolvedDb = defaultDbTs;
|
|
25
|
+
else if (fs.existsSync(defaultDbJs)) resolvedDb = defaultDbJs;
|
|
26
|
+
}
|
|
27
|
+
let resolvedAuthCode;
|
|
28
|
+
if (typeof options.auth === "string") {
|
|
29
|
+
const resolvedAuthPath = path.isAbsolute(options.auth) ? options.auth : path.resolve(rootDir, options.auth);
|
|
30
|
+
resolvedAuthCode = `export { authAdapter, authAdapter as default } from ${JSON.stringify(resolvedAuthPath)};`;
|
|
31
|
+
} else if (options.auth && typeof options.auth === "object") {
|
|
32
|
+
const authObj = options.auth;
|
|
33
|
+
const adapterName = authObj.name || "mock";
|
|
34
|
+
const adapterOpts = authObj.options || {};
|
|
35
|
+
if (adapterName === "cf-access") resolvedAuthCode = `import { cfAccessAuth } from "@rimelight/auth/cf-access";
|
|
36
|
+
export const authAdapter = cfAccessAuth(${JSON.stringify(adapterOpts)});
|
|
37
|
+
export default authAdapter;`;
|
|
38
|
+
else if (adapterName === "auth0") resolvedAuthCode = `import { auth0Auth } from "@rimelight/auth/auth0";
|
|
39
|
+
export const authAdapter = auth0Auth(${JSON.stringify(adapterOpts)});
|
|
40
|
+
export default authAdapter;`;
|
|
41
|
+
else resolvedAuthCode = `import { mockAuth } from "@rimelight/auth/mock";
|
|
42
|
+
export const authAdapter = mockAuth(${JSON.stringify(adapterOpts)});
|
|
43
|
+
export default authAdapter;`;
|
|
44
|
+
} else resolvedAuthCode = `import { mockAuth } from "@rimelight/auth/mock";
|
|
45
|
+
export const authAdapter = mockAuth({
|
|
46
|
+
session: {
|
|
47
|
+
userId: "cms-admin",
|
|
48
|
+
name: "CMS Administrator",
|
|
49
|
+
email: "admin@rimelight.com",
|
|
50
|
+
roles: ["admin", "editor"],
|
|
51
|
+
permissions: ["*"],
|
|
52
|
+
userType: "employee"
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export default authAdapter;`;
|
|
56
|
+
injectRoute({
|
|
57
|
+
pattern: `${routePrefix}`,
|
|
58
|
+
entrypoint: "@rimelight/cms/admin/pages/dashboard.astro"
|
|
59
|
+
});
|
|
60
|
+
injectRoute({
|
|
61
|
+
pattern: `${routePrefix}/pages`,
|
|
62
|
+
entrypoint: "@rimelight/cms/admin/pages/pages-index.astro"
|
|
63
|
+
});
|
|
64
|
+
injectRoute({
|
|
65
|
+
pattern: `${routePrefix}/pages/new`,
|
|
66
|
+
entrypoint: "@rimelight/cms/admin/pages/pages-new.astro"
|
|
67
|
+
});
|
|
68
|
+
injectRoute({
|
|
69
|
+
pattern: `${routePrefix}/pages/[id]/edit`,
|
|
70
|
+
entrypoint: "@rimelight/cms/admin/pages/pages-edit.astro"
|
|
71
|
+
});
|
|
72
|
+
injectRoute({
|
|
73
|
+
pattern: `${routePrefix}/pages/[id]/preview`,
|
|
74
|
+
entrypoint: "@rimelight/cms/admin/pages/pages-preview.astro"
|
|
75
|
+
});
|
|
76
|
+
injectRoute({
|
|
77
|
+
pattern: `${routePrefix}/pages/[id]/review`,
|
|
78
|
+
entrypoint: "@rimelight/cms/admin/pages/pages-review.astro"
|
|
79
|
+
});
|
|
80
|
+
injectRoute({
|
|
81
|
+
pattern: `${routePrefix}/templates`,
|
|
82
|
+
entrypoint: "@rimelight/cms/admin/pages/templates-index.astro"
|
|
83
|
+
});
|
|
84
|
+
injectRoute({
|
|
85
|
+
pattern: `${routePrefix}/templates/new`,
|
|
86
|
+
entrypoint: "@rimelight/cms/admin/pages/templates-new.astro"
|
|
87
|
+
});
|
|
88
|
+
injectRoute({
|
|
89
|
+
pattern: `${routePrefix}/templates/[id]/edit`,
|
|
90
|
+
entrypoint: "@rimelight/cms/admin/pages/templates-edit.astro"
|
|
91
|
+
});
|
|
92
|
+
injectRoute({
|
|
93
|
+
pattern: `${routePrefix}/assets`,
|
|
94
|
+
entrypoint: "@rimelight/cms/admin/pages/assets.astro"
|
|
95
|
+
});
|
|
96
|
+
injectRoute({
|
|
97
|
+
pattern: `${routePrefix}/categories`,
|
|
98
|
+
entrypoint: "@rimelight/cms/admin/pages/categories.astro"
|
|
99
|
+
});
|
|
100
|
+
injectRoute({
|
|
101
|
+
pattern: `${routePrefix}/tags`,
|
|
102
|
+
entrypoint: "@rimelight/cms/admin/pages/tags.astro"
|
|
103
|
+
});
|
|
104
|
+
injectRoute({
|
|
105
|
+
pattern: `${routePrefix}/bylines`,
|
|
106
|
+
entrypoint: "@rimelight/cms/admin/pages/bylines.astro"
|
|
107
|
+
});
|
|
108
|
+
injectRoute({
|
|
109
|
+
pattern: `${routePrefix}/versions`,
|
|
110
|
+
entrypoint: "@rimelight/cms/admin/pages/versions.astro"
|
|
111
|
+
});
|
|
112
|
+
injectRoute({
|
|
113
|
+
pattern: `${routePrefix}/content-types`,
|
|
114
|
+
entrypoint: "@rimelight/cms/admin/pages/content-types.astro"
|
|
115
|
+
});
|
|
116
|
+
injectRoute({
|
|
117
|
+
pattern: `${routePrefix}/byline-schema`,
|
|
118
|
+
entrypoint: "@rimelight/cms/admin/pages/byline-schema.astro"
|
|
119
|
+
});
|
|
120
|
+
injectRoute({
|
|
121
|
+
pattern: `${routePrefix}/users`,
|
|
122
|
+
entrypoint: "@rimelight/cms/admin/pages/users.astro"
|
|
123
|
+
});
|
|
124
|
+
injectRoute({
|
|
125
|
+
pattern: `${routePrefix}/settings`,
|
|
126
|
+
entrypoint: "@rimelight/cms/admin/pages/settings.astro"
|
|
127
|
+
});
|
|
128
|
+
injectRoute({
|
|
129
|
+
pattern: `${routePrefix}/api/media`,
|
|
130
|
+
entrypoint: "@rimelight/cms/admin/api/media.ts"
|
|
131
|
+
});
|
|
132
|
+
injectRoute({
|
|
133
|
+
pattern: `${routePrefix}/api/media/file/[...key]`,
|
|
134
|
+
entrypoint: "@rimelight/cms/admin/api/media-file.ts"
|
|
135
|
+
});
|
|
136
|
+
updateConfig({ vite: { plugins: [{
|
|
137
|
+
name: "vite-plugin-rimelight-cms-virtuals",
|
|
138
|
+
resolveId(id) {
|
|
139
|
+
if (id === "virtual:rimelight-cms/parent-layout") return "\0virtual:rimelight-cms/parent-layout";
|
|
140
|
+
if (id === "virtual:rimelight-cms/db") return "\0virtual:rimelight-cms/db";
|
|
141
|
+
if (id === "virtual:rimelight-cms/storage") return "\0virtual:rimelight-cms/storage";
|
|
142
|
+
if (id === "virtual:rimelight-cms/auth") return "\0virtual:rimelight-cms/auth";
|
|
143
|
+
},
|
|
144
|
+
load(id) {
|
|
145
|
+
if (id === "\0virtual:rimelight-cms/parent-layout") {
|
|
146
|
+
if (resolvedParentLayout && fs.existsSync(resolvedParentLayout)) return `export { default } from ${JSON.stringify(resolvedParentLayout)};`;
|
|
147
|
+
return `export { default } from "@rimelight/cms/admin/layouts/DefaultParentLayout.astro";`;
|
|
148
|
+
}
|
|
149
|
+
if (id === "\0virtual:rimelight-cms/db") {
|
|
150
|
+
if (resolvedDb && fs.existsSync(resolvedDb)) return `export * from ${JSON.stringify(resolvedDb)};`;
|
|
151
|
+
return `export const db = null;`;
|
|
152
|
+
}
|
|
153
|
+
if (id === "\0virtual:rimelight-cms/storage") return `export const storageConfig = ${JSON.stringify(storageConfig)};`;
|
|
154
|
+
if (id === "\0virtual:rimelight-cms/auth") return resolvedAuthCode;
|
|
155
|
+
}
|
|
156
|
+
}] } });
|
|
157
|
+
} }
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { rimelightCms };
|