@medyll/idae-machine 0.135.2 → 0.136.1
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/LICENSE +21 -21
- package/README.md +555 -360
- package/cli.cjs +22 -0
- package/dist/__fixtures__/demoModel.d.ts +79 -0
- package/dist/__fixtures__/demoModel.js +146 -0
- package/dist/ai/frame/AiChatSession.svelte +152 -0
- package/dist/ai/frame/AiChatSession.svelte.d.ts +7 -0
- package/dist/ai/frame/index.d.ts +1 -0
- package/dist/ai/frame/index.js +2 -0
- package/dist/ai/index.d.ts +9 -0
- package/dist/ai/index.js +12 -0
- package/dist/ai/schema/ai-catalogs.d.ts +2 -0
- package/dist/ai/schema/ai-catalogs.js +86 -0
- package/dist/ai/schema/ai-chat-session.d.ts +2 -0
- package/dist/ai/schema/ai-chat-session.js +35 -0
- package/dist/ai/schema/ai-companion.d.ts +2 -0
- package/dist/ai/schema/ai-companion.js +25 -0
- package/dist/ai/schema/ai-message.d.ts +2 -0
- package/dist/ai/schema/ai-message.js +20 -0
- package/dist/ai/schema/ai-tool-call.d.ts +2 -0
- package/dist/ai/schema/ai-tool-call.js +18 -0
- package/dist/ai/schema/ai-user-prompt.d.ts +2 -0
- package/dist/ai/schema/ai-user-prompt.js +17 -0
- package/dist/ai/schema/tag.d.ts +2 -0
- package/dist/ai/schema/tag.js +14 -0
- package/dist/ai/streamIntoRecord.d.ts +31 -0
- package/dist/ai/streamIntoRecord.js +79 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +19 -0
- package/dist/data-ui/controls/AlphabetFilter.svelte +114 -0
- package/dist/data-ui/controls/AlphabetFilter.svelte.d.ts +10 -0
- package/dist/data-ui/controls/ButtonAction.svelte +151 -0
- package/dist/data-ui/controls/ButtonAction.svelte.d.ts +18 -0
- package/dist/data-ui/controls/DataFind.svelte +174 -0
- package/dist/data-ui/controls/DataFind.svelte.d.ts +10 -0
- package/dist/data-ui/controls/DataGroup.svelte +150 -0
- package/dist/data-ui/controls/DataGroup.svelte.d.ts +7 -0
- package/dist/data-ui/controls/DataSort.svelte +78 -0
- package/dist/data-ui/controls/DataSort.svelte.d.ts +9 -0
- package/dist/data-ui/controls/DataToolbar.svelte +67 -0
- package/dist/data-ui/controls/DataToolbar.svelte.d.ts +11 -0
- package/dist/data-ui/controls/Find.svelte +38 -0
- package/dist/data-ui/controls/Find.svelte.d.ts +9 -0
- package/dist/data-ui/controls/FkFilter.svelte +94 -0
- package/dist/data-ui/controls/FkFilter.svelte.d.ts +11 -0
- package/dist/data-ui/controls/Group.svelte +36 -0
- package/dist/data-ui/controls/Group.svelte.d.ts +8 -0
- package/dist/data-ui/controls/ListMode.svelte +79 -0
- package/dist/data-ui/controls/ListMode.svelte.d.ts +10 -0
- package/dist/data-ui/controls/Sort.svelte +100 -0
- package/dist/data-ui/controls/Sort.svelte.d.ts +8 -0
- package/dist/data-ui/data/DataCount.svelte +67 -0
- package/dist/data-ui/data/DataCount.svelte.d.ts +36 -0
- package/dist/data-ui/data/DataFk.svelte +54 -0
- package/dist/data-ui/data/DataFk.svelte.d.ts +11 -0
- package/dist/data-ui/data/DataForm.svelte +191 -0
- package/dist/data-ui/data/DataForm.svelte.d.ts +15 -0
- package/dist/data-ui/data/DataList.svelte +645 -0
- package/dist/data-ui/data/DataList.svelte.d.ts +75 -0
- package/dist/data-ui/data/DataListFk.svelte +111 -0
- package/dist/data-ui/data/DataListFk.svelte.d.ts +13 -0
- package/dist/data-ui/data/DataListRfk.svelte +111 -0
- package/dist/data-ui/data/DataListRfk.svelte.d.ts +13 -0
- package/dist/data-ui/data/DataRecord.svelte +167 -0
- package/dist/data-ui/data/DataRecord.svelte.d.ts +22 -0
- package/dist/data-ui/data/DataRfk.svelte +73 -0
- package/dist/data-ui/data/DataRfk.svelte.d.ts +15 -0
- package/dist/data-ui/data/index.d.ts +7 -0
- package/dist/data-ui/data/index.js +8 -0
- package/dist/data-ui/field/DataField.svelte +343 -0
- package/dist/data-ui/field/DataField.svelte.d.ts +33 -0
- package/dist/{form/FieldInPlace.svelte → data-ui/field/DataFieldEdit.svelte} +103 -98
- package/dist/{form/FieldInPlace.svelte.d.ts → data-ui/field/DataFieldEdit.svelte.d.ts} +5 -5
- package/dist/data-ui/field/index.d.ts +2 -0
- package/dist/data-ui/field/index.js +3 -0
- package/dist/data-ui/field/snippets/FieldAiPrompt.svelte +145 -0
- package/dist/data-ui/field/snippets/FieldAiPrompt.svelte.d.ts +14 -0
- package/dist/data-ui/field/snippets/FieldBoolean.svelte +43 -0
- package/dist/data-ui/field/snippets/FieldBoolean.svelte.d.ts +12 -0
- package/dist/data-ui/field/snippets/FieldColor.svelte +48 -0
- package/dist/data-ui/field/snippets/FieldColor.svelte.d.ts +10 -0
- package/dist/data-ui/field/snippets/FieldCurrency.svelte +105 -0
- package/dist/data-ui/field/snippets/FieldCurrency.svelte.d.ts +15 -0
- package/dist/data-ui/field/snippets/FieldEmail.svelte +77 -0
- package/dist/data-ui/field/snippets/FieldEmail.svelte.d.ts +14 -0
- package/dist/data-ui/field/snippets/FieldIcon.svelte +73 -0
- package/dist/data-ui/field/snippets/FieldIcon.svelte.d.ts +11 -0
- package/dist/data-ui/field/snippets/FieldSelect.svelte +71 -0
- package/dist/data-ui/field/snippets/FieldSelect.svelte.d.ts +15 -0
- package/dist/data-ui/field/snippets/FieldText.svelte +52 -0
- package/dist/data-ui/field/snippets/FieldText.svelte.d.ts +13 -0
- package/dist/data-ui/field/snippets/FieldTextarea.svelte +50 -0
- package/dist/data-ui/field/snippets/FieldTextarea.svelte.d.ts +13 -0
- package/dist/data-ui/field/snippets/index.d.ts +9 -0
- package/dist/data-ui/field/snippets/index.js +10 -0
- package/dist/data-ui/fragments/ContextMenu.svelte +109 -0
- package/dist/data-ui/fragments/ContextMenu.svelte.d.ts +4 -0
- package/dist/data-ui/fragments/ContextMenuContent.svelte +275 -0
- package/dist/data-ui/fragments/ContextMenuContent.svelte.d.ts +8 -0
- package/dist/data-ui/fragments/Frame.svelte +43 -0
- package/dist/data-ui/fragments/Frame.svelte.d.ts +10 -0
- package/dist/data-ui/fragments/InfoLine.svelte +123 -0
- package/dist/data-ui/fragments/InfoLine.svelte.d.ts +12 -0
- package/dist/data-ui/fragments/Selector.svelte +56 -0
- package/dist/data-ui/fragments/Selector.svelte.d.ts +10 -0
- package/dist/{fragments → data-ui/fragments}/Skeleton.svelte +21 -21
- package/dist/data-ui/fragments/Tile.svelte +126 -0
- package/dist/data-ui/fragments/Tile.svelte.d.ts +14 -0
- package/dist/data-ui/fragments/contextMenu.svelte.d.ts +22 -0
- package/dist/data-ui/fragments/contextMenu.svelte.js +31 -0
- package/dist/data-ui/fragments/dialog/Dialog.svelte +185 -0
- package/dist/data-ui/fragments/dialog/Dialog.svelte.d.ts +29 -0
- package/dist/data-ui/fragments/dialog/dialog.svelte.d.ts +27 -0
- package/dist/data-ui/fragments/dialog/dialog.svelte.js +41 -0
- package/dist/data-ui/fragments/index.d.ts +11 -0
- package/dist/data-ui/fragments/index.js +11 -0
- package/dist/data-ui/utils/__tests__/HostProbe.svelte +18 -0
- package/dist/data-ui/utils/__tests__/HostProbe.svelte.d.ts +8 -0
- package/dist/data-ui/utils/data-utils.d.ts +29 -0
- package/dist/data-ui/utils/data-utils.js +83 -0
- package/dist/data-ui/utils/dataRelationUtils.d.ts +37 -0
- package/dist/data-ui/utils/dataRelationUtils.js +125 -0
- package/dist/data-ui/utils/diagramUtils.d.ts +6 -0
- package/dist/data-ui/utils/diagramUtils.js +131 -0
- package/dist/data-ui/utils/draggable.d.ts +15 -0
- package/dist/data-ui/utils/draggable.js +61 -0
- package/dist/data-ui/utils/menuPrefs.d.ts +80 -0
- package/dist/data-ui/utils/menuPrefs.js +119 -0
- package/dist/data-ui/utils/useMachinePrefs.svelte.d.ts +38 -0
- package/dist/data-ui/utils/useMachinePrefs.svelte.js +117 -0
- package/dist/data-ui/utils/useMenuTree.svelte.d.ts +26 -0
- package/dist/data-ui/utils/useMenuTree.svelte.js +68 -0
- package/dist/data-ui/utils/useRecordData.svelte.d.ts +22 -0
- package/dist/data-ui/utils/useRecordData.svelte.js +50 -0
- package/dist/data-ui/utils/useViewFields.svelte.d.ts +22 -0
- package/dist/data-ui/utils/useViewFields.svelte.js +59 -0
- package/dist/demo/.gitkeep +0 -0
- package/dist/demo/demo-status.json +9 -0
- package/dist/idae/boot.d.ts +28 -0
- package/dist/idae/boot.js +43 -0
- package/dist/idae/bridge/register.d.ts +4 -0
- package/dist/idae/bridge/register.js +15 -0
- package/dist/idae/capabilities/Capabilities.d.ts +10 -0
- package/dist/idae/capabilities/Capabilities.js +34 -0
- package/dist/idae/codefield/CodeFieldConvention.d.ts +3 -0
- package/dist/idae/codefield/CodeFieldConvention.js +25 -0
- package/dist/idae/fieldcatalog/defaultFieldTypesDef.d.ts +2 -0
- package/dist/idae/fieldcatalog/defaultFieldTypesDef.js +104 -0
- package/dist/idae/frames/FrameCatalog.d.ts +31 -0
- package/dist/idae/frames/FrameCatalog.js +31 -0
- package/dist/idae/index.d.ts +14 -0
- package/dist/idae/index.js +13 -0
- package/dist/idae/menu/IdaeMenuManager.d.ts +79 -0
- package/dist/idae/menu/IdaeMenuManager.js +108 -0
- package/dist/idae/menu/IdaeMenuStore.d.ts +77 -0
- package/dist/idae/menu/IdaeMenuStore.js +68 -0
- package/dist/idae/menu/menuSnapshot.d.ts +30 -0
- package/dist/idae/menu/menuSnapshot.js +30 -0
- package/dist/idae/meta/MetaModelProvider.d.ts +11 -0
- package/dist/idae/meta/MetaModelProvider.js +43 -0
- package/dist/idae/relations/RelationPolicy.d.ts +19 -0
- package/dist/idae/relations/RelationPolicy.js +125 -0
- package/dist/idae/rights/RightsPolicy.d.ts +16 -0
- package/dist/idae/rights/RightsPolicy.js +80 -0
- package/dist/idae/userscope/UserScopePolicy.d.ts +9 -0
- package/dist/idae/userscope/UserScopePolicy.js +42 -0
- package/dist/idae/userscope/navTracking.d.ts +11 -0
- package/dist/idae/userscope/navTracking.js +15 -0
- package/dist/index.d.ts +68 -35
- package/dist/index.js +82 -36
- package/dist/main/__tests__/_relationTestUtils.d.ts +12 -0
- package/dist/main/__tests__/_relationTestUtils.js +53 -0
- package/dist/main/__tests__/helpers/mockCollection.d.ts +21 -0
- package/dist/main/__tests__/helpers/mockCollection.js +27 -0
- package/dist/main/api/types.d.ts +29 -0
- package/dist/main/ext/hooks.d.ts +32 -0
- package/dist/main/ext/hooks.js +31 -0
- package/dist/main/ext/interfaces.d.ts +69 -0
- package/dist/main/ext/interfaces.js +3 -0
- package/dist/main/ext/registry.d.ts +29 -0
- package/dist/main/ext/registry.js +30 -0
- package/dist/main/frame/MachineFrameManager.d.ts +187 -0
- package/dist/main/frame/MachineFrameManager.js +403 -0
- package/dist/main/frame/contextMenuSetup.d.ts +9 -0
- package/dist/main/frame/contextMenuSetup.js +42 -0
- package/dist/main/frame/frameUrl.d.ts +1 -0
- package/dist/main/frame/frameUrl.js +8 -0
- package/dist/main/frame/frameUtils.d.ts +16 -0
- package/dist/main/frame/frameUtils.js +26 -0
- package/dist/main/frame/linkParser.d.ts +9 -0
- package/dist/main/frame/linkParser.js +15 -0
- package/dist/main/index.d.ts +15 -0
- package/dist/main/index.js +19 -0
- package/dist/main/machine/MachineAction.d.ts +62 -0
- package/dist/main/machine/MachineAction.js +96 -0
- package/dist/main/machine/MachineError.js +2 -2
- package/dist/main/machine/MachineFieldType.d.ts +25 -6
- package/dist/main/machine/MachineFieldType.js +118 -27
- package/dist/main/machine/MachineFkFold.d.ts +34 -0
- package/dist/main/machine/MachineFkFold.js +57 -0
- package/dist/main/machine/MachineRecordIdentity.d.ts +26 -0
- package/dist/main/machine/MachineRecordIdentity.js +44 -0
- package/dist/main/machine/MachineRights.d.ts +50 -0
- package/dist/main/machine/MachineRights.js +133 -0
- package/dist/main/machine/MachineRouter.d.ts +56 -0
- package/dist/main/machine/MachineRouter.js +250 -0
- package/dist/main/machine/MachineScheme.d.ts +40 -70
- package/dist/main/machine/MachineScheme.js +107 -94
- package/dist/main/machine/MachineSchemeField.js +32 -16
- package/dist/main/machine/MachineSchemeFieldForge.d.ts +11 -11
- package/dist/main/machine/MachineSchemeFieldForge.js +33 -21
- package/dist/main/machine/MachineSchemeFieldValues.d.ts +8 -9
- package/dist/main/machine/MachineSchemeFieldValues.js +12 -9
- package/dist/main/machine/MachineSchemeValidate.d.ts +69 -13
- package/dist/main/machine/MachineSchemeValidate.js +173 -46
- package/dist/main/machine/MachineSchemeValues.d.ts +32 -21
- package/dist/main/machine/MachineSchemeValues.js +132 -104
- package/dist/main/machine/SchemeFieldDefaultValues.d.ts +4 -2
- package/dist/main/machine/SchemeFieldDefaultValues.js +8 -2
- package/dist/main/machine/authState.svelte.d.ts +11 -0
- package/dist/main/machine/authState.svelte.js +17 -0
- package/dist/main/machine/fieldBuilder.d.ts +23 -0
- package/dist/main/machine/fieldBuilder.d.ts.map +1 -0
- package/dist/main/machine/fieldBuilder.js +10 -0
- package/dist/main/machine/fieldBuilder.js.map +1 -0
- package/dist/main/machine/machineLabel.d.ts +11 -0
- package/dist/main/machine/machineLabel.js +23 -0
- package/dist/main/machine/validateRules.d.ts +38 -0
- package/dist/main/machine/validateRules.js +109 -0
- package/dist/main/machine.d.ts +207 -68
- package/dist/main/machine.js +482 -96
- package/dist/main/machineDb.d.ts +21 -8
- package/dist/main/machineDb.js +33 -4
- package/dist/main/machineIdbAdapter.d.ts +83 -0
- package/dist/main/machineIdbAdapter.js +347 -0
- package/dist/main/machineModelBuilder.d.ts +31 -0
- package/dist/main/machineModelBuilder.js +58 -0
- package/dist/main/machineParserForge.d.ts +9 -18
- package/dist/main/machineParserForge.js +92 -35
- package/dist/main/machineSchemaCache.d.ts +8 -0
- package/dist/main/machineSchemaCache.js +58 -0
- package/dist/main/machineSchemaDoctor.d.ts +17 -0
- package/dist/main/machineSchemaDoctor.js +73 -0
- package/dist/main/machineSchemaLoader.d.ts +18 -0
- package/dist/main/machineSchemaLoader.js +43 -0
- package/dist/main/machineSeed.d.ts +21 -0
- package/dist/main/machineSeed.js +44 -0
- package/dist/main/router/componentRegistry.d.ts +35 -0
- package/dist/main/router/componentRegistry.js +35 -0
- package/dist/main/router/urlParser.d.ts +17 -0
- package/dist/main/router/urlParser.js +41 -0
- package/dist/main/warmupUtils.d.ts +40 -0
- package/dist/main/warmupUtils.js +73 -0
- package/dist/mcp/MachineMcpClient.d.ts +43 -0
- package/dist/mcp/MachineMcpClient.js +175 -0
- package/dist/shell/Frame.svelte +67 -0
- package/dist/shell/Frame.svelte.d.ts +11 -0
- package/dist/shell/auth/Login.svelte +244 -0
- package/dist/shell/auth/Login.svelte.d.ts +3 -0
- package/dist/shell/frame/dashboard/Dashboard.svelte +0 -0
- package/dist/shell/frame/dashboard/Dashboard.svelte.d.ts +26 -0
- package/dist/shell/frame/diagram/Diagram.svelte +244 -0
- package/dist/shell/frame/diagram/Diagram.svelte.d.ts +9 -0
- package/dist/shell/frame/explorer/Explorer.svelte +86 -0
- package/dist/shell/frame/explorer/Explorer.svelte.d.ts +29 -0
- package/dist/shell/frame/explorer/ExplorerContent.svelte +126 -0
- package/dist/shell/frame/explorer/ExplorerContent.svelte.d.ts +32 -0
- package/dist/shell/frame/index.d.ts +8 -0
- package/dist/shell/frame/index.js +9 -0
- package/dist/shell/frame/main-menu-content/MainMenuContent.svelte +100 -0
- package/dist/shell/frame/main-menu-content/MainMenuContent.svelte.d.ts +6 -0
- package/dist/shell/frame/planning/Planning.svelte +426 -0
- package/dist/shell/frame/planning/Planning.svelte.d.ts +12 -0
- package/dist/shell/frame/rbac/RbacMatrix.svelte +197 -0
- package/dist/shell/frame/rbac/RbacMatrix.svelte.d.ts +7 -0
- package/dist/shell/frame/space/Space.svelte +554 -0
- package/dist/shell/frame/space/Space.svelte.d.ts +8 -0
- package/dist/shell/frame/synthesis/Synthesis.svelte +383 -0
- package/dist/shell/frame/synthesis/Synthesis.svelte.d.ts +8 -0
- package/dist/shell/frame/today/Today.svelte +174 -0
- package/dist/shell/frame/today/Today.svelte.d.ts +3 -0
- package/dist/shell/layout/App.svelte +30 -0
- package/dist/shell/layout/App.svelte.d.ts +3 -0
- package/dist/shell/layout/Breadcrumb.svelte +67 -0
- package/dist/shell/layout/Breadcrumb.svelte.d.ts +12 -0
- package/dist/shell/layout/Columner.svelte +214 -0
- package/dist/shell/layout/Columner.svelte.d.ts +16 -0
- package/dist/shell/layout/DevResetPanel.svelte +194 -0
- package/dist/shell/layout/DevResetPanel.svelte.d.ts +7 -0
- package/dist/shell/layout/Fiche.svelte +111 -0
- package/dist/shell/layout/Fiche.svelte.d.ts +7 -0
- package/dist/shell/layout/FicheUpdate.svelte +53 -0
- package/dist/shell/layout/FicheUpdate.svelte.d.ts +7 -0
- package/dist/shell/layout/MainMenu.svelte +256 -0
- package/dist/shell/layout/MainMenu.svelte.d.ts +6 -0
- package/dist/shell/layout/MenuSettings.svelte +182 -0
- package/dist/shell/layout/MenuSettings.svelte.d.ts +6 -0
- package/dist/shell/layout/RecordTimeline.svelte +199 -0
- package/dist/shell/layout/RecordTimeline.svelte.d.ts +8 -0
- package/dist/shell/layout/RecordToolbar.svelte +39 -0
- package/dist/shell/layout/RecordToolbar.svelte.d.ts +7 -0
- package/dist/shell/layout/TaskBar.svelte +118 -0
- package/dist/shell/layout/TaskBar.svelte.d.ts +7 -0
- package/dist/shell/layout/TemplateShell.svelte +48 -0
- package/dist/shell/layout/TemplateShell.svelte.d.ts +15 -0
- package/dist/shell/layout/ThemeToggle.svelte +46 -0
- package/dist/shell/layout/ThemeToggle.svelte.d.ts +3 -0
- package/dist/shell/layout/index.d.ts +8 -0
- package/dist/shell/layout/index.js +9 -0
- package/dist/storage/ApiStorageAdapter.d.ts +41 -0
- package/dist/storage/ApiStorageAdapter.js +111 -0
- package/dist/storage/IdbStorageAdapter.d.ts +31 -0
- package/dist/storage/IdbStorageAdapter.js +72 -0
- package/dist/storage/MemoryStorageAdapter.d.ts +33 -0
- package/dist/storage/MemoryStorageAdapter.js +132 -0
- package/dist/storage/README.md +222 -0
- package/dist/storage/StorageAdapter.d.ts +75 -0
- package/dist/storage/StorageAdapter.js +7 -0
- package/dist/storage/demo/storage-demo.d.ts +22 -0
- package/dist/storage/demo/storage-demo.js +107 -0
- package/dist/storage/index.d.ts +9 -0
- package/dist/storage/index.js +9 -0
- package/dist/types/entity-types.d.ts +444 -0
- package/dist/types/entity-types.js +16 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +6 -0
- package/dist/types/machine-model.d.ts +198 -0
- package/dist/types/machine-model.js +5 -0
- package/dist/types/qoolie-svelte.d.ts +11 -0
- package/dist/types/schema-utils.d.ts +32 -0
- package/dist/types/schema-utils.js +103 -0
- package/dist/utils/generateCode.d.ts +5 -0
- package/dist/utils/generateCode.js +9 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +20 -0
- package/package.json +59 -33
- package/cli.js +0 -46
- package/dist/db/CrudService.d.ts +0 -9
- package/dist/db/CrudService.js +0 -45
- package/dist/demo/dbSchema.d.ts +0 -446
- package/dist/demo/dbSchema.js +0 -449
- package/dist/demo/testScheme.d.ts +0 -56
- package/dist/demo/testScheme.js +0 -42
- package/dist/form/CreateUpdate.svelte +0 -219
- package/dist/form/CreateUpdate.svelte.d.ts +0 -27
- package/dist/form/DataProvider.svelte +0 -23
- package/dist/form/DataProvider.svelte.d.ts +0 -7
- package/dist/form/FieldValue.svelte +0 -148
- package/dist/form/FieldValue.svelte.d.ts +0 -34
- package/dist/form/types.d.ts +0 -17
- package/dist/fragments/Confirm.svelte +0 -73
- package/dist/fragments/Confirm.svelte.d.ts +0 -7
- package/dist/fragments/Frame.svelte +0 -19
- package/dist/fragments/Frame.svelte.d.ts +0 -32
- package/dist/fragments/InfoLine.svelte +0 -21
- package/dist/fragments/InfoLine.svelte.d.ts +0 -35
- package/dist/fragments/Selector.svelte +0 -26
- package/dist/fragments/Selector.svelte.d.ts +0 -38
- package/dist/main/machine/MachineSchemeField.d.ts +0 -19
- package/dist/types/appschemeTypes.d.ts +0 -71
- package/dist/types/appschemeTypes.js +0 -83
- package/dist/ui/CollectionButton.svelte +0 -29
- package/dist/ui/CollectionButton.svelte.d.ts +0 -29
- package/dist/ui/CollectionFks.svelte +0 -24
- package/dist/ui/CollectionFks.svelte.d.ts +0 -9
- package/dist/ui/CollectionList.svelte +0 -100
- package/dist/ui/CollectionList.svelte.d.ts +0 -36
- package/dist/ui/CollectionListFieldValues.svelte +0 -59
- package/dist/ui/CollectionListFieldValues.svelte.d.ts +0 -9
- package/dist/ui/CollectionListMenu.svelte +0 -39
- package/dist/ui/CollectionListMenu.svelte.d.ts +0 -34
- package/dist/ui/CollectionReverseFks.svelte +0 -37
- package/dist/ui/CollectionReverseFks.svelte.d.ts +0 -14
- /package/dist/{fragments → data-ui/fragments}/Skeleton.svelte.d.ts +0 -0
- /package/dist/{form → main/api}/types.js +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { getGrantDecoder } from '../ext/hooks.js';
|
|
2
|
+
const ALL_OPS = ['C', 'R', 'U', 'D', 'L', 'X'];
|
|
3
|
+
export class MachineRights {
|
|
4
|
+
#currentUser = null;
|
|
5
|
+
#grants = [];
|
|
6
|
+
#menuBaseline = {};
|
|
7
|
+
#authEnabled = false;
|
|
8
|
+
#policies = {};
|
|
9
|
+
/**
|
|
10
|
+
* Load structural rights policies from the MachineModel.
|
|
11
|
+
* Call once at Machine.boot() — after model is resolved.
|
|
12
|
+
*/
|
|
13
|
+
setPolicies(policies) {
|
|
14
|
+
this.#policies = policies;
|
|
15
|
+
}
|
|
16
|
+
/** Extract and load rights policies directly from a MachineModel. */
|
|
17
|
+
loadPoliciesFromModel(model) {
|
|
18
|
+
if (!model)
|
|
19
|
+
return;
|
|
20
|
+
const policies = {};
|
|
21
|
+
for (const [name, col] of Object.entries(model)) {
|
|
22
|
+
if ('rights' in col && col.rights)
|
|
23
|
+
policies[name] = col.rights;
|
|
24
|
+
}
|
|
25
|
+
this.setPolicies(policies);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Enable auth and set the current user + their grants.
|
|
29
|
+
* Once called, open mode is disabled — all access goes through checkAccess().
|
|
30
|
+
*/
|
|
31
|
+
setCurrentUser(user, grants = [], menuBaseline = {}) {
|
|
32
|
+
this.#authEnabled = true;
|
|
33
|
+
this.#currentUser = user;
|
|
34
|
+
this.#grants = grants;
|
|
35
|
+
this.#menuBaseline = menuBaseline;
|
|
36
|
+
}
|
|
37
|
+
/** Disable auth and return to open mode (all access allowed). */
|
|
38
|
+
clearCurrentUser() {
|
|
39
|
+
this.#authEnabled = false;
|
|
40
|
+
this.#currentUser = null;
|
|
41
|
+
this.#grants = [];
|
|
42
|
+
this.#menuBaseline = {};
|
|
43
|
+
}
|
|
44
|
+
get currentUser() {
|
|
45
|
+
return this.#currentUser;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Role-derived menu visibility baseline (scopeKey → bool), resolved server-side at
|
|
49
|
+
* login by OR-ing the user's role presets. The menu reads `override ?? baseline ??
|
|
50
|
+
* false`; role codes are never exposed client-side — only this flat effect.
|
|
51
|
+
*/
|
|
52
|
+
get menuBaseline() {
|
|
53
|
+
return this.#menuBaseline;
|
|
54
|
+
}
|
|
55
|
+
get isAuthEnabled() {
|
|
56
|
+
return this.#authEnabled;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if the current user has access to perform `operation` on `collection`.
|
|
60
|
+
*
|
|
61
|
+
* Resolution order:
|
|
62
|
+
* 1. `ops` policy blocks the operation → deny (structural, absolute)
|
|
63
|
+
* 2. Auth not initialized → allow (open mode, dev/test)
|
|
64
|
+
* 3. `public` policy includes the operation → allow (no auth required)
|
|
65
|
+
* 4. No user → deny
|
|
66
|
+
* 5. User inactive or locked → deny
|
|
67
|
+
* 6. appPermissions.ADMIN → allow all (within ops)
|
|
68
|
+
* 7. Explicit grant (temporal + collection scoped) → respected
|
|
69
|
+
* 8. `default` policy includes the operation → allow (authenticated fallback)
|
|
70
|
+
* 9. Deny
|
|
71
|
+
*/
|
|
72
|
+
checkAccess(collection, operation = 'R') {
|
|
73
|
+
const policy = this.#policies[collection];
|
|
74
|
+
// 1. Structural ops whitelist — hard deny regardless of user/grants
|
|
75
|
+
const allowedOps = policy?.ops ?? ALL_OPS;
|
|
76
|
+
if (!allowedOps.includes(operation))
|
|
77
|
+
return false;
|
|
78
|
+
// 2. Open mode (auth not initialized)
|
|
79
|
+
if (!this.#authEnabled)
|
|
80
|
+
return true;
|
|
81
|
+
// 3. Public access
|
|
82
|
+
if (policy?.public?.includes(operation))
|
|
83
|
+
return true;
|
|
84
|
+
// 4–5. User checks
|
|
85
|
+
if (!this.#currentUser)
|
|
86
|
+
return false;
|
|
87
|
+
if (!this.#currentUser.isActive || this.#currentUser.isLocked)
|
|
88
|
+
return false;
|
|
89
|
+
// 6. Admin override
|
|
90
|
+
if (this.#currentUser.appPermissions?.ADMIN)
|
|
91
|
+
return true;
|
|
92
|
+
// 7. Explicit grants
|
|
93
|
+
const permField = operation.toLowerCase();
|
|
94
|
+
const now = new Date();
|
|
95
|
+
const granted = this.#grants.some(grant => {
|
|
96
|
+
if (grant.revokedAt)
|
|
97
|
+
return false;
|
|
98
|
+
if (grant.validFrom && new Date(grant.validFrom) > now)
|
|
99
|
+
return false;
|
|
100
|
+
if (grant.validUntil && new Date(grant.validUntil) < now)
|
|
101
|
+
return false;
|
|
102
|
+
const decoder = getGrantDecoder();
|
|
103
|
+
const schemeCode = decoder
|
|
104
|
+
? decoder.decodeSchemeCode(grant)
|
|
105
|
+
: undefined;
|
|
106
|
+
if (schemeCode && schemeCode !== collection && schemeCode !== '*')
|
|
107
|
+
return false;
|
|
108
|
+
return grant[permField] === true;
|
|
109
|
+
});
|
|
110
|
+
if (granted)
|
|
111
|
+
return true;
|
|
112
|
+
// 8. Default policy for authenticated users
|
|
113
|
+
if (policy?.default?.includes(operation))
|
|
114
|
+
return true;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Enumerate all collections the current user has access to for the given operation.
|
|
119
|
+
* Returns an array of collection names where checkAccess(collection, op) returns true.
|
|
120
|
+
* Used by menu generators and UI components that need to filter collections by rights.
|
|
121
|
+
*/
|
|
122
|
+
allowedCollections(operation = 'R') {
|
|
123
|
+
const result = [];
|
|
124
|
+
for (const [name] of Object.entries(this.#policies)) {
|
|
125
|
+
if (this.checkAccess(name, operation)) {
|
|
126
|
+
result.push(name);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export const machineRights = new MachineRights();
|
|
133
|
+
export default machineRights;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type DialogNavigationEvent, type NavigationEvent } from '../frame/MachineFrameManager.js';
|
|
2
|
+
export interface MachineRouterConfig {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
/** Enable auth guard. When true, non-public routes redirect to loginRoute if no token. */
|
|
5
|
+
authEnabled?: boolean;
|
|
6
|
+
loginRoute?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* MachineRouter — thin URL dispatcher on top of idae-router.
|
|
10
|
+
*
|
|
11
|
+
* Sole responsibility: catch hash URLs of shape `/+zone/modulePath/collection[/id][?vars]`
|
|
12
|
+
* and delegate to machineFrameManager (which loads existing Frame or mounts a new one).
|
|
13
|
+
*
|
|
14
|
+
* Auth guard is kept but disabled by default — enable via `authEnabled: true` when wiring login.
|
|
15
|
+
*
|
|
16
|
+
* RBAC is NOT here:
|
|
17
|
+
* - Server enforces via `requireDroit` middleware (authoritative).
|
|
18
|
+
* - UI hints via `machineRights.checkAccess` (display layer).
|
|
19
|
+
*/
|
|
20
|
+
export declare class MachineRouter {
|
|
21
|
+
private router;
|
|
22
|
+
private config;
|
|
23
|
+
private pushedRoutes;
|
|
24
|
+
private routedDialogIds;
|
|
25
|
+
private dialogReturnPaths;
|
|
26
|
+
private dialogOptions;
|
|
27
|
+
constructor(config?: MachineRouterConfig);
|
|
28
|
+
init(): import("@medyll/idae-router").RouterInstance;
|
|
29
|
+
private handleLoadIn;
|
|
30
|
+
/** Mount a frame without changing the URL (framer history:false). */
|
|
31
|
+
openFrame(event: NavigationEvent): void;
|
|
32
|
+
private mountZoneFrame;
|
|
33
|
+
/**
|
|
34
|
+
* Deep-link cold boot: the initial hash dispatch can fire before the shell
|
|
35
|
+
* (and its [data-target-zone]) is mounted — auth gating renders <App/> only
|
|
36
|
+
* after boot resolves. Wait for the zone instead of dropping the navigation.
|
|
37
|
+
* Resolves null on timeout (load then fails as before).
|
|
38
|
+
*/
|
|
39
|
+
private waitForZone;
|
|
40
|
+
private handleAuthGuard;
|
|
41
|
+
private checkAuthentication;
|
|
42
|
+
navigate(path: string): void;
|
|
43
|
+
push(path: string): void;
|
|
44
|
+
/** Add a business dialog to the current routed state. */
|
|
45
|
+
openDialog(event: DialogNavigationEvent): void;
|
|
46
|
+
/**
|
|
47
|
+
* Keep browser history aligned when a routed zone frame closes.
|
|
48
|
+
* Routes pushed inside the app can safely go back. A cold deep-link only goes
|
|
49
|
+
* back when its referrer is same-origin; otherwise the frame hash is removed
|
|
50
|
+
* in place so closing never sends the user back to another site.
|
|
51
|
+
*/
|
|
52
|
+
closeFrame(frameId: string): void;
|
|
53
|
+
getRouter(): import("@medyll/idae-router").RouterInstance | null;
|
|
54
|
+
private dialogFrameId;
|
|
55
|
+
}
|
|
56
|
+
export declare function createMachineRouter(config?: MachineRouterConfig): MachineRouter;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { createRouter } from '@medyll/idae-router';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { parseLoadInUrl } from '../router/urlParser.js';
|
|
4
|
+
import { buildLoadInUrl } from '../frame/frameUrl.js';
|
|
5
|
+
import { machineFrameManager } from '../frame/MachineFrameManager.js';
|
|
6
|
+
/**
|
|
7
|
+
* MachineRouter — thin URL dispatcher on top of idae-router.
|
|
8
|
+
*
|
|
9
|
+
* Sole responsibility: catch hash URLs of shape `/+zone/modulePath/collection[/id][?vars]`
|
|
10
|
+
* and delegate to machineFrameManager (which loads existing Frame or mounts a new one).
|
|
11
|
+
*
|
|
12
|
+
* Auth guard is kept but disabled by default — enable via `authEnabled: true` when wiring login.
|
|
13
|
+
*
|
|
14
|
+
* RBAC is NOT here:
|
|
15
|
+
* - Server enforces via `requireDroit` middleware (authoritative).
|
|
16
|
+
* - UI hints via `machineRights.checkAccess` (display layer).
|
|
17
|
+
*/
|
|
18
|
+
export class MachineRouter {
|
|
19
|
+
router = null;
|
|
20
|
+
config;
|
|
21
|
+
pushedRoutes = new Set();
|
|
22
|
+
routedDialogIds = new Set();
|
|
23
|
+
dialogReturnPaths = new Map();
|
|
24
|
+
dialogOptions = new Map();
|
|
25
|
+
constructor(config = {}) {
|
|
26
|
+
this.config = {
|
|
27
|
+
baseUrl: config.baseUrl || '/',
|
|
28
|
+
authEnabled: config.authEnabled ?? false,
|
|
29
|
+
loginRoute: config.loginRoute || '/login',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
init() {
|
|
33
|
+
// Router outlet unused — actions delegate to machineFrameManager (Frame.svelte = real mount target).
|
|
34
|
+
// In browser: provide offscreen placeholder so createRouter doesn't throw.
|
|
35
|
+
// In SSR/test (no document): omit outlet entirely.
|
|
36
|
+
const placeholderOutlet = typeof document !== 'undefined' ? (() => {
|
|
37
|
+
const el = document.createElement('div');
|
|
38
|
+
el.setAttribute('data-idae-router-placeholder', '');
|
|
39
|
+
el.style.cssText = 'display:none;position:fixed;left:-9999px;';
|
|
40
|
+
document.body.appendChild(el);
|
|
41
|
+
return el;
|
|
42
|
+
})() : undefined;
|
|
43
|
+
const routes = [
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
{ path: '/*', action: (ctx) => this.handleLoadIn(ctx), metadata: { title: 'LoadIn' } },
|
|
46
|
+
];
|
|
47
|
+
this.router = createRouter({
|
|
48
|
+
mode: 'hash',
|
|
49
|
+
base: this.config.baseUrl,
|
|
50
|
+
linkInterception: true,
|
|
51
|
+
routes,
|
|
52
|
+
...(placeholderOutlet && { outlet: placeholderOutlet })
|
|
53
|
+
});
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
this.router?.before?.((to, _from, next) => {
|
|
56
|
+
this.handleAuthGuard(to, next);
|
|
57
|
+
});
|
|
58
|
+
logger.info('🧭 Machine router initialized');
|
|
59
|
+
return this.router;
|
|
60
|
+
}
|
|
61
|
+
async handleLoadIn(ctx) {
|
|
62
|
+
const path = ctx.path ?? '';
|
|
63
|
+
const segments = parseLoadInUrl(path);
|
|
64
|
+
const desiredDialogIds = new Set(segments
|
|
65
|
+
.filter((seg) => seg.targetId === 'dialog')
|
|
66
|
+
.map((seg) => this.dialogFrameId(seg.modulePath, seg.collection, seg.collectionId)));
|
|
67
|
+
for (const frameId of this.routedDialogIds) {
|
|
68
|
+
if (desiredDialogIds.has(frameId))
|
|
69
|
+
continue;
|
|
70
|
+
if (machineFrameManager.has(frameId)) {
|
|
71
|
+
machineFrameManager.close(frameId, { history: false });
|
|
72
|
+
}
|
|
73
|
+
this.routedDialogIds.delete(frameId);
|
|
74
|
+
}
|
|
75
|
+
for (const seg of segments) {
|
|
76
|
+
if (seg.targetId === 'dialog') {
|
|
77
|
+
const frameId = this.dialogFrameId(seg.modulePath, seg.collection, seg.collectionId);
|
|
78
|
+
const dialogOptions = this.dialogOptions.get(frameId);
|
|
79
|
+
await machineFrameManager.loadInDialog(seg.modulePath, seg.collection, seg.collectionId, { vars: seg.vars, history: false, ...dialogOptions });
|
|
80
|
+
this.routedDialogIds.add(frameId);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
await this.mountZoneFrame(seg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Mount a frame without changing the URL (framer history:false). */
|
|
87
|
+
openFrame(event) {
|
|
88
|
+
void this.mountZoneFrame({
|
|
89
|
+
targetId: event.zone,
|
|
90
|
+
modulePath: event.modulePath,
|
|
91
|
+
collection: event.collection,
|
|
92
|
+
collectionId: event.collectionId === undefined ? undefined : String(event.collectionId),
|
|
93
|
+
vars: event.vars
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async mountZoneFrame(seg) {
|
|
97
|
+
// frameId is content-keyed: "modulePath:zone" — mirrors dialog frame ids.
|
|
98
|
+
const contentFrameId = `${seg.modulePath}:${seg.targetId}`;
|
|
99
|
+
const mountFn = async (frameId) => {
|
|
100
|
+
if (typeof document === 'undefined')
|
|
101
|
+
return;
|
|
102
|
+
const zone = frameId.slice(frameId.indexOf(':') + 1);
|
|
103
|
+
const target = await this.waitForZone(zone);
|
|
104
|
+
if (!target)
|
|
105
|
+
return;
|
|
106
|
+
const taskbar = target.dataset.taskbar !== 'false';
|
|
107
|
+
const { mount } = await import('svelte');
|
|
108
|
+
const { default: Frame } = await import('../../shell/Frame.svelte');
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
mount(Frame, { target, props: { id: frameId, taskbar } });
|
|
111
|
+
};
|
|
112
|
+
try {
|
|
113
|
+
await machineFrameManager.load(contentFrameId, seg.modulePath, seg.collection, seg.collectionId, seg.vars, mountFn);
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
logger.warn(`[MachineRouter] Failed to load frame: ${seg.modulePath} → ${seg.targetId}`, err);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Deep-link cold boot: the initial hash dispatch can fire before the shell
|
|
121
|
+
* (and its [data-target-zone]) is mounted — auth gating renders <App/> only
|
|
122
|
+
* after boot resolves. Wait for the zone instead of dropping the navigation.
|
|
123
|
+
* Resolves null on timeout (load then fails as before).
|
|
124
|
+
*/
|
|
125
|
+
waitForZone(zone, timeoutMs = 15_000) {
|
|
126
|
+
const selector = `[data-target-zone="${zone}"]`;
|
|
127
|
+
const existing = document.querySelector(selector);
|
|
128
|
+
if (existing)
|
|
129
|
+
return Promise.resolve(existing);
|
|
130
|
+
return new Promise((resolve) => {
|
|
131
|
+
const observer = new MutationObserver(() => {
|
|
132
|
+
const el = document.querySelector(selector);
|
|
133
|
+
if (el) {
|
|
134
|
+
observer.disconnect();
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
resolve(el);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const timer = setTimeout(() => {
|
|
140
|
+
observer.disconnect();
|
|
141
|
+
resolve(null);
|
|
142
|
+
}, timeoutMs);
|
|
143
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
handleAuthGuard(to, next) {
|
|
147
|
+
if (!this.config.authEnabled) {
|
|
148
|
+
next();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const meta = to.metadata;
|
|
152
|
+
if (!meta?.public && !this.checkAuthentication()) {
|
|
153
|
+
logger.warn('⛔ Not authenticated, redirecting to login');
|
|
154
|
+
next(`${this.config.loginRoute}?redirect=${encodeURIComponent(to.path ?? '')}`);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
next();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
checkAuthentication() {
|
|
161
|
+
return !!localStorage?.getItem?.('auth_token');
|
|
162
|
+
}
|
|
163
|
+
navigate(path) {
|
|
164
|
+
this.pushedRoutes.add(path);
|
|
165
|
+
this.router ? this.router.push(path) : (location.href = path);
|
|
166
|
+
}
|
|
167
|
+
push(path) {
|
|
168
|
+
this.navigate(path);
|
|
169
|
+
}
|
|
170
|
+
/** Add a business dialog to the current routed state. */
|
|
171
|
+
openDialog(event) {
|
|
172
|
+
if (typeof window === 'undefined')
|
|
173
|
+
return;
|
|
174
|
+
const currentPath = window.location.hash.replace(/^#/, '') || '/';
|
|
175
|
+
const frameId = this.dialogFrameId(event.modulePath, event.collection, event.collectionId);
|
|
176
|
+
const alreadyPresent = parseLoadInUrl(currentPath).some((seg) => seg.targetId === 'dialog'
|
|
177
|
+
&& this.dialogFrameId(seg.modulePath, seg.collection, seg.collectionId) === frameId);
|
|
178
|
+
if (alreadyPresent)
|
|
179
|
+
return;
|
|
180
|
+
this.dialogReturnPaths.set(frameId, currentPath);
|
|
181
|
+
this.dialogOptions.set(frameId, {
|
|
182
|
+
modal: event.modal,
|
|
183
|
+
closable: event.closable,
|
|
184
|
+
draggable: event.draggable,
|
|
185
|
+
fullscreen: event.fullscreen
|
|
186
|
+
});
|
|
187
|
+
const basePath = currentPath.split('?')[0].replace(/\/$/, '');
|
|
188
|
+
const vars = event.vars && Object.keys(event.vars).length > 0
|
|
189
|
+
? new URLSearchParams(event.vars).toString()
|
|
190
|
+
: undefined;
|
|
191
|
+
const dialogPath = buildLoadInUrl(event.modulePath, 'dialog', event.collection, event.collectionId, vars);
|
|
192
|
+
this.push(`${basePath === '' ? '' : basePath}${dialogPath}`);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Keep browser history aligned when a routed zone frame closes.
|
|
196
|
+
* Routes pushed inside the app can safely go back. A cold deep-link only goes
|
|
197
|
+
* back when its referrer is same-origin; otherwise the frame hash is removed
|
|
198
|
+
* in place so closing never sends the user back to another site.
|
|
199
|
+
*/
|
|
200
|
+
closeFrame(frameId) {
|
|
201
|
+
if (typeof window === 'undefined')
|
|
202
|
+
return;
|
|
203
|
+
const path = window.location.hash.replace(/^#/, '');
|
|
204
|
+
const segments = parseLoadInUrl(path);
|
|
205
|
+
const isCurrentFrame = segments.some((seg) => `${seg.modulePath}:${seg.targetId}` === frameId
|
|
206
|
+
|| (seg.targetId === 'dialog'
|
|
207
|
+
&& this.dialogFrameId(seg.modulePath, seg.collection, seg.collectionId) === frameId));
|
|
208
|
+
if (!isCurrentFrame)
|
|
209
|
+
return;
|
|
210
|
+
if (frameId.startsWith('dialog:')) {
|
|
211
|
+
const returnPath = this.dialogReturnPaths.get(frameId);
|
|
212
|
+
this.dialogReturnPaths.delete(frameId);
|
|
213
|
+
if (returnPath) {
|
|
214
|
+
this.push(returnPath);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const remaining = segments.filter((seg) => this.dialogFrameId(seg.modulePath, seg.collection, seg.collectionId) !== frameId);
|
|
218
|
+
const remainingPath = remaining.map((seg, index) => {
|
|
219
|
+
const isLast = index === remaining.length - 1;
|
|
220
|
+
const vars = isLast && seg.vars
|
|
221
|
+
? new URLSearchParams(seg.vars).toString()
|
|
222
|
+
: undefined;
|
|
223
|
+
return buildLoadInUrl(seg.modulePath, seg.targetId, seg.collection, seg.collectionId, vars);
|
|
224
|
+
}).join('');
|
|
225
|
+
this.push(remainingPath || '/');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let sameOriginReferrer = false;
|
|
229
|
+
if (document.referrer) {
|
|
230
|
+
try {
|
|
231
|
+
sameOriginReferrer = new URL(document.referrer).origin === window.location.origin;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
sameOriginReferrer = false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (this.pushedRoutes.has(path) || sameOriginReferrer) {
|
|
238
|
+
window.history.back();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
window.history.replaceState(window.history.state, '', `${window.location.pathname}${window.location.search}`);
|
|
242
|
+
}
|
|
243
|
+
getRouter() { return this.router; }
|
|
244
|
+
dialogFrameId(modulePath, collection, collectionId) {
|
|
245
|
+
return `dialog:${modulePath}:${collection}:${collectionId ?? ''}`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
export function createMachineRouter(config) {
|
|
249
|
+
return new MachineRouter(config);
|
|
250
|
+
}
|
|
@@ -1,84 +1,54 @@
|
|
|
1
|
-
import type { TplCollectionName,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import type { TplCollectionName, TplFields, IDbForge, TplFieldRules, SortBy } from '../../types/index.js';
|
|
2
|
+
import type { MachineModel, MachineCollectionModel, MachineDisplayTemplate, MachineFkDef } from '../../types/index.js';
|
|
3
|
+
import { MachineDb } from '../machineDb.js';
|
|
4
|
+
import { MachineSchemeFieldForge } from './MachineSchemeFieldForge.js';
|
|
5
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
6
|
+
import { MachineSchemeValidate } from './MachineSchemeValidate.js';
|
|
7
|
+
import { MachineSchemeField } from './MachineSchemeField.js';
|
|
7
8
|
/**
|
|
8
9
|
* @class MachineScheme
|
|
9
|
-
* @role Provides schema and field utilities for a collection
|
|
10
|
+
* @role Provides schema and field utilities for a collection: metadata, formatting, field parsing.
|
|
10
11
|
*/
|
|
11
12
|
export declare class MachineScheme {
|
|
12
13
|
#private;
|
|
13
|
-
/** The collection name. */
|
|
14
14
|
collection: TplCollectionName;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
get model(): CollectionModel<Record<string, any>>;
|
|
29
|
-
/**
|
|
30
|
-
* Get the collection template.
|
|
31
|
-
* @role Accessor
|
|
32
|
-
* @return {Tpl} The collection template.
|
|
33
|
-
*/
|
|
34
|
-
get template(): Tpl;
|
|
35
|
-
/**
|
|
36
|
-
* Get a form validator for this collection.
|
|
37
|
-
* @role Utility
|
|
38
|
-
* @return {MachineSchemeValidate} The form validator instance.
|
|
39
|
-
*/
|
|
15
|
+
name: TplCollectionName;
|
|
16
|
+
constructor(collectionName: TplCollectionName, idbBase: MachineDb, model: MachineModel);
|
|
17
|
+
get model(): MachineCollectionModel;
|
|
18
|
+
/** Display template (presentation only). */
|
|
19
|
+
get template(): MachineDisplayTemplate;
|
|
20
|
+
/** Field definitions (data). */
|
|
21
|
+
get fields(): Record<string, import("../../types/index.js").MachineFieldDef>;
|
|
22
|
+
/** Foreign key relations. */
|
|
23
|
+
get fks(): Record<string, MachineFkDef>;
|
|
24
|
+
/** Primary key field name, derived from keyPath ('++id' → 'id'). */
|
|
25
|
+
get index(): string;
|
|
26
|
+
/** Default sort inferred from defaultSort or field naming/type conventions. */
|
|
27
|
+
get defaultSort(): SortBy[];
|
|
40
28
|
get validator(): MachineSchemeValidate;
|
|
41
|
-
/**
|
|
42
|
-
* Get the field rule for a given field name.
|
|
43
|
-
* @role Field rule accessor
|
|
44
|
-
* @param {keyof TplFields} fieldName The field name.
|
|
45
|
-
* @return {TplFieldRules | undefined} The field rule or undefined.
|
|
46
|
-
*/
|
|
47
29
|
getFieldRule(fieldName: keyof TplFields): TplFieldRules | undefined;
|
|
48
|
-
|
|
49
|
-
* Get a new IDbCollectionValues instance for this collection.
|
|
50
|
-
* @role Utility
|
|
51
|
-
* @return {MachineSchemeValues} The collection values instance.
|
|
52
|
-
*/
|
|
53
|
-
get collectionValues(): MachineSchemeValues<Record<string, any>>;
|
|
30
|
+
get collectionValues(): MachineSchemeValues<Record<string, unknown>>;
|
|
54
31
|
field(fieldName: keyof TplFields): MachineSchemeField;
|
|
55
|
-
|
|
56
|
-
* Get a field forge instance for a specific field and data.
|
|
57
|
-
* @role Field forge factory
|
|
58
|
-
* @template T
|
|
59
|
-
* @param {keyof T} fieldName The field name.
|
|
60
|
-
* @param {T} data The data object.
|
|
61
|
-
* @return {MachineSchemeFieldForge<T>} The field forge instance.
|
|
62
|
-
*/
|
|
63
|
-
fieldForge<T extends Record<string, any>>(fieldName: keyof T, data: T): MachineSchemeFieldForge<T>;
|
|
64
|
-
/**
|
|
65
|
-
* Parse all fields of a given collection.
|
|
66
|
-
* @role Field parsing
|
|
67
|
-
* @return {Record<string, IDbForge | undefined> | undefined} All parsed fields or undefined.
|
|
68
|
-
*/
|
|
32
|
+
fieldForge<T extends Record<string, unknown>>(fieldName: keyof T, data: T): MachineSchemeFieldForge<T>;
|
|
69
33
|
parse(): Record<string, IDbForge | undefined> | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Get all foreign keys for this collection.
|
|
72
|
-
* @role Foreign key accessor
|
|
73
|
-
* @return {{ [collection: string]: Tpl }} Foreign key collections.
|
|
74
|
-
*/
|
|
75
34
|
parseFks(): {
|
|
76
35
|
[collection: string]: Record<string, IDbForge | undefined>;
|
|
77
36
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
37
|
+
findFkField(targetCollection: string): {
|
|
38
|
+
fieldName: string;
|
|
39
|
+
targetIndex: string;
|
|
40
|
+
} | null;
|
|
41
|
+
/**
|
|
42
|
+
* Whether `record` carries a value for FK relation `relationKey` — covers the
|
|
43
|
+
* nested `fks.{relationKey}_{id}` convention, the nested object form
|
|
44
|
+
* `fks.{relationKey} = { id|code }`, and the legacy flat scalar field
|
|
45
|
+
* (via `findFkField`). Used by `MachineSchemeValidate` to enforce
|
|
46
|
+
* `MachineFkDef.required`.
|
|
47
|
+
*/
|
|
48
|
+
hasFkValue(record: Record<string, unknown>, relationKey: string): boolean;
|
|
49
|
+
parseReverseFks(): Record<string, Record<string, unknown>>;
|
|
50
|
+
parseReverseFkFields(): Record<string, Record<string, MachineFkDef & {
|
|
51
|
+
fieldName?: string;
|
|
52
|
+
targetIndex?: string;
|
|
53
|
+
}>>;
|
|
84
54
|
}
|