@antelopejs/dms 0.25.8 → 0.25.9-next.1183.ga9db169

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 (477) hide show
  1. package/CHANGELOG.md +0 -48
  2. package/E2E.md +138 -0
  3. package/README.md +2 -2
  4. package/data/mockup-example/spec.json +13 -0
  5. package/data/mockup-spec.schema.json +399 -16
  6. package/dist/e2e/index.d.mts +2 -1
  7. package/dist/implementations/dms/live-pages.d.ts +6 -0
  8. package/dist/implementations/dms/live-pages.js +139 -0
  9. package/dist/implementations/dms/live-pages.js.map +1 -0
  10. package/dist/implementations/dms/page/notifications.js +2 -0
  11. package/dist/implementations/dms/page/notifications.js.map +1 -1
  12. package/dist/implementations/dms/page/registry.js +19 -4
  13. package/dist/implementations/dms/page/registry.js.map +1 -1
  14. package/dist/implementations/dms/registry-snapshot.d.ts +32 -0
  15. package/dist/implementations/dms/registry-snapshot.js +55 -0
  16. package/dist/implementations/dms/registry-snapshot.js.map +1 -0
  17. package/dist/implementations/dms/services.d.ts +2 -0
  18. package/dist/implementations/dms/services.js +2 -0
  19. package/dist/implementations/dms/services.js.map +1 -1
  20. package/dist/implementations/dms/tenant-access.d.ts +1 -0
  21. package/dist/implementations/dms/tenant-access.js +7 -0
  22. package/dist/implementations/dms/tenant-access.js.map +1 -1
  23. package/dist/implementations/dms-builder/engine/compose-page.js +1 -1
  24. package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
  25. package/dist/implementations/dms-builder/engine/map-resources-pages.js +1 -1
  26. package/dist/implementations/dms-builder/engine/map-resources-pages.js.map +1 -1
  27. package/dist/implementations/dms-builder/engine/ops-blocks.d.ts +2 -1
  28. package/dist/implementations/dms-builder/engine/ops-blocks.js +12 -1
  29. package/dist/implementations/dms-builder/engine/ops-blocks.js.map +1 -1
  30. package/dist/implementations/dms-builder/engine/table-view-settings.js +9 -33
  31. package/dist/implementations/dms-builder/engine/table-view-settings.js.map +1 -1
  32. package/dist/index.js +2 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/mcp/index.d.ts +2 -0
  35. package/dist/mcp/index.js +9 -0
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/mockup-export/capture.d.ts +19 -0
  38. package/dist/mcp/mockup-export/capture.js +99 -0
  39. package/dist/mcp/mockup-export/capture.js.map +1 -0
  40. package/dist/mcp/mockup-export/document.d.ts +4 -0
  41. package/dist/mcp/mockup-export/document.js +199 -0
  42. package/dist/mcp/mockup-export/document.js.map +1 -0
  43. package/dist/mcp/mockup-export/index.d.ts +20 -0
  44. package/dist/mcp/mockup-export/index.js +112 -0
  45. package/dist/mcp/mockup-export/index.js.map +1 -0
  46. package/dist/mcp/mockup-export/jobs.d.ts +32 -0
  47. package/dist/mcp/mockup-export/jobs.js +49 -0
  48. package/dist/mcp/mockup-export/jobs.js.map +1 -0
  49. package/dist/mcp/mockup-export/plan.d.ts +78 -0
  50. package/dist/mcp/mockup-export/plan.js +296 -0
  51. package/dist/mcp/mockup-export/plan.js.map +1 -0
  52. package/dist/mcp/mockup-export/route.d.ts +23 -0
  53. package/dist/mcp/mockup-export/route.js +91 -0
  54. package/dist/mcp/mockup-export/route.js.map +1 -0
  55. package/dist/mcp/page-verify/index.d.ts +15 -0
  56. package/dist/mcp/page-verify/index.js +16 -6
  57. package/dist/mcp/page-verify/index.js.map +1 -1
  58. package/dist/mcp/page-verify/mockup.d.ts +3 -1
  59. package/dist/mcp/page-verify/mockup.js +2 -0
  60. package/dist/mcp/page-verify/mockup.js.map +1 -1
  61. package/dist/mcp/page-verify/modules.d.ts +1 -0
  62. package/dist/mcp/page-verify/modules.js +22 -0
  63. package/dist/mcp/page-verify/modules.js.map +1 -0
  64. package/dist/mcp/page-verify/page-probe.d.ts +5 -0
  65. package/dist/mcp/page-verify/page-probe.js +2 -0
  66. package/dist/mcp/page-verify/page-probe.js.map +1 -1
  67. package/dist/mcp/page-verify/playwright.d.ts +22 -4
  68. package/dist/mcp/page-verify/playwright.js.map +1 -1
  69. package/dist/mcp/page-verify/report.d.ts +1 -0
  70. package/dist/mcp/tools/builder-compose.js +4 -1
  71. package/dist/mcp/tools/builder-compose.js.map +1 -1
  72. package/dist/mcp/tools/builder-pages.js +1 -1
  73. package/dist/mcp/tools/builder-pages.js.map +1 -1
  74. package/dist/mcp/tools/index.d.ts +2 -0
  75. package/dist/mcp/tools/index.js +6 -1
  76. package/dist/mcp/tools/index.js.map +1 -1
  77. package/dist/mcp/tools/mockup-export-pdf.d.ts +1 -0
  78. package/dist/mcp/tools/mockup-export-pdf.js +69 -0
  79. package/dist/mcp/tools/mockup-export-pdf.js.map +1 -0
  80. package/dist/mcp/tools/mockup-install-modules.d.ts +9 -0
  81. package/dist/mcp/tools/mockup-install-modules.js +122 -0
  82. package/dist/mcp/tools/mockup-install-modules.js.map +1 -0
  83. package/dist/mcp/tools/mockup-module-catalog.d.ts +3 -0
  84. package/dist/mcp/tools/mockup-module-catalog.js +52 -0
  85. package/dist/mcp/tools/mockup-module-catalog.js.map +1 -0
  86. package/dist/mcp/tools/mockup-patch-spec.js +1 -1
  87. package/dist/mcp/tools/mockup-patch-spec.js.map +1 -1
  88. package/dist/mcp/tools/mockup-read-spec.js +8 -6
  89. package/dist/mcp/tools/mockup-read-spec.js.map +1 -1
  90. package/dist/mcp/tools/mockup-support.js +18 -5
  91. package/dist/mcp/tools/mockup-support.js.map +1 -1
  92. package/dist/mcp/tools/mockup-write-spec.js +1 -1
  93. package/dist/mcp/tools/mockup-write-spec.js.map +1 -1
  94. package/dist/mcp/tools/mockup.js +6 -0
  95. package/dist/mcp/tools/mockup.js.map +1 -1
  96. package/dist/mcp/tools/page-verify.d.ts +1 -0
  97. package/dist/mcp/tools/page-verify.js +6 -2
  98. package/dist/mcp/tools/page-verify.js.map +1 -1
  99. package/dist/mcp/tools/pages.d.ts +1 -0
  100. package/dist/mcp/tools/pages.js +9 -3
  101. package/dist/mcp/tools/pages.js.map +1 -1
  102. package/dist/mockup/annotations.js +2 -2
  103. package/dist/mockup/annotations.js.map +1 -1
  104. package/dist/mockup/apply-notes.js +1 -1
  105. package/dist/mockup/apply-notes.js.map +1 -1
  106. package/dist/mockup/compile-layouts.d.ts +5 -0
  107. package/dist/mockup/compile-layouts.js +74 -0
  108. package/dist/mockup/compile-layouts.js.map +1 -0
  109. package/dist/mockup/compile-modules.d.ts +5 -0
  110. package/dist/mockup/compile-modules.js +40 -0
  111. package/dist/mockup/compile-modules.js.map +1 -0
  112. package/dist/mockup/compile-nodes.d.ts +11 -0
  113. package/dist/mockup/compile-nodes.js +119 -0
  114. package/dist/mockup/compile-nodes.js.map +1 -0
  115. package/dist/mockup/compile-pages.d.ts +20 -0
  116. package/dist/mockup/compile-pages.js +272 -0
  117. package/dist/mockup/compile-pages.js.map +1 -0
  118. package/dist/mockup/compile.d.ts +10 -12
  119. package/dist/mockup/compile.js +36 -292
  120. package/dist/mockup/compile.js.map +1 -1
  121. package/dist/mockup/controller-blocks.js +2 -0
  122. package/dist/mockup/controller-blocks.js.map +1 -1
  123. package/dist/mockup/create.d.ts +16 -0
  124. package/dist/mockup/create.js +78 -0
  125. package/dist/mockup/create.js.map +1 -0
  126. package/dist/mockup/created-watch.d.ts +18 -0
  127. package/dist/mockup/created-watch.js +110 -0
  128. package/dist/mockup/created-watch.js.map +1 -0
  129. package/dist/mockup/database-routes.d.ts +15 -0
  130. package/dist/mockup/database-routes.js +58 -0
  131. package/dist/mockup/database-routes.js.map +1 -0
  132. package/dist/mockup/database-schema.d.ts +17 -0
  133. package/dist/mockup/database-schema.js +41 -0
  134. package/dist/mockup/database-schema.js.map +1 -0
  135. package/dist/mockup/entities.d.ts +20 -0
  136. package/dist/mockup/entities.js +213 -0
  137. package/dist/mockup/entities.js.map +1 -0
  138. package/dist/mockup/etag.d.ts +1 -0
  139. package/dist/mockup/etag.js +10 -0
  140. package/dist/mockup/etag.js.map +1 -0
  141. package/dist/mockup/extensions.d.ts +34 -0
  142. package/dist/mockup/extensions.js +107 -0
  143. package/dist/mockup/extensions.js.map +1 -0
  144. package/dist/mockup/files.d.ts +2 -1
  145. package/dist/mockup/files.js +2 -1
  146. package/dist/mockup/files.js.map +1 -1
  147. package/dist/mockup/fixture-answers.d.ts +3 -2
  148. package/dist/mockup/fixture-answers.js +13 -4
  149. package/dist/mockup/fixture-answers.js.map +1 -1
  150. package/dist/mockup/fixture-batch.d.ts +21 -0
  151. package/dist/mockup/fixture-batch.js +111 -0
  152. package/dist/mockup/fixture-batch.js.map +1 -0
  153. package/dist/mockup/fixture-routes.d.ts +21 -0
  154. package/dist/mockup/fixture-routes.js +136 -0
  155. package/dist/mockup/fixture-routes.js.map +1 -0
  156. package/dist/mockup/fixtures.d.ts +2 -29
  157. package/dist/mockup/fixtures.js +0 -111
  158. package/dist/mockup/fixtures.js.map +1 -1
  159. package/dist/mockup/from-page.js +2 -9
  160. package/dist/mockup/from-page.js.map +1 -1
  161. package/dist/mockup/generate.js +4 -1
  162. package/dist/mockup/generate.js.map +1 -1
  163. package/dist/mockup/history-routes.d.ts +2 -4
  164. package/dist/mockup/history-routes.js +30 -39
  165. package/dist/mockup/history-routes.js.map +1 -1
  166. package/dist/mockup/history.js +7 -3
  167. package/dist/mockup/history.js.map +1 -1
  168. package/dist/mockup/index.d.ts +14 -0
  169. package/dist/mockup/index.js +14 -0
  170. package/dist/mockup/index.js.map +1 -1
  171. package/dist/mockup/json-schema-entities.d.ts +5 -0
  172. package/dist/mockup/json-schema-entities.js +141 -0
  173. package/dist/mockup/json-schema-entities.js.map +1 -0
  174. package/dist/mockup/json-schema-layout.d.ts +1 -0
  175. package/dist/mockup/json-schema-layout.js +95 -2
  176. package/dist/mockup/json-schema-layout.js.map +1 -1
  177. package/dist/mockup/json-schema.d.ts +1 -1
  178. package/dist/mockup/json-schema.js +41 -20
  179. package/dist/mockup/json-schema.js.map +1 -1
  180. package/dist/mockup/json.d.ts +8 -0
  181. package/dist/mockup/json.js +20 -0
  182. package/dist/mockup/json.js.map +1 -0
  183. package/dist/mockup/layout-model.d.ts +156 -0
  184. package/dist/mockup/layout-model.js +96 -0
  185. package/dist/mockup/layout-model.js.map +1 -0
  186. package/dist/mockup/layouts.d.ts +9 -0
  187. package/dist/mockup/layouts.js +40 -0
  188. package/dist/mockup/layouts.js.map +1 -0
  189. package/dist/mockup/manage-routes.d.ts +3 -1
  190. package/dist/mockup/manage-routes.js +38 -1
  191. package/dist/mockup/manage-routes.js.map +1 -1
  192. package/dist/mockup/manage.js +1 -1
  193. package/dist/mockup/manage.js.map +1 -1
  194. package/dist/mockup/model.d.ts +145 -99
  195. package/dist/mockup/model.js +101 -86
  196. package/dist/mockup/model.js.map +1 -1
  197. package/dist/mockup/module-context.d.ts +25 -0
  198. package/dist/mockup/module-context.js +83 -0
  199. package/dist/mockup/module-context.js.map +1 -0
  200. package/dist/mockup/module-install.d.ts +22 -0
  201. package/dist/mockup/module-install.js +71 -0
  202. package/dist/mockup/module-install.js.map +1 -0
  203. package/dist/mockup/module-states.d.ts +17 -0
  204. package/dist/mockup/module-states.js +167 -0
  205. package/dist/mockup/module-states.js.map +1 -0
  206. package/dist/mockup/modules-schema.d.ts +2 -0
  207. package/dist/mockup/modules-schema.js +38 -0
  208. package/dist/mockup/modules-schema.js.map +1 -0
  209. package/dist/mockup/modules.d.ts +9 -10
  210. package/dist/mockup/modules.js +104 -25
  211. package/dist/mockup/modules.js.map +1 -1
  212. package/dist/mockup/page-capture-routes.d.ts +19 -0
  213. package/dist/mockup/page-capture-routes.js +92 -0
  214. package/dist/mockup/page-capture-routes.js.map +1 -0
  215. package/dist/mockup/page-captures.d.ts +61 -0
  216. package/dist/mockup/page-captures.js +252 -0
  217. package/dist/mockup/page-captures.js.map +1 -0
  218. package/dist/mockup/page-descriptions.d.ts +2 -0
  219. package/dist/mockup/page-descriptions.js +18 -0
  220. package/dist/mockup/page-descriptions.js.map +1 -0
  221. package/dist/mockup/parse-spec.d.ts +10 -0
  222. package/dist/mockup/parse-spec.js +62 -0
  223. package/dist/mockup/parse-spec.js.map +1 -0
  224. package/dist/mockup/places.d.ts +17 -0
  225. package/dist/mockup/places.js +75 -0
  226. package/dist/mockup/places.js.map +1 -0
  227. package/dist/mockup/presence-board.js +1 -1
  228. package/dist/mockup/presence-board.js.map +1 -1
  229. package/dist/mockup/presence-routes.js +2 -2
  230. package/dist/mockup/presence-routes.js.map +1 -1
  231. package/dist/mockup/refusals.d.ts +6 -0
  232. package/dist/mockup/refusals.js +17 -0
  233. package/dist/mockup/refusals.js.map +1 -1
  234. package/dist/mockup/routes.d.ts +3 -5
  235. package/dist/mockup/routes.js +24 -163
  236. package/dist/mockup/routes.js.map +1 -1
  237. package/dist/mockup/sketch-limits.d.ts +1 -0
  238. package/dist/mockup/sketch-limits.js +2 -1
  239. package/dist/mockup/sketch-limits.js.map +1 -1
  240. package/dist/mockup/sketch.d.ts +2 -2
  241. package/dist/mockup/sketch.js +2 -1
  242. package/dist/mockup/sketch.js.map +1 -1
  243. package/dist/mockup/slug.d.ts +3 -0
  244. package/dist/mockup/slug.js +7 -0
  245. package/dist/mockup/slug.js.map +1 -0
  246. package/dist/mockup/source-routes.d.ts +5 -4
  247. package/dist/mockup/source-routes.js +26 -17
  248. package/dist/mockup/source-routes.js.map +1 -1
  249. package/dist/mockup/source.d.ts +3 -3
  250. package/dist/mockup/source.js +4 -3
  251. package/dist/mockup/source.js.map +1 -1
  252. package/dist/mockup/state-patch.d.ts +22 -0
  253. package/dist/mockup/state-patch.js +76 -0
  254. package/dist/mockup/state-patch.js.map +1 -0
  255. package/dist/mockup/state.d.ts +163 -0
  256. package/dist/mockup/state.js +24 -0
  257. package/dist/mockup/state.js.map +1 -0
  258. package/dist/mockup/store-list.d.ts +28 -0
  259. package/dist/mockup/store-list.js +89 -0
  260. package/dist/mockup/store-list.js.map +1 -0
  261. package/dist/mockup/store.d.ts +25 -38
  262. package/dist/mockup/store.js +126 -203
  263. package/dist/mockup/store.js.map +1 -1
  264. package/dist/mockup/table-archive.d.ts +0 -1
  265. package/dist/mockup/table-archive.js +0 -16
  266. package/dist/mockup/table-archive.js.map +1 -1
  267. package/dist/mockup/tenancy.d.ts +19 -0
  268. package/dist/mockup/tenancy.js +73 -0
  269. package/dist/mockup/tenancy.js.map +1 -0
  270. package/dist/mockup/tenant-rows.d.ts +4 -0
  271. package/dist/mockup/tenant-rows.js +19 -0
  272. package/dist/mockup/tenant-rows.js.map +1 -0
  273. package/dist/mockup/unknown-keys.d.ts +2 -2
  274. package/dist/mockup/unknown-keys.js +8 -4
  275. package/dist/mockup/unknown-keys.js.map +1 -1
  276. package/dist/mockup/validate.d.ts +2 -2
  277. package/dist/mockup/validate.js.map +1 -1
  278. package/dist/store/catalog.d.ts +5 -1
  279. package/dist/store/catalog.js +12 -1
  280. package/dist/store/catalog.js.map +1 -1
  281. package/dist/store/changes.d.ts +3 -0
  282. package/dist/store/changes.js +22 -0
  283. package/dist/store/changes.js.map +1 -0
  284. package/dist/store/index.d.ts +2 -0
  285. package/dist/store/index.js +2 -0
  286. package/dist/store/index.js.map +1 -1
  287. package/dist/store/listing.js +5 -5
  288. package/dist/store/listing.js.map +1 -1
  289. package/dist/store/operations.d.ts +8 -0
  290. package/dist/store/operations.js +27 -3
  291. package/dist/store/operations.js.map +1 -1
  292. package/dist/store/registry.d.ts +1 -0
  293. package/dist/store/registry.js +9 -0
  294. package/dist/store/registry.js.map +1 -1
  295. package/dist/store/types.d.ts +3 -0
  296. package/dist/types/index.d.ts +1 -0
  297. package/dist/types/index.js +1 -0
  298. package/dist/types/index.js.map +1 -1
  299. package/dist/types/live-pages.d.ts +41 -0
  300. package/dist/types/live-pages.js +3 -0
  301. package/dist/types/live-pages.js.map +1 -0
  302. package/dist/validation/store.schema.d.ts +1 -0
  303. package/dist/validation/store.schema.js +4 -4
  304. package/dist/validation/store.schema.js.map +1 -1
  305. package/e2e/index.mjs +3 -2
  306. package/frontend-vue/build/viewer-chunks.ts +181 -0
  307. package/frontend-vue/dms.frontend.build.ts +2 -1
  308. package/frontend-vue/dms.frontend.ts +7 -0
  309. package/frontend-vue/eslint-globals.generated.mjs +27 -24
  310. package/frontend-vue/layers/dms-core/app/build/utils/asyncDataScope.ts +3 -31
  311. package/frontend-vue/layers/dms-core/app/build/utils/previewFrame.ts +6 -1
  312. package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +8 -2
  313. package/frontend-vue/layers/dms-core/app/utils/localFetchAnswers.ts +124 -0
  314. package/frontend-vue/layers/dms-core/app/utils/textDigest.ts +29 -0
  315. package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +4 -0
  316. package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +4 -0
  317. package/frontend-vue/layers/dms-layout/app/build/components/layout/DashboardSidebar.vue +89 -31
  318. package/frontend-vue/layers/dms-layout/app/build/components/layout/MockupSidebarMenu.vue +21 -6
  319. package/frontend-vue/layers/dms-layout/app/build/components/layout/SidebarUserMenu.vue +61 -8
  320. package/frontend-vue/layers/dms-layout/app/build/components/layout/mockupMenu.ts +79 -9
  321. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsNav.vue +57 -8
  322. package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsShell.vue +12 -0
  323. package/frontend-vue/layers/dms-layout/app/build/composables/settings/useSettingsNavigation.ts +42 -62
  324. package/frontend-vue/layers/dms-layout/app/build/mockups/created-mockups.ts +12 -2
  325. package/frontend-vue/layers/dms-layout/app/build/mockups/created-toast.ts +9 -1
  326. package/frontend-vue/layers/dms-layout/app/composables/page/useMockupStoreInstaller.ts +85 -0
  327. package/frontend-vue/layers/dms-layout/app/custom-layouts/MockupLayout.vue +0 -2
  328. package/frontend-vue/layers/dms-layout/app/custom-layouts/PreviewLayout.vue +53 -6
  329. package/frontend-vue/layers/dms-layout/app/plugins/mockup-store-installer.ts +10 -0
  330. package/frontend-vue/layers/dms-layout/app/plugins/registered-sidebar-widgets.ts +10 -0
  331. package/frontend-vue/layers/dms-layout/app/plugins/seo.ts +7 -0
  332. package/frontend-vue/layers/dms-layout/app/theme/actions.ts +11 -7
  333. package/frontend-vue/layers/dms-onboarding/app/middleware/onboarding.global.ts +3 -3
  334. package/frontend-vue/layers/dms-onboarding/app/plugins/onboarding-preload.ts +5 -1
  335. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/BlockPreviewSketch.vue +31 -5
  336. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupCanvasChrome.vue +2 -2
  337. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabase.vue +204 -0
  338. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseData.vue +288 -0
  339. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseDiagram.vue +91 -0
  340. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseRelationEdge.vue +40 -0
  341. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseTableNode.vue +133 -0
  342. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEmptyState.vue +23 -0
  343. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModuleStore.vue +240 -0
  344. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverview.vue +54 -33
  345. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSectionLabel.vue +52 -0
  346. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSlot.vue +65 -12
  347. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPagesList.vue +21 -0
  348. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinCard.vue +1 -1
  349. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinLayer.vue +1 -1
  350. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupReconnecting.vue +17 -0
  351. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTenantBanner.vue +48 -0
  352. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTitle.vue +24 -15
  353. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupToolbar.vue +196 -0
  354. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTopBar.vue +200 -179
  355. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWarningsMenu.vue +59 -0
  356. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkbench.vue +152 -57
  357. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkspaceSwitcher.vue +142 -0
  358. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewAdmission.ts +20 -0
  359. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewCapture.ts +71 -4
  360. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewNavigation.ts +44 -4
  361. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewSwapHold.ts +157 -0
  362. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/registeredSidebarWidgets.ts +20 -0
  363. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/storeModuleInstaller.ts +32 -0
  364. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockInspector.ts +14 -2
  365. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockPreviewEmbed.ts +309 -41
  366. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useFixtureBatches.ts +154 -0
  367. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupActivation.ts +182 -0
  368. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupConnectionTables.ts +80 -0
  369. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupDatabase.ts +212 -0
  370. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupEditing.ts +13 -1
  371. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameRender.ts +126 -0
  372. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameSize.ts +10 -5
  373. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupOverview.ts +50 -23
  374. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageFrame.ts +103 -29
  375. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageZoom.ts +146 -0
  376. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPdfExport.ts +124 -0
  377. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPins.ts +1 -1
  378. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRealData.ts +11 -4
  379. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRoutePage.ts +60 -14
  380. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSession.ts +8 -3
  381. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSpec.ts +6 -2
  382. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupTenancy.ts +36 -0
  383. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupToolModes.ts +5 -7
  384. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerActivation.ts +59 -0
  385. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerExport.ts +46 -0
  386. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerPages.ts +44 -10
  387. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerShortcuts.ts +13 -2
  388. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupWarningFocus.ts +145 -0
  389. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useOverviewCaptures.ts +39 -10
  390. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePersistedCaptures.ts +151 -0
  391. package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +41 -0
  392. package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +37 -3
  393. package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCreateModal.vue +130 -0
  394. package/frontend-vue/layers/dms-ui/app/build/mockups/manage.ts +20 -1
  395. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +137 -78
  396. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewChannel.ts +1 -8
  397. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +165 -103
  398. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewNavigation.ts +321 -0
  399. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewRects.ts +22 -0
  400. package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +112 -175
  401. package/frontend-vue/layers/dms-ui/app/build/utils/mockupActivation.ts +120 -0
  402. package/frontend-vue/layers/dms-ui/app/build/utils/mockupAnnotations.ts +146 -0
  403. package/frontend-vue/layers/dms-ui/app/build/utils/mockupCaptures.ts +118 -9
  404. package/frontend-vue/layers/dms-ui/app/build/utils/mockupDiagram.ts +330 -0
  405. package/frontend-vue/layers/dms-ui/app/build/utils/mockupEntities.ts +80 -0
  406. package/frontend-vue/layers/dms-ui/app/build/utils/mockupFrame.ts +123 -8
  407. package/frontend-vue/layers/dms-ui/app/build/utils/mockupLinks.ts +11 -2
  408. package/frontend-vue/layers/dms-ui/app/build/utils/mockupModuleNavigation.ts +215 -0
  409. package/frontend-vue/layers/dms-ui/app/build/utils/mockupModules.ts +240 -0
  410. package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverview.ts +21 -3
  411. package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverviewSections.ts +66 -0
  412. package/frontend-vue/layers/dms-ui/app/build/utils/mockupPageTree.ts +15 -0
  413. package/frontend-vue/layers/dms-ui/app/build/utils/mockupPins.ts +6 -8
  414. package/frontend-vue/layers/dms-ui/app/build/utils/mockupRealData.ts +23 -5
  415. package/frontend-vue/layers/dms-ui/app/build/utils/mockupRows.ts +83 -0
  416. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSchema.ts +173 -0
  417. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSettings.ts +218 -0
  418. package/frontend-vue/layers/dms-ui/app/build/utils/mockupShortcuts.ts +17 -6
  419. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +20 -0
  420. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStatePatch.ts +180 -0
  421. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +17 -2
  422. package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenancy.ts +148 -0
  423. package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenants.ts +23 -0
  424. package/frontend-vue/layers/dms-ui/app/build/utils/mockupTitles.ts +33 -0
  425. package/frontend-vue/layers/dms-ui/app/build/utils/mockupVersions.ts +2 -7
  426. package/frontend-vue/layers/dms-ui/app/build/utils/previewFixtureAnswers.ts +156 -0
  427. package/frontend-vue/layers/dms-ui/app/build/utils/previewFixturesOnly.ts +37 -19
  428. package/frontend-vue/layers/dms-ui/app/build/utils/previewOptionRules.ts +129 -0
  429. package/frontend-vue/layers/dms-ui/app/build/utils/previewPageLayout.ts +108 -6
  430. package/frontend-vue/layers/dms-ui/app/build/utils/previewPageQuery.ts +5 -1
  431. package/frontend-vue/layers/dms-ui/app/build/utils/previewRows.ts +400 -0
  432. package/frontend-vue/layers/dms-ui/app/build/utils/recordGuards.ts +15 -0
  433. package/frontend-vue/layers/dms-ui/app/build/utils/settingsGroups.ts +73 -0
  434. package/frontend-vue/layers/dms-ui/app/build/utils/sketch.ts +68 -12
  435. package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +15 -0
  436. package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +61 -12
  437. package/frontend-vue/layers/dms-ui/app/components/block-preview/MockupViewer.vue +4 -1
  438. package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupModuleStore.ts +2 -0
  439. package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupTenantBanner.ts +2 -0
  440. package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupWorkspaceSwitcher.ts +2 -0
  441. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/registeredSidebarWidgets.ts +1 -0
  442. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/storeModuleInstaller.ts +1 -0
  443. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useFixtureBatches.ts +1 -0
  444. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupActivation.ts +1 -0
  445. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupOverview.ts +1 -0
  446. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupPdfExport.ts +1 -0
  447. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupRoutePage.ts +1 -0
  448. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupSession.ts +1 -0
  449. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupTenancy.ts +1 -0
  450. package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/usePersistedCaptures.ts +1 -0
  451. package/frontend-vue/layers/dms-ui/app/entries/utils/blockPreview.ts +1 -0
  452. package/frontend-vue/layers/dms-ui/app/entries/utils/json.ts +1 -0
  453. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupActivation.ts +1 -0
  454. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupAnnotations.ts +1 -0
  455. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupDiagram.ts +1 -0
  456. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupModuleNavigation.ts +1 -0
  457. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupOverviewSections.ts +1 -0
  458. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupRows.ts +1 -0
  459. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupSchema.ts +1 -0
  460. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupSettings.ts +1 -0
  461. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupStatePatch.ts +1 -0
  462. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenancy.ts +1 -0
  463. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenants.ts +1 -0
  464. package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTitles.ts +1 -0
  465. package/frontend-vue/layers/dms-ui/app/entries/utils/previewFixtureAnswers.ts +1 -0
  466. package/frontend-vue/layers/dms-ui/app/entries/utils/previewRows.ts +1 -0
  467. package/frontend-vue/layers/dms-ui/app/entries/utils/settingsGroups.ts +1 -0
  468. package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +85 -7
  469. package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +85 -7
  470. package/frontend-vue/package.json +2 -2
  471. package/frontend-vue/scripts/test-dms-components.mjs +1 -1
  472. package/package.json +6 -5
  473. package/dist/mockup/row-filters.d.ts +0 -8
  474. package/dist/mockup/row-filters.js +0 -107
  475. package/dist/mockup/row-filters.js.map +0 -1
  476. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModules.vue +0 -47
  477. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewZoom.vue +0 -67
