@kardalum/plugin-sdk 0.17.0 → 0.19.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 (247) hide show
  1. package/CHANGELOG.md +109 -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-serializers.js +1 -1
  10. package/dist/built-in-settings-schemas.d.ts +2 -0
  11. package/dist/built-in-settings-schemas.js +31 -4
  12. package/dist/built-in-value-schemas.js +3 -0
  13. package/dist/built-ins.js +20 -11
  14. package/dist/capabilities.js +5 -0
  15. package/dist/data-type-plugin.d.ts +2 -2
  16. package/dist/datatype-validation.d.ts +2 -2
  17. package/dist/datatype-validation.js +20 -6
  18. package/dist/datatypes-entry.d.ts +1 -0
  19. package/dist/datatypes-entry.js +1 -0
  20. package/dist/define-plugin.d.ts +4 -4
  21. package/dist/define-plugin.js +5 -5
  22. package/dist/entitlement-entry.d.ts +3 -2
  23. package/dist/entitlement-entry.js +13 -1
  24. package/dist/entitlement-gate.d.ts +18 -0
  25. package/dist/entitlement-gate.js +95 -21
  26. package/dist/entitlement-plan.d.ts +21 -0
  27. package/dist/entitlement-plan.js +26 -0
  28. package/dist/entitlement-types.d.ts +21 -4
  29. package/dist/entitlement.d.ts +29 -1
  30. package/dist/entitlement.js +39 -0
  31. package/dist/grid-arrow-step.d.ts +7 -0
  32. package/dist/grid-arrow-step.js +20 -0
  33. package/dist/index.d.ts +8 -1
  34. package/dist/index.js +11 -12
  35. package/dist/manifest-entry.d.ts +4 -0
  36. package/dist/manifest-entry.js +4 -0
  37. package/dist/manifest-schema.d.ts +5 -1
  38. package/dist/manifest-schema.js +14 -2
  39. package/dist/manifest.d.ts +21 -1
  40. package/dist/media/media-picker.js +34 -34
  41. package/dist/notify.d.ts +17 -0
  42. package/dist/notify.js +17 -0
  43. package/dist/plugin-context.js +3 -3
  44. package/dist/register-built-ins.js +6 -6
  45. package/dist/registry.js +1 -1
  46. package/dist/richtext/block-panel.js +19 -20
  47. package/dist/richtext/extensions.js +17 -8
  48. package/dist/richtext/insert-menu.js +4 -4
  49. package/dist/richtext/kardalum-block.js +17 -17
  50. package/dist/richtext/style-listbox.js +2 -2
  51. package/dist/richtext/text-style-class.js +1 -1
  52. package/dist/richtext-html-entry.d.ts +35 -0
  53. package/dist/richtext-html-entry.js +73 -0
  54. package/dist/simple-storage-value-provider.js +3 -3
  55. package/dist/structured-storage-types.d.ts +12 -1
  56. package/dist/structured-storage-types.js +2 -2
  57. package/dist/tailwind.js +10 -3
  58. package/dist/tokens/tailwind-theme.css +176 -0
  59. package/dist/tokens/tokens.css +1 -0
  60. package/dist/tokens/tokens.json +2 -1
  61. package/dist/ui-entry.js +3 -3
  62. package/dist/vendor-check.d.ts +39 -0
  63. package/dist/vendor-check.js +79 -0
  64. package/dist/vendor-entry.d.ts +3 -0
  65. package/dist/vendor-entry.js +9 -0
  66. package/dist/vendor-service.d.ts +20 -0
  67. package/dist/vendor-service.js +20 -0
  68. package/dist/views/asset-view.d.ts +6 -0
  69. package/dist/views/asset-view.js +55 -0
  70. package/dist/views/content-list-settings-view.js +1 -1
  71. package/dist/views/content-list-view.js +1 -1
  72. package/dist/views/date-range-view.js +5 -5
  73. package/dist/views/html-code-editor.js +2 -3
  74. package/dist/views/html-view.js +7 -7
  75. package/dist/views/image-view.js +5 -5
  76. package/dist/views/rich-text-view.js +33 -32
  77. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  78. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
  79. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +17 -15
  80. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  81. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  82. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +1 -0
  83. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
  84. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
  85. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  86. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  87. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +13 -0
  88. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +30 -9
  89. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
  90. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
  91. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
  92. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
  93. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  94. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +26 -6
  95. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  96. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +6 -3
  97. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  98. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  99. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +90 -0
  100. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +56 -6
  101. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
  102. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  103. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  104. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +48 -19
  105. package/node_modules/@kardalum/api-schemas/dist/index.js +34 -12
  106. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  107. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  108. package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.d.ts +46 -0
  109. package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
  110. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +162 -1
  111. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +144 -9
  112. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  114. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  115. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +15 -9
  116. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  117. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  118. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +5 -5
  119. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  120. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  121. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  122. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  123. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  124. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  125. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  126. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +7 -2
  127. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  128. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
  129. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +251 -0
  130. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +196 -31
  131. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  132. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  133. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +1 -1
  134. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +3 -3
  135. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
  136. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
  137. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  138. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -20
  139. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
  140. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
  141. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  142. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  143. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +207 -0
  144. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +147 -0
  145. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +11 -0
  146. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -8
  147. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
  148. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
  149. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
  150. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  151. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
  152. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
  153. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +27 -12
  154. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
  155. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
  156. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
  157. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
  158. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
  159. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +6 -1
  160. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  161. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  162. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  163. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  164. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +13 -0
  165. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
  166. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  167. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
  168. package/node_modules/@kardalum/design-tokens/dist/build-css.js +2 -2
  169. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  170. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  171. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  172. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  173. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -1
  174. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
  175. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
  176. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
  177. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
  178. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
  179. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
  180. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
  181. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
  182. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  183. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
  184. package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -5
  185. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  186. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -1
  187. package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
  188. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  189. package/node_modules/@kardalum/plugin-package/README.md +1 -1
  190. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  191. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
  192. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  193. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
  194. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
  195. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
  196. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
  197. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +9 -4
  198. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
  199. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
  200. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
  201. package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
  202. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
  203. package/node_modules/@kardalum/plugin-package/dist/extract.js +10 -10
  204. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
  205. package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
  206. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
  207. package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
  208. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  209. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  210. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +2 -2
  211. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
  212. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
  213. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  214. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  215. package/node_modules/@kardalum/ui/README.md +1 -1
  216. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
  217. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
  218. package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
  219. package/node_modules/@kardalum/ui/dist/components/button.js +2 -2
  220. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  221. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
  222. package/node_modules/@kardalum/ui/dist/components/dialog.js +52 -4
  223. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
  224. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +20 -7
  225. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
  226. package/node_modules/@kardalum/ui/dist/components/input.js +6 -1
  227. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  228. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  229. package/node_modules/@kardalum/ui/dist/components/property-field.js +3 -3
  230. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
  231. package/node_modules/@kardalum/ui/dist/components/sheet.js +15 -9
  232. package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
  233. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  234. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
  235. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  236. package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
  237. package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
  238. package/node_modules/@kardalum/ui/dist/components/tooltip.js +82 -0
  239. package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +11 -0
  240. package/node_modules/@kardalum/ui/dist/components/truncated-text.js +94 -0
  241. package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
  242. package/node_modules/@kardalum/ui/dist/index.d.ts +4 -1
  243. package/node_modules/@kardalum/ui/dist/index.js +4 -1
  244. package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
  245. package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
  246. package/node_modules/@kardalum/ui/package.json +8 -6
  247. package/package.json +21 -7
