@kidecms/core 0.1.11 → 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.
Files changed (181) hide show
  1. package/LICENSE +21 -0
  2. package/admin/components/AssetsGrid.tsx +366 -173
  3. package/admin/components/BlockEditor.tsx +260 -679
  4. package/admin/components/CheckboxField.tsx +2 -2
  5. package/admin/components/CollaborationReviewBar.tsx +384 -0
  6. package/admin/components/ColorField.tsx +87 -0
  7. package/admin/components/CommandPalette.tsx +169 -0
  8. package/admin/components/ContentEditor.tsx +687 -0
  9. package/admin/components/DocumentActions.tsx +4 -2
  10. package/admin/components/DocumentsDataTable.tsx +91 -10
  11. package/admin/components/FieldControl.astro +151 -26
  12. package/admin/components/FocalPointSelector.tsx +27 -1
  13. package/admin/components/InternalLinkPicker.tsx +4 -3
  14. package/admin/components/LinkField.tsx +126 -0
  15. package/admin/components/RelationField.tsx +105 -26
  16. package/admin/components/RepeaterInput.tsx +46 -0
  17. package/admin/components/RichTextEditor.tsx +44 -9
  18. package/admin/components/SharedSectionBlockField.tsx +93 -0
  19. package/admin/components/SidebarUserMenu.tsx +1 -1
  20. package/admin/components/Toast.astro +1 -1
  21. package/admin/components/TreeItemsEditor.tsx +20 -19
  22. package/admin/components/TreeSelect.tsx +2 -2
  23. package/admin/components/YoutubeField.tsx +48 -0
  24. package/admin/components/block-fields.tsx +777 -0
  25. package/admin/components/content-block-spec.ts +114 -0
  26. package/admin/components/slash-command.tsx +242 -0
  27. package/admin/components/tree-utils.ts +14 -2
  28. package/admin/components/ui/badge.tsx +2 -3
  29. package/admin/components/ui/button.tsx +5 -4
  30. package/admin/components/ui/checkbox.tsx +1 -1
  31. package/admin/components/ui/input.tsx +1 -1
  32. package/admin/components/ui/select.tsx +1 -1
  33. package/admin/components/ui/table.tsx +1 -1
  34. package/admin/components/ui/textarea.tsx +1 -1
  35. package/admin/layouts/AdminLayout.astro +323 -123
  36. package/admin/lib/access.ts +54 -0
  37. package/admin/lib/collaboration.ts +178 -0
  38. package/admin/lib/edit-data.ts +448 -0
  39. package/admin/views/AccessDeniedView.astro +8 -0
  40. package/admin/views/EditView.astro +706 -0
  41. package/admin/views/ListView.astro +202 -0
  42. package/admin/views/RecentView.astro +76 -0
  43. package/admin/views/SinglesView.astro +65 -0
  44. package/admin/views/edit/EditScripts.astro +145 -0
  45. package/admin/views/edit/ReverseReferencesList.astro +68 -0
  46. package/core/admin.ts +193 -0
  47. package/core/ai.ts +87 -0
  48. package/core/api.ts +1392 -0
  49. package/core/assets.ts +336 -0
  50. package/core/audit.ts +84 -0
  51. package/core/auth-config.ts +44 -0
  52. package/core/auth.ts +303 -0
  53. package/core/collaboration.ts +276 -0
  54. package/core/content.ts +27 -0
  55. package/core/create-admin.ts +28 -0
  56. package/core/define.ts +625 -0
  57. package/core/field-model.ts +172 -0
  58. package/core/generator.ts +519 -0
  59. package/core/http.ts +42 -0
  60. package/core/image.ts +219 -0
  61. package/core/index.ts +211 -0
  62. package/core/locks.ts +52 -0
  63. package/core/log.ts +37 -0
  64. package/core/migrate.ts +278 -0
  65. package/core/rate-limit.ts +110 -0
  66. package/core/request-scope.ts +33 -0
  67. package/core/richtext.ts +1 -0
  68. package/core/runtime.ts +63 -0
  69. package/core/schema.ts +32 -0
  70. package/core/search.ts +489 -0
  71. package/core/seed.ts +101 -0
  72. package/core/shared-sections.ts +96 -0
  73. package/core/tasks.ts +176 -0
  74. package/core/values.ts +433 -0
  75. package/core/webhooks.ts +85 -0
  76. package/core/youtube.ts +39 -0
  77. package/internals/cli.mjs +34 -0
  78. package/internals/context.ts +67 -0
  79. package/internals/create-admin.ts +40 -0
  80. package/internals/describe.ts +25 -0
  81. package/internals/eject.ts +144 -0
  82. package/internals/generator.ts +11 -0
  83. package/internals/integration.ts +481 -0
  84. package/internals/mcp.ts +397 -0
  85. package/internals/project.ts +26 -0
  86. package/internals/push.ts +160 -0
  87. package/internals/reindex.ts +11 -0
  88. package/internals/restore.ts +257 -0
  89. package/internals/seed.data.ts +7 -0
  90. package/internals/seed.ts +11 -0
  91. package/internals/upgrade.ts +776 -0
  92. package/{virtual.d.ts → internals/virtual.d.ts} +39 -5
  93. package/middleware/auth.ts +130 -17
  94. package/middleware/push.ts +121 -0
  95. package/package.json +55 -67
  96. package/platform/cloudflare/cf-env.ts +60 -0
  97. package/platform/cloudflare/database.ts +28 -0
  98. package/platform/cloudflare/globals.d.ts +5 -0
  99. package/platform/cloudflare/storage.ts +33 -0
  100. package/platform/cloudflare/uploads-route.ts +37 -0
  101. package/platform/node/database.ts +39 -0
  102. package/platform/node/storage.ts +52 -0
  103. package/routes/admin/[...path].astro +71 -0
  104. package/routes/{pages/admin → admin}/assets/[id].astro +25 -19
  105. package/routes/admin/assets/index.astro +90 -0
  106. package/routes/{pages/admin/login.astro → admin/forgot-password.astro} +21 -19
  107. package/routes/{pages/admin → admin}/invite.astro +6 -6
  108. package/routes/admin/login.astro +103 -0
  109. package/routes/admin/reset-password.astro +73 -0
  110. package/routes/{pages/admin → admin}/setup.astro +31 -8
  111. package/routes/api/{cms/[collection] → [collection]}/[...path].ts +66 -14
  112. package/routes/api/admin/search.ts +89 -0
  113. package/routes/api/{cms/assets → assets}/[id].ts +24 -14
  114. package/routes/api/{cms/assets → assets}/index.ts +4 -2
  115. package/routes/api/assets/upload.ts +147 -0
  116. package/routes/api/auth/forgot-password.ts +77 -0
  117. package/routes/api/{cms/auth → auth}/invite.ts +41 -9
  118. package/routes/api/auth/login.ts +167 -0
  119. package/routes/api/{cms/auth → auth}/logout.ts +11 -2
  120. package/routes/api/auth/reset-password.ts +85 -0
  121. package/routes/api/auth/setup.ts +110 -0
  122. package/routes/api/auth/sso/[provider]/start.ts +34 -0
  123. package/routes/api/collaboration/index.ts +106 -0
  124. package/routes/api/cron/_authorize.ts +25 -0
  125. package/routes/api/{cms/cron → cron}/publish.ts +3 -9
  126. package/routes/api/cron/tasks.ts +33 -0
  127. package/routes/api/forms/submit/[slug].ts +143 -0
  128. package/routes/api/img/[...path].ts +65 -0
  129. package/routes/api/{cms/preview → preview}/render.ts +8 -3
  130. package/routes/api/{cms/references → references}/[collection]/[id].ts +31 -1
  131. package/routes/api/webhooks/[provider].ts +54 -0
  132. package/README.md +0 -28
  133. package/dist/admin.d.ts +0 -33
  134. package/dist/admin.js +0 -92
  135. package/dist/ai.d.ts +0 -15
  136. package/dist/ai.js +0 -70
  137. package/dist/api.d.ts +0 -14
  138. package/dist/api.js +0 -833
  139. package/dist/assets.d.ts +0 -51
  140. package/dist/assets.js +0 -163
  141. package/dist/auth.d.ts +0 -30
  142. package/dist/auth.js +0 -132
  143. package/dist/content.d.ts +0 -3
  144. package/dist/content.js +0 -29
  145. package/dist/create-admin.d.ts +0 -5
  146. package/dist/create-admin.js +0 -23
  147. package/dist/define.d.ts +0 -254
  148. package/dist/define.js +0 -36
  149. package/dist/generator.d.ts +0 -9
  150. package/dist/generator.js +0 -370
  151. package/dist/image.d.ts +0 -9
  152. package/dist/image.js +0 -69
  153. package/dist/index.d.ts +0 -28
  154. package/dist/index.js +0 -16
  155. package/dist/integration.d.ts +0 -14
  156. package/dist/integration.js +0 -327
  157. package/dist/locks.d.ts +0 -7
  158. package/dist/locks.js +0 -37
  159. package/dist/richtext.d.ts +0 -1
  160. package/dist/richtext.js +0 -1
  161. package/dist/runtime.d.ts +0 -24
  162. package/dist/runtime.js +0 -26
  163. package/dist/schema.d.ts +0 -17
  164. package/dist/schema.js +0 -13
  165. package/dist/seed.d.ts +0 -2
  166. package/dist/seed.js +0 -84
  167. package/dist/values.d.ts +0 -8
  168. package/dist/values.js +0 -102
  169. package/dist/webhooks.d.ts +0 -2
  170. package/dist/webhooks.js +0 -73
  171. package/routes/api/cms/assets/upload.ts +0 -112
  172. package/routes/api/cms/auth/login.ts +0 -124
  173. package/routes/api/cms/auth/setup.ts +0 -77
  174. package/routes/api/cms/img/[...path].ts +0 -24
  175. package/routes/pages/admin/[...path].astro +0 -1107
  176. package/routes/pages/admin/assets/index.astro +0 -63
  177. /package/routes/api/{cms/ai → ai}/alt-text.ts +0 -0
  178. /package/routes/api/{cms/ai → ai}/seo.ts +0 -0
  179. /package/routes/api/{cms/ai → ai}/translate.ts +0 -0
  180. /package/routes/api/{cms/assets → assets}/folders.ts +0 -0
  181. /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;