@@ -0,0 +1,156 @@
1
+ import type { JsonValue } from "../../../../dms-core/app/types/json";
2
+ import type {
3
+ LocalFetchAnswer,
4
+ LocalFetchAnswerer,
5
+ LocalFetchRequest,
6
+ } from "../../../../dms-core/app/utils/localFetchAnswers";
7
+ import { HTTP_NOT_FOUND } from "../../../../dms-core/app/utils/http-status";
8
+ import { isJsonValue, isObjectValue } from "./json";
9
+ import { isRecord } from "./recordGuards";
10
+ import { findRow, listRows, parseRows, parseRowsQuery } from "./previewRows";
11
+
12
+ /**
13
+ * The fixtures one page reads, keyed by the fixture route its tree names,
14
+ * `/api/mockup/<name>[/tenants/<tenant>]/pages/<page>/fixtures/<key>`: what
15
+ * the viewer posts with a `render` so the frame answers its blocks' reads
16
+ * with no request.
17
+ */
18
+ export type PreviewFixtureBatch = Record<string, JsonValue>;
19
+
20
+ /** Whether `value` is a {@link PreviewFixtureBatch}: an object whose every value is JSON. */
21
+ export function isPreviewFixtureBatch(
22
+ value: Parameters<typeof isRecord>[0],
23
+ ): value is PreviewFixtureBatch {
24
+ return isRecord(value) && Object.values(value).every(isJsonValue);
25
+ }
26
+
27
+ /**
28
+ * The keys of a batch the frame answers from: the fixture routes of one of
29
+ * the mockup's pages, `/api/mockup/<name>/.../fixtures/<key>`. The page the
30
+ * batch comes from is trusted to name what it reads, and not to name any
31
+ * other route of the API for its blocks to read from.
32
+ */
33
+ const FIXTURE_ROUTE = /^\/api\/mockup\/[^/]+\/(?:[^/]+\/)*fixtures\/[^/]+$/;
34
+
35
+ const ROWS_NOT_FOUND = "$dms.refusals.mockup.rows_not_found";
36
+ const ROW_NOT_FOUND = "$dms.refusals.mockup.row_not_found";
37
+
38
+ /** What a read of a fixture asks for, by the route's suffix after the fixture's own. */
39
+ type Read = "fixture" | "rows" | "record";
40
+
41
+ /** The suffixes a fixture's routes carry after its own, longest first. */
42
+ const SUFFIXES: ReadonlyArray<readonly [string, Read]> = [
43
+ ["/rows/list", "rows"],
44
+ ["/rows/get", "record"],
45
+ ["/rows", "rows"],
46
+ ["/record", "record"],
47
+ ];
48
+
49
+ const notFound = (message: string): LocalFetchAnswer => ({
50
+ status: HTTP_NOT_FOUND,
51
+ message,
52
+ });
53
+
54
+ /** `value` as a copy no block can write back into the batch through. */
55
+ function copyOf<T extends JsonValue>(value: T): T {
56
+ return structuredClone(value);
57
+ }
58
+
59
+ /** Whether two JSON values are the same data. */
60
+ function isSameJson(left: JsonValue, right: JsonValue): boolean {
61
+ if (left === right) return true;
62
+ if (Array.isArray(left) || Array.isArray(right)) {
63
+ return (
64
+ Array.isArray(left) &&
65
+ Array.isArray(right) &&
66
+ left.length === right.length &&
67
+ left.every((entry, index) => isSameJson(entry, right[index]))
68
+ );
69
+ }
70
+ if (!isObjectValue(left) || !isObjectValue(right)) return false;
71
+ const keys = Object.keys(left);
72
+ return (
73
+ keys.length === Object.keys(right).length &&
74
+ keys.every(
75
+ (key) => Object.hasOwn(right, key) && isSameJson(left[key], right[key]),
76
+ )
77
+ );
78
+ }
79
+
80
+ /** The fixture of the batch a path names, and what the path reads of it. */
81
+ function readOf(
82
+ batch: ReadonlyMap<string, JsonValue>,
83
+ path: string,
84
+ ): { fixture: JsonValue; read: Read } | undefined {
85
+ const own = batch.get(path);
86
+ if (own !== undefined) return { fixture: own, read: "fixture" };
87
+ for (const [suffix, read] of SUFFIXES) {
88
+ if (!path.endsWith(suffix)) continue;
89
+ const fixture = batch.get(path.slice(0, -suffix.length));
90
+ if (fixture !== undefined) return { fixture, read };
91
+ }
92
+ return undefined;
93
+ }
94
+
95
+ /** The answer of a read of `fixture` that lists rows or names one. */
96
+ function answerRows(
97
+ fixture: JsonValue,
98
+ read: Exclude<Read, "fixture">,
99
+ query: LocalFetchRequest["query"],
100
+ ): LocalFetchAnswer {
101
+ const rows = parseRows(fixture);
102
+ if (!rows) return notFound(ROWS_NOT_FOUND);
103
+ if (read === "rows") {
104
+ const { results, total } = listRows(rows, parseRowsQuery(query));
105
+ return { data: copyOf({ results, total }) };
106
+ }
107
+ const id = query.get("id");
108
+ const row =
109
+ id === null ? undefined : findRow(rows, id, query.get("key") ?? undefined);
110
+ return row ? { data: copyOf(row) } : notFound(ROW_NOT_FOUND);
111
+ }
112
+
113
+ /**
114
+ * The fixtures a preview frame answers from, and how it answers. A GET whose
115
+ * path is under an entry of the batch is answered from it, with no request:
116
+ * the fixture itself, its rows (a page of them, as a table asks), one row as
117
+ * a record, and the row a details view reads. Any other request goes to the
118
+ * network.
119
+ */
120
+ export interface PreviewFixtureAnswers {
121
+ /**
122
+ * Makes `batch` the fixtures answered from, the entries under the mockup's
123
+ * fixture routes alone: any other key is ignored.
124
+ *
125
+ * @returns Whether an entry was added, removed or changed
126
+ */
127
+ replace: (batch: PreviewFixtureBatch) => boolean;
128
+ /** The answerer to install on `$authFetch`. */
129
+ answer: LocalFetchAnswerer;
130
+ }
131
+
132
+ export function createPreviewFixtureAnswers(): PreviewFixtureAnswers {
133
+ let held = new Map<string, JsonValue>();
134
+ return {
135
+ replace(batch) {
136
+ const next = new Map(
137
+ Object.entries(batch).filter(([route]) => FIXTURE_ROUTE.test(route)),
138
+ );
139
+ const isChanged =
140
+ next.size !== held.size ||
141
+ [...next].some(([key, value]) => {
142
+ const before = held.get(key);
143
+ return before === undefined || !isSameJson(before, value);
144
+ });
145
+ held = next;
146
+ return isChanged;
147
+ },
148
+ answer({ path, query }) {
149
+ const found = readOf(held, path);
150
+ if (!found) return undefined;
151
+ return found.read === "fixture"
152
+ ? { data: copyOf(found.fixture) }
153
+ : answerRows(found.fixture, found.read, query);
154
+ },
155
+ };
156
+ }
@@ -2,23 +2,35 @@
2
2
  export const FIXTURES_ONLY_QUERY = "fixtures";