package/CHANGELOG.md CHANGED
@@ -8,6 +8,115 @@ Subpaths are noted per entry. `.` is the package index; `./manifest` is the
8
8
  server-safe manifest contract subpath, which pulls in no React and no
9
9
  `@kardalum/ui`.
10
10
 
11
+ ## 0.19.0
12
+
13
+ Plugin views get the admin's tooltips: an icon-only button can name itself
14
+ on hover and focus, and a name cut off by its column shows in full. The
15
+ SDK's own pickers and rich text toolbar use them, and a bundle must now name
16
+ its members.
17
+
18
+ ### Added
19
+
20
+ - `.`: `IconTooltip` (with `IconTooltipProps`), which wraps an icon-only
21
+ control and shows its `aria-label` as a tooltip, and `TruncatedText` (with
22
+ `TruncatedTextProps`), which renders text that truncates and shows the
23
+ whole text in a tooltip only when it is cut. The admin's
24
+ `TooltipProvider` sits above every mounted plugin view.
25
+ - `./ui`: everything `@kardalum/ui` gained comes through, so also
26
+ `Tooltip`, `TooltipContent`, `TooltipProvider`, `TooltipTrigger`,
27
+ `isTextCut` and `DropdownMenuContainer`.
28
+
29
+ ### Changed
30
+
31
+ - `.`: the rich text view's toolbar buttons show their names in a tooltip
32
+ instead of the browser's `title`, and the media picker, the asset picker,
33
+ the asset and image views and the rich text block panel show a cut-off
34
+ file or folder name in full through `TruncatedText`.
35
+ - `./manifest` and `.`: `contributions.bundledPlugins` must name at least
36
+ one member plugin id. Declaring members is what makes a plugin a bundle,
37
+ so an empty list is refused; a plugin that bundles none leaves the key
38
+ out.
39
+
40
+ ### Tools
41
+
42
+ - `kardalum plugin build --out <dir>` refuses an output folder that is not
43
+ new, empty, a previous package or a folder holding a `remoteEntry` file,
44
+ and the default `kardalum-package` refuses a folder holding `.git`,
45
+ `package.json` or `node_modules`.
46
+ - `kardalum plugin validate` has a 30th check that warns when the
47
+ federation plugin's type declarations are on (`dts: false` is missing),
48
+ and build and pack drop the `@mf-types` files.
49
+ - A plugin whose migration rollback fails keeps the records of the
50
+ migrations still applied, and a later install or update treats them as
51
+ applied without running `up()` again.
52
+
53
+ ## 0.18.0
54
+
55
+ Plugins can be sold on plans with a term they can read, and a plugin can call its
56
+ author's own server with a short-lived licence token. The release also adds a
57
+ vendor-side licence check, rich text from HTML for the server, notifications
58
+ from a plugin, and the Tailwind 4 theme.
59
+
60
+ ### Added
61
+
62
+ - `./vendor`: a new subpath for the author's own server (any Node server).
63
+ `createVendorLicenceCheck({ pluginId, origin })` checks the licence token
64
+ the CMS sends with a call and answers `check(authorization)` or throws
65
+ `VendorLicenceError` (status 401 or 402) from `requireLive(authorization)`.
66
+ It also exports `VENDOR_AUTH_SCHEME`, `isVendorLicenceError`, the
67
+ `VendorLicence*` types and `LICENSE_VERDICT_PUBLIC_KEYS`.
68
+ - `./manifest` and `.`: the manifest may declare `vendorService`, the origin of
69
+ the author's server. A plugin that declares it gets
70
+ `context.vendorService.fetch(path, init?)` in its routes and hooks, which
71
+ calls that origin with a 5-minute licence token and never sends the key.
72
+ It throws `VendorServiceError` (check it with `isVendorServiceError`) with
73
+ one of the codes in `VENDOR_SERVICE_ERROR_CODES`. Declaring it is declaring
74
+ outbound network use.
75
+ - `./manifest` and `.`: the manifest may declare
76
+ `contributions.notifications: true`, which derives the
77
+ `admin.notifications` capability. The plugin then gets `context.notify(input)`
78
+ in its routes and hooks, which answers how many people it reached and
79
+ throws `NotificationRefusedError` (check it with
80
+ `isNotificationRefusedError`) with one of `NOTIFICATION_REFUSAL_REASONS`.
81
+ Those three come from `./manifest`; `.` carries their types only.
82
+ - `./richtext-html`: `richtextFromHtml(html)` turns a rich text value given as
83
+ HTML into the editor's stored JSON, using the editor's own extensions. It
84
+ refuses (`RichtextHtmlError`, check it with `isRichtextHtmlError`) a value
85
+ over `MAX_RICHTEXT_HTML_BYTES` (1 MiB), an image that names no media item,
86
+ and HTML it cannot parse. It is Node-safe and imports no React.
87
+ - `./datatypes`: `BUILT_IN_EDITOR_IDS`, the ids of the built-in editors. A
88
+ plugin may not contribute an editor under one of them.
89
+ - `.` and `./manifest`: route and hook contexts, and the structured storage
90
+ context, gain the optional `notify` and `vendorService` members described
91
+ above, and `readOnly` described below.
92
+ - `./entitlement`: `entitlementPlan(entitlement, { pluginId, listingPlans?, trustedKeys? })`,
93
+ the plan key
94
+ and the term (`active`, `renewing`, `past_due`, `lapsed`, with its end, the
95
+ next charge and whether it was cancelled) of a verdict whose signature and
96
+ new `termSignature` verify. A verdict from before this release reads as
97
+ plan unknown, term active. On a non-production install it answers the
98
+ listing's highest plan when the host or the caller hands the listing's
99
+ plans. `EntitlementVerdict` gains an optional `termSignature`, `exempt` an
100
+ optional `listingPlans`. A lapsed term still comes with a `valid` verdict,
101
+ so `requireEntitlement` keeps passing for reads. `entitlementPlan` checks
102
+ the plugin id and the `valid` status like `requireEntitlement` and answers
103
+ null otherwise.
104
+ - `.`: `useEntitlement` answers `readOnly`, true while the verified term is
105
+ lapsed.
106
+ - `./manifest`: route and hook contexts carry `readOnly`, the host's own
107
+ decision; the host refuses a lapsed plugin's writes with 403
108
+ `plugin_read_only` whatever the plugin does.
109
+ - `.`: `EntitlementPlan`, `ListingPlanSummary`, `LicenseVerdictTerm`,
110
+ `highestListingPlan`, `planFromEnvelope` and `UNKNOWN_TERM`.
111
+ - `./tailwind/theme.css`: the design tokens' scales as a Tailwind 4 `@theme`
112
+ block, generated from the same source as `tailwindTheme`. Import it after
113
+ `@import "tailwindcss"`. `./tailwind` keeps exporting the Tailwind 3
114
+ `tailwindTheme` unchanged.
115
+ - `.`: `gridArrowStep(key, rtl)`, how far an arrow key moves in an option
116
+ grid read in the page direction (Right goes back in a right-to-left page;
117
+ Up and Down move back and forward in both). The media and asset pickers
118
+ have used it since S314c4.
119
+
11
120
  ## 0.17.0
