@kardalum/plugin-sdk 0.0.0-stage → 0.15.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 (312) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/LICENSE +202 -0
  3. package/README.md +70 -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 +99 -0
  15. package/dist/capabilities.js +363 -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 +93 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +22 -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 +408 -0
  47. package/dist/manifest-schema.js +774 -0
  48. package/dist/manifest.d.ts +546 -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 +438 -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 +75 -0
  55. package/dist/plugin-context.js +70 -0
  56. package/dist/plugin-screen-context.d.ts +40 -0
  57. package/dist/plugin-screen-context.js +16 -0
  58. package/dist/register-built-ins.d.ts +1 -0
  59. package/dist/register-built-ins.js +41 -0
  60. package/dist/registry.d.ts +4 -0
  61. package/dist/registry.js +17 -0
  62. package/dist/rendition-eligibility.d.ts +24 -0
  63. package/dist/rendition-eligibility.js +40 -0
  64. package/dist/richtext/block-panel.d.ts +27 -0
  65. package/dist/richtext/block-panel.js +232 -0
  66. package/dist/richtext/extensions.d.ts +19 -0
  67. package/dist/richtext/extensions.js +56 -0
  68. package/dist/richtext/insert-menu.d.ts +24 -0
  69. package/dist/richtext/insert-menu.js +142 -0
  70. package/dist/richtext/kardalum-block.d.ts +33 -0
  71. package/dist/richtext/kardalum-block.js +282 -0
  72. package/dist/richtext/style-listbox.d.ts +10 -0
  73. package/dist/richtext/style-listbox.js +69 -0
  74. package/dist/richtext/text-style-class.d.ts +18 -0
  75. package/dist/richtext/text-style-class.js +36 -0
  76. package/dist/simple-storage-value-provider.d.ts +9 -0
  77. package/dist/simple-storage-value-provider.js +96 -0
  78. package/dist/structured-storage-types.d.ts +61 -0
  79. package/dist/structured-storage-types.js +11 -0
  80. package/dist/tailwind.d.ts +1 -0
  81. package/dist/tailwind.js +5 -0
  82. package/dist/tokens/system-dark.css +75 -0
  83. package/dist/tokens/tokens.css +239 -0
  84. package/dist/tokens/tokens.json +212 -0
  85. package/dist/tokens.d.ts +1 -0
  86. package/dist/tokens.js +11 -0
  87. package/dist/ui-entry.d.ts +5 -0
  88. package/dist/ui-entry.js +42 -0
  89. package/dist/views/content-list-preview.d.ts +1 -0
  90. package/dist/views/content-list-preview.js +14 -0
  91. package/dist/views/content-list-settings-view.d.ts +1 -0
  92. package/dist/views/content-list-settings-view.js +97 -0
  93. package/dist/views/content-list-view.d.ts +19 -0
  94. package/dist/views/content-list-view.js +248 -0
  95. package/dist/views/crop-view.d.ts +55 -0
  96. package/dist/views/crop-view.js +161 -0
  97. package/dist/views/date-range-view.d.ts +6 -0
  98. package/dist/views/date-range-view.js +55 -0
  99. package/dist/views/file-upload-view.d.ts +43 -0
  100. package/dist/views/file-upload-view.js +104 -0
  101. package/dist/views/html-code-editor.d.ts +10 -0
  102. package/dist/views/html-code-editor.js +101 -0
  103. package/dist/views/html-view.d.ts +3 -0
  104. package/dist/views/html-view.js +53 -0
  105. package/dist/views/image-view.d.ts +3 -0
  106. package/dist/views/image-view.js +387 -0
  107. package/dist/views/rich-text-view.d.ts +2 -0
  108. package/dist/views/rich-text-view.js +429 -0
  109. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  110. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  111. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  112. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  113. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +5 -0
  114. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -0
  117. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  118. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  121. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  122. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +537 -0
  124. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-path.js +256 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +151 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  137. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +302 -0
  138. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -0
  139. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  140. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  141. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +36 -0
  142. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +296 -0
  146. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  149. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  150. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  151. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  153. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +102 -0
  154. package/node_modules/@kardalum/api-schemas/dist/index.js +58 -0
  155. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  157. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +381 -0
  158. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
  159. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
  160. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -0
  161. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  162. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  171. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  172. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  173. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  174. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +169 -0
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +89 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +369 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  193. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +306 -0
  194. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -0
  195. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  196. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  197. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  198. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  199. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  200. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  201. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +90 -0
  202. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -0
  203. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  204. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  205. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +108 -0
  206. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -0
  207. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  208. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  209. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +43 -0
  210. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -0
  211. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  212. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  213. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  214. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  215. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  216. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  217. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  218. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  219. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +89 -0
  220. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -0
  221. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  222. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  223. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  224. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  225. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  226. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  227. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  228. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  229. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  230. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  231. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  232. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  233. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  234. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  235. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  236. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  237. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  238. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  239. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  240. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  241. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  242. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  243. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  244. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  247. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  248. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  249. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  250. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  251. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  252. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  253. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  254. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  255. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  256. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  257. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  258. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  259. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  260. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -0
  261. package/node_modules/@kardalum/plugin-package/dist/index.js +7 -0
  262. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  263. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  264. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  265. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  266. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +1 -0
  267. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
  268. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
  269. package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
  270. package/node_modules/@kardalum/plugin-package/package.json +49 -0
  271. package/node_modules/@kardalum/ui/LICENSE +202 -0
  272. package/node_modules/@kardalum/ui/README.md +35 -0
  273. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  274. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  275. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  276. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  277. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  278. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  279. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  280. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  281. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  282. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  283. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  284. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  285. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  286. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  287. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  288. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  289. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  290. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  291. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  292. package/node_modules/@kardalum/ui/dist/components/property-field.js +86 -0
  293. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  294. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  295. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  296. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  297. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  298. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  299. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  300. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  301. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  302. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  303. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  304. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  305. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  306. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  307. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  308. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  309. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  310. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  311. package/node_modules/@kardalum/ui/package.json +63 -0
  312. package/package.json +146 -4