3
3
  export const FIXTURES_ONLY_VALUE = "only";
4
4
 
5
+ /**
6
+ * The query that marks `/dms-preview` as the mockup viewer's page frame, on
7
+ * sample or real data alike, and its value: that frame hands the viewer its
8
+ * zoom wheel and reports where its blocks sit while not inspecting.
9
+ */
10
+ export const MOCKUP_PAGE_FRAME_QUERY = "frame";
11
+ export const MOCKUP_PAGE_FRAME_VALUE = "page";
12
+
13
+ /** The value of {@link MOCKUP_PAGE_FRAME_QUERY} on a frame of the viewer's Overview: a frame of the viewer that has no zoom wheel of its own. */
14
+ export const MOCKUP_OVERVIEW_FRAME_VALUE = "overview";
15
+
16
+ /** Where the backend serves a page's block routes: every API path of a live block starts with it. */
17
+ export const LIVE_API_PREFIX = "/dms/pages/";
18
+
5
19
  /** The routes answering a mockup's fixtures and its own state. */
6
- const MOCKUP_ROUTES = "/api/mockup/";
20
+ export const MOCKUP_ROUTES = "/api/mockup/";
7
21
 
8
22
  /**
9
- * What the dashboard reads on any page, none of it a block's data: its
10
- * realtime session and page topics, its icons, the account's permissions,
11
- * the system and onboarding state its shell checks, and the preview page
12
- * itself, which a development reload fetches again.
23
+ * The site's own API, which a connection of the frame may reach: the routes
24
+ * of the modules (`/api/`) and of the DMS (`/dms/`), where the real blocks of
25
+ * a registered page read their data and the dashboard reads its shell (the
26
+ * realtime session, the account's permissions, the system state). A real
27
+ * block's routes are the ones its page and its module serve, so no list of
28
+ * pages covers them.
13
29
  */