12
121
 
13
122
  The licence verdict key set shrinks to one, three manifest contributions that
package/README.md CHANGED
@@ -50,7 +50,8 @@ the root; the subpaths below are bundled into whatever imports them.
50
50
  | `@kardalum/plugin-sdk/tokens.css` | Every token as a CSS custom property, light theme by default. |
51
51
  | `@kardalum/plugin-sdk/tokens/system-dark.css` | The dark theme's custom properties under `prefers-color-scheme: dark`. |
52
52
  | `@kardalum/plugin-sdk/tokens.json` | The same tokens as JSON, for build tools. |
53
- | `@kardalum/plugin-sdk/tailwind` | `tailwindTheme`, the Tailwind preset generated from the tokens. |
53
+ | `@kardalum/plugin-sdk/tailwind` | `tailwindTheme`, the Tailwind 3 theme generated from the tokens (use it as `theme` in a `tailwind.config`). |
54
+ | `@kardalum/plugin-sdk/tailwind/theme.css` | The same scales for Tailwind 4, as an `@theme` block reference. In the plugin's stylesheet: `@import "tailwindcss/theme.css" layer(theme);`, then `@import "@kardalum/plugin-sdk/tailwind/theme.css";`, then `@import "tailwindcss/utilities.css" layer(utilities);` and an `@source` line for the plugin's own files. Never `@import "tailwindcss";` (it brings Tailwind's base reset into the admin). The theme is reference-only (values are `var(--x)`), so a standalone preview outside the admin also needs `@kardalum/plugin-sdk/tokens.css`. |
54
55
  | `@kardalum/plugin-sdk/icons` | The Lucide icons the admin draws with, and the `IconName` type a manifest's `icon` takes. |
55
56
  | `@kardalum/plugin-sdk/entitlement` | A paid plugin's licence check (`requireEntitlement`), for plugin server code only. |
56
57
  | `@kardalum/plugin-sdk/datatypes` | The built-in data types' settings schemas and serializers, for server code. |
@@ -66,13 +67,13 @@ management API that the admin itself calls with the signed-in session. A plugin
66
67
  view that calls a CMS family builds its path from it, for example the content
67
68
  roots at `/api/manage/v1/content/roots`, and calls its own routes under
68
69
  `/api/plugins/:pluginId/`. The
69
- [management routes](https://docs.kardalum.com/v1/reference/manage/) page lists
70
+ [management routes](https://dev.kardalum.com/docs/v1/reference/manage/) page lists
70
71
  every operation.
71
72
 
72
73
  ## Docs
73
74
 
74
75
  The plugin guide, the manifest reference and the storage reference are at
75
- [docs.kardalum.com](https://docs.kardalum.com/v1/learn/build-a-plugin/).
76
+ [dev.kardalum.com/docs](https://dev.kardalum.com/docs/v1/plugins/build-a-plugin/).
76
77
 
77
78
  ## Support
78
79
 
@@ -0,0 +1,11 @@
1
+ import { type AssetAccepts } from "@kardalum/api-schemas";
2
+ export interface AssetPickerProps {
3
+ accepts: AssetAccepts;
4
+ /** The folder the drawer opens in; the root when null or when it names no folder. */
5
+ startFolder: string | null;
6
+ /** The file the field holds now: the drawer opens in its folder with it selected, when it exists and is taken. */
7
+ currentPath?: string | null;
8
+ onPick: (path: string) => void;
9
+ onClose: () => void;
10
+ }
11
+ export declare function AssetPicker({ accepts, startFolder: rawStartFolder, currentPath, onPick, onClose }: AssetPickerProps): import("react").JSX.Element;
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState } from "react";
3
+ import { ChevronRight, Folder as FolderIcon } from "lucide-react";
4
+ import { assetPathAccepted, assetPathIsImage } from "@kardalum/api-schemas";
5
+ import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, TruncatedText } from "@kardalum/ui";
6
+ import { usePluginTranslate } from "../plugin-screen-context.js";
7
+ import { gridArrowStep } from "../grid-arrow-step.js";
8
+ import { assetBaseName, assetParent, normalizeStartFolder, useAssetThumbnail, useAssetTree } from "./asset-tree.js";
9
+ const NO_ENTRIES = [];
10
+ function inFolder(entries, folder, kind) {
11
+ return entries
12
+ .filter((entry) => entry.kind === kind && assetParent(entry.path) === folder)
13
+ .sort((a, b) => assetBaseName(a.path).localeCompare(assetBaseName(b.path)));
14
+ }
15
+ function formatSize(size) {
16
+ return size === null ? "" : `${Math.max(1, Math.round(size / 1024))} KiB`;
17
+ }
18
+ function TileThumbnail({ path }) {
19
+ const [element, setElement] = useState(null);
20
+ const url = useAssetThumbnail(assetPathIsImage(path) ? path : null, element);
21
+ return (_jsx("span", { ref: setElement, className: "block aspect-square overflow-hidden bg-background-subtle", children: url ? _jsx("img", { src: url, alt: "", className: "h-full w-full object-cover" }) : null }));
22
+ }
23
+ const LINK_CLASS = "rounded-md px-1 hover:text-primary-600 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600";
24
+ export function AssetPicker({ accepts, startFolder: rawStartFolder, currentPath = null, onPick, onClose }) {
25
+ const t = usePluginTranslate();
26
+ const tree = useAssetTree(true, true);
27
+ const startFolder = normalizeStartFolder(rawStartFolder);
28
+ // Whatever had focus when the drawer mounted, read once during the first render (see MediaPicker).
29
+ const [opener] = useState(() => typeof document === "undefined" ? null : document.activeElement);
30
+ const [chosenFolder, setChosenFolder] = useState(null);
31
+ const [pending, setPending] = useState(currentPath);
32
+ const [activeIndex, setActiveIndex] = useState(0);
33
+ const optionRefs = useRef([]);
34
+ const entries = tree.status === "ready" ? tree.entries : NO_ENTRIES;
35
+ const startExists = startFolder !== null && entries.some((entry) => entry.kind === "folder" && entry.path === startFolder);
36
+ const currentEntry = currentPath === null ? undefined : entries.find((entry) => entry.kind === "file" && entry.path === currentPath);
37
+ const currentUsable = currentEntry !== undefined && assetPathAccepted(currentEntry.path, accepts);
38
+ const folder = chosenFolder ?? (currentUsable && currentPath !== null ? assetParent(currentPath) : startExists && startFolder !== null ? startFolder : "");
39
+ // The held path is a selection only when the file is there and the type takes it.
40
+ const selectedPath = pending === currentPath && !currentUsable ? null : pending;
41
+ const folders = useMemo(() => inFolder(entries, folder, "folder"), [entries, folder]);
42
+ const files = useMemo(() => inFolder(entries, folder, "file"), [entries, folder]);
43
+ const crumbs = folder === "" ? [] : folder.split("/").map((name, index, all) => ({ name, path: all.slice(0, index + 1).join("/") }));
44
+ function openFolder(path) {
45
+ setChosenFolder(path);
46
+ setPending(null);
47
+ setActiveIndex(0);
48
+ }
49
+ function choose(entry) {
50
+ if (assetPathAccepted(entry.path, accepts))
51
+ setPending(entry.path);
52
+ }
53
+ function focusIndex(index) {
54
+ setActiveIndex(index);
55
+ optionRefs.current[index]?.focus();
56
+ }
57
+ function handleGridKeyDown(event) {
58
+ if (files.length === 0)
59
+ return;
60
+ // The grid reads in the page's direction (the compose sheet reads it the same way).
61
+ const step = gridArrowStep(event.key, event.currentTarget.closest('[dir="rtl"]') !== null);
62
+ let next = activeIndex;
63
+ if (step !== 0) {
64
+ next = Math.min(Math.max(activeIndex + step, 0), files.length - 1);
65
+ }
66
+ else {
67
+ switch (event.key) {
68
+ case "Home":
69
+ next = 0;
70
+ break;
71
+ case "End":
72
+ next = files.length - 1;
73
+ break;
74
+ case "Enter":
75
+ case " ": {
76
+ event.preventDefault();
77
+ const focused = files[activeIndex];
78
+ if (focused)
79
+ choose(focused);
80
+ return;
81
+ }
82
+ default:
83
+ return;
84
+ }
85
+ }
86
+ event.preventDefault();
87
+ focusIndex(next);
88
+ }
89
+ return (_jsx(Sheet, { open: true, onOpenChange: (next) => {
90
+ if (!next)
91
+ onClose();
92
+ }, children: _jsxs(SheetContent, { onCloseAutoFocus: (event) => {
93
+ if (opener?.isConnected) {
94
+ event.preventDefault();
95
+ opener.focus();
96
+ }
97
+ }, children: [_jsxs(SheetHeader, { className: "flex-col items-start gap-1", children: [_jsx(SheetTitle, { children: t("asset.pickerTitle") }), _jsx(SheetDescription, { children: t(accepts === "any" ? "asset.pickerAny" : "asset.pickerImages") })] }), _jsx("nav", { "aria-label": t("asset.location"), className: "shrink-0 border-b border-border-default px-4 py-2", children: _jsxs("ol", { className: "flex flex-wrap items-center gap-1 text-sm text-text-tertiary", children: [_jsx("li", { children: folder === "" ? (_jsx("span", { "aria-current": "page", className: "font-medium text-text-primary", children: t("asset.root") })) : (_jsx("button", { type: "button", onClick: () => openFolder(""), className: LINK_CLASS, children: t("asset.root") })) }), crumbs.map((crumb, index) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), index === crumbs.length - 1 ? (_jsx(TruncatedText, { "aria-current": "page", className: "truncate font-medium text-text-primary", children: crumb.name })) : (_jsx("button", { type: "button", onClick: () => openFolder(crumb.path), className: cn("min-w-0", LINK_CLASS), children: _jsx(TruncatedText, { className: "block truncate", children: crumb.name }) }))] }, crumb.path)))] }) }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [tree.status === "loading" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.loading") }), tree.status === "forbidden" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.noAccess") }), tree.status === "failed" && _jsx("p", { className: "text-sm text-danger-600", children: t("asset.loadFailed") }), tree.status === "ready" && tree.truncated && _jsx("p", { className: "text-sm text-text-tertiary", children: t("asset.truncated") }), folders.length > 0 && (_jsx("ul", { "aria-label": t("asset.folders"), className: "flex flex-wrap gap-2", children: folders.map((entry) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", onClick: () => openFolder(entry.path), className: "flex max-w-full items-center gap-2 rounded-full border border-border-default bg-background-elevated px-3 py-1 text-xs text-text-secondary hover:bg-background-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: [_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-text-tertiary" }), _jsx(TruncatedText, { className: "truncate", children: assetBaseName(entry.path) })] }) }, entry.path))) })), tree.status === "ready" && files.length === 0 && folders.length === 0 && (_jsx("p", { className: "text-sm text-text-secondary", children: t("asset.empty") })), files.length > 0 && (_jsx("div", { role: "listbox", "aria-label": t("asset.files"), onKeyDown: handleGridKeyDown, className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: files.map((entry, index) => {
98
+ const accepted = assetPathAccepted(entry.path, accepts);
99
+ const selected = selectedPath === entry.path;
100
+ return (_jsxs("button", { type: "button", ref: (element) => {
101
+ optionRefs.current[index] = element;
102
+ }, role: "option", "aria-selected": selected, "aria-disabled": !accepted, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => choose(entry), className: cn("flex flex-col overflow-hidden rounded-md border text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "border-primary-600 bg-primary-100" : "border-border-subtle hover:bg-background-elevated", !accepted && "cursor-not-allowed opacity-50 hover:bg-transparent"), children: [_jsx(TileThumbnail, { path: entry.path }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx(TruncatedText, { className: "block truncate font-mono text-xs text-text-primary", children: assetBaseName(entry.path) }), _jsx(TruncatedText, { className: "block truncate text-xs text-text-tertiary", children: accepted ? formatSize(entry.size) : t("asset.notAnImage") })] })] }, entry.path));
103
+ }) }))] }), _jsxs(SheetFooter, { className: "items-center justify-end gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("asset.cancel") }), _jsx(Button, { type: "button", disabled: selectedPath === null, onClick: () => {
104
+ if (selectedPath === null)
105
+ return;
106
+ onPick(selectedPath);
107
+ onClose();
108
+ }, children: selectedPath === null ? t("asset.confirmNone") : t("asset.confirm", { name: assetBaseName(selectedPath) }) })] })] }) }));
109
+ }
@@ -0,0 +1,30 @@
1
+ import type { AssetTreeEntry } from "@kardalum/api-schemas";
2
+ export type AssetTreeState = {
3
+ status: "loading";
4
+ } | {
5
+ status: "ready";
6
+ entries: AssetTreeEntry[];
7
+ truncated: boolean;
8
+ } | {
9
+ status: "forbidden";
10
+ } | {
11
+ status: "failed";
12
+ };
13
+ /** The folder a path sits in, "" for the root. */
14
+ export declare function assetParent(path: string): string;
15
+ /** The last segment of a path. */
16
+ export declare function assetBaseName(path: string): string;
17
+ export declare function assetRawUrl(path: string): string;
18
+ /** A start folder as the tree spells it: trimmed, no leading or trailing slash; null when nothing is left. */
19
+ export declare function normalizeStartFolder(value: string | null): string | null;
20
+ /**
21
+ * Reads the tree (shared, see loadTree). `enabled` false makes no request. `fresh` skips the shared
22
+ * copy once, for the picker. A 403 is its own state.
23
+ */
24
+ export declare function useAssetTree(enabled?: boolean, fresh?: boolean): AssetTreeState;
25
+ /**
26
+ * An object URL for an image's bytes, or null (no path, not near the viewport yet, still loading, or the
27
+ * read failed). `element` is the tile to watch (null until it mounts); leave it undefined to fetch at once.
28
+ * At most 6 reads run at a time. Revoked when the path changes or the view goes.
29
+ */
30
+ export declare function useAssetThumbnail(path: string | null, element?: Element | null): string | null;
@@ -0,0 +1,150 @@
1
+ import { useEffect, useState } from "react";
2
+ import { MANAGE_API, usePluginApi } from "../plugin-context.js";
3
+ /** The folder a path sits in, "" for the root. */
4
+ export function assetParent(path) {
5
+ const slash = path.lastIndexOf("/");
6
+ return slash === -1 ? "" : path.slice(0, slash);
7
+ }
8
+ /** The last segment of a path. */
9
+ export function assetBaseName(path) {
10
+ return path.slice(path.lastIndexOf("/") + 1);
11
+ }
12
+ export function assetRawUrl(path) {
13
+ return `${MANAGE_API}/assets/raw?path=${encodeURIComponent(path)}`;
14
+ }
15
+ /** A start folder as the tree spells it: trimmed, no leading or trailing slash; null when nothing is left. */
16
+ export function normalizeStartFolder(value) {
17
+ if (value === null)
18
+ return null;
19
+ const folder = value
20
+ .trim()
21
+ .split("/")
22
+ .filter((part) => part !== "")
23
+ .join("/");
24
+ return folder === "" ? null : folder;
25
+ }
26
+ const TREE_LIFETIME_MS = 30_000;
27
+ const treeCache = new WeakMap();
28
+ function readTree(fetchApi) {
29
+ return fetchApi(`${MANAGE_API}/assets/tree`)
30
+ .then(async (response) => {
31
+ if (response.status === 403)
32
+ return { status: "forbidden" };
33
+ if (!response.ok)
34
+ return { status: "failed" };
35
+ const body = (await response.json());
36
+ return { status: "ready", entries: body.entries, truncated: body.truncated };
37
+ })
38
+ .catch(() => ({ status: "failed" }));
39
+ }
40
+ /** One read shared by every caller of the same API for a short while (and while in flight); a failed read is never kept. */
41
+ function loadTree(fetchApi, fresh) {
42
+ const cached = treeCache.get(fetchApi);
43
+ if (!fresh && cached && Date.now() - cached.at < TREE_LIFETIME_MS)
44
+ return cached.promise;
45
+ const entry = { at: Date.now(), promise: readTree(fetchApi) };
46
+ treeCache.set(fetchApi, entry);
47
+ void entry.promise.then((state) => {
48
+ if (state.status !== "ready" && treeCache.get(fetchApi) === entry)
49
+ treeCache.delete(fetchApi);
50
+ });
51
+ return entry.promise;
52
+ }
53
+ /**
54
+ * Reads the tree (shared, see loadTree). `enabled` false makes no request. `fresh` skips the shared
55
+ * copy once, for the picker. A 403 is its own state.
56
+ */
57
+ export function useAssetTree(enabled = true, fresh = false) {
58
+ const fetchApi = usePluginApi();
59
+ const [state, setState] = useState({ status: "loading" });
60
+ useEffect(() => {
61
+ if (!enabled)
62
+ return;
63
+ let cancelled = false;
64
+ void loadTree(fetchApi, fresh).then((next) => {
65
+ if (!cancelled)
66
+ setState(next);
67
+ });
68
+ return () => {
69
+ cancelled = true;
70
+ };
71
+ }, [fetchApi, enabled, fresh]);
72
+ return state;
73
+ }
74
+ const MAX_THUMBNAIL_FETCHES = 6;
75
+ let activeFetches = 0;
76
+ const waitingFetches = [];
77
+ function acquireSlot() {
78
+ if (activeFetches < MAX_THUMBNAIL_FETCHES) {
79
+ activeFetches += 1;
80
+ return Promise.resolve();
81
+ }
82
+ return new Promise((resolve) => waitingFetches.push(resolve));
83
+ }
84
+ function releaseSlot() {
85
+ const next = waitingFetches.shift();
86
+ if (next)
87
+ next();
88
+ else
89
+ activeFetches -= 1;
90
+ }
91
+ /** True once `element` has been near the viewport; always true where IntersectionObserver is absent. */
92
+ function useNearViewport(element) {
93
+ const supported = typeof IntersectionObserver !== "undefined";
94
+ const [seen, setSeen] = useState(false);
95
+ useEffect(() => {
96
+ if (!supported || !element || seen)
97
+ return;
98
+ const observer = new IntersectionObserver((entries) => {
99
+ if (entries.some((entry) => entry.isIntersecting))
100
+ setSeen(true);
101
+ }, { rootMargin: "200px" });
102
+ observer.observe(element);
103
+ return () => observer.disconnect();
104
+ }, [supported, element, seen]);
105
+ return !supported || seen;
106
+ }
107
+ /**
108
+ * An object URL for an image's bytes, or null (no path, not near the viewport yet, still loading, or the
109
+ * read failed). `element` is the tile to watch (null until it mounts); leave it undefined to fetch at once.
110
+ * At most 6 reads run at a time. Revoked when the path changes or the view goes.
111
+ */
112
+ export function useAssetThumbnail(path, element) {
113
+ const fetchApi = usePluginApi();
114
+ const near = useNearViewport(element ?? null);
115
+ const ready = element === undefined || near;
116
+ const [url, setUrl] = useState(null);
117
+ useEffect(() => {
118
+ setUrl(null);
119
+ if (path === null || !ready)
120
+ return;
121
+ let cancelled = false;
122
+ let objectUrl = null;
123
+ void acquireSlot().then(async () => {
124
+ try {
125
+ if (cancelled)
126
+ return;
127
+ const response = await fetchApi(assetRawUrl(path));
128
+ if (!response.ok || cancelled)
129
+ return;
130
+ const bytes = await response.blob();
131
+ if (cancelled)
132
+ return;
133
+ objectUrl = URL.createObjectURL(bytes);
134
+ setUrl(objectUrl);
135
+ }
136
+ catch {
137
+ // A failed read leaves the tile without a picture.
138
+ }
139
+ finally {
140
+ releaseSlot();
141
+ }
142
+ });
143
+ return () => {
144
+ cancelled = true;
145
+ if (objectUrl)
146
+ URL.revokeObjectURL(objectUrl);
147
+ };
148
+ }, [fetchApi, path, ready]);
149
+ return url;
150
+ }
@@ -0,0 +1 @@
1
+ export declare const BUILT_IN_EDITOR_IDS: readonly string[];
@@ -0,0 +1,20 @@
1
+ // S314o3 (D1): the ids of the built-in editors, as plain data the server can read without the
2
+ // React registry in built-ins.tsx. A plugin may not contribute an editor under one of these ids:
3
+ // the install refuses it, because the admin would refuse to register it and the server would
4
+ // validate the field by the built-in's rules. built-ins.test.tsx holds this list to what
5
+ // built-ins.tsx registers.
6
+ export const BUILT_IN_EDITOR_IDS = [
7
+ "com.kardalum.text",
8
+ "com.kardalum.number",
9
+ "com.kardalum.boolean",
10
+ "com.kardalum.date",
11
+ "com.kardalum.image",
12
+ "com.kardalum.fileupload",
13
+ "com.kardalum.richtext",
14
+ "com.kardalum.html",
15
+ "com.kardalum.daterange",
16
+ "com.kardalum.contentlist",
17
+ "com.kardalum.crop",
18
+ "com.kardalum.thumbnail",
19
+ "com.kardalum.asset",
20
+ ];
@@ -3,7 +3,7 @@
3
3
  // ./datatypes subpath (Session 69's "no browser weight in the server
