@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.
Files changed (375) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +555 -360
  3. package/cli.cjs +22 -0
  4. package/dist/__fixtures__/demoModel.d.ts +79 -0
  5. package/dist/__fixtures__/demoModel.js +146 -0
  6. package/dist/ai/frame/AiChatSession.svelte +152 -0
  7. package/dist/ai/frame/AiChatSession.svelte.d.ts +7 -0
  8. package/dist/ai/frame/index.d.ts +1 -0
  9. package/dist/ai/frame/index.js +2 -0
  10. package/dist/ai/index.d.ts +9 -0
  11. package/dist/ai/index.js +12 -0
  12. package/dist/ai/schema/ai-catalogs.d.ts +2 -0
  13. package/dist/ai/schema/ai-catalogs.js +86 -0
  14. package/dist/ai/schema/ai-chat-session.d.ts +2 -0
  15. package/dist/ai/schema/ai-chat-session.js +35 -0
  16. package/dist/ai/schema/ai-companion.d.ts +2 -0
  17. package/dist/ai/schema/ai-companion.js +25 -0
  18. package/dist/ai/schema/ai-message.d.ts +2 -0
  19. package/dist/ai/schema/ai-message.js +20 -0
  20. package/dist/ai/schema/ai-tool-call.d.ts +2 -0
  21. package/dist/ai/schema/ai-tool-call.js +18 -0
  22. package/dist/ai/schema/ai-user-prompt.d.ts +2 -0
  23. package/dist/ai/schema/ai-user-prompt.js +17 -0
  24. package/dist/ai/schema/tag.d.ts +2 -0
  25. package/dist/ai/schema/tag.js +14 -0
  26. package/dist/ai/streamIntoRecord.d.ts +31 -0
  27. package/dist/ai/streamIntoRecord.js +79 -0
  28. package/dist/config.d.ts +17 -0
  29. package/dist/config.js +19 -0
  30. package/dist/data-ui/controls/AlphabetFilter.svelte +114 -0
  31. package/dist/data-ui/controls/AlphabetFilter.svelte.d.ts +10 -0
  32. package/dist/data-ui/controls/ButtonAction.svelte +151 -0
  33. package/dist/data-ui/controls/ButtonAction.svelte.d.ts +18 -0
  34. package/dist/data-ui/controls/DataFind.svelte +174 -0
  35. package/dist/data-ui/controls/DataFind.svelte.d.ts +10 -0
  36. package/dist/data-ui/controls/DataGroup.svelte +150 -0
  37. package/dist/data-ui/controls/DataGroup.svelte.d.ts +7 -0
  38. package/dist/data-ui/controls/DataSort.svelte +78 -0
  39. package/dist/data-ui/controls/DataSort.svelte.d.ts +9 -0
  40. package/dist/data-ui/controls/DataToolbar.svelte +67 -0
  41. package/dist/data-ui/controls/DataToolbar.svelte.d.ts +11 -0
  42. package/dist/data-ui/controls/Find.svelte +38 -0
  43. package/dist/data-ui/controls/Find.svelte.d.ts +9 -0
  44. package/dist/data-ui/controls/FkFilter.svelte +94 -0
  45. package/dist/data-ui/controls/FkFilter.svelte.d.ts +11 -0
  46. package/dist/data-ui/controls/Group.svelte +36 -0
  47. package/dist/data-ui/controls/Group.svelte.d.ts +8 -0
  48. package/dist/data-ui/controls/ListMode.svelte +79 -0
  49. package/dist/data-ui/controls/ListMode.svelte.d.ts +10 -0
  50. package/dist/data-ui/controls/Sort.svelte +100 -0
  51. package/dist/data-ui/controls/Sort.svelte.d.ts +8 -0
  52. package/dist/data-ui/data/DataCount.svelte +67 -0
  53. package/dist/data-ui/data/DataCount.svelte.d.ts +36 -0
  54. package/dist/data-ui/data/DataFk.svelte +54 -0
  55. package/dist/data-ui/data/DataFk.svelte.d.ts +11 -0
  56. package/dist/data-ui/data/DataForm.svelte +191 -0
  57. package/dist/data-ui/data/DataForm.svelte.d.ts +15 -0
  58. package/dist/data-ui/data/DataList.svelte +645 -0
  59. package/dist/data-ui/data/DataList.svelte.d.ts +75 -0
  60. package/dist/data-ui/data/DataListFk.svelte +111 -0
  61. package/dist/data-ui/data/DataListFk.svelte.d.ts +13 -0
  62. package/dist/data-ui/data/DataListRfk.svelte +111 -0
  63. package/dist/data-ui/data/DataListRfk.svelte.d.ts +13 -0
  64. package/dist/data-ui/data/DataRecord.svelte +167 -0
  65. package/dist/data-ui/data/DataRecord.svelte.d.ts +22 -0
  66. package/dist/data-ui/data/DataRfk.svelte +73 -0
  67. package/dist/data-ui/data/DataRfk.svelte.d.ts +15 -0
  68. package/dist/data-ui/data/index.d.ts +7 -0
  69. package/dist/data-ui/data/index.js +8 -0
  70. package/dist/data-ui/field/DataField.svelte +343 -0
  71. package/dist/data-ui/field/DataField.svelte.d.ts +33 -0
  72. package/dist/{form/FieldInPlace.svelte → data-ui/field/DataFieldEdit.svelte} +103 -98
  73. package/dist/{form/FieldInPlace.svelte.d.ts → data-ui/field/DataFieldEdit.svelte.d.ts} +5 -5
  74. package/dist/data-ui/field/index.d.ts +2 -0
  75. package/dist/data-ui/field/index.js +3 -0
  76. package/dist/data-ui/field/snippets/FieldAiPrompt.svelte +145 -0
  77. package/dist/data-ui/field/snippets/FieldAiPrompt.svelte.d.ts +14 -0
  78. package/dist/data-ui/field/snippets/FieldBoolean.svelte +43 -0
  79. package/dist/data-ui/field/snippets/FieldBoolean.svelte.d.ts +12 -0
  80. package/dist/data-ui/field/snippets/FieldColor.svelte +48 -0
  81. package/dist/data-ui/field/snippets/FieldColor.svelte.d.ts +10 -0
  82. package/dist/data-ui/field/snippets/FieldCurrency.svelte +105 -0
  83. package/dist/data-ui/field/snippets/FieldCurrency.svelte.d.ts +15 -0
  84. package/dist/data-ui/field/snippets/FieldEmail.svelte +77 -0
  85. package/dist/data-ui/field/snippets/FieldEmail.svelte.d.ts +14 -0
  86. package/dist/data-ui/field/snippets/FieldIcon.svelte +73 -0
  87. package/dist/data-ui/field/snippets/FieldIcon.svelte.d.ts +11 -0
  88. package/dist/data-ui/field/snippets/FieldSelect.svelte +71 -0
  89. package/dist/data-ui/field/snippets/FieldSelect.svelte.d.ts +15 -0
  90. package/dist/data-ui/field/snippets/FieldText.svelte +52 -0
  91. package/dist/data-ui/field/snippets/FieldText.svelte.d.ts +13 -0
  92. package/dist/data-ui/field/snippets/FieldTextarea.svelte +50 -0
  93. package/dist/data-ui/field/snippets/FieldTextarea.svelte.d.ts +13 -0
  94. package/dist/data-ui/field/snippets/index.d.ts +9 -0
  95. package/dist/data-ui/field/snippets/index.js +10 -0
  96. package/dist/data-ui/fragments/ContextMenu.svelte +109 -0
  97. package/dist/data-ui/fragments/ContextMenu.svelte.d.ts +4 -0
  98. package/dist/data-ui/fragments/ContextMenuContent.svelte +275 -0
  99. package/dist/data-ui/fragments/ContextMenuContent.svelte.d.ts +8 -0
  100. package/dist/data-ui/fragments/Frame.svelte +43 -0
  101. package/dist/data-ui/fragments/Frame.svelte.d.ts +10 -0
  102. package/dist/data-ui/fragments/InfoLine.svelte +123 -0
  103. package/dist/data-ui/fragments/InfoLine.svelte.d.ts +12 -0
  104. package/dist/data-ui/fragments/Selector.svelte +56 -0
  105. package/dist/data-ui/fragments/Selector.svelte.d.ts +10 -0
  106. package/dist/{fragments → data-ui/fragments}/Skeleton.svelte +21 -21
  107. package/dist/data-ui/fragments/Tile.svelte +126 -0
  108. package/dist/data-ui/fragments/Tile.svelte.d.ts +14 -0
  109. package/dist/data-ui/fragments/contextMenu.svelte.d.ts +22 -0
  110. package/dist/data-ui/fragments/contextMenu.svelte.js +31 -0
  111. package/dist/data-ui/fragments/dialog/Dialog.svelte +185 -0
  112. package/dist/data-ui/fragments/dialog/Dialog.svelte.d.ts +29 -0
  113. package/dist/data-ui/fragments/dialog/dialog.svelte.d.ts +27 -0
  114. package/dist/data-ui/fragments/dialog/dialog.svelte.js +41 -0
  115. package/dist/data-ui/fragments/index.d.ts +11 -0
  116. package/dist/data-ui/fragments/index.js +11 -0
  117. package/dist/data-ui/utils/__tests__/HostProbe.svelte +18 -0
  118. package/dist/data-ui/utils/__tests__/HostProbe.svelte.d.ts +8 -0
  119. package/dist/data-ui/utils/data-utils.d.ts +29 -0
  120. package/dist/data-ui/utils/data-utils.js +83 -0
  121. package/dist/data-ui/utils/dataRelationUtils.d.ts +37 -0
  122. package/dist/data-ui/utils/dataRelationUtils.js +125 -0
  123. package/dist/data-ui/utils/diagramUtils.d.ts +6 -0
  124. package/dist/data-ui/utils/diagramUtils.js +131 -0
  125. package/dist/data-ui/utils/draggable.d.ts +15 -0
  126. package/dist/data-ui/utils/draggable.js +61 -0
  127. package/dist/data-ui/utils/menuPrefs.d.ts +80 -0
  128. package/dist/data-ui/utils/menuPrefs.js +119 -0
  129. package/dist/data-ui/utils/useMachinePrefs.svelte.d.ts +38 -0
  130. package/dist/data-ui/utils/useMachinePrefs.svelte.js +117 -0
  131. package/dist/data-ui/utils/useMenuTree.svelte.d.ts +26 -0
  132. package/dist/data-ui/utils/useMenuTree.svelte.js +68 -0
  133. package/dist/data-ui/utils/useRecordData.svelte.d.ts +22 -0
  134. package/dist/data-ui/utils/useRecordData.svelte.js +50 -0
  135. package/dist/data-ui/utils/useViewFields.svelte.d.ts +22 -0
  136. package/dist/data-ui/utils/useViewFields.svelte.js +59 -0
  137. package/dist/demo/.gitkeep +0 -0
  138. package/dist/demo/demo-status.json +9 -0
  139. package/dist/idae/boot.d.ts +28 -0
  140. package/dist/idae/boot.js +43 -0
  141. package/dist/idae/bridge/register.d.ts +4 -0
  142. package/dist/idae/bridge/register.js +15 -0
  143. package/dist/idae/capabilities/Capabilities.d.ts +10 -0
  144. package/dist/idae/capabilities/Capabilities.js +34 -0
  145. package/dist/idae/codefield/CodeFieldConvention.d.ts +3 -0
  146. package/dist/idae/codefield/CodeFieldConvention.js +25 -0
  147. package/dist/idae/fieldcatalog/defaultFieldTypesDef.d.ts +2 -0
  148. package/dist/idae/fieldcatalog/defaultFieldTypesDef.js +104 -0
  149. package/dist/idae/frames/FrameCatalog.d.ts +31 -0
  150. package/dist/idae/frames/FrameCatalog.js +31 -0
  151. package/dist/idae/index.d.ts +14 -0
  152. package/dist/idae/index.js +13 -0
  153. package/dist/idae/menu/IdaeMenuManager.d.ts +79 -0
  154. package/dist/idae/menu/IdaeMenuManager.js +108 -0
  155. package/dist/idae/menu/IdaeMenuStore.d.ts +77 -0
  156. package/dist/idae/menu/IdaeMenuStore.js +68 -0
  157. package/dist/idae/menu/menuSnapshot.d.ts +30 -0
  158. package/dist/idae/menu/menuSnapshot.js +30 -0
  159. package/dist/idae/meta/MetaModelProvider.d.ts +11 -0
  160. package/dist/idae/meta/MetaModelProvider.js +43 -0
  161. package/dist/idae/relations/RelationPolicy.d.ts +19 -0
  162. package/dist/idae/relations/RelationPolicy.js +125 -0
  163. package/dist/idae/rights/RightsPolicy.d.ts +16 -0
  164. package/dist/idae/rights/RightsPolicy.js +80 -0
  165. package/dist/idae/userscope/UserScopePolicy.d.ts +9 -0
  166. package/dist/idae/userscope/UserScopePolicy.js +42 -0
  167. package/dist/idae/userscope/navTracking.d.ts +11 -0
  168. package/dist/idae/userscope/navTracking.js +15 -0
  169. package/dist/index.d.ts +68 -35
  170. package/dist/index.js +82 -36
  171. package/dist/main/__tests__/_relationTestUtils.d.ts +12 -0
  172. package/dist/main/__tests__/_relationTestUtils.js +53 -0
  173. package/dist/main/__tests__/helpers/mockCollection.d.ts +21 -0
  174. package/dist/main/__tests__/helpers/mockCollection.js +27 -0
  175. package/dist/main/api/types.d.ts +29 -0
  176. package/dist/main/ext/hooks.d.ts +32 -0
  177. package/dist/main/ext/hooks.js +31 -0
  178. package/dist/main/ext/interfaces.d.ts +69 -0
  179. package/dist/main/ext/interfaces.js +3 -0
  180. package/dist/main/ext/registry.d.ts +29 -0
  181. package/dist/main/ext/registry.js +30 -0
  182. package/dist/main/frame/MachineFrameManager.d.ts +187 -0
  183. package/dist/main/frame/MachineFrameManager.js +403 -0
  184. package/dist/main/frame/contextMenuSetup.d.ts +9 -0
  185. package/dist/main/frame/contextMenuSetup.js +42 -0
  186. package/dist/main/frame/frameUrl.d.ts +1 -0
  187. package/dist/main/frame/frameUrl.js +8 -0
  188. package/dist/main/frame/frameUtils.d.ts +16 -0
  189. package/dist/main/frame/frameUtils.js +26 -0
  190. package/dist/main/frame/linkParser.d.ts +9 -0
  191. package/dist/main/frame/linkParser.js +15 -0
  192. package/dist/main/index.d.ts +15 -0
  193. package/dist/main/index.js +19 -0
  194. package/dist/main/machine/MachineAction.d.ts +62 -0
  195. package/dist/main/machine/MachineAction.js +96 -0
  196. package/dist/main/machine/MachineError.js +2 -2
  197. package/dist/main/machine/MachineFieldType.d.ts +25 -6
  198. package/dist/main/machine/MachineFieldType.js +118 -27
  199. package/dist/main/machine/MachineFkFold.d.ts +34 -0
  200. package/dist/main/machine/MachineFkFold.js +57 -0
  201. package/dist/main/machine/MachineRecordIdentity.d.ts +26 -0
  202. package/dist/main/machine/MachineRecordIdentity.js +44 -0
  203. package/dist/main/machine/MachineRights.d.ts +50 -0
  204. package/dist/main/machine/MachineRights.js +133 -0
  205. package/dist/main/machine/MachineRouter.d.ts +56 -0
  206. package/dist/main/machine/MachineRouter.js +250 -0
  207. package/dist/main/machine/MachineScheme.d.ts +40 -70
  208. package/dist/main/machine/MachineScheme.js +107 -94
  209. package/dist/main/machine/MachineSchemeField.js +32 -16
  210. package/dist/main/machine/MachineSchemeFieldForge.d.ts +11 -11
  211. package/dist/main/machine/MachineSchemeFieldForge.js +33 -21
  212. package/dist/main/machine/MachineSchemeFieldValues.d.ts +8 -9
  213. package/dist/main/machine/MachineSchemeFieldValues.js +12 -9
  214. package/dist/main/machine/MachineSchemeValidate.d.ts +69 -13
  215. package/dist/main/machine/MachineSchemeValidate.js +173 -46
  216. package/dist/main/machine/MachineSchemeValues.d.ts +32 -21
  217. package/dist/main/machine/MachineSchemeValues.js +132 -104
  218. package/dist/main/machine/SchemeFieldDefaultValues.d.ts +4 -2
  219. package/dist/main/machine/SchemeFieldDefaultValues.js +8 -2
  220. package/dist/main/machine/authState.svelte.d.ts +11 -0
  221. package/dist/main/machine/authState.svelte.js +17 -0
  222. package/dist/main/machine/fieldBuilder.d.ts +23 -0
  223. package/dist/main/machine/fieldBuilder.d.ts.map +1 -0
  224. package/dist/main/machine/fieldBuilder.js +10 -0
  225. package/dist/main/machine/fieldBuilder.js.map +1 -0
  226. package/dist/main/machine/machineLabel.d.ts +11 -0
  227. package/dist/main/machine/machineLabel.js +23 -0
  228. package/dist/main/machine/validateRules.d.ts +38 -0
  229. package/dist/main/machine/validateRules.js +109 -0
  230. package/dist/main/machine.d.ts +207 -68
  231. package/dist/main/machine.js +482 -96
  232. package/dist/main/machineDb.d.ts +21 -8
  233. package/dist/main/machineDb.js +33 -4
  234. package/dist/main/machineIdbAdapter.d.ts +83 -0
  235. package/dist/main/machineIdbAdapter.js +347 -0
  236. package/dist/main/machineModelBuilder.d.ts +31 -0
  237. package/dist/main/machineModelBuilder.js +58 -0
  238. package/dist/main/machineParserForge.d.ts +9 -18
  239. package/dist/main/machineParserForge.js +92 -35
  240. package/dist/main/machineSchemaCache.d.ts +8 -0
  241. package/dist/main/machineSchemaCache.js +58 -0
  242. package/dist/main/machineSchemaDoctor.d.ts +17 -0
  243. package/dist/main/machineSchemaDoctor.js +73 -0
  244. package/dist/main/machineSchemaLoader.d.ts +18 -0
  245. package/dist/main/machineSchemaLoader.js +43 -0
  246. package/dist/main/machineSeed.d.ts +21 -0
  247. package/dist/main/machineSeed.js +44 -0
  248. package/dist/main/router/componentRegistry.d.ts +35 -0
  249. package/dist/main/router/componentRegistry.js +35 -0
  250. package/dist/main/router/urlParser.d.ts +17 -0
  251. package/dist/main/router/urlParser.js +41 -0
  252. package/dist/main/warmupUtils.d.ts +40 -0
  253. package/dist/main/warmupUtils.js +73 -0
  254. package/dist/mcp/MachineMcpClient.d.ts +43 -0
  255. package/dist/mcp/MachineMcpClient.js +175 -0
  256. package/dist/shell/Frame.svelte +67 -0
  257. package/dist/shell/Frame.svelte.d.ts +11 -0
  258. package/dist/shell/auth/Login.svelte +244 -0
  259. package/dist/shell/auth/Login.svelte.d.ts +3 -0
  260. package/dist/shell/frame/dashboard/Dashboard.svelte +0 -0
  261. package/dist/shell/frame/dashboard/Dashboard.svelte.d.ts +26 -0
  262. package/dist/shell/frame/diagram/Diagram.svelte +244 -0
  263. package/dist/shell/frame/diagram/Diagram.svelte.d.ts +9 -0
  264. package/dist/shell/frame/explorer/Explorer.svelte +86 -0
  265. package/dist/shell/frame/explorer/Explorer.svelte.d.ts +29 -0
  266. package/dist/shell/frame/explorer/ExplorerContent.svelte +126 -0
  267. package/dist/shell/frame/explorer/ExplorerContent.svelte.d.ts +32 -0
  268. package/dist/shell/frame/index.d.ts +8 -0
  269. package/dist/shell/frame/index.js +9 -0
  270. package/dist/shell/frame/main-menu-content/MainMenuContent.svelte +100 -0
  271. package/dist/shell/frame/main-menu-content/MainMenuContent.svelte.d.ts +6 -0
  272. package/dist/shell/frame/planning/Planning.svelte +426 -0
  273. package/dist/shell/frame/planning/Planning.svelte.d.ts +12 -0
  274. package/dist/shell/frame/rbac/RbacMatrix.svelte +197 -0
  275. package/dist/shell/frame/rbac/RbacMatrix.svelte.d.ts +7 -0
  276. package/dist/shell/frame/space/Space.svelte +554 -0
  277. package/dist/shell/frame/space/Space.svelte.d.ts +8 -0
  278. package/dist/shell/frame/synthesis/Synthesis.svelte +383 -0
  279. package/dist/shell/frame/synthesis/Synthesis.svelte.d.ts +8 -0
  280. package/dist/shell/frame/today/Today.svelte +174 -0
  281. package/dist/shell/frame/today/Today.svelte.d.ts +3 -0
  282. package/dist/shell/layout/App.svelte +30 -0
  283. package/dist/shell/layout/App.svelte.d.ts +3 -0
  284. package/dist/shell/layout/Breadcrumb.svelte +67 -0
  285. package/dist/shell/layout/Breadcrumb.svelte.d.ts +12 -0
  286. package/dist/shell/layout/Columner.svelte +214 -0
  287. package/dist/shell/layout/Columner.svelte.d.ts +16 -0
  288. package/dist/shell/layout/DevResetPanel.svelte +194 -0
  289. package/dist/shell/layout/DevResetPanel.svelte.d.ts +7 -0
  290. package/dist/shell/layout/Fiche.svelte +111 -0
  291. package/dist/shell/layout/Fiche.svelte.d.ts +7 -0
  292. package/dist/shell/layout/FicheUpdate.svelte +53 -0
  293. package/dist/shell/layout/FicheUpdate.svelte.d.ts +7 -0
  294. package/dist/shell/layout/MainMenu.svelte +256 -0
  295. package/dist/shell/layout/MainMenu.svelte.d.ts +6 -0
  296. package/dist/shell/layout/MenuSettings.svelte +182 -0
  297. package/dist/shell/layout/MenuSettings.svelte.d.ts +6 -0
  298. package/dist/shell/layout/RecordTimeline.svelte +199 -0
  299. package/dist/shell/layout/RecordTimeline.svelte.d.ts +8 -0
  300. package/dist/shell/layout/RecordToolbar.svelte +39 -0
  301. package/dist/shell/layout/RecordToolbar.svelte.d.ts +7 -0
  302. package/dist/shell/layout/TaskBar.svelte +118 -0
  303. package/dist/shell/layout/TaskBar.svelte.d.ts +7 -0
  304. package/dist/shell/layout/TemplateShell.svelte +48 -0
  305. package/dist/shell/layout/TemplateShell.svelte.d.ts +15 -0
  306. package/dist/shell/layout/ThemeToggle.svelte +46 -0
  307. package/dist/shell/layout/ThemeToggle.svelte.d.ts +3 -0
  308. package/dist/shell/layout/index.d.ts +8 -0
  309. package/dist/shell/layout/index.js +9 -0
  310. package/dist/storage/ApiStorageAdapter.d.ts +41 -0
  311. package/dist/storage/ApiStorageAdapter.js +111 -0
  312. package/dist/storage/IdbStorageAdapter.d.ts +31 -0
  313. package/dist/storage/IdbStorageAdapter.js +72 -0
  314. package/dist/storage/MemoryStorageAdapter.d.ts +33 -0
  315. package/dist/storage/MemoryStorageAdapter.js +132 -0
  316. package/dist/storage/README.md +222 -0
  317. package/dist/storage/StorageAdapter.d.ts +75 -0
  318. package/dist/storage/StorageAdapter.js +7 -0
  319. package/dist/storage/demo/storage-demo.d.ts +22 -0
  320. package/dist/storage/demo/storage-demo.js +107 -0
  321. package/dist/storage/index.d.ts +9 -0
  322. package/dist/storage/index.js +9 -0
  323. package/dist/types/entity-types.d.ts +444 -0
  324. package/dist/types/entity-types.js +16 -0
  325. package/dist/types/index.d.ts +7 -0
  326. package/dist/types/index.js +6 -0
  327. package/dist/types/machine-model.d.ts +198 -0
  328. package/dist/types/machine-model.js +5 -0
  329. package/dist/types/qoolie-svelte.d.ts +11 -0
  330. package/dist/types/schema-utils.d.ts +32 -0
  331. package/dist/types/schema-utils.js +103 -0
  332. package/dist/utils/generateCode.d.ts +5 -0
  333. package/dist/utils/generateCode.js +9 -0
  334. package/dist/utils/logger.d.ts +10 -0
  335. package/dist/utils/logger.js +20 -0
  336. package/package.json +59 -33
  337. package/cli.js +0 -46
  338. package/dist/db/CrudService.d.ts +0 -9
  339. package/dist/db/CrudService.js +0 -45
  340. package/dist/demo/dbSchema.d.ts +0 -446
  341. package/dist/demo/dbSchema.js +0 -449
  342. package/dist/demo/testScheme.d.ts +0 -56
  343. package/dist/demo/testScheme.js +0 -42
  344. package/dist/form/CreateUpdate.svelte +0 -219
  345. package/dist/form/CreateUpdate.svelte.d.ts +0 -27
  346. package/dist/form/DataProvider.svelte +0 -23
  347. package/dist/form/DataProvider.svelte.d.ts +0 -7
  348. package/dist/form/FieldValue.svelte +0 -148
  349. package/dist/form/FieldValue.svelte.d.ts +0 -34
  350. package/dist/form/types.d.ts +0 -17
  351. package/dist/fragments/Confirm.svelte +0 -73
  352. package/dist/fragments/Confirm.svelte.d.ts +0 -7
  353. package/dist/fragments/Frame.svelte +0 -19
  354. package/dist/fragments/Frame.svelte.d.ts +0 -32
  355. package/dist/fragments/InfoLine.svelte +0 -21
  356. package/dist/fragments/InfoLine.svelte.d.ts +0 -35
  357. package/dist/fragments/Selector.svelte +0 -26
  358. package/dist/fragments/Selector.svelte.d.ts +0 -38
  359. package/dist/main/machine/MachineSchemeField.d.ts +0 -19
  360. package/dist/types/appschemeTypes.d.ts +0 -71
  361. package/dist/types/appschemeTypes.js +0 -83
  362. package/dist/ui/CollectionButton.svelte +0 -29
  363. package/dist/ui/CollectionButton.svelte.d.ts +0 -29
  364. package/dist/ui/CollectionFks.svelte +0 -24
  365. package/dist/ui/CollectionFks.svelte.d.ts +0 -9
  366. package/dist/ui/CollectionList.svelte +0 -100
  367. package/dist/ui/CollectionList.svelte.d.ts +0 -36
  368. package/dist/ui/CollectionListFieldValues.svelte +0 -59
  369. package/dist/ui/CollectionListFieldValues.svelte.d.ts +0 -9
  370. package/dist/ui/CollectionListMenu.svelte +0 -39
  371. package/dist/ui/CollectionListMenu.svelte.d.ts +0 -34
  372. package/dist/ui/CollectionReverseFks.svelte +0 -37
  373. package/dist/ui/CollectionReverseFks.svelte.d.ts +0 -14
  374. /package/dist/{fragments → data-ui/fragments}/Skeleton.svelte.d.ts +0 -0
  375. /package/dist/{form → main/api}/types.js +0 -0