14
- const SHELL_ROUTES = [
15
- "/api/realtime/",
16
- "/api/_dms/",
17
- "/api/system-state",
18
- "/api/onboarding/informations",
19
- "/dms/permissions",
20
- "/dms-preview",
21
- ];
30
+ export const SITE_API_ROUTES = ["/api/", "/dms/"];
31
+
32
+ /** The preview page itself, which a development reload fetches again. */
33
+ const PREVIEW_ROUTE = "/dms-preview";
22
34
 
23
35
  /**
24
36
  * Where the dashboard's own scripts, styles, fonts and images are served:
@@ -44,11 +56,17 @@ export type PolicyLocation = Pick<Location, "origin" | "host" | "protocol">;
44
56
  /**
45
57
  * The Content Security Policy of a preview drawn on fixtures. Every kind of
46
58
  * load (images, media, styles and the URLs they import, fonts, prefetches,
47
- * workers) and every connection reaches the mockup's routes, the
48
- * dashboard's own and its assets only, so no value a block holds can make
49
- * the frame read a live route, whatever block or data type draws it.
50
- * Scripts stay the dashboard's own: the frame loads block code after the
51
- * policy is set, and no value a block draws becomes a script.
59
+ * workers) reaches the mockup's routes, the dashboard's own and its assets
60
+ * only, so no value a block holds can make the frame load a live resource,
61
+ * whatever block or data type draws it. Connections also reach the site's own
62
+ * API ({@link SITE_API_ROUTES}), always, so the document does not depend on
63
+ * which pages a mockup draws: the real blocks of a registered page read their
64
+ * page's routes and their module's. What keeps a block the spec writes off
65
+ * those routes is the check of each node, not this policy: a node that is not
66
+ * a real block is refused a URL under them (`resolvePreviewTree`), and a block
67
+ * that needs a controller is refused. Scripts stay the dashboard's own: the
68
+ * frame loads block code after the policy is set, and no value a block draws
69
+ * becomes a script.
52
70
  */