4
4
  // process" boundary), while built-ins.tsx re-imports them so the browser
5
5
  // registry contract is unchanged. All six are identity today (Session
6
- // 111 wires the PIPELINE, not new output shapes) — a built-in that needs
6
+ // 111 wires the PIPELINE, not new output shapes), so a built-in that needs
7
7
  // a real serialized projection later changes its entry here and nowhere
8
8
  // else. Keys are editor ids (DataTypeConfig.editorId), matching
9
9
  // BUILT_IN_DATA_TYPE_CONFIGS in @kardalum/api-schemas.
@@ -11,4 +11,6 @@ export declare const CROP_SETTINGS_SCHEMA: JSONSchema7;
11
11
  export declare const THUMBNAIL_SETTINGS_SCHEMA: JSONSchema7;
12
12
  export declare const CROP_DEFAULT_SETTINGS: Record<string, unknown>;
13
13
  export declare const THUMBNAIL_DEFAULT_SETTINGS: Record<string, unknown>;
14
+ export declare const ASSET_SETTINGS_SCHEMA: JSONSchema7;
15
+ export declare const ASSET_DEFAULT_SETTINGS: Record<string, unknown>;
14
16
  export declare const BUILT_IN_SETTINGS_SCHEMAS: Readonly<Record<string, JSONSchema7>>;
