@medyll/idae-machine 0.135.2 → 0.136.2
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
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { MachineDb } from '../machineDb.js';
|
|
2
2
|
import { MachineError } from './MachineError.js';
|
|
3
3
|
import { SchemeFieldDefaultValues } from './SchemeFieldDefaultValues.js';
|
|
4
|
+
import { MachineSchemeFieldType } from './MachineFieldType.js';
|
|
5
|
+
import { getRelationResolver } from '../ext/hooks.js';
|
|
6
|
+
/** Walk a plain dot-path into an object (no FK awareness). */
|
|
7
|
+
function walkPath(root, segments) {
|
|
8
|
+
return segments.reduce((acc, key) => (acc != null && typeof acc === 'object') ? acc[key] : undefined, root);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a presentation token against a record.
|
|
12
|
+
* Delegates to the domain bridge first; falls back to built-in bag walk.
|
|
13
|
+
*/
|
|
14
|
+
function resolvePresentationToken(data, token) {
|
|
15
|
+
const segments = token.split('.');
|
|
16
|
+
const resolver = getRelationResolver();
|
|
17
|
+
if (resolver?.resolvePresentationToken && segments.length >= 2) {
|
|
18
|
+
const resolved = resolver.resolvePresentationToken(data, segments);
|
|
19
|
+
if (resolved !== undefined)
|
|
20
|
+
return resolved;
|
|
21
|
+
}
|
|
22
|
+
// Fallback: plain path walk (also handles bare fks.<base>.<field> for tests without domain)
|
|
23
|
+
return walkPath(data, segments);
|
|
24
|
+
}
|
|
4
25
|
/**
|
|
5
26
|
* @class MachineSchemeValues
|
|
6
27
|
* @role Provides utilities to display, format, and introspect field values for a given collection, using the schema and provided data.
|
|
@@ -31,20 +52,30 @@ export class MachineSchemeValues {
|
|
|
31
52
|
/**
|
|
32
53
|
* Get the presentation string for a data object, using the collection's presentation template.
|
|
33
54
|
* @role Presentation logic
|
|
34
|
-
* @param {Record<string,
|
|
55
|
+
* @param {Record<string, unknown>} data The data object.
|
|
35
56
|
* @return {string} The formatted presentation string.
|
|
36
57
|
*/
|
|
37
58
|
presentation(data) {
|
|
38
59
|
try {
|
|
39
|
-
this
|
|
40
|
-
const presentation =
|
|
60
|
+
const scheme = this.machine.collection(this.collectionName);
|
|
61
|
+
const presentation = scheme.template?.presentation;
|
|
41
62
|
this.#checkError(!presentation, 'Presentation template not found', 'TEMPLATE_NOT_FOUND');
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
.map((
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
const tokens = presentation.split(' ').filter(Boolean);
|
|
64
|
+
return tokens
|
|
65
|
+
.map((token) => {
|
|
66
|
+
// Dot notation: 'fks.firm.name', 'address.city', etc.
|
|
67
|
+
const value = resolvePresentationToken(data, token);
|
|
68
|
+
if (value === null || value === undefined)
|
|
69
|
+
return '';
|
|
70
|
+
// For dot-notation tokens, skip type-aware formatting (no field metadata at depth).
|
|
71
|
+
if (token.includes('.'))
|
|
72
|
+
return String(value);
|
|
73
|
+
const fieldInfo = scheme.field(token).parse();
|
|
74
|
+
return fieldInfo?.fieldType
|
|
75
|
+
? MachineSchemeFieldType.format(value, fieldInfo.fieldType)
|
|
76
|
+
: String(value);
|
|
47
77
|
})
|
|
78
|
+
.filter(Boolean)
|
|
48
79
|
.join(' ');
|
|
49
80
|
}
|
|
50
81
|
catch (error) {
|
|
@@ -60,13 +91,12 @@ export class MachineSchemeValues {
|
|
|
60
91
|
/**
|
|
61
92
|
* Get the value of the index field for a data object.
|
|
62
93
|
* @role Index accessor
|
|
63
|
-
* @param {Record<string,
|
|
64
|
-
* @return {
|
|
94
|
+
* @param {Record<string, unknown>} data The data object.
|
|
95
|
+
* @return {unknown | null} The value of the index field, or null if not found.
|
|
65
96
|
*/
|
|
66
97
|
indexValue(data) {
|
|
67
98
|
try {
|
|
68
|
-
this
|
|
69
|
-
const indexName = this.machine.collection(this.collectionName).template.index;
|
|
99
|
+
const indexName = this.machine.collection(this.collectionName).index;
|
|
70
100
|
this.#checkError(!indexName, 'Index not found for collection', 'INDEX_NOT_FOUND');
|
|
71
101
|
this.#checkError(!(indexName in data), `Index field ${indexName} not found in data`, 'FIELD_NOT_FOUND');
|
|
72
102
|
return data[indexName];
|
|
@@ -91,26 +121,16 @@ export class MachineSchemeValues {
|
|
|
91
121
|
*/
|
|
92
122
|
format(fieldName, data) {
|
|
93
123
|
try {
|
|
94
|
-
this.#checkError(!this.#checkAccess(), 'Access denied', 'ACCESS_DENIED');
|
|
95
124
|
this.#checkError(!(fieldName in data), `Field ${String(fieldName)} not found in data`, 'FIELD_NOT_FOUND');
|
|
96
|
-
const fieldInfo = this.machine
|
|
125
|
+
const fieldInfo = this.machine
|
|
126
|
+
.collection(this.collectionName)
|
|
127
|
+
.field(String(fieldName))
|
|
128
|
+
.parse();
|
|
97
129
|
this.#checkError(!fieldInfo, `Field ${String(fieldName)} not found in collection`, 'FIELD_NOT_FOUND');
|
|
98
130
|
if (!fieldInfo) {
|
|
99
131
|
return String(data[fieldName]);
|
|
100
132
|
}
|
|
101
|
-
|
|
102
|
-
case 'number':
|
|
103
|
-
return this.#formatNumberField(data[fieldName]);
|
|
104
|
-
case 'text':
|
|
105
|
-
case 'text-tiny':
|
|
106
|
-
case 'text-short':
|
|
107
|
-
case 'text-medium':
|
|
108
|
-
case 'text-long':
|
|
109
|
-
case 'text-giant':
|
|
110
|
-
return this.#formatTextField(data[fieldName], fieldInfo.fieldType);
|
|
111
|
-
default:
|
|
112
|
-
return String(data[fieldName]);
|
|
113
|
-
}
|
|
133
|
+
return MachineSchemeFieldType.format(data[fieldName], fieldInfo.fieldType);
|
|
114
134
|
}
|
|
115
135
|
catch (error) {
|
|
116
136
|
MachineError.handleError(error);
|
|
@@ -134,13 +154,17 @@ export class MachineSchemeValues {
|
|
|
134
154
|
const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
|
|
135
155
|
const fieldType = fieldInfo?.fieldType ?? '';
|
|
136
156
|
const fieldArgs = fieldInfo?.fieldArgs?.join(' ') ?? '';
|
|
137
|
-
const
|
|
157
|
+
const inputSize = fieldInfo?.inputSize ?? '';
|
|
158
|
+
const indexName = this.machine.collection(this.collectionName).index;
|
|
138
159
|
return {
|
|
139
160
|
'data-collection': this.collectionName,
|
|
140
|
-
'data-
|
|
161
|
+
'data-collection-id': indexName && data?.[indexName] !== undefined
|
|
162
|
+
? String(data?.[indexName])
|
|
163
|
+
: '',
|
|
141
164
|
'data-fieldName': String(fieldName),
|
|
142
165
|
'data-fieldType': fieldType,
|
|
143
|
-
'data-fieldArgs': fieldArgs
|
|
166
|
+
'data-fieldArgs': fieldArgs,
|
|
167
|
+
'data-inputSize': inputSize
|
|
144
168
|
};
|
|
145
169
|
}
|
|
146
170
|
/**
|
|
@@ -153,11 +177,10 @@ export class MachineSchemeValues {
|
|
|
153
177
|
* Iterate over an array field and return an array of IDbForge objects for each element.
|
|
154
178
|
* @role Array field iteration
|
|
155
179
|
* @param {keyof TplFields} fieldName The field name.
|
|
156
|
-
* @param {
|
|
157
|
-
* @return {
|
|
180
|
+
* @param {unknown[]} data The array data.
|
|
181
|
+
* @return {Array<Record<string, unknown>>} An array of IDbForge objects.
|
|
158
182
|
*/
|
|
159
|
-
// NOTE: Return type is
|
|
160
|
-
// TODO: Refine IDbForge type if needed for stricter typing
|
|
183
|
+
// NOTE: Return type is Array<Record<string, unknown>> to match actual runtime type from parser
|
|
161
184
|
iterateArrayField(fieldName, data) {
|
|
162
185
|
const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
|
|
163
186
|
if (fieldInfo?.is !== 'array' || !Array.isArray(data)) {
|
|
@@ -165,25 +188,20 @@ export class MachineSchemeValues {
|
|
|
165
188
|
}
|
|
166
189
|
return data
|
|
167
190
|
.map((_, idx) => fieldInfo && fieldInfo.fieldType
|
|
168
|
-
? {
|
|
191
|
+
? {
|
|
192
|
+
...fieldInfo,
|
|
193
|
+
fieldName: `${String(fieldName)}[${idx}]`,
|
|
194
|
+
collection: this.collectionName
|
|
195
|
+
}
|
|
169
196
|
: undefined)
|
|
170
|
-
.filter(
|
|
197
|
+
.filter((x) => x !== undefined);
|
|
171
198
|
}
|
|
172
199
|
/**
|
|
173
|
-
* Iterate over an object field and return
|
|
200
|
+
* Iterate over an object field and return data rows keyed by property name.
|
|
174
201
|
* @param fieldName The field name.
|
|
175
202
|
* @param data The object data.
|
|
176
|
-
* @returns
|
|
177
|
-
*/
|
|
178
|
-
/**
|
|
179
|
-
* Iterate over an object field and return an array of IDbForge objects for each property.
|
|
180
|
-
* @role Object field iteration
|
|
181
|
-
* @param {keyof TplFields} fieldName The field name.
|
|
182
|
-
* @param {Record<string, unknown>} data The object data.
|
|
183
|
-
* @return {IDbForge[]} An array of IDbForge objects.
|
|
203
|
+
* @returns Data rows derived from the object's properties.
|
|
184
204
|
*/
|
|
185
|
-
// NOTE: Return type is any[] to match actual runtime type from parser (fieldArgs may be string)
|
|
186
|
-
// TODO: Refine IDbForge type if needed for stricter typing
|
|
187
205
|
iterateObjectField(fieldName, data) {
|
|
188
206
|
const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
|
|
189
207
|
if (fieldInfo?.is !== 'object' || typeof data !== 'object' || data === null) {
|
|
@@ -191,62 +209,13 @@ export class MachineSchemeValues {
|
|
|
191
209
|
}
|
|
192
210
|
return Object.keys(data)
|
|
193
211
|
.map((key) => fieldInfo && fieldInfo.fieldType
|
|
194
|
-
? {
|
|
212
|
+
? {
|
|
213
|
+
...fieldInfo,
|
|
214
|
+
fieldName: `${String(fieldName)}.${key}`,
|
|
215
|
+
collection: this.collectionName
|
|
216
|
+
}
|
|
195
217
|
: undefined)
|
|
196
|
-
.filter(
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Internal: Format a number field for display.
|
|
200
|
-
* @param value The number value.
|
|
201
|
-
* @returns The formatted string.
|
|
202
|
-
*/
|
|
203
|
-
/**
|
|
204
|
-
* Internal: Format a number field for display.
|
|
205
|
-
* @role Number formatting
|
|
206
|
-
* @param {number} value The number value.
|
|
207
|
-
* @return {string} The formatted string.
|
|
208
|
-
*/
|
|
209
|
-
#formatNumberField(value) {
|
|
210
|
-
// Implement number formatting logic here
|
|
211
|
-
return value.toString();
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Internal: Format a text field for display, with length limits by type.
|
|
215
|
-
* @param value The string value.
|
|
216
|
-
* @param type The text type (e.g. 'text-short').
|
|
217
|
-
* @returns The formatted string.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* Internal: Format a text field for display, with length limits by type.
|
|
221
|
-
* @role Text formatting
|
|
222
|
-
* @param {unknown} value The string value.
|
|
223
|
-
* @param {string} type The text type (e.g. 'text-short').
|
|
224
|
-
* @return {string} The formatted string.
|
|
225
|
-
*/
|
|
226
|
-
#formatTextField(value, type) {
|
|
227
|
-
const lengths = {
|
|
228
|
-
'text-tiny': 10,
|
|
229
|
-
'text-short': 20,
|
|
230
|
-
'text-medium': 30,
|
|
231
|
-
'text-long': 40,
|
|
232
|
-
'text-giant': 50
|
|
233
|
-
};
|
|
234
|
-
const str = typeof value === 'string' ? value : String(value ?? '');
|
|
235
|
-
const maxLength = lengths[type] || str.length;
|
|
236
|
-
return str.substring(0, maxLength);
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Internal: Check if access is allowed (override for custom logic).
|
|
240
|
-
* @returns True if access is allowed.
|
|
241
|
-
*/
|
|
242
|
-
/**
|
|
243
|
-
* Internal: Check if access is allowed (override for custom logic).
|
|
244
|
-
* @role Access check
|
|
245
|
-
* @return {boolean} True if access is allowed.
|
|
246
|
-
*/
|
|
247
|
-
#checkAccess() {
|
|
248
|
-
// Implement access check logic here
|
|
249
|
-
return true;
|
|
218
|
+
.filter((x) => x !== undefined);
|
|
250
219
|
}
|
|
251
220
|
/**
|
|
252
221
|
* Internal: Throw an error if a condition is met.
|
|
@@ -266,13 +235,72 @@ export class MachineSchemeValues {
|
|
|
266
235
|
MachineError.throwError(message, code);
|
|
267
236
|
}
|
|
268
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Resolved descriptor for a single field — the machine-native equivalent of the legacy
|
|
240
|
+
* `columnModel[]` entry. Scalar-vs-FK divergence is decided HERE, never in a component.
|
|
241
|
+
*/
|
|
242
|
+
descriptor(fieldName) {
|
|
243
|
+
try {
|
|
244
|
+
const scheme = this.machine.collection(this.collectionName);
|
|
245
|
+
// FK detection from the structured `fks` block (canonical). The relation key
|
|
246
|
+
// is the field name; the join index is the semantic `code`. No magic-string
|
|
247
|
+
// fieldType parsing — the synthesized `fk-X.code` field is deprecated.
|
|
248
|
+
const fkDef = scheme.fks?.[fieldName];
|
|
249
|
+
if (fkDef?.code) {
|
|
250
|
+
return {
|
|
251
|
+
kind: 'fk',
|
|
252
|
+
fieldName,
|
|
253
|
+
fieldType: `fk-${fkDef.code}.code`,
|
|
254
|
+
title: fieldName,
|
|
255
|
+
fkCollection: fkDef.code,
|
|
256
|
+
fkIndexField: 'code'
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const info = scheme.field(fieldName).parse();
|
|
260
|
+
if (!info)
|
|
261
|
+
return null;
|
|
262
|
+
const type = (info.fieldType ?? '');
|
|
263
|
+
const title = info.title ?? fieldName;
|
|
264
|
+
return { kind: 'scalar', fieldName, fieldType: type, title };
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Human-readable display value for a field.
|
|
272
|
+
* Scalar → MachineSchemeFieldType.format(). FK → presentation(targetRecord).
|
|
273
|
+
* `resolveTarget` is injected by the caller (keeps this class pure/testable).
|
|
274
|
+
*/
|
|
275
|
+
displayValue(fieldName, data, resolveTarget) {
|
|
276
|
+
const d = this.descriptor(String(fieldName));
|
|
277
|
+
if (!d)
|
|
278
|
+
return String(data[fieldName] ?? '');
|
|
279
|
+
if (d.kind === 'scalar') {
|
|
280
|
+
return MachineSchemeFieldType.format(data[fieldName], d.fieldType);
|
|
281
|
+
}
|
|
282
|
+
// FK path — resolve target record, then use its presentation template
|
|
283
|
+
const raw = data[fieldName];
|
|
284
|
+
if (raw == null)
|
|
285
|
+
return '—';
|
|
286
|
+
const target = resolveTarget?.(d.fkCollection, d.fkIndexField, raw);
|
|
287
|
+
if (!target)
|
|
288
|
+
return String(raw);
|
|
289
|
+
try {
|
|
290
|
+
const fkValues = new MachineSchemeValues(d.fkCollection, this.machine);
|
|
291
|
+
return fkValues.presentation(target) || String(raw);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return String(raw);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
269
297
|
/**
|
|
270
298
|
* Get default values for the collection, using global and collection-specific factories.
|
|
271
299
|
* @role Default values
|
|
272
|
-
* @returns {Record<string,
|
|
300
|
+
* @returns {Record<string, unknown>} An object with default values for each field in the collection.
|
|
273
301
|
*/
|
|
274
302
|
getDefaults() {
|
|
275
|
-
const fields = Object.keys(this.machine.collection(this.collectionName).
|
|
303
|
+
const fields = Object.keys(this.machine.collection(this.collectionName).fields || {});
|
|
276
304
|
return SchemeFieldDefaultValues.getDefaults(fields, this.collectionName);
|
|
277
305
|
}
|
|
278
306
|
}
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
* // To set multiple defaults for a collection:
|
|
28
28
|
* SchemeFieldDefaultValues.setDefaults({ status: () => 'pending' }, 'orders');
|
|
29
29
|
*/
|
|
30
|
-
import type { TplCollectionName } from
|
|
30
|
+
import type { TplCollectionName } from '../../types/index.js';
|
|
31
31
|
export declare class SchemeFieldDefaultValues {
|
|
32
32
|
/**
|
|
33
33
|
* Default value factories for all collections (global fields).
|
|
34
34
|
* Each key is a field name, value is a function returning the default value.
|
|
35
|
+
* Using `any` return type is intentional: factories must work with all field types.
|
|
35
36
|
* @type {Record<string, () => any>}
|
|
36
37
|
*/
|
|
37
38
|
static defaultFieldFactories: Record<string, () => any>;
|
|
38
39
|
/**
|
|
39
40
|
* Default value factories per collection.
|
|
40
41
|
* Each key is a collection name, value is an object of field factories.
|
|
42
|
+
* Using `any` return type is intentional: factories must work with all field types.
|
|
41
43
|
* @type {Record<string, Record<string, () => any>>}
|
|
42
44
|
*/
|
|
43
45
|
static defaultCollectionFactories: Record<string, Record<string, () => any>>;
|
|
@@ -70,5 +72,5 @@ export declare class SchemeFieldDefaultValues {
|
|
|
70
72
|
* @param {TplCollectionName} [collectionName] - Optional collection name for specific default.
|
|
71
73
|
* @returns {any} The default value for the field, or undefined if none.
|
|
72
74
|
*/
|
|
73
|
-
static getDefault(field: string, collectionName?: TplCollectionName):
|
|
75
|
+
static getDefault(field: string, collectionName?: TplCollectionName): unknown;
|
|
74
76
|
}
|
|
@@ -5,19 +5,23 @@ export class SchemeFieldDefaultValues {
|
|
|
5
5
|
/**
|
|
6
6
|
* Default value factories for all collections (global fields).
|
|
7
7
|
* Each key is a field name, value is a function returning the default value.
|
|
8
|
+
* Using `any` return type is intentional: factories must work with all field types.
|
|
8
9
|
* @type {Record<string, () => any>}
|
|
9
10
|
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
12
|
static defaultFieldFactories = {
|
|
11
13
|
createdAt: () => new Date(),
|
|
12
14
|
updatedAt: () => new Date(),
|
|
13
|
-
status: () =>
|
|
15
|
+
status: () => 'draft'
|
|
14
16
|
// Add more global defaults here
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Default value factories per collection.
|
|
18
20
|
* Each key is a collection name, value is an object of field factories.
|
|
21
|
+
* Using `any` return type is intentional: factories must work with all field types.
|
|
19
22
|
* @type {Record<string, Record<string, () => any>>}
|
|
20
23
|
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
25
|
static defaultCollectionFactories = {
|
|
22
26
|
// Example:
|
|
23
27
|
// agents: {
|
|
@@ -68,7 +72,9 @@ export class SchemeFieldDefaultValues {
|
|
|
68
72
|
*/
|
|
69
73
|
static getDefaults(fields, collectionName) {
|
|
70
74
|
const result = {};
|
|
71
|
-
const collectionDefaults = collectionName
|
|
75
|
+
const collectionDefaults = collectionName
|
|
76
|
+
? this.defaultCollectionFactories[collectionName] || {}
|
|
77
|
+
: {};
|
|
72
78
|
for (const field of fields) {
|
|
73
79
|
if (collectionDefaults[field]) {
|
|
74
80
|
result[field] = collectionDefaults[field]();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* authState — reactive client auth gate.
|
|
3
|
+
*
|
|
4
|
+
* A tiny `$state`-backed signal so the boot layout can react to login success.
|
|
5
|
+
* Props/callbacks can't cross the framer mount boundary (the login dialog is
|
|
6
|
+
* mounted dynamically, not as a child of `+layout`), so this module is the
|
|
7
|
+
* shared channel between `Login.svelte` and the gate in `+layout.svelte`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const authState: {
|
|
10
|
+
authed: boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* authState — reactive client auth gate.
|
|
3
|
+
*
|
|
4
|
+
* A tiny `$state`-backed signal so the boot layout can react to login success.
|
|
5
|
+
* Props/callbacks can't cross the framer mount boundary (the login dialog is
|
|
6
|
+
* mounted dynamically, not as a child of `+layout`), so this module is the
|
|
7
|
+
* shared channel between `Login.svelte` and the gate in `+layout.svelte`.
|
|
8
|
+
*/
|
|
9
|
+
let _authed = $state(false);
|
|
10
|
+
export const authState = {
|
|
11
|
+
get authed() {
|
|
12
|
+
return _authed;
|
|
13
|
+
},
|
|
14
|
+
set authed(v) {
|
|
15
|
+
_authed = v;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MachineFieldDef, ImageFieldDef, InputSize } from '../../types/index.js';
|
|
2
|
+
type BaseFieldOptions = {
|
|
3
|
+
required?: boolean;
|
|
4
|
+
readonly?: boolean;
|
|
5
|
+
private?: boolean;
|
|
6
|
+
inputSize?: InputSize;
|
|
7
|
+
};
|
|
8
|
+
type ImageFieldOptions = Omit<ImageFieldDef, 'type'>;
|
|
9
|
+
/**
|
|
10
|
+
* Builder helper for machine field declarations.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* fields: {
|
|
14
|
+
* id: field('id', { readonly: true }),
|
|
15
|
+
* name: field('text', { required: true }),
|
|
16
|
+
* catId: field('fk-category.id'),
|
|
17
|
+
* photo: field('image', { presets: ['thumb', 'banner'] }),
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
export declare function field(type: 'image', opts?: ImageFieldOptions): ImageFieldDef;
|
|
21
|
+
export declare function field(type: string, opts?: BaseFieldOptions): MachineFieldDef;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=fieldBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldBuilder.d.ts","sourceRoot":"","sources":["fieldBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErF,KAAK,gBAAgB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAC7G,KAAK,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;AAC9E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAG,IAAI,CAAC,EAAE,gBAAgB,GAAI,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function field(type, opts) {
|
|
2
|
+
if (type === 'image') {
|
|
3
|
+
const o = opts;
|
|
4
|
+
if (o?.preset && o?.presets)
|
|
5
|
+
throw new Error('Use preset OR presets, not both');
|
|
6
|
+
const hasPresets = !!(o?.presets ?? o?.preset);
|
|
7
|
+
return { type: 'image', ...o, free: o?.free ?? (hasPresets ? false : true) };
|
|
8
|
+
}
|
|
9
|
+
return { type, ...opts };
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldBuilder.js","sourceRoot":"","sources":["fieldBuilder.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,KAAK,CACpB,IAAY,EACZ,IAA2C;IAE3C,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,IAAqC,CAAC;QAChD,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAChF,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,GAAI,IAAyB,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MachineDb } from '../machineDb.js';
|
|
2
|
+
type FetchRecord = (collection: string, id: string | number) => Promise<Record<string, unknown> | undefined>;
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a human-readable label for a record, using the collection's presentation template.
|
|
5
|
+
* Composes an injected async fetch with MachineSchemeValues.presentation() — which handles
|
|
6
|
+
* plain paths AND FK paths (fks.firm.name), unlike the former inline token walk.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from machine.ts._renderLabel.
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderLabel(machineDb: MachineDb, fetchRecord: FetchRecord, collection: string, collectionId: string | number): Promise<string | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MachineDb } from '../machineDb.js';
|
|
2
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a human-readable label for a record, using the collection's presentation template.
|
|
5
|
+
* Composes an injected async fetch with MachineSchemeValues.presentation() — which handles
|
|
6
|
+
* plain paths AND FK paths (fks.firm.name), unlike the former inline token walk.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from machine.ts._renderLabel.
|
|
9
|
+
*/
|
|
10
|
+
export async function renderLabel(machineDb, fetchRecord, collection, collectionId) {
|
|
11
|
+
try {
|
|
12
|
+
const id = isNaN(Number(collectionId)) ? collectionId : Number(collectionId);
|
|
13
|
+
const rec = await fetchRecord(collection, id);
|
|
14
|
+
if (!rec)
|
|
15
|
+
return undefined;
|
|
16
|
+
const values = new MachineSchemeValues(collection, machineDb);
|
|
17
|
+
const label = values.presentation(rec);
|
|
18
|
+
return label || undefined;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure validation rules — no browser/Svelte dependencies.
|
|
3
|
+
* Used by both client (MachineSchemeValidate) and server (domain actions).
|
|
4
|
+
*
|
|
5
|
+
* Legacy PHP InputValidator.php rules ported:
|
|
6
|
+
* validateInt, validateEmail, validateDate, validateUrl,
|
|
7
|
+
* validateCp (code postal FR), validateAlpha, validateAlphanum
|
|
8
|
+
*/
|
|
9
|
+
export type FieldRule = {
|
|
10
|
+
required?: boolean;
|
|
11
|
+
type?: string;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
minLength?: number;
|
|
15
|
+
maxLength?: number;
|
|
16
|
+
pattern?: RegExp | string;
|
|
17
|
+
};
|
|
18
|
+
export type ValidationResult = {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
errors: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Validate a single field value against a rule.
|
|
24
|
+
* Returns null if valid, error message string if invalid.
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateField(value: unknown, rule: FieldRule): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Validate a complete record against a field rules map.
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateRecord(data: Record<string, unknown>, fields: Record<string, FieldRule>): ValidationResult;
|
|
31
|
+
/**
|
|
32
|
+
* Get all supported type names.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getSupportedTypes(): string[];
|
|
35
|
+
/**
|
|
36
|
+
* Register a custom type validator.
|
|
37
|
+
*/
|
|
38
|
+
export declare function registerTypeValidator(type: string, validator: (value: unknown) => boolean | string): void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure validation rules — no browser/Svelte dependencies.
|
|
3
|
+
* Used by both client (MachineSchemeValidate) and server (domain actions).
|
|
4
|
+
*
|
|
5
|
+
* Legacy PHP InputValidator.php rules ported:
|
|
6
|
+
* validateInt, validateEmail, validateDate, validateUrl,
|
|
7
|
+
* validateCp (code postal FR), validateAlpha, validateAlphanum
|
|
8
|
+
*/
|
|
9
|
+
// ── Type validators ──────────────────────────────────────────────────────────
|
|
10
|
+
const validators = {
|
|
11
|
+
email: (v) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(v)) || 'Format email invalide',
|
|
12
|
+
url: (v) => {
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(String(v));
|
|
15
|
+
if (!['http:', 'https:'].includes(url.protocol))
|
|
16
|
+
return 'URL doit commencer par http:// ou https://';
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 'URL invalide';
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
date: (v) => !isNaN(Date.parse(String(v))) || 'Format de date invalide',
|
|
24
|
+
datetime: (v) => !isNaN(Date.parse(String(v))) || 'Format date/heure invalide',
|
|
25
|
+
time: (v) => /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/.test(String(v)) || 'Format d\'heure invalide (HH:MM)',
|
|
26
|
+
number: (v) => !isNaN(Number(v)) || 'Doit être un nombre',
|
|
27
|
+
integer: (v) => Number.isInteger(Number(v)) || 'Doit être un entier',
|
|
28
|
+
boolean: (v) => (typeof v === 'boolean' || v === 'true' || v === 'false') || 'Doit être vrai ou faux',
|
|
29
|
+
phone: (v) => /^\+?[\d\s-]{10,}$/.test(String(v)) || 'Format de téléphone invalide',
|
|
30
|
+
cp: (v) => /^\d{5}$/.test(String(v)) || 'Code postal invalide (5 chiffres)',
|
|
31
|
+
alpha: (v) => /^[a-zA-ZÀ-ÿ\s'-]+$/.test(String(v)) || 'Ne doit contenir que des lettres',
|
|
32
|
+
alphanum: (v) => /^[a-zA-Z0-9À-ÿ\s'-]+$/.test(String(v)) || 'Ne doit contenir que des lettres et chiffres',
|
|
33
|
+
password: () => true,
|
|
34
|
+
text: () => true,
|
|
35
|
+
'text-area': () => true,
|
|
36
|
+
currency: (v) => !isNaN(Number(v)) || 'Montant invalide',
|
|
37
|
+
};
|
|
38
|
+
// ── Core validation ──────────────────────────────────────────────────────────
|
|
39
|
+
/**
|
|
40
|
+
* Validate a single field value against a rule.
|
|
41
|
+
* Returns null if valid, error message string if invalid.
|
|
42
|
+
*/
|
|
43
|
+
export function validateField(value, rule) {
|
|
44
|
+
// Required check
|
|
45
|
+
if (rule.required && (value === undefined || value === null || value === '')) {
|
|
46
|
+
return 'Ce champ est obligatoire';
|
|
47
|
+
}
|
|
48
|
+
// Skip further validation if empty and not required
|
|
49
|
+
if (value === undefined || value === null || value === '') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
// Type validation
|
|
53
|
+
if (rule.type) {
|
|
54
|
+
const typeValidator = validators[rule.type];
|
|
55
|
+
if (typeValidator) {
|
|
56
|
+
const result = typeValidator(value);
|
|
57
|
+
if (result !== true) {
|
|
58
|
+
return typeof result === 'string' ? result : 'Format invalide';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Pattern validation
|
|
63
|
+
if (rule.pattern) {
|
|
64
|
+
const regex = typeof rule.pattern === 'string' ? new RegExp(rule.pattern) : rule.pattern;
|
|
65
|
+
if (!regex.test(String(value))) {
|
|
66
|
+
return 'Format invalide';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Numeric range
|
|
70
|
+
if (rule.type && ['number', 'integer', 'currency'].includes(rule.type)) {
|
|
71
|
+
const num = Number(value);
|
|
72
|
+
if (rule.min !== undefined && num < rule.min)
|
|
73
|
+
return `Minimum ${rule.min}`;
|
|
74
|
+
if (rule.max !== undefined && num > rule.max)
|
|
75
|
+
return `Maximum ${rule.max}`;
|
|
76
|
+
}
|
|
77
|
+
// String length
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
if (rule.minLength !== undefined && value.length < rule.minLength)
|
|
80
|
+
return `Minimum ${rule.minLength} caractères`;
|
|
81
|
+
if (rule.maxLength !== undefined && value.length > rule.maxLength)
|
|
82
|
+
return `Maximum ${rule.maxLength} caractères`;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Validate a complete record against a field rules map.
|
|
88
|
+
*/
|
|
89
|
+
export function validateRecord(data, fields) {
|
|
90
|
+
const errors = {};
|
|
91
|
+
for (const [name, rule] of Object.entries(fields)) {
|
|
92
|
+
const error = validateField(data[name], rule);
|
|
93
|
+
if (error)
|
|
94
|
+
errors[name] = error;
|
|
95
|
+
}
|
|
96
|
+
return { valid: Object.keys(errors).length === 0, errors };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get all supported type names.
|
|
100
|
+
*/
|
|
101
|
+
export function getSupportedTypes() {
|
|
102
|
+
return Object.keys(validators);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Register a custom type validator.
|
|
106
|
+
*/
|
|
107
|
+
export function registerTypeValidator(type, validator) {
|
|
108
|
+
validators[type] = validator;
|
|
109
|
+
}
|