53
71
  export function fixturesOnlyPolicy(location: PolicyLocation): string {
54
72
  const at = (paths: readonly string[]) =>
@@ -60,7 +78,7 @@ export function fixturesOnlyPolicy(location: PolicyLocation): string {
60
78
  `script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:`,
61
79
  `worker-src ${loads}`,
62
80
  `style-src 'unsafe-inline' ${loads}`,
63
- `connect-src ${at([MOCKUP_ROUTES, ...SHELL_ROUTES, ...ASSET_PATHS])} ${socket}//${location.host}`,
81
+ `connect-src ${at([...SITE_API_ROUTES, PREVIEW_ROUTE, ...ASSET_PATHS])} ${socket}//${location.host}`,
64
82
  "frame-src 'none'",
65
83
  "object-src 'none'",
66
84
  ].join("; ");
@@ -0,0 +1,129 @@
1
+ import { isObject, isString } from "../../../../dms-core/app/utils/type-check";
2
+ import { MOCKUP_ROUTES, SITE_API_ROUTES } from "./previewFixturesOnly";
3
+ import { startsWithUrlToken } from "./urlVariables";
4
+
5
+ const RELATIVE_PATH_PATTERN = /^\/(?![/\\])/;
6
+ const SAFE_METHODS = new Set(["GET", "HEAD"]);
7
+ const FRAME_ORIGIN = "http://frame.invalid";
8
+
9
+ /** The issue a refused option is reported as. */
10
+ type RefusedOptionIssue = "unsafe_url" | "unsafe_method";
11
+
12
+ /** A rule an option of a node must pass: on the keys `key` matches, a value `isAllowed` accepts. */
13
+ export interface OptionRule {
14
+ issue: RefusedOptionIssue;
15
+ /** Matches the option keys the rule applies to. */
16
+ key: RegExp;
17
+ isAllowed: (value: string) => boolean;
18
+ }
19
+
20
+ function isRecord(
21
+ value: Parameters<typeof isObject>[0],
22
+ ): value is Record<string, unknown> {
23
+ return isObject(value) && value !== null && !Array.isArray(value);
24
+ }
25
+
26
+ /**
27
+ * A URL a block may fetch from the preview: a path of this site. Anything
28
+ * with a scheme or a host (`https://…`, `//host/…`, `/\host`) would let an
29
+ * embedding page make the preview call out with the visitor's cookies.
30
+ */
31
+ export function isRelativePath(url: string): boolean {
32
+ return RELATIVE_PATH_PATTERN.test(url);
33
+ }
34
+
35
+ /** A method a block may load with: it reads, so loading the page changes nothing. */
36
+ export function isReadMethod(method: string): boolean {
37
+ return SAFE_METHODS.has(method.toUpperCase());
38
+ }
39
+
40
+ /**
41
+ * Whether `url`, a path of this site, reaches a route of the site's API that
42
+ * is not the mockup's own, as the browser resolves it: dot segments and
43
+ * percent-encoding applied, so `/api/mockup/../users` and `/%61pi/users` are
44
+ * the `/api/users` they request. A URL that does not parse reaches it.
45
+ */
46
+ export function reachesSiteApi(url: string): boolean {
47
+ try {
48
+ const decoded = decodeURIComponent(new URL(url, FRAME_ORIGIN).pathname);
49
+ const { pathname } = new URL(decoded, FRAME_ORIGIN);
50
+ return (
51
+ !pathname.startsWith(MOCKUP_ROUTES) &&
52
+ SITE_API_ROUTES.some((route) => pathname.startsWith(route))
53
+ );
54
+ } catch {
55
+ return true;
56
+ }
57
+ }
58
+
59
+ function urlRule(isAllowed: (url: string) => boolean): OptionRule {
60
+ return { issue: "unsafe_url", key: /(url|^location)$/i, isAllowed };
61
+ }
62
+
63
+ /**
64
+ * What a tree an embedding page hands over may not make the preview do with
65
+ * the visitor's session: call another site, or write on load (`fetchUrl`
66
+ * read with `POST`). A user action (a form's submit) stays the user's.
67
+ */
68
+ function optionRules(isUrlAllowed: (url: string) => boolean): OptionRule[] {
69
+ return [
70
+ urlRule(isUrlAllowed),
71
+ { issue: "unsafe_method", key: /urlmethod$/i, isAllowed: isReadMethod },
72
+ ];
73
+ }
74
+
75
+ /** The rules of a node the spec or an embedding page writes: relative paths, read on load. */
76
+ export const OPTION_RULES: readonly OptionRule[] = optionRules(isRelativePath);
77
+
78
+ /** The rules of such a node in a fixtures-only frame, which also keeps it off the routes of the site's API but the mockup's own. */
79
+ export const FIXTURES_OPTION_RULES: readonly OptionRule[] = optionRules(
80
+ (url) => isRelativePath(url) && !reachesSiteApi(url),
81
+ );
82
+
83
+ /**
84
+ * The rules of a real block of a registered page: the URLs it may read are the
85
+ * relative paths of its page and its module, and the templates its block fills
86
+ * per row or per route (`{{row.invoiceUrl}}`), which start with a token and so
87
+ * name no foreign address themselves. A foreign literal stays refused. It loads
88
+ * with the method its page declares, as on the real page: a list read with
89
+ * `POST`, as the members table is.
90
+ */
91
+ export const LIVE_OPTION_RULES: readonly OptionRule[] = [
92
+ urlRule((url) => isRelativePath(url) || startsWithUrlToken(url)),
93
+ ];
94
+
95
+ /** An option value the preview refuses, with the rule refusing it. */
96
+ export interface RefusedOption {
97
+ issue: RefusedOptionIssue;
98
+ value: string;
99
+ }
100
+
101
+ function refuseEntry(
102
+ key: string,
103
+ entry: Parameters<typeof isString>[0],
104
+ rules: readonly OptionRule[],
105
+ ): RefusedOption | undefined {
106
+ if (!isString(entry) || entry === "") return undefined;
107
+ const rule = rules.find(
108
+ (candidate) => candidate.key.test(key) && !candidate.isAllowed(entry),
109
+ );
110
+ return rule ? { issue: rule.issue, value: entry } : undefined;
111
+ }
112
+
113
+ /** The first option, at any depth, a rule of `rules` refuses: {@link OPTION_RULES} by default. */
114
+ export function findRefusedOption(
115
+ value: Parameters<typeof isRecord>[0],
116
+ rules: readonly OptionRule[] = OPTION_RULES,
117
+ ): RefusedOption | undefined {
118
+ const entries: Array<[string, unknown]> = Array.isArray(value)
119
+ ? value.map((entry) => ["", entry])
120
+ : isRecord(value)
121
+ ? Object.entries(value)
122
+ : [];
123
+ for (const [key, entry] of entries) {
124
+ const refused =
125
+ refuseEntry(key, entry, rules) ?? findRefusedOption(entry, rules);
126
+ if (refused) return refused;
127
+ }
128
+ return undefined;
129
+ }
@@ -1,8 +1,11 @@
1
1
  import {
2
2
  isBoolean,
3
+ isNumber,
3
4
  isObject,
4
5
  isString,
5
6
  } from "../../../../dms-core/app/utils/type-check";
7
+ import type { PreviewSketch } from "./blockPreview";
8
+ import { isPreviewSketch } from "./blockPreviewNavigation";
6
9
 
7
10
  /**
8
11
  * The layouts a mockup page is drawn in, named after their factories:
@@ -35,12 +38,51 @@ const LAYOUT_OPTION_KEYS: readonly string[] = [
35
38
  "hideFooter",
36
39
  ] satisfies (keyof PreviewPageLayoutOptions)[];
37
40
 
38
- /** The layout a page is drawn in, with its options. */
39
- export interface PreviewPageLayout {
41
+ /** One of the DMS's layouts a page is drawn in, with its options. */
42
+ export interface PreviewBuiltInLayout {
40
43
  type: PreviewPageLayoutType;
41
44
  options?: PreviewPageLayoutOptions;
42
45
  }
43
46
 
47
+ /** The side of the page a custom layout's aside is on. */
48
+ export type PreviewAsideSide = "start" | "end";
49
+
50
+ const ASIDE_SIDES: ReadonlySet<unknown> = new Set<PreviewAsideSide>([
51
+ "start",
52
+ "end",
53
+ ]);
54
+
55
+ /** The aside of a custom layout: a sketch beside the page, `width` pixels wide. */
56
+ export interface PreviewLayoutAside extends PreviewSketch {
57
+ width: number;
58
+ side: PreviewAsideSide;
59
+ }
60
+
61
+ /**
62
+ * A layout the spec declares, resolved for the page that names it: sketches
63
+ * drawn above, beside and under the page, and whether the dashboard's
64
+ * sidebar, top bar and page header stay around it.
65
+ */
66
+ export interface PreviewCustomLayout {
67
+ type: "custom";
68
+ id: string;
69
+ title: string;
70
+ dashboard: boolean;
71
+ header?: PreviewSketch;
72
+ aside?: PreviewLayoutAside;
73
+ footer?: PreviewSketch;
74
+ }
75
+
76
+ /** The layout a page is drawn in: one of the DMS's with its options, or a custom layout of the mockup. */
77
+ export type PreviewPageLayout = PreviewBuiltInLayout | PreviewCustomLayout;
78
+
79
+ /** The sketches a custom layout draws around the page. */
80
+ export interface PreviewCustomRegions {
81
+ header?: PreviewSketch;
82
+ aside?: PreviewLayoutAside;
83
+ footer?: PreviewSketch;
84
+ }
85
+
44
86
  /** What the preview draws around a page's blocks. */
45
87
  export interface PreviewFrame {
46
88
  /** The dashboard's sidebar and top bar. */
@@ -57,6 +99,8 @@ export interface PreviewFrame {
57
99
  brand: boolean;
58
100
  /** Without the dashboard: the footer under the page. */
59
101
  footer: boolean;
102
+ /** A custom layout's sketches around the page; absent for the DMS's own layouts. */
103
+ custom?: PreviewCustomRegions;
60
104
  }
61
105
 
62
106
  function isRecord(
@@ -85,10 +129,34 @@ function isLayoutOptions(value: unknown): value is PreviewPageLayoutOptions {
85
129
  );
86
130
  }
87
131
 
88
- /** Whether `value` is a layout a page is drawn in, each option a boolean the layouts take. */
89
- export function isPreviewPageLayout(
90
- value: unknown,
91
- ): value is PreviewPageLayout {
132
+ function isOptionalSketch(value: unknown): value is PreviewSketch | undefined {
133
+ return value === undefined || isPreviewSketch(value);
134
+ }
135
+
136
+ function isLayoutAside(value: unknown): value is PreviewLayoutAside {
137
+ return (
138
+ isPreviewSketch(value) &&
139
+ isRecord(value) &&
140
+ isNumber(value.width) &&
141
+ Number.isFinite(value.width) &&
142
+ ASIDE_SIDES.has(value.side)
143
+ );
144
+ }
145
+
146
+ function isCustomLayout(value: unknown): value is PreviewCustomLayout {
147
+ return (
148
+ isRecord(value) &&
149
+ value.type === "custom" &&
150
+ isString(value.id) &&
151
+ isString(value.title) &&
152
+ isBoolean(value.dashboard) &&
153
+ isOptionalSketch(value.header) &&
154
+ (value.aside === undefined || isLayoutAside(value.aside)) &&
155
+ isOptionalSketch(value.footer)
156
+ );
157
+ }
158
+
159
+ function isBuiltInLayout(value: unknown): value is PreviewBuiltInLayout {
92
160
  return (
93
161
  isRecord(value) &&
94
162
  isLayoutType(value.type) &&
@@ -96,6 +164,16 @@ export function isPreviewPageLayout(
96
164
  );
97
165
  }
98
166
 
167
+ /**
168
+ * Whether `value` is a layout a page is drawn in: one of the DMS's, each
169
+ * option a boolean the layouts take, or a custom layout, each region a sketch.
170
+ */
171
+ export function isPreviewPageLayout(
172
+ value: unknown,
173
+ ): value is PreviewPageLayout {
174
+ return isBuiltInLayout(value) || isCustomLayout(value);
175
+ }
176
+
99
177
  /** Whether `value` is absent, or a layout a page is drawn in. */
100
178
  export function isOptionalPreviewPageLayout(
101
179
  value: unknown,
@@ -123,6 +201,7 @@ export function isOptionalStringRecord(
123
201
  export function previewFrameOf(
124
202
  layout: PreviewPageLayout | undefined,
125
203
  ): PreviewFrame {
204
+ if (layout?.type === "custom") return customFrameOf(layout);
126
205
  const options = layout?.options ?? {};
127
206
  const fillHeight = options.fillHeight ?? false;
128
207
  if (layout?.type === "empty") {
@@ -147,3 +226,26 @@ export function previewFrameOf(
147
226
  footer: false,
148
227
  };
149
228
  }
229
+
230
+ /**
231
+ * What the preview draws around a page in a custom layout: the dashboard's
232
+ * sidebar, top bar and page header when the layout keeps the dashboard, none
233
+ * of them and no logo or footer when it does not, and the layout's sketches,
234
+ * the blocks spanning the panel either way.
235
+ */
236
+ function customFrameOf(layout: PreviewCustomLayout): PreviewFrame {
237
+ return {
238
+ dashboard: layout.dashboard,
239
+ header: layout.dashboard,
240
+ fullWidth: true,
241
+ settings: false,
242
+ fillHeight: false,
243
+ brand: false,
244
+ footer: false,
245
+ custom: {
246
+ ...(layout.header && { header: layout.header }),
247
+ ...(layout.aside && { aside: layout.aside }),
248
+ ...(layout.footer && { footer: layout.footer }),
249
+ },
250
+ };
251
+ }
@@ -1,4 +1,7 @@
1
- import { FIXTURES_ONLY_QUERY } from "./previewFixturesOnly";
1
+ import {
2
+ FIXTURES_ONLY_QUERY,
3
+ MOCKUP_PAGE_FRAME_QUERY,
4
+ } from "./previewFixturesOnly";
2
5
 
3
6
  /** The query `/dms-preview` reads its first state from. */
4
7
  export const STATE_QUERY = "state";
@@ -7,6 +10,7 @@ export const STATE_QUERY = "state";
7
10
  const PREVIEW_QUERY_KEYS: ReadonlySet<string> = new Set([
8
11
  STATE_QUERY,
9
12
  FIXTURES_ONLY_QUERY,
13
+ MOCKUP_PAGE_FRAME_QUERY,
10
14
  ]);
11
15
 
12
16
  type QueryValue = string | null | readonly (string | null)[];