@@ -1,10 +1,10 @@
1
1
  // Settings schemas for built-in editors that have real, validated settings
2
- // (Session 69) — keyed by the SAME id built-ins.tsx registers under
2
+ // (Session 69), keyed by the SAME id built-ins.tsx registers under
3
3
  // (com.kardalum.<name>). Editors with no entry here have no server-side
4
4
  // settings validation: either they have no settings at all (empty
5
5
  // settingsSchema, e.g. number/boolean/date), or they're a third-party/
6
6
  // remote plugin the server has no way to load code for (Module Federation
7
- // remotes only ever run in the browser — see manifest-entry.ts). This is a
7
+ // remotes only ever run in the browser, see manifest-entry.ts). This is a
8
8
  // deliberate, documented scope boundary, not an oversight.
9
9
  //
10
10
  // Zero React import: this file (and the @kardalum/plugin-sdk/datatypes
@@ -17,7 +17,7 @@ export const TEXT_SETTINGS_SCHEMA = {
17
17
  },
18
18
  additionalProperties: false,
19
19
  };
20
- // Deliberately {} — resolve-data-type.ts falls back to editor.defaultSettings
20
+ // Deliberately {}: resolve-data-type.ts falls back to editor.defaultSettings
21
21
  // for any config with empty settings (all six seeded built-ins today), so a