@@ -1,16 +1,8 @@
1
- import type { TplCollectionName, TplFieldRules, TplFieldType, TplFieldArgs } from "@medyll/idae-idbql";
1
+ import type { TplFieldRules, IDbForge } from '../types/index.js';
2
2
  /**
3
3
  * Utility class for parsing and constructing database field definitions (IDbForge).
4
4
  * Provides methods to analyze field rules and extract type information for schema generation.
5
5
  */
6
- export type IDbForge = {
7
- collection: TplCollectionName;
8
- fieldName: string;
9
- fieldType: TplFieldType;
10
- fieldRule: TplFieldRules;
11
- fieldArgs: TplFieldArgs;
12
- is: "array" | "object" | "fk" | "primitive";
13
- };
14
6
  export declare class MachineParserForge {
15
7
  #private;
16
8
  /**
@@ -19,29 +11,28 @@ export declare class MachineParserForge {
19
11
  constructor();
20
12
  /**
21
13
  * Test if a field rule matches a specific type (array, object, fk, primitive).
14
+ * Accepts both legacy string rules ('text-long (required)') and new object rules ({ type: 'text', required: true }).
22
15
  * @param what - The type to test for ("array", "object", "fk", "primitive").
23
- * @param fieldRule - The field rule string to analyze.
16
+ * @param fieldRule - The field rule (string or object) to analyze.
24
17
  * @returns Partial IDbForge object if the rule matches, otherwise undefined.
25
18
  */
26
- testIs(what: "array" | "object" | "fk" | "primitive", fieldRule: TplFieldRules): Partial<IDbForge> | undefined;
19
+ testIs(what: 'array' | 'object' | 'fk' | 'primitive', fieldRule: TplFieldRules | string): Partial<IDbForge> | undefined;
27
20
  /**
28
21
  * Returns a partial IDbForge object for the given type and field rule.
29
22
  * @param what - The type to extract ("array", "object", "fk", "primitive").
30
23
  * @param fieldRule - The field rule string to analyze.
31
24
  * @returns Partial IDbForge object with extracted type info.
32
25
  */
33
- is(what: "array" | "object" | "fk" | "primitive", fieldRule: TplFieldRules): Partial<IDbForge>;
26
+ is(what: 'array' | 'object' | 'fk' | 'primitive', fieldRule: string): Partial<IDbForge>;
34
27
  /**
35
- * Extracts type, rule, and argument information from a field rule string.
36
- * @param type - The type to extract ("array", "object", "fk", "primitive").
37
- * @param fieldRule - The field rule string to analyze.
38
- * @returns Partial IDbForge object with extracted details.
28
+ * Extracts type, rule, and argument information from a string field rule.
29
+ * Only called after object rules are handled by #fromObjectRule.
39
30
  */
40
- extract(type: "array" | "object" | "fk" | "primitive", fieldRule: TplFieldRules): Partial<IDbForge>;
31
+ extract(type: 'array' | 'object' | 'fk' | 'primitive', fieldRule: string): Partial<IDbForge>;
41
32
  /**
42
33
  * Constructs an IDbForge object from its components.
43
34
  * @param params - The components of the IDbForge object.
44
35
  * @returns A complete IDbForge object.
45
36
  */
46
- forge({ collection, fieldName, fieldType, fieldRule, fieldArgs, is, }: IDbForge): IDbForge;
37
+ forge(input: IDbForge): IDbForge;
47
38
  }
