@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,400 @@
|
|
|
1
|
+
import type { JsonValue } from "../../../../dms-core/app/types/json";
|
|
2
|
+
import { isNumber, isString } from "../../../../dms-core/app/utils/type-check";
|
|
3
|
+
import { isJsonObject, type JsonObject } from "./json";
|
|
4
|
+
|
|
5
|
+
/** The query key prefix of a column filter: `filter_<field>=<mode>:<value>`. */
|
|
6
|
+
const FILTER_PREFIX = "filter_";
|
|
7
|
+
const LIST_SEPARATOR = ",";
|
|
8
|
+
const ISO_DAY = /^\d{4}-\d{2}-\d{2}/;
|
|
9
|
+
|
|
10
|
+
/** The keys a row's id is read from, in order. */
|
|
11
|
+
const ROW_ID_KEYS = ["_id", "id"] as const;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The row field a mockup table in archive mode reads a row's archived state
|
|
15
|
+
* from: the member `@ArchiveField` decorates in the DMS docs and playground.
|
|
16
|
+
*/
|
|
17
|
+
const ARCHIVE_FIELD = "isArchived";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One column filter of a list query, as a table sends it for a tab, a quick
|
|
21
|
+
* filter, a column filter or a saved view. A table repeats the key once per
|
|
22
|
+
* filter on a field, and a row must pass them all.
|
|
23
|
+
*/
|
|
24
|
+
export interface ColumnFilter {
|
|
25
|
+
field: string;
|
|
26
|
+
mode: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The list query a table sends its `fetchUrl`. */
|
|
31
|
+
export interface RowsQuery {
|
|
32
|
+
offset: number;
|
|
33
|
+
limit?: number;
|
|
34
|
+
/** Trimmed and lower-cased. */
|
|
35
|
+
search: string;
|
|
36
|
+
sortKey?: string;
|
|
37
|
+
sortDirection: "asc" | "desc";
|
|
38
|
+
/** Set by a table in archive mode: which side of the archive toggle it lists. */
|
|
39
|
+
showArchived?: boolean;
|
|
40
|
+
/** The values of the sorted field, in the order its groups are listed in. */
|
|
41
|
+
groupOrder?: GroupValue[];
|
|
42
|
+
filters: ColumnFilter[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A value a group order lists. */
|
|
46
|
+
type GroupValue = string | number | boolean;
|
|
47
|
+
|
|
48
|
+
function isGroupValue(value: unknown): value is GroupValue {
|
|
49
|
+
return (
|
|
50
|
+
typeof value === "string" ||
|
|
51
|
+
typeof value === "number" ||
|
|
52
|
+
typeof value === "boolean"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One page of rows, as `TableView.fromSource` reads it. */
|
|
57
|
+
export interface RowsPage {
|
|
58
|
+
results: JsonObject[];
|
|
59
|
+
total: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether a cell passes a filter's value. */
|
|
63
|
+
type Test = (cell: JsonValue | undefined, value: string) => boolean;
|
|
64
|
+
|
|
65
|
+
function isScalar(
|
|
66
|
+
cell: JsonValue | undefined,
|
|
67
|
+
): cell is string | number | boolean {
|
|
68
|
+
return (
|
|
69
|
+
typeof cell === "string" ||
|
|
70
|
+
typeof cell === "number" ||
|
|
71
|
+
typeof cell === "boolean"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The values a cell holds, as text: its scalar, or each scalar entry of a list. */
|
|
76
|
+
function cellTexts(cell: JsonValue | undefined): string[] {
|
|
77
|
+
if (Array.isArray(cell)) return cell.flatMap(cellTexts);
|
|
78
|
+
return isScalar(cell) ? [String(cell)] : [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isNumeric(text: string): boolean {
|
|
82
|
+
return text.trim() !== "" && Number.isFinite(Number(text));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Where `text` sits on a line: a number, or an ISO date as its epoch. */
|
|
86
|
+
function positionOf(text: string): number | undefined {
|
|
87
|
+
const trimmed = text.trim();
|
|
88
|
+
if (isNumeric(trimmed)) return Number(trimmed);
|
|
89
|
+
if (!ISO_DAY.test(trimmed)) return undefined;
|
|
90
|
+
const epoch = Date.parse(trimmed);
|
|
91
|
+
return Number.isNaN(epoch) ? undefined : epoch;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function sameValue(text: string, wanted: string): boolean {
|
|
95
|
+
if (text === wanted) return true;
|
|
96
|
+
return (
|
|
97
|
+
isNumeric(text) && isNumeric(wanted) && Number(text) === Number(wanted)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Whether the cell, or one of its entries, equals the value or one of its comma-separated values. */
|
|
102
|
+
function isAny(cell: JsonValue | undefined, value: string): boolean {
|
|
103
|
+
const wanted = [value, ...value.split(LIST_SEPARATOR)];
|
|
104
|
+
return cellTexts(cell).some((text) =>
|
|
105
|
+
wanted.some((candidate) => sameValue(text, candidate)),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function containsText(cell: JsonValue | undefined, value: string): boolean {
|
|
110
|
+
const needle = value.toLowerCase();
|
|
111
|
+
return cellTexts(cell).some((text) => text.toLowerCase().includes(needle));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The positions of the cell's values on a line; a value off the line has none. */
|
|
115
|
+
function positionsOf(cell: JsonValue | undefined): number[] {
|
|
116
|
+
return cellTexts(cell).flatMap((text) => {
|
|
117
|
+
const position = positionOf(text);
|
|
118
|
+
return position === undefined ? [] : [position];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function ordered(accept: (here: number, bound: number) => boolean): Test {
|
|
123
|
+
return (cell, value) => {
|
|
124
|
+
const bound = positionOf(value);
|
|
125
|
+
return (
|
|
126
|
+
bound !== undefined &&
|
|
127
|
+
positionsOf(cell).some((here) => accept(here, bound))
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isBetween(cell: JsonValue | undefined, value: string): boolean {
|
|
133
|
+
const bounds = value.split(LIST_SEPARATOR).map(positionOf);
|
|
134
|
+
const [low, high] = bounds;
|
|
135
|
+
if (bounds.length !== 2 || low === undefined || high === undefined) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return positionsOf(cell).some((here) => here >= low && here <= high);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isEmpty(cell: JsonValue | undefined): boolean {
|
|
142
|
+
return (
|
|
143
|
+
cell === undefined ||
|
|
144
|
+
cell === null ||
|
|
145
|
+
cell === "" ||
|
|
146
|
+
(Array.isArray(cell) && cell.length === 0)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The compare modes a table sends, as the DMS registers them
|
|
152
|
+
* (`DefaultDataCompareTypes`). `is` and `include` also read a quick filter's
|
|
153
|
+
* comma-separated values as any of them, and a list cell matches when one of
|
|
154
|
+
* its entries does.
|
|
155
|
+
*/
|
|
156
|
+
const MODES: ReadonlyMap<string, Test> = new Map<string, Test>([
|
|
157
|
+
["is", isAny],
|
|
158
|
+
["is_not", (cell, value) => !isAny(cell, value)],
|
|
159
|
+
["include", isAny],
|
|
160
|
+
["exclude", (cell, value) => !isAny(cell, value)],
|
|
161
|
+
["contains", containsText],
|
|
162
|
+
["not_contains", (cell, value) => !containsText(cell, value)],
|
|
163
|
+
["array_contains_string", containsText],
|
|
164
|
+
["greater_than", ordered((here, bound) => here > bound)],
|
|
165
|
+
["less_than", ordered((here, bound) => here < bound)],
|
|
166
|
+
["greater_than_or_equal_to", ordered((here, bound) => here >= bound)],
|
|
167
|
+
["less_than_or_equal_to", ordered((here, bound) => here <= bound)],
|
|
168
|
+
["is_between", isBetween],
|
|
169
|
+
["is_empty", isEmpty],
|
|
170
|
+
["is_not_empty", (cell) => !isEmpty(cell)],
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The column filters of a list query, in the order they were sent. A filter
|
|
175
|
+
* with no field, or of a mode no data controller has, is left out, so it
|
|
176
|
+
* keeps every row.
|
|
177
|
+
*/
|
|
178
|
+
function parseColumnFilters(params: URLSearchParams): ColumnFilter[] {
|
|
179
|
+
return [...params.entries()].flatMap(([key, raw]): ColumnFilter[] => {
|
|
180
|
+
if (!key.startsWith(FILTER_PREFIX) || key === FILTER_PREFIX) return [];
|
|
181
|
+
const separator = raw.indexOf(":");
|
|
182
|
+
const mode = separator < 0 ? raw : raw.slice(0, separator);
|
|
183
|
+
if (!MODES.has(mode)) return [];
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
field: key.slice(FILTER_PREFIX.length),
|
|
187
|
+
mode,
|
|
188
|
+
value: separator < 0 ? "" : raw.slice(separator + 1),
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function passesFilters(
|
|
195
|
+
row: JsonObject,
|
|
196
|
+
filters: readonly ColumnFilter[],
|
|
197
|
+
): boolean {
|
|
198
|
+
return filters.every(({ field, mode, value }) => {
|
|
199
|
+
const cell = Object.hasOwn(row, field) ? row[field] : undefined;
|
|
200
|
+
return MODES.get(mode)?.(cell, value) ?? true;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** `raw` as a whole number of at least `min`, or undefined when it is none. */
|
|
205
|
+
function integerAtLeast(raw: string | null, min: number): number | undefined {
|
|
206
|
+
if (raw === null) return undefined;
|
|
207
|
+
const value = Number(raw);
|
|
208
|
+
return Number.isInteger(value) && value >= min ? value : undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Reads a list query; a malformed parameter falls back to its default. */
|
|
212
|
+
export function parseRowsQuery(params: URLSearchParams): RowsQuery {
|
|
213
|
+
const showArchived = params.get("showArchived");
|
|
214
|
+
const query: RowsQuery = {
|
|
215
|
+
offset: integerAtLeast(params.get("offset"), 0) ?? 0,
|
|
216
|
+
search: (params.get("search") ?? "").trim().toLowerCase(),
|
|
217
|
+
sortDirection: params.get("sortDirection") === "desc" ? "desc" : "asc",
|
|
218
|
+
filters: parseColumnFilters(params),
|
|
219
|
+
};
|
|
220
|
+
const limit = integerAtLeast(params.get("limit"), 1);
|
|
221
|
+
if (limit !== undefined) query.limit = limit;
|
|
222
|
+
const sortKey = params.get("sortKey");
|
|
223
|
+
if (sortKey !== null) query.sortKey = sortKey;
|
|
224
|
+
if (showArchived === "true" || showArchived === "false") {
|
|
225
|
+
query.showArchived = showArchived === "true";
|
|
226
|
+
}
|
|
227
|
+
const groupOrder = readGroupOrder(params.get("groupOrder"));
|
|
228
|
+
if (groupOrder) query.groupOrder = groupOrder;
|
|
229
|
+
return query;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The most values a group order lists: the list route reads one group at a time. */
|
|
233
|
+
const MAX_GROUP_ORDER_VALUES = 50;
|
|
234
|
+
|
|
235
|
+
/** A list query's `groupOrder`, or undefined when it is no JSON list of 1 to {@link MAX_GROUP_ORDER_VALUES} scalars. */
|
|
236
|
+
function readGroupOrder(raw: string | null): GroupValue[] | undefined {
|
|
237
|
+
if (raw === null) return undefined;
|
|
238
|
+
try {
|
|
239
|
+
const parsed: unknown = JSON.parse(raw);
|
|
240
|
+
return Array.isArray(parsed) &&
|
|
241
|
+
parsed.length >= 1 &&
|
|
242
|
+
parsed.length <= MAX_GROUP_ORDER_VALUES &&
|
|
243
|
+
parsed.every(isGroupValue)
|
|
244
|
+
? parsed
|
|
245
|
+
: undefined;
|
|
246
|
+
} catch {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The rows of a fixture, or undefined when it is not an array of objects. */
|
|
252
|
+
export function parseRows(fixture: JsonValue): JsonObject[] | undefined {
|
|
253
|
+
return Array.isArray(fixture) && fixture.every(isJsonObject)
|
|
254
|
+
? fixture
|
|
255
|
+
: undefined;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** The id of `row` read at `key` when given, else its `_id`, else its `id`, as text. */
|
|
259
|
+
function rowIdAt(row: JsonObject, key?: string): string | undefined {
|
|
260
|
+
for (const field of key === undefined ? ROW_ID_KEYS : [key]) {
|
|
261
|
+
const value = Object.hasOwn(row, field) ? row[field] : undefined;
|
|
262
|
+
if (isString(value) || isNumber(value)) return String(value);
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** The row of `rows` whose id is `id`, read at `key` when given. */
|
|
268
|
+
export function findRow(
|
|
269
|
+
rows: readonly JsonObject[],
|
|
270
|
+
id: string,
|
|
271
|
+
key?: string,
|
|
272
|
+
): JsonObject | undefined {
|
|
273
|
+
return rows.find((row) => rowIdAt(row, key) === id);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** How many of `count` rows a fixture without an archive field gives as archived: a quarter, at least one, never all. */
|
|
277
|
+
function archivedCount(count: number): number {
|
|
278
|
+
return Math.min(Math.ceil(count / 4), count - 1);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The rows with their archived state at {@link ARCHIVE_FIELD}: as written when
|
|
283
|
+
* a row writes it, else made up, the last quarter of the rows archived, so a
|
|
284
|
+
* table in archive mode has rows on both sides of its toggle.
|
|
285
|
+
*/
|
|
286
|
+
function withArchiveField(rows: JsonObject[]): JsonObject[] {
|
|
287
|
+
if (rows.some((row) => Object.hasOwn(row, ARCHIVE_FIELD))) return rows;
|
|
288
|
+
const firstArchived = rows.length - archivedCount(rows.length);
|
|
289
|
+
return rows.map((row, index) => ({
|
|
290
|
+
...row,
|
|
291
|
+
[ARCHIVE_FIELD]: index >= firstArchived,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** The rows on one side of the archive toggle: the archived ones, or the others. */
|
|
296
|
+
function archiveSide(rows: JsonObject[], archived: boolean): JsonObject[] {
|
|
297
|
+
return withArchiveField(rows).filter(
|
|
298
|
+
(row) => (row[ARCHIVE_FIELD] === true) === archived,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Where a value sorts: numbers, and text that reads as one, by value; other
|
|
304
|
+
* text as people read it; anything else by its JSON text. Each class sorts
|
|
305
|
+
* before the next, so the order is total over mixed values.
|
|
306
|
+
*/
|
|
307
|
+
type SortKey =
|
|
308
|
+
| { rank: 0; value: number }
|
|
309
|
+
| { rank: 1; text: string }
|
|
310
|
+
| { rank: 2; text: string };
|
|
311
|
+
|
|
312
|
+
function sortKeyOf(value: JsonValue): SortKey {
|
|
313
|
+
if (isNumber(value)) return { rank: 0, value };
|
|
314
|
+
if (!isString(value)) return { rank: 2, text: JSON.stringify(value) };
|
|
315
|
+
const numeric = Number(value);
|
|
316
|
+
return value.trim() !== "" && Number.isFinite(numeric)
|
|
317
|
+
? { rank: 0, value: numeric }
|
|
318
|
+
: { rank: 1, text: value };
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const TEXT_ORDER = new Intl.Collator(undefined, {
|
|
322
|
+
numeric: true,
|
|
323
|
+
sensitivity: "base",
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
function compareValues(left: JsonValue, right: JsonValue): number {
|
|
327
|
+
const a = sortKeyOf(left);
|
|
328
|
+
const b = sortKeyOf(right);
|
|
329
|
+
if (a.rank !== b.rank) return a.rank - b.rank;
|
|
330
|
+
if (a.rank === 0 && b.rank === 0) return a.value - b.value;
|
|
331
|
+
if (a.rank !== 0 && b.rank !== 0) return TEXT_ORDER.compare(a.text, b.text);
|
|
332
|
+
return 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** Sorts in `direction`, rows missing the value last either way. */
|
|
336
|
+
function compareRows(
|
|
337
|
+
left: JsonValue | undefined,
|
|
338
|
+
right: JsonValue | undefined,
|
|
339
|
+
direction: number,
|
|
340
|
+
): number {
|
|
341
|
+
const leftMissing = left === undefined || left === null;
|
|
342
|
+
const rightMissing = right === undefined || right === null;
|
|
343
|
+
if (leftMissing || rightMissing) {
|
|
344
|
+
return Number(leftMissing) - Number(rightMissing);
|
|
345
|
+
}
|
|
346
|
+
return compareValues(left, right) * direction;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Where a value's group stands in a list query's `groupOrder`, reversed on a
|
|
351
|
+
* descending sort; a value it leaves out, or none, after every listed one.
|
|
352
|
+
*/
|
|
353
|
+
function groupRank(
|
|
354
|
+
order: RowsQuery["groupOrder"],
|
|
355
|
+
direction: number,
|
|
356
|
+
): (value: JsonValue | undefined) => number {
|
|
357
|
+
if (!order) return () => 0;
|
|
358
|
+
const listed = direction < 0 ? [...order].reverse() : order;
|
|
359
|
+
return (value) => {
|
|
360
|
+
const rank = listed.findIndex((entry) => entry === value);
|
|
361
|
+
return rank < 0 ? listed.length : rank;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Filters, searches, sorts and pages `rows` as the list query asks. A table in
|
|
367
|
+
* archive mode sends `showArchived`: it lists the archived rows, or the others,
|
|
368
|
+
* each row carrying its archived state.
|
|
369
|
+
*/
|
|
370
|
+
export function listRows(rows: JsonObject[], query: RowsQuery): RowsPage {
|
|
371
|
+
const sided =
|
|
372
|
+
query.showArchived === undefined
|
|
373
|
+
? rows
|
|
374
|
+
: archiveSide(rows, query.showArchived);
|
|
375
|
+
const found = sided.filter(
|
|
376
|
+
(row) =>
|
|
377
|
+
passesFilters(row, query.filters) &&
|
|
378
|
+
(!query.search ||
|
|
379
|
+
Object.values(row).some(
|
|
380
|
+
(value) =>
|
|
381
|
+
isScalar(value) &&
|
|
382
|
+
String(value).toLowerCase().includes(query.search),
|
|
383
|
+
)),
|
|
384
|
+
);
|
|
385
|
+
const { sortKey, groupOrder } = query;
|
|
386
|
+
if (sortKey) {
|
|
387
|
+
const direction = query.sortDirection === "desc" ? -1 : 1;
|
|
388
|
+
const valueOf = (row: JsonObject) =>
|
|
389
|
+
Object.hasOwn(row, sortKey) ? row[sortKey] : undefined;
|
|
390
|
+
const groupOf = groupRank(groupOrder, direction);
|
|
391
|
+
found.sort(
|
|
392
|
+
(a, b) =>
|
|
393
|
+
groupOf(valueOf(a)) - groupOf(valueOf(b)) ||
|
|
394
|
+
compareRows(valueOf(a), valueOf(b), direction),
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
const end =
|
|
398
|
+
query.limit === undefined ? undefined : query.offset + query.limit;
|
|
399
|
+
return { results: found.slice(query.offset, end), total: found.length };
|
|
400
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isObject, isString } from "../../../../dms-core/app/utils/type-check";
|
|
2
|
+
|
|
3
|
+
/** Whether `value` is a plain record: an object that is neither `null` nor a list. */
|
|
4
|
+
export function isRecord(
|
|
5
|
+
value: Parameters<typeof isObject>[0],
|
|
6
|
+
): value is Record<string, unknown> {
|
|
7
|
+
return isObject(value) && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Whether `value` is absent or a string. */
|
|
11
|
+
export function isOptionalString(
|
|
12
|
+
value: Parameters<typeof isString>[0],
|
|
13
|
+
): boolean {
|
|
14
|
+
return value === undefined || isString(value);
|
|
15
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { MenuItemStatus } from "#dms-core/app/types/menu";
|
|
2
|
+
import type { SiteLayoutTree } from "#dms-core/app/types/page";
|
|
3
|
+
import {
|
|
4
|
+
listCategoryPages,
|
|
5
|
+
listPagesAmong,
|
|
6
|
+
orderedChildren,
|
|
7
|
+
} from "./categoryPages";
|
|
8
|
+
|
|
9
|
+
/** The id of the settings root in the dashboard's menu. */
|
|
10
|
+
export const SETTINGS_ROOT_ID = "settings";
|
|
11
|
+
|
|
12
|
+
/** The icon of a settings page that declares none. */
|
|
13
|
+
export const DEFAULT_SETTINGS_ICON = "i-ph-gear-six";
|
|
14
|
+
|
|
15
|
+
export interface SettingsNavPage {
|
|
16
|
+
fullId: string;
|
|
17
|
+
label: string;
|
|
18
|
+
description: string;
|
|
19
|
+
icon: string;
|
|
20
|
+
to: string;
|
|
21
|
+
/** Badge the server counted or the page declared for its entry. */
|
|
22
|
+
badge?: string;
|
|
23
|
+
/** The tone of a counted badge; neutral when absent. */
|
|
24
|
+
badgeTone?: MenuItemBadgeTone;
|
|
25
|
+
/** Dot the page declared for its entry. */
|
|
26
|
+
status?: MenuItemStatus;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SettingsNavGroup {
|
|
30
|
+
id: string;
|
|
31
|
+
/** The category's display name, an i18n key (`$…`) or a literal. */
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
pages: SettingsNavPage[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const toNavPage = (node: SiteLayoutTree): SettingsNavPage => ({
|
|
38
|
+
fullId: node.fullId,
|
|
39
|
+
label: node.displayName,
|
|
40
|
+
description: node.description || "",
|
|
41
|
+
icon: node.icon || DEFAULT_SETTINGS_ICON,
|
|
42
|
+
to: node.fullSlug,
|
|
43
|
+
badge: node.badge,
|
|
44
|
+
badgeTone: node.badgeTone,
|
|
45
|
+
status: node.status,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function groupOf(
|
|
49
|
+
category: SiteLayoutTree,
|
|
50
|
+
pages: SiteLayoutTree[],
|
|
51
|
+
): SettingsNavGroup {
|
|
52
|
+
return {
|
|
53
|
+
id: category.fullId,
|
|
54
|
+
label: category.displayName,
|
|
55
|
+
description: category.description,
|
|
56
|
+
pages: pages.map(toNavPage),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The settings navigation's groups: one per category declared under the
|
|
62
|
+
* settings root, in menu order, then the pages declared on the root itself.
|
|
63
|
+
* Each lists the pages the viewer can open, in menu order.
|
|
64
|
+
*/
|
|
65
|
+
export function buildSettingsGroups(root: SiteLayoutTree): SettingsNavGroup[] {
|
|
66
|
+
const children = orderedChildren(root);
|
|
67
|
+
const groups = children
|
|
68
|
+
.filter((child) => !child.layoutUrl)
|
|
69
|
+
.map((category) => groupOf(category, listCategoryPages(category)));
|
|
70
|
+
const rootPages = children.filter((child) => child.layoutUrl);
|
|
71
|
+
groups.push(groupOf(root, listPagesAmong(rootPages, root.fullSlug)));
|
|
72
|
+
return groups.filter((group) => group.pages.length > 0);
|
|
73
|
+
}
|
|
@@ -1,14 +1,32 @@
|
|
|
1
|
+
import { ref, type Ref } from "vue";
|
|
1
2
|
import type { PreviewSketch } from "./blockPreview";
|
|
2
3
|
import { MOCKUP_VIEWER_PATH } from "./mockupLinks";
|
|
4
|
+
import { isString } from "../../../../dms-core/app/utils/type-check";
|
|
5
|
+
import { isRecord } from "./recordGuards";
|
|
6
|
+
|
|
7
|
+
/** The type of the message {@link SKETCH_LINK_RELAY} posts. */
|
|
8
|
+
const SKETCH_LINK_MESSAGE = "dms-sketch-link";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The one script a sketch frame runs, and only a sketch linking to a page of
|
|
12
|
+
* the mockup: a click on such a link posts its URL to the page holding the
|
|
13
|
+
* frame, which opens that page of the mockup ({@link sketchLinkHref}), in
|
|
14
|
+
* place of loading the whole dashboard again.
|
|
15
|
+
*/
|
|
16
|
+
export const SKETCH_LINK_RELAY = `document.addEventListener("click",function(e){var a=e.target instanceof Element&&e.target.closest("a[target=_top]");if(!a)return;e.preventDefault();parent.postMessage({type:"${SKETCH_LINK_MESSAGE}",href:a.href},"*")})`;
|
|
17
|
+
|
|
18
|
+
/** The CSP source of {@link SKETCH_LINK_RELAY}: its SHA-256, base64. */
|
|
19
|
+
export const SKETCH_LINK_RELAY_SOURCE =
|
|
20
|
+
"'sha256-6lqeH4ElBGXp0HTSjcu3IIz4LMoCGtwgjt4UkUBhX2I='";
|
|
3
21
|
|
|
4
22
|
/**
|
|
5
23
|
* How a sketch is drawn. The frame is the security boundary: a `sandbox`
|
|
6
|
-
* with
|
|
24
|
+
* with an opaque origin, no forms, popups or top navigation, and scripts
|
|
7
25
|
* only for a sketch linking to a page ({@link sketchSandbox}), and a CSP that
|
|
8
|
-
*
|
|
26
|
+
* runs no script but {@link SKETCH_LINK_RELAY} and loads nothing but inline
|
|
27
|
+
* styles and `data:` images and fonts.
|
|
9
28
|
*/
|
|
10
|
-
export const SKETCH_CSP =
|
|
11
|
-
"default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:";
|
|
29
|
+
export const SKETCH_CSP = `default-src 'none'; script-src ${SKETCH_LINK_RELAY_SOURCE}; style-src 'unsafe-inline'; img-src data:; font-src data:`;
|
|
12
30
|
|
|
13
31
|
/**
|
|
14
32
|
* A link to a page of the mockup as the compiler writes it in a sketch's
|
|
@@ -31,13 +49,22 @@ export interface SketchLinkContext {
|
|
|
31
49
|
|
|
32
50
|
/**
|
|
33
51
|
* The frame's `sandbox`: empty, except for a sketch linking to a page of the
|
|
34
|
-
* mockup, which
|
|
35
|
-
*
|
|
52
|
+
* mockup, which runs the scripts its CSP admits, {@link SKETCH_LINK_RELAY}
|
|
53
|
+
* alone. Never top navigation, never the dashboard's origin.
|
|
36
54
|
*/
|
|
37
55
|
export function sketchSandbox(html: string): string {
|
|
38
|
-
return HOLDS_PAGE_LINK.test(html)
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
return HOLDS_PAGE_LINK.test(html) ? "allow-scripts" : "";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The URL of the link a message of {@link SKETCH_LINK_RELAY} says was clicked. */
|
|
60
|
+
export function sketchLinkHref(
|
|
61
|
+
data: Parameters<typeof isRecord>[0],
|
|
62
|
+
): string | undefined {
|
|
63
|
+
return isRecord(data) &&
|
|
64
|
+
data.type === SKETCH_LINK_MESSAGE &&
|
|
65
|
+
isString(data.href)
|
|
66
|
+
? data.href
|
|
67
|
+
: undefined;
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
/**
|
|
@@ -185,13 +212,38 @@ export function computedStyleReader(element: Element): TokenReader {
|
|
|
185
212
|
return (variable) => style.getPropertyValue(variable);
|
|
186
213
|
}
|
|
187
214
|
|
|
188
|
-
/** The scheme
|
|
189
|
-
|
|
215
|
+
/** The scheme `<html>` carries now. */
|
|
216
|
+
function documentScheme(): SketchScheme {
|
|
190
217
|
return document.documentElement.classList.contains(DARK_THEME_CLASS)
|
|
191
218
|
? "dark"
|
|
192
219
|
: "light";
|
|
193
220
|
}
|
|
194
221
|
|
|
222
|
+
/** The scheme `<html>` carries, kept in step with its class once something reads it. */
|
|
223
|
+
let observedScheme: Ref<SketchScheme> | undefined;
|
|
224
|
+
|
|
225
|
+
function schemeSource(): Ref<SketchScheme> {
|
|
226
|
+
if (observedScheme) return observedScheme;
|
|
227
|
+
const scheme = ref(documentScheme());
|
|
228
|
+
new MutationObserver(() => {
|
|
229
|
+
scheme.value = documentScheme();
|
|
230
|
+
}).observe(document.documentElement, {
|
|
231
|
+
attributes: true,
|
|
232
|
+
attributeFilter: ["class"],
|
|
233
|
+
});
|
|
234
|
+
observedScheme = scheme;
|
|
235
|
+
return scheme;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* The scheme the dashboard shows now: its dark class on `<html>`, or light.
|
|
240
|
+
* Read in a computed, a watcher or a render function, it is a reactive source:
|
|
241
|
+
* they run again when the dashboard changes its color mode.
|
|
242
|
+
*/
|
|
243
|
+
export function currentSketchScheme(): SketchScheme {
|
|
244
|
+
return schemeSource().value;
|
|
245
|
+
}
|
|
246
|
+
|
|
195
247
|
/**
|
|
196
248
|
* The standalone document a sketch is drawn in. The CSP comes first in the
|
|
197
249
|
* head, before anything the sketch wrote, so no later markup can loosen it.
|
|
@@ -203,7 +255,8 @@ export function currentSketchScheme(): SketchScheme {
|
|
|
203
255
|
* `#anchor` resolve inside the frame's own `about:srcdoc` document, where a
|
|
204
256
|
* srcdoc document would otherwise resolve it against the dashboard's URL and
|
|
205
257
|
* load the dashboard into the frame. With `links`, the sketch's links to the
|
|
206
|
-
* pages of the mockup are drawn absolute ({@link resolveSketchLinks}).
|
|
258
|
+
* pages of the mockup are drawn absolute ({@link resolveSketchLinks}). A
|
|
259
|
+
* sketch holding such a link carries {@link SKETCH_LINK_RELAY}.
|
|
207
260
|
*/
|
|
208
261
|
export function buildSketchDocument(
|
|
209
262
|
sketch: PreviewSketch,
|
|
@@ -217,6 +270,9 @@ export function buildSketchDocument(
|
|
|
217
270
|
'<meta charset="utf-8">',
|
|
218
271
|
`<style>${tokensCss}\n${SKETCH_BASE_CSS}</style>`,
|
|
219
272
|
`<style>${sketch.css ?? ""}</style>`,
|
|
273
|
+
HOLDS_PAGE_LINK.test(sketch.html)
|
|
274
|
+
? `<script>${SKETCH_LINK_RELAY}</script>`
|
|
275
|
+
: "",
|
|
220
276
|
`</head><body>${links ? resolveSketchLinks(sketch.html, links) : sketch.html}</body></html>`,
|
|
221
277
|
].join("");
|
|
222
278
|
}
|
|
@@ -191,6 +191,21 @@ const ROW_KEY = String.raw`row\.[^{}\s]+`;
|
|
|
191
191
|
const ROW_TOKEN = tokenPattern(ROW_KEY);
|
|
192
192
|
const ROW_VALUE = new RegExp(`^${tokenPattern(ROW_KEY, "").source}$`);
|
|
193
193
|
|
|
194
|
+
const URL_TEMPLATE_START = new RegExp(
|
|
195
|
+
`^${tokenPattern(`(?:${ROW_KEY}|${PARAM_KEY}|${QUERY_KEY}|${RESPONSE_KEY})`, "").source}`,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Whether a URL opens with one of the tokens the dashboard fills where a URL
|
|
200
|
+
* is read: `{{row.X}}` from the row a table draws, `{{params.X}}` and
|
|
201
|
+
* `{{query.X}}` from the route, `{{response.X}}` from a response. Nothing
|
|
202
|
+
* literal comes before the token, so the block, not the template, decides
|
|
203
|
+
* where the URL points.
|
|
204
|
+
*/
|
|
205
|
+
export function startsWithUrlToken(url: string): boolean {
|
|
206
|
+
return URL_TEMPLATE_START.test(url);
|
|
207
|
+
}
|
|
208
|
+
|
|
194
209
|
/**
|
|
195
210
|
* A URL sent without a row (a bulk action on the selection bar) with its
|
|
196
211
|
* `{{row.X}}` tokens taken out as a link's unresolved page tokens are: a query
|