@@ -0,0 +1,243 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Lower-cases, trims, drops one trailing dot. Returns null when the result
4
+ * is not a plain hostname (spec D3): one or more labels of a-z, 0-9 and
5
+ * "-" joined by dots, no label empty, longer than 63, or starting or
6
+ * ending with a dash, the whole name no longer than 253.
7
+ *
8
+ * So no scheme, port, path, wildcard, user or space gets through: each of
9
+ * them needs a character a label cannot hold.
10
+ *
11
+ * An internationalised domain is entered in its ASCII form
12
+ * ("xn--bcher-kva.example"); a name with a non-ASCII character is refused.
13
+ * The characters are tested BEFORE lower-casing, because lower-casing can
14
+ * turn a character that is not a letter of a hostname into one (U+212A,
15
+ * the Kelvin sign, becomes "k"), and two entries would then mean one host.
16
+ *
17
+ * A single label such as "localhost" is accepted: a local setup needs it.
18
+ * An IP address is refused: a site's domain is a name, and the server's IP
19
+ * is an unclaimed address, which shows the default site. A name whose last
20
+ * label is a number is how an IPv4 address reads to a browser and to some
21
+ * resolvers (the WHATWG URL rule), and a number there is all digits or
22
+ * begins with "0x". So a name is refused when its last label is all digits
23
+ * or begins with "0x" or "0X", whatever follows: "0x7f000001" is
24
+ * 127.0.0.1 to a browser. No registered top-level domain begins that way.
25
+ *
26
+ * Written with string functions only, behind a length cap, because the
27
+ * input is whatever somebody typed or sent: no pattern is ever run over it.
28
+ */
29
+ export declare function normalizeHostname(input: string): string | null;
30
+ /**
31
+ * One domain of a site. Parses through `normalizeHostname`, so the output
32
+ * is the stored form: lower-case, no trailing dot.
33
+ */
34
+ export declare const HostnameSchema: z.ZodType<string, string>;
35
+ export declare const MAX_HOSTNAMES_PER_SITE = 20;
36
+ /**
37
+ * The domains of one site, in order: the first is the site's address, and
38
+ * every other one redirects to it.
39
+ */
40
+ export declare const SiteHostnamesSchema: z.ZodObject<{
41
+ siteId: z.ZodString;
42
+ hostnames: z.ZodArray<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
43
+ }, z.core.$strip>;
44
+ export type SiteHostnames = z.infer<typeof SiteHostnamesSchema>;
45
+ /**
46
+ * The install's sites setting (the `sites` settings row): which top-level
47
+ * node is the default site, and the domains of each site that has any.
48
+ *
49
+ * A row written before sites had domains (`{ defaultSiteId }`) reads with
50
+ * `sites: []`.
51
+ *
52
+ * That a domain belongs to one site, and is listed once, is NOT checked
53
+ * here. The route that writes the record checks it, because the refusal
54
+ * has to name the site that holds the domain.
55
+ */
56
+ export declare const SitesSettingsSchema: z.ZodObject<{
57
+ defaultSiteId: z.ZodNullable<z.ZodString>;
58
+ sites: z.ZodDefault<z.ZodArray<z.ZodObject<{
59
+ siteId: z.ZodString;
60
+ hostnames: z.ZodArray<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
61
+ }, z.core.$strip>>>;
62
+ }, z.core.$strip>;
63
+ export type SitesSettings = z.infer<typeof SitesSettingsSchema>;
64
+ /** The body of PUT /api/settings/sites/default. Null clears the pin. */
65
+ export declare const SetDefaultSiteRequestSchema: z.ZodObject<{
66
+ defaultSiteId: z.ZodNullable<z.ZodString>;
67
+ }, z.core.$strip>;
68
+ export type SetDefaultSiteRequest = z.infer<typeof SetDefaultSiteRequestSchema>;
69
+ /**
70
+ * The body of PUT /api/settings/sites/:siteId/hostnames: the site's whole
71
+ * list, in order. An empty list takes every domain off the site.
72
+ */
73
+ export declare const SetSiteHostnamesRequestSchema: z.ZodObject<{
74
+ hostnames: z.ZodArray<z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
75
+ }, z.core.$strip>;
76
+ export type SetSiteHostnamesRequest = z.infer<typeof SetSiteHostnamesRequestSchema>;
77
+ /**
78
+ * The default site as a visitor meets it: the top-level node whose own
79
+ * first path segment is hidden from every address. `path` is its stored
80
+ * path, which is what `publicPath` takes to make an address.
81
+ */
82
+ export declare const DefaultSiteSchema: z.ZodObject<{
83
+ id: z.ZodString;
84
+ path: z.ZodString;
85
+ }, z.core.$strip>;
86
+ export type DefaultSite = z.infer<typeof DefaultSiteSchema>;
87
+ /** One site as the admin lists it: its node, its name and its domains. */
88
+ export declare const SiteSummarySchema: z.ZodObject<{
89
+ siteId: z.ZodString;
90
+ path: z.ZodString;
91
+ name: z.ZodString;
92
+ hostnames: z.ZodArray<z.ZodString>;
93
+ isDefault: z.ZodBoolean;
94
+ }, z.core.$strip>;
95
+ export type SiteSummary = z.infer<typeof SiteSummarySchema>;
96
+ /**
97
+ * What GET /api/settings/sites and the two writes answer: the stored pin,
98
+ * and beside it the default site that pin (or, with nothing pinned, tree
99
+ * order) gives a visitor right now. Null when there is none: a pin whose
100
+ * node is in the trash or not published, or a tree with nothing published.
101
+ * The admin reads `defaultSite` to print the address a page will have; it
102
+ * never works the rule out for itself.
103
+ *
104
+ * `sites` is every site that has at least one domain, plus the default
105
+ * site even when it has none: the stored record, which is what an address
106
+ * is worked out from. It is bounded by that record and is not a list of
107
+ * every top-level page; GET /api/sites is that list. `requestHost` is the
108
+ * host the server sees for this very request (spec D10): behind a proxy
109
+ * that does not pass the domain on it differs from the browser's, and
110
+ * that is the one place it shows.
111
+ *
112
+ * `defaultAddressHost` is the name of the default address, where the
113
+ * default site and every site with no domain live: the default site's
114
+ * first domain; while it has none, the host of KARDALUM_PUBLIC_URL (port
115
+ * included) unless a site holds that host as a domain; null when there is
116
+ * neither. It comes from what is stored and configured, never from a
117
+ * request header. While it is null and some site has a domain, a link from
118
+ * that site's domain to a page of the default address cannot be made.
119
+ */
120
+ export declare const SitesSettingsResponseSchema: z.ZodObject<{
121
+ defaultSiteId: z.ZodNullable<z.ZodString>;
122
+ defaultSite: z.ZodNullable<z.ZodObject<{
123
+ id: z.ZodString;
124
+ path: z.ZodString;
125
+ }, z.core.$strip>>;
126
+ sites: z.ZodArray<z.ZodObject<{
127
+ siteId: z.ZodString;
128
+ path: z.ZodString;
129
+ name: z.ZodString;
130
+ hostnames: z.ZodArray<z.ZodString>;
131
+ isDefault: z.ZodBoolean;
132
+ }, z.core.$strip>>;
133
+ requestHost: z.ZodString;
134
+ defaultAddressHost: z.ZodNullable<z.ZodString>;
135
+ }, z.core.$strip>;
136
+ export type SitesSettingsResponse = z.infer<typeof SitesSettingsResponseSchema>;
137
+ /**
138
+ * The query of GET /api/sites. The cursor is the id of the previous page's
139
+ * last row, the convention of the content tree's own lists
140
+ * (GET /api/content/roots).
141
+ */
142
+ export declare const SiteListQuerySchema: z.ZodObject<{
143
+ cursor: z.ZodOptional<z.ZodString>;
144
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
145
+ }, z.core.$strip>;
146
+ export type SiteListQuery = z.infer<typeof SiteListQuerySchema>;
147
+ /**
148
+ * One top-level page as the Sites overview lists it. Every top-level page
149
+ * is a site, so this is every one of them, with or without a domain.
150
+ * `isDefault` is the default site a visitor gets right now; `published`
151
+ * says whether the page itself is published (a site that is not answers
152
+ * nothing on its domain).
153
+ */
154
+ export declare const SiteListRowSchema: z.ZodObject<{
155
+ siteId: z.ZodString;
156
+ path: z.ZodString;
157
+ name: z.ZodString;
158
+ hostnames: z.ZodArray<z.ZodString>;
159
+ isDefault: z.ZodBoolean;
160
+ published: z.ZodBoolean;
161
+ }, z.core.$strip>;
162
+ export type SiteListRow = z.infer<typeof SiteListRowSchema>;
163
+ /** What GET /api/sites answers: one page of top-level pages in tree order. */
164
+ export declare const SiteListResponseSchema: z.ZodObject<{
165
+ items: z.ZodArray<z.ZodObject<{
166
+ siteId: z.ZodString;
167
+ path: z.ZodString;
168
+ name: z.ZodString;
169
+ hostnames: z.ZodArray<z.ZodString>;
170
+ isDefault: z.ZodBoolean;
171
+ published: z.ZodBoolean;
172
+ }, z.core.$strip>>;
173
+ nextCursor: z.ZodNullable<z.ZodString>;
174
+ }, z.core.$strip>;
175
+ export type SiteListResponse = z.infer<typeof SiteListResponseSchema>;
176
+ /** A node's one address: the domain it lives on, or null, and its path there. */
177
+ export interface SiteAddress {
178
+ host: string | null;
179
+ path: string;
180
+ }
181
+ /** The two things about an address that the site's own facts do not say. */
182
+ export interface SiteAddressOptions {
183
+ /**
184
+ * The page's short path is itself the stored path of another live node,
185
+ * so the short path answers that node and not this page (S277e, D3). The
186
+ * caller finds this out; the rule only says what follows from it. Absent
187
+ * means false.
188
+ */
189
+ shortPathTaken?: boolean;
190
+ /**
191
+ * The domain the address is asked from, when that is a domain of a site:
192
+ * the host of the page a link is printed on, or of the request an answer
193
+ * is for. Null or absent when the asker is on no site's domain, or is
194
+ * nobody in particular (S277e, A4).
195
+ */
196
+ fromSiteHost?: string | null;
197
+ }
198
+ /**
199
+ * The one rule for a page's address (spec section 2), from facts already in
200
+ * hand. `site` is the page's top-level ancestor: its stored path, its first
201
+ * domain or null, and whether it is the default site. `defaultHost` is the
202
+ * name of the default address or null.
203
+ *
204
+ * host: the site's first domain; for a site with none, the default
205
+ * address. path: the stored path without the site's own first segment when
206
+ * the site has a domain or is the default site; the stored path otherwise.
207
+ *
208
+ * Two answers more (S277e):
209
+ *
210
+ * - With `shortPathTaken`, a page below the root of such a site keeps its
211
+ * stored path: the short one would open another page.
212
+ * - Null, "this link cannot be made", when the address is asked from a
213
+ * site's domain (`fromSiteHost`), the page lives on the default address,
214
+ * and the default address has no name. A path alone would be read on the
215
+ * asker's domain and open another page there, or none.
216
+ *
217
+ * The server's `addressOf` and the admin's preview of an address that is
218
+ * not stored yet both end here, so the two cannot come to differ.
219
+ */
220
+ export declare function siteAddress(site: {
221
+ path: string;
222
+ ownHost: string | null;
223
+ isDefault: boolean;
224
+ }, defaultHost: string | null, storedPath: string, options?: SiteAddressOptions): SiteAddress | null;
225
+ /**
226
+ * The address of a stored path, worked out from what GET /api/settings/sites
227
+ * answers, for a page the server cannot be asked about because nothing is
228
+ * stored at it yet (a page being created, a name being typed).
229
+ *
230
+ * The site of a path is the listed site stored at its first segment. A
231
+ * site that is not listed has no domain and is not the default site.
232
+ *
233
+ * As the admin's `url` fields do, this names a domain only while some site
234
+ * has one: with none there is one address, and a path says all of it.
235
+ *
236
+ * Two things the server's answer for a stored page knows and this cannot
237
+ * (S277e). Whether the short path is taken by another node: nothing here
238
+ * reads the tree, so a page that would be shadowed is previewed at its
239
+ * short form, and the `url` the server gives once it is stored is the one
240
+ * to trust. And who is asking: this says where the page lives, never "no
241
+ * link can be made from here", so it always has an answer.
242
+ */
243
+ export declare function addressFromSitesRecord(record: Pick<SitesSettingsResponse, "defaultSite" | "sites" | "defaultAddressHost">, storedPath: string): SiteAddress;
@@ -0,0 +1,296 @@
1
+ import { z } from "zod";
2
+ import { firstSegment, publicPath } from "./content-path.js";
3
+ // S277d: a site (a top-level node) can have its own domains. Everything
4
+ // here is the shape of that record and the rule for one hostname.
5
+ /** The longest a hostname may be (RFC 1035), without a trailing dot. */
6
+ const MAX_HOSTNAME_LENGTH = 253;
7
+ /** The longest one label of a hostname may be. */
8
+ const MAX_LABEL_LENGTH = 63;
9
+ /**
10
+ * The longest input that is looked at at all. Twice the longest hostname
11
+ * leaves room for surrounding whitespace and the trailing dot; anything
12
+ * longer is refused before a single character is read, so a hostile input
13
+ * costs the same whatever its length.
14
+ */
15
+ const MAX_HOSTNAME_INPUT_LENGTH = MAX_HOSTNAME_LENGTH * 2;
16
+ const CODE_0 = 48;
17
+ const CODE_9 = 57;
18
+ const CODE_UPPER_A = 65;
19
+ const CODE_UPPER_Z = 90;
20
+ const CODE_LOWER_A = 97;
21
+ const CODE_LOWER_Z = 122;
22
+ const CODE_DASH = 45;
23
+ const CODE_UPPER_X = 88;
24
+ const CODE_LOWER_X = 120;
25
+ function isDigit(code) {
26
+ return code >= CODE_0 && code <= CODE_9;
27
+ }
28
+ function isLabelCharacter(code) {
29
+ return ((code >= CODE_LOWER_A && code <= CODE_LOWER_Z) ||
30
+ (code >= CODE_UPPER_A && code <= CODE_UPPER_Z) ||
31
+ isDigit(code) ||
32
+ code === CODE_DASH);
33
+ }
34
+ /**
35
+ * Lower-cases, trims, drops one trailing dot. Returns null when the result
36
+ * is not a plain hostname (spec D3): one or more labels of a-z, 0-9 and
37
+ * "-" joined by dots, no label empty, longer than 63, or starting or
38
+ * ending with a dash, the whole name no longer than 253.
39
+ *
40
+ * So no scheme, port, path, wildcard, user or space gets through: each of
41
+ * them needs a character a label cannot hold.
42
+ *
43
+ * An internationalised domain is entered in its ASCII form
44
+ * ("xn--bcher-kva.example"); a name with a non-ASCII character is refused.
45
+ * The characters are tested BEFORE lower-casing, because lower-casing can
46
+ * turn a character that is not a letter of a hostname into one (U+212A,
47
+ * the Kelvin sign, becomes "k"), and two entries would then mean one host.
48
+ *
49
+ * A single label such as "localhost" is accepted: a local setup needs it.
50
+ * An IP address is refused: a site's domain is a name, and the server's IP
51
+ * is an unclaimed address, which shows the default site. A name whose last
52
+ * label is a number is how an IPv4 address reads to a browser and to some
53
+ * resolvers (the WHATWG URL rule), and a number there is all digits or
54
+ * begins with "0x". So a name is refused when its last label is all digits
55
+ * or begins with "0x" or "0X", whatever follows: "0x7f000001" is
56
+ * 127.0.0.1 to a browser. No registered top-level domain begins that way.
57
+ *
58
+ * Written with string functions only, behind a length cap, because the
59
+ * input is whatever somebody typed or sent: no pattern is ever run over it.
60
+ */
61
+ export function normalizeHostname(input) {
62
+ if (typeof input !== "string")
63
+ return null;
64
+ if (input.length > MAX_HOSTNAME_INPUT_LENGTH)
65
+ return null;
66
+ let name = input.trim();
67
+ if (name.endsWith("."))
68
+ name = name.slice(0, -1);
69
+ if (name.length === 0 || name.length > MAX_HOSTNAME_LENGTH)
70
+ return null;
71
+ const labels = name.split(".");
72
+ for (const label of labels) {
73
+ if (label.length === 0 || label.length > MAX_LABEL_LENGTH)
74
+ return null;
75
+ if (label.charCodeAt(0) === CODE_DASH || label.charCodeAt(label.length - 1) === CODE_DASH)
76
+ return null;
77
+ for (let i = 0; i < label.length; i += 1) {
78
+ if (!isLabelCharacter(label.charCodeAt(i)))
79
+ return null;
80
+ }
81
+ }
82
+ const last = labels[labels.length - 1];
83
+ let allDigits = true;
84
+ for (let i = 0; i < last.length; i += 1) {
85
+ if (!isDigit(last.charCodeAt(i))) {
86
+ allDigits = false;
87
+ break;
88
+ }
89
+ }
90
+ if (allDigits)
91
+ return null;
92
+ // "0x" or "0X" first: a hexadecimal number to the same readers.
93
+ if (last.charCodeAt(0) === CODE_0 && (last.charCodeAt(1) === CODE_LOWER_X || last.charCodeAt(1) === CODE_UPPER_X)) {
94
+ return null;
95
+ }
96
+ // Every character is ASCII by now, so this changes A-Z and nothing else.
97
+ return name.toLowerCase();
98
+ }
99
+ /**
100
+ * One domain of a site. Parses through `normalizeHostname`, so the output
101
+ * is the stored form: lower-case, no trailing dot.
102
+ */
103
+ export const HostnameSchema = z.string().transform((value, ctx) => {
104
+ const hostname = normalizeHostname(value);
105
+ if (hostname === null) {
106
+ ctx.addIssue({
107
+ code: "custom",
108
+ message: 'A domain is a plain host name such as "example.com": no scheme, port, path or wildcard.',
109
+ });
110
+ return z.NEVER;
111
+ }
112
+ return hostname;
113
+ });
114
+ export const MAX_HOSTNAMES_PER_SITE = 20;
115
+ /**
116
+ * The domains of one site, in order: the first is the site's address, and
117
+ * every other one redirects to it.
118
+ */
119
+ export const SiteHostnamesSchema = z.object({
120
+ siteId: z.string().min(1),
121
+ hostnames: z.array(HostnameSchema).max(MAX_HOSTNAMES_PER_SITE),
122
+ });
123
+ /**
124
+ * The install's sites setting (the `sites` settings row): which top-level
125
+ * node is the default site, and the domains of each site that has any.
126
+ *
127
+ * A row written before sites had domains (`{ defaultSiteId }`) reads with
128
+ * `sites: []`.
129
+ *
130
+ * That a domain belongs to one site, and is listed once, is NOT checked
131
+ * here. The route that writes the record checks it, because the refusal
132
+ * has to name the site that holds the domain.
133
+ */
134
+ export const SitesSettingsSchema = z.object({
135
+ defaultSiteId: z.string().min(1).nullable(),
136
+ sites: z.array(SiteHostnamesSchema).default([]),
137
+ });
138
+ /** The body of PUT /api/settings/sites/default. Null clears the pin. */
139
+ export const SetDefaultSiteRequestSchema = z.object({ defaultSiteId: z.string().min(1).nullable() });
140
+ /**
141
+ * The body of PUT /api/settings/sites/:siteId/hostnames: the site's whole
142
+ * list, in order. An empty list takes every domain off the site.
143
+ */
144
+ export const SetSiteHostnamesRequestSchema = z.object({
145
+ hostnames: z.array(HostnameSchema).max(MAX_HOSTNAMES_PER_SITE),
146
+ });
147
+ /**
148
+ * The default site as a visitor meets it: the top-level node whose own
149
+ * first path segment is hidden from every address. `path` is its stored
150
+ * path, which is what `publicPath` takes to make an address.
151
+ */
152
+ export const DefaultSiteSchema = z.object({ id: z.string().min(1), path: z.string().min(1) });
153
+ /** One site as the admin lists it: its node, its name and its domains. */
154
+ export const SiteSummarySchema = z.object({
155
+ siteId: z.string(),
156
+ path: z.string(),
157
+ name: z.string(),
158
+ hostnames: z.array(z.string()),
159
+ isDefault: z.boolean(),
160
+ });
161
+ /**
162
+ * What GET /api/settings/sites and the two writes answer: the stored pin,
163
+ * and beside it the default site that pin (or, with nothing pinned, tree
164
+ * order) gives a visitor right now. Null when there is none: a pin whose
165
+ * node is in the trash or not published, or a tree with nothing published.
166
+ * The admin reads `defaultSite` to print the address a page will have; it
167
+ * never works the rule out for itself.
168
+ *
169
+ * `sites` is every site that has at least one domain, plus the default
170
+ * site even when it has none: the stored record, which is what an address
171
+ * is worked out from. It is bounded by that record and is not a list of
172
+ * every top-level page; GET /api/sites is that list. `requestHost` is the
173
+ * host the server sees for this very request (spec D10): behind a proxy
174
+ * that does not pass the domain on it differs from the browser's, and
175
+ * that is the one place it shows.
176
+ *
177
+ * `defaultAddressHost` is the name of the default address, where the
178
+ * default site and every site with no domain live: the default site's
179
+ * first domain; while it has none, the host of KARDALUM_PUBLIC_URL (port
180
+ * included) unless a site holds that host as a domain; null when there is
181
+ * neither. It comes from what is stored and configured, never from a
182
+ * request header. While it is null and some site has a domain, a link from
183
+ * that site's domain to a page of the default address cannot be made.
184
+ */
185
+ export const SitesSettingsResponseSchema = z.object({
186
+ defaultSiteId: z.string().nullable(),
187
+ defaultSite: DefaultSiteSchema.nullable(),
188
+ sites: z.array(SiteSummarySchema),
189
+ requestHost: z.string(),
190
+ defaultAddressHost: z.string().nullable(),
191
+ });
192
+ /**
193
+ * The query of GET /api/sites. The cursor is the id of the previous page's
194
+ * last row, the convention of the content tree's own lists
195
+ * (GET /api/content/roots).
196
+ */
197
+ export const SiteListQuerySchema = z.object({
198
+ cursor: z.string().uuid().optional(),
199
+ limit: z.coerce.number().int().min(1).max(100).default(50),
200
+ });
201
+ /**
202
+ * One top-level page as the Sites overview lists it. Every top-level page
203
+ * is a site, so this is every one of them, with or without a domain.
204
+ * `isDefault` is the default site a visitor gets right now; `published`
205
+ * says whether the page itself is published (a site that is not answers
206
+ * nothing on its domain).
207
+ */
208
+ export const SiteListRowSchema = z.object({
209
+ siteId: z.string(),
210
+ path: z.string(),
211
+ name: z.string(),
212
+ hostnames: z.array(z.string()),
213
+ isDefault: z.boolean(),
214
+ published: z.boolean(),
215
+ });
216
+ /** What GET /api/sites answers: one page of top-level pages in tree order. */
217
+ export const SiteListResponseSchema = z.object({
218
+ items: z.array(SiteListRowSchema),
219
+ // null = no more pages.
220
+ nextCursor: z.string().uuid().nullable(),
221
+ });
222
+ /** Where a page lives, with nothing said about who is asking. */
223
+ function placeOnSite(site, defaultHost, storedPath, shortPathTaken) {
224
+ const host = site.ownHost ?? defaultHost;
225
+ // The site's own segment is hidden when the site has a domain or is the
226
+ // default site.
227
+ if (site.ownHost === null && !site.isDefault)
228
+ return { host, path: storedPath };
229
+ // A page below the site's root whose short path belongs to another node
230
+ // keeps its long form: that is the address that answers it.
231
+ if (shortPathTaken && storedPath !== site.path)
232
+ return { host, path: storedPath };
233
+ return { host, path: publicPath(storedPath, site.path) };
234
+ }
235
+ /**
236
+ * The one rule for a page's address (spec section 2), from facts already in
237
+ * hand. `site` is the page's top-level ancestor: its stored path, its first
238
+ * domain or null, and whether it is the default site. `defaultHost` is the
239
+ * name of the default address or null.
240
+ *
241
+ * host: the site's first domain; for a site with none, the default
242
+ * address. path: the stored path without the site's own first segment when
243
+ * the site has a domain or is the default site; the stored path otherwise.
244
+ *
245
+ * Two answers more (S277e):
246
+ *
247
+ * - With `shortPathTaken`, a page below the root of such a site keeps its
248
+ * stored path: the short one would open another page.
249
+ * - Null, "this link cannot be made", when the address is asked from a
250
+ * site's domain (`fromSiteHost`), the page lives on the default address,
251
+ * and the default address has no name. A path alone would be read on the
252
+ * asker's domain and open another page there, or none.
253
+ *
254
+ * The server's `addressOf` and the admin's preview of an address that is
255
+ * not stored yet both end here, so the two cannot come to differ.
256
+ */
257
+ export function siteAddress(site, defaultHost, storedPath, options = {}) {
258
+ const askedFromASite = options.fromSiteHost !== undefined && options.fromSiteHost !== null;
259
+ if (askedFromASite && site.ownHost === null && defaultHost === null)
260
+ return null;
261
+ return placeOnSite(site, defaultHost, storedPath, options.shortPathTaken === true);
262
+ }
263
+ /**
264
+ * The address of a stored path, worked out from what GET /api/settings/sites
265
+ * answers, for a page the server cannot be asked about because nothing is
266
+ * stored at it yet (a page being created, a name being typed).
267
+ *
268
+ * The site of a path is the listed site stored at its first segment. A
269
+ * site that is not listed has no domain and is not the default site.
270
+ *
271
+ * As the admin's `url` fields do, this names a domain only while some site
272
+ * has one: with none there is one address, and a path says all of it.
273
+ *
274
+ * Two things the server's answer for a stored page knows and this cannot
275
+ * (S277e). Whether the short path is taken by another node: nothing here
276
+ * reads the tree, so a page that would be shadowed is previewed at its
277
+ * short form, and the `url` the server gives once it is stored is the one
278
+ * to trust. And who is asking: this says where the page lives, never "no
279
+ * link can be made from here", so it always has an answer.
280
+ */
281
+ export function addressFromSitesRecord(record, storedPath) {
282
+ const sitePath = `/${firstSegment(storedPath)}`;
283
+ let ownHost = null;
284
+ let hasDomains = false;
285
+ for (const site of record.sites) {
286
+ const first = site.hostnames[0];
287
+ if (first === undefined)
288
+ continue;
289
+ hasDomains = true;
290
+ if (ownHost === null && site.path === sitePath)
291
+ ownHost = first;
292
+ }
293
+ const isDefault = record.defaultSite !== null && record.defaultSite.path === sitePath;
294
+ const address = placeOnSite({ path: sitePath, ownHost, isDefault }, record.defaultAddressHost, storedPath, false);
295
+ return hasDomains ? address : { host: null, path: address.path };
296
+ }
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ export declare const CreateSnapshotRequestSchema: z.ZodObject<{
3
+ label: z.ZodString;
4
+ description: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export type CreateSnapshotRequest = z.infer<typeof CreateSnapshotRequestSchema>;
7
+ export declare const SnapshotResponseSchema: z.ZodObject<{
8
+ snapshot: z.ZodObject<{
9
+ id: z.ZodString;
10
+ createdAt: z.ZodString;
11
+ label: z.ZodString;
12
+ createdBy: z.ZodString;
13
+ description: z.ZodNullable<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ }, z.core.$strip>;
16
+ export type SnapshotResponse = z.infer<typeof SnapshotResponseSchema>;
17
+ export declare const SnapshotListQuerySchema: z.ZodObject<{
18
+ cursor: z.ZodOptional<z.ZodString>;
19
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
20
+ }, z.core.$strip>;
21
+ export type SnapshotListQuery = z.infer<typeof SnapshotListQuerySchema>;
22
+ export declare const SnapshotListResponseSchema: z.ZodObject<{
23
+ items: z.ZodArray<z.ZodObject<{
24
+ id: z.ZodString;
25
+ createdAt: z.ZodString;
26
+ label: z.ZodString;
27
+ createdBy: z.ZodString;
28
+ description: z.ZodNullable<z.ZodString>;
29
+ }, z.core.$strip>>;
30
+ nextCursor: z.ZodNullable<z.ZodString>;
31
+ }, z.core.$strip>;
32
+ export type SnapshotListResponse = z.infer<typeof SnapshotListResponseSchema>;
33
+ export declare const RestoreSnapshotResponseSchema: z.ZodObject<{
34
+ snapshot: z.ZodObject<{
35
+ id: z.ZodString;
36
+ createdAt: z.ZodString;
37
+ label: z.ZodString;
38
+ createdBy: z.ZodString;
39
+ description: z.ZodNullable<z.ZodString>;
40
+ }, z.core.$strip>;
41
+ restoredItems: z.ZodNumber;
42
+ }, z.core.$strip>;
43
+ export type RestoreSnapshotResponse = z.infer<typeof RestoreSnapshotResponseSchema>;
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ import { SnapshotMetaSchema } from "./snapshot.schema.js";
3
+ // createdBy comes from the JWT, never the body (same rule as content).
4
+ export const CreateSnapshotRequestSchema = z.object({
5
+ label: z.string().min(1),
6
+ description: z.string().min(1).optional(),
7
+ });
8
+ export const SnapshotResponseSchema = z.object({
9
+ snapshot: SnapshotMetaSchema,
10
+ });
11
+ // Newest-first; cursor = id of the previous page's last snapshot.
12
+ export const SnapshotListQuerySchema = z.object({
13
+ cursor: z.string().uuid().optional(),
14
+ limit: z.coerce.number().int().min(1).max(100).default(20),
15
+ });
16
+ export const SnapshotListResponseSchema = z.object({
17
+ items: z.array(SnapshotMetaSchema),
18
+ // null = no more pages.
19
+ nextCursor: z.string().uuid().nullable(),
20
+ });
21
+ export const RestoreSnapshotResponseSchema = z.object({
22
+ snapshot: SnapshotMetaSchema,
23
+ // How many content nodes had their pointers repointed.
24
+ restoredItems: z.number().int().nonnegative(),
25
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ export declare const SnapshotItemSchema: z.ZodObject<{
3
+ contentId: z.ZodString;
4
+ culture: z.ZodString;
5
+ version: z.ZodNumber;
6
+ publishedAt: z.ZodNullable<z.ZodString>;
7
+ }, z.core.$strip>;
8
+ export declare const SnapshotSchema: z.ZodObject<{
9
+ id: z.ZodString;
10
+ label: z.ZodString;
11
+ description: z.ZodNullable<z.ZodString>;
12
+ createdAt: z.ZodString;
13
+ createdBy: z.ZodString;
14
+ items: z.ZodArray<z.ZodObject<{
15
+ contentId: z.ZodString;
16
+ culture: z.ZodString;
17
+ version: z.ZodNumber;
18
+ publishedAt: z.ZodNullable<z.ZodString>;
19
+ }, z.core.$strip>>;
20
+ }, z.core.$strip>;
21
+ export type SnapshotItem = z.infer<typeof SnapshotItemSchema>;
22
+ export type Snapshot = z.infer<typeof SnapshotSchema>;
23
+ export declare const SnapshotMetaSchema: z.ZodObject<{
24
+ id: z.ZodString;
25
+ createdAt: z.ZodString;
26
+ label: z.ZodString;
27
+ createdBy: z.ZodString;
28
+ description: z.ZodNullable<z.ZodString>;
29
+ }, z.core.$strip>;
30
+ export type SnapshotMeta = z.infer<typeof SnapshotMetaSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ export const SnapshotItemSchema = z.object({
3
+ contentId: z.string().uuid(),
4
+ // Which culture this pointer belongs to (content_node_cultures).
5
+ culture: z.string().min(2),
6
+ version: z.number().int().positive(),
7
+ publishedAt: z.string().datetime().nullable(),
8
+ });
9
+ export const SnapshotSchema = z.object({
10
+ id: z.string().uuid(),
11
+ label: z.string().min(1),
12
+ description: z.string().nullable(),
13
+ createdAt: z.string().datetime(),
14
+ createdBy: z.string().uuid(),
15
+ items: z.array(SnapshotItemSchema),
16
+ });
17
+ // Timeline listings — items excluded on purpose: a snapshot's items array
18
+ // scales with tree size and the timeline only needs the row facts.
19
+ export const SnapshotMetaSchema = SnapshotSchema.omit({ items: true });