@kardalum/plugin-sdk 0.17.0 → 0.18.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 (174) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +4 -3
  3. package/dist/assets/asset-picker.d.ts +11 -0
  4. package/dist/assets/asset-picker.js +109 -0
  5. package/dist/assets/asset-tree.d.ts +30 -0
  6. package/dist/assets/asset-tree.js +150 -0
  7. package/dist/built-in-editor-ids.d.ts +1 -0
  8. package/dist/built-in-editor-ids.js +20 -0
  9. package/dist/built-in-settings-schemas.d.ts +2 -0
  10. package/dist/built-in-settings-schemas.js +27 -0
  11. package/dist/built-in-value-schemas.js +3 -0
  12. package/dist/built-ins.js +10 -1
  13. package/dist/capabilities.js +5 -0
  14. package/dist/datatype-validation.js +18 -4
  15. package/dist/datatypes-entry.d.ts +1 -0
  16. package/dist/datatypes-entry.js +1 -0
  17. package/dist/entitlement-entry.d.ts +3 -2
  18. package/dist/entitlement-entry.js +13 -1
  19. package/dist/entitlement-gate.d.ts +18 -0
  20. package/dist/entitlement-gate.js +95 -21
  21. package/dist/entitlement-plan.d.ts +21 -0
  22. package/dist/entitlement-plan.js +26 -0
  23. package/dist/entitlement-types.d.ts +21 -4
  24. package/dist/entitlement.d.ts +29 -1
  25. package/dist/entitlement.js +39 -0
  26. package/dist/grid-arrow-step.d.ts +7 -0
  27. package/dist/grid-arrow-step.js +20 -0
  28. package/dist/index.d.ts +6 -1
  29. package/dist/index.js +7 -12
  30. package/dist/manifest-entry.d.ts +4 -0
  31. package/dist/manifest-entry.js +4 -0
  32. package/dist/manifest-schema.d.ts +5 -1
  33. package/dist/manifest-schema.js +7 -1
  34. package/dist/manifest.d.ts +21 -1
  35. package/dist/media/media-picker.js +32 -32
  36. package/dist/notify.d.ts +17 -0
  37. package/dist/notify.js +17 -0
  38. package/dist/richtext/block-panel.js +17 -18
  39. package/dist/richtext/extensions.js +10 -1
  40. package/dist/richtext/insert-menu.js +1 -1
  41. package/dist/richtext/kardalum-block.js +17 -17
  42. package/dist/richtext/style-listbox.js +1 -1
  43. package/dist/richtext-html-entry.d.ts +35 -0
  44. package/dist/richtext-html-entry.js +73 -0
  45. package/dist/structured-storage-types.d.ts +11 -0
  46. package/dist/tailwind.js +10 -3
  47. package/dist/tokens/tailwind-theme.css +176 -0
  48. package/dist/tokens/tokens.css +1 -0
  49. package/dist/tokens/tokens.json +2 -1
  50. package/dist/vendor-check.d.ts +39 -0
  51. package/dist/vendor-check.js +79 -0
  52. package/dist/vendor-entry.d.ts +3 -0
  53. package/dist/vendor-entry.js +9 -0
  54. package/dist/vendor-service.d.ts +20 -0
  55. package/dist/vendor-service.js +20 -0
  56. package/dist/views/asset-view.d.ts +6 -0
  57. package/dist/views/asset-view.js +55 -0
  58. package/dist/views/content-list-settings-view.js +1 -1
  59. package/dist/views/content-list-view.js +1 -1
  60. package/dist/views/html-code-editor.js +0 -1
  61. package/dist/views/image-view.js +1 -1
  62. package/dist/views/rich-text-view.js +30 -30
  63. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  64. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +16 -14
  65. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  66. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  67. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
  68. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
  69. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  70. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  71. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
  72. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +16 -1
  73. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
  74. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
  75. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  76. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
  77. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  78. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
  79. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  80. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  81. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
  82. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  83. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  84. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +41 -15
  85. package/node_modules/@kardalum/api-schemas/dist/index.js +30 -10
  86. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  87. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  88. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +115 -1
  89. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +102 -1
  90. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  91. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  92. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  93. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
  94. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  95. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  96. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  97. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  98. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  99. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  100. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  101. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  102. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  103. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
  104. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  105. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +227 -0
  106. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +157 -31
  107. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  108. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  109. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
  110. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
  111. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  112. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
  113. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  114. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  115. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
  116. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
  117. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
  118. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  119. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
  120. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -11
  121. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
  122. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
  123. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
  124. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
  125. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  126. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  127. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  128. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  129. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
  130. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
  131. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  132. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  133. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  134. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  135. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  136. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
  137. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  138. package/node_modules/@kardalum/design-tokens/dist/tokens.js +1 -0
  139. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  140. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
  141. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  142. package/node_modules/@kardalum/plugin-package/README.md +1 -1
  143. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  144. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
  145. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  146. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
  147. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
  148. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
  149. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
  150. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +8 -4
  151. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
  152. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
  153. package/node_modules/@kardalum/plugin-package/dist/extract.js +1 -1
  154. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
  155. package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
  156. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  157. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  158. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  159. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  160. package/node_modules/@kardalum/ui/README.md +1 -1
  161. package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
  162. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  163. package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
  164. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
  165. package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
  166. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  167. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  168. package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
  169. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  170. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  171. package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
  172. package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
  173. package/node_modules/@kardalum/ui/dist/index.js +1 -0
  174. package/package.json +17 -4
