@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,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu preference scope helpers.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes the zone → appuser_prefs scope mapping for the global menu:
|
|
5
|
+
* - side → app_menu
|
|
6
|
+
* - start → app_menu_start
|
|
7
|
+
* - create → app_menu_create
|
|
8
|
+
* - panel → app_panel
|
|
9
|
+
*
|
|
10
|
+
* The `app_*` prefixes are a convention, not a contract: consumers must never
|
|
11
|
+
* build `'app_menu_' + table` literals. Use `menuPrefsScope(zone, collection)`.
|
|
12
|
+
*
|
|
13
|
+
* Default policy: a collection is visible only when an explicit `value: true` exists
|
|
14
|
+
* for that zone+collection key — either a per-user override row (`'{userId}:{key}'`)
|
|
15
|
+
* or, failing that, the role-derived `baseline` resolved server-side at login. The
|
|
16
|
+
* precedence is `userOverride ?? baseline ?? false`: a user's explicit row (incl. an
|
|
17
|
+
* explicit `false`) always wins; otherwise the role baseline decides; unset = hidden.
|
|
18
|
+
* In dev mode the filter is bypassed entirely.
|
|
19
|
+
*/
|
|
20
|
+
/** Known menu zones and their canonical appuser_prefs scope prefixes. */
|
|
21
|
+
export const MENU_ZONES = {
|
|
22
|
+
side: 'app_menu',
|
|
23
|
+
start: 'app_menu_start',
|
|
24
|
+
create: 'app_menu_create',
|
|
25
|
+
panel: 'app_panel'
|
|
26
|
+
};
|
|
27
|
+
function isTestEnvironment() {
|
|
28
|
+
try {
|
|
29
|
+
return (typeof process !== 'undefined' &&
|
|
30
|
+
!!process.env &&
|
|
31
|
+
(process.env.VITEST === 'true' || process.env.NODE_ENV === 'test'));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getIsDev(isDev) {
|
|
38
|
+
if (isDev !== undefined)
|
|
39
|
+
return isDev;
|
|
40
|
+
// In vitest we default to false so tests can exercise both modes explicitly.
|
|
41
|
+
if (isTestEnvironment())
|
|
42
|
+
return false;
|
|
43
|
+
if (typeof import.meta !== 'undefined' && import.meta.env && typeof import.meta.env.DEV === 'boolean') {
|
|
44
|
+
return import.meta.env.DEV;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the canonical appuser_prefs scope key for a menu zone + collection.
|
|
50
|
+
* The key is `{prefix}.{collection}` and is intended to be used as the `scope`
|
|
51
|
+
* argument of `useMachinePrefs` (the slot/collection name becomes the pref slot).
|
|
52
|
+
*/
|
|
53
|
+
export function menuPrefsScope(zone, collection) {
|
|
54
|
+
return `${MENU_ZONES[zone]}.${collection}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the canonical appuser_prefs scope prefix for a zone.
|
|
58
|
+
* Use this when reading/writing menu prefs directly via machine.collection('appuser_prefs').
|
|
59
|
+
*/
|
|
60
|
+
export function menuPrefsPrefix(zone) {
|
|
61
|
+
return MENU_ZONES[zone];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check whether a collection should be visible in a menu zone.
|
|
65
|
+
*
|
|
66
|
+
* Resolution (`userOverride ?? baseline ?? false`):
|
|
67
|
+
* 1. Dev mode (`isDev === true`) → always visible.
|
|
68
|
+
* 2. User override present (`key in prefs`) → use it (explicit `false` hides).
|
|
69
|
+
* 3. Else role baseline (`baseline[key]`) → visible when truthy.
|
|
70
|
+
* 4. Else hidden.
|
|
71
|
+
*
|
|
72
|
+
* `baseline` is the role-derived map delivered by the server at login (OR'd across
|
|
73
|
+
* the user's roles); `prefs` are the user's own override rows. "Unset" = hidden.
|
|
74
|
+
*/
|
|
75
|
+
export function isMenuCollectionVisible(zone, collection, prefs = {}, isDev, baseline = {}) {
|
|
76
|
+
if (getIsDev(isDev))
|
|
77
|
+
return true;
|
|
78
|
+
const key = menuPrefsScope(zone, collection);
|
|
79
|
+
if (key in prefs)
|
|
80
|
+
return Boolean(prefs[key]);
|
|
81
|
+
return Boolean(baseline[key]);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Reduce raw appuser_prefs rows (`{ code: '{userId}:{scopeKey}', value }`) down to a
|
|
85
|
+
* `{ scopeKey: value }` map for the given user — the shape `isMenuCollectionVisible`/
|
|
86
|
+
* `filterMenuCollections` expect as `prefs`. Mirrors useMachinePrefs.svelte.ts's
|
|
87
|
+
* hydration prefix-strip so menu prefs read the same records the settings gear (BL-18)
|
|
88
|
+
* writes via machine.action.
|
|
89
|
+
*/
|
|
90
|
+
export function readMenuPrefsFromRecords(records, userId) {
|
|
91
|
+
const prefix = `${String(userId)}:`;
|
|
92
|
+
const prefs = {};
|
|
93
|
+
for (const record of records) {
|
|
94
|
+
if (typeof record.code !== 'string' || !record.code.startsWith(prefix))
|
|
95
|
+
continue;
|
|
96
|
+
prefs[record.code.slice(prefix.length)] = record.value;
|
|
97
|
+
}
|
|
98
|
+
return prefs;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Filter a list of collections to those visible in a menu zone.
|
|
102
|
+
*
|
|
103
|
+
* @param zone Menu zone being rendered.
|
|
104
|
+
* @param collections Candidate collection names (e.g. from appscheme).
|
|
105
|
+
* @param options.prefs Map of `menuPrefsScope(zone, collection)` → boolean.
|
|
106
|
+
* @param options.permittedCollections Optional whitelist (e.g. `machine.rights.allowedCollections('L')`).
|
|
107
|
+
* When provided, the result is intersected with it.
|
|
108
|
+
* @param options.baseline Role-derived visibility map (server-resolved at login).
|
|
109
|
+
* @param options.isDev Force dev-mode bypass (defaults to `import.meta.env.DEV`).
|
|
110
|
+
*/
|
|
111
|
+
export function filterMenuCollections(zone, collections, options = {}) {
|
|
112
|
+
const { prefs = {}, baseline = {}, permittedCollections, isDev } = options;
|
|
113
|
+
const base = permittedCollections?.length
|
|
114
|
+
? collections.filter((c) => permittedCollections.includes(c))
|
|
115
|
+
: [...collections];
|
|
116
|
+
if (getIsDev(isDev))
|
|
117
|
+
return base;
|
|
118
|
+
return base.filter((c) => isMenuCollectionVisible(zone, c, prefs, false, baseline));
|
|
119
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SortBy } from '../../types/index.js';
|
|
2
|
+
type SlotMap = Record<string, unknown>;
|
|
3
|
+
/** Prefs slots shared by DataList and its externalised controls (Sort/Group/Find). */
|
|
4
|
+
export interface DataListPrefs {
|
|
5
|
+
mode: 'list' | 'table' | 'grid' | 'accordion' | null;
|
|
6
|
+
sortBy: SortBy[];
|
|
7
|
+
groupBy: string | undefined;
|
|
8
|
+
find: Record<string, unknown> | undefined;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/** Canonical prefs scope key for a list — controls must use the same key to sync. */
|
|
12
|
+
export declare function dataListPrefsScope(collection: string, prefsScope?: string): string;
|
|
13
|
+
export declare function dataListPrefsDefaults(): DataListPrefs;
|
|
14
|
+
/**
|
|
15
|
+
* Drop all cached prefs stores. The cache deliberately survives component
|
|
16
|
+
* remounts (so externalised controls share live state); in production a
|
|
17
|
+
* user switch reloads the page. Tests reboot the machine in-process, so they
|
|
18
|
+
* must clear the cache between cases to stay isolated.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clearMachinePrefsCache(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Svelte 5 rune: hydrate + persist a set of named preference slots
|
|
23
|
+
* from/to appuser_prefs (code = `{userId}:{scope}.{slot}`).
|
|
24
|
+
*
|
|
25
|
+
* Usage:
|
|
26
|
+
* const prefs = useMachinePrefs(() => 'datalist.vehicle', { sortBy: [], groupBy: undefined }, () => true);
|
|
27
|
+
* prefs.get('sortBy') → reactive read
|
|
28
|
+
* prefs.set('sortBy', v) → reactive write + persist
|
|
29
|
+
* prefs.hydrated → true once initial load done
|
|
30
|
+
*/
|
|
31
|
+
export declare function useMachinePrefs<T extends SlotMap>(scope: () => string, defaults: T, enabled: () => boolean): {
|
|
32
|
+
readonly hydrated: boolean;
|
|
33
|
+
get<K extends keyof T>(slot: K): T[K];
|
|
34
|
+
set<K extends keyof T>(slot: K, value: T[K]): void;
|
|
35
|
+
/** Raw reactive state — for binding in templates */
|
|
36
|
+
readonly slots: T;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { machine } from '../../main/machine.js';
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
/** Canonical prefs scope key for a list — controls must use the same key to sync. */
|
|
4
|
+
export function dataListPrefsScope(collection, prefsScope) {
|
|
5
|
+
return prefsScope ?? `datalist.${collection}`;
|
|
6
|
+
}
|
|
7
|
+
export function dataListPrefsDefaults() {
|
|
8
|
+
return { mode: null, sortBy: [], groupBy: undefined, find: undefined };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Shared per-scope reactive stores. A DataList and any external control
|
|
12
|
+
* (Sort/Group/Find) bound to the same scope read/write the *same* `$state`
|
|
13
|
+
* object — so toolbars externalised as sibling components stay in sync with
|
|
14
|
+
* the list instead of each holding an isolated copy.
|
|
15
|
+
*/
|
|
16
|
+
const stores = new Map();
|
|
17
|
+
function ensureStore(scopeStr, defaults) {
|
|
18
|
+
const existing = stores.get(scopeStr);
|
|
19
|
+
if (existing)
|
|
20
|
+
return existing;
|
|
21
|
+
const store = $state({ slots: { ...defaults }, hydrated: false, loaded: false });
|
|
22
|
+
stores.set(scopeStr, store);
|
|
23
|
+
return store;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Drop all cached prefs stores. The cache deliberately survives component
|
|
27
|
+
* remounts (so externalised controls share live state); in production a
|
|
28
|
+
* user switch reloads the page. Tests reboot the machine in-process, so they
|
|
29
|
+
* must clear the cache between cases to stay isolated.
|
|
30
|
+
*/
|
|
31
|
+
export function clearMachinePrefsCache() {
|
|
32
|
+
stores.clear();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Svelte 5 rune: hydrate + persist a set of named preference slots
|
|
36
|
+
* from/to appuser_prefs (code = `{userId}:{scope}.{slot}`).
|
|
37
|
+
*
|
|
38
|
+
* Usage:
|
|
39
|
+
* const prefs = useMachinePrefs(() => 'datalist.vehicle', { sortBy: [], groupBy: undefined }, () => true);
|
|
40
|
+
* prefs.get('sortBy') → reactive read
|
|
41
|
+
* prefs.set('sortBy', v) → reactive write + persist
|
|
42
|
+
* prefs.hydrated → true once initial load done
|
|
43
|
+
*/
|
|
44
|
+
export function useMachinePrefs(scope, defaults, enabled) {
|
|
45
|
+
function normalize(value) {
|
|
46
|
+
if (value == null || typeof value !== 'object')
|
|
47
|
+
return value;
|
|
48
|
+
return JSON.parse(JSON.stringify(value));
|
|
49
|
+
}
|
|
50
|
+
function persist(scopeStr, slot, value) {
|
|
51
|
+
if (!enabled())
|
|
52
|
+
return;
|
|
53
|
+
const scopeKey = `${scopeStr}.${slot}`;
|
|
54
|
+
void machine.action('appuser_prefs', { scopeKey, name: scopeKey, value: normalize(value) }, { code: '{userId}:{scopeKey}', upsertOn: ['code'] });
|
|
55
|
+
}
|
|
56
|
+
// Hydrate when scope/enabled changes. Guarded so a scope only fetches from
|
|
57
|
+
// IDB once — later-mounting controls bound to the same scope reuse the
|
|
58
|
+
// already-hydrated shared store instead of re-reading (or worse, resetting
|
|
59
|
+
// a value the user just changed).
|
|
60
|
+
$effect(() => {
|
|
61
|
+
const s = scope();
|
|
62
|
+
const on = enabled();
|
|
63
|
+
const st = ensureStore(s, defaults);
|
|
64
|
+
// usePrefs=false: never read persisted prefs. Don't touch shared slots
|
|
65
|
+
// (a prefs-enabled consumer may own them); just report hydrated.
|
|
66
|
+
if (!on) {
|
|
67
|
+
st.hydrated = true;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (st.loaded) {
|
|
71
|
+
st.hydrated = true;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const user = machine.rights.currentUser;
|
|
75
|
+
if (!user) {
|
|
76
|
+
st.hydrated = true;
|
|
77
|
+
return;
|
|
78
|
+
} // retry once a user is set
|
|
79
|
+
st.loaded = true;
|
|
80
|
+
// Reset to defaults before applying persisted values so a stale slot
|
|
81
|
+
// can't survive a (re)hydration.
|
|
82
|
+
Object.assign(st.slots, defaults);
|
|
83
|
+
const prefix = `${String(user.id)}:${s}.`;
|
|
84
|
+
untrack(() => {
|
|
85
|
+
Promise.resolve(machine.collection('appuser_prefs').getAll())
|
|
86
|
+
.then((rows) => {
|
|
87
|
+
for (const r of rows) {
|
|
88
|
+
if (typeof r.code === 'string' && r.code.startsWith(prefix)) {
|
|
89
|
+
const key = r.code.slice(prefix.length);
|
|
90
|
+
if (key in st.slots)
|
|
91
|
+
st.slots[key] = r.value ?? st.slots[key];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
.catch((error) => {
|
|
96
|
+
console.warn('[useMachinePrefs] Failed to hydrate preferences:', error);
|
|
97
|
+
})
|
|
98
|
+
.finally(() => { st.hydrated = true; });
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
get hydrated() { return ensureStore(scope(), defaults).hydrated; },
|
|
103
|
+
get(slot) {
|
|
104
|
+
return ensureStore(scope(), defaults).slots[slot];
|
|
105
|
+
},
|
|
106
|
+
set(slot, value) {
|
|
107
|
+
const st = ensureStore(scope(), defaults);
|
|
108
|
+
st.slots[slot] = value;
|
|
109
|
+
if (enabled() && st.hydrated)
|
|
110
|
+
untrack(() => persist(scope(), slot, value));
|
|
111
|
+
},
|
|
112
|
+
/** Raw reactive state — for binding in templates */
|
|
113
|
+
get slots() {
|
|
114
|
+
return ensureStore(scope(), defaults).slots;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MenuTree } from '../../idae/menu/IdaeMenuStore.js';
|
|
2
|
+
import { type MenuZone } from './menuPrefs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Svelte 5 rune: reactive list of allowed collection codes for a zone — the access
|
|
5
|
+
* half of {@link useMenuTree} (rights('L') ∩ prefs ∩ baseline ∩ dev), without the
|
|
6
|
+
* appscheme/appscheme_base metadata join or grouping.
|
|
7
|
+
*
|
|
8
|
+
* Use when a consumer renders the metadata itself (e.g. `DataList collection="appscheme"
|
|
9
|
+
* where={{ code: { $in: codes } }}`) — the labels/icons/grouping then come from the
|
|
10
|
+
* appscheme collection instead of being re-derived here. Only subscribes to
|
|
11
|
+
* appuser_prefs, not appscheme/appscheme_base.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useMenuCodes(zone: () => MenuZone): {
|
|
14
|
+
readonly codes: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Svelte 5 rune: reactive menu tree for a zone — rights(L) ∩ prefs ∩ appscheme/type.
|
|
18
|
+
* Re-derives whenever appuser_prefs/appscheme/appscheme_base/current user changes.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* const menu = useMenuTree(() => 'side');
|
|
22
|
+
* menu.tree.groups → [{ key, label, items: [{ collection, label, icon, ... }] }]
|
|
23
|
+
*/
|
|
24
|
+
export declare function useMenuTree(zone: () => MenuZone): {
|
|
25
|
+
readonly tree: MenuTree;
|
|
26
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { machine } from '../../main/machine.js';
|
|
2
|
+
import { buildMenuTree } from '../../idae/menu/IdaeMenuStore.js';
|
|
3
|
+
import { filterMenuCollections, readMenuPrefsFromRecords } from './menuPrefs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Svelte 5 rune: reactive list of allowed collection codes for a zone — the access
|
|
6
|
+
* half of {@link useMenuTree} (rights('L') ∩ prefs ∩ baseline ∩ dev), without the
|
|
7
|
+
* appscheme/appscheme_base metadata join or grouping.
|
|
8
|
+
*
|
|
9
|
+
* Use when a consumer renders the metadata itself (e.g. `DataList collection="appscheme"
|
|
10
|
+
* where={{ code: { $in: codes } }}`) — the labels/icons/grouping then come from the
|
|
11
|
+
* appscheme collection instead of being re-derived here. Only subscribes to
|
|
12
|
+
* appuser_prefs, not appscheme/appscheme_base.
|
|
13
|
+
*/
|
|
14
|
+
export function useMenuCodes(zone) {
|
|
15
|
+
const prefsSrc = machine.store('appuser_prefs');
|
|
16
|
+
const codes = $derived.by(() => {
|
|
17
|
+
const userId = machine.rights.currentUser?.id;
|
|
18
|
+
const prefsRecords = prefsSrc.records;
|
|
19
|
+
const prefs = userId != null ? readMenuPrefsFromRecords(prefsRecords, userId) : {};
|
|
20
|
+
return filterMenuCollections(zone(), machine.rights.allowedCollections('L'), {
|
|
21
|
+
prefs,
|
|
22
|
+
baseline: machine.rights.menuBaseline,
|
|
23
|
+
isDev: import.meta.env.DEV
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
get codes() {
|
|
28
|
+
return codes;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Svelte 5 rune: reactive menu tree for a zone — rights(L) ∩ prefs ∩ appscheme/type.
|
|
34
|
+
* Re-derives whenever appuser_prefs/appscheme/appscheme_base/current user changes.
|
|
35
|
+
*
|
|
36
|
+
* Usage:
|
|
37
|
+
* const menu = useMenuTree(() => 'side');
|
|
38
|
+
* menu.tree.groups → [{ key, label, items: [{ collection, label, icon, ... }] }]
|
|
39
|
+
*/
|
|
40
|
+
export function useMenuTree(zone) {
|
|
41
|
+
// machine.store() registers a reactive subscription (Svelte 5 $effect under the
|
|
42
|
+
// hood) — it must be called ONCE per hook instance, at top level, never re-invoked
|
|
43
|
+
// inside $derived.by. Calling it fresh on every recompute (the original S50-01
|
|
44
|
+
// shape) re-registers a brand-new subscription each pass and the tree never
|
|
45
|
+
// converges (always reads the just-reset empty snapshot).
|
|
46
|
+
const prefsSrc = machine.store('appuser_prefs');
|
|
47
|
+
const appschemeSrc = machine.store('appscheme');
|
|
48
|
+
const appschemeBaseSrc = machine.store('appscheme_base');
|
|
49
|
+
const tree = $derived.by(() => {
|
|
50
|
+
const z = zone();
|
|
51
|
+
const userId = machine.rights.currentUser?.id;
|
|
52
|
+
const prefsRecords = prefsSrc.records;
|
|
53
|
+
const prefs = userId != null ? readMenuPrefsFromRecords(prefsRecords, userId) : {};
|
|
54
|
+
return buildMenuTree({
|
|
55
|
+
allowedCollections: machine.rights.allowedCollections('L'),
|
|
56
|
+
prefs,
|
|
57
|
+
baseline: machine.rights.menuBaseline,
|
|
58
|
+
appscheme: appschemeSrc.records,
|
|
59
|
+
appscheme_base: appschemeBaseSrc.records,
|
|
60
|
+
isDev: import.meta.env.DEV
|
|
61
|
+
}, z);
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
get tree() {
|
|
65
|
+
return tree;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive dual-source record resolution — BL-24.
|
|
3
|
+
*
|
|
4
|
+
* A component receives either `(collection, collectionId)` or `(collection, data)`.
|
|
5
|
+
* `data` wins when provided (controlled — e.g. DataList passes a store item); otherwise
|
|
6
|
+
* the record is read reactively via `machine.store` (never `machine.collection` —
|
|
7
|
+
* invariant CLAUDE.md 8) using the scheme's index field (default `id`).
|
|
8
|
+
*
|
|
9
|
+
* Extracted from the inline pattern in DataRecord.svelte (the documented contract,
|
|
10
|
+
* CLAUDE.md §4 "DataRecord data source contract") so other collection+collectionId
|
|
11
|
+
* consumers (ContextMenuContent, DataField, Fiche, ...) share one resolution path
|
|
12
|
+
* instead of re-implementing it divergently (ContextMenuContent.svelte:40 used a loose
|
|
13
|
+
* `== ` match against the raw store, ignoring `scheme.index` and never re-deriving).
|
|
14
|
+
*/
|
|
15
|
+
export declare function useRecordData(collection: () => string | undefined, source: () => {
|
|
16
|
+
collectionId?: string | number;
|
|
17
|
+
data?: Record<string, unknown>;
|
|
18
|
+
}): {
|
|
19
|
+
readonly record: Record<string, unknown> | undefined;
|
|
20
|
+
readonly collectionId: string | number | undefined;
|
|
21
|
+
readonly scheme: import("../../main/machine/MachineScheme.js").MachineScheme | null;
|
|
22
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { machine } from '../../main/machine.js';
|
|
2
|
+
import { MachineRecordIdentity } from '../../main/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reactive dual-source record resolution — BL-24.
|
|
5
|
+
*
|
|
6
|
+
* A component receives either `(collection, collectionId)` or `(collection, data)`.
|
|
7
|
+
* `data` wins when provided (controlled — e.g. DataList passes a store item); otherwise
|
|
8
|
+
* the record is read reactively via `machine.store` (never `machine.collection` —
|
|
9
|
+
* invariant CLAUDE.md 8) using the scheme's index field (default `id`).
|
|
10
|
+
*
|
|
11
|
+
* Extracted from the inline pattern in DataRecord.svelte (the documented contract,
|
|
12
|
+
* CLAUDE.md §4 "DataRecord data source contract") so other collection+collectionId
|
|
13
|
+
* consumers (ContextMenuContent, DataField, Fiche, ...) share one resolution path
|
|
14
|
+
* instead of re-implementing it divergently (ContextMenuContent.svelte:40 used a loose
|
|
15
|
+
* `== ` match against the raw store, ignoring `scheme.index` and never re-deriving).
|
|
16
|
+
*/
|
|
17
|
+
export function useRecordData(collection, source) {
|
|
18
|
+
const scheme = $derived.by(() => {
|
|
19
|
+
const c = collection();
|
|
20
|
+
return c ? machine.logic.collection(c) : null;
|
|
21
|
+
});
|
|
22
|
+
const queryId = $derived(MachineRecordIdentity.normalizeKey(source().collectionId));
|
|
23
|
+
const recordStore = $derived.by(() => {
|
|
24
|
+
const { data, collectionId } = source();
|
|
25
|
+
const c = collection();
|
|
26
|
+
if (data !== undefined || !c || collectionId === undefined)
|
|
27
|
+
return null;
|
|
28
|
+
return machine.store(c, MachineRecordIdentity.buildWhere(scheme?.index ?? 'id', queryId));
|
|
29
|
+
});
|
|
30
|
+
const fetchedData = $derived(recordStore?.records?.[0]);
|
|
31
|
+
const record = $derived(source().data ?? fetchedData);
|
|
32
|
+
const resolvedCollectionId = $derived.by(() => {
|
|
33
|
+
const { collectionId, data } = source();
|
|
34
|
+
if (collectionId !== undefined)
|
|
35
|
+
return collectionId;
|
|
36
|
+
const idx = scheme?.index ?? 'id';
|
|
37
|
+
return data?.[idx];
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
get record() {
|
|
41
|
+
return record;
|
|
42
|
+
},
|
|
43
|
+
get collectionId() {
|
|
44
|
+
return resolvedCollectionId;
|
|
45
|
+
},
|
|
46
|
+
get scheme() {
|
|
47
|
+
return scheme;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive field-list resolution for a (collection, view) pair.
|
|
3
|
+
*
|
|
4
|
+
* Both structural views (full/flat/fk/focus) and custom named views are resolved
|
|
5
|
+
* through `appscheme_view` — the single source of truth published by publishModel.
|
|
6
|
+
*
|
|
7
|
+
* `view` and `groupFieldBy` are ORTHOGONAL axes:
|
|
8
|
+
* view → WHICH fields (field codes from appscheme_view rows)
|
|
9
|
+
* groupFieldBy → HOW to group them (looked up in appscheme_field, grouped on its FK)
|
|
10
|
+
*/
|
|
11
|
+
export declare function useViewFields(collection: () => string | undefined, view: () => string | undefined, groupFieldBy?: () => string | undefined): {
|
|
12
|
+
readonly fieldNames: unknown[];
|
|
13
|
+
readonly fieldKinds: Record<string, {
|
|
14
|
+
kind: "scalar" | "fk";
|
|
15
|
+
fieldName: string;
|
|
16
|
+
fieldType: string;
|
|
17
|
+
title: string;
|
|
18
|
+
fkCollection?: string;
|
|
19
|
+
fkIndexField?: string;
|
|
20
|
+
} | null>;
|
|
21
|
+
readonly groups: Record<string, any[]> | undefined;
|
|
22
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { machine } from '../../main/machine.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reactive field-list resolution for a (collection, view) pair.
|
|
4
|
+
*
|
|
5
|
+
* Both structural views (full/flat/fk/focus) and custom named views are resolved
|
|
6
|
+
* through `appscheme_view` — the single source of truth published by publishModel.
|
|
7
|
+
*
|
|
8
|
+
* `view` and `groupFieldBy` are ORTHOGONAL axes:
|
|
9
|
+
* view → WHICH fields (field codes from appscheme_view rows)
|
|
10
|
+
* groupFieldBy → HOW to group them (looked up in appscheme_field, grouped on its FK)
|
|
11
|
+
*/
|
|
12
|
+
export function useViewFields(collection, view, groupFieldBy) {
|
|
13
|
+
const viewName = $derived(view() ?? 'full');
|
|
14
|
+
// qoolie's where engine uses BARE operators (eq/in/gte…), NOT Mongo's $-prefixed
|
|
15
|
+
// form. A `$eq` key matches no operator case → the condition is a silent no-op →
|
|
16
|
+
// the store returns every appscheme_view row (all collections, all view types),
|
|
17
|
+
// yielding duplicate field codes (e.g. `id` in full+flat). Use `eq`/`in`.
|
|
18
|
+
const viewRows = $derived(collection()
|
|
19
|
+
? machine.store('appscheme_view', {
|
|
20
|
+
'fks.appscheme.code': { eq: collection() },
|
|
21
|
+
'fks.appscheme_view_type.code': { eq: viewName },
|
|
22
|
+
})
|
|
23
|
+
: null);
|
|
24
|
+
const fieldNames = $derived([
|
|
25
|
+
...new Set((viewRows?.records ?? [])
|
|
26
|
+
.slice()
|
|
27
|
+
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
28
|
+
.map((r) => r?.fks?.appscheme_field?.code)
|
|
29
|
+
.filter((c) => !!c))
|
|
30
|
+
]);
|
|
31
|
+
// kind: scalar|fk per field, projected from the scheme's `fks{}` block onto the
|
|
32
|
+
// view's field list — lets a consumer iterating fieldNames know FK-ness without
|
|
33
|
+
// re-deriving descriptor() itself. Read-only projection; MachineSchemeValues.descriptor()
|
|
34
|
+
// stays the single source of truth.
|
|
35
|
+
const fieldKinds = $derived.by(() => {
|
|
36
|
+
const name = collection();
|
|
37
|
+
const collLogic = name ? machine.logic.collection(name) : null;
|
|
38
|
+
const out = {};
|
|
39
|
+
if (!collLogic)
|
|
40
|
+
return out;
|
|
41
|
+
for (const fieldName of fieldNames) {
|
|
42
|
+
out[fieldName] = collLogic.collectionValues.descriptor(fieldName);
|
|
43
|
+
}
|
|
44
|
+
return out;
|
|
45
|
+
});
|
|
46
|
+
// ── groupFieldBy axis → query appscheme_field ONLY when grouping is asked ───
|
|
47
|
+
const groupKey = $derived(groupFieldBy?.());
|
|
48
|
+
const fieldStore = $derived(groupKey && fieldNames.length
|
|
49
|
+
? machine.store('appscheme_field', { code: { in: fieldNames } })
|
|
50
|
+
: null);
|
|
51
|
+
const groups = $derived(groupKey && fieldStore?.records?.length
|
|
52
|
+
? fieldStore.records.groupBy(`fks.${groupKey}.code`, true)
|
|
53
|
+
: undefined);
|
|
54
|
+
return {
|
|
55
|
+
get fieldNames() { return fieldNames; },
|
|
56
|
+
get fieldKinds() { return fieldKinds; },
|
|
57
|
+
get groups() { return groups; },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RelationPolicy, MetaModelProvider, UserScopePolicy, RightsPolicy, Capabilities, FrameCatalog } from '../main/ext/interfaces.js';
|
|
2
|
+
import type { MachineModel } from '../types/index.js';
|
|
3
|
+
import { IdaeRelationPolicy } from './relations/RelationPolicy.js';
|
|
4
|
+
import { IdaeUserScopePolicy } from './userscope/UserScopePolicy.js';
|
|
5
|
+
import { IdaeMetaModelProvider } from './meta/MetaModelProvider.js';
|
|
6
|
+
import { IdaeRightsPolicy } from './rights/RightsPolicy.js';
|
|
7
|
+
import { IdaeCapabilities } from './capabilities/Capabilities.js';
|
|
8
|
+
import { IdaeFrameCatalog } from './frames/FrameCatalog.js';
|
|
9
|
+
declare const relationPolicy: IdaeRelationPolicy;
|
|
10
|
+
declare const userScopePolicy: IdaeUserScopePolicy;
|
|
11
|
+
declare const metaModelProvider: IdaeMetaModelProvider;
|
|
12
|
+
declare const rightsPolicy: IdaeRightsPolicy;
|
|
13
|
+
declare const capabilities: IdaeCapabilities;
|
|
14
|
+
declare const frameCatalog: IdaeFrameCatalog;
|
|
15
|
+
export interface PolicyRegistry {
|
|
16
|
+
relation?: RelationPolicy;
|
|
17
|
+
meta?: MetaModelProvider;
|
|
18
|
+
userScope?: UserScopePolicy;
|
|
19
|
+
rights?: RightsPolicy;
|
|
20
|
+
capabilities?: Capabilities;
|
|
21
|
+
frameCatalog?: FrameCatalog;
|
|
22
|
+
}
|
|
23
|
+
export declare function registerPolicy<T extends keyof PolicyRegistry>(policyName: T, implementation: PolicyRegistry[T]): void;
|
|
24
|
+
export declare function getPolicyRegistry(): PolicyRegistry;
|
|
25
|
+
export declare function initializeDomainPoliciesWithMachine(machine: any): void;
|
|
26
|
+
export declare function initializeDomainPoliciesWithModel(model: MachineModel): void;
|
|
27
|
+
export declare function initializeDomainPolicies(): void;
|
|
28
|
+
export { relationPolicy, userScopePolicy, metaModelProvider, rightsPolicy, capabilities, frameCatalog };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// idae/boot.ts — domain policy registration
|
|
2
|
+
// Registers all idae domain implementations with the machine engine.
|
|
3
|
+
import { IdaeRelationPolicy } from './relations/RelationPolicy.js';
|
|
4
|
+
import { IdaeUserScopePolicy } from './userscope/UserScopePolicy.js';
|
|
5
|
+
import { IdaeMetaModelProvider } from './meta/MetaModelProvider.js';
|
|
6
|
+
import { IdaeRightsPolicy } from './rights/RightsPolicy.js';
|
|
7
|
+
import { IdaeCapabilities } from './capabilities/Capabilities.js';
|
|
8
|
+
import { IdaeFrameCatalog } from './frames/FrameCatalog.js';
|
|
9
|
+
import { registerDomainBridges } from './bridge/register.js';
|
|
10
|
+
const relationPolicy = new IdaeRelationPolicy();
|
|
11
|
+
const userScopePolicy = new IdaeUserScopePolicy();
|
|
12
|
+
const metaModelProvider = new IdaeMetaModelProvider();
|
|
13
|
+
const rightsPolicy = new IdaeRightsPolicy();
|
|
14
|
+
const capabilities = new IdaeCapabilities();
|
|
15
|
+
const frameCatalog = new IdaeFrameCatalog();
|
|
16
|
+
let policyRegistry = {};
|
|
17
|
+
export function registerPolicy(policyName, implementation) {
|
|
18
|
+
policyRegistry[policyName] = implementation;
|
|
19
|
+
}
|
|
20
|
+
export function getPolicyRegistry() {
|
|
21
|
+
return policyRegistry;
|
|
22
|
+
}
|
|
23
|
+
export function initializeDomainPoliciesWithMachine(machine) {
|
|
24
|
+
relationPolicy.initialize(machine);
|
|
25
|
+
userScopePolicy.initialize(machine);
|
|
26
|
+
registerPolicy('relation', relationPolicy);
|
|
27
|
+
registerPolicy('userScope', userScopePolicy);
|
|
28
|
+
registerDomainBridges(relationPolicy, metaModelProvider, rightsPolicy);
|
|
29
|
+
}
|
|
30
|
+
export function initializeDomainPoliciesWithModel(model) {
|
|
31
|
+
metaModelProvider.initialize(model);
|
|
32
|
+
rightsPolicy.initialize(model);
|
|
33
|
+
capabilities.initialize(model);
|
|
34
|
+
registerPolicy('meta', metaModelProvider);
|
|
35
|
+
registerPolicy('rights', rightsPolicy);
|
|
36
|
+
registerPolicy('capabilities', capabilities);
|
|
37
|
+
registerPolicy('frameCatalog', frameCatalog);
|
|
38
|
+
registerDomainBridges(relationPolicy, metaModelProvider, rightsPolicy);
|
|
39
|
+
}
|
|
40
|
+
export function initializeDomainPolicies() {
|
|
41
|
+
// stub — call initializeDomainPoliciesWithMachine + initializeDomainPoliciesWithModel for full init
|
|
42
|
+
}
|
|
43
|
+
export { relationPolicy, userScopePolicy, metaModelProvider, rightsPolicy, capabilities, frameCatalog };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IdaeRelationPolicy } from '../relations/RelationPolicy.js';
|
|
2
|
+
import type { IdaeMetaModelProvider } from '../meta/MetaModelProvider.js';
|
|
3
|
+
import type { IdaeRightsPolicy } from '../rights/RightsPolicy.js';
|
|
4
|
+
export declare function registerDomainBridges(relationPolicy: IdaeRelationPolicy, metaModelProvider: IdaeMetaModelProvider, rightsPolicy: IdaeRightsPolicy): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// idae/bridge/register.ts
|
|
2
|
+
// Registers all domain implementations with the engine bridge hooks.
|
|
3
|
+
// Called once during boot — after this, engine files can delegate to domain
|
|
4
|
+
// via the abstract hooks without importing from idae/.
|
|
5
|
+
import { registerRelationResolver, registerMetaCollectionResolver, registerCodeFieldConvention, registerGrantDecoder } from '../../main/ext/hooks.js';
|
|
6
|
+
import { ensureCodeField, CODE_FIELD_NAME } from '../codefield/CodeFieldConvention.js';
|
|
7
|
+
export function registerDomainBridges(relationPolicy, metaModelProvider, rightsPolicy) {
|
|
8
|
+
registerRelationResolver(relationPolicy);
|
|
9
|
+
registerMetaCollectionResolver(metaModelProvider);
|
|
10
|
+
registerCodeFieldConvention({
|
|
11
|
+
codeFieldName: CODE_FIELD_NAME,
|
|
12
|
+
ensureCodeField
|
|
13
|
+
});
|
|
14
|
+
registerGrantDecoder(rightsPolicy);
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Capabilities as CapabilitiesInterface } from '../../main/ext/interfaces.js';
|
|
2
|
+
import type { MachineModel } from '../../types/index.js';
|
|
3
|
+
export declare class IdaeCapabilities implements CapabilitiesInterface {
|
|
4
|
+
private model;
|
|
5
|
+
initialize(model: MachineModel): void;
|
|
6
|
+
statusField(collection: string): string | null;
|
|
7
|
+
typeField(collection: string): string | null;
|
|
8
|
+
groupField(collection: string): string | null;
|
|
9
|
+
workflowOrder(_collection: string): string[];
|
|
10
|
+
}
|