@@ -1,32 +1,38 @@
1
- import { MachineError } from "./machine/MachineError.js";
1
+ import { MachineError } from './machine/MachineError.js';
2
+ /**
3
+ * Utility class for parsing and constructing database field definitions (IDbForge).
4
+ * Provides methods to analyze field rules and extract type information for schema generation.
5
+ */
2
6
  export class MachineParserForge {
3
- #machineForge;
4
7
  /**
5
8
  * Create a new MachineParserForge instance.
6
9
  */
7
- constructor() {
8
- // Correction : ne pas initialiser #machineForge récursivement
9
- this.#machineForge = undefined;
10
- }
10
+ constructor() { }
11
11
  /**
12
12
  * Test if a field rule matches a specific type (array, object, fk, primitive).
13
+ * Accepts both legacy string rules ('text-long (required)') and new object rules ({ type: 'text', required: true }).
13
14
  * @param what - The type to test for ("array", "object", "fk", "primitive").
14
- * @param fieldRule - The field rule string to analyze.
15
+ * @param fieldRule - The field rule (string or object) to analyze.
15
16
  * @returns Partial IDbForge object if the rule matches, otherwise undefined.
16
17
  */
17
18
  testIs(what, fieldRule) {
19
+ // New world: object-based field rule
20
+ if (typeof fieldRule === 'object' && fieldRule !== null) {
21
+ return this.#fromObjectRule(what, fieldRule);
22
+ }
23
+ // Legacy: string-based field rule
18
24
  const typeMappings = {
19
- fk: "fk-",
20
- array: "array-of-",
21
- object: "object-",
22
- primitive: "",
25
+ fk: 'fk-',
26
+ array: 'array-of-',
27
+ object: 'object-',
28
+ primitive: ''
23
29
  };
24
30
  const prefix = typeMappings[what];
25
31
  // For primitive, ensure it does not start with any other type prefix
26
- if (what === "primitive") {
27
- if (!fieldRule.startsWith("array-of-") &&
28
- !fieldRule.startsWith("object-") &&
29
- !fieldRule.startsWith("fk-")) {
32
+ if (what === 'primitive') {
33
+ if (!fieldRule.startsWith('array-of-') &&
34
+ !fieldRule.startsWith('object-') &&
35
+ !fieldRule.startsWith('fk-')) {
30
36
  return this.is(what, fieldRule);
31
37
  }
32
38
  return undefined;
@@ -37,6 +43,50 @@ export class MachineParserForge {
37
43
  }
38
44
  return undefined;
39
45
  }
46
+ /**
47
+ * Parse a new-world object field rule into IDbForge format.
48
+ * Only returns a value when `what` matches the actual type of the rule.
49
+ */
50
+ #fromObjectRule(what, rule) {
51
+ // Fallback mirrors publishModel.ts's `fd.type ?? 'text'` — type is resolved
52
+ // catalog-first server-side (FieldList, ADR-field-type-source.md); a bare
53
+ // `{ required, readonly }` field (core convention) has no type here either.
54
+ const type = rule.type ?? 'text';
55
+ const isArray = type.startsWith('array-of-');
56
+ const isObject = type.startsWith('object-');
57
+ const isFk = type.startsWith('fk-');
58
+ const isPrimitive = !isArray && !isObject && !isFk;
59
+ const matches = {
60
+ array: isArray, object: isObject, fk: isFk, primitive: isPrimitive
61
+ };
62
+ if (!matches[what])
63
+ return undefined;
64
+ const fieldArgs = this.#argsFromObject(rule);
65
+ // Pass through any extra display/forge options (presets, preset, free, maxSize, etc.).
66
+ // `group` is scheme metadata, not part of IDbForge, so it's stripped along with the
67
+ // other known base keys.
68
+ const { type: _t, required: _req, readonly: _ro, private: _priv, group: _grp, ...extras } = rule;
69
+ return {
70
+ fieldType: type,
71
+ fieldArgs,
72
+ is: what,
73
+ ...extras,
74
+ ...(type === 'image' ? { accept: 'image/*' } : {}),
75
+ };
76
+ }
77
+ /**
78
+ * Extract fieldArgs array from an object rule's boolean flags.
79
+ */
80
+ #argsFromObject(rule) {
81
+ const args = [];
82
+ if (rule.required)
83
+ args.push('required');
84
+ if (rule.readonly)
85
+ args.push('readonly');
86
+ if (rule.private)
87
+ args.push('private');
88
+ return args.length ? args : undefined;
89
+ }
40
90
  /**
41
91
  * Returns a partial IDbForge object for the given type and field rule.
42
92
  * @param what - The type to extract ("array", "object", "fk", "primitive").
@@ -47,10 +97,8 @@ export class MachineParserForge {
47
97
  return this.extract(what, fieldRule);
48
98
  }
49
99
  /**
50
- * Extracts type, rule, and argument information from a field rule string.
51
- * @param type - The type to extract ("array", "object", "fk", "primitive").
52
- * @param fieldRule - The field rule string to analyze.
53
- * @returns Partial IDbForge object with extracted details.
100
+ * Extracts type, rule, and argument information from a string field rule.
101
+ * Only called after object rules are handled by #fromObjectRule.
54
102
  */
55
103
  extract(type, fieldRule) {
56
104
  /**
@@ -60,8 +108,9 @@ export class MachineParserForge {
60
108
  * @returns The substring after the pattern.
61
109
  */
62
110
  function extractAfter(pattern, source) {
63
- const reg = source?.split("(")?.[0];
64
- return reg.split(pattern)[1];
111
+ const reg = source?.split('(')?.[0];
112
+ const after = reg.split(pattern)[1];
113
+ return (after?.split('(')?.[0]?.trim() ?? '');
65
114
  }
66
115
  /**
67
116
  * Helper to extract the main type and argument list from a field rule string.
@@ -69,15 +118,18 @@ export class MachineParserForge {
69
118
  * @returns Object with the main type (piece) and argument array (args).
70
119
  */
71
120
  function extractArgs(source) {
72
- const [piece, remaining] = source.split("(");
121
+ const [piece, remaining] = source.split('(');
73
122
  if (!remaining)
74
- return { piece: piece.trim(), args: [] };
123
+ return { piece: piece.trim() };
75
124
  let central;
76
125
  if (remaining !== undefined) {
77
- [central] = remaining.split(")");
126
+ [central] = remaining.split(')');
78
127
  }
79
128
  const args = central
80
- ? central.split(" ")
129
+ ? central
130
+ .split(' ')
131
+ .map((s) => s.trim())
132
+ .filter(Boolean)
81
133
  : undefined;
82
134
  return { piece: piece.trim(), args };
83
135
  }
@@ -85,27 +137,32 @@ export class MachineParserForge {
85
137
  let fieldType;
86
138
  const fieldArgs = extractedArgs?.args;
87
139
  switch (type) {
88
- case "array":
89
- fieldType = extractAfter("array-of-", fieldRule);
140
+ case 'array':
141
+ fieldType = extractAfter('array-of-', fieldRule);
90
142
  break;
91
- case "object":
92
- fieldType = extractAfter("object-", fieldRule);
143
+ case 'object':
144
+ fieldType = extractAfter('object-', fieldRule);
93
145
  break;
94
- case "fk":
95
- fieldType = "fk-" + extractAfter("fk-", fieldRule);
146
+ case 'fk':
147
+ fieldType = 'fk-' + extractAfter('fk-', fieldRule);
96
148
  break;
97
- case "primitive":
149
+ case 'primitive':
98
150
  fieldType = extractedArgs?.piece;
99
151
  break;
100
152
  }
101
- return { fieldType, fieldRule, fieldArgs, is: type };
153
+ const result = {
154
+ fieldType,
155
+ fieldArgs,
156
+ is: type
157
+ };
158
+ return result;
102
159
  }
103
160
  /**
104
161
  * Constructs an IDbForge object from its components.
105
162
  * @param params - The components of the IDbForge object.
106
163
  * @returns A complete IDbForge object.
107
164
  */
108
- forge({ collection, fieldName, fieldType, fieldRule, fieldArgs, is, }) {
109
- return { collection, fieldName, fieldType, fieldRule, fieldArgs, is };
165
+ forge(input) {
166
+ return { ...input };
110
167
  }
111
168
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * IDB-backed schema cache for remote schema loading during machine.boot().
3
+ * Stores raw IdbqModel JSON keyed by URL in a dedicated _schema store.
4
+ * Uses stale-while-revalidate: serve cache immediately, refresh in background.
5
+ */
6
+ export declare function readSchemaCache(url: string): Promise<unknown | null>;
7
+ export declare function clearSchemaCache(): Promise<void>;
8
+ export declare function writeSchemaCache(url: string, data: unknown): Promise<void>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * IDB-backed schema cache for remote schema loading during machine.boot().
3
+ * Stores raw IdbqModel JSON keyed by URL in a dedicated _schema store.
4
+ * Uses stale-while-revalidate: serve cache immediately, refresh in background.
5
+ */
6
+ const DB_NAME = '_machine_schema_cache';
7
+ const STORE_NAME = '_schema';
8
+ const DB_VERSION = 1;
9
+ function openCacheDb() {
10
+ return new Promise((resolve, reject) => {
11
+ const req = indexedDB.open(DB_NAME, DB_VERSION);
12
+ req.onupgradeneeded = () => {
13
+ req.result.createObjectStore(STORE_NAME, { keyPath: 'url' });
14
+ };
15
+ req.onsuccess = () => resolve(req.result);
16
+ req.onerror = () => reject(req.error);
17
+ });
18
+ }
19
+ export async function readSchemaCache(url) {
20
+ try {
21
+ const db = await openCacheDb();
22
+ const tx = db.transaction(STORE_NAME, 'readonly');
23
+ const store = tx.objectStore(STORE_NAME);
24
+ return await new Promise((resolve, reject) => {
25
+ const req = store.get(url);
26
+ req.onsuccess = () => resolve(req.result?.data ?? null);
27
+ req.onerror = () => reject(req.error);
28
+ });
29
+ }
30
+ catch (err) {
31
+ console.warn('[idae-machine] Schema cache read failed — will fetch fresh:', err);
32
+ return null;
33
+ }
34
+ }
35
+ export async function clearSchemaCache() {
36
+ await new Promise((resolve) => {
37
+ const req = indexedDB.deleteDatabase(DB_NAME);
38
+ req.onsuccess = () => resolve();
39
+ req.onerror = () => resolve(); // non-fatal
40
+ req.onblocked = () => resolve();
41
+ });
42
+ }
43
+ export async function writeSchemaCache(url, data) {
44
+ try {
45
+ const db = await openCacheDb();
46
+ const tx = db.transaction(STORE_NAME, 'readwrite');
47
+ const store = tx.objectStore(STORE_NAME);
48
+ await new Promise((resolve, reject) => {
49
+ const req = store.put({ url, data, cachedAt: Date.now() });
50
+ req.onsuccess = () => resolve();
51
+ req.onerror = () => reject(req.error);
52
+ });
53
+ }
54
+ catch (err) {
55
+ // Cache write failure is non-fatal — schema will be re-fetched on next boot
56
+ console.warn('[idae-machine] Schema cache write failed:', err);
57
+ }
58
+ }
@@ -0,0 +1,17 @@
1
+ import type { MachineModel } from '../types/index.js';
2
+ export type SchemaDiagnosticSeverity = 'error' | 'warning';
3
+ export interface SchemaDiagnostic {
4
+ severity: SchemaDiagnosticSeverity;
5
+ collection: string;
6
+ path: string;
7
+ code: string;
8
+ message: string;
9
+ }
10
+ export interface SchemaDiagnosticReport {
11
+ valid: boolean;
12
+ errors: number;
13
+ warnings: number;
14
+ issues: SchemaDiagnostic[];
15
+ }
16
+ /** Pure schema inspection. It never mutates the model and performs no I/O. */
17
+ export declare function diagnoseMachineModel(model: MachineModel): SchemaDiagnosticReport;
@@ -0,0 +1,73 @@
1
+ const TEMPORAL_TYPES = new Set(['date', 'datetime', 'time']);
2
+ const PERMISSIONS = new Set(['C', 'R', 'U', 'D', 'L', 'X']);
3
+ function issue(issues, severity, collection, path, code, message) {
4
+ issues.push({ severity, collection, path, code, message });
5
+ }
6
+ function hasAccessor(collection, accessor) {
7
+ const [root, relation] = accessor.split('.');
8
+ if (root === 'fks')
9
+ return !!relation && relation in (collection.fks ?? collection.fkRelations ?? {});
10
+ return root in (collection.fields ?? {});
11
+ }
12
+ function diagnoseCollection(name, collection, model, issues) {
13
+ const fields = collection.fields ?? {};
14
+ const relations = collection.fks ?? collection.fkRelations ?? {};
15
+ const keyField = (collection.keyPath ?? '++id').replace(/^\+\+/, '');
16
+ if (!(keyField in fields)) {
17
+ issue(issues, 'error', name, 'keyPath', 'missing-index-field', `Index field "${keyField}" is not declared.`);
18
+ }
19
+ if (!('code' in fields)) {
20
+ issue(issues, 'error', name, 'fields.code', 'missing-code-field', 'Semantic field "code" is required.');
21
+ }
22
+ for (const [relation, definition] of Object.entries(relations)) {
23
+ if (!(definition.code in model)) {
24
+ issue(issues, 'error', name, `fkRelations.${relation}`, 'missing-fk-target', `Relation "${relation}" targets unknown collection "${definition.code}".`);
25
+ }
26
+ }
27
+ for (const accessor of collection.template?.presentation?.split(/\s+/).filter(Boolean) ?? []) {
28
+ if (!hasAccessor(collection, accessor)) {
29
+ issue(issues, 'warning', name, 'template.presentation', 'unknown-presentation-field', `Presentation accessor "${accessor}" is not declared.`);
30
+ }
31
+ }
32
+ for (const sort of collection.defaultSort ?? []) {
33
+ if (!hasAccessor(collection, sort.field)) {
34
+ issue(issues, 'warning', name, 'defaultSort', 'unknown-sort-field', `Default sort field "${sort.field}" is not declared.`);
35
+ }
36
+ }
37
+ if (collection.timespan) {
38
+ for (const endpoint of ['start', 'end']) {
39
+ const fieldName = collection.timespan[endpoint];
40
+ const field = fields[fieldName];
41
+ if (!field) {
42
+ issue(issues, 'error', name, `timespan.${endpoint}`, 'missing-timespan-field', `Timespan ${endpoint} field "${fieldName}" is not declared.`);
43
+ }
44
+ else if (!field.type || !TEMPORAL_TYPES.has(field.type)) {
45
+ issue(issues, 'error', name, `timespan.${endpoint}`, 'invalid-timespan-type', `Timespan field "${fieldName}" must be date, datetime or time.`);
46
+ }
47
+ }
48
+ }
49
+ for (const [viewName, view] of Object.entries(collection._views ?? {})) {
50
+ for (const field of view ?? []) {
51
+ if (!hasAccessor(collection, field.name)) {
52
+ issue(issues, 'warning', name, `_views.${viewName}`, 'unknown-view-field', `View "${viewName}" references unknown field "${field.name}".`);
53
+ }
54
+ }
55
+ }
56
+ for (const [policy, permissions] of Object.entries(collection.rights ?? {})) {
57
+ for (const permission of permissions ?? []) {
58
+ if (!PERMISSIONS.has(permission)) {
59
+ issue(issues, 'error', name, `rights.${policy}`, 'invalid-permission', `Unknown permission "${permission}".`);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ /** Pure schema inspection. It never mutates the model and performs no I/O. */
65
+ export function diagnoseMachineModel(model) {
66
+ const issues = [];
67
+ for (const [name, collection] of Object.entries(model)) {
68
+ diagnoseCollection(name, collection, model, issues);
69
+ }
70
+ const errors = issues.filter((entry) => entry.severity === 'error').length;
71
+ const warnings = issues.length - errors;
72
+ return { valid: errors === 0, errors, warnings, issues };
73
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * machineSchemaLoader.ts
3
+ * Stale-while-revalidate schema fetching for machine.boot().
4
+ * Reads from IDB cache, starts machine immediately, refreshes in background.
5
+ */
6
+ import type { MachineModel } from '../types/index.js';
7
+ export interface SchemaLoaderCallbacks {
8
+ onModel: (model: MachineModel) => void;
9
+ onStart: () => void;
10
+ onDrift: () => Promise<void>;
11
+ }
12
+ /**
13
+ * Load schema with stale-while-revalidate strategy.
14
+ * - Cache hit → call onModel + onStart immediately, refresh in background.
15
+ * - Cache miss → fetch, cache, call onModel + onStart.
16
+ * Returns an EventTarget that emits 'schema:updated' when background refresh brings new data.
17
+ */
18
+ export declare function loadSchema(url: string, callbacks: SchemaLoaderCallbacks): Promise<EventTarget>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * machineSchemaLoader.ts
3
+ * Stale-while-revalidate schema fetching for machine.boot().
4
+ * Reads from IDB cache, starts machine immediately, refreshes in background.
5
+ */
6
+ import { readSchemaCache, writeSchemaCache } from './machineSchemaCache.js';
7
+ /**
8
+ * Load schema with stale-while-revalidate strategy.
9
+ * - Cache hit → call onModel + onStart immediately, refresh in background.
10
+ * - Cache miss → fetch, cache, call onModel + onStart.
11
+ * Returns an EventTarget that emits 'schema:updated' when background refresh brings new data.
12
+ */
13
+ export async function loadSchema(url, callbacks) {
14
+ const emitter = new EventTarget();
15
+ const cached = await readSchemaCache(url);
16
+ if (cached) {
17
+ callbacks.onModel(cached);
18
+ callbacks.onStart();
19
+ fetch(url)
20
+ .then((r) => r.json())
21
+ .then(async (fresh) => {
22
+ if (JSON.stringify(fresh) !== JSON.stringify(cached)) {
23
+ await writeSchemaCache(url, fresh);
24
+ callbacks.onModel(fresh);
25
+ await callbacks.onDrift();
26
+ emitter.dispatchEvent(new CustomEvent('schema:updated', { detail: fresh }));
27
+ }
28
+ })
29
+ .catch((err) => {
30
+ console.warn('[idae-machine] Background schema refresh failed:', err);
31
+ });
32
+ }
33
+ else {
34
+ const res = await fetch(url);
35
+ if (!res.ok)
36
+ throw new Error(`[idae-machine] Schema fetch failed: ${res.status} ${res.statusText}`);
37
+ const model = await res.json();
38
+ await writeSchemaCache(url, model);
39
+ callbacks.onModel(model);
40
+ callbacks.onStart();
41
+ }
42
+ return emitter;
43
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * machineSeed.ts
3
+ * Unified seed mechanism — same call for any collection.
4
+ */
5
+ /**
6
+ * Seed collections with initial data.
7
+ * Works for any collection — core or business (vehicle, reservation…).
8
+ *
9
+ * @param data - Map of collection name → rows to insert.
10
+ * @param options.onlyIfEmpty - When true, skips collections that already have data (idempotent).
11
+ *
12
+ * @example
13
+ * // Always insert
14
+ * seed({ vehicle: [{ brand: 'Renault', model: 'Clio' }] });
15
+ *
16
+ * // Idempotent — only inserts if the collection is empty
17
+ * seed({ vehicle: [{ brand: 'Renault', model: 'Clio' }] }, { onlyIfEmpty: true });
18
+ */
19
+ export declare function seed(data: Record<string, unknown[]>, { onlyIfEmpty }?: {
20
+ onlyIfEmpty?: boolean;
21
+ }): Promise<void>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * machineSeed.ts
3
+ * Unified seed mechanism — same call for any collection.
4
+ */
5
+ import { machine } from './machine.js';
6
+ import { getCodeFieldConvention } from './ext/hooks.js';
7
+ /** Auto-fill the semantic code field when a row has an id but no code. */
8
+ function withCode(row) {
9
+ if (row && typeof row === 'object') {
10
+ const r = row;
11
+ const codeField = getCodeFieldConvention()?.codeFieldName ?? 'code';
12
+ if ((r[codeField] === undefined || r[codeField] === null || r[codeField] === '') && r.id != null) {
13
+ return { ...r, [codeField]: String(r.id) };
14
+ }
15
+ }
16
+ return row;
17
+ }
18
+ /**
19
+ * Seed collections with initial data.
20
+ * Works for any collection — core or business (vehicle, reservation…).
21
+ *
22
+ * @param data - Map of collection name → rows to insert.
23
+ * @param options.onlyIfEmpty - When true, skips collections that already have data (idempotent).
24
+ *
25
+ * @example
26
+ * // Always insert
27
+ * seed({ vehicle: [{ brand: 'Renault', model: 'Clio' }] });
28
+ *
29
+ * // Idempotent — only inserts if the collection is empty
30
+ * seed({ vehicle: [{ brand: 'Renault', model: 'Clio' }] }, { onlyIfEmpty: true });
31
+ */
32
+ export async function seed(data, { onlyIfEmpty = false } = {}) {
33
+ for (const [collection, rows] of Object.entries(data)) {
34
+ const store = machine.collection(collection);
35
+ if (onlyIfEmpty) {
36
+ const existing = await store.getAll();
37
+ if (existing.length > 0)
38
+ continue;
39
+ }
40
+ for (const row of rows) {
41
+ await store.create(withCode(row));
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,35 @@
1
+ import type { Component } from 'svelte';
2
+ type AnyComponent = Component<any, any, any>;
3
+ type ComponentLoader = () => Promise<{
4
+ default: AnyComponent;
5
+ }>;
6
+ export interface ComponentRegistryEntry {
7
+ loader: ComponentLoader;
8
+ resolved?: AnyComponent;
9
+ }
10
+ export declare class ComponentRegistry {
11
+ private registry;
12
+ register(key: string, loader: ComponentLoader): void;
13
+ registerMany(entries: Record<string, ComponentLoader>): void;
14
+ resolve(key: string): Promise<AnyComponent>;
15
+ has(key: string): boolean;
16
+ unregister(key: string): boolean;
17
+ keys(): string[];
18
+ clear(): void;
19
+ }
20
+ export declare const componentRegistry: ComponentRegistry;
21
+ export type ComponentLoaderFn = ComponentLoader;
22
+ /**
23
+ * Augmentable by domain code — main/ (engine) can't hardcode literal frame keys
24
+ * (FrameCatalog is a pluggable ext-point, see machine.ts composition root), but
25
+ * doesn't have to fall back to bare `string` either. Domain layer (idae/frames/
26
+ * FrameCatalog.ts) declares `interface FrameKeyRegistry extends Record<...>`
27
+ * for this same module specifier; TS merges it in at compile time (ambient
28
+ * declaration merging, no runtime import — main→idae law untouched). Falls
29
+ * back to `string` only if nothing augments it (e.g. a different domain swaps
30
+ * in its own FrameCatalog without augmenting this interface).
31
+ */
32
+ export interface FrameKeyRegistry {
33
+ }
34
+ export type RegistryKey = keyof FrameKeyRegistry extends never ? string : keyof FrameKeyRegistry;
35
+ export {};
@@ -0,0 +1,35 @@
1
+ export class ComponentRegistry {
2
+ registry = new Map();
3
+ register(key, loader) {
4
+ this.registry.set(key, { loader });
5
+ }
6
+ registerMany(entries) {
7
+ for (const [key, loader] of Object.entries(entries)) {
8
+ this.register(key, loader);
9
+ }
10
+ }
11
+ async resolve(key) {
12
+ const entry = this.registry.get(key);
13
+ if (!entry) {
14
+ throw new Error(`[registry] unknown: ${key}`);
15
+ }
16
+ if (!entry.resolved) {
17
+ const mod = await entry.loader();
18
+ entry.resolved = mod.default;
19
+ }
20
+ return entry.resolved;
21
+ }
22
+ has(key) {
23
+ return this.registry.has(key);
24
+ }
25
+ unregister(key) {
26
+ return this.registry.delete(key);
27
+ }
28
+ keys() {
29
+ return Array.from(this.registry.keys());
30
+ }
31
+ clear() {
32
+ this.registry.clear();
33
+ }
34
+ }
35
+ export const componentRegistry = new ComponentRegistry();
@@ -0,0 +1,17 @@
1
+ export interface LoadInSegment {
2
+ targetId: string;
3
+ modulePath: string;
4
+ collection: string;
5
+ collectionId?: string;
6
+ vars?: Record<string, string>;
7
+ }
8
+ /**
9
+ * Parse a URL containing one or more +targetId segments into LoadInSegment[].
10
+ *
11
+ * URL format: /+targetId/modulePath/collection[/collectionId][?vars]
12
+ * Multi-segment: /+t1/mod1/col1/42/+t2/mod2/col2?x=1
13
+ *
14
+ * Decision: URL without any + prefix returns [] (not an error).
15
+ * This allows the parser to be used safely on any URL.
16
+ */
17
+ export declare function parseLoadInUrl(url: string): LoadInSegment[];