@@ -12,7 +12,7 @@ import { BlockPanel, BlockPreviewPopover } from "../richtext/block-panel.js";
12
12
  import { StyleListbox } from "../richtext/style-listbox.js";
13
13
  // The rich content editor (S197 spec §3): one TipTap editor definition
14
14
  // (buildRichtextExtensions), mounted here with a fixed compact toolbar per
15
- // the mockup's screen 3 — the same commands the on-page bubble toolbar
15
+ // the mockup's screen 3: the same commands the on-page bubble toolbar
16
16
  // offers, plus "Edit on page" (a later task wires the navigation; this
17
17
  // task ships it as a disabled placeholder, spec-listed toolbar chrome).
18
18
  //
@@ -25,7 +25,7 @@ const CONTENT_CLASSES = "text-sm text-text-primary [&_h1]:text-xl [&_h1]:font-bo
25
25
  "[&_a]:text-primary-700 [&_a]:underline " +
26
26
  "[&_blockquote]:border-s-2 [&_blockquote]:border-border-default [&_blockquote]:ps-3 [&_blockquote]:italic [&_blockquote]:text-text-secondary";
27
27
  // Source view (Item 3, S197 QA-wave B): a light prettification, not a real
28
- // formatter — no dependency is worth pulling in just to indent nested
28
+ // formatter: no dependency is worth pulling in just to indent nested
29
29
  // markup. TipTap's own getHTML() emits one unbroken string with no
30
30
  // whitespace between block elements at all (`<p>a</p><p>b</p>`); parsing it
31
31
  // back and re-joining each TOP-LEVEL node's own outerHTML with a newline is
@@ -50,7 +50,7 @@ function useTextStyles() {
50
50
  setLoading(true);
51
51
  fetchApi(`${MANAGE_API}/render/text-styles`)
52
52
  .then(async (response) => {
53
- // The endpoint doesn't exist yet (a later task ships it) — a 404,
53
+ // The endpoint doesn't exist yet (a later task ships it), so a 404,
54
54
  // any other error status, and a genuinely empty declared list all
55
55
  // render the same "no styles" state, so treat them identically.
56
56
  if (!response.ok)
@@ -76,8 +76,8 @@ function useTextStyles() {
76
76
  // Roving tabindex over the toolbar's top-level buttons (WAI-ARIA toolbar
77
77
  // pattern): one stop in the page Tab order, arrow keys move focus among
78
78
  // buttons, Home/End jump to the ends. Disabled buttons (Block, Edit on
79
- // page — both placeholders this task) are skipped entirely, matching
80
- // native disabled-control behavior — they can never hold focus.
79
+ // page, both placeholders this task) are skipped entirely, matching
80
+ // native disabled-control behavior, so they can never hold focus.
81
81
  function useToolbarRovingTabIndex(focusableKeys) {
82
82
  const [activeKey, setActiveKey] = useState(focusableKeys[0] ?? null);
83
83
  const refs = useRef(new Map());
@@ -128,7 +128,7 @@ function useToolbarRovingTabIndex(focusableKeys) {
128
128
  return { activeKey, setActiveKey, registerRef, handleKeyDown };
129
129
  }
130
130
  function ToolbarButton({ itemKey, label, ariaLabel, title, active, disabled, expanded, hasPopup, isRovingActive, registerRef, onFocus, onClick, }) {
131
- return (_jsx("button", { ref: registerRef, type: "button", "data-testid": `rt-toolbar-${itemKey}`, "aria-label": ariaLabel, "aria-pressed": active, "aria-haspopup": hasPopup, "aria-expanded": hasPopup ? expanded : undefined, title: title, disabled: disabled, tabIndex: disabled ? -1 : isRovingActive ? 0 : -1, onFocus: onFocus, onClick: onClick, className: cn("inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium text-text-secondary hover:bg-background-hover disabled:pointer-events-none disabled:opacity-50", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600", active && "bg-primary-100 text-primary-800"), children: label }));
131
+ return (_jsx("button", { ref: registerRef, type: "button", "data-testid": `rt-toolbar-${itemKey}`, "aria-label": ariaLabel, "aria-pressed": active, "aria-haspopup": hasPopup, "aria-expanded": hasPopup ? expanded : undefined, title: title, disabled: disabled, tabIndex: disabled ? -1 : isRovingActive ? 0 : -1, onFocus: onFocus, onClick: onClick, className: cn("inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium text-text-secondary hover:bg-background-hover disabled:pointer-events-none disabled:opacity-50", "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", active && "bg-primary-100 text-primary-800"), children: label }));
132
132
  }
133
133
  function ToolbarSeparator() {
134
134
  return _jsx("span", { "aria-hidden": "true", className: "mx-1 inline-block h-4 w-px bg-border-default" });
@@ -154,10 +154,10 @@ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
154
154
  if (href.trim())
155
155
  onApply(href.trim());
156
156
  }
157
- }, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "Remove link" })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-text-inverse hover:bg-primary-700 disabled:opacity-50", children: "Apply" })] })] }));
157
+ }, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "Remove link" })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-text-inverse hover:bg-primary-700 disabled:opacity-50", children: "Apply" })] })] }));
158
158
  }
159
159
  // S197 Task 12: bubbles up so a mount that HAS routing (content-editor.tsx,
160
- // admin-ui) can navigate to /content/:id/edit-on-page — same "plain DOM
160
+ // admin-ui) can navigate to /content/:id/edit-on-page, the same "plain DOM
161
161
  // CustomEvent, no framework-specific callback" idiom the block chip's own
162
162
  // "preview" button already uses (kardalum-block.ts's own doc comment), for
163
163
  // the identical reason: this package has no router of its own, and the
@@ -185,7 +185,7 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
185
185
  "editOnPage",
186
186
  ];
187
187
  // Every other command is disabled in source mode (editing raw HTML has no
188
- // "toggle bold" equivalent) — Source itself is the only tab stop then, so
188
+ // "toggle bold" equivalent); Source itself is the only tab stop then, so
189
189
  // the roving tabindex's own focusable set shrinks to match, same as the
190
190
  // doc comment above useToolbarRovingTabIndex describes for disabled items.
191
191
  const focusableKeys = sourceMode ? ["source"] : allItemKeys;
@@ -202,7 +202,7 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
202
202
  }
