@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.
Files changed (182) 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/admin/forgot-password.astro +60 -0
  107. package/routes/{pages/admin → admin}/invite.astro +7 -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 +32 -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/pages/admin/login.astro +0 -57
  178. /package/routes/api/{cms/ai → ai}/alt-text.ts +0 -0
  179. /package/routes/api/{cms/ai → ai}/seo.ts +0 -0
  180. /package/routes/api/{cms/ai → ai}/translate.ts +0 -0
  181. /package/routes/api/{cms/assets → assets}/folders.ts +0 -0
  182. /package/routes/api/{cms/locks → locks}/[...path].ts +0 -0
@@ -45,6 +45,8 @@ import {
45
45
  findItemDepth,
46
46
  canIndent,
47
47
  canOutdent,
48
+ canAddChild,
49
+ MENU_MAX_DEPTH,
48
50
  } from "./tree-utils";
49
51
 
50
52
  // --- Types ---
@@ -72,6 +74,16 @@ function blankEdit(id: string): EditState {
72
74
  return { id, label: "", href: "", target: "", linkType: "internal", name: "", slug: "", autoSlug: true };
73
75
  }
74
76
 
77
+ function flattenForSelect(list: TreeItem[], depth = 0): Array<{ id: string; label: string }> {
78
+ return list.flatMap((item) => [
79
+ {
80
+ id: item.id,
81
+ label: `${"—".repeat(depth)}${depth > 0 ? " " : ""}${String(item.name || item.label || item.id)}`,
82
+ },
83
+ ...flattenForSelect(item.children, depth + 1),
84
+ ]);
85
+ }
86
+
75
87
  // --- Sortable wrapper ---
76
88
 
