@kidecms/core 0.1.10 → 0.13.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/LICENSE +21 -0
- package/admin/components/AssetsGrid.tsx +366 -173
- package/admin/components/BlockEditor.tsx +260 -679
- package/admin/components/CheckboxField.tsx +2 -2
- package/admin/components/CollaborationReviewBar.tsx +384 -0
- package/admin/components/ColorField.tsx +87 -0
- package/admin/components/CommandPalette.tsx +169 -0
- package/admin/components/ContentEditor.tsx +687 -0
- package/admin/components/DocumentActions.tsx +4 -2
- package/admin/components/DocumentsDataTable.tsx +91 -10
- package/admin/components/FieldControl.astro +151 -26
- package/admin/components/FocalPointSelector.tsx +27 -1
- package/admin/components/InternalLinkPicker.tsx +4 -3
- package/admin/components/LinkField.tsx +126 -0
- package/admin/components/RelationField.tsx +105 -26
- package/admin/components/RepeaterInput.tsx +46 -0
- package/admin/components/RichTextEditor.tsx +44 -9
- package/admin/components/SharedSectionBlockField.tsx +93 -0
- package/admin/components/SidebarUserMenu.tsx +1 -1
- package/admin/components/Toast.astro +1 -1
- package/admin/components/TreeItemsEditor.tsx +20 -19
- package/admin/components/TreeSelect.tsx +2 -2
- package/admin/components/YoutubeField.tsx +48 -0
- package/admin/components/block-fields.tsx +777 -0
- package/admin/components/content-block-spec.ts +114 -0
- package/admin/components/slash-command.tsx +242 -0
- package/admin/components/tree-utils.ts +14 -2
- package/admin/components/ui/badge.tsx +2 -3
- package/admin/components/ui/button.tsx +5 -4
- package/admin/components/ui/checkbox.tsx +1 -1
- package/admin/components/ui/input.tsx +1 -1
- package/admin/components/ui/select.tsx +1 -1
- package/admin/components/ui/table.tsx +1 -1
- package/admin/components/ui/textarea.tsx +1 -1
- package/admin/layouts/AdminLayout.astro +323 -123
- package/admin/lib/access.ts +54 -0
- package/admin/lib/collaboration.ts +178 -0
- package/admin/lib/edit-data.ts +448 -0
- package/admin/views/AccessDeniedView.astro +8 -0
- package/admin/views/EditView.astro +706 -0
- package/admin/views/ListView.astro +202 -0
- package/admin/views/RecentView.astro +76 -0
- package/admin/views/SinglesView.astro +65 -0
- package/admin/views/edit/EditScripts.astro +145 -0
- package/admin/views/edit/ReverseReferencesList.astro +68 -0
- package/core/admin.ts +193 -0
- package/core/ai.ts +87 -0
- package/core/api.ts +1392 -0
- package/core/assets.ts +336 -0
- package/core/audit.ts +84 -0
- package/core/auth-config.ts +44 -0
- package/core/auth.ts +303 -0
- package/core/collaboration.ts +276 -0
- package/core/content.ts +27 -0
- package/core/create-admin.ts +28 -0
- package/core/define.ts +625 -0
- package/core/field-model.ts +172 -0
- package/core/generator.ts +519 -0
- package/core/http.ts +42 -0
- package/core/image.ts +219 -0
- package/core/index.ts +211 -0
- package/core/locks.ts +52 -0
- package/core/log.ts +37 -0
- package/core/migrate.ts +278 -0
- package/core/rate-limit.ts +110 -0
- package/core/request-scope.ts +33 -0
- package/core/richtext.ts +1 -0
- package/core/runtime.ts +63 -0
- package/core/schema.ts +32 -0
- package/core/search.ts +489 -0
- package/core/seed.ts +101 -0
- package/core/shared-sections.ts +96 -0
- package/core/tasks.ts +176 -0
- package/core/values.ts +433 -0
- package/core/webhooks.ts +85 -0
- package/core/youtube.ts +39 -0
- package/internals/cli.mjs +34 -0
- package/internals/context.ts +67 -0
- package/internals/create-admin.ts +40 -0
- package/internals/describe.ts +25 -0
- package/internals/eject.ts +144 -0
- package/internals/generator.ts +11 -0
- package/internals/integration.ts +481 -0
- package/internals/mcp.ts +397 -0
- package/internals/project.ts +26 -0
- package/internals/push.ts +160 -0
- package/internals/reindex.ts +11 -0
- package/internals/restore.ts +257 -0
- package/internals/seed.data.ts +7 -0
- package/internals/seed.ts +11 -0
- package/internals/upgrade.ts +776 -0
- package/{virtual.d.ts → internals/virtual.d.ts} +39 -5
- package/middleware/auth.ts +130 -17
- package/middleware/push.ts +121 -0
- package/package.json +55 -67
- package/platform/cloudflare/cf-env.ts +60 -0
- package/platform/cloudflare/database.ts +28 -0
- package/platform/cloudflare/globals.d.ts +5 -0
- package/platform/cloudflare/storage.ts +33 -0
- package/platform/cloudflare/uploads-route.ts +37 -0
- package/platform/node/database.ts +39 -0
- package/platform/node/storage.ts +52 -0
- package/routes/admin/[...path].astro +71 -0
- package/routes/{pages/admin → admin}/assets/[id].astro +25 -19
- package/routes/admin/assets/index.astro +90 -0
- package/routes/admin/forgot-password.astro +60 -0
- package/routes/{pages/admin → admin}/invite.astro +7 -6
- package/routes/admin/login.astro +103 -0
- package/routes/admin/reset-password.astro +73 -0
- package/routes/{pages/admin → admin}/setup.astro +32 -8
- package/routes/api/{cms/[collection] → [collection]}/[...path].ts +66 -14
- package/routes/api/admin/search.ts +89 -0
- package/routes/api/{cms/assets → assets}/[id].ts +24 -14
- package/routes/api/{cms/assets → assets}/index.ts +4 -2
- package/routes/api/assets/upload.ts +147 -0
- package/routes/api/auth/forgot-password.ts +77 -0
- package/routes/api/{cms/auth → auth}/invite.ts +41 -9
- package/routes/api/auth/login.ts +167 -0
- package/routes/api/{cms/auth → auth}/logout.ts +11 -2
- package/routes/api/auth/reset-password.ts +85 -0
- package/routes/api/auth/setup.ts +110 -0
- package/routes/api/auth/sso/[provider]/start.ts +34 -0
- package/routes/api/collaboration/index.ts +106 -0
- package/routes/api/cron/_authorize.ts +25 -0
- package/routes/api/{cms/cron → cron}/publish.ts +3 -9
- package/routes/api/cron/tasks.ts +33 -0
- package/routes/api/forms/submit/[slug].ts +143 -0
- package/routes/api/img/[...path].ts +65 -0
- package/routes/api/{cms/preview → preview}/render.ts +8 -3
- package/routes/api/{cms/references → references}/[collection]/[id].ts +31 -1
- package/routes/api/webhooks/[provider].ts +54 -0
- package/README.md +0 -28
- package/dist/admin.d.ts +0 -33
- package/dist/admin.js +0 -92
- package/dist/ai.d.ts +0 -15
- package/dist/ai.js +0 -70
- package/dist/api.d.ts +0 -14
- package/dist/api.js +0 -833
- package/dist/assets.d.ts +0 -51
- package/dist/assets.js +0 -163
- package/dist/auth.d.ts +0 -30
- package/dist/auth.js +0 -132
- package/dist/content.d.ts +0 -3
- package/dist/content.js +0 -29
- package/dist/create-admin.d.ts +0 -5
- package/dist/create-admin.js +0 -23
- package/dist/define.d.ts +0 -254
- package/dist/define.js +0 -36
- package/dist/generator.d.ts +0 -9
- package/dist/generator.js +0 -370
- package/dist/image.d.ts +0 -9
- package/dist/image.js +0 -69
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -16
- package/dist/integration.d.ts +0 -14
- package/dist/integration.js +0 -327
- package/dist/locks.d.ts +0 -7
- package/dist/locks.js +0 -37
- package/dist/richtext.d.ts +0 -1
- package/dist/richtext.js +0 -1
- package/dist/runtime.d.ts +0 -24
- package/dist/runtime.js +0 -26
- package/dist/schema.d.ts +0 -17
- package/dist/schema.js +0 -13
- package/dist/seed.d.ts +0 -2
- package/dist/seed.js +0 -84
- package/dist/values.d.ts +0 -8
- package/dist/values.js +0 -102
- package/dist/webhooks.d.ts +0 -2
- package/dist/webhooks.js +0 -73
- package/routes/api/cms/assets/upload.ts +0 -112
- package/routes/api/cms/auth/login.ts +0 -124
- package/routes/api/cms/auth/setup.ts +0 -77
- package/routes/api/cms/img/[...path].ts +0 -24
- package/routes/pages/admin/[...path].astro +0 -1107
- package/routes/pages/admin/assets/index.astro +0 -63
- package/routes/pages/admin/login.astro +0 -57
- /package/routes/api/{cms/ai → ai}/alt-text.ts +0 -0
- /package/routes/api/{cms/ai → ai}/seo.ts +0 -0
- /package/routes/api/{cms/ai → ai}/translate.ts +0 -0
- /package/routes/api/{cms/assets → assets}/folders.ts +0 -0
- /package/routes/api/{cms/locks → locks}/[...path].ts +0 -0
package/dist/image.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const ALLOWED_WIDTHS = [320, 480, 640, 768, 960, 1024, 1280, 1536, 1920];
|
|
2
|
-
const ALLOWED_FORMATS = ["webp", "avif", "jpeg", "png"];
|
|
3
|
-
function clampWidth(width) {
|
|
4
|
-
return ALLOWED_WIDTHS.reduce((prev, curr) => (Math.abs(curr - width) < Math.abs(prev - width) ? curr : prev));
|
|
5
|
-
}
|
|
6
|
-
function isCloudflare() {
|
|
7
|
-
return typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers";
|
|
8
|
-
}
|
|
9
|
-
export function cmsImage(src, width, format = "webp") {
|
|
10
|
-
if (!src)
|
|
11
|
-
return "";
|
|
12
|
-
if (isCloudflare()) {
|
|
13
|
-
const parts = [];
|
|
14
|
-
if (width)
|
|
15
|
-
parts.push(`width=${clampWidth(width)}`);
|
|
16
|
-
parts.push(`format=${format}`);
|
|
17
|
-
parts.push("quality=80");
|
|
18
|
-
return `/cdn-cgi/image/${parts.join(",")}${src}`;
|
|
19
|
-
}
|
|
20
|
-
const params = new URLSearchParams();
|
|
21
|
-
if (width)
|
|
22
|
-
params.set("w", String(clampWidth(width)));
|
|
23
|
-
if (format !== "webp")
|
|
24
|
-
params.set("f", format);
|
|
25
|
-
const qs = params.toString();
|
|
26
|
-
return `/api/cms/img${src}${qs ? `?${qs}` : ""}`;
|
|
27
|
-
}
|
|
28
|
-
export function cmsSrcset(src, widths = [480, 768, 1024, 1280], format = "webp") {
|
|
29
|
-
if (!src)
|
|
30
|
-
return "";
|
|
31
|
-
return widths.map((width) => `${cmsImage(src, width, format)} ${width}w`).join(", ");
|
|
32
|
-
}
|
|
33
|
-
export async function transformImage(src, width, format, quality) {
|
|
34
|
-
const { existsSync, mkdirSync, readFileSync } = await import("node:fs");
|
|
35
|
-
const { writeFile } = await import("node:fs/promises");
|
|
36
|
-
const path = await import("node:path");
|
|
37
|
-
const sharpModule = "sharp";
|
|
38
|
-
const sharp = (await import(/* @vite-ignore */ sharpModule)).default;
|
|
39
|
-
const publicDir = path.join(process.cwd(), "public");
|
|
40
|
-
const cacheDir = path.join(process.cwd(), ".cms-cache", "img");
|
|
41
|
-
const filePath = path.join(publicDir, src);
|
|
42
|
-
if (!existsSync(filePath))
|
|
43
|
-
return null;
|
|
44
|
-
const resolvedFormat = ALLOWED_FORMATS.includes(format) ? format : "webp";
|
|
45
|
-
const resolvedWidth = width ? clampWidth(width) : undefined;
|
|
46
|
-
const resolvedQuality = quality ?? 80;
|
|
47
|
-
if (!existsSync(cacheDir))
|
|
48
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
49
|
-
const safeName = src.replace(/[^a-zA-Z0-9.-]/g, "_");
|
|
50
|
-
const cacheKey = `${safeName}_${resolvedWidth ?? 0}.${resolvedFormat}`;
|
|
51
|
-
const cachePath = path.join(cacheDir, cacheKey);
|
|
52
|
-
if (existsSync(cachePath)) {
|
|
53
|
-
return {
|
|
54
|
-
buffer: readFileSync(cachePath),
|
|
55
|
-
contentType: `image/${resolvedFormat === "jpeg" ? "jpeg" : resolvedFormat}`,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
let pipeline = sharp(readFileSync(filePath));
|
|
59
|
-
if (resolvedWidth) {
|
|
60
|
-
pipeline = pipeline.resize(resolvedWidth, undefined, { withoutEnlargement: true });
|
|
61
|
-
}
|
|
62
|
-
pipeline = pipeline.toFormat(resolvedFormat, { quality: resolvedQuality });
|
|
63
|
-
const buffer = await pipeline.toBuffer();
|
|
64
|
-
writeFile(cachePath, buffer).catch(() => { });
|
|
65
|
-
return {
|
|
66
|
-
buffer,
|
|
67
|
-
contentType: `image/${resolvedFormat === "jpeg" ? "jpeg" : resolvedFormat}`,
|
|
68
|
-
};
|
|
69
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { configureCmsRuntime, resetCmsRuntime, getCmsRuntime, getDb, closeDb, getStorage, getEmail, readEnv, } from "./runtime";
|
|
2
|
-
export type { CmsRuntimeConfig, CmsStorageAdapter, CmsEmailAdapter } from "./runtime";
|
|
3
|
-
export { initSchema, getSchema, resetSchema } from "./schema";
|
|
4
|
-
export { fields, defineCollection, defineConfig, getCollectionMap, getDefaultLocale, getTranslatableFieldNames, isStructuralField, getCollectionLabel, getLabelField, hasRole, } from "./define";
|
|
5
|
-
export type { CMSConfig, CollectionConfig, CollectionFieldMap, FieldConfig, TextFieldConfig, SlugFieldConfig, EmailFieldConfig, NumberFieldConfig, BooleanFieldConfig, DateFieldConfig, SelectFieldConfig, RichTextFieldConfig, ImageFieldConfig, RelationFieldConfig, ArrayFieldConfig, JsonFieldConfig, BlocksFieldConfig, RichTextNode, RichTextDocument, CollectionLabels, DatabaseConfig, LocaleConfig, AdminConfig, AdminNavItem, WebhookConfig, WebhookEvent, WebhookContext, AdminFieldComponent, FieldCondition, SeedDocument, CollectionViewConfig, AccessContext, AccessRule, CollectionAccess, HookContext, CollectionHooks, } from "./define";
|
|
6
|
-
export { createCms } from "./api";
|
|
7
|
-
export type { FindOptions } from "./api";
|
|
8
|
-
export type CustomFieldProps = {
|
|
9
|
-
name: string;
|
|
10
|
-
field: import("./define").FieldConfig;
|
|
11
|
-
value: string;
|
|
12
|
-
readOnly: boolean;
|
|
13
|
-
};
|
|
14
|
-
export { hashPassword, verifyPassword, createSession, validateSession, destroySession, getSessionUser, createInvite, validateInvite, consumeInvite, SESSION_COOKIE_NAME, setSessionCookie, clearSessionCookie, } from "./auth";
|
|
15
|
-
export type { SessionUser } from "./auth";
|
|
16
|
-
export { assets, folders } from "./assets";
|
|
17
|
-
export type { AssetRecord, FolderRecord } from "./assets";
|
|
18
|
-
export { parseBlocks, parseList, cacheTags } from "./content";
|
|
19
|
-
export { renderRichText, createRichTextFromPlainText, richTextToPlainText } from "./richtext";
|
|
20
|
-
export { cloneValue, slugify, escapeHtml, serializeFieldValue } from "./values";
|
|
21
|
-
export { cmsImage, cmsSrcset, transformImage } from "./image";
|
|
22
|
-
export { initDateFormat, formatDate, resolveAdminRoute, humanize, formatFieldValue, getListColumns, getFieldSets, } from "./admin";
|
|
23
|
-
export type { AdminRoute } from "./admin";
|
|
24
|
-
export { acquireLock, releaseLock } from "./locks";
|
|
25
|
-
export { isAiEnabled, getAiModel, streamAltText, streamSeoDescription, streamTranslation } from "./ai";
|
|
26
|
-
export { generate } from "./generator";
|
|
27
|
-
export { seedDatabase } from "./seed";
|
|
28
|
-
export { createAdminUser } from "./create-admin";
|
package/dist/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { configureCmsRuntime, resetCmsRuntime, getCmsRuntime, getDb, closeDb, getStorage, getEmail, readEnv, } from "./runtime";
|
|
2
|
-
export { initSchema, getSchema, resetSchema } from "./schema";
|
|
3
|
-
export { fields, defineCollection, defineConfig, getCollectionMap, getDefaultLocale, getTranslatableFieldNames, isStructuralField, getCollectionLabel, getLabelField, hasRole, } from "./define";
|
|
4
|
-
export { createCms } from "./api";
|
|
5
|
-
export { hashPassword, verifyPassword, createSession, validateSession, destroySession, getSessionUser, createInvite, validateInvite, consumeInvite, SESSION_COOKIE_NAME, setSessionCookie, clearSessionCookie, } from "./auth";
|
|
6
|
-
export { assets, folders } from "./assets";
|
|
7
|
-
export { parseBlocks, parseList, cacheTags } from "./content";
|
|
8
|
-
export { renderRichText, createRichTextFromPlainText, richTextToPlainText } from "./richtext";
|
|
9
|
-
export { cloneValue, slugify, escapeHtml, serializeFieldValue } from "./values";
|
|
10
|
-
export { cmsImage, cmsSrcset, transformImage } from "./image";
|
|
11
|
-
export { initDateFormat, formatDate, resolveAdminRoute, humanize, formatFieldValue, getListColumns, getFieldSets, } from "./admin";
|
|
12
|
-
export { acquireLock, releaseLock } from "./locks";
|
|
13
|
-
export { isAiEnabled, getAiModel, streamAltText, streamSeoDescription, streamTranslation } from "./ai";
|
|
14
|
-
export { generate } from "./generator";
|
|
15
|
-
export { seedDatabase } from "./seed";
|
|
16
|
-
export { createAdminUser } from "./create-admin";
|
package/dist/integration.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AstroIntegration } from "astro";
|
|
2
|
-
export interface CmsIntegrationOptions {
|
|
3
|
-
/** Path to the CMS config file (default: "src/cms/cms.config") */
|
|
4
|
-
configPath?: string;
|
|
5
|
-
/** Path to the CMS runtime file (default: "src/cms/runtime") */
|
|
6
|
-
runtimePath?: string;
|
|
7
|
-
/** Path to the generated output directory (default: "src/cms/.generated") */
|
|
8
|
-
generatedPath?: string;
|
|
9
|
-
/** Path to the adapters directory (default: "src/cms/adapters") */
|
|
10
|
-
adaptersPath?: string;
|
|
11
|
-
/** Path to the generator script (default: "src/cms/generator.ts") */
|
|
12
|
-
generatorPath?: string;
|
|
13
|
-
}
|
|
14
|
-
export default function cmsIntegration(options?: CmsIntegrationOptions): AstroIntegration;
|
package/dist/integration.js
DELETED
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, watch, writeFileSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
function runGenerator(cwd, generatorPath) {
|
|
6
|
-
execSync(`node --import tsx ${generatorPath}`, {
|
|
7
|
-
stdio: "inherit",
|
|
8
|
-
cwd,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
function pushSchema(cwd) {
|
|
12
|
-
execSync("npx drizzle-kit push --force", {
|
|
13
|
-
stdio: "inherit",
|
|
14
|
-
cwd,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function isCloudflareD1(cwd) {
|
|
18
|
-
const wranglerPath = path.join(cwd, "wrangler.toml");
|
|
19
|
-
if (!existsSync(wranglerPath))
|
|
20
|
-
return false;
|
|
21
|
-
try {
|
|
22
|
-
const content = readFileSync(wranglerPath, "utf-8");
|
|
23
|
-
return content.includes("[[d1_databases]]");
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function hasLocalD1Database(cwd) {
|
|
30
|
-
const dir = path.join(cwd, ".wrangler/state/v3/d1/miniflare-D1DatabaseObject");
|
|
31
|
-
try {
|
|
32
|
-
return readdirSync(dir).some((file) => file.endsWith(".sqlite") && file !== "*.sqlite");
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function getD1DatabaseName(cwd) {
|
|
39
|
-
const wranglerPath = path.join(cwd, "wrangler.toml");
|
|
40
|
-
try {
|
|
41
|
-
const content = readFileSync(wranglerPath, "utf-8");
|
|
42
|
-
const match = content.match(/database_name\s*=\s*"([^"]+)"/);
|
|
43
|
-
return match ? match[1] : null;
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function initLocalD1(cwd) {
|
|
50
|
-
const dbName = getD1DatabaseName(cwd);
|
|
51
|
-
if (!dbName)
|
|
52
|
-
throw new Error("No database_name found in wrangler.toml");
|
|
53
|
-
execSync(`npx wrangler d1 execute "${dbName}" --local --command="SELECT 1"`, {
|
|
54
|
-
stdio: "pipe",
|
|
55
|
-
cwd,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
export default function cmsIntegration(options) {
|
|
59
|
-
const configPath = options?.configPath ?? "src/cms/cms.config";
|
|
60
|
-
const runtimePath = options?.runtimePath ?? "src/cms/internals/runtime";
|
|
61
|
-
const generatedPath = options?.generatedPath ?? "src/cms/.generated";
|
|
62
|
-
const adaptersPath = options?.adaptersPath ?? "src/cms/adapters";
|
|
63
|
-
const generatorPath = options?.generatorPath ?? "src/cms/internals/generator.ts";
|
|
64
|
-
return {
|
|
65
|
-
name: "kide-cms",
|
|
66
|
-
hooks: {
|
|
67
|
-
"astro:config:setup": ({ command, updateConfig, injectRoute, injectScript, addMiddleware }) => {
|
|
68
|
-
const root = process.cwd();
|
|
69
|
-
// Generate a wrapper CSS that adds @source directives and imports user's admin CSS
|
|
70
|
-
const corePkgDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
71
|
-
const adminDir = path.join(corePkgDir, "admin");
|
|
72
|
-
const routesDir = path.join(corePkgDir, "routes");
|
|
73
|
-
// Find tw-animate-css — pnpm may hoist it anywhere in the dep tree
|
|
74
|
-
const findTwAnimate = () => {
|
|
75
|
-
const candidates = [
|
|
76
|
-
path.join(corePkgDir, "node_modules", "tw-animate-css", "dist", "tw-animate.css"),
|
|
77
|
-
path.join(root, "node_modules", "tw-animate-css", "dist", "tw-animate.css"),
|
|
78
|
-
];
|
|
79
|
-
// Walk up from corePkgDir
|
|
80
|
-
let dir = corePkgDir;
|
|
81
|
-
while (dir !== path.dirname(dir)) {
|
|
82
|
-
candidates.push(path.join(dir, "node_modules", "tw-animate-css", "dist", "tw-animate.css"));
|
|
83
|
-
dir = path.dirname(dir);
|
|
84
|
-
}
|
|
85
|
-
for (const candidate of candidates) {
|
|
86
|
-
if (existsSync(candidate))
|
|
87
|
-
return candidate;
|
|
88
|
-
}
|
|
89
|
-
return candidates[0];
|
|
90
|
-
};
|
|
91
|
-
const twAnimateCssPath = findTwAnimate();
|
|
92
|
-
const userAdminCss = path.resolve(root, "src/styles/admin.css");
|
|
93
|
-
const generatedDir = path.join(root, "node_modules", ".kide");
|
|
94
|
-
mkdirSync(generatedDir, { recursive: true });
|
|
95
|
-
const wrapperCss = path.join(generatedDir, "admin.css");
|
|
96
|
-
writeFileSync(wrapperCss, [
|
|
97
|
-
`@source "${adminDir}";`,
|
|
98
|
-
`@source "${routesDir}";`,
|
|
99
|
-
`@import "${twAnimateCssPath}";`,
|
|
100
|
-
`@import "${userAdminCss}";`,
|
|
101
|
-
"",
|
|
102
|
-
"/* shadcn component styles (accordion, state variants) */",
|
|
103
|
-
"@theme inline {",
|
|
104
|
-
" @keyframes accordion-down { from { height: 0 } to { height: var(--radix-accordion-content-height, var(--accordion-panel-height, auto)) } }",
|
|
105
|
-
" @keyframes accordion-up { from { height: var(--radix-accordion-content-height, var(--accordion-panel-height, auto)) } to { height: 0 } }",
|
|
106
|
-
"}",
|
|
107
|
-
'@custom-variant data-open { &:where([data-state="open"]), &:where([data-open]:not([data-open="false"])) { @slot; } }',
|
|
108
|
-
'@custom-variant data-closed { &:where([data-state="closed"]), &:where([data-closed]:not([data-closed="false"])) { @slot; } }',
|
|
109
|
-
'@custom-variant data-checked { &:where([data-state="checked"]), &:where([data-checked]:not([data-checked="false"])) { @slot; } }',
|
|
110
|
-
'@custom-variant data-unchecked { &:where([data-state="unchecked"]), &:where([data-unchecked]:not([data-unchecked="false"])) { @slot; } }',
|
|
111
|
-
'@custom-variant data-selected { &:where([data-selected="true"]) { @slot; } }',
|
|
112
|
-
'@custom-variant data-disabled { &:where([data-disabled="true"]), &:where([data-disabled]:not([data-disabled="false"])) { @slot; } }',
|
|
113
|
-
'@custom-variant data-active { &:where([data-state="active"]), &:where([data-active]:not([data-active="false"])) { @slot; } }',
|
|
114
|
-
'@custom-variant data-horizontal { &:where([data-orientation="horizontal"]) { @slot; } }',
|
|
115
|
-
'@custom-variant data-vertical { &:where([data-orientation="vertical"]) { @slot; } }',
|
|
116
|
-
"@utility no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; &::-webkit-scrollbar { display: none; } }",
|
|
117
|
-
"",
|
|
118
|
-
].join("\n"));
|
|
119
|
-
// Generate custom field components barrel
|
|
120
|
-
const customFieldsDir = path.resolve(root, "src/cms/admin/fields");
|
|
121
|
-
const customFieldsBarrel = path.join(generatedDir, "custom-fields.ts");
|
|
122
|
-
const generateFieldsBarrel = () => {
|
|
123
|
-
if (existsSync(customFieldsDir)) {
|
|
124
|
-
const files = readdirSync(customFieldsDir).filter((f) => f.endsWith(".tsx"));
|
|
125
|
-
const imports = files.map((f) => {
|
|
126
|
-
const name = f.replace(".tsx", "");
|
|
127
|
-
return ` "${name}": (await import("${path.join(customFieldsDir, f)}")).default,`;
|
|
128
|
-
});
|
|
129
|
-
writeFileSync(customFieldsBarrel, `export const customFields: Record<string, any> = {\n${imports.join("\n")}\n};\n`);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
writeFileSync(customFieldsBarrel, "export const customFields: Record<string, any> = {};\n");
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
generateFieldsBarrel();
|
|
136
|
-
// Virtual module aliases — resolve route imports to the user's app files
|
|
137
|
-
updateConfig({
|
|
138
|
-
vite: {
|
|
139
|
-
resolve: {
|
|
140
|
-
alias: {
|
|
141
|
-
"virtual:kide/config": path.resolve(root, configPath),
|
|
142
|
-
"virtual:kide/api": path.resolve(root, generatedPath, "api"),
|
|
143
|
-
"virtual:kide/schema": path.resolve(root, generatedPath, "schema"),
|
|
144
|
-
"virtual:kide/runtime": path.resolve(root, runtimePath),
|
|
145
|
-
"virtual:kide/db": path.resolve(root, adaptersPath, "db"),
|
|
146
|
-
"virtual:kide/email": path.resolve(root, adaptersPath, "email"),
|
|
147
|
-
"virtual:kide/block-renderer": path.resolve(root, "src/components/BlockRenderer.astro"),
|
|
148
|
-
"virtual:kide/admin-css": wrapperCss,
|
|
149
|
-
"virtual:kide/custom-fields": customFieldsBarrel,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
// Pre-bundle admin component deps. Without this, Vite's dep scanner skips
|
|
153
|
-
// the admin/ source (it lives in node_modules), so packages like @tiptap/react
|
|
154
|
-
// are served raw — and their CJS sub-deps (use-sync-external-store/shim) break
|
|
155
|
-
// browser ESM imports. Use "@kidecms/core > X" syntax so Vite resolves the
|
|
156
|
-
// packages through @kidecms/core's nested node_modules under pnpm.
|
|
157
|
-
optimizeDeps: {
|
|
158
|
-
include: [
|
|
159
|
-
"@kidecms/core > @tiptap/react",
|
|
160
|
-
"@kidecms/core > @tiptap/starter-kit",
|
|
161
|
-
"@kidecms/core > @tiptap/extension-image",
|
|
162
|
-
"@kidecms/core > @tiptap/extension-link",
|
|
163
|
-
"@kidecms/core > @tiptap/markdown",
|
|
164
|
-
"@kidecms/core > @tiptap/core",
|
|
165
|
-
"@kidecms/core > @dnd-kit/core",
|
|
166
|
-
"@kidecms/core > @dnd-kit/sortable",
|
|
167
|
-
"@kidecms/core > @dnd-kit/utilities",
|
|
168
|
-
"@kidecms/core > @radix-ui/react-dropdown-menu",
|
|
169
|
-
"@kidecms/core > @radix-ui/react-popover",
|
|
170
|
-
"@kidecms/core > @base-ui/react/alert-dialog",
|
|
171
|
-
"@kidecms/core > @base-ui/react/button",
|
|
172
|
-
"@kidecms/core > @base-ui/react/checkbox",
|
|
173
|
-
"@kidecms/core > @base-ui/react/collapsible",
|
|
174
|
-
"@kidecms/core > @base-ui/react/dialog",
|
|
175
|
-
"@kidecms/core > @base-ui/react/input",
|
|
176
|
-
"@kidecms/core > @base-ui/react/merge-props",
|
|
177
|
-
"@kidecms/core > @base-ui/react/select",
|
|
178
|
-
"@kidecms/core > @base-ui/react/separator",
|
|
179
|
-
"@kidecms/core > @base-ui/react/tooltip",
|
|
180
|
-
"@kidecms/core > @base-ui/react/use-render",
|
|
181
|
-
"@kidecms/core > @tanstack/react-table",
|
|
182
|
-
"@kidecms/core > class-variance-authority",
|
|
183
|
-
"@kidecms/core > clsx",
|
|
184
|
-
"@kidecms/core > cmdk",
|
|
185
|
-
"@kidecms/core > lucide-react",
|
|
186
|
-
"@kidecms/core > tailwind-merge",
|
|
187
|
-
],
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
// Inject admin pages
|
|
192
|
-
injectRoute({ pattern: "/admin/login", entrypoint: "@kidecms/core/routes/pages/admin/login.astro" });
|
|
193
|
-
injectRoute({ pattern: "/admin/setup", entrypoint: "@kidecms/core/routes/pages/admin/setup.astro" });
|
|
194
|
-
injectRoute({ pattern: "/admin/invite", entrypoint: "@kidecms/core/routes/pages/admin/invite.astro" });
|
|
195
|
-
injectRoute({ pattern: "/admin/assets", entrypoint: "@kidecms/core/routes/pages/admin/assets/index.astro" });
|
|
196
|
-
injectRoute({
|
|
197
|
-
pattern: "/admin/assets/[id]",
|
|
198
|
-
entrypoint: "@kidecms/core/routes/pages/admin/assets/[id].astro",
|
|
199
|
-
});
|
|
200
|
-
injectRoute({ pattern: "/admin/[...path]", entrypoint: "@kidecms/core/routes/pages/admin/[...path].astro" });
|
|
201
|
-
// Inject API routes
|
|
202
|
-
injectRoute({ pattern: "/api/cms/auth/login", entrypoint: "@kidecms/core/routes/api/cms/auth/login.ts" });
|
|
203
|
-
injectRoute({ pattern: "/api/cms/auth/logout", entrypoint: "@kidecms/core/routes/api/cms/auth/logout.ts" });
|
|
204
|
-
injectRoute({ pattern: "/api/cms/auth/setup", entrypoint: "@kidecms/core/routes/api/cms/auth/setup.ts" });
|
|
205
|
-
injectRoute({ pattern: "/api/cms/auth/invite", entrypoint: "@kidecms/core/routes/api/cms/auth/invite.ts" });
|
|
206
|
-
injectRoute({ pattern: "/api/cms/assets/upload", entrypoint: "@kidecms/core/routes/api/cms/assets/upload.ts" });
|
|
207
|
-
injectRoute({
|
|
208
|
-
pattern: "/api/cms/assets/folders",
|
|
209
|
-
entrypoint: "@kidecms/core/routes/api/cms/assets/folders.ts",
|
|
210
|
-
});
|
|
211
|
-
injectRoute({ pattern: "/api/cms/assets/[id]", entrypoint: "@kidecms/core/routes/api/cms/assets/[id].ts" });
|
|
212
|
-
injectRoute({ pattern: "/api/cms/assets", entrypoint: "@kidecms/core/routes/api/cms/assets/index.ts" });
|
|
213
|
-
injectRoute({ pattern: "/api/cms/ai/alt-text", entrypoint: "@kidecms/core/routes/api/cms/ai/alt-text.ts" });
|
|
214
|
-
injectRoute({ pattern: "/api/cms/ai/seo", entrypoint: "@kidecms/core/routes/api/cms/ai/seo.ts" });
|
|
215
|
-
injectRoute({ pattern: "/api/cms/ai/translate", entrypoint: "@kidecms/core/routes/api/cms/ai/translate.ts" });
|
|
216
|
-
injectRoute({ pattern: "/api/cms/cron/publish", entrypoint: "@kidecms/core/routes/api/cms/cron/publish.ts" });
|
|
217
|
-
injectRoute({
|
|
218
|
-
pattern: "/api/cms/locks/[...path]",
|
|
219
|
-
entrypoint: "@kidecms/core/routes/api/cms/locks/[...path].ts",
|
|
220
|
-
});
|
|
221
|
-
// Preview render route uses Astro Container API which depends on Vite internals.
|
|
222
|
-
// Only inject in dev mode — production builds (especially Cloudflare Workers) can't bundle it.
|
|
223
|
-
if (command === "dev") {
|
|
224
|
-
injectRoute({
|
|
225
|
-
pattern: "/api/cms/preview/render",
|
|
226
|
-
entrypoint: "@kidecms/core/routes/api/cms/preview/render.ts",
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
injectRoute({
|
|
230
|
-
pattern: "/api/cms/references/[collection]/[id]",
|
|
231
|
-
entrypoint: "@kidecms/core/routes/api/cms/references/[collection]/[id].ts",
|
|
232
|
-
});
|
|
233
|
-
injectRoute({ pattern: "/api/cms/img/[...path]", entrypoint: "@kidecms/core/routes/api/cms/img/[...path].ts" });
|
|
234
|
-
injectRoute({
|
|
235
|
-
pattern: "/api/cms/[collection]/[...path]",
|
|
236
|
-
entrypoint: "@kidecms/core/routes/api/cms/[collection]/[...path].ts",
|
|
237
|
-
});
|
|
238
|
-
// Inject auth middleware
|
|
239
|
-
addMiddleware({ entrypoint: "@kidecms/core/middleware/auth.ts", order: "pre" });
|
|
240
|
-
// Inject live-preview client script (no-op unless ?preview is in the URL)
|
|
241
|
-
const previewClient = path.join(corePkgDir, "client", "preview.ts");
|
|
242
|
-
injectScript("page", `import ${JSON.stringify(previewClient)};`);
|
|
243
|
-
// Generate schema, types, validators, and API
|
|
244
|
-
console.log(" [cms] Generating schema, types, validators, and API...");
|
|
245
|
-
try {
|
|
246
|
-
runGenerator(root, generatorPath);
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
console.error(" [cms] Generator failed:", error.message);
|
|
250
|
-
}
|
|
251
|
-
if (command === "dev") {
|
|
252
|
-
const useD1 = isCloudflareD1(root);
|
|
253
|
-
if (useD1) {
|
|
254
|
-
const isFirstRun = !hasLocalD1Database(root);
|
|
255
|
-
if (isFirstRun) {
|
|
256
|
-
console.log(" \x1b[36m[cms]\x1b[0m First run — setting up database...");
|
|
257
|
-
try {
|
|
258
|
-
initLocalD1(root);
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
console.error(" \x1b[31m[cms]\x1b[0m Failed to initialize D1:", error.message);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
pushSchema(root);
|
|
266
|
-
if (isFirstRun) {
|
|
267
|
-
console.log(" \x1b[36m[cms]\x1b[0m Database ready. Open /admin to create your admin account.");
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
catch (error) {
|
|
271
|
-
console.error(" \x1b[31m[cms]\x1b[0m Database setup failed:", error.message);
|
|
272
|
-
console.error(" \x1b[31m[cms]\x1b[0m Try running: npx drizzle-kit push --force");
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
const dbPath = path.join(root, "data", "cms.db");
|
|
277
|
-
const isFirstRun = !existsSync(dbPath);
|
|
278
|
-
if (isFirstRun) {
|
|
279
|
-
console.log(" \x1b[36m[cms]\x1b[0m First run — setting up database...");
|
|
280
|
-
}
|
|
281
|
-
try {
|
|
282
|
-
mkdirSync(path.join(root, "data"), { recursive: true });
|
|
283
|
-
pushSchema(root);
|
|
284
|
-
if (isFirstRun) {
|
|
285
|
-
console.log(" \x1b[36m[cms]\x1b[0m Database ready. Open /admin to create your admin account.");
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
console.error(" \x1b[31m[cms]\x1b[0m Database setup failed:", error.message);
|
|
290
|
-
console.error(" \x1b[31m[cms]\x1b[0m Try running: npx drizzle-kit push --force");
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
const configFilePath = path.join(root, configPath.replace(/\/?$/, ".ts"));
|
|
294
|
-
let debounceTimer = null;
|
|
295
|
-
watch(configFilePath, () => {
|
|
296
|
-
if (debounceTimer)
|
|
297
|
-
clearTimeout(debounceTimer);
|
|
298
|
-
debounceTimer = setTimeout(() => {
|
|
299
|
-
console.log(" [cms] Config changed, regenerating...");
|
|
300
|
-
try {
|
|
301
|
-
runGenerator(root, generatorPath);
|
|
302
|
-
pushSchema(root);
|
|
303
|
-
console.log(" [cms] Schema updated.");
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
console.error(" [cms] Regeneration failed:", error.message);
|
|
307
|
-
}
|
|
308
|
-
}, 500);
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
"astro:server:start": ({ address }) => {
|
|
313
|
-
const host = address.family === "IPv6" ? `[${address.address}]` : address.address;
|
|
314
|
-
const base = `http://${host === "[::1]" || host === "127.0.0.1" || host === "[::]" ? "localhost" : host}:${address.port}`;
|
|
315
|
-
console.log(` \x1b[36m[cms]\x1b[0m Admin panel: \x1b[36m${base}/admin\x1b[0m`);
|
|
316
|
-
},
|
|
317
|
-
"astro:build:done": () => {
|
|
318
|
-
const entryPath = path.join(process.cwd(), "dist/server/entry.mjs");
|
|
319
|
-
if (!existsSync(entryPath))
|
|
320
|
-
return;
|
|
321
|
-
let content = readFileSync(entryPath, "utf-8");
|
|
322
|
-
content = content.replace(/export\s*\{\s*(\w+)\s+as\s+default\s*\}/, (_, name) => `const _astroWorker = ${name};\nexport default {\n fetch: (...args) => _astroWorker.fetch(...args),\n async scheduled(event, env, ctx) {\n const headers = env.CRON_SECRET ? { Authorization: "Bearer " + env.CRON_SECRET } : {};\n const res = await _astroWorker.fetch(new Request("https://dummy/api/cms/cron/publish", { headers }), env, ctx);\n if (!res.ok) console.error("Cron publish failed:", res.status, await res.text());\n else console.log("Cron publish:", await res.text());\n }\n};`);
|
|
323
|
-
writeFileSync(entryPath, content);
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
};
|
|
327
|
-
}
|
package/dist/locks.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const acquireLock: (collection: string, documentId: string, userId: string, userEmail: string) => Promise<{
|
|
2
|
-
acquired: true;
|
|
3
|
-
} | {
|
|
4
|
-
acquired: false;
|
|
5
|
-
userEmail: string;
|
|
6
|
-
}>;
|
|
7
|
-
export declare const releaseLock: (collection: string, documentId: string, userId: string) => Promise<void>;
|
package/dist/locks.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { and, eq, lte } from "drizzle-orm";
|
|
2
|
-
import { nanoid } from "nanoid";
|
|
3
|
-
import { getDb } from "./runtime";
|
|
4
|
-
import { getSchema } from "./schema";
|
|
5
|
-
const LOCK_TTL_MS = 5 * 60 * 1000;
|
|
6
|
-
const getLockTable = () => getSchema().cmsLocks;
|
|
7
|
-
const isExpired = (lockedAt) => new Date(lockedAt).getTime() + LOCK_TTL_MS < Date.now();
|
|
8
|
-
export const acquireLock = async (collection, documentId, userId, userEmail) => {
|
|
9
|
-
const db = await getDb();
|
|
10
|
-
const table = getLockTable();
|
|
11
|
-
await db.delete(table).where(lte(table.lockedAt, new Date(Date.now() - LOCK_TTL_MS).toISOString()));
|
|
12
|
-
const rows = await db
|
|
13
|
-
.select()
|
|
14
|
-
.from(table)
|
|
15
|
-
.where(and(eq(table.collection, collection), eq(table.documentId, documentId)));
|
|
16
|
-
const existing = rows[0];
|
|
17
|
-
const now = new Date().toISOString();
|
|
18
|
-
if (existing) {
|
|
19
|
-
if (existing.userId === userId) {
|
|
20
|
-
await db.update(table).set({ lockedAt: now }).where(eq(table._id, existing._id));
|
|
21
|
-
return { acquired: true };
|
|
22
|
-
}
|
|
23
|
-
if (!isExpired(existing.lockedAt)) {
|
|
24
|
-
return { acquired: false, userEmail: existing.userEmail };
|
|
25
|
-
}
|
|
26
|
-
await db.delete(table).where(eq(table._id, existing._id));
|
|
27
|
-
}
|
|
28
|
-
await db.insert(table).values({ _id: nanoid(), collection, documentId, userId, userEmail, lockedAt: now });
|
|
29
|
-
return { acquired: true };
|
|
30
|
-
};
|
|
31
|
-
export const releaseLock = async (collection, documentId, userId) => {
|
|
32
|
-
const db = await getDb();
|
|
33
|
-
const table = getLockTable();
|
|
34
|
-
await db
|
|
35
|
-
.delete(table)
|
|
36
|
-
.where(and(eq(table.collection, collection), eq(table.documentId, documentId), eq(table.userId, userId)));
|
|
37
|
-
};
|
package/dist/richtext.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRichTextFromPlainText, renderRichText, richTextToPlainText } from "./values";
|
package/dist/richtext.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRichTextFromPlainText, renderRichText, richTextToPlainText } from "./values";
|
package/dist/runtime.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type CmsStorageAdapter = {
|
|
2
|
-
putFile: (storagePath: string, data: ArrayBuffer | Uint8Array) => Promise<void>;
|
|
3
|
-
getFile: (storagePath: string) => Promise<ArrayBuffer | null>;
|
|
4
|
-
deleteFile: (storagePath: string) => Promise<void>;
|
|
5
|
-
};
|
|
6
|
-
export type CmsEmailAdapter = {
|
|
7
|
-
sendInviteEmail: (to: string, inviteUrl: string) => Promise<boolean>;
|
|
8
|
-
isEmailConfigured: () => boolean;
|
|
9
|
-
};
|
|
10
|
-
export type CmsRuntimeConfig = {
|
|
11
|
-
getDb: () => Promise<any>;
|
|
12
|
-
closeDb?: () => void;
|
|
13
|
-
storage: CmsStorageAdapter;
|
|
14
|
-
email?: CmsEmailAdapter;
|
|
15
|
-
env?: (key: string) => string | undefined;
|
|
16
|
-
};
|
|
17
|
-
export declare const configureCmsRuntime: (config: CmsRuntimeConfig) => void;
|
|
18
|
-
export declare const resetCmsRuntime: () => void;
|
|
19
|
-
export declare const getCmsRuntime: () => CmsRuntimeConfig;
|
|
20
|
-
export declare const getDb: () => Promise<any>;
|
|
21
|
-
export declare const closeDb: () => void;
|
|
22
|
-
export declare const getStorage: () => CmsStorageAdapter;
|
|
23
|
-
export declare const getEmail: () => CmsEmailAdapter;
|
|
24
|
-
export declare const readEnv: (key: string) => string | undefined;
|
package/dist/runtime.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
let runtime = null;
|
|
2
|
-
const runtimeError = () => new Error("@kidecms/core runtime not initialized. Call configureCmsRuntime(...) and initSchema(...) from your app before using runtime APIs.");
|
|
3
|
-
export const configureCmsRuntime = (config) => {
|
|
4
|
-
runtime = config;
|
|
5
|
-
};
|
|
6
|
-
export const resetCmsRuntime = () => {
|
|
7
|
-
runtime = null;
|
|
8
|
-
};
|
|
9
|
-
export const getCmsRuntime = () => {
|
|
10
|
-
if (!runtime)
|
|
11
|
-
throw runtimeError();
|
|
12
|
-
return runtime;
|
|
13
|
-
};
|
|
14
|
-
export const getDb = () => getCmsRuntime().getDb();
|
|
15
|
-
export const closeDb = () => {
|
|
16
|
-
getCmsRuntime().closeDb?.();
|
|
17
|
-
};
|
|
18
|
-
export const getStorage = () => getCmsRuntime().storage;
|
|
19
|
-
export const getEmail = () => {
|
|
20
|
-
const email = getCmsRuntime().email;
|
|
21
|
-
return (email ?? {
|
|
22
|
-
sendInviteEmail: async () => false,
|
|
23
|
-
isEmailConfigured: () => false,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
export const readEnv = (key) => getCmsRuntime().env?.(key) ?? process.env[key];
|
package/dist/schema.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type SchemaModule = {
|
|
2
|
-
cmsTables: Record<string, {
|
|
3
|
-
main: any;
|
|
4
|
-
translations?: any;
|
|
5
|
-
versions?: any;
|
|
6
|
-
}>;
|
|
7
|
-
cmsAssets: any;
|
|
8
|
-
cmsAssetFolders: any;
|
|
9
|
-
cmsSessions: any;
|
|
10
|
-
cmsLocks: any;
|
|
11
|
-
cmsInvites: any;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
export declare const initSchema: (nextSchema: SchemaModule) => void;
|
|
15
|
-
export declare const resetSchema: () => void;
|
|
16
|
-
export declare const getSchema: () => SchemaModule;
|
|
17
|
-
export {};
|
package/dist/schema.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
let schema = null;
|
|
2
|
-
export const initSchema = (nextSchema) => {
|
|
3
|
-
schema = nextSchema;
|
|
4
|
-
};
|
|
5
|
-
export const resetSchema = () => {
|
|
6
|
-
schema = null;
|
|
7
|
-
};
|
|
8
|
-
export const getSchema = () => {
|
|
9
|
-
if (!schema) {
|
|
10
|
-
throw new Error("@kidecms/core schema not initialized. Call initSchema(...) from your app before using runtime APIs.");
|
|
11
|
-
}
|
|
12
|
-
return schema;
|
|
13
|
-
};
|
package/dist/seed.d.ts
DELETED