@kardalum/plugin-sdk 0.0.0-stage → 0.16.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 (332) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/LICENSE +202 -0
  3. package/README.md +80 -2
  4. package/dist/admin-section-registry.d.ts +34 -0
  5. package/dist/admin-section-registry.js +49 -0
  6. package/dist/built-in-serializers.d.ts +3 -0
  7. package/dist/built-in-serializers.js +18 -0
  8. package/dist/built-in-settings-schemas.d.ts +14 -0
  9. package/dist/built-in-settings-schemas.js +225 -0
  10. package/dist/built-in-value-schemas.d.ts +4 -0
  11. package/dist/built-in-value-schemas.js +47 -0
  12. package/dist/built-ins.d.ts +1 -0
  13. package/dist/built-ins.js +257 -0
  14. package/dist/capabilities.d.ts +29 -0
  15. package/dist/capabilities.js +67 -0
  16. package/dist/data-type-plugin.d.ts +28 -0
  17. package/dist/data-type-plugin.js +1 -0
  18. package/dist/datatype-validation.d.ts +26 -0
  19. package/dist/datatype-validation.js +110 -0
  20. package/dist/datatypes-entry.d.ts +4 -0
  21. package/dist/datatypes-entry.js +18 -0
  22. package/dist/define-plugin.d.ts +25 -0
  23. package/dist/define-plugin.js +51 -0
  24. package/dist/entitlement-entry.d.ts +5 -0
  25. package/dist/entitlement-entry.js +24 -0
  26. package/dist/entitlement-gate.d.ts +36 -0
  27. package/dist/entitlement-gate.js +201 -0
  28. package/dist/entitlement-types.d.ts +39 -0
  29. package/dist/entitlement-types.js +1 -0
  30. package/dist/entitlement.d.ts +57 -0
  31. package/dist/entitlement.js +170 -0
  32. package/dist/host-entry.d.ts +1 -0
  33. package/dist/host-entry.js +11 -0
  34. package/dist/icon-name.d.ts +1 -0
  35. package/dist/icon-name.js +1 -0
  36. package/dist/icons.d.ts +2 -0
  37. package/dist/icons.js +10 -0
  38. package/dist/index.d.ts +28 -0
  39. package/dist/index.js +94 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +26 -0
  42. package/dist/local-host.d.ts +3 -0
  43. package/dist/local-host.js +38 -0
  44. package/dist/manifest-entry.d.ts +8 -0
  45. package/dist/manifest-entry.js +13 -0
  46. package/dist/manifest-schema.d.ts +476 -0
  47. package/dist/manifest-schema.js +823 -0
  48. package/dist/manifest.d.ts +611 -0
  49. package/dist/manifest.js +86 -0
  50. package/dist/media/media-picker.d.ts +39 -0
  51. package/dist/media/media-picker.js +447 -0
  52. package/dist/media/upload-error.d.ts +12 -0
  53. package/dist/media/upload-error.js +30 -0
  54. package/dist/plugin-context.d.ts +82 -0
  55. package/dist/plugin-context.js +77 -0
  56. package/dist/plugin-screen-context.d.ts +71 -0
  57. package/dist/plugin-screen-context.js +41 -0
  58. package/dist/read-all-pages.d.ts +23 -0
  59. package/dist/read-all-pages.js +30 -0
  60. package/dist/register-built-ins.d.ts +1 -0
  61. package/dist/register-built-ins.js +41 -0
  62. package/dist/registry.d.ts +4 -0
  63. package/dist/registry.js +17 -0
  64. package/dist/rendition-eligibility.d.ts +24 -0
  65. package/dist/rendition-eligibility.js +40 -0
  66. package/dist/richtext/block-panel.d.ts +27 -0
  67. package/dist/richtext/block-panel.js +232 -0
  68. package/dist/richtext/extensions.d.ts +19 -0
  69. package/dist/richtext/extensions.js +56 -0
  70. package/dist/richtext/insert-menu.d.ts +24 -0
  71. package/dist/richtext/insert-menu.js +142 -0
  72. package/dist/richtext/kardalum-block.d.ts +33 -0
  73. package/dist/richtext/kardalum-block.js +282 -0
  74. package/dist/richtext/style-listbox.d.ts +10 -0
  75. package/dist/richtext/style-listbox.js +69 -0
  76. package/dist/richtext/text-style-class.d.ts +18 -0
  77. package/dist/richtext/text-style-class.js +36 -0
  78. package/dist/simple-storage-value-provider.d.ts +9 -0
  79. package/dist/simple-storage-value-provider.js +96 -0
  80. package/dist/structured-storage-types.d.ts +61 -0
  81. package/dist/structured-storage-types.js +11 -0
  82. package/dist/tailwind.d.ts +1 -0
  83. package/dist/tailwind.js +5 -0
  84. package/dist/tokens/system-dark.css +75 -0
  85. package/dist/tokens/tokens.css +239 -0
  86. package/dist/tokens/tokens.json +212 -0
  87. package/dist/tokens.d.ts +1 -0
  88. package/dist/tokens.js +11 -0
  89. package/dist/ui-entry.d.ts +5 -0
  90. package/dist/ui-entry.js +42 -0
  91. package/dist/views/content-list-preview.d.ts +1 -0
  92. package/dist/views/content-list-preview.js +14 -0
  93. package/dist/views/content-list-settings-view.d.ts +1 -0
  94. package/dist/views/content-list-settings-view.js +97 -0
  95. package/dist/views/content-list-view.d.ts +19 -0
  96. package/dist/views/content-list-view.js +248 -0
  97. package/dist/views/crop-view.d.ts +55 -0
  98. package/dist/views/crop-view.js +161 -0
  99. package/dist/views/date-range-view.d.ts +6 -0
  100. package/dist/views/date-range-view.js +55 -0
  101. package/dist/views/file-upload-view.d.ts +43 -0
  102. package/dist/views/file-upload-view.js +104 -0
  103. package/dist/views/html-code-editor.d.ts +10 -0
  104. package/dist/views/html-code-editor.js +101 -0
  105. package/dist/views/html-view.d.ts +3 -0
  106. package/dist/views/html-view.js +53 -0
  107. package/dist/views/image-view.d.ts +3 -0
  108. package/dist/views/image-view.js +372 -0
  109. package/dist/views/rich-text-view.d.ts +2 -0
  110. package/dist/views/rich-text-view.js +429 -0
  111. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  112. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  113. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  114. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
  117. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
  118. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  121. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  122. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  123. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  124. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  138. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  139. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
  140. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
  141. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  142. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  146. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  149. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  150. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  151. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  152. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  153. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  154. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  155. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
  156. package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
  157. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  158. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  159. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  160. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  161. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
  162. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  171. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  172. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  173. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  174. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  175. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  176. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  177. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  178. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  205. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
  206. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
  207. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  208. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  209. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  210. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  211. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  212. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  213. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
  214. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
  215. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  216. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  217. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
  218. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
  219. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
  220. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
  221. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  222. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  223. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
  224. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
  225. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  226. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  227. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  228. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  229. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  230. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  231. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  232. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  233. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
  234. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
  235. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  236. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  237. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  238. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  239. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  240. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  241. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  242. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  243. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  244. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  247. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  248. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  249. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  250. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  251. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  252. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  253. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  254. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  255. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  256. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  257. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  258. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  259. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  260. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  261. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  262. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  263. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  264. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  265. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  266. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
  267. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
  268. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  269. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
  270. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  271. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  272. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  273. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  274. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  275. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  276. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  277. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  278. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
  279. package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
  280. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  281. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  282. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  283. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  284. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
  285. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
  286. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
  287. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
  288. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
  289. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
  290. package/node_modules/@kardalum/plugin-package/package.json +54 -0
  291. package/node_modules/@kardalum/ui/LICENSE +202 -0
  292. package/node_modules/@kardalum/ui/README.md +35 -0
  293. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  294. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  295. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  296. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  297. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  298. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  299. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  300. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  301. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  302. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  303. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  304. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  305. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  306. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  307. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  308. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  309. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  310. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  311. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  312. package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
  313. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  314. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  315. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  316. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  317. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  318. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  320. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  321. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  322. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  323. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  324. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  325. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  326. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  327. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  328. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  329. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  330. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  331. package/node_modules/@kardalum/ui/package.json +63 -0
  332. package/package.json +146 -4