77
89
  function SortableTreeItem({
@@ -106,6 +118,7 @@ function SortableTreeItem({
106
118
  // --- Main component ---
107
119
 
108
120
  export default function TreeItemsEditor({ name, value, variant, label, linkOptions = [] }: Props) {
121
+ const maxDepth = variant === "menu" ? MENU_MAX_DEPTH : undefined;
109
122
  const [items, setItems] = React.useState<TreeItem[]>(() => parseItems(value));
110
123
  const [editing, setEditing] = React.useState<EditState | null>(null);
111
124
  const [activeId, setActiveId] = React.useState<string | null>(null);
@@ -261,6 +274,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
261
274
  };
262
275
 
263
276
  const addChildItem = (parentId: string) => {
277
+ if (!canAddChild(items, parentId, maxDepth)) return;
264
278
  saveOrDiscardEdit();
265
279
  const newItem = createBlankItem();
266
280
  setItems((prev) => {
@@ -303,6 +317,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
303
317
  };
304
318
 
305
319
  const indentItem = (id: string) => {
320
+ if (!canIndent(items, id, maxDepth)) return;
306
321
  setItems((prev) => {
307
322
  const next = cloneItems(prev);
308
323
  const doIndent = (list: TreeItem[]): boolean => {
@@ -503,7 +518,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
503
518
  <Collapsible open={isExpanded}>
504
519
  <div ref={setNodeRef} style={style} className={cn(isDragging && "z-10 opacity-30")}>
505
520
  <div
506
- className="hover:bg-accent/40 flex items-center gap-1 border-b py-1.5 pr-2 text-sm transition-colors"
521
+ className="hover:bg-muted-strong/70 flex items-center gap-1 border-b py-1.5 pr-2 text-sm transition-colors"
507
522
  style={{ paddingLeft: `${depth * 1.5 + 0.25}rem` }}
508
523
  >
509
524
  <button
@@ -558,7 +573,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
558
573
  className="size-7"
559
574
  title="Indent"
560
575
  onClick={() => indentItem(item.id)}
561
- disabled={!canIndent(items, item.id)}
576
+ disabled={!canIndent(items, item.id, maxDepth)}
562
577
  >
563
578
  <Indent className="size-3.5" />
564
579
  </Button>
@@ -578,6 +593,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
578
593
  className="size-7"
579
594
  title="Add child"
580
595
  onClick={() => addChildItem(item.id)}
596
+ disabled={!canAddChild(items, item.id, maxDepth)}
581
597
  >
582
598
  <Plus className="size-3.5" />
583
599
  </Button>
@@ -623,22 +639,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
623
639
  const [bulkInput, setBulkInput] = React.useState("");
624
640
  const [bulkParent, setBulkParent] = React.useState("");
625
641
 
626
- const flattenForSelect = React.useCallback(
627
- (list: TreeItem[], depth = 0): Array<{ id: string; label: string }> =>
628
- list.flatMap((item) => [
629
- {
630
- id: item.id,
631
- label: `${"—".repeat(depth)}${depth > 0 ? " " : ""}${String(item.name || item.label || item.id)}`,
632
- },
633
- ...flattenForSelect(item.children, depth + 1),
634
- ]),
635
- [],
636
- );
637
-
638
- const parentOptions = React.useMemo(
639
- () => [{ id: "", label: "Root" }, ...flattenForSelect(items)],
640
- [items, flattenForSelect],
641
- );
642
+ const parentOptions = React.useMemo(() => [{ id: "", label: "Root" }, ...flattenForSelect(items)], [items]);
642
643
 
643
644
  const handleBulkAdd = () => {
644
645
  const names = bulkInput
@@ -756,7 +757,7 @@ export default function TreeItemsEditor({ name, value, variant, label, linkOptio
756
757
  onDragEnd={handleDragEnd}
757
758
  onDragCancel={handleDragCancel}
758
759
  >
759
- <div className="rounded-lg border">
760
+ <div className="bg-muted-strong/50 rounded-lg border">
760
761
  {items.length > 0 ? (
761
762
  <SortableContext items={items.map((item) => item.id)} strategy={verticalListSortingStrategy}>
762
763
  {items.map((item) => renderItem(item, 0))}
@@ -97,11 +97,11 @@ export default function TreeSelect({
97
97
  <Popover open={open} onOpenChange={setOpen}>
98
98
  <PopoverTrigger asChild>
99
99
  <Button
100
- variant="outline"
100
+ variant="input"
101
101
  role="combobox"
102
102
  aria-expanded={open}
103
103
  size="lg"
104
- className="border-input bg-muted/30 hover:bg-muted dark:bg-input/30 dark:hover:bg-input/50 w-full justify-between text-base font-normal"
104
+ className="w-full justify-between text-sm font-normal"
105
105
  >
106
106
  <span className={cn("truncate", !selected && "text-muted-foreground")}>
107
107
  {selected ? (
@@ -0,0 +1,48 @@
1
+ import { getYoutubeId, youtubeThumbnail } from "../../core/youtube";
2
+ import { cn } from "../lib/utils";
3
+ import { Input } from "./ui/input";
4
+
5
+ type Props = {
6
+ value?: string;
7
+ placeholder?: string;
8
+ onChange: (value: string) => void;
9
+ };
10
+
11
+ /**
12
+ * URL input for a YouTube block sub-field that shows the video thumbnail once a
13
+ * valid id can be parsed — mirrors ImagePicker's preview box. Stores the raw URL.
14
+ */
15
+ export default function YoutubeField({ value = "", placeholder, onChange }: Props) {
16
+ const id = getYoutubeId(value);
17
+
18
+ return (
19
+ <div className="space-y-3">
20
+ <Input
21
+ type="url"
22
+ value={value}
23
+ placeholder={placeholder ?? "Paste a YouTube URL"}
24
+ onChange={(e) => onChange(e.target.value)}
25
+ />
26
+
27
+ {value &&
28
+ (id ? (
29
+ <a
30
+ href={`https://www.youtube.com/watch?v=${id}`}
31
+ target="_blank"
32
+ rel="noreferrer"
33
+ className="hover:border-foreground/50 block w-64 max-w-full overflow-hidden rounded-lg border"
34
+ >
35
+ <img src={youtubeThumbnail(id)} alt="" className="aspect-video w-full object-cover" />
36
+ </a>
37
+ ) : (
38
+ <div
39
+ className={cn(
40
+ "bg-muted/30 text-muted-foreground flex aspect-video w-64 max-w-full items-center justify-center rounded-lg border px-4 text-center text-sm",
41
+ )}
42
+ >
43
+ Not a recognized YouTube URL
44
+ </div>
45
+ ))}
46
+ </div>
47
+ );
48
+ }