@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
|
@@ -1,146 +1,159 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { MachineError } from './MachineError.js';
|
|
2
|
+
import { indexFromKeyPath } from '../../types/index.js';
|
|
3
|
+
import { MachineDb } from '../machineDb.js';
|
|
4
|
+
import { getCollectionRelations } from '../../data-ui/utils/dataRelationUtils.js';
|
|
5
|
+
import { getRelationResolver } from '../ext/hooks.js';
|
|
6
|
+
import { MachineSchemeFieldForge } from './MachineSchemeFieldForge.js';
|
|
7
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
8
|
+
import { MachineSchemeValidate } from './MachineSchemeValidate.js';
|
|
9
|
+
import { MachineSchemeField } from './MachineSchemeField.js';
|
|
6
10
|
/**
|
|
7
11
|
* @class MachineScheme
|
|
8
|
-
* @role Provides schema and field utilities for a collection
|
|
12
|
+
* @role Provides schema and field utilities for a collection: metadata, formatting, field parsing.
|
|
9
13
|
*/
|
|
10
14
|
export class MachineScheme {
|
|
11
|
-
/** The collection name. */
|
|
12
15
|
collection;
|
|
13
|
-
|
|
14
|
-
#template;
|
|
15
|
-
/** The MachineDb instance. */
|
|
16
|
-
#machineDb;
|
|
17
|
-
/** The collection model. */
|
|
16
|
+
name;
|
|
18
17
|
#collectionModel;
|
|
18
|
+
#machineDb;
|
|
19
19
|
#model;
|
|
20
|
-
/**
|
|
21
|
-
* Create a new MachineScheme instance.
|
|
22
|
-
* @role Constructor
|
|
23
|
-
* @param {TplCollectionName} collectionName The collection name.
|
|
24
|
-
* @param {MachineDb} idbBase The MachineDb instance.
|
|
25
|
-
* @param {IdbqModel} model The IdbqModel instance.
|
|
26
|
-
*/
|
|
27
20
|
constructor(collectionName, idbBase, model) {
|
|
28
21
|
this.collection = collectionName;
|
|
22
|
+
this.name = collectionName;
|
|
29
23
|
this.#machineDb = idbBase;
|
|
30
24
|
this.#collectionModel = model[String(collectionName)];
|
|
31
|
-
|
|
25
|
+
if (!this.#collectionModel) {
|
|
26
|
+
throw new MachineError(`Collection '${collectionName}' not found in model.`, 'COLLECTION_NOT_FOUND');
|
|
27
|
+
}
|
|
32
28
|
this.#model = model;
|
|
33
29
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Get the collection model.
|
|
36
|
-
* @role Accessor
|
|
37
|
-
* @return {IdbqModel["Collection"]} The collection model.
|
|
38
|
-
*/
|
|
39
30
|
get model() {
|
|
40
31
|
return this.#collectionModel;
|
|
41
32
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the collection template.
|
|
44
|
-
* @role Accessor
|
|
45
|
-
* @return {Tpl} The collection template.
|
|
46
|
-
*/
|
|
33
|
+
/** Display template (presentation only). */
|
|
47
34
|
get template() {
|
|
48
|
-
return this.#template;
|
|
35
|
+
return this.#collectionModel.template ?? {};
|
|
36
|
+
}
|
|
37
|
+
/** Field definitions (data). */
|
|
38
|
+
get fields() {
|
|
39
|
+
return this.#collectionModel.fields ?? {};
|
|
40
|
+
}
|
|
41
|
+
/** Foreign key relations. */
|
|
42
|
+
get fks() {
|
|
43
|
+
return getCollectionRelations(this.collection) ?? {};
|
|
44
|
+
}
|
|
45
|
+
/** Primary key field name, derived from keyPath ('++id' → 'id'). */
|
|
46
|
+
get index() {
|
|
47
|
+
return indexFromKeyPath(this.#collectionModel.keyPath ?? '++id');
|
|
48
|
+
}
|
|
49
|
+
/** Default sort inferred from defaultSort or field naming/type conventions. */
|
|
50
|
+
get defaultSort() {
|
|
51
|
+
const explicitSort = this.#collectionModel.defaultSort;
|
|
52
|
+
if (explicitSort?.length)
|
|
53
|
+
return explicitSort;
|
|
54
|
+
const fields = this.fields;
|
|
55
|
+
const fieldNames = Object.keys(fields);
|
|
56
|
+
const ordreField = fieldNames.find(f => f === 'ordre' || f === 'order');
|
|
57
|
+
if (ordreField)
|
|
58
|
+
return [{ field: ordreField, direction: 'asc' }];
|
|
59
|
+
const nameField = fieldNames.find(f => ['name', 'nom', 'label', 'titre', 'title', 'code'].includes(f));
|
|
60
|
+
if (nameField)
|
|
61
|
+
return [{ field: nameField, direction: 'asc' }];
|
|
62
|
+
const updatedField = fieldNames.find(f => f === 'updatedAt' || f === 'dateModification');
|
|
63
|
+
if (updatedField)
|
|
64
|
+
return [{ field: updatedField, direction: 'desc' }];
|
|
65
|
+
const createdField = fieldNames.find(f => f === 'createdAt' || f === 'dateCreation');
|
|
66
|
+
if (createdField)
|
|
67
|
+
return [{ field: createdField, direction: 'desc' }];
|
|
68
|
+
const dateField = fieldNames.find(f => {
|
|
69
|
+
const t = fields[f]?.type ?? '';
|
|
70
|
+
return t === 'date' || t === 'datetime';
|
|
71
|
+
});
|
|
72
|
+
if (dateField)
|
|
73
|
+
return [{ field: dateField, direction: 'desc' }];
|
|
74
|
+
return [{ field: this.index, direction: 'asc' }];
|
|
49
75
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Get a form validator for this collection.
|
|
52
|
-
* @role Utility
|
|
53
|
-
* @return {MachineSchemeValidate} The form validator instance.
|
|
54
|
-
*/
|
|
55
76
|
get validator() {
|
|
56
77
|
return new MachineSchemeValidate(this.collection, this.#machineDb);
|
|
57
78
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Get the field rule for a given field name.
|
|
60
|
-
* @role Field rule accessor
|
|
61
|
-
* @param {keyof TplFields} fieldName The field name.
|
|
62
|
-
* @return {TplFieldRules | undefined} The field rule or undefined.
|
|
63
|
-
*/
|
|
64
79
|
getFieldRule(fieldName) {
|
|
65
|
-
return this
|
|
80
|
+
return this.fields[String(fieldName)];
|
|
66
81
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Get a new IDbCollectionValues instance for this collection.
|
|
69
|
-
* @role Utility
|
|
70
|
-
* @return {MachineSchemeValues} The collection values instance.
|
|
71
|
-
*/
|
|
72
82
|
get collectionValues() {
|
|
73
83
|
return new MachineSchemeValues(this.collection, this.#machineDb);
|
|
74
84
|
}
|
|
75
85
|
field(fieldName) {
|
|
76
86
|
return new MachineSchemeField(this.#model, this.collection, fieldName);
|
|
77
87
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Get a field forge instance for a specific field and data.
|
|
80
|
-
* @role Field forge factory
|
|
81
|
-
* @template T
|
|
82
|
-
* @param {keyof T} fieldName The field name.
|
|
83
|
-
* @param {T} data The data object.
|
|
84
|
-
* @return {MachineSchemeFieldForge<T>} The field forge instance.
|
|
85
|
-
*/
|
|
86
88
|
fieldForge(fieldName, data) {
|
|
87
89
|
return new MachineSchemeFieldForge(this.collection, fieldName, data, this.collectionValues, this.#machineDb);
|
|
88
90
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Parse all fields of a given collection.
|
|
91
|
-
* @role Field parsing
|
|
92
|
-
* @return {Record<string, IDbForge | undefined> | undefined} All parsed fields or undefined.
|
|
93
|
-
*/
|
|
94
91
|
parse() {
|
|
95
|
-
const fields = this
|
|
92
|
+
const fields = this.fields;
|
|
96
93
|
if (!fields)
|
|
97
94
|
return;
|
|
98
95
|
const out = {};
|
|
99
96
|
Object.keys(fields).forEach((fieldName) => {
|
|
100
|
-
|
|
101
|
-
if (fieldType) {
|
|
102
|
-
out[fieldName] = this.field(fieldName).parse();
|
|
103
|
-
}
|
|
97
|
+
out[fieldName] = this.field(fieldName).parse();
|
|
104
98
|
});
|
|
105
|
-
console.log("Parsed fields for collection", this.collection, out);
|
|
106
99
|
return out;
|
|
107
100
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Get all foreign keys for this collection.
|
|
110
|
-
* @role Foreign key accessor
|
|
111
|
-
* @return {{ [collection: string]: Tpl }} Foreign key collections.
|
|
112
|
-
*/
|
|
113
101
|
parseFks() {
|
|
114
|
-
const fks = this.#template?.fks;
|
|
115
102
|
const out = {};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
}
|
|
103
|
+
Object.keys(this.fks).forEach((collection) => {
|
|
104
|
+
const fkScheme = new MachineScheme(collection, this.#machineDb, this.#model);
|
|
105
|
+
out[collection] = fkScheme.parse() ?? {};
|
|
106
|
+
});
|
|
122
107
|
return out;
|
|
123
108
|
}
|
|
109
|
+
findFkField(targetCollection) {
|
|
110
|
+
return getRelationResolver()?.findRelationField?.(this.collection, targetCollection) ?? null;
|
|
111
|
+
}
|
|
124
112
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
113
|
+
* Whether `record` carries a value for FK relation `relationKey` — covers the
|
|
114
|
+
* nested `fks.{relationKey}_{id}` convention, the nested object form
|
|
115
|
+
* `fks.{relationKey} = { id|code }`, and the legacy flat scalar field
|
|
116
|
+
* (via `findFkField`). Used by `MachineSchemeValidate` to enforce
|
|
117
|
+
* `MachineFkDef.required`.
|
|
128
118
|
*/
|
|
119
|
+
hasFkValue(record, relationKey) {
|
|
120
|
+
return getRelationResolver()?.hasRelationValue?.(this.collection, record, relationKey) ?? false;
|
|
121
|
+
}
|
|
129
122
|
parseReverseFks() {
|
|
130
123
|
const result = {};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
124
|
+
// Get all collection names from the model
|
|
125
|
+
const collectionNames = Object.keys(this.#model);
|
|
126
|
+
// For each collection, get its relations and check if any point to this collection
|
|
127
|
+
for (const collectionName of collectionNames) {
|
|
128
|
+
const relations = getCollectionRelations(collectionName);
|
|
129
|
+
if (!relations)
|
|
130
|
+
continue;
|
|
131
|
+
Object.entries(relations).forEach(([fkName, fkConfig]) => {
|
|
132
|
+
if (fkConfig?.code === this.collection) {
|
|
133
|
+
if (!result[collectionName])
|
|
134
|
+
result[collectionName] = {};
|
|
135
|
+
result[collectionName][fkName] = fkConfig;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
parseReverseFkFields() {
|
|
142
|
+
const reverseFks = this.parseReverseFks();
|
|
143
|
+
const result = {};
|
|
144
|
+
for (const [sourceCollection, relations] of Object.entries(reverseFks)) {
|
|
145
|
+
const sourceScheme = new MachineScheme(sourceCollection, this.#machineDb, this.#model);
|
|
146
|
+
result[sourceCollection] = {};
|
|
147
|
+
for (const [relationKey, relationDef] of Object.entries(relations)) {
|
|
148
|
+
const fkDef = relationDef;
|
|
149
|
+
const fieldInfo = sourceScheme.findFkField(this.collection);
|
|
150
|
+
result[sourceCollection][relationKey] = {
|
|
151
|
+
...fkDef,
|
|
152
|
+
fieldName: fieldInfo?.fieldName,
|
|
153
|
+
targetIndex: fieldInfo?.targetIndex
|
|
154
|
+
};
|
|
142
155
|
}
|
|
143
|
-
}
|
|
156
|
+
}
|
|
144
157
|
return result;
|
|
145
158
|
}
|
|
146
159
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { MachineParserForge } from
|
|
2
|
-
import { MachineError } from
|
|
1
|
+
import { MachineParserForge } from '../machineParserForge.js';
|
|
2
|
+
import { MachineError } from './MachineError.js';
|
|
3
|
+
import { getCollectionRelations } from '../../data-ui/utils/dataRelationUtils.js';
|
|
3
4
|
export class MachineSchemeField {
|
|
4
5
|
#collection;
|
|
5
6
|
#fieldName;
|
|
6
7
|
#machineForge;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** The collection template. */
|
|
10
|
-
#template;
|
|
11
|
-
constructor(fullIDBModel, collection, fieldName) {
|
|
8
|
+
#collectionModel;
|
|
9
|
+
constructor(fullModel, collection, fieldName) {
|
|
12
10
|
this.#collection = collection;
|
|
13
11
|
this.#fieldName = fieldName;
|
|
14
12
|
this.#machineForge = new MachineParserForge();
|
|
15
|
-
this.#
|
|
16
|
-
this.#template = this.#model["template"];
|
|
13
|
+
this.#collectionModel = fullModel[String(collection)];
|
|
17
14
|
}
|
|
18
15
|
/**
|
|
19
16
|
* Parse a single field of a collection and return its IDbForge metadata.
|
|
@@ -24,28 +21,47 @@ export class MachineSchemeField {
|
|
|
24
21
|
parse() {
|
|
25
22
|
const field = this.getFieldRule(this.#fieldName);
|
|
26
23
|
if (!field) {
|
|
27
|
-
MachineError.throwError(`Field ${this.#fieldName} not found in collection ${this.#collection}`,
|
|
24
|
+
MachineError.throwError(`Field ${this.#fieldName} not found in collection ${this.#collection}`, 'FIELD_NOT_FOUND');
|
|
28
25
|
return undefined;
|
|
29
26
|
}
|
|
30
|
-
const array = this.#machineForge.testIs(
|
|
31
|
-
const object = this.#machineForge.testIs(
|
|
32
|
-
const fk = this.#machineForge.testIs(
|
|
33
|
-
const primitive = this.#machineForge.testIs(
|
|
27
|
+
const array = this.#machineForge.testIs('array', field);
|
|
28
|
+
const object = this.#machineForge.testIs('object', field);
|
|
29
|
+
const fk = this.#machineForge.testIs('fk', field);
|
|
30
|
+
const primitive = this.#machineForge.testIs('primitive', field);
|
|
34
31
|
const fieldType = array ?? object ?? fk ?? primitive;
|
|
35
32
|
return this.#machineForge.forge({
|
|
36
33
|
collection: this.#collection,
|
|
37
34
|
fieldName: String(this.#fieldName),
|
|
38
35
|
...(fieldType ?? {}),
|
|
39
|
-
is: fieldType?.is ??
|
|
36
|
+
is: fieldType?.is ?? 'primitive',
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
43
40
|
* Get the field rule for a given field name.
|
|
41
|
+
*
|
|
42
|
+
* Scalar fields live in `fields`. FK relations live in the structured `fks`
|
|
43
|
+
* block (no scalar `fk-X` field) — synthesize a `fk-<code>.code` rule for them
|
|
44
|
+
* so the forge resolves them as FK, mirroring `MachineSchemeValues.descriptor`.
|
|
45
|
+
* Without this fallback, rendering an FK relation (e.g. a `view="fk"` field)
|
|
46
|
+
* throws FIELD_NOT_FOUND.
|
|
47
|
+
*
|
|
44
48
|
* @role Field rule accessor
|
|
45
49
|
* @param {keyof TplFields} fieldName The field name.
|
|
46
50
|
* @return {TplFieldRules | undefined} The field rule or undefined.
|
|
47
51
|
*/
|
|
48
52
|
getFieldRule(fieldName) {
|
|
49
|
-
|
|
53
|
+
const name = String(fieldName);
|
|
54
|
+
const scalar = (this.#collectionModel.fields ?? {})[name];
|
|
55
|
+
if (scalar)
|
|
56
|
+
return scalar;
|
|
57
|
+
const relations = getCollectionRelations(this.#collection);
|
|
58
|
+
const fkDef = relations?.[name];
|
|
59
|
+
if (fkDef?.code) {
|
|
60
|
+
return {
|
|
61
|
+
type: `fk-${fkDef.code}.code`,
|
|
62
|
+
...(fkDef.required ? { required: true } : {})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
50
66
|
}
|
|
51
67
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { TplCollectionName, TplFieldArgs, TplFieldType } from
|
|
2
|
-
import { MachineSchemeValues } from
|
|
3
|
-
import type {
|
|
4
|
-
import type { MachineDb } from "../machineDb.js";
|
|
1
|
+
import type { TplCollectionName, TplFieldArgs, TplFieldType, IDbForge } from '../../types/index.js';
|
|
2
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
3
|
+
import type { MachineDb } from '../machineDb.js';
|
|
5
4
|
/**
|
|
6
5
|
* @class IDbCollectionFieldForge
|
|
7
6
|
* @role Provides advanced metadata and formatting for a single field of a collection, given a data object.
|
|
@@ -9,7 +8,7 @@ import type { MachineDb } from "../machineDb.js";
|
|
|
9
8
|
*
|
|
10
9
|
* @template T The type of the data object for the collection.
|
|
11
10
|
*/
|
|
12
|
-
export declare class MachineSchemeFieldForge<T extends Record<string,
|
|
11
|
+
export declare class MachineSchemeFieldForge<T extends Record<string, unknown>> {
|
|
13
12
|
#private;
|
|
14
13
|
/**
|
|
15
14
|
* Create a new IDbCollectionFieldForge instance.
|
|
@@ -19,7 +18,7 @@ export declare class MachineSchemeFieldForge<T extends Record<string, any>> {
|
|
|
19
18
|
* @param {T} data The data object.
|
|
20
19
|
* @param {MachineSchemeValues<T>=} collectionValues Optional collection values instance.
|
|
21
20
|
*/
|
|
22
|
-
constructor(collection: TplCollectionName, fieldName:
|
|
21
|
+
constructor(collection: TplCollectionName, fieldName: keyof T | string, data: T, collectionValues: MachineSchemeValues<T>, machineDb: MachineDb);
|
|
23
22
|
/**
|
|
24
23
|
* Get the formatted value for the field.
|
|
25
24
|
* @role Field formatting
|
|
@@ -31,7 +30,7 @@ export declare class MachineSchemeFieldForge<T extends Record<string, any>> {
|
|
|
31
30
|
* @role Input attribute generation
|
|
32
31
|
* @return {any} The input attributes for the field.
|
|
33
32
|
*/
|
|
34
|
-
get inputDataSet(): Record<"data-collection" | "data-
|
|
33
|
+
get inputDataSet(): Record<"data-collection" | "data-fieldType" | "data-collection-id" | "data-fieldName" | "data-fieldArgs" | "data-inputSize", string>;
|
|
35
34
|
/**
|
|
36
35
|
* Get the parsed field metadata (IDbForge) for the field.
|
|
37
36
|
* @role Field metadata accessor
|
|
@@ -50,6 +49,7 @@ export declare class MachineSchemeFieldForge<T extends Record<string, any>> {
|
|
|
50
49
|
* @return {TplFieldType | undefined} The field type or undefined.
|
|
51
50
|
*/
|
|
52
51
|
get fieldType(): TplFieldType | undefined;
|
|
52
|
+
get inputSize(): import("../../types/index.js").InputSize | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* will return text.inputBase for ['url', 'email', 'number', 'date', 'time', 'datetime', 'phone', 'password']
|
|
55
55
|
*/
|
|
@@ -58,7 +58,7 @@ export declare class MachineSchemeFieldForge<T extends Record<string, any>> {
|
|
|
58
58
|
* @role Input type accessor
|
|
59
59
|
* @return {string | 'text' | 'area'} The HTML input type.
|
|
60
60
|
*/
|
|
61
|
-
get htmlInputType(): string |
|
|
61
|
+
get htmlInputType(): string | 'text' | 'area';
|
|
62
62
|
/**
|
|
63
63
|
* Get the raw data object for the field.
|
|
64
64
|
* @role Data accessor
|
|
@@ -72,13 +72,13 @@ export declare class MachineSchemeFieldForge<T extends Record<string, any>> {
|
|
|
72
72
|
* @param {any[]} data The array data.
|
|
73
73
|
* @return {IDbForge[]} Array of field metadata objects for each item.
|
|
74
74
|
*/
|
|
75
|
-
iterateArray(fieldName: string, data:
|
|
75
|
+
iterateArray(fieldName: string, data: unknown[]): IDbForge[];
|
|
76
76
|
/**
|
|
77
77
|
* Iterate over an object field and return field metadata for each property.
|
|
78
78
|
* @role Object field iteration
|
|
79
79
|
* @param {string} fieldName The field name.
|
|
80
|
-
* @param {Record<string,
|
|
80
|
+
* @param {Record<string, unknown>} data The object data.
|
|
81
81
|
* @return {IDbForge[]} Array of field metadata objects for each property.
|
|
82
82
|
*/
|
|
83
|
-
iterateObject(fieldName: string, data: Record<string,
|
|
83
|
+
iterateObject(fieldName: string, data: Record<string, unknown>): IDbForge[];
|
|
84
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MachineSchemeValues } from
|
|
1
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
2
2
|
/**
|
|
3
3
|
* @class IDbCollectionFieldForge
|
|
4
4
|
* @role Provides advanced metadata and formatting for a single field of a collection, given a data object.
|
|
@@ -21,8 +21,7 @@ export class MachineSchemeFieldForge {
|
|
|
21
21
|
*/
|
|
22
22
|
constructor(collection, fieldName, data, collectionValues, machineDb) {
|
|
23
23
|
this.#collection = collection;
|
|
24
|
-
this.#collectionValues =
|
|
25
|
-
collectionValues ?? new MachineSchemeValues(collection, machineDb);
|
|
24
|
+
this.#collectionValues = collectionValues ?? new MachineSchemeValues(collection, machineDb);
|
|
26
25
|
this.#fieldName = String(fieldName);
|
|
27
26
|
this.#data = data;
|
|
28
27
|
}
|
|
@@ -51,7 +50,8 @@ export class MachineSchemeFieldForge {
|
|
|
51
50
|
get forge() {
|
|
52
51
|
return this.#collectionValues.machine
|
|
53
52
|
.collection(this.#collection)
|
|
54
|
-
.field(String(this.#fieldName))
|
|
53
|
+
.field(String(this.#fieldName))
|
|
54
|
+
.parse();
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Get the field arguments for the field.
|
|
@@ -69,6 +69,20 @@ export class MachineSchemeFieldForge {
|
|
|
69
69
|
get fieldType() {
|
|
70
70
|
return this.forge?.fieldType;
|
|
71
71
|
}
|
|
72
|
+
get inputSize() {
|
|
73
|
+
if (this.forge?.inputSize)
|
|
74
|
+
return this.forge.inputSize;
|
|
75
|
+
const ft = this.forge?.fieldType ?? '';
|
|
76
|
+
if (ft === 'text-area' || ft === 'text-full')
|
|
77
|
+
return 'full';
|
|
78
|
+
if (ft === 'text-xs')
|
|
79
|
+
return 'xs';
|
|
80
|
+
if (ft === 'text-sm')
|
|
81
|
+
return 'sm';
|
|
82
|
+
if (ft === 'text-lg' || ft === 'text-long')
|
|
83
|
+
return 'lg';
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
72
86
|
/**
|
|
73
87
|
* will return text.inputBase for ['url', 'email', 'number', 'date', 'time', 'datetime', 'phone', 'password']
|
|
74
88
|
*/
|
|
@@ -78,24 +92,22 @@ export class MachineSchemeFieldForge {
|
|
|
78
92
|
* @return {string | 'text' | 'area'} The HTML input type.
|
|
79
93
|
*/
|
|
80
94
|
get htmlInputType() {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
95
|
+
const ft = this.forge?.fieldType ?? '';
|
|
96
|
+
if (ft === 'image')
|
|
97
|
+
return 'file';
|
|
98
|
+
if (ft === 'color')
|
|
99
|
+
return 'color';
|
|
100
|
+
if (ft === 'icon')
|
|
101
|
+
return 'icon';
|
|
102
|
+
const variant = ft.split('text-')?.[1] ?? ft;
|
|
103
|
+
if (variant === 'area')
|
|
83
104
|
return variant;
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
86
|
-
if ([
|
|
87
|
-
|
|
88
|
-
"email",
|
|
89
|
-
"number",
|
|
90
|
-
"date",
|
|
91
|
-
"time",
|
|
92
|
-
"datetime",
|
|
93
|
-
"phone",
|
|
94
|
-
"password",
|
|
95
|
-
].includes(this.forge?.fieldType ?? "")) {
|
|
96
|
-
return this.forge?.fieldType?.trim?.() ?? "text";
|
|
105
|
+
if (ft.startsWith('text-'))
|
|
106
|
+
return 'text';
|
|
107
|
+
if (['url', 'email', 'number', 'date', 'time', 'datetime', 'phone', 'password'].includes(ft)) {
|
|
108
|
+
return ft.trim() || 'text';
|
|
97
109
|
}
|
|
98
|
-
return
|
|
110
|
+
return 'text';
|
|
99
111
|
}
|
|
100
112
|
/**
|
|
101
113
|
* Get the raw data object for the field.
|
|
@@ -119,7 +131,7 @@ export class MachineSchemeFieldForge {
|
|
|
119
131
|
* Iterate over an object field and return field metadata for each property.
|
|
120
132
|
* @role Object field iteration
|
|
121
133
|
* @param {string} fieldName The field name.
|
|
122
|
-
* @param {Record<string,
|
|
134
|
+
* @param {Record<string, unknown>} data The object data.
|
|
123
135
|
* @return {IDbForge[]} Array of field metadata objects for each property.
|
|
124
136
|
*/
|
|
125
137
|
iterateObject(fieldName, data) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { TplCollectionName } from
|
|
2
|
-
import { MachineSchemeValues } from
|
|
3
|
-
import type { IDbForge } from "../machineParserForge.js";
|
|
1
|
+
import type { TplCollectionName, IDbForge } from '../../types/index.js';
|
|
2
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
4
3
|
/**
|
|
5
4
|
* @class MachineSchemeFieldValues
|
|
6
5
|
* @role Utility class for introspecting and formatting field values for a given collection and data object.
|
|
@@ -19,7 +18,7 @@ import type { IDbForge } from "../machineParserForge.js";
|
|
|
19
18
|
*
|
|
20
19
|
* @template T The type of the data object for the collection.
|
|
21
20
|
*/
|
|
22
|
-
export declare class MachineSchemeFieldValues<T extends Record<string,
|
|
21
|
+
export declare class MachineSchemeFieldValues<T extends Record<string, unknown>> {
|
|
23
22
|
#private;
|
|
24
23
|
/**
|
|
25
24
|
* Returns the IDbForge metadata for a given field name.
|
|
@@ -42,14 +41,14 @@ export declare class MachineSchemeFieldValues<T extends Record<string, any>> {
|
|
|
42
41
|
* @param {keyof T} fieldName The field name.
|
|
43
42
|
* @return {string | string[]} The formatted value or array of formatted values.
|
|
44
43
|
*/
|
|
45
|
-
format(fieldName: keyof T): string | string[];
|
|
44
|
+
format(fieldName: keyof T): string | string[] | unknown[];
|
|
46
45
|
/**
|
|
47
46
|
* Get input attributes for a field.
|
|
48
47
|
* @role Input attribute generation
|
|
49
48
|
* @param {keyof T} fieldName The field name.
|
|
50
49
|
* @return {any} The input attributes for the field.
|
|
51
50
|
*/
|
|
52
|
-
getInputDataSet(fieldName: keyof T): Record<
|
|
51
|
+
getInputDataSet(fieldName: keyof T): Record<string, unknown> | undefined;
|
|
53
52
|
/**
|
|
54
53
|
* Iterate over an array field and return field metadata for each item.
|
|
55
54
|
* @role Array field iteration
|
|
@@ -57,13 +56,13 @@ export declare class MachineSchemeFieldValues<T extends Record<string, any>> {
|
|
|
57
56
|
* @param {any[]} data The array data.
|
|
58
57
|
* @return {IDbForge[]} Array of field metadata objects for each item.
|
|
59
58
|
*/
|
|
60
|
-
iterateArray(fieldName: string, data:
|
|
59
|
+
iterateArray(fieldName: string, data: unknown[]): unknown[];
|
|
61
60
|
/**
|
|
62
61
|
* Iterate over an object field and return field metadata for each property.
|
|
63
62
|
* @role Object field iteration
|
|
64
63
|
* @param {string} fieldName The field name.
|
|
65
|
-
* @param {Record<string,
|
|
64
|
+
* @param {Record<string, unknown>} data The object data.
|
|
66
65
|
* @return {IDbForge[]} Array of field metadata objects for each property.
|
|
67
66
|
*/
|
|
68
|
-
iterateObject(fieldName: string, data: Record<string,
|
|
67
|
+
iterateObject(fieldName: string, data: Record<string, unknown>): IDbForge[];
|
|
69
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MachineSchemeValues } from
|
|
2
|
-
import { machine } from
|
|
1
|
+
import { MachineSchemeValues } from './MachineSchemeValues.js';
|
|
2
|
+
import { machine } from '../machine.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class MachineSchemeFieldValues
|
|
5
5
|
* @role Utility class for introspecting and formatting field values for a given collection and data object.
|
|
@@ -31,7 +31,8 @@ export class MachineSchemeFieldValues {
|
|
|
31
31
|
getForge(fieldName) {
|
|
32
32
|
return this.#collectionValues.machine
|
|
33
33
|
.collection(this.#collection)
|
|
34
|
-
.field(fieldName)
|
|
34
|
+
.field(String(fieldName))
|
|
35
|
+
.parse();
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Create a new IDbCollectionFieldValues instance.
|
|
@@ -42,8 +43,7 @@ export class MachineSchemeFieldValues {
|
|
|
42
43
|
*/
|
|
43
44
|
constructor(collection, data, collectionValues) {
|
|
44
45
|
this.#collection = collection;
|
|
45
|
-
this.#collectionValues =
|
|
46
|
-
collectionValues ?? new MachineSchemeValues(collection, machine);
|
|
46
|
+
this.#collectionValues = collectionValues ?? new MachineSchemeValues(collection, machine.logic);
|
|
47
47
|
this.#data = data;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
@@ -53,11 +53,14 @@ export class MachineSchemeFieldValues {
|
|
|
53
53
|
* @return {string | string[]} The formatted value or array of formatted values.
|
|
54
54
|
*/
|
|
55
55
|
format(fieldName) {
|
|
56
|
-
const fieldInfo = this.#collectionValues.machine
|
|
57
|
-
|
|
56
|
+
const fieldInfo = this.#collectionValues.machine
|
|
57
|
+
.collection(this.#collection)
|
|
58
|
+
.field(String(fieldName))
|
|
59
|
+
.parse();
|
|
60
|
+
if (fieldInfo?.is === 'array') {
|
|
58
61
|
return this.iterateArray(String(fieldName), this.#data);
|
|
59
62
|
}
|
|
60
|
-
if (fieldInfo?.is ===
|
|
63
|
+
if (fieldInfo?.is === 'object') {
|
|
61
64
|
return this.iterateObject(String(fieldName), this.#data);
|
|
62
65
|
}
|
|
63
66
|
return this.#collectionValues.format(fieldName, this.#data);
|
|
@@ -85,7 +88,7 @@ export class MachineSchemeFieldValues {
|
|
|
85
88
|
* Iterate over an object field and return field metadata for each property.
|
|
86
89
|
* @role Object field iteration
|
|
87
90
|
* @param {string} fieldName The field name.
|
|
88
|
-
* @param {Record<string,
|
|
91
|
+
* @param {Record<string, unknown>} data The object data.
|
|
89
92
|
* @return {IDbForge[]} Array of field metadata objects for each property.
|
|
90
93
|
*/
|
|
91
94
|
iterateObject(fieldName, data) {
|