@@ -0,0 +1,823 @@
1
+ import { z } from "zod";
2
+ import { ACTION_SEGMENT_MAX, API_ROUTE_METHODS, API_ROUTE_RESPONSE_STATUSES_MAX, isApiRouteResponseStatus, ActionStringSchema, CultureSchema, DocsLanguageSchema, MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_REGEX, SLOT_ID_MAX, SLOT_ID_REGEX, PluginDocsPageSchema, PluginInstallDeclarationSchema, checkApiRouteActions, checkApiRouteDeclarations, checkDocsDeclaration, checkInstallDeclaration, CreateDocumentTypeRequestSchema, PluginActionDeclarationSchema, PluginRoleOfferSchema, checkActionDeclarations as checkActionDeclarationsRule, isPluginActionFor } from "@kardalum/api-schemas";
3
+ import { isActionGated } from "./capabilities.js";
4
+ // Runtime mirror of manifest.ts — the same contract, enforced for
5
+ // manifests that arrive as VALUES (Module Federation remotes, sideloaded
6
+ // plugins, the future `kardalum plugin validate` CLI) where the compiler
7
+ // can't help. Since S268 there is ONE manifest shape and ONE contributions
8
+ // object: the plugin's `type` gates nothing. Both objects stay .strict(),
9
+ // so an unknown key still fails with a clear path like
10
+ // `contributions.adminSection` (a typo, or a field a later version
11
+ // removed). Ungating which contributions are legal is not the same as
12
+ // accepting anything.
13
+ //
14
+ // Lives in the SDK, not @kardalum/api-schemas, deliberately: the manifest
15
+ // carries React components and functions (api-schemas must never know
16
+ // React), and third-party tooling needs this validator from the
17
+ // published package.
18
+ // Zod 4: z.function() is not a schema — validate callables with
19
+ // z.custom. The type parameter is the CONTRACT type from manifest.ts,
20
+ // which is what makes the compile-time sync assertion at the bottom of
21
+ // this file hold. React components may be functions OR objects
22
+ // (React.memo/forwardRef produce exotic objects).
23
+ const callable = (label) => z.custom((value) => typeof value === "function", { message: `${label} must be a function` });
24
+ const componentSchema = z.custom((value) => typeof value === "function" || (typeof value === "object" && value !== null), { message: "must be a React component" });
25
+ // A JSON Schema document is a plain object (DataTypePlugin.schema is the
26
+ // JSONSchema7 object interface, not the boolean shorthand).
27
+ const jsonSchemaSchema = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value), { message: "must be a JSON Schema object" });
28
+ // A plugin-declared request schema must be a REAL Zod v4 schema instance
29
+ // (z.object(...), z.string() and the rest: every Zod schema extends the base
30
+ // ZodType class), not just an object that looks like one. The server compiles
31
+ // it with its validator compiler (fastify-type-provider-zod), which runs it
32
+ // through Zod's core safeParse, and that needs a real v4 instance.
33
+ const zodSchemaField = z.instanceof(z.ZodType);
34
+ // Reverse-domain id per the documented contract, e.g. "com.vendor.name".
35
+ // Shared by manifest ids, datatype ids and plugin references, so it carries
36
+ // only the CHARACTER rules: every segment is lowercase and starts with a
37
+ // letter. Every action a plugin declares is prefixed with the plugin's id,
38
+ // and an action segment must match /^[a-z][a-zA-Z0-9-]*$/, so a segment
39
+ // that starts with a digit or a hyphen, or is uppercase, would make an id
40
+ // that can never prefix a valid action. The segment COUNT is deliberately
41
+ // not capped here: a datatype id is the owning plugin's id plus the field
42
+ // name (com.kardalum.google-maps.location), so four segments is correct for it.
43
+ // The pattern itself lives in api-schemas (PLUGIN_ID_REGEX), which the nav
44
+ // setting reads too.
45
+ const pluginIdSchema = z
46
+ .string()
47
+ .regex(PLUGIN_ID_REGEX, "must be a reverse-domain id like com.vendor.plugin: every segment is lowercase, starts with a letter, and uses only a-z, 0-9 and hyphens");
48
+ // The most segments a plugin manifest's own id may have. An action is the
49
+ // plugin id plus at least an object and a verb, and an action has at most
50
+ // ACTION_SEGMENT_MAX segments, so an id of more than ACTION_SEGMENT_MAX - 2
51
+ // segments could not declare any action at all. MANIFEST_ID_SEGMENT_MAX
52
+ // (ACTION_SEGMENT_MAX - 2) is imported from api-schemas.
53
+ // A plugin manifest's own id: the shared id rules plus the segment cap
54
+ // above. Not used for datatype ids, which extend the plugin id with a field
55
+ // name and are legitimately longer.
56
+ const manifestIdSchema = pluginIdSchema.refine((id) => id.split(".").length <= MANIFEST_ID_SEGMENT_MAX, {
57
+ message: `a plugin id has at most ${MANIFEST_ID_SEGMENT_MAX} segments: every action is the plugin id plus an object ` +
58
+ `and a verb, and an action has at most ${ACTION_SEGMENT_MAX} segments, so a longer id could not declare any action`,
59
+ });
60
+ // S234a Task 6c: the catch-all is a singleton the whole upload path
61
+ // depends on (an upload of an extension nothing else claims lands on it,
62
+ // or 400s if there is none). A plugin's install path calls
63
+ // DocumentTypeService.createDocumentType directly, bypassing the sweep
64
+ // that the /api/manage/v1/document-types routes use to keep the flag a singleton,
65
+ // and uninstalling a plugin deletes every document type it contributed.
66
+ // A plugin allowed to hold the catch-all could therefore take it to zero
67
+ // on uninstall, so it is refused here, at the one schema every
68
+ // manifest-contributed document type passes through regardless of which
69
+ // plugin declares it (contributionsSchema references this, not the bare
70
+ // array).
71
+ // A plugin contributing a media type without the flag stays legal.
72
+ const manifestDocumentTypesSchema = z
73
+ .array(CreateDocumentTypeRequestSchema)
74
+ .optional()
75
+ .superRefine((documentTypes, ctx) => {
76
+ (documentTypes ?? []).forEach((documentType, index) => {
77
+ if (documentType.kind === "media" && documentType.catchAll === true) {
78
+ ctx.addIssue({
79
+ code: "custom",
80
+ message: "A plugin may contribute a media document type but may not claim the catch-all " +
81
+ '("catchAll: true"): uninstalling the plugin deletes its contributed types, and the ' +
82
+ "catch-all must survive that.",
83
+ path: [index, "catchAll"],
84
+ });
85
+ }
86
+ });
87
+ });
88
+ // S289: each enum the manual quotes is an exported constant the schema
89
+ // itself uses, so the manual's enum test checks against what is enforced,
90
+ // never a copy (manual-enum-examples.test.ts).
91
+ export const DATABASE_DIALECTS = ["postgresql", "mysql", "sqlite", "mssql", "mongodb"];
92
+ export const STORAGE_TYPES = ["simple", "structured"];
93
+ // S295: api-schemas' list, the one the apiRoutes rule compares, re-exported so
94
+ // the enum below and the manual's enum test read that same constant.
95
+ export { API_ROUTE_METHODS };
96
+ export const API_ROUTE_ACCESS_TIERS = ["admin", "apiKey", "public"];
97
+ export const TEMPLATE_KINDS = ["page", "layout", "partial"];
98
+ export const PLUGIN_TYPES = ["datatype", "section", "template", "theme", "integration", "utility", "bundle"];
99
+ export const DATATYPE_ENTRY_TYPES = ["datatype"];
100
+ const dialectSchema = z.enum(DATABASE_DIALECTS);
101
+ const databaseCompatibilitySchema = z
102
+ .object({
103
+ storageType: z.enum(STORAGE_TYPES),
104
+ // A plugin supporting zero databases can never be installed anywhere.
105
+ supported: z.array(dialectSchema).min(1),
106
+ unsupportedReason: z.partialRecord(dialectSchema, z.string()).optional(),
107
+ })
108
+ .strict();
109
+ // An assertion is a key with a reason, never a boolean. Presence is the
110
+ // claim, so there is no `false` to write and no way to assert something
111
+ // and deny it in the same breath. Keyed by assertion name rather than
112
+ // held in an array of { kind, reason } for the same reason the booleans
113
+ // lost `needsStructuredData`: an array admits two entries for the same
114
+ // kind with contradicting reasons, and a manifest that can disagree with
115
+ // itself is the shape S267 is removing. Readers that want a list take
116
+ // Object.entries.
117
+ const assertionSchema = z
118
+ .object({
119
+ // Non-empty because an empty reason is the bare boolean again, and
120
+ // the install screen would render a blank line where the operator
121
+ // needs a sentence.
122
+ reason: z.string().min(1),
123
+ })
124
+ .strict();
125
+ // Held as a shape, not inlined into the schema, so ASSERTION_KINDS below
126
+ // can be derived from it rather than retyped beside it.
127
+ const assertionsShape = {
128
+ externalNetwork: assertionSchema.optional(),
129
+ filesystemAccess: assertionSchema.optional(),
130
+ };
131
+ // .strict() is what rejects an old manifest's `needsStructuredData`
132
+ // loudly instead of dropping it: the capability it stood for is derived
133
+ // from databaseCompatibility.storageType now, and a manifest still
134
+ // carrying the boolean was written against a contract that is gone.
135
+ export const AssertionsSchema = z.object(assertionsShape).strict();
136
+ /**
137
+ * Every assertion kind this contract defines, at runtime, derived from
138
+ * the shape above so it cannot drift from it.
139
+ *
140
+ * Exists for the same reason CONTRIBUTION_KEYS does: the marketplace
141
+ * carries a hand-maintained static mirror of AssertionsSchema (its
142
+ * Next.js runtime never imports plugin tooling), that mirror is
143
+ * `.strict()`, and a kind added here but not there turns into a publish
144
+ * refusal for an artifact that built fine. Exporting the kinds and the
145
+ * schema gives the mirror something to be pinned against.
146
+ */
147
+ export const ASSERTION_KINDS = Object.keys(assertionsShape);
148
+ const pluginMigrationSchema = z
149
+ .object({
150
+ id: z.string().min(1),
151
+ name: z.string().min(1),
152
+ up: callable("up"),
153
+ down: callable("down"),
154
+ })
155
+ .strict();
156
+ const migrationHooksSchema = z
157
+ .object({
158
+ beforeMigration: callable("beforeMigration").optional(),
159
+ transformRow: callable("transformRow").optional(),
160
+ afterMigration: callable("afterMigration").optional(),
161
+ validateMigration: callable("validateMigration").optional(),
162
+ })
163
+ .strict();
164
+ export const HOOK_EVENTS = [
165
+ "content:beforeSave",
166
+ "content:afterSave",
167
+ "content:beforePublish",
168
+ "content:afterPublish",
169
+ "content:afterTrash",
170
+ "content:afterRestore",
171
+ "content:beforeDelete",
172
+ "media:afterUpload",
173
+ "user:afterLogin",
174
+ "api:beforeResponse",
175
+ ];
176
+ const hookEventsMatch = true;
177
+ const pluginTypesMatch = true;
178
+ const dialectsMatch = true;
179
+ void hookEventsMatch;
180
+ void pluginTypesMatch;
181
+ void dialectsMatch;
182
+ // z.partialRecord, not z.record: with enum keys, Zod 4's record is
183
+ // exhaustive (it would demand a handler for all ten events).
184
+ const hooksSchema = z.partialRecord(z.enum(HOOK_EVENTS), callable("hook handler"));
185
+ // The DataTypePlugin contract's structural shape — shared by manifests
186
+ // (dataTypes contributions arriving as data) and definePlugin (which
187
+ // fronts it with friendlier required-view messages).
188
+ export const DataTypePluginSchema = z
189
+ .object({
190
+ id: pluginIdSchema,
191
+ name: z.string().min(1),
192
+ icon: z.string().min(1),
193
+ version: z.string().min(1),
194
+ type: z.literal(DATATYPE_ENTRY_TYPES[0]),
195
+ schema: jsonSchemaSchema,
196
+ settingsSchema: jsonSchemaSchema,
197
+ defaultSettings: z.record(z.string(), z.unknown()),
198
+ views: z
199
+ .object({
200
+ input: componentSchema,
201
+ readOnly: componentSchema,
202
+ settings: componentSchema,
203
+ preview: componentSchema.optional(),
204
+ })
205
+ .strict(),
206
+ serialize: callable("serialize"),
207
+ deserialize: callable("deserialize"),
208
+ // Runtime-module members only: the manifest.json writer keeps a
209
+ // string-field allowlist, so these never serialize (S198 spec S8).
210
+ // They must still be ACCEPTED here — the object is .strict(), and a
211
+ // plugin author declaring its datatype's validate hook goes through
212
+ // this same schema via definePlugin.
213
+ validate: callable("validate").optional(),
214
+ isEmpty: callable("isEmpty").optional(),
215
+ })
216
+ .strict();
217
+ // --- the slots (S280, Theme B) ----------------------------------------------
218
+ // Three closed kinds, never a general registry (spec D1): a top-level
219
+ // section whose view is its landing page, a rail entry in that section's own
220
+ // rail, and a rail entry in a built-in section. Every slot declares its
221
+ // action (D4) and carries a translatable label (D5). `name` is gone from
222
+ // adminSections rather than kept beside `label`: nothing is released, and a
223
+ // leftover `name` is refused with a message that says what to write instead.
224
+ // A slot's id is a segment of its screen's URL (spec D3), so it is limited
225
+ // to characters that need no encoding and cannot be read as a path step:
226
+ // no "/", "%", space, unicode or upper case, and never "." or "..", which a
227
+ // router resolves as "this" or "the parent" segment. The same kebab-case
228
+ // rule template aliases use. The pattern and the cap live in api-schemas
229
+ // (SLOT_ID_REGEX, SLOT_ID_MAX), which the nav setting reads too.
230
+ const slotIdSchema = z
231
+ .string()
232
+ .regex(SLOT_ID_REGEX, 'slot ids are lowercase letters, digits and single hyphens (for example "orders" or "order-reports"), because the id is a segment of the screen\'s URL')
233
+ .max(SLOT_ID_MAX, `slot ids are at most ${SLOT_ID_MAX} characters, because the id is a segment of the screen's URL`);
234
+ // A language code to the text shown in that language; `en` is required
235
+ // because it is what every other language falls back to. No language may
236
+ // carry an empty string or whitespace alone, which would render a blank tab
237
+ // (and a blank English label is one the generated reference refuses). Every
238
+ // key is a language code under the same rule as the site's cultures setting
239
+ // (CultureSchema), so "" or "anything" is refused rather than carried as a
240
+ // language no locale can ever pick.
241
+ const slotLabelTextSchema = z.string().refine((text) => text.trim() !== "", { message: "must not be empty" });
242
+ const slotLabelSchema = z
243
+ .object({ en: slotLabelTextSchema })
244
+ .catchall(slotLabelTextSchema)
245
+ .superRefine((label, ctx) => {
246
+ for (const key of Object.keys(label)) {
247
+ if (!CultureSchema.safeParse(key).success) {
248
+ ctx.addIssue({
249
+ code: "custom",
250
+ message: `label keys are language codes such as "en", "de" or "pt-BR", not ${JSON.stringify(key)}`,
251
+ path: [key],
252
+ });
253
+ }
254
+ }
255
+ });
256
+ const railEntryInSectionSchema = z
257
+ .object({
258
+ id: slotIdSchema,
259
+ label: slotLabelSchema,
260
+ icon: z.string().min(1).optional(),
261
+ action: ActionStringSchema,
262
+ view: componentSchema,
263
+ })
264
+ .strict();
265
+ const adminSectionSchema = z
266
+ .object({
267
+ id: slotIdSchema,
268
+ label: slotLabelSchema,
269
+ icon: z.string().min(1),
270
+ action: ActionStringSchema,
271
+ view: componentSchema,
272
+ rail: z.array(railEntryInSectionSchema).optional(),
273
+ // `name` was the section's plain-text title before labels became
274
+ // translatable. Declared here only so a manifest still carrying it is
275
+ // told what to write instead, rather than reading "Unrecognized key"
276
+ // beside a missing label and having to infer the change.
277
+ name: z
278
+ .never({
279
+ error: (issue) => `"name" was replaced by "label", a map of language code to text with "en" required: write label: { en: ${typeof issue.input === "string" ? JSON.stringify(issue.input) : '"<your name>"'} }`,
280
+ })
281
+ .optional(),
282
+ })
283
+ .strict();
284
+ /**
285
+ * The built-in sections whose rail a plugin may add an entry to. Plugin
286
+ * management is not among them: it is the operator's screen for plugins,
287
+ * not a host for them. A plugin cannot take over any built-in section's
288
+ * landing page (spec D2), only add to its rail.
289
+ */
290
+ export const BUILT_IN_RAIL_SECTIONS = ["content", "media", "settings", "users"];
291
+ const railEntrySchema = z
292
+ .object({
293
+ id: slotIdSchema,
294
+ section: z.enum(BUILT_IN_RAIL_SECTIONS),
295
+ label: slotLabelSchema,
296
+ icon: z.string().min(1).optional(),
297
+ action: ActionStringSchema,
298
+ view: componentSchema,
299
+ })
300
+ .strict();
301
+ const dashboardWidgetSchema = z
302
+ .object({
303
+ id: z.string().min(1),
304
+ name: z.string().min(1),
305
+ view: componentSchema,
306
+ action: ActionStringSchema,
307
+ })
308
+ .strict();
309
+ // S297: a route's declared success responses. The keys are decided by the rule
310
+ // the host's route table compiles with (isApiRouteResponseStatus), so the two
311
+ // cannot disagree; the values are real Zod schemas like the request parts.
312
+ const apiRouteResponseSchema = z.record(z.string(), zodSchemaField).superRefine((value, ctx) => {
313
+ const keys = Object.keys(value);
314
+ if (keys.length > API_ROUTE_RESPONSE_STATUSES_MAX) {
315
+ ctx.addIssue({
316
+ code: "custom",
317
+ message: `declares ${keys.length} responses; at most ${API_ROUTE_RESPONSE_STATUSES_MAX} are allowed`,
318
+ });
319
+ }
320
+ for (const key of keys) {
321
+ if (!isApiRouteResponseStatus(key)) {
322
+ ctx.addIssue({ code: "custom", message: `"${key}" is not a success status: use a status code from "200" to "299"`, path: [key] });
323
+ }
324
+ }
325
+ });
326
+ const apiRouteSchema = z
327
+ .object({
328
+ method: z.enum(API_ROUTE_METHODS),
329
+ // S295: the path's syntax and its relation to the plugin's other routes are
330
+ // api-schemas' checkApiRouteDeclarations, run once on the whole manifest
331
+ // below, so a bad path is reported once and in the words the door uses.
332
+ path: z.string(),
333
+ access: z.enum(API_ROUTE_ACCESS_TIERS).optional(),
334
+ action: ActionStringSchema.optional(),
335
+ schema: z
336
+ .object({
337
+ body: zodSchemaField.optional(),
338
+ querystring: zodSchemaField.optional(),
339
+ params: zodSchemaField.optional(),
340
+ response: apiRouteResponseSchema.optional(),
341
+ })
342
+ .strict()
343
+ .optional(),
344
+ handler: callable("handler"),
345
+ })
346
+ .strict();
347
+ const customFormatContributionSchema = z.object({
348
+ name: z.string().regex(/^[a-z0-9-]+$/),
349
+ build: callable("build"),
350
+ }).strict();
351
+ const serializerContributionSchema = z
352
+ .object({
353
+ extendContentResponse: callable("extendContentResponse").optional(),
354
+ customFormats: z.array(customFormatContributionSchema).optional(),
355
+ })
356
+ .strict()
357
+ .superRefine((value, ctx) => {
358
+ const names = (value.customFormats ?? []).map((format) => format.name);
359
+ if (new Set(names).size !== names.length) {
360
+ ctx.addIssue({ code: "custom", message: "customFormats names must be unique within a manifest" });
361
+ }
362
+ });
363
+ const scheduledTaskSchema = z
364
+ .object({
365
+ id: z.string().min(1),
366
+ name: z.string().min(1),
367
+ cron: z.string().min(1),
368
+ run: callable("run"),
369
+ })
370
+ .strict();
371
+ const mediaProcessorSchema = z
372
+ .object({
373
+ id: z.string().min(1),
374
+ name: z.string().min(1),
375
+ process: callable("process"),
376
+ })
377
+ .strict();
378
+ const settingsPageSchema = z
379
+ .object({
380
+ id: z.string().min(1),
381
+ name: z.string().min(1),
382
+ view: componentSchema,
383
+ action: ActionStringSchema,
384
+ })
385
+ .strict();
386
+ const contentTreeActionSchema = z
387
+ .object({
388
+ id: z.string().min(1),
389
+ label: z.string().min(1),
390
+ onSelect: callable("onSelect"),
391
+ action: ActionStringSchema,
392
+ })
393
+ .strict();
394
+ const editorToolbarSchema = z
395
+ .object({
396
+ id: z.string().min(1),
397
+ label: z.string().min(1),
398
+ icon: z.string().min(1),
399
+ onClick: callable("onClick"),
400
+ action: ActionStringSchema,
401
+ })
402
+ .strict();
403
+ const exposedServiceSchema = z
404
+ .object({ id: z.string().min(1), name: z.string().min(1), service: z.unknown() })
405
+ .strict();
406
+ const bundledTemplateSchema = z
407
+ .object({
408
+ name: z.string().min(1),
409
+ description: z.string().optional(),
410
+ repository: z.string().optional(),
411
+ })
412
+ .strict();
413
+ // Both the record KEY (kebab-cased into the CSS custom-property name by
414
+ // @kardalum/design-tokens's flatten()) and the VALUE (emitted verbatim after
415
+ // the colon) end up spliced into a shared, admin-wide `[data-theme] { ... }`
416
+ // block at runtime (see theme-css.ts's themeOverridesToCss). Braces,
417
+ // semicolons, and control characters are never legitimate in a single CSS
418
+ // identifier or value, and would otherwise let an installed theme plugin
419
+ // break out of its declaration and inject arbitrary rules. This is a belt
420
+ // to theme-css.ts's own runtime filter, enforced earlier at manifest
421
+ // validation time.
422
+ const safeCssTokenSchema = z
423
+ .string()
424
+ .max(200)
425
+ .regex(new RegExp('^[^{};\\u0000-\\u001f\\u007f]+$'), "must not contain CSS-escaping characters");
426
+ // themeTokens: minimal strict mirror of ThemeTokenOverrides — only
427
+ // color/radius keys exist (themes are cosmetic by construction);
428
+ // design-tokens has no Zod and shouldn't gain one, so token values are
429
+ // validated shallowly here.
430
+ const themeTokensSchema = z
431
+ .object({
432
+ color: z.record(safeCssTokenSchema, z.record(safeCssTokenSchema, safeCssTokenSchema)).optional(),
433
+ radius: z.record(safeCssTokenSchema, safeCssTokenSchema).optional(),
434
+ })
435
+ .strict();
436
+ // --- templates/assets contributions (S192 §8) -------------------------------
437
+ // Any plugin may declare templates and assets (S268). What still binds is
438
+ // the cross-check below: a `page` kind entry may only name a document type
439
+ // the same manifest declares.
440
+ // Local copies of the canonical alias/path rules and reserved roots, not
441
+ // imports. This is NOT a package boundary: plugin-sdk does depend on
442
+ // @kardalum/api-schemas (package.json lists it, and
443
+ // CreateDocumentTypeRequestSchema is value-imported above for
444
+ // contributionsSchema). The real one-way rule runs the other direction:
445
+ // api-schemas must never know about React, which the manifest carries,
446
+ // which is why the manifest schema lives here rather than there.
447
+ // These rules stay local because the manifest's versions are strictly
448
+ // narrower than the server's: assetPathSchema below also refuses a
449
+ // "public/" prefix and non-text extensions, neither of which
450
+ // api-schemas' AssetPathSchema does. They are still deliberate mirrors
451
+ // of api-schemas' AssetPathSchema / TemplateAliasSchema, so a change
452
+ // there wants a matching change here.
453
+ const TEMPLATE_ALIAS_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
454
+ // A path segment: starts alnum, then alnum/dot/dash/underscore. This alone
455
+ // rejects "." and ".." segments (both start with a dot, never alnum) —
456
+ // no separate traversal check needed.
457
+ const PATH_SEGMENT_REGEX = /^[a-z0-9][a-z0-9._-]*$/i;
458
+ // Case-insensitive first-segment refusal — same reserved roots the
459
+ // request pipeline enforces for real routes (S192 §6 / since S184).
460
+ const RESERVED_ASSET_ROOTS = new Set(["kardalum", "api", "docs", "plugin-assets", "media"]);
461
+ // I3 (S196 final-fix wave): registered assets (contributions.assets) are
462
+ // the admin-editable css/js layer per the S192 spec — the install pipeline
463
+ // reads a declared asset's file as utf8 and registers it as TEXT content
464
+ // with version history, so a binary file declared here would be silently
465
+ // UTF-8-mangled on install. Ship binaries as unregistered public/ files
466
+ // instead (still copied byte-for-byte, just without a registry row). This
467
+ // allowlist is intentionally narrower than asset-fs.ts's isTextPath (which
468
+ // classifies the walked, unregistered tree and is more permissive) — it is
469
+ // mirrored byte-for-byte in kardalum plugin's checks/templates.ts and the
470
+ // marketplace's validation-checks.ts; keep all three in lockstep.
471
+ const REGISTERED_ASSET_TEXT_EXTENSIONS = new Set(["css", "js", "mjs", "json", "svg", "txt", "md"]);
472
+ function hasAllowedRegisteredAssetExtension(value) {
473
+ const base = value.split("/").pop() ?? value;
474
+ const dot = base.lastIndexOf(".");
475
+ if (dot <= 0)
476
+ return false; // no extension, or a dotfile with no extension of its own
477
+ return REGISTERED_ASSET_TEXT_EXTENSIONS.has(base.slice(dot + 1).toLowerCase());
478
+ }
479
+ function isRelativeSlashPath(value) {
480
+ return value.length > 0 && !value.startsWith("/") && !value.includes("\\");
481
+ }
482
+ function hasValidSegments(value) {
483
+ return value.split("/").every((segment) => PATH_SEGMENT_REGEX.test(segment));
484
+ }
485
+ const templateAliasSchema = z
486
+ .string()
487
+ .min(1)
488
+ .max(120)
489
+ .regex(TEMPLATE_ALIAS_REGEX, "must be lowercase kebab-case, e.g. product-page");
490
+ const templateFileSchema = z
491
+ .string()
492
+ .min(1)
493
+ .max(255)
494
+ .refine(isRelativeSlashPath, {
495
+ message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
496
+ })
497
+ .refine((value) => value.toLowerCase().endsWith(".liquid"), { message: "must end with .liquid" })
498
+ .refine(hasValidSegments, {
499
+ message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
500
+ });
501
+ const assetPathSchema = z
502
+ .string()
503
+ .min(1)
504
+ .max(400)
505
+ .refine(isRelativeSlashPath, {
506
+ message: "must be a relative path using forward slashes (no leading \"/\", no \"\\\\\")",
507
+ })
508
+ .refine(hasValidSegments, {
509
+ message: 'path segments must match [a-z0-9][a-z0-9._-]*: no "." or ".." segments',
510
+ })
511
+ .refine((value) => {
512
+ const firstSegment = value.split("/")[0]?.toLowerCase() ?? "";
513
+ return !RESERVED_ASSET_ROOTS.has(firstSegment);
514
+ }, { message: `must not be rooted at a reserved path (${[...RESERVED_ASSET_ROOTS].sort().join(", ")})` })
515
+ // contributions.assets entries flow verbatim into the server's
516
+ // AssetMirrorService.register at install time, whose AssetPathSchema is
517
+ // already public/-relative — a "public/"-prefixed entry here would
518
+ // resolve to public/public/…. Rejecting the prefix outright (rather than
519
+ // just documenting the bare convention) makes the ambiguity impossible
520
+ // for plugin authors to hit.
521
+ .refine((value) => (value.split("/")[0]?.toLowerCase() ?? "") !== "public", {
522
+ message: 'declare asset paths relative to public/: drop the "public/" prefix',
523
+ })
524
+ // I3: registered assets are text-only — see REGISTERED_ASSET_TEXT_EXTENSIONS above.
525
+ .refine(hasAllowedRegisteredAssetExtension, {
526
+ message: "registered assets are text files editable in the admin: ship binary files as unregistered public/ files instead",
527
+ });
528
+ const templateEntrySchema = z
529
+ .object({
530
+ file: templateFileSchema,
531
+ name: z.string().min(1),
532
+ alias: templateAliasSchema,
533
+ kind: z.enum(TEMPLATE_KINDS),
534
+ documentType: z.string().min(1).optional(),
535
+ })
536
+ .strict();
537
+ // The templates/assets cross-checks, run by contributionsSchema for every
538
+ // manifest (S268: one contributions object, so one place this fires).
539
+ // `documentTypes` is read structurally: a manifest that declares none can
540
+ // never resolve a `documentType` reference, which is the correct outcome
541
+ // rather than a special case.
542
+ function checkTemplateAndAssetContributions(value, ctx) {
543
+ const documentTypeNames = new Set((value.documentTypes ?? []).map((dt) => dt.name));
544
+ const seenAliases = new Set();
545
+ const seenFiles = new Set();
546
+ (value.templates ?? []).forEach((template, index) => {
547
+ if (seenAliases.has(template.alias)) {
548
+ ctx.addIssue({
549
+ code: "custom",
550
+ message: `Duplicate template alias "${template.alias}": aliases must be unique within a manifest`,
551
+ path: ["templates", index, "alias"],
552
+ });
553
+ }
554
+ seenAliases.add(template.alias);
555
+ if (seenFiles.has(template.file)) {
556
+ ctx.addIssue({
557
+ code: "custom",
558
+ message: `Duplicate template file "${template.file}": files must be unique within a manifest`,
559
+ path: ["templates", index, "file"],
560
+ });
561
+ }
562
+ seenFiles.add(template.file);
563
+ if (template.kind === "page") {
564
+ if (template.documentType !== undefined && !documentTypeNames.has(template.documentType)) {
565
+ ctx.addIssue({
566
+ code: "custom",
567
+ message: `documentType "${template.documentType}" does not match any name in this manifest's documentTypes contribution`,
568
+ path: ["templates", index, "documentType"],
569
+ });
570
+ }
571
+ }
572
+ else if (template.documentType !== undefined) {
573
+ ctx.addIssue({
574
+ code: "custom",
575
+ message: `documentType is only allowed on "page" kind templates, not "${template.kind}"`,
576
+ path: ["templates", index, "documentType"],
577
+ });
578
+ }
579
+ });
580
+ const seenAssets = new Set();
581
+ (value.assets ?? []).forEach((asset, index) => {
582
+ if (seenAssets.has(asset)) {
583
+ ctx.addIssue({
584
+ code: "custom",
585
+ message: `Duplicate asset path "${asset}": asset paths must be unique within a manifest`,
586
+ path: ["assets", index],
587
+ });
588
+ }
589
+ seenAssets.add(asset);
590
+ });
591
+ }
592
+ // A slot's id is the last segment of its URL (spec D3), so it must be unique
593
+ // where its URL would collide: among this plugin's sections, within one
594
+ // section's rail, and among this plugin's built-in rail entries. Across those
595
+ // three lists the same id is fine, because the URLs differ
596
+ // (/plugins/<plugin>/<id>, /plugins/<plugin>/<section>/<id>,
597
+ // /<built-in>/plugins/<plugin>/<id>), and two plugins may share any id
598
+ // because every one of those URLs carries the plugin's id (D8).
599
+ function checkSlotContributions(value, ctx) {
600
+ const unique = (entries, path, what) => {
601
+ const seen = new Set();
602
+ entries.forEach((entry, index) => {
603
+ if (seen.has(entry.id)) {
604
+ ctx.addIssue({
605
+ code: "custom",
606
+ message: `Duplicate ${what} id "${entry.id}": ids must be unique ${what === "rail entry" ? "within one section's rail" : `within ${path[0]}`}, because the id is part of the slot's URL`,
607
+ path: [...path, index, "id"],
608
+ });
609
+ }
610
+ seen.add(entry.id);
611
+ });
612
+ };
613
+ const sections = value.adminSections ?? [];
614
+ unique(sections, ["adminSections"], "section");
615
+ sections.forEach((section, index) => unique(section.rail ?? [], ["adminSections", index, "rail"], "rail entry"));
616
+ unique(value.railEntries ?? [], ["railEntries"], "built-in rail entry");
617
+ }
618
+ // Every action a plugin declares must sit in that plugin's own namespace (its
619
+ // full reverse-domain id plus a dot), so one plugin cannot declare an action in
620
+ // another plugin's namespace or in core's. Whether an apiRoute must declare one
621
+ // at all is api-schemas' checkApiRouteActions, the one rule the marketplace
622
+ // door runs too.
623
+ function checkActionContributions(value, ctx) {
624
+ const contributions = value.contributions;
625
+ // A section's own rail entries are gated too (S280). They are not a
626
+ // contribution key of their own, so they are walked here, beside the
627
+ // section that carries them, under the path an author can find.
628
+ (contributions.adminSections ?? []).forEach((section, index) => {
629
+ (section.rail ?? []).forEach((entry, railIndex) => {
630
+ if (entry.action !== undefined && !isPluginActionFor(entry.action, value.id)) {
631
+ ctx.addIssue({
632
+ code: "custom",
633
+ message: `action "${entry.action}" must be prefixed with this plugin's id "${value.id}."`,
634
+ path: ["contributions", "adminSections", index, "rail", railIndex, "action"],
635
+ });
636
+ }
637
+ });
638
+ });
639
+ // Derived from the classification on CONTRIBUTION_RULES, never a literal
640
+ // list, so a newly gated contribution kind cannot skip this check.
641
+ for (const key of CONTRIBUTION_KEYS.filter(isActionGated)) {
642
+ (contributions[key] ?? []).forEach((entry, index) => {
643
+ if (entry.action === undefined) {
644
+ // Whether an apiRoute may omit its action is checkApiRouteActions' to
645
+ // say (only a public route may), run once on the whole manifest below;
646
+ // every other gated kind requires its action through its own schema.
647
+ return;
648
+ }
649
+ if (!isPluginActionFor(entry.action, value.id)) {
650
+ ctx.addIssue({
651
+ code: "custom",
652
+ message: `action "${entry.action}" must be prefixed with this plugin's id "${value.id}."`,
653
+ path: ["contributions", key, index, "action"],
654
+ });
655
+ }
656
+ });
657
+ }
658
+ }
659
+ // S274b: the rule itself lives in api-schemas (spec D3) so the marketplace
660
+ // runs the same function at submission; this adapter only maps its issues
661
+ // onto the Zod context.
662
+ function checkActionDeclarations(value, ctx) {
663
+ for (const issue of checkActionDeclarationsRule(value)) {
664
+ ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
665
+ }
666
+ }
667
+ // --- contributions: one ungated surface (S268) ------------------------------
668
+ // Every key optional, and the plugin's `type` gates none of them. .strict()
669
+ // stays: a key this contract does not define is still an error, so a typo
670
+ // and a field removed by a later version both fail loudly instead of being
671
+ // silently dropped. The two cross-checks it runs are what still binds, and
672
+ // they now run for every manifest rather than for some of the old variants.
673
+ const contributionsShape = {
674
+ dataTypes: z.array(DataTypePluginSchema).optional(),
675
+ adminSections: z.array(adminSectionSchema).optional(),
676
+ railEntries: z.array(railEntrySchema).optional(),
677
+ dashboardWidgets: z.array(dashboardWidgetSchema).optional(),
678
+ apiRoutes: z.array(apiRouteSchema).optional(),
679
+ hooks: hooksSchema.optional(),
680
+ scheduledTasks: z.array(scheduledTaskSchema).optional(),
681
+ mediaProcessors: z.array(mediaProcessorSchema).optional(),
682
+ settingsPages: z.array(settingsPageSchema).optional(),
683
+ contentTreeActions: z.array(contentTreeActionSchema).optional(),
684
+ editorToolbar: z.array(editorToolbarSchema).optional(),
685
+ exposedServices: z.array(exposedServiceSchema).optional(),
686
+ serializers: serializerContributionSchema.optional(),
687
+ documentTypes: manifestDocumentTypesSchema,
688
+ themeTokens: themeTokensSchema.optional(),
689
+ templates: z.array(templateEntrySchema).optional(),
690
+ assets: z.array(assetPathSchema).optional(),
691
+ // manifestIdSchema, not the shared one: these are the ids of OTHER
692
+ // PLUGINS, each of which has a manifest and so is itself capped. A
693
+ // four-segment entry here could never resolve to an installable plugin,
694
+ // so catching it at publish beats discovering it at install.
695
+ bundledPlugins: z.array(manifestIdSchema).optional(),
696
+ bundledTemplate: bundledTemplateSchema.optional(),
697
+ };
698
+ const contributionsSchema = z
699
+ .object(contributionsShape)
700
+ .strict()
701
+ .superRefine(checkTemplateAndAssetContributions)
702
+ .superRefine(checkSlotContributions);
703
+ /**
704
+ * Every contribution key this contract defines, at runtime, derived from
705
+ * the schema above so it cannot drift from it.
706
+ *
707
+ * Exists for the conformance tests that partition these keys into
708
+ * view-bearing and not (S268 Task 3 review, F3). Splitting a list by hand
709
+ * has a third outcome besides "in the right half" and "in the wrong
710
+ * half": in neither half, and therefore never exercised, which is how a
711
+ * mirror of VIEW_BEARING_CONTRIBUTIONS can diverge and still be green.
712
+ * Counting against this set is what closes that.
713
+ */
714
+ export const CONTRIBUTION_KEYS = Object.keys(contributionsShape);
715
+ // --- the manifest -----------------------------------------------------------
716
+ const baseFields = {
717
+ id: manifestIdSchema,
718
+ name: z.string().min(1),
719
+ // Non-empty for now; strict semver checking belongs to
720
+ // `kardalum plugin validate` (Month 7).
721
+ version: z.string().min(1),
722
+ description: z.string().min(1),
723
+ author: z.string().min(1),
724
+ license: z.string().min(1),
725
+ price: z.number().nonnegative().optional(),
726
+ // Optional by design: sideloaded/dev plugins are unsigned (Tier 2).
727
+ signature: z.string().optional(),
728
+ cmsVersion: z.string().min(1),
729
+ // Capped for the same reason as bundledPlugins above: a dependency names
730
+ // another plugin's manifest id.
731
+ pluginDependencies: z.array(manifestIdSchema).optional(),
732
+ databaseCompatibility: databaseCompatibilitySchema,
733
+ // Optional: a plugin that claims neither thing writes nothing, rather
734
+ // than three falses.
735
+ assertions: AssertionsSchema.optional(),
736
+ migrations: z.array(pluginMigrationSchema).optional(),
737
+ onInstall: callable("onInstall").optional(),
738
+ onUninstall: callable("onUninstall").optional(),
739
+ onActivate: callable("onActivate").optional(),
740
+ onDeactivate: callable("onDeactivate").optional(),
741
+ onUpdate: callable("onUpdate").optional(),
742
+ migrationHooks: migrationHooksSchema.optional(),
743
+ actions: z.array(PluginActionDeclarationSchema).optional(),
744
+ roles: z.array(PluginRoleOfferSchema).optional(),
745
+ docs: z.array(PluginDocsPageSchema).optional(),
746
+ // S291: the docs pages' language, a code under the same rule as a slot
747
+ // label's keys (CultureSchema), so "German" is refused rather than shown,
748
+ // and at most 35 characters: DocsLanguageSchema is the one rule the
749
+ // marketplace's check and its stored languages apply too.
750
+ docsLanguage: DocsLanguageSchema.optional(),
751
+ // S292: what the install asks. The shape is api-schemas'
752
+ // PluginInstallDeclarationSchema; the rule over it (caps, distinct ids,
753
+ // defaults among the choices) runs below through checkInstallDeclaration,
754
+ // the function `kardalum plugin validate` and the marketplace door run.
755
+ install: PluginInstallDeclarationSchema.optional(),
756
+ };
757
+ const pluginTypeSchema = z.enum(PLUGIN_TYPES);
758
+ // One manifest, no union (S268). `type` is a marketplace listing label
759
+ // that parses as one of seven values and gates nothing; what a plugin may
760
+ // do is decided by the capability list derived from `contributions` and by
761
+ // marketplace review. .strict() here is the other half of the contract:
762
+ // an unknown top-level key is still rejected.
763
+ export const CMSPluginSchema = z
764
+ .object({ ...baseFields, type: pluginTypeSchema, contributions: contributionsSchema })
765
+ .strict()
766
+ .superRefine(checkActionContributions)
767
+ .superRefine(checkActionDeclarations)
768
+ // S295 (2026-10-14-s295-routes-fastify-knows-about-design.md 3.1): the rule
769
+ // `kardalum plugin validate` and the marketplace door run too, rooted at the
770
+ // manifest.
771
+ .superRefine((value, ctx) => {
772
+ for (const issue of checkApiRouteDeclarations(value)) {
773
+ ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
774
+ }
775
+ })
776
+ // S299 (2026-10-15-s299-tokens-that-carry-actions-design.md D15): an admin-tier
777
+ // or apiKey-tier apiRoute names its action; the marketplace door runs the same
778
+ // function on manifest.json.
779
+ .superRefine((value, ctx) => {
780
+ for (const issue of checkApiRouteActions(value)) {
781
+ ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
782
+ }
783
+ })
784
+ .superRefine((value, ctx) => {
785
+ for (const issue of checkDocsDeclaration(value.docs ?? [])) {
786
+ ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
787
+ }
788
+ })
789
+ .superRefine((value, ctx) => {
790
+ if (!value.install)
791
+ return;
792
+ // The rule reads only a declaration its schema parsed. A refinement still
793
+ // runs when a field failed a check (an id the id rule refused), and the
794
+ // rule would then report that id a second time, as "used more than once".
795
+ const install = PluginInstallDeclarationSchema.safeParse(value.install);
796
+ if (!install.success)
797
+ return;
798
+ for (const issue of checkInstallDeclaration(install.data)) {
799
+ ctx.addIssue({ code: "custom", message: issue.message, path: issue.path });
800
+ }
801
+ });
802
+ // Shared by validatePluginManifest and definePlugin — one formatting
803
+ // convention for every validation surface: `path: message`.
804
+ export function formatIssues(issues) {
805
+ return issues.map((issue) => {
806
+ const path = issue.path.join(".");
807
+ return path ? `${path}: ${issue.message}` : issue.message;
808
+ });
809
+ }
810
+ /**
811
+ * Validate an untrusted value as a plugin manifest. The registry's
812
+ * install() (Session 62) and `kardalum plugin validate` (Month 7) both go
813
+ * through this: errors come back as readable `path: message` strings
814
+ * (e.g. `contributions.adminSection: Unrecognized key ...` for a key this
815
+ * contract does not define).
816
+ */
817
+ export function validatePluginManifest(value) {
818
+ const result = CMSPluginSchema.safeParse(value);
819
+ if (result.success) {
820
+ return { ok: true, manifest: result.data };
821
+ }
822
+ return { ok: false, errors: formatIssues(result.error.issues) };
823
+ }