22
22
  // non-empty default here would silently change every existing Text field's
23
23
  // behavior the moment this ships.
@@ -72,7 +72,7 @@ export const IMAGE_SETTINGS_SCHEMA = {
72
72
  };
73
73
  export const IMAGE_DEFAULT_SETTINGS = {};
74
74
  // S197 Task 8 (spec §7, D7): the raw-HTML datatype's one setting is an
75
- // honest trust boundary, not a UX preference — default OFF, and the
75
+ // honest trust boundary, not a UX preference. It is default OFF, and the
76
76
  // input view's settings screen states the trade-off inline (verbatim
77
77
  // copy lives in html-view.tsx's HtmlSettingsView, not duplicated here).
78
78
  export const HTML_SETTINGS_SCHEMA = {
@@ -208,6 +208,32 @@ export const THUMBNAIL_SETTINGS_SCHEMA = {
208
208
  // not open and save back unchanged.
209
209
  export const CROP_DEFAULT_SETTINGS = { ratio: "1:1", maxWidth: null };
210
210
  export const THUMBNAIL_DEFAULT_SETTINGS = { longestEdge: 320 };
211
+ // S314p (D3). The hand-kept mirror of AssetFieldSettingsSchema in @kardalum/api-schemas, the
212
+ // generator's literal input-mode output (built-ins.test.tsx holds the two equal). Input mode for
213
+ // the crop's reason: both members carry defaults, and a client may send `{}`. The start folder's
214
+ // AssetPathSchema refinements have no JSON Schema form, so ajv checks its type and length only; a
215
+ // start folder that names no folder is harmless (the picker opens at the root).
216
+ export const ASSET_SETTINGS_SCHEMA = {
217
+ type: "object",
218
+ properties: {
219
+ accepts: { default: "images", type: "string", enum: ["images", "any"] },
220
+ startFolder: {
221
+ default: null,
222
+ anyOf: [
223
+ {
224
+ type: "string",
225
+ minLength: 1,
226
+ maxLength: 400,
227
+ description: "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.",
228
+ },
229
+ { type: "null" },
230
+ ],
231
+ },
232
+ },
233
+ additionalProperties: false,
234
+ };
235
+ // The settings migration 0033 seeds (ASSET_DATA_TYPE_CONFIG in @kardalum/api-schemas).
236
+ export const ASSET_DEFAULT_SETTINGS = { accepts: "images", startFolder: null };
211
237
  // com.kardalum.contentlist is the first entry whose schema has a REQUIRED
212
238
  // member (`columns`), so unlike the three above it cannot fall back to the
213
239
  // "stored settings are {} until a webmaster edits them" convention: its
@@ -222,4 +248,5 @@ export const BUILT_IN_SETTINGS_SCHEMAS = {
222
248
  "com.kardalum.fileupload": FILE_UPLOAD_SETTINGS_SCHEMA,
223
249
  "com.kardalum.crop": CROP_SETTINGS_SCHEMA,
224
250
  "com.kardalum.thumbnail": THUMBNAIL_SETTINGS_SCHEMA,
251
+ "com.kardalum.asset": ASSET_SETTINGS_SCHEMA,
225
252
  };
@@ -44,4 +44,7 @@ export const BUILT_IN_VALUE_SCHEMAS = {
44
44
  // and the rendition row records it. So this field, like the content list
45
45
  // above, carries no value of its own.
46
46
  "com.kardalum.thumbnail": { type: "null" },
47
+ // S314p (D3). A path under public/, as Settings, Assets names the file; the address a template
48
+ // prints is worked out at render.
49
+ "com.kardalum.asset": { type: "string" },
47
50
  };