@kidecms/core 0.1.11 → 0.14.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 +86 -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 +623 -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 +31 -0
- package/internals/push.ts +160 -0
- package/internals/reindex.ts +11 -0
- package/internals/restore.ts +257 -0
- package/internals/seed.ts +15 -0
- package/internals/upgrade.ts +785 -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/{pages/admin/login.astro → admin/forgot-password.astro} +21 -19
- package/routes/{pages/admin → admin}/invite.astro +13 -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 +67 -15
- 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 +34 -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/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/admin.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { richTextToPlainText } from "./values";
|
|
2
|
-
const DEFAULT_DATE_FORMAT = "en-US";
|
|
3
|
-
let dateLocale = DEFAULT_DATE_FORMAT;
|
|
4
|
-
let timeZone;
|
|
5
|
-
export const initDateFormat = (config, nextTimeZone) => {
|
|
6
|
-
dateLocale = config.admin?.dateFormat ?? DEFAULT_DATE_FORMAT;
|
|
7
|
-
timeZone = nextTimeZone;
|
|
8
|
-
};
|
|
9
|
-
export const formatDate = (value) => {
|
|
10
|
-
if (!value)
|
|
11
|
-
return "—";
|
|
12
|
-
const date = new Date(String(value));
|
|
13
|
-
if (Number.isNaN(date.getTime()))
|
|
14
|
-
return String(value);
|
|
15
|
-
return date.toLocaleString(dateLocale, {
|
|
16
|
-
year: "numeric",
|
|
17
|
-
month: "numeric",
|
|
18
|
-
day: "numeric",
|
|
19
|
-
hour: "2-digit",
|
|
20
|
-
minute: "2-digit",
|
|
21
|
-
timeZone,
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export const resolveAdminRoute = (path) => {
|
|
25
|
-
const segments = (path ?? "").split("/").filter(Boolean);
|
|
26
|
-
if (segments.length === 0)
|
|
27
|
-
return { kind: "dashboard" };
|
|
28
|
-
if (segments[0] === "recent" && segments.length === 1)
|
|
29
|
-
return { kind: "recent" };
|
|
30
|
-
if (segments[0] === "singles" && segments.length === 1)
|
|
31
|
-
return { kind: "singles" };
|
|
32
|
-
if (segments.length === 1)
|
|
33
|
-
return { kind: "list", collectionSlug: segments[0] };
|
|
34
|
-
if (segments[1] === "new")
|
|
35
|
-
return { kind: "new", collectionSlug: segments[0] };
|
|
36
|
-
return {
|
|
37
|
-
kind: "edit",
|
|
38
|
-
collectionSlug: segments[0],
|
|
39
|
-
documentId: segments[1],
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
export const humanize = (value) => value
|
|
43
|
-
.replace(/^_+/, "")
|
|
44
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
45
|
-
.replace(/[-_]/g, " ")
|
|
46
|
-
.replace(/\s+/g, " ")
|
|
47
|
-
.trim()
|
|
48
|
-
.replace(/^\w/, (char) => char.toUpperCase());
|
|
49
|
-
export const formatFieldValue = (field, value, relationLabels = {}) => {
|
|
50
|
-
if (value === undefined || value === null || value === "")
|
|
51
|
-
return "—";
|
|
52
|
-
if (!field)
|
|
53
|
-
return String(value);
|
|
54
|
-
if (field.type === "richText") {
|
|
55
|
-
const text = richTextToPlainText(value);
|
|
56
|
-
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
57
|
-
}
|
|
58
|
-
if (field.type === "array") {
|
|
59
|
-
return Array.isArray(value) ? value.join(", ") : "—";
|
|
60
|
-
}
|
|
61
|
-
if (field.type === "json" || field.type === "blocks") {
|
|
62
|
-
return Array.isArray(value) ? `${value.length} items` : "JSON";
|
|
63
|
-
}
|
|
64
|
-
if (field.type === "boolean")
|
|
65
|
-
return value ? "Yes" : "No";
|
|
66
|
-
if (field.type === "relation") {
|
|
67
|
-
if (Array.isArray(value)) {
|
|
68
|
-
return value.map((entry) => relationLabels[String(entry)] ?? String(entry)).join(", ");
|
|
69
|
-
}
|
|
70
|
-
return relationLabels[String(value)] ?? String(value);
|
|
71
|
-
}
|
|
72
|
-
return String(value);
|
|
73
|
-
};
|
|
74
|
-
export const getListColumns = (collection, viewConfig) => {
|
|
75
|
-
if (viewConfig?.columns?.length) {
|
|
76
|
-
return collection.drafts ? viewConfig.columns : viewConfig.columns.filter((column) => column !== "_status");
|
|
77
|
-
}
|
|
78
|
-
const firstField = "title" in collection.fields ? "title" : Object.keys(collection.fields)[0];
|
|
79
|
-
return collection.drafts ? [firstField, "_status", "_updatedAt"] : [firstField, "_updatedAt"];
|
|
80
|
-
};
|
|
81
|
-
export const getFieldSets = (collection) => {
|
|
82
|
-
const allFields = Object.keys(collection.fields).filter((fieldName) => !collection.fields[fieldName].admin?.hidden);
|
|
83
|
-
const contentFields = allFields.filter((fieldName) => collection.fields[fieldName].admin?.position !== "sidebar");
|
|
84
|
-
const sidebarFields = allFields.filter((fieldName) => collection.fields[fieldName].admin?.position === "sidebar");
|
|
85
|
-
if (sidebarFields.length > 0) {
|
|
86
|
-
return [
|
|
87
|
-
{ fields: contentFields, position: "content" },
|
|
88
|
-
{ fields: sidebarFields, position: "sidebar" },
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
return [{ fields: contentFields, position: "content" }];
|
|
92
|
-
};
|
package/dist/ai.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare function isAiEnabled(): boolean;
|
|
2
|
-
export declare function getAiModel(): Promise<any>;
|
|
3
|
-
export declare function streamAltText(imageUrl: string, filename: string): Promise<any>;
|
|
4
|
-
export declare function streamSeoDescription(content: {
|
|
5
|
-
title: string;
|
|
6
|
-
excerpt?: string;
|
|
7
|
-
body?: string;
|
|
8
|
-
}): Promise<any>;
|
|
9
|
-
export declare function streamTranslation(content: {
|
|
10
|
-
text: string;
|
|
11
|
-
sourceLocale: string;
|
|
12
|
-
targetLocale: string;
|
|
13
|
-
fieldName: string;
|
|
14
|
-
fieldType: "text" | "richText" | "slug";
|
|
15
|
-
}): Promise<any>;
|
package/dist/ai.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { getStorage, readEnv } from "./runtime";
|
|
2
|
-
const getStreamText = async () => (await import("ai")).streamText;
|
|
3
|
-
export function isAiEnabled() {
|
|
4
|
-
return !!(readEnv("AI_PROVIDER") && readEnv("AI_API_KEY"));
|
|
5
|
-
}
|
|
6
|
-
export async function getAiModel() {
|
|
7
|
-
const provider = readEnv("AI_PROVIDER") || "openai";
|
|
8
|
-
const modelName = readEnv("AI_MODEL") || "gpt-4o-mini";
|
|
9
|
-
if (provider === "openai") {
|
|
10
|
-
const { createOpenAI } = await import("@ai-sdk/openai");
|
|
11
|
-
const openai = createOpenAI({ apiKey: readEnv("AI_API_KEY") });
|
|
12
|
-
return openai(modelName);
|
|
13
|
-
}
|
|
14
|
-
throw new Error(`Unsupported AI provider: ${provider}`);
|
|
15
|
-
}
|
|
16
|
-
export async function streamAltText(imageUrl, filename) {
|
|
17
|
-
const model = await getAiModel();
|
|
18
|
-
const image = await getStorage().getFile(imageUrl);
|
|
19
|
-
if (!image) {
|
|
20
|
-
throw new Error(`Image not found: ${imageUrl}`);
|
|
21
|
-
}
|
|
22
|
-
const streamText = await getStreamText();
|
|
23
|
-
return streamText({
|
|
24
|
-
model,
|
|
25
|
-
messages: [
|
|
26
|
-
{
|
|
27
|
-
role: "user",
|
|
28
|
-
content: [
|
|
29
|
-
{
|
|
30
|
-
type: "image",
|
|
31
|
-
image: new Uint8Array(image),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: "text",
|
|
35
|
-
text: `Generate a concise, descriptive alt text for this image (filename: ${filename}). The alt text should be suitable for accessibility purposes. Return only the alt text, no quotes or extra formatting.`,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
export async function streamSeoDescription(content) {
|
|
43
|
-
const model = await getAiModel();
|
|
44
|
-
const prompt = `Generate an SEO-optimized meta description (max 155 characters) for a page with the following content. Return only the description, no quotes or extra formatting.
|
|
45
|
-
|
|
46
|
-
Title: ${content.title}
|
|
47
|
-
${content.excerpt ? `Excerpt: ${content.excerpt}` : ""}
|
|
48
|
-
${content.body ? `Body preview: ${content.body.substring(0, 500)}` : ""}`;
|
|
49
|
-
const streamText = await getStreamText();
|
|
50
|
-
return streamText({ model, prompt });
|
|
51
|
-
}
|
|
52
|
-
export async function streamTranslation(content) {
|
|
53
|
-
const model = await getAiModel();
|
|
54
|
-
let prompt;
|
|
55
|
-
if (content.fieldType === "richText") {
|
|
56
|
-
prompt = `Translate the following rich text JSON AST from ${content.sourceLocale} to ${content.targetLocale}. Keep the exact same JSON structure, only translate the text values. Return only the valid JSON, no extra formatting or code blocks.
|
|
57
|
-
|
|
58
|
-
${content.text}`;
|
|
59
|
-
}
|
|
60
|
-
else if (content.fieldType === "slug") {
|
|
61
|
-
prompt = `Translate and create a URL-friendly slug in ${content.targetLocale} based on this ${content.sourceLocale} text: "${content.text}". Return only the slug (lowercase, hyphens instead of spaces, no special characters).`;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
prompt = `Translate the following text from ${content.sourceLocale} to ${content.targetLocale}. Return only the translated text, no quotes or extra formatting.
|
|
65
|
-
|
|
66
|
-
${content.text}`;
|
|
67
|
-
}
|
|
68
|
-
const streamText = await getStreamText();
|
|
69
|
-
return streamText({ model, prompt });
|
|
70
|
-
}
|
package/dist/api.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CMSConfig } from "./define";
|
|
2
|
-
export type FindOptions = {
|
|
3
|
-
where?: Record<string, unknown>;
|
|
4
|
-
sort?: {
|
|
5
|
-
field: string;
|
|
6
|
-
direction: "asc" | "desc";
|
|
7
|
-
};
|
|
8
|
-
limit?: number;
|
|
9
|
-
offset?: number;
|
|
10
|
-
status?: "draft" | "published" | "scheduled" | "any";
|
|
11
|
-
locale?: string;
|
|
12
|
-
search?: string;
|
|
13
|
-
};
|
|
14
|
-
export declare const createCms: (config: CMSConfig) => any;
|