@kardalum/plugin-sdk 0.20.0 → 0.21.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 (323) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/admin-section-registry.d.ts +33 -1
  3. package/dist/admin-section-registry.js +67 -0
  4. package/dist/capabilities.js +46 -1
  5. package/dist/consent-entry.d.ts +11 -0
  6. package/dist/consent-entry.js +18 -0
  7. package/dist/content-library.d.ts +17 -0
  8. package/dist/content-list-extensions.d.ts +50 -0
  9. package/dist/content-list-extensions.js +11 -0
  10. package/dist/content-picker/page-picker-sheet.d.ts +2 -0
  11. package/dist/content-picker/page-picker-sheet.js +1 -1
  12. package/dist/content-picker/page-picker.d.ts +18 -0
  13. package/dist/content-picker/page-picker.js +20 -0
  14. package/dist/datatype-validation.js +10 -2
  15. package/dist/datatypes-entry.d.ts +1 -0
  16. package/dist/datatypes-entry.js +2 -0
  17. package/dist/entitlement-types.d.ts +18 -1
  18. package/dist/host-entry.d.ts +7 -1
  19. package/dist/host-entry.js +14 -1
  20. package/dist/index.d.ts +35 -7
  21. package/dist/index.js +46 -5
  22. package/dist/mail.d.ts +6 -2
  23. package/dist/manifest-entry.d.ts +22 -4
  24. package/dist/manifest-entry.js +25 -1
  25. package/dist/manifest-schema.d.ts +570 -31
  26. package/dist/manifest-schema.js +240 -12
  27. package/dist/manifest.d.ts +757 -32
  28. package/dist/manifest.js +8 -4
  29. package/dist/plugin-context.d.ts +47 -0
  30. package/dist/plugin-context.js +27 -0
  31. package/dist/plugin-permissions.d.ts +18 -0
  32. package/dist/plugin-permissions.js +25 -0
  33. package/dist/plugin-screen-context.d.ts +152 -11
  34. package/dist/plugin-screen-context.js +30 -0
  35. package/dist/providers.d.ts +47 -2
  36. package/dist/render-page.d.ts +15 -0
  37. package/dist/render-page.js +20 -0
  38. package/dist/richtext/block-panel.d.ts +12 -1
  39. package/dist/richtext/block-panel.js +27 -21
  40. package/dist/richtext/button-view.d.ts +11 -0
  41. package/dist/richtext/button-view.js +45 -0
  42. package/dist/richtext/content-guard.d.ts +4 -0
  43. package/dist/richtext/content-guard.js +27 -0
  44. package/dist/richtext/editor-handle.d.ts +34 -0
  45. package/dist/richtext/editor-handle.js +225 -0
  46. package/dist/richtext/extensions.d.ts +6 -0
  47. package/dist/richtext/extensions.js +16 -0
  48. package/dist/richtext/insert-menu.d.ts +6 -1
  49. package/dist/richtext/insert-menu.js +38 -18
  50. package/dist/richtext/item-attributes.d.ts +6 -0
  51. package/dist/richtext/item-attributes.js +19 -0
  52. package/dist/richtext/item-panel.d.ts +25 -0
  53. package/dist/richtext/item-panel.js +118 -0
  54. package/dist/richtext/item-view.d.ts +58 -0
  55. package/dist/richtext/item-view.js +172 -0
  56. package/dist/richtext/mark-form.d.ts +10 -0
  57. package/dist/richtext/mark-form.js +38 -0
  58. package/dist/richtext/paste-choice.d.ts +9 -0
  59. package/dist/richtext/paste-choice.js +13 -0
  60. package/dist/richtext/plugin-items.d.ts +72 -0
  61. package/dist/richtext/plugin-items.js +562 -0
  62. package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
  63. package/dist/richtext/plugin-mark-tooltips.js +44 -0
  64. package/dist/richtext/plugin-toolbar.d.ts +57 -0
  65. package/dist/richtext/plugin-toolbar.js +186 -0
  66. package/dist/richtext/rich-item-icons.d.ts +5 -0
  67. package/dist/richtext/rich-item-icons.js +42 -0
  68. package/dist/richtext/rich-items.d.ts +42 -0
  69. package/dist/richtext/rich-items.js +68 -0
  70. package/dist/richtext/rich-text-view-host.d.ts +24 -0
  71. package/dist/richtext/rich-text-view-host.js +11 -0
  72. package/dist/richtext/toolbar-button.d.ts +16 -0
  73. package/dist/richtext/toolbar-button.js +9 -0
  74. package/dist/richtext/url-paste.d.ts +20 -0
  75. package/dist/richtext/url-paste.js +82 -0
  76. package/dist/richtext-html-entry.d.ts +5 -0
  77. package/dist/richtext-html-entry.js +11 -0
  78. package/dist/sdk-strings.d.ts +59 -0
  79. package/dist/sdk-strings.js +64 -0
  80. package/dist/service-contract.d.ts +17 -0
  81. package/dist/service-contract.js +39 -0
  82. package/dist/services.d.ts +114 -0
  83. package/dist/services.js +1 -0
  84. package/dist/structured-storage-types.d.ts +124 -4
  85. package/dist/tailwind.js +10 -5
  86. package/dist/template-reads.d.ts +16 -0
  87. package/dist/template-reads.js +21 -0
  88. package/dist/testing-entry.d.ts +38 -0
  89. package/dist/testing-entry.js +173 -0
  90. package/dist/text-entry.d.ts +1 -1
  91. package/dist/text-entry.js +3 -2
  92. package/dist/tokens/system-dark.css +1 -0
  93. package/dist/tokens/tailwind-theme.css +2 -0
  94. package/dist/tokens/tokens.css +4 -0
  95. package/dist/tokens/tokens.json +5 -1
  96. package/dist/uploads.d.ts +43 -0
  97. package/dist/uploads.js +1 -0
  98. package/dist/user-library.d.ts +51 -0
  99. package/dist/user-library.js +15 -0
  100. package/dist/view-helpers.d.ts +18 -0
  101. package/dist/view-helpers.js +64 -0
  102. package/dist/views/content-list-view.js +207 -8
  103. package/dist/views/content-picker-view.js +1 -1
  104. package/dist/views/rich-text-view.d.ts +2 -0
  105. package/dist/views/rich-text-view.js +182 -24
  106. package/dist/views/unreadable-rich-text.d.ts +17 -0
  107. package/dist/views/unreadable-rich-text.js +40 -0
  108. package/dist/visitors.d.ts +81 -0
  109. package/dist/visitors.js +1 -0
  110. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
  111. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
  112. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
  113. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
  114. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +127 -8
  115. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +82 -7
  116. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +5 -1
  117. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +2 -2
  118. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +7 -0
  119. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +11 -0
  120. package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +1 -1
  121. package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +18 -0
  122. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +80 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +41 -2
  124. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
  126. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
  127. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
  128. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +50 -13
  129. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +19 -10
  130. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +77 -0
  131. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +37 -0
  132. package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
  133. package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
  134. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
  135. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
  136. package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
  138. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
  139. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
  140. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +52 -14
  141. package/node_modules/@kardalum/api-schemas/dist/index.js +53 -9
  142. package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
  143. package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
  144. package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +4 -2
  145. package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +6 -1
  146. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +178 -2
  147. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +10 -0
  148. package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +3 -3
  149. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +16 -0
  150. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +4 -0
  151. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +7 -0
  153. package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +51 -2
  154. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
  155. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
  156. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
  157. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
  158. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +4 -2
  159. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +12 -2
  160. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
  161. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
  162. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
  163. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
  164. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
  165. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
  166. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
  167. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
  168. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
  169. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
  170. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
  171. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
  172. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +18 -0
  173. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +18 -0
  174. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +5 -2
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +10 -2
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +48 -1
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +5 -2
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +6 -4
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +12 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +3 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +2 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +3 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +67 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +15 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +80 -15
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +67 -23
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +10 -3
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +33 -8
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +2 -1
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +7 -1
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +1 -1
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +43 -7
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +36 -5
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
  205. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
  206. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
  207. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
  208. package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
  209. package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
  210. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +10 -0
  211. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +10 -1
  212. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +171 -4
  213. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +406 -42
  214. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
  215. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
  216. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
  217. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
  218. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
  219. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
  220. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
  221. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
  222. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
  223. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
  224. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
  225. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
  226. package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
  227. package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
  228. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +303 -0
  229. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
  230. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
  231. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
  232. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +66 -1
  233. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +465 -7
  234. package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +15 -118
  235. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +110 -0
  236. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
  237. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
  238. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
  239. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +9 -2
  240. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +7 -2
  241. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +26 -0
  242. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +19 -0
  243. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
  244. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
  245. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +5 -3
  246. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +3 -1
  247. package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
  248. package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
  249. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +4 -0
  250. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +28 -0
  251. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
  252. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
  253. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +14 -0
  254. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +2 -0
  255. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
  256. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
  257. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
  258. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
  259. package/node_modules/@kardalum/api-schemas/package.json +1 -0
  260. package/node_modules/@kardalum/design-tokens/dist/build-css.js +9 -1
  261. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
  262. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +2 -0
  263. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  264. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  265. package/node_modules/@kardalum/design-tokens/dist/tokens.css +4 -0
  266. package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -0
  267. package/node_modules/@kardalum/design-tokens/dist/tokens.json +5 -1
  268. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +4 -0
  269. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +17 -0
  270. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +9 -0
  271. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +1 -1
  272. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +276 -19
  273. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
  274. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +23 -0
  275. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
  276. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
  277. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
  278. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
  279. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
  280. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  281. package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +21 -8
  282. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +1 -1
  283. package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +23 -10
  284. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
  285. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +2 -0
  286. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +2 -0
  287. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +30 -2
  288. package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +6 -2
  289. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
  290. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
  291. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +2 -0
  292. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +24 -6
  293. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +15 -0
  294. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
  295. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
  296. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +1 -1
  297. package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +14 -4
  298. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
  299. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
  300. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
  301. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
  302. package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +44 -11
  303. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +7 -0
  304. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
  305. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
  306. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
  307. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
  308. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -0
  309. package/node_modules/@kardalum/plugin-package/dist/index.js +5 -0
  310. package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
  311. package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
  312. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
  313. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
  314. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
  315. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
  316. package/node_modules/@kardalum/plugin-package/package.json +4 -0
  317. package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
  318. package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
  320. package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
  321. package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
  322. package/node_modules/@kardalum/ui/dist/index.js +2 -0
  323. package/package.json +15 -3
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ /** Where a public request goes: the site's own addresses, the delivery API (`/api/v1/`) or public media (`/media/`). */
3
+ export declare const SITE_REQUEST_SURFACES: readonly ["site", "delivery", "media"];
4
+ export type SiteRequestSurface = (typeof SITE_REQUEST_SURFACES)[number];
5
+ /** The request guards asked a request, in plugin id order; a fifth is skipped and logged. */
6
+ export declare const REQUEST_GUARDS_MAX = 4;
7
+ /** How long the core waits for one guard, in milliseconds. */
8
+ export declare const REQUEST_GUARD_TIME_MS = 50;
9
+ /** How long the core waits for all guards of one request together, counted on the plugins' calls only. */
10
+ export declare const REQUEST_GUARD_TIME_PER_REQUEST_MS = 100;
11
+ /** The statuses a guard may block with. */
12
+ export declare const REQUEST_GUARD_BLOCK_STATUSES: readonly [403, 404, 410, 429, 451, 503];
13
+ export type RequestGuardBlockStatus = (typeof REQUEST_GUARD_BLOCK_STATUSES)[number];
14
+ /** The longest text a block shows, in characters; written escaped. */
15
+ export declare const REQUEST_GUARD_MESSAGE_MAX = 300;
16
+ /** The longest wait a 429 or 503 block asks for, one day, in seconds. */
17
+ export declare const REQUEST_GUARD_RETRY_AFTER_MAX = 86400;
18
+ /** The plugins asked for headers of one response, in plugin id order; a fifth is skipped and logged. */
19
+ export declare const RESPONSE_HEADER_PLUGINS_MAX = 4;
20
+ /** How long the core waits for one plugin's headers, in milliseconds. */
21
+ export declare const RESPONSE_HEADERS_TIME_MS = 50;
22
+ /** How long the core waits for every plugin's headers of one response together, counted on the plugins' calls only. */
23
+ export declare const RESPONSE_HEADERS_TIME_PER_RESPONSE_MS = 100;
24
+ /** The header names one plugin's answer gives at most; more refuses the whole answer. */
25
+ export declare const RESPONSE_HEADERS_PER_PLUGIN_MAX = 8;
26
+ /** The longest header value, in characters (printable ASCII, so bytes too). */
27
+ export declare const RESPONSE_HEADER_VALUE_MAX = 4096;
28
+ /** The bytes of plugin headers one response carries at most (name, ": ", value and line end each). */
29
+ export declare const RESPONSE_HEADERS_BYTES_MAX = 16384;
30
+ /** The longest name the core reads before it compares it with the list. */
31
+ export declare const RESPONSE_HEADER_NAME_MAX = 64;
32
+ /** The only headers a plugin may add to a public answer, in the spelling the core writes. Never a
33
+ * cookie (consent, 35-P5), caching (35-P4's `pageCache`, whose headers the core writes for a rendered page),
34
+ * the type, length or location of an answer, or the core's CORS. After 1.0 the list only grows. */
35
+ export declare const RESPONSE_HEADER_NAMES: readonly ["Content-Security-Policy", "Content-Security-Policy-Report-Only", "Strict-Transport-Security", "Permissions-Policy", "Referrer-Policy", "X-Frame-Options", "Cross-Origin-Opener-Policy", "Cross-Origin-Embedder-Policy", "Cross-Origin-Resource-Policy", "Origin-Agent-Cluster", "X-Permitted-Cross-Domain-Policies", "X-DNS-Prefetch-Control", "X-Robots-Tag", "Reporting-Endpoints"];
36
+ export type ResponseHeaderName = (typeof RESPONSE_HEADER_NAMES)[number];
37
+ /** The listed name a plugin's key means, in the list's spelling, or null. The length is checked first. */
38
+ export declare function responseHeaderNameOf(name: string): ResponseHeaderName | null;
39
+ /** Why a header value is refused, or null: 1 to RESPONSE_HEADER_VALUE_MAX characters, each printable
40
+ * ASCII or tab, so no line break can start a second header. The reason never quotes the value. */
41
+ export declare function responseHeaderValueProblem(value: string): string | null;
42
+ /**
43
+ * A response headers answer read without trusting it: a plain object (prototype Object or none) of at
44
+ * most RESPONSE_HEADERS_PER_PLUGIN_MAX keys. Each entry is kept in the list's spelling when its name is
45
+ * listed, given once (in any case) and its value is a string the value rule takes; every other entry is
46
+ * counted as refused. A getter is the plugin's code: a throw while reading refuses the whole answer.
47
+ */
48
+ export declare function readResponseHeadersAnswer(raw: unknown): {
49
+ ok: true;
50
+ headers: Array<[ResponseHeaderName, string]>;
51
+ refused: number;
52
+ } | {
53
+ ok: false;
54
+ };
55
+ /** What a request guard answers instead of `null`: a block the core writes, or a redirect checked like a site fallback's. */
56
+ export declare const RequestGuardAnswerSchema: z.ZodUnion<readonly [z.ZodObject<{
57
+ block: z.ZodObject<{
58
+ status: z.ZodLiteral<429 | 403 | 404 | 410 | 451 | 503>;
59
+ message: z.ZodOptional<z.ZodString>;
60
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
61
+ }, z.core.$strict>;
62
+ }, z.core.$strict>, z.ZodObject<{
63
+ redirect: z.ZodObject<{
64
+ location: z.ZodString;
65
+ status: z.ZodLiteral<301 | 302 | 307 | 308>;
66
+ maxAgeSeconds: z.ZodOptional<z.ZodNumber>;
67
+ }, z.core.$strict>;
68
+ }, z.core.$strict>]>;
69
+ export type RequestGuardAnswer = z.infer<typeof RequestGuardAnswerSchema>;
@@ -0,0 +1,149 @@
1
+ import { z } from "zod";
2
+ import { SiteRedirectAnswerSchema } from "./plugin-site-extensions.js";
3
+ import { hasNoControlCharacter } from "./strict-url.js";
4
+ // M35 P2 (W2): the rules and limits of what a plugin does with a public request before anything
5
+ // answers it (`requestGuard`) and with every public answer's headers (`responseHeaders`). Both run
6
+ // for the site's own addresses, public media and the delivery API only (the server's
7
+ // site-request-surface.ts), never for the admin, sign-in or the management API. Every character
8
+ // rule is one loop over a length-capped string, never a pattern match.
9
+ /** Where a public request goes: the site's own addresses, the delivery API (`/api/v1/`) or public media (`/media/`). */
10
+ export const SITE_REQUEST_SURFACES = ["site", "delivery", "media"];
11
+ /** The request guards asked a request, in plugin id order; a fifth is skipped and logged. */
12
+ export const REQUEST_GUARDS_MAX = 4;
13
+ /** How long the core waits for one guard, in milliseconds. */
14
+ export const REQUEST_GUARD_TIME_MS = 50;
15
+ /** How long the core waits for all guards of one request together, counted on the plugins' calls only. */
16
+ export const REQUEST_GUARD_TIME_PER_REQUEST_MS = 100;
17
+ /** The statuses a guard may block with. */
18
+ export const REQUEST_GUARD_BLOCK_STATUSES = [403, 404, 410, 429, 451, 503];
19
+ /** The longest text a block shows, in characters; written escaped. */
20
+ export const REQUEST_GUARD_MESSAGE_MAX = 300;
21
+ /** The longest wait a 429 or 503 block asks for, one day, in seconds. */
22
+ export const REQUEST_GUARD_RETRY_AFTER_MAX = 86_400;
23
+ /** The plugins asked for headers of one response, in plugin id order; a fifth is skipped and logged. */
24
+ export const RESPONSE_HEADER_PLUGINS_MAX = 4;
25
+ /** How long the core waits for one plugin's headers, in milliseconds. */
26
+ export const RESPONSE_HEADERS_TIME_MS = 50;
27
+ /** How long the core waits for every plugin's headers of one response together, counted on the plugins' calls only. */
28
+ export const RESPONSE_HEADERS_TIME_PER_RESPONSE_MS = 100;
29
+ /** The header names one plugin's answer gives at most; more refuses the whole answer. */
30
+ export const RESPONSE_HEADERS_PER_PLUGIN_MAX = 8;
31
+ /** The longest header value, in characters (printable ASCII, so bytes too). */
32
+ export const RESPONSE_HEADER_VALUE_MAX = 4_096;
33
+ /** The bytes of plugin headers one response carries at most (name, ": ", value and line end each). */
34
+ export const RESPONSE_HEADERS_BYTES_MAX = 16_384;
35
+ /** The longest name the core reads before it compares it with the list. */
36
+ export const RESPONSE_HEADER_NAME_MAX = 64;
37
+ /** The only headers a plugin may add to a public answer, in the spelling the core writes. Never a
38
+ * cookie (consent, 35-P5), caching (35-P4's `pageCache`, whose headers the core writes for a rendered page),
39
+ * the type, length or location of an answer, or the core's CORS. After 1.0 the list only grows. */
40
+ export const RESPONSE_HEADER_NAMES = [
41
+ "Content-Security-Policy",
42
+ "Content-Security-Policy-Report-Only",
43
+ "Strict-Transport-Security",
44
+ "Permissions-Policy",
45
+ "Referrer-Policy",
46
+ "X-Frame-Options",
47
+ "Cross-Origin-Opener-Policy",
48
+ "Cross-Origin-Embedder-Policy",
49
+ "Cross-Origin-Resource-Policy",
50
+ "Origin-Agent-Cluster",
51
+ "X-Permitted-Cross-Domain-Policies",
52
+ "X-DNS-Prefetch-Control",
53
+ "X-Robots-Tag",
54
+ "Reporting-Endpoints",
55
+ ];
56
+ /** ASCII lower case, one loop; any other character stays as it is (and so matches no listed name). */
57
+ function asciiLower(value) {
58
+ let out = "";
59
+ for (let index = 0; index < value.length; index += 1) {
60
+ const code = value.charCodeAt(index);
61
+ out += code >= 0x41 && code <= 0x5a ? String.fromCharCode(code + 0x20) : value[index];
62
+ }
63
+ return out;
64
+ }
65
+ const NAMES_BY_LOWER = new Map(RESPONSE_HEADER_NAMES.map((name) => [asciiLower(name), name]));
66
+ /** The listed name a plugin's key means, in the list's spelling, or null. The length is checked first. */
67
+ export function responseHeaderNameOf(name) {
68
+ if (typeof name !== "string" || name.length === 0 || name.length > RESPONSE_HEADER_NAME_MAX)
69
+ return null;
70
+ return NAMES_BY_LOWER.get(asciiLower(name)) ?? null;
71
+ }
72
+ /** Why a header value is refused, or null: 1 to RESPONSE_HEADER_VALUE_MAX characters, each printable
73
+ * ASCII or tab, so no line break can start a second header. The reason never quotes the value. */
74
+ export function responseHeaderValueProblem(value) {
75
+ if (typeof value !== "string")
76
+ return "is not a string";
77
+ if (value.length === 0)
78
+ return "is empty";
79
+ if (value.length > RESPONSE_HEADER_VALUE_MAX)
80
+ return `is more than ${RESPONSE_HEADER_VALUE_MAX} characters`;
81
+ for (let index = 0; index < value.length; index += 1) {
82
+ const code = value.charCodeAt(index);
83
+ if (code !== 0x09 && (code < 0x20 || code > 0x7e))
84
+ return "holds a character that is not printable ASCII";
85
+ }
86
+ return null;
87
+ }
88
+ /**
89
+ * A response headers answer read without trusting it: a plain object (prototype Object or none) of at
90
+ * most RESPONSE_HEADERS_PER_PLUGIN_MAX keys. Each entry is kept in the list's spelling when its name is
91
+ * listed, given once (in any case) and its value is a string the value rule takes; every other entry is
92
+ * counted as refused. A getter is the plugin's code: a throw while reading refuses the whole answer.
93
+ */
94
+ export function readResponseHeadersAnswer(raw) {
95
+ if (raw === null || typeof raw !== "object")
96
+ return { ok: false };
97
+ let keys;
98
+ try {
99
+ // Inside the try: Array.isArray throws on a revoked Proxy.
100
+ if (Array.isArray(raw))
101
+ return { ok: false };
102
+ const prototype = Object.getPrototypeOf(raw);
103
+ if (prototype !== Object.prototype && prototype !== null)
104
+ return { ok: false };
105
+ keys = Object.keys(raw);
106
+ }
107
+ catch {
108
+ return { ok: false };
109
+ }
110
+ if (keys.length > RESPONSE_HEADERS_PER_PLUGIN_MAX)
111
+ return { ok: false };
112
+ const headers = [];
113
+ const seen = new Set();
114
+ let refused = 0;
115
+ for (const key of keys) {
116
+ let value;
117
+ try {
118
+ value = raw[key];
119
+ }
120
+ catch {
121
+ return { ok: false };
122
+ }
123
+ const name = responseHeaderNameOf(key);
124
+ if (name === null || seen.has(name) || typeof value !== "string" || responseHeaderValueProblem(value) !== null) {
125
+ refused += 1;
126
+ continue;
127
+ }
128
+ seen.add(name);
129
+ headers.push([name, value]);
130
+ }
131
+ return { ok: true, headers, refused };
132
+ }
133
+ const guardMessage = z
134
+ .string()
135
+ .min(1)
136
+ .max(REQUEST_GUARD_MESSAGE_MAX)
137
+ .refine(hasNoControlCharacter, { message: "holds no control character" });
138
+ const guardBlock = z
139
+ .strictObject({
140
+ status: z.literal(REQUEST_GUARD_BLOCK_STATUSES),
141
+ message: guardMessage.optional(),
142
+ retryAfterSeconds: z.number().int().min(1).max(REQUEST_GUARD_RETRY_AFTER_MAX).optional(),
143
+ })
144
+ .refine((block) => block.retryAfterSeconds === undefined || block.status === 429 || block.status === 503, {
145
+ message: "retryAfterSeconds is only for a 429 or 503 block",
146
+ path: ["retryAfterSeconds"],
147
+ });
148
+ /** What a request guard answers instead of `null`: a block the core writes, or a redirect checked like a site fallback's. */
149
+ export const RequestGuardAnswerSchema = z.union([z.strictObject({ block: guardBlock }), SiteRedirectAnswerSchema]);
@@ -0,0 +1,5 @@
1
+ /** The admin's layer for every plugin stylesheet. */
2
+ export declare const PLUGIN_STYLES_LAYER = "plugins";
3
+ /** The plugin's own sub-layer: the id with each "." written "_" (an id holds no "_", so two ids never
4
+ * share a layer, and the name is one CSS identifier per dot-separated part). */
5
+ export declare function pluginStylesLayerName(pluginId: string): string;
@@ -0,0 +1,13 @@
1
+ // M35 C3 (design D3): the cascade layer a plugin's stylesheet sits in. The admin declares
2
+ // `@layer properties, theme, base, plugins, components, utilities;` first in its stylesheet, so a plugin's
3
+ // rules beat the admin's base reset and lose to its components and utilities where both set a property,
4
+ // and never touch the design token variables (unlayered); Tailwind's theme variables are kept by the check's
5
+ // refusal of `:root` and global rules. `kardalum plugin build` wraps each stylesheet in the plugin's own sub-layer; the
6
+ // "admin styles" delivery check refuses one that is not.
7
+ /** The admin's layer for every plugin stylesheet. */
8
+ export const PLUGIN_STYLES_LAYER = "plugins";
9
+ /** The plugin's own sub-layer: the id with each "." written "_" (an id holds no "_", so two ids never
10
+ * share a layer, and the name is one CSS identifier per dot-separated part). */
11
+ export function pluginStylesLayerName(pluginId) {
12
+ return `${PLUGIN_STYLES_LAYER}.${pluginId.split(".").join("_")}`;
13
+ }
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ /** Files one request may carry. */
3
+ export declare const UPLOAD_FILES_MAX = 10;
4
+ /** The largest file a route may declare (100 MiB). At serve time the site's media size setting caps it too. */
5
+ export declare const UPLOAD_FILE_BYTES_MAX = 104857600;
6
+ /** The most bytes of files one request may carry (200 MiB). */
7
+ export declare const UPLOAD_REQUEST_BYTES_MAX = 209715200;
8
+ /** Text fields beside the files: as many as a site form takes (SITE_ROUTE_FORM_FIELDS_MAX), at most as many bytes
9
+ * together as a site form's body (SITE_ROUTE_BODY_LIMIT_BYTES). Restated, not imported, because
10
+ * plugin-site-extensions imports this file; plugin-uploads.test.ts pins both to those constants. */
11
+ export declare const UPLOAD_FIELDS_MAX = 200;
12
+ export declare const UPLOAD_FIELDS_BYTES_MAX = 65536;
13
+ export declare const UPLOAD_FIELD_NAME_MAX = 100;
14
+ /** Boundaries and part headers beyond the files and the fields: what a Content-Length may add before it is refused. */
15
+ export declare const UPLOAD_ENVELOPE_BYTES_MAX = 65536;
16
+ export declare const UPLOAD_DECLARED_TYPES_MAX = 20;
17
+ /** The longest media type label read; a longer one is no type. */
18
+ export declare const UPLOAD_TYPE_NAME_MAX = 100;
19
+ /** The bytes of request bodies one process holds for uploads at once (256 MiB); past it a request answers 503. */
20
+ export declare const UPLOADS_IN_FLIGHT_BYTES_MAX = 268435456;
21
+ export declare const UPLOAD_BUSY_RETRY_SECONDS = 5;
22
+ /** A body's read deadline: this much time, plus its reservation at UPLOAD_READ_MIN_BYTES_PER_SECOND (128 KiB/s,
23
+ * about 1 Mbit/s). A body still unread then answers 408 (upload_slow), and its reservation is released. */
24
+ export declare const UPLOAD_READ_BASE_MS = 30000;
25
+ export declare const UPLOAD_READ_MIN_BYTES_PER_SECOND = 131072;
26
+ /** A visitor's requests with files, per plugin and address, in one window (per process). */
27
+ export declare const VISITOR_UPLOAD_SENDS_PER_ADDRESS_MAX = 20;
28
+ export declare const VISITOR_UPLOAD_SENDS_WINDOW_SECONDS = 3600;
29
+ /** All visitors' kept files together, unless KARDALUM_VISITOR_UPLOADS_MAX_BYTES says otherwise (2 GiB). */
30
+ export declare const VISITOR_UPLOADS_STORED_BYTES_DEFAULT = 2147483648;
31
+ /** The part of that anonymous visitors' files may take, in percent. */
32
+ export declare const VISITOR_UPLOADS_ANONYMOUS_SHARE_PERCENT = 50;
33
+ /** One visitor account's kept files together (100 MiB). */
34
+ export declare const VISITOR_UPLOADS_PER_ACCOUNT_BYTES_MAX = 104857600;
35
+ /** On local disk, a keep that would leave less free than this is refused (1 GiB). */
36
+ export declare const UPLOAD_LOCAL_DISK_FREE_MIN_BYTES = 1073741824;
37
+ /** How often the files of deleted visitor accounts are erased, and how many a batch. */
38
+ export declare const VISITOR_UPLOAD_ERASE_INTERVAL_MS = 900000;
39
+ export declare const VISITOR_UPLOAD_ERASE_BATCH = 100;
40
+ /** The most files a visitor's account export lists, newest first. */
41
+ export declare const VISITOR_EXPORT_UPLOADS_MAX = 1000;
42
+ export declare const API_ROUTE_UPLOAD_METHODS: readonly ["POST", "PUT", "PATCH"];
43
+ export declare const SITE_ROUTE_UPLOAD_METHODS: readonly ["POST"];
44
+ /** The families a route may declare as `<family>/*`. */
45
+ export declare const UPLOAD_TYPE_FAMILIES: readonly ["image", "audio", "video"];
46
+ export declare const UPLOAD_TYPES: readonly string[];
47
+ /** Labels that say nothing, so the name's extension decides (phones send `application/octet-stream`). */
48
+ export declare const UPLOAD_GENERIC_LABELS: readonly string[];
49
+ export declare const UPLOAD_KEEP_REFUSALS: readonly ["invalid", "ended", "unprotected", "quota", "disk", "type", "folder", "store", "inactive", "readOnly"];
50
+ export type UploadKeepRefusal = (typeof UPLOAD_KEEP_REFUSALS)[number];
51
+ /** The `code` beside `message` of the core's refusals of a multipart body. */
52
+ export declare const UPLOAD_READ_CODES: readonly ["upload_too_large", "upload_too_many", "upload_type", "upload_malformed", "upload_busy", "upload_rate", "upload_slow", "multipart_refused"];
53
+ export type UploadReadCode = (typeof UPLOAD_READ_CODES)[number];
54
+ export declare const MULTIPART_REFUSED_MESSAGE = "This route does not take files";
55
+ /** The body of those refusals. The plugin dispatcher's 400 and 503 answer it beside the plain `{ message }`, so
56
+ * `code` reaches the caller; the route document names it for a route that takes files. */
57
+ export declare const UploadRefusalSchema: z.ZodObject<{
58
+ message: z.ZodString;
59
+ code: z.ZodEnum<{
60
+ upload_too_large: "upload_too_large";
61
+ upload_too_many: "upload_too_many";
62
+ upload_type: "upload_type";
63
+ upload_malformed: "upload_malformed";
64
+ upload_busy: "upload_busy";
65
+ upload_rate: "upload_rate";
66
+ upload_slow: "upload_slow";
67
+ multipart_refused: "multipart_refused";
68
+ }>;
69
+ }, z.core.$strip>;
70
+ export declare function uploadExtensionsOf(type: string): readonly string[] | null;
71
+ /** The listed type a name's extension names, or null. Reads at most EXTENSION_MAX characters after the last dot. */
72
+ export declare function uploadTypeOfName(name: string): string | null;
73
+ /** A part's label as a listed type: parameters dropped, trimmed, lower case, an alias read; null for any other. */
74
+ export declare function canonicalUploadType(label: string): string | null;
75
+ /** A listed type, or `<family>/*` of UPLOAD_TYPE_FAMILIES. */
76
+ export declare function isUploadTypeDeclaration(value: string): boolean;
77
+ /** The listed types a declaration admits, in list order, each once. */
78
+ export declare function expandUploadTypes(declared: readonly string[]): string[];
79
+ export interface RouteUploads {
80
+ readonly maxFiles: number;
81
+ readonly maxFileBytes: number;
82
+ readonly maxTotalBytes: number;
83
+ readonly declaredTypes: readonly string[];
84
+ readonly types: readonly string[];
85
+ }
86
+ /** Why an `uploads` value cannot stand, or null when it can. */
87
+ export declare function uploadsDeclarationProblem(uploads: unknown): string | null;
88
+ /** Why a route's `uploads` cannot stand, or null (absent, or a good declaration on one of `methods` without rawBody).
89
+ * A method outside the route's own method list is that rule's to report, as apiRouteRawBodyProblem does. */
90
+ export declare function routeUploadsProblem(route: {
91
+ method?: unknown;
92
+ uploads?: unknown;
93
+ rawBody?: unknown;
94
+ }, methods: readonly string[], what: "route" | "site route"): string | null;
95
+ /** The declaration as the server reads it, frozen, or null for anything the rule refuses. */
96
+ export declare function readRouteUploads(value: unknown): RouteUploads | null;
@@ -0,0 +1,185 @@
1
+ import { z } from "zod";
2
+ // M35 B3 (W17, G22): what a plugin route may declare to take files a caller sends, and the limits the core
3
+ // reads and keeps them under. One rule, read by the SDK's manifest schema (and through it
4
+ // `kardalum plugin validate`), the delivery checks, the marketplace door and the server. Every check is a
5
+ // length check and a forward scan or a Map lookup; no pattern runs on a declared or a sent value.
6
+ /** Files one request may carry. */
7
+ export const UPLOAD_FILES_MAX = 10;
8
+ /** The largest file a route may declare (100 MiB). At serve time the site's media size setting caps it too. */
9
+ export const UPLOAD_FILE_BYTES_MAX = 104_857_600;
10
+ /** The most bytes of files one request may carry (200 MiB). */
11
+ export const UPLOAD_REQUEST_BYTES_MAX = 209_715_200;
12
+ /** Text fields beside the files: as many as a site form takes (SITE_ROUTE_FORM_FIELDS_MAX), at most as many bytes
13
+ * together as a site form's body (SITE_ROUTE_BODY_LIMIT_BYTES). Restated, not imported, because
14
+ * plugin-site-extensions imports this file; plugin-uploads.test.ts pins both to those constants. */
15
+ export const UPLOAD_FIELDS_MAX = 200;
16
+ export const UPLOAD_FIELDS_BYTES_MAX = 65_536;
17
+ export const UPLOAD_FIELD_NAME_MAX = 100;
18
+ /** Boundaries and part headers beyond the files and the fields: what a Content-Length may add before it is refused. */
19
+ export const UPLOAD_ENVELOPE_BYTES_MAX = 65_536;
20
+ export const UPLOAD_DECLARED_TYPES_MAX = 20;
21
+ /** The longest media type label read; a longer one is no type. */
22
+ export const UPLOAD_TYPE_NAME_MAX = 100;
23
+ /** The bytes of request bodies one process holds for uploads at once (256 MiB); past it a request answers 503. */
24
+ export const UPLOADS_IN_FLIGHT_BYTES_MAX = 268_435_456;
25
+ export const UPLOAD_BUSY_RETRY_SECONDS = 5;
26
+ /** A body's read deadline: this much time, plus its reservation at UPLOAD_READ_MIN_BYTES_PER_SECOND (128 KiB/s,
27
+ * about 1 Mbit/s). A body still unread then answers 408 (upload_slow), and its reservation is released. */
28
+ export const UPLOAD_READ_BASE_MS = 30_000;
29
+ export const UPLOAD_READ_MIN_BYTES_PER_SECOND = 131_072;
30
+ /** A visitor's requests with files, per plugin and address, in one window (per process). */
31
+ export const VISITOR_UPLOAD_SENDS_PER_ADDRESS_MAX = 20;
32
+ export const VISITOR_UPLOAD_SENDS_WINDOW_SECONDS = 3_600;
33
+ /** All visitors' kept files together, unless KARDALUM_VISITOR_UPLOADS_MAX_BYTES says otherwise (2 GiB). */
34
+ export const VISITOR_UPLOADS_STORED_BYTES_DEFAULT = 2_147_483_648;
35
+ /** The part of that anonymous visitors' files may take, in percent. */
36
+ export const VISITOR_UPLOADS_ANONYMOUS_SHARE_PERCENT = 50;
37
+ /** One visitor account's kept files together (100 MiB). */
38
+ export const VISITOR_UPLOADS_PER_ACCOUNT_BYTES_MAX = 104_857_600;
39
+ /** On local disk, a keep that would leave less free than this is refused (1 GiB). */
40
+ export const UPLOAD_LOCAL_DISK_FREE_MIN_BYTES = 1_073_741_824;
41
+ /** How often the files of deleted visitor accounts are erased, and how many a batch. */
42
+ export const VISITOR_UPLOAD_ERASE_INTERVAL_MS = 900_000;
43
+ export const VISITOR_UPLOAD_ERASE_BATCH = 100;
44
+ /** The most files a visitor's account export lists, newest first. */
45
+ export const VISITOR_EXPORT_UPLOADS_MAX = 1_000;
46
+ export const API_ROUTE_UPLOAD_METHODS = ["POST", "PUT", "PATCH"];
47
+ export const SITE_ROUTE_UPLOAD_METHODS = ["POST"];
48
+ /** The families a route may declare as `<family>/*`. */
49
+ export const UPLOAD_TYPE_FAMILIES = ["image", "audio", "video"];
50
+ /** The types the core can confirm by a file's first bytes, with the extensions a stored name may end in (the
51
+ * first is the one it is given). The list only grows. SVG, HTML, XML and script types are never on it. */
52
+ const TYPES = [
53
+ ["image/png", ["png"]],
54
+ ["image/jpeg", ["jpg", "jpeg"]],
55
+ ["image/gif", ["gif"]],
56
+ ["image/webp", ["webp"]],
57
+ ["image/avif", ["avif"]],
58
+ ["application/pdf", ["pdf"]],
59
+ ["text/plain", ["txt"]],
60
+ ["text/csv", ["csv"]],
61
+ ["application/zip", ["zip"]],
62
+ ["application/vnd.openxmlformats-officedocument.wordprocessingml.document", ["docx"]],
63
+ ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ["xlsx"]],
64
+ ["application/vnd.oasis.opendocument.text", ["odt"]],
65
+ ["application/vnd.oasis.opendocument.spreadsheet", ["ods"]],
66
+ ["audio/mpeg", ["mp3"]],
67
+ ["audio/ogg", ["ogg", "oga"]],
68
+ ["audio/wav", ["wav"]],
69
+ ["video/mp4", ["mp4", "m4v"]],
70
+ ["video/webm", ["webm"]],
71
+ ];
72
+ export const UPLOAD_TYPES = Object.freeze(TYPES.map(([type]) => type));
73
+ const EXTENSIONS_OF = new Map(TYPES);
74
+ const TYPE_OF_EXTENSION = new Map(TYPES.flatMap(([type, extensions]) => extensions.map((ext) => [ext, type])));
75
+ /** Labels browsers send for listed types. */
76
+ const ALIASES = new Map([
77
+ ["image/pjpeg", "image/jpeg"],
78
+ ["image/jpg", "image/jpeg"],
79
+ ["audio/x-wav", "audio/wav"],
80
+ ["audio/wave", "audio/wav"],
81
+ ["audio/mp3", "audio/mpeg"],
82
+ ["application/x-zip-compressed", "application/zip"],
83
+ ]);
84
+ /** Labels that say nothing, so the name's extension decides (phones send `application/octet-stream`). */
85
+ export const UPLOAD_GENERIC_LABELS = Object.freeze(["", "application/octet-stream"]);
86
+ /** The longest extension read off a name. */
87
+ const EXTENSION_MAX = 5;
88
+ export const UPLOAD_KEEP_REFUSALS = ["invalid", "ended", "unprotected", "quota", "disk", "type", "folder", "store", "inactive", "readOnly"];
89
+ /** The `code` beside `message` of the core's refusals of a multipart body. */
90
+ export const UPLOAD_READ_CODES = ["upload_too_large", "upload_too_many", "upload_type", "upload_malformed", "upload_busy", "upload_rate", "upload_slow", "multipart_refused"];
91
+ export const MULTIPART_REFUSED_MESSAGE = "This route does not take files";
92
+ /** The body of those refusals. The plugin dispatcher's 400 and 503 answer it beside the plain `{ message }`, so
93
+ * `code` reaches the caller; the route document names it for a route that takes files. */
94
+ export const UploadRefusalSchema = z.object({ message: z.string(), code: z.enum(UPLOAD_READ_CODES) });
95
+ export function uploadExtensionsOf(type) {
96
+ return EXTENSIONS_OF.get(type) ?? null;
97
+ }
98
+ /** The listed type a name's extension names, or null. Reads at most EXTENSION_MAX characters after the last dot. */
99
+ export function uploadTypeOfName(name) {
100
+ const dot = name.lastIndexOf(".");
101
+ if (dot === -1 || name.length - dot - 1 > EXTENSION_MAX)
102
+ return null;
103
+ return TYPE_OF_EXTENSION.get(name.slice(dot + 1).toLowerCase()) ?? null;
104
+ }
105
+ /** A part's label as a listed type: parameters dropped, trimmed, lower case, an alias read; null for any other. */
106
+ export function canonicalUploadType(label) {
107
+ if (label.length > UPLOAD_TYPE_NAME_MAX)
108
+ return null;
109
+ const semi = label.indexOf(";");
110
+ const bare = (semi === -1 ? label : label.slice(0, semi)).trim().toLowerCase();
111
+ const type = ALIASES.get(bare) ?? bare;
112
+ return EXTENSIONS_OF.has(type) ? type : null;
113
+ }
114
+ /** A listed type, or `<family>/*` of UPLOAD_TYPE_FAMILIES. */
115
+ export function isUploadTypeDeclaration(value) {
116
+ if (EXTENSIONS_OF.has(value))
117
+ return true;
118
+ if (value.length > 8 || !value.endsWith("/*"))
119
+ return false;
120
+ return UPLOAD_TYPE_FAMILIES.includes(value.slice(0, -2));
121
+ }
122
+ /** The listed types a declaration admits, in list order, each once. */
123
+ export function expandUploadTypes(declared) {
124
+ const wanted = new Set(declared);
125
+ return UPLOAD_TYPES.filter((type) => wanted.has(type) || wanted.has(`${type.slice(0, type.indexOf("/"))}/*`));
126
+ }
127
+ const KEYS = new Set(["maxFiles", "maxFileBytes", "maxTotalBytes", "types"]);
128
+ const isWhole = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
129
+ const shown = (value) => (typeof value === "string" ? JSON.stringify(value.slice(0, 60)) : typeof value);
130
+ /** Why an `uploads` value cannot stand, or null when it can. */
131
+ export function uploadsDeclarationProblem(uploads) {
132
+ if (uploads === null || typeof uploads !== "object" || Array.isArray(uploads))
133
+ return "uploads is an object { maxFiles, maxFileBytes, types }";
134
+ for (const key of Object.keys(uploads)) {
135
+ if (!KEYS.has(key))
136
+ return `uploads holds maxFiles, maxFileBytes, maxTotalBytes and types only, not "${key.slice(0, 40)}"`;
137
+ }
138
+ const value = uploads;
139
+ if (!isWhole(value.maxFiles, 1, UPLOAD_FILES_MAX))
140
+ return `uploads.maxFiles is a whole number from 1 to ${UPLOAD_FILES_MAX}`;
141
+ if (!isWhole(value.maxFileBytes, 1, UPLOAD_FILE_BYTES_MAX))
142
+ return `uploads.maxFileBytes is a whole number of bytes from 1 to ${UPLOAD_FILE_BYTES_MAX}`;
143
+ if (value.maxTotalBytes !== undefined && !isWhole(value.maxTotalBytes, value.maxFileBytes, UPLOAD_REQUEST_BYTES_MAX)) {
144
+ return `uploads.maxTotalBytes is a whole number of bytes from maxFileBytes to ${UPLOAD_REQUEST_BYTES_MAX}`;
145
+ }
146
+ const types = value.types;
147
+ if (!Array.isArray(types) || types.length < 1 || types.length > UPLOAD_DECLARED_TYPES_MAX)
148
+ return `uploads.types lists 1 to ${UPLOAD_DECLARED_TYPES_MAX} media types`;
149
+ const seen = new Set();
150
+ for (const type of types) {
151
+ if (typeof type !== "string" || type.length > UPLOAD_TYPE_NAME_MAX || !isUploadTypeDeclaration(type)) {
152
+ return `uploads.types holds media types the core can check (UPLOAD_TYPES) or image/*, audio/*, video/*, and ${shown(type)} is not one`;
153
+ }
154
+ if (seen.has(type))
155
+ return `uploads.types names ${type} once`;
156
+ seen.add(type);
157
+ }
158
+ return null;
159
+ }
160
+ const methodsText = (methods) => (methods.length === 1 ? methods[0] : `${methods.slice(0, -1).join(", ")} or ${methods.at(-1)}`);
161
+ /** Why a route's `uploads` cannot stand, or null (absent, or a good declaration on one of `methods` without rawBody).
162
+ * A method outside the route's own method list is that rule's to report, as apiRouteRawBodyProblem does. */
163
+ export function routeUploadsProblem(route, methods, what) {
164
+ if (route.uploads === undefined)
165
+ return null;
166
+ if (typeof route.method === "string" && route.method.length <= 10 && !methods.includes(route.method)) {
167
+ return `uploads is only for a ${methodsText(methods)} ${what}, and this route is ${route.method}`;
168
+ }
169
+ if (route.rawBody === true)
170
+ return "a route takes uploads or rawBody, not both";
171
+ return uploadsDeclarationProblem(route.uploads);
172
+ }
173
+ /** The declaration as the server reads it, frozen, or null for anything the rule refuses. */
174
+ export function readRouteUploads(value) {
175
+ if (value === undefined || uploadsDeclarationProblem(value) !== null)
176
+ return null;
177
+ const declared = value;
178
+ return Object.freeze({
179
+ maxFiles: declared.maxFiles,
180
+ maxFileBytes: declared.maxFileBytes,
181
+ maxTotalBytes: declared.maxTotalBytes ?? Math.min(declared.maxFiles * declared.maxFileBytes, UPLOAD_REQUEST_BYTES_MAX),
182
+ declaredTypes: Object.freeze([...declared.types]),
183
+ types: Object.freeze(expandUploadTypes(declared.types)),
184
+ });
185
+ }