@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.
- package/CHANGELOG.md +0 -48
- package/E2E.md +138 -0
- package/README.md +2 -2
- package/data/mockup-example/spec.json +13 -0
- package/data/mockup-spec.schema.json +399 -16
- package/dist/e2e/index.d.mts +2 -1
- package/dist/implementations/dms/live-pages.d.ts +6 -0
- package/dist/implementations/dms/live-pages.js +139 -0
- package/dist/implementations/dms/live-pages.js.map +1 -0
- package/dist/implementations/dms/page/notifications.js +2 -0
- package/dist/implementations/dms/page/notifications.js.map +1 -1
- package/dist/implementations/dms/page/registry.js +19 -4
- package/dist/implementations/dms/page/registry.js.map +1 -1
- package/dist/implementations/dms/registry-snapshot.d.ts +32 -0
- package/dist/implementations/dms/registry-snapshot.js +55 -0
- package/dist/implementations/dms/registry-snapshot.js.map +1 -0
- package/dist/implementations/dms/services.d.ts +2 -0
- package/dist/implementations/dms/services.js +2 -0
- package/dist/implementations/dms/services.js.map +1 -1
- package/dist/implementations/dms/tenant-access.d.ts +1 -0
- package/dist/implementations/dms/tenant-access.js +7 -0
- package/dist/implementations/dms/tenant-access.js.map +1 -1
- package/dist/implementations/dms-builder/engine/compose-page.js +1 -1
- package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
- package/dist/implementations/dms-builder/engine/map-resources-pages.js +1 -1
- package/dist/implementations/dms-builder/engine/map-resources-pages.js.map +1 -1
- package/dist/implementations/dms-builder/engine/ops-blocks.d.ts +2 -1
- package/dist/implementations/dms-builder/engine/ops-blocks.js +12 -1
- package/dist/implementations/dms-builder/engine/ops-blocks.js.map +1 -1
- package/dist/implementations/dms-builder/engine/table-view-settings.js +9 -33
- package/dist/implementations/dms-builder/engine/table-view-settings.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mockup-export/capture.d.ts +19 -0
- package/dist/mcp/mockup-export/capture.js +99 -0
- package/dist/mcp/mockup-export/capture.js.map +1 -0
- package/dist/mcp/mockup-export/document.d.ts +4 -0
- package/dist/mcp/mockup-export/document.js +199 -0
- package/dist/mcp/mockup-export/document.js.map +1 -0
- package/dist/mcp/mockup-export/index.d.ts +20 -0
- package/dist/mcp/mockup-export/index.js +112 -0
- package/dist/mcp/mockup-export/index.js.map +1 -0
- package/dist/mcp/mockup-export/jobs.d.ts +32 -0
- package/dist/mcp/mockup-export/jobs.js +49 -0
- package/dist/mcp/mockup-export/jobs.js.map +1 -0
- package/dist/mcp/mockup-export/plan.d.ts +78 -0
- package/dist/mcp/mockup-export/plan.js +296 -0
- package/dist/mcp/mockup-export/plan.js.map +1 -0
- package/dist/mcp/mockup-export/route.d.ts +23 -0
- package/dist/mcp/mockup-export/route.js +91 -0
- package/dist/mcp/mockup-export/route.js.map +1 -0
- package/dist/mcp/page-verify/index.d.ts +15 -0
- package/dist/mcp/page-verify/index.js +16 -6
- package/dist/mcp/page-verify/index.js.map +1 -1
- package/dist/mcp/page-verify/mockup.d.ts +3 -1
- package/dist/mcp/page-verify/mockup.js +2 -0
- package/dist/mcp/page-verify/mockup.js.map +1 -1
- package/dist/mcp/page-verify/modules.d.ts +1 -0
- package/dist/mcp/page-verify/modules.js +22 -0
- package/dist/mcp/page-verify/modules.js.map +1 -0
- package/dist/mcp/page-verify/page-probe.d.ts +5 -0
- package/dist/mcp/page-verify/page-probe.js +2 -0
- package/dist/mcp/page-verify/page-probe.js.map +1 -1
- package/dist/mcp/page-verify/playwright.d.ts +22 -4
- package/dist/mcp/page-verify/playwright.js.map +1 -1
- package/dist/mcp/page-verify/report.d.ts +1 -0
- package/dist/mcp/tools/builder-compose.js +4 -1
- package/dist/mcp/tools/builder-compose.js.map +1 -1
- package/dist/mcp/tools/builder-pages.js +1 -1
- package/dist/mcp/tools/builder-pages.js.map +1 -1
- package/dist/mcp/tools/index.d.ts +2 -0
- package/dist/mcp/tools/index.js +6 -1
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/mockup-export-pdf.d.ts +1 -0
- package/dist/mcp/tools/mockup-export-pdf.js +69 -0
- package/dist/mcp/tools/mockup-export-pdf.js.map +1 -0
- package/dist/mcp/tools/mockup-install-modules.d.ts +9 -0
- package/dist/mcp/tools/mockup-install-modules.js +122 -0
- package/dist/mcp/tools/mockup-install-modules.js.map +1 -0
- package/dist/mcp/tools/mockup-module-catalog.d.ts +3 -0
- package/dist/mcp/tools/mockup-module-catalog.js +52 -0
- package/dist/mcp/tools/mockup-module-catalog.js.map +1 -0
- package/dist/mcp/tools/mockup-patch-spec.js +1 -1
- package/dist/mcp/tools/mockup-patch-spec.js.map +1 -1
- package/dist/mcp/tools/mockup-read-spec.js +8 -6
- package/dist/mcp/tools/mockup-read-spec.js.map +1 -1
- package/dist/mcp/tools/mockup-support.js +18 -5
- package/dist/mcp/tools/mockup-support.js.map +1 -1
- package/dist/mcp/tools/mockup-write-spec.js +1 -1
- package/dist/mcp/tools/mockup-write-spec.js.map +1 -1
- package/dist/mcp/tools/mockup.js +6 -0
- package/dist/mcp/tools/mockup.js.map +1 -1
- package/dist/mcp/tools/page-verify.d.ts +1 -0
- package/dist/mcp/tools/page-verify.js +6 -2
- package/dist/mcp/tools/page-verify.js.map +1 -1
- package/dist/mcp/tools/pages.d.ts +1 -0
- package/dist/mcp/tools/pages.js +9 -3
- package/dist/mcp/tools/pages.js.map +1 -1
- package/dist/mockup/annotations.js +2 -2
- package/dist/mockup/annotations.js.map +1 -1
- package/dist/mockup/apply-notes.js +1 -1
- package/dist/mockup/apply-notes.js.map +1 -1
- package/dist/mockup/compile-layouts.d.ts +5 -0
- package/dist/mockup/compile-layouts.js +74 -0
- package/dist/mockup/compile-layouts.js.map +1 -0
- package/dist/mockup/compile-modules.d.ts +5 -0
- package/dist/mockup/compile-modules.js +40 -0
- package/dist/mockup/compile-modules.js.map +1 -0
- package/dist/mockup/compile-nodes.d.ts +11 -0
- package/dist/mockup/compile-nodes.js +119 -0
- package/dist/mockup/compile-nodes.js.map +1 -0
- package/dist/mockup/compile-pages.d.ts +20 -0
- package/dist/mockup/compile-pages.js +272 -0
- package/dist/mockup/compile-pages.js.map +1 -0
- package/dist/mockup/compile.d.ts +10 -12
- package/dist/mockup/compile.js +36 -292
- package/dist/mockup/compile.js.map +1 -1
- package/dist/mockup/controller-blocks.js +2 -0
- package/dist/mockup/controller-blocks.js.map +1 -1
- package/dist/mockup/create.d.ts +16 -0
- package/dist/mockup/create.js +78 -0
- package/dist/mockup/create.js.map +1 -0
- package/dist/mockup/created-watch.d.ts +18 -0
- package/dist/mockup/created-watch.js +110 -0
- package/dist/mockup/created-watch.js.map +1 -0
- package/dist/mockup/database-routes.d.ts +15 -0
- package/dist/mockup/database-routes.js +58 -0
- package/dist/mockup/database-routes.js.map +1 -0
- package/dist/mockup/database-schema.d.ts +17 -0
- package/dist/mockup/database-schema.js +41 -0
- package/dist/mockup/database-schema.js.map +1 -0
- package/dist/mockup/entities.d.ts +20 -0
- package/dist/mockup/entities.js +213 -0
- package/dist/mockup/entities.js.map +1 -0
- package/dist/mockup/etag.d.ts +1 -0
- package/dist/mockup/etag.js +10 -0
- package/dist/mockup/etag.js.map +1 -0
- package/dist/mockup/extensions.d.ts +34 -0
- package/dist/mockup/extensions.js +107 -0
- package/dist/mockup/extensions.js.map +1 -0
- package/dist/mockup/files.d.ts +2 -1
- package/dist/mockup/files.js +2 -1
- package/dist/mockup/files.js.map +1 -1
- package/dist/mockup/fixture-answers.d.ts +3 -2
- package/dist/mockup/fixture-answers.js +13 -4
- package/dist/mockup/fixture-answers.js.map +1 -1
- package/dist/mockup/fixture-batch.d.ts +21 -0
- package/dist/mockup/fixture-batch.js +111 -0
- package/dist/mockup/fixture-batch.js.map +1 -0
- package/dist/mockup/fixture-routes.d.ts +21 -0
- package/dist/mockup/fixture-routes.js +136 -0
- package/dist/mockup/fixture-routes.js.map +1 -0
- package/dist/mockup/fixtures.d.ts +2 -29
- package/dist/mockup/fixtures.js +0 -111
- package/dist/mockup/fixtures.js.map +1 -1
- package/dist/mockup/from-page.js +2 -9
- package/dist/mockup/from-page.js.map +1 -1
- package/dist/mockup/generate.js +4 -1
- package/dist/mockup/generate.js.map +1 -1
- package/dist/mockup/history-routes.d.ts +2 -4
- package/dist/mockup/history-routes.js +30 -39
- package/dist/mockup/history-routes.js.map +1 -1
- package/dist/mockup/history.js +7 -3
- package/dist/mockup/history.js.map +1 -1
- package/dist/mockup/index.d.ts +14 -0
- package/dist/mockup/index.js +14 -0
- package/dist/mockup/index.js.map +1 -1
- package/dist/mockup/json-schema-entities.d.ts +5 -0
- package/dist/mockup/json-schema-entities.js +141 -0
- package/dist/mockup/json-schema-entities.js.map +1 -0
- package/dist/mockup/json-schema-layout.d.ts +1 -0
- package/dist/mockup/json-schema-layout.js +95 -2
- package/dist/mockup/json-schema-layout.js.map +1 -1
- package/dist/mockup/json-schema.d.ts +1 -1
- package/dist/mockup/json-schema.js +41 -20
- package/dist/mockup/json-schema.js.map +1 -1
- package/dist/mockup/json.d.ts +8 -0
- package/dist/mockup/json.js +20 -0
- package/dist/mockup/json.js.map +1 -0
- package/dist/mockup/layout-model.d.ts +156 -0
- package/dist/mockup/layout-model.js +96 -0
- package/dist/mockup/layout-model.js.map +1 -0
- package/dist/mockup/layouts.d.ts +9 -0
- package/dist/mockup/layouts.js +40 -0
- package/dist/mockup/layouts.js.map +1 -0
- package/dist/mockup/manage-routes.d.ts +3 -1
- package/dist/mockup/manage-routes.js +38 -1
- package/dist/mockup/manage-routes.js.map +1 -1
- package/dist/mockup/manage.js +1 -1
- package/dist/mockup/manage.js.map +1 -1
- package/dist/mockup/model.d.ts +145 -99
- package/dist/mockup/model.js +101 -86
- package/dist/mockup/model.js.map +1 -1
- package/dist/mockup/module-context.d.ts +25 -0
- package/dist/mockup/module-context.js +83 -0
- package/dist/mockup/module-context.js.map +1 -0
- package/dist/mockup/module-install.d.ts +22 -0
- package/dist/mockup/module-install.js +71 -0
- package/dist/mockup/module-install.js.map +1 -0
- package/dist/mockup/module-states.d.ts +17 -0
- package/dist/mockup/module-states.js +167 -0
- package/dist/mockup/module-states.js.map +1 -0
- package/dist/mockup/modules-schema.d.ts +2 -0
- package/dist/mockup/modules-schema.js +38 -0
- package/dist/mockup/modules-schema.js.map +1 -0
- package/dist/mockup/modules.d.ts +9 -10
- package/dist/mockup/modules.js +104 -25
- package/dist/mockup/modules.js.map +1 -1
- package/dist/mockup/page-capture-routes.d.ts +19 -0
- package/dist/mockup/page-capture-routes.js +92 -0
- package/dist/mockup/page-capture-routes.js.map +1 -0
- package/dist/mockup/page-captures.d.ts +61 -0
- package/dist/mockup/page-captures.js +252 -0
- package/dist/mockup/page-captures.js.map +1 -0
- package/dist/mockup/page-descriptions.d.ts +2 -0
- package/dist/mockup/page-descriptions.js +18 -0
- package/dist/mockup/page-descriptions.js.map +1 -0
- package/dist/mockup/parse-spec.d.ts +10 -0
- package/dist/mockup/parse-spec.js +62 -0
- package/dist/mockup/parse-spec.js.map +1 -0
- package/dist/mockup/places.d.ts +17 -0
- package/dist/mockup/places.js +75 -0
- package/dist/mockup/places.js.map +1 -0
- package/dist/mockup/presence-board.js +1 -1
- package/dist/mockup/presence-board.js.map +1 -1
- package/dist/mockup/presence-routes.js +2 -2
- package/dist/mockup/presence-routes.js.map +1 -1
- package/dist/mockup/refusals.d.ts +6 -0
- package/dist/mockup/refusals.js +17 -0
- package/dist/mockup/refusals.js.map +1 -1
- package/dist/mockup/routes.d.ts +3 -5
- package/dist/mockup/routes.js +24 -163
- package/dist/mockup/routes.js.map +1 -1
- package/dist/mockup/sketch-limits.d.ts +1 -0
- package/dist/mockup/sketch-limits.js +2 -1
- package/dist/mockup/sketch-limits.js.map +1 -1
- package/dist/mockup/sketch.d.ts +2 -2
- package/dist/mockup/sketch.js +2 -1
- package/dist/mockup/sketch.js.map +1 -1
- package/dist/mockup/slug.d.ts +3 -0
- package/dist/mockup/slug.js +7 -0
- package/dist/mockup/slug.js.map +1 -0
- package/dist/mockup/source-routes.d.ts +5 -4
- package/dist/mockup/source-routes.js +26 -17
- package/dist/mockup/source-routes.js.map +1 -1
- package/dist/mockup/source.d.ts +3 -3
- package/dist/mockup/source.js +4 -3
- package/dist/mockup/source.js.map +1 -1
- package/dist/mockup/state-patch.d.ts +22 -0
- package/dist/mockup/state-patch.js +76 -0
- package/dist/mockup/state-patch.js.map +1 -0
- package/dist/mockup/state.d.ts +163 -0
- package/dist/mockup/state.js +24 -0
- package/dist/mockup/state.js.map +1 -0
- package/dist/mockup/store-list.d.ts +28 -0
- package/dist/mockup/store-list.js +89 -0
- package/dist/mockup/store-list.js.map +1 -0
- package/dist/mockup/store.d.ts +25 -38
- package/dist/mockup/store.js +126 -203
- package/dist/mockup/store.js.map +1 -1
- package/dist/mockup/table-archive.d.ts +0 -1
- package/dist/mockup/table-archive.js +0 -16
- package/dist/mockup/table-archive.js.map +1 -1
- package/dist/mockup/tenancy.d.ts +19 -0
- package/dist/mockup/tenancy.js +73 -0
- package/dist/mockup/tenancy.js.map +1 -0
- package/dist/mockup/tenant-rows.d.ts +4 -0
- package/dist/mockup/tenant-rows.js +19 -0
- package/dist/mockup/tenant-rows.js.map +1 -0
- package/dist/mockup/unknown-keys.d.ts +2 -2
- package/dist/mockup/unknown-keys.js +8 -4
- package/dist/mockup/unknown-keys.js.map +1 -1
- package/dist/mockup/validate.d.ts +2 -2
- package/dist/mockup/validate.js.map +1 -1
- package/dist/store/catalog.d.ts +5 -1
- package/dist/store/catalog.js +12 -1
- package/dist/store/catalog.js.map +1 -1
- package/dist/store/changes.d.ts +3 -0
- package/dist/store/changes.js +22 -0
- package/dist/store/changes.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +2 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/listing.js +5 -5
- package/dist/store/listing.js.map +1 -1
- package/dist/store/operations.d.ts +8 -0
- package/dist/store/operations.js +27 -3
- package/dist/store/operations.js.map +1 -1
- package/dist/store/registry.d.ts +1 -0
- package/dist/store/registry.js +9 -0
- package/dist/store/registry.js.map +1 -1
- package/dist/store/types.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/live-pages.d.ts +41 -0
- package/dist/types/live-pages.js +3 -0
- package/dist/types/live-pages.js.map +1 -0
- package/dist/validation/store.schema.d.ts +1 -0
- package/dist/validation/store.schema.js +4 -4
- package/dist/validation/store.schema.js.map +1 -1
- package/e2e/index.mjs +3 -2
- package/frontend-vue/build/viewer-chunks.ts +181 -0
- package/frontend-vue/dms.frontend.build.ts +2 -1
- package/frontend-vue/dms.frontend.ts +7 -0
- package/frontend-vue/eslint-globals.generated.mjs +27 -24
- package/frontend-vue/layers/dms-core/app/build/utils/asyncDataScope.ts +3 -31
- package/frontend-vue/layers/dms-core/app/build/utils/previewFrame.ts +6 -1
- package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +8 -2
- package/frontend-vue/layers/dms-core/app/utils/localFetchAnswers.ts +124 -0
- package/frontend-vue/layers/dms-core/app/utils/textDigest.ts +29 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +4 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +4 -0
- package/frontend-vue/layers/dms-layout/app/build/components/layout/DashboardSidebar.vue +89 -31
- package/frontend-vue/layers/dms-layout/app/build/components/layout/MockupSidebarMenu.vue +21 -6
- package/frontend-vue/layers/dms-layout/app/build/components/layout/SidebarUserMenu.vue +61 -8
- package/frontend-vue/layers/dms-layout/app/build/components/layout/mockupMenu.ts +79 -9
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsNav.vue +57 -8
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsShell.vue +12 -0
- package/frontend-vue/layers/dms-layout/app/build/composables/settings/useSettingsNavigation.ts +42 -62
- package/frontend-vue/layers/dms-layout/app/build/mockups/created-mockups.ts +12 -2
- package/frontend-vue/layers/dms-layout/app/build/mockups/created-toast.ts +9 -1
- package/frontend-vue/layers/dms-layout/app/composables/page/useMockupStoreInstaller.ts +85 -0
- package/frontend-vue/layers/dms-layout/app/custom-layouts/MockupLayout.vue +0 -2
- package/frontend-vue/layers/dms-layout/app/custom-layouts/PreviewLayout.vue +53 -6
- package/frontend-vue/layers/dms-layout/app/plugins/mockup-store-installer.ts +10 -0
- package/frontend-vue/layers/dms-layout/app/plugins/registered-sidebar-widgets.ts +10 -0
- package/frontend-vue/layers/dms-layout/app/plugins/seo.ts +7 -0
- package/frontend-vue/layers/dms-layout/app/theme/actions.ts +11 -7
- package/frontend-vue/layers/dms-onboarding/app/middleware/onboarding.global.ts +3 -3
- package/frontend-vue/layers/dms-onboarding/app/plugins/onboarding-preload.ts +5 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/BlockPreviewSketch.vue +31 -5
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupCanvasChrome.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabase.vue +204 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseData.vue +288 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseDiagram.vue +91 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseRelationEdge.vue +40 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabaseTableNode.vue +133 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEmptyState.vue +23 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModuleStore.vue +240 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverview.vue +54 -33
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSectionLabel.vue +52 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSlot.vue +65 -12
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPagesList.vue +21 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinCard.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinLayer.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupReconnecting.vue +17 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTenantBanner.vue +48 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTitle.vue +24 -15
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupToolbar.vue +196 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTopBar.vue +200 -179
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWarningsMenu.vue +59 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkbench.vue +152 -57
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkspaceSwitcher.vue +142 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewAdmission.ts +20 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewCapture.ts +71 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewNavigation.ts +44 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewSwapHold.ts +157 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/registeredSidebarWidgets.ts +20 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/storeModuleInstaller.ts +32 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockInspector.ts +14 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockPreviewEmbed.ts +309 -41
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useFixtureBatches.ts +154 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupActivation.ts +182 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupConnectionTables.ts +80 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupDatabase.ts +212 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupEditing.ts +13 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameRender.ts +126 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameSize.ts +10 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupOverview.ts +50 -23
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageFrame.ts +103 -29
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageZoom.ts +146 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPdfExport.ts +124 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPins.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRealData.ts +11 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRoutePage.ts +60 -14
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSession.ts +8 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSpec.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupTenancy.ts +36 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupToolModes.ts +5 -7
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerActivation.ts +59 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerExport.ts +46 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerPages.ts +44 -10
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerShortcuts.ts +13 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupWarningFocus.ts +145 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useOverviewCaptures.ts +39 -10
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePersistedCaptures.ts +151 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +41 -0
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +37 -3
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCreateModal.vue +130 -0
- package/frontend-vue/layers/dms-ui/app/build/mockups/manage.ts +20 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +137 -78
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewChannel.ts +1 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +165 -103
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewNavigation.ts +321 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewRects.ts +22 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +112 -175
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupActivation.ts +120 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupAnnotations.ts +146 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCaptures.ts +118 -9
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupDiagram.ts +330 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupEntities.ts +80 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupFrame.ts +123 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupLinks.ts +11 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupModuleNavigation.ts +215 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupModules.ts +240 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverview.ts +21 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverviewSections.ts +66 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupPageTree.ts +15 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupPins.ts +6 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupRealData.ts +23 -5
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupRows.ts +83 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSchema.ts +173 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSettings.ts +218 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupShortcuts.ts +17 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +20 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStatePatch.ts +180 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +17 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenancy.ts +148 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenants.ts +23 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupTitles.ts +33 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupVersions.ts +2 -7
- package/frontend-vue/layers/dms-ui/app/build/utils/previewFixtureAnswers.ts +156 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewFixturesOnly.ts +37 -19
- package/frontend-vue/layers/dms-ui/app/build/utils/previewOptionRules.ts +129 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageLayout.ts +108 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageQuery.ts +5 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/previewRows.ts +400 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/recordGuards.ts +15 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/settingsGroups.ts +73 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/sketch.ts +68 -12
- package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +15 -0
- package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +61 -12
- package/frontend-vue/layers/dms-ui/app/components/block-preview/MockupViewer.vue +4 -1
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupModuleStore.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupTenantBanner.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupWorkspaceSwitcher.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/registeredSidebarWidgets.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/storeModuleInstaller.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useFixtureBatches.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupActivation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupOverview.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupPdfExport.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupRoutePage.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupSession.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupTenancy.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/usePersistedCaptures.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/blockPreview.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/json.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupActivation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupAnnotations.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupDiagram.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupModuleNavigation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupOverviewSections.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupRows.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupSchema.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupSettings.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupStatePatch.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenancy.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenants.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTitles.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/previewFixtureAnswers.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/previewRows.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/settingsGroups.ts +1 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +85 -7
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +85 -7
- package/frontend-vue/package.json +2 -2
- package/frontend-vue/scripts/test-dms-components.mjs +1 -1
- package/package.json +6 -5
- package/dist/mockup/row-filters.d.ts +0 -8
- package/dist/mockup/row-filters.js +0 -107
- package/dist/mockup/row-filters.js.map +0 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModules.vue +0 -47
- 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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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)
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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([
|
|
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
|
-
/**
|
|
39
|
-
export interface
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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 {
|
|
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)[];
|