203
203
  }, [sourceMode]);
204
204
  // The picked/uploaded item (S197 Task 2 contract) becomes a mediaId-backed
205
- // image node — src is the item's path-relative downloadUrl, alt starts
205
+ // image node: src is the item's path-relative downloadUrl, alt starts
206
206
  // empty (there is no filename to fall back to once MediaPicker reports
207
207
  // only {id, downloadUrl, alt}).
208
208
  function handleMediaPick(item) {
@@ -234,11 +234,11 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
234
234
  function RichTextEditor({ editable }) {
235
235
  const { value, onChange } = usePluginValue();
236
236
  // Guards the sync effect below against reacting to the update it just
237
- // caused itself — without this, every keystroke would round-trip
237
+ // caused itself. Without this, every keystroke would round-trip
238
238
  // through setContent and reset the cursor.
239
239
  const isInternalUpdate = useRef(false);
240
240
  // The host renders this inside a PropertyField, but TipTap's editable
241
- // surface is a contenteditable <div role="textbox"> — not a labelable
241
+ // surface is a contenteditable <div role="textbox">, not a labelable
242
242
  // element, so the field's <label for> can never name it. editorProps
243
243
  // .attributes is the only way to get aria onto that exact node, so the
244
244
  // field's identity is stamped there instead (WCAG 4.1.2; axe reports
@@ -249,14 +249,14 @@ function RichTextEditor({ editable }) {
249
249
  content: value ?? "",
250
250
  editable,
251
251
  // @tiptap/react 3.31 no longer re-renders the owning component on every
252
- // transaction by default — without this the toolbar's isActive()/
252
+ // transaction by default. Without this the toolbar's isActive()/
253
253
  // getAttributes() reads (bold state, the active heading level, the
254
254
  // current link href) would go stale the instant the selection moves.
255
255
  shouldRerenderOnTransaction: true,
256
256
  editorProps: {
257
257
  attributes: {
258
258
  // ProseMirror's editable surface is a plain contenteditable div
259
- // with NO role of its own — which makes it a `generic` element,
259
+ // with NO role of its own, which makes it a `generic` element,
260
260
  // and aria-labelledby is *prohibited* on generic (axe flags the
261
261
  // field's own label as "needs review": aria-prohibited-attr). The
262
262
  // element genuinely IS a multi-line text field, so declaring that
@@ -273,7 +273,7 @@ function RichTextEditor({ editable }) {
273
273
  const json = updated.getJSON();
274
274
  // Non-edit 'update' events must not arm the echo guard below (they
275
275
  // would swallow the next genuine external value change). The one
276
- // programmatic emitter here — setEditable — is silenced at the
276
+ // programmatic emitter here (setEditable) is silenced at the
277
277
  // source (emitUpdate: false, see the effect below), so any doc that
278
278
  // still equals the external value is TipTap's own construction-time
279
279
  // normalization pass, not an edit.
@@ -284,7 +284,7 @@ function RichTextEditor({ editable }) {
284
284
  },
285
285
  });
286
286
  // Item 3 (S197 QA-wave B): the HTML source view. `null` means "not in
287
- // source mode" — the textarea's own in-progress edits live here, entirely
287
+ // source mode"; the textarea's own in-progress edits live here, entirely
288
288
  // separate from `value`/onChange, until the toggle-back below commits
289
289
  // them. Typing in source deliberately does NOT flow through onChange (the
290
290
  // spec's own choice of the two offered): a half-typed `<p` mid-edit is not
@@ -292,21 +292,21 @@ function RichTextEditor({ editable }) {
292
292
  // there is no debounce that makes an in-progress HTML string safe to
293
293
  // parse. Commit happens on toggling back to the rich view; blurring the
294
294
  // textarea without toggling back does NOT commit (the other choice the
295
- // spec allows) — staying in source mode until the user explicitly asks to
295
+ // spec allows): staying in source mode until the user explicitly asks to
296
296
  // leave it means a click elsewhere never silently discards or applies an
297
297
  // edit the user hasn't finished. Declared before the value-sync effect
298
298
  // below (not just before its own toggle handler) because that effect
299
299
  // needs to read the refs declared here.
300
300
  const [sourceHtml, setSourceHtml] = useState(null);
301
301
  const sourceMode = sourceHtml !== null;
302
- // The HTML sourceHtml was last (re-)seeded with — sourceHtml !== this
302
+ // The HTML sourceHtml was last (re-)seeded with; sourceHtml !== this
303
303
  // means the user has typed something, i.e. the buffer is "dirty". Used
304
304
  // only by the external value-sync effect below to decide whether an
305
305
  // external change can safely replace the buffer or must leave it (and
306
306
  // the user's in-progress edits) alone. A ref, not state: nothing here
307
307
  // needs to re-render on its own.
308
308
  const sourceSeedRef = useRef(null);
309
- // Whether an external value change arrived while the buffer was dirty —
309
+ // Whether an external value change arrived while the buffer was dirty,
310
310
  // shown as a small notice; cleared on toggle-back (the buffer commits,
311
311
  // resolving the conflict) or on a later external change against a
312
312
  // by-then-pristine buffer (re-seeded silently instead).
@@ -329,11 +329,11 @@ function RichTextEditor({ editable }) {
329
329
  return;
330
330
  }
331
331
  // setContent's default emitUpdate: true fires the same onUpdate path a
332
- // live edit would (JSON.stringify guard included) — no separate commit
332
+ // live edit would (JSON.stringify guard included), so no separate commit
333
333
  // plumbing needed, this is the exact mechanism the external value-sync
334
334
  // effect below already relies on. If an external change arrived while
335
335
  // this buffer was dirty (sourceStale), this is the "informed overwrite"
336
- // the notice warned about — the user's buffer wins, same as any other
336
+ // the notice warned about: the user's buffer wins, same as any other
337
337
  // edit made after seeing the notice.
338
338
  editor.commands.setContent(sourceHtml);
339
339
  sourceSeedRef.current = null;
@@ -357,18 +357,18 @@ function RichTextEditor({ editable }) {
357
357
  // back would setContent() the STALE buffer over it, re-emitting the
358
358
  // stale content as a fresh edit and clobbering the external change.
359
359
  // Refs (not state) so this effect doesn't need sourceMode/sourceHtml
360
- // in its deps — it only needs their CURRENT values when `value`
360
+ // in its deps; it only needs their CURRENT values when `value`
361
361
  // actually changes.
362
362
  if (sourceModeRef.current) {
363
363
  const pristine = sourceHtmlRef.current === sourceSeedRef.current;
364
364
  if (!pristine) {
365
- // The user has unsaved edits in the buffer — keep them (their
365
+ // The user has unsaved edits in the buffer: keep them (their
366
366
  // choice to make, not this effect's), just flag that leaving
367
367
  // source view now will overwrite the external change.
368
368
  setSourceStale(true);
369
369
  return;
370
370
  }
371
- // No local edits yet — safe to re-seed from the fresh external doc,
371
+ // No local edits yet: safe to re-seed from the fresh external doc,
372
372
  // same as the non-source branch below but keeping the textarea's
373
373
  // displayed HTML in sync too.
374
374
  editor.commands.setContent(value ?? "");
@@ -381,18 +381,18 @@ function RichTextEditor({ editable }) {
381
381
  editor.commands.setContent(value ?? "");
382
382
  }, [value, editor]);
383
383
  useEffect(() => {
384
- // emitUpdate: false — setEditable's unconditional 'update' event is
384
+ // emitUpdate: false, since setEditable's unconditional 'update' event is
385
385
  // not an edit; silencing it at the source keeps onUpdate's arming
386
386
  // logic honest (review fix, Editor.ts:307-313 in @tiptap/core 3.31).
387
387
  editor?.setEditable(editable, false);
388
388
  }, [editable, editor]);
389
389
  // The block chip's "preview ⤢" button (kardalum-block.ts) is plain DOM with
390
- // no React tree of its own — it dispatches a bubbling
390
+ // no React tree of its own: it dispatches a bubbling
391
391
  // "kardalum:preview-block" CustomEvent instead of fetching directly, since
392
392
  // only this mount has the authenticated fetchApi and somewhere to render
393
393
  // a popover. Listening on the wrapper (rather than threading a callback
394
394
  // through buildRichtextExtensions' options) keeps the extension mount-
395
- // agnostic — a vanilla mount can dispatch/listen for the same event with
395
+ // agnostic: a vanilla mount can dispatch/listen for the same event with
396
396
  // no React involved either.
397
397
  const wrapperRef = useRef(null);
398
398
  const [previewRequest, setPreviewRequest] = useState(null);
@@ -413,13 +413,13 @@ function RichTextEditor({ editable }) {
413
413
  // right signal rather than separate open/close state.
414
414
  const selection = editor?.state.selection;
415
415
  const blockSelection = editor && selection instanceof NodeSelection && selection.node.type.name === "kardalumBlock" ? selection : null;
416
- return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && Boolean(blockSelection) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: "Content changed elsewhere. Leaving source view will overwrite it." })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": "HTML source", value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-none" })] })) : (_jsx(EditorContent, { editor: editor, className: cn(CONTENT_CLASSES, editable &&
416
+ return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && Boolean(blockSelection) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: "Content changed elsewhere. Leaving source view will overwrite it." })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": "HTML source", value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-hidden" })] })) : (_jsx(EditorContent, { editor: editor, className: cn(CONTENT_CLASSES, editable &&
417
417
  // min-h-72 (18rem) matches the mockup's .rtbody proportions (S197
418
- // screen 3) — the editor grows with content past that floor, it
418
+ // screen 3): the editor grows with content past that floor, it
419
419
  // never shrinks below a real working height. px-5/py-4 are the
420
420
  // token scale's closest steps to the mockup's literal 1.3rem/
421
421
  // 1.1rem .rtbody padding (design-tokens has no 1.1/1.3rem step).
422
- "min-h-72 px-5 py-4 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })), previewRequest && (_jsx(BlockPreviewPopover, { partial: previewRequest.partial, params: previewRequest.params, anchorRect: previewRequest.anchorRect, onClose: () => setPreviewRequest(null) }))] }));
422
+ "min-h-72 px-5 py-4 focus-within:outline-hidden focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })), previewRequest && (_jsx(BlockPreviewPopover, { partial: previewRequest.partial, params: previewRequest.params, anchorRect: previewRequest.anchorRect, onClose: () => setPreviewRequest(null) }))] }));
423
423
  }
424
424
  export function RichTextInputView() {
425
425
  return _jsx(RichTextEditor, { editable: true });
@@ -53,4 +53,4 @@ request-making methods, not just types.
53
53
  ## Source & support
54
54
 
55
55
  Source: [kardalum-starter](https://github.com/kardalum/kardalum-starter).
56
- Docs: https://docs.kardalum.com. Apache-2.0.
56
+ Docs: https://dev.kardalum.com/docs/. Apache-2.0.
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { TrashCursorSchema } from "./trash-cursor.schema.js";
3
- import { AssetPathSchema, AssetVersionMetaSchema, AssetVersionSchema, MAX_ASSET_CONTENT_BYTES, TrashedAssetSchema } from "./asset.schema.js";
3
+ import { AssetPathSchema, AssetRoutePathSchema, AssetVersionMetaSchema, AssetVersionSchema, TrashedAssetSchema } from "./asset.schema.js";
4
4
  import { VersionListQuerySchema } from "./content-api.schema.js";
5
5
  // S192 asset tree browser: caps mirror the content-tree pagination
6
6
  // philosophy (never load an unbounded subtree) even though the tree
@@ -8,7 +8,7 @@ import { VersionListQuerySchema } from "./content-api.schema.js";
8
8
  export const ASSET_TREE_MAX_DEPTH = 8;
9
9
  export const ASSET_TREE_MAX_ENTRIES = 2000;
10
10
  export const AssetTreeEntrySchema = z.object({
11
- path: AssetPathSchema,
11
+ path: AssetRoutePathSchema,
12
12
  kind: z.enum(["file", "folder"]),
13
13
  size: z.number().int().min(0).nullable(),
14
14
  mtimeMs: z.number().nullable(),
@@ -25,7 +25,7 @@ export const AssetTreeResponseSchema = z.object({
25
25
  skipped: z.array(AssetTreeSkipSchema).optional(),
26
26
  });
27
27
  export const AssetContentResponseSchema = z.object({
28
- path: AssetPathSchema,
28
+ path: AssetRoutePathSchema,
29
29
  content: z.string(),
30
30
  size: z.number().int(),
31
31
  registered: z.boolean(),
@@ -33,22 +33,24 @@ export const AssetContentResponseSchema = z.object({
33
33
  version: z.number().int().min(1).nullable(),
34
34
  });
35
35
  export const WriteAssetContentRequestSchema = z
36
- .object({ path: AssetPathSchema, content: z.string().max(MAX_ASSET_CONTENT_BYTES) })
36
+ .object({ path: AssetRoutePathSchema, content: z.string() })
37
37
  .strict();
38
- export const CreateAssetFolderRequestSchema = z.object({ path: AssetPathSchema }).strict();
38
+ export const CreateAssetFolderRequestSchema = z.object({ path: AssetRoutePathSchema }).strict();
39
39
  export const RenameAssetRequestSchema = z
40
- .object({ path: AssetPathSchema, newPath: AssetPathSchema })
41
- .strict();
40
+ .object({ path: AssetRoutePathSchema, newPath: AssetRoutePathSchema })
41
+ .strict()
42
+ // S314c6 (D6): both fields would otherwise show the same path, a rename that moves nothing.
43
+ .meta({ example: { path: "css/site.css", newPath: "css/main.css" } });
42
44
  // DELETE /api/manage/v1/assets is a two-step confirm gate like content trash and
43
45
  // plugin uninstall: confirm is a literal "true" query string (not a
44
46
  // boolean) because query params are always strings on the wire.
45
47
  export const DeleteAssetQuerySchema = z.object({
46
- path: AssetPathSchema,
48
+ path: AssetRoutePathSchema,
47
49
  confirm: z.enum(["true"]).optional(),
48
50
  });
49
51
  export const AssetDeleteBlockedResponseSchema = z.object({
50
52
  requiresConfirmation: z.literal(true),
51
- path: AssetPathSchema,
53
+ path: AssetRoutePathSchema,
52
54
  kind: z.enum(["file", "folder"]),
53
55
  entryCount: z.number().int().min(0),
54
56
  registered: z.boolean(),
@@ -57,7 +59,7 @@ export const AssetDeleteBlockedResponseSchema = z.object({
57
59
  export const ZipExtractReportSchema = z.object({
58
60
  extracted: z.number().int().min(0),
59
61
  skipped: z.array(z.object({ path: z.string(), reason: z.string() })),
60
- targetFolder: AssetPathSchema.nullable(),
62
+ targetFolder: AssetPathSchema.meta({ example: "css" }).nullable(),
61
63
  });
62
64
  export const AssetSyncReportSchema = z.object({
63
65
  checked: z.number().int(),
@@ -67,17 +69,17 @@ export const AssetSyncReportSchema = z.object({
67
69
  // S314g (D5, P3): a registered text asset's history, addressed by its path as
68
70
  // the other asset routes are. Same paging as the template history.
69
71
  export const AssetVersionParamsSchema = z.object({ version: z.coerce.number().int().positive() });
70
- export const AssetVersionListQuerySchema = VersionListQuerySchema.extend({ path: AssetPathSchema });
71
- export const AssetVersionQuerySchema = z.object({ path: AssetPathSchema });
72
+ export const AssetVersionListQuerySchema = VersionListQuerySchema.extend({ path: AssetRoutePathSchema });
73
+ export const AssetVersionQuerySchema = z.object({ path: AssetRoutePathSchema });
72
74
  export const AssetVersionListResponseSchema = z.object({
73
75
  items: z.array(AssetVersionMetaSchema),
74
76
  nextCursor: z.number().int().positive().nullable(),
75
77
  });
76
78
  export const AssetVersionResponseSchema = z.object({ version: AssetVersionSchema });
77
- export const MakeAssetVersionCurrentRequestSchema = z.object({ path: AssetPathSchema }).strict();
79
+ export const MakeAssetVersionCurrentRequestSchema = z.object({ path: AssetRoutePathSchema }).strict();
78
80
  // The path D5 names, and the trashed row's id from the trash list: 0014 lets
79
81
  // several trashed rows share one path, so the path alone cannot say which.
80
- export const RestoreAssetRequestSchema = z.object({ path: AssetPathSchema, id: z.string().uuid() }).strict();
82
+ export const RestoreAssetRequestSchema = z.object({ path: AssetRoutePathSchema, id: z.string().uuid() }).strict();
81
83
  // The restore's answer: the asset's content response, and whether a file found
82
84
  // at the path was kept as a file-sync version first (as RestoreTemplateResponse).
83
85
  export const RestoreAssetResponseSchema = AssetContentResponseSchema.extend({ foldedFile: z.boolean() });
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import type { DataTypeConfig } from "./data-type-config.schema.js";
3
+ export declare const ASSET_EDITOR_ID = "com.kardalum.asset";
4
+ export declare const ASSET_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000014";
5
+ export declare const ASSET_IMAGE_EXTENSIONS: readonly ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"];
6
+ export declare const ASSET_ACCEPTS: readonly ["images", "any"];
7
+ export type AssetAccepts = (typeof ASSET_ACCEPTS)[number];
8
+ export declare const AssetFieldSettingsSchema: z.ZodObject<{
9
+ accepts: z.ZodDefault<z.ZodEnum<{
10
+ any: "any";
11
+ images: "images";
12
+ }>>;
13
+ startFolder: z.ZodDefault<z.ZodNullable<z.ZodString>>;
14
+ }, z.core.$strict>;
15
+ export type AssetFieldSettings = z.infer<typeof AssetFieldSettingsSchema>;
16
+ /** The last segment's extension, lower-cased, or "" when it has none (a leading dot is not one). */
17
+ export declare function assetExtension(path: string): string;
18
+ export declare function assetPathIsImage(path: string): boolean;
19
+ /** Whether a field with this `accepts` setting takes the file: a stored settings bag may lack the key, which means images. */
20
+ export declare function assetPathAccepted(path: string, accepts: unknown): boolean;
21
+ export declare const ASSET_DATA_TYPE_CONFIG: DataTypeConfig;
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { AssetPathSchema } from "./asset.schema.js";
3
+ // S314p (D3): the Asset data type. Its field points at a file under Settings, Assets (public/),
4
+ // stored as the path that screen shows, so a script can write it and a site built from an HTML
5
+ // kit can use the pictures it already has. A template gets the file's address, worked out at
6
+ // render (spec C5).
7
+ export const ASSET_EDITOR_ID = "com.kardalum.asset";
8
+ // The b1e00000 block continues: 0001 to 0009, 0012 and 0013 are seeded, and 0010 and 0011 are
9
+ // fixtures in document-type.schema.test.ts (see media-rendition.schema.ts).
10
+ export const ASSET_DATA_TYPE_ID = "b1e00000-0000-4000-8000-000000000014";
11
+ export const ASSET_IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "svg", "avif"];
12
+ export const ASSET_ACCEPTS = ["images", "any"];
13
+ // `.strict()` with defaults, the crop's idiom: the JSON Schema mirror in plugin-sdk is generated
14
+ // in input mode, and a strict object keeps `additionalProperties: false` there.
15
+ export const AssetFieldSettingsSchema = z
16
+ .object({
17
+ accepts: z.enum(ASSET_ACCEPTS).default("images"),
18
+ startFolder: AssetPathSchema.nullable().default(null),
19
+ })
20
+ .strict();
21
+ /** The last segment's extension, lower-cased, or "" when it has none (a leading dot is not one). */
22
+ export function assetExtension(path) {
23
+ const name = path.slice(path.lastIndexOf("/") + 1);
24
+ const dot = name.lastIndexOf(".");
25
+ return dot <= 0 ? "" : name.slice(dot + 1).toLowerCase();
26
+ }
27
+ export function assetPathIsImage(path) {
28
+ return ASSET_IMAGE_EXTENSIONS.includes(assetExtension(path));
29
+ }
30
+ /** Whether a field with this `accepts` setting takes the file: a stored settings bag may lack the key, which means images. */
31
+ export function assetPathAccepted(path, accepts) {
32
+ return accepts === "any" || assetPathIsImage(path);
33
+ }
34
+ // Seeded by migration 0033 on every install, never by BUILT_IN_DATA_TYPE_CONFIGS (0006 inserts
35
+ // that array only while it creates the table). The settings are parsed, so the stored row is the
36
+ // object the data types screen saves back unchanged.
37
+ export const ASSET_DATA_TYPE_CONFIG = {
38
+ id: ASSET_DATA_TYPE_ID,
39
+ name: "Asset",
40
+ editorId: ASSET_EDITOR_ID,
41
+ settings: AssetFieldSettingsSchema.parse({}),
42
+ };
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  export declare const AssetPathSchema: z.ZodString;
3
+ export declare const AssetRoutePathSchema: z.ZodString;
3
4
  export declare const AssetDefinitionSchema: z.ZodObject<{
4
5
  id: z.ZodString;
5
6
  path: z.ZodString;
@@ -54,16 +54,23 @@ export const AssetPathSchema = z
54
54
  message: "this path root is reserved for the server (see RESERVED_ROOT_SLUGS)",
55
55
  })
56
56
  .describe("A path under public/: segments of letters, digits, spaces and _ - . ~ @ + , ( ) ! $ ' = ; & joined by /, none starting with a dot or ending with a dot or space, each at most 255 bytes, never under a reserved root.");
57
+ // S314c6 (D6): the generator's name rule gives a `path` field "/about-us", whose leading slash
58
+ // is the empty segment the refinements refuse. A route's path field carries a valid example;
59
+ // the shared AssetPathSchema stays without one, because the asset field's settings
60
+ // (startFolder, mirrored in the plugin SDK) reuse it for a folder.
61
+ export const AssetRoutePathSchema = AssetPathSchema.meta({ example: "css/site.css" });
57
62
  export const AssetDefinitionSchema = z
58
63
  .object({
59
64
  id: z.string().uuid(),
60
- path: AssetPathSchema,
65
+ path: AssetRoutePathSchema,
61
66
  pluginId: z.string().min(1).nullable(),
62
67
  currentVersion: z.number().int().min(1),
63
68
  })
64
69
  .strict();
65
- // 5MB cap: big enough for a vendored bundle someone opens once to patch,
66
- // while keeping a single version row bounded.
70
+ // S314c3 (D8): the default of a site's asset limit, in UTF-8 bytes. The server holds every
71
+ // write to KARDALUM_MAX_ASSET_BYTES (this number unless raised); the plugin build holds a
72
+ // package to this number (D10). The request schemas carry no maximum of their own, so the
73
+ // configured limit is enforced in one place.
67
74
  export const MAX_ASSET_CONTENT_BYTES = 5_242_880;
68
75
  export const AssetVersionSchema = z
69
76
  .object({
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ import { type PlanShapeValue } from "./plan-editor.schema.js";
3
+ /** At most 7 digits: the plan cap is 1 000 000 cents. */
4
+ export declare const SHOWN_PRICE_DIGITS_MAX = 7;
5
+ /**
6
+ * Whole cents written as decimal digits. A linear scan with the length
7
+ * checked first, never a regex (a form field is untrusted text). Null unless
8
+ * it is a whole number from 0 to PLAN_MAX_PRICE_CENTS.
9
+ */
10
+ export declare function parseShownCents(text: string): number | null;
11
+ export type ShownPlan = {
12
+ priceCents: number;
13
+ shape: PlanShapeValue;
14
+ };
15
+ export declare const ShownPlanFieldsSchema: z.ZodPipe<z.ZodObject<{
16
+ shownPriceCents: z.ZodString;
17
+ shownShape: z.ZodEnum<{
18
+ free: "free";
19
+ one_time: "one_time";
20
+ monthly: "monthly";
21
+ yearly: "yearly";
22
+ }>;
23
+ }, z.core.$strip>, z.ZodTransform<ShownPlan, {
24
+ shownPriceCents: string;
25
+ shownShape: "free" | "one_time" | "monthly" | "yearly";
26
+ }>>;
27
+ /** The two form fields, or null when either is missing or unreadable (read as a mismatch). */
28
+ export declare function readShownPlan(fields: {
29
+ shownPriceCents: unknown;
30
+ shownShape: unknown;
31
+ }): ShownPlan | null;
32
+ /** The plan still costs what the buyer was shown, in the kind they were shown. */
33
+ export declare function shownPlanMatches(shown: ShownPlan, plan: {
34
+ shape: string;
35
+ priceCents: number;
36
+ }): boolean;
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import { PLAN_MAX_PRICE_CENTS, PlanShapeSchema } from "./plan-editor.schema.js";
3
+ // S322 (spec D3, 3a): what a buyer was shown, carried by every form that can
4
+ // charge or schedule a charge. The marketplace action compares it with the
5
+ // plan and refuses on a mismatch before any checkout or schedule exists.
6
+ /** At most 7 digits: the plan cap is 1 000 000 cents. */
7
+ export const SHOWN_PRICE_DIGITS_MAX = 7;
8
+ /**
9
+ * Whole cents written as decimal digits. A linear scan with the length
10
+ * checked first, never a regex (a form field is untrusted text). Null unless
11
+ * it is a whole number from 0 to PLAN_MAX_PRICE_CENTS.
12
+ */
13
+ export function parseShownCents(text) {
14
+ if (text.length < 1 || text.length > SHOWN_PRICE_DIGITS_MAX)
15
+ return null;
16
+ let cents = 0;
17
+ for (let i = 0; i < text.length; i++) {
18
+ const c = text.charCodeAt(i);
19
+ if (c < 48 || c > 57)
20
+ return null;
21
+ cents = cents * 10 + (c - 48);
22
+ }
23
+ return cents <= PLAN_MAX_PRICE_CENTS ? cents : null;
24
+ }
25
+ export const ShownPlanFieldsSchema = z
26
+ .object({
27
+ shownPriceCents: z.string().max(SHOWN_PRICE_DIGITS_MAX),
28
+ shownShape: PlanShapeSchema,
29
+ })
30
+ .transform((fields, ctx) => {
31
+ const priceCents = parseShownCents(fields.shownPriceCents);
32
+ if (priceCents === null) {
33
+ ctx.addIssue({ code: "custom", message: "The shown price is not a whole number of cents", path: ["shownPriceCents"] });
34
+ return z.NEVER;
35
+ }
36
+ return { priceCents, shape: fields.shownShape };
37
+ });
38
+ /** The two form fields, or null when either is missing or unreadable (read as a mismatch). */
39
+ export function readShownPlan(fields) {
40
+ const parsed = ShownPlanFieldsSchema.safeParse(fields);
41
+ return parsed.success ? parsed.data : null;
42
+ }
43
+ /** The plan still costs what the buyer was shown, in the kind they were shown. */
44
+ export function shownPlanMatches(shown, plan) {
45
+ return shown.shape === plan.shape && shown.priceCents === plan.priceCents;
46
+ }
@@ -11,6 +11,11 @@ export declare const CreateContentRequestSchema: z.ZodObject<{
11
11
  }, z.core.$strip>;
12
12
  export type CreateContentRequest = z.infer<typeof CreateContentRequestSchema>;
13
13
  export declare const ContentItemResponseSchema: z.ZodObject<{
14
+ readOnlyFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
15
+ fieldAlias: z.ZodString;
16
+ pluginId: z.ZodString;
17
+ message: z.ZodString;
18
+ }, z.core.$strip>>>;
14
19
  node: z.ZodObject<{
15
20
  id: z.ZodString;
16
21
  parentId: z.ZodNullable<z.ZodString>;
@@ -19,6 +24,7 @@ export declare const ContentItemResponseSchema: z.ZodObject<{
19
24
  sortOrder: z.ZodNumber;
20
25
  documentTypeId: z.ZodString;
21
26
  publishedAt: z.ZodNullable<z.ZodString>;
27
+ name: z.ZodOptional<z.ZodString>;
22
28
  }, z.core.$strip>;
23
29
  url: z.ZodNullable<z.ZodString>;
24
30
  version: z.ZodObject<{
@@ -185,6 +191,11 @@ export declare const SaveContentRequestSchema: z.ZodObject<{
185
191
  }, z.core.$strip>;
186
192
  export type SaveContentRequest = z.infer<typeof SaveContentRequestSchema>;
187
193
  export declare const SaveContentResponseSchema: z.ZodObject<{
194
+ readOnlyFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
195
+ fieldAlias: z.ZodString;
196
+ pluginId: z.ZodString;
197
+ message: z.ZodString;
198
+ }, z.core.$strip>>>;
188
199
  version: z.ZodObject<{
189
200
  id: z.ZodString;
190
201
  contentId: z.ZodString;
@@ -224,6 +235,7 @@ export declare const LatestVersionResponseSchema: z.ZodObject<{
224
235
  createdAt: z.ZodString;
225
236
  createdBy: z.ZodString;
226
237
  }, z.core.$strip>;
238
+ defaultCulture: z.ZodOptional<z.ZodString>;
227
239
  fellBack: z.ZodOptional<z.ZodArray<z.ZodString>>;
228
240
  }, z.core.$strip>;
229
241
  export type LatestVersionResponse = z.infer<typeof LatestVersionResponseSchema>;
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { ReadOnlyFieldSchema } from "./plugin-read-only.schema.js";
2
3
  import { RESERVED_ROOT_SLUGS, isReservedRootSlug } from "./reserved-slugs.js";
3
4
  import { ContentNodeSchema, NodeCultureSchema } from "./content.schema.js";
4
5
  import { ContentVersionSchema } from "./content-version.schema.js";
@@ -36,7 +37,13 @@ export const CreateContentRequestSchema = z.object({
36
37
  path: ["slug"],
37
38
  });
38
39
  export const ContentItemResponseSchema = z.object({
39
- node: ContentNodeSchema,
40
+ // S318: fields kept because their plugin is read-only.
41
+ readOnlyFields: z.array(ReadOnlyFieldSchema).optional(),
42
+ // S314o (D3): the node with the display name the list rows carry
43
+ // (ContentNodeWithNameSchema), so a create, a read by id and a copy
44
+ // answer the name where a list does. Optional, and absent rather than
45
+ // empty, for the same reason as there.
46
+ node: ContentNodeSchema.extend({ name: z.string().min(1).optional() }),
40
47
  // S277c: the address a visitor would use for this node in the culture
41
48
  // this response is for: the stored path with the default site's own
42
49
  // segment hidden, and the culture prefix on a site with more than one
@@ -102,6 +109,8 @@ export const SaveContentRequestSchema = z.object({
102
109
  baseVersion: z.number().int().positive().optional(),
103
110
  });
104
111
  export const SaveContentResponseSchema = z.object({
112
+ // S318: fields kept because their plugin is read-only.
113
+ readOnlyFields: z.array(ReadOnlyFieldSchema).optional(),
105
114
  version: ContentVersionSchema,
106
115
  // S277e: the node as it is after this save. A save can rename the node,
107
116
  // which moves its stored path, so the editor replaces the node it holds
@@ -131,6 +140,12 @@ export const LatestVersionQuerySchema = z.object({ locale: CultureSchema.optiona
131
140
  export const VersionQuerySchema = LatestVersionQuerySchema;
132
141
  export const LatestVersionResponseSchema = z.object({
133
142
  version: ContentVersionSchema,
143
+ // S314o (D1): the site's default culture, so a client that patches the
144
+ // newest save (the CLI's --field) knows which culture's view it merges
145
+ // over without asking settings.read. This server always answers it, on
146
+ // the latest read and on the one-version read alike; it is optional so a
147
+ // client reading an older server, or a test double, need not carry it.
148
+ defaultCulture: CultureSchema.optional(),
134
149
  // With ?locale=: the varying field ids this language has no value for,
135
150
  // whether or not the default language has one. Unlike the public read,
136
151
  // where fellBack lists only the fields actually filled from the default.