@medyll/idae-machine 0.129.0 → 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.
Files changed (405) hide show
  1. package/README.md +462 -300
  2. package/cli.cjs +22 -0
  3. package/dist/__fixtures__/demoModel.d.ts +79 -0
  4. package/dist/__fixtures__/demoModel.js +146 -0
  5. package/dist/ai/frame/AiChatSession.svelte +152 -0
  6. package/dist/ai/frame/AiChatSession.svelte.d.ts +7 -0
  7. package/dist/ai/frame/index.d.ts +1 -0
  8. package/dist/ai/frame/index.js +2 -0
  9. package/dist/ai/index.d.ts +9 -0
  10. package/dist/ai/index.js +12 -0
  11. package/dist/ai/schema/ai-catalogs.d.ts +2 -0
  12. package/dist/ai/schema/ai-catalogs.js +86 -0
  13. package/dist/ai/schema/ai-chat-session.d.ts +2 -0
  14. package/dist/ai/schema/ai-chat-session.js +35 -0
  15. package/dist/ai/schema/ai-companion.d.ts +2 -0
  16. package/dist/ai/schema/ai-companion.js +25 -0
  17. package/dist/ai/schema/ai-message.d.ts +2 -0
  18. package/dist/ai/schema/ai-message.js +20 -0
  19. package/dist/ai/schema/ai-tool-call.d.ts +2 -0
  20. package/dist/ai/schema/ai-tool-call.js +18 -0
  21. package/dist/ai/schema/ai-user-prompt.d.ts +2 -0
  22. package/dist/ai/schema/ai-user-prompt.js +17 -0
  23. package/dist/ai/schema/tag.d.ts +2 -0
  24. package/dist/ai/schema/tag.js +14 -0
  25. package/dist/ai/streamIntoRecord.d.ts +31 -0
  26. package/dist/ai/streamIntoRecord.js +79 -0
  27. package/dist/config.d.ts +17 -0
  28. package/dist/config.js +19 -0
  29. package/dist/data-ui/controls/AlphabetFilter.svelte +114 -0
  30. package/dist/data-ui/controls/AlphabetFilter.svelte.d.ts +10 -0
  31. package/dist/data-ui/controls/ButtonAction.svelte +151 -0
  32. package/dist/data-ui/controls/ButtonAction.svelte.d.ts +18 -0
  33. package/dist/data-ui/controls/DataFind.svelte +174 -0
  34. package/dist/data-ui/controls/DataFind.svelte.d.ts +10 -0
  35. package/dist/data-ui/controls/DataGroup.svelte +150 -0
  36. package/dist/data-ui/controls/DataGroup.svelte.d.ts +7 -0
  37. package/dist/data-ui/controls/DataSort.svelte +78 -0
  38. package/dist/data-ui/controls/DataSort.svelte.d.ts +9 -0
  39. package/dist/data-ui/controls/DataToolbar.svelte +67 -0
  40. package/dist/data-ui/controls/DataToolbar.svelte.d.ts +11 -0
  41. package/dist/data-ui/controls/Find.svelte +38 -0
  42. package/dist/data-ui/controls/Find.svelte.d.ts +9 -0
  43. package/dist/data-ui/controls/FkFilter.svelte +94 -0
  44. package/dist/data-ui/controls/FkFilter.svelte.d.ts +11 -0
  45. package/dist/data-ui/controls/Group.svelte +36 -0
  46. package/dist/data-ui/controls/Group.svelte.d.ts +8 -0
  47. package/dist/data-ui/controls/ListMode.svelte +79 -0
  48. package/dist/data-ui/controls/ListMode.svelte.d.ts +10 -0
  49. package/dist/data-ui/controls/Sort.svelte +100 -0
  50. package/dist/data-ui/controls/Sort.svelte.d.ts +8 -0
  51. package/dist/data-ui/data/DataCount.svelte +67 -0
  52. package/dist/data-ui/data/DataCount.svelte.d.ts +36 -0
  53. package/dist/data-ui/data/DataFk.svelte +54 -0
  54. package/dist/data-ui/data/DataFk.svelte.d.ts +11 -0
  55. package/dist/data-ui/data/DataForm.svelte +191 -0
  56. package/dist/data-ui/data/DataForm.svelte.d.ts +15 -0
  57. package/dist/data-ui/data/DataList.svelte +645 -0
  58. package/dist/data-ui/data/DataList.svelte.d.ts +75 -0
  59. package/dist/data-ui/data/DataListFk.svelte +111 -0
  60. package/dist/data-ui/data/DataListFk.svelte.d.ts +13 -0
  61. package/dist/data-ui/data/DataListRfk.svelte +111 -0
  62. package/dist/data-ui/data/DataListRfk.svelte.d.ts +13 -0
  63. package/dist/data-ui/data/DataRecord.svelte +167 -0
  64. package/dist/data-ui/data/DataRecord.svelte.d.ts +22 -0
  65. package/dist/data-ui/data/DataRfk.svelte +73 -0
  66. package/dist/data-ui/data/DataRfk.svelte.d.ts +15 -0
  67. package/dist/data-ui/data/index.d.ts +7 -0
  68. package/dist/data-ui/data/index.js +8 -0
  69. package/dist/data-ui/field/DataField.svelte +343 -0
  70. package/dist/data-ui/field/DataField.svelte.d.ts +33 -0
  71. package/dist/data-ui/field/DataFieldEdit.svelte +103 -0
  72. package/dist/data-ui/field/DataFieldEdit.svelte.d.ts +14 -0
  73. package/dist/data-ui/field/index.d.ts +2 -0
  74. package/dist/data-ui/field/index.js +3 -0
  75. package/dist/data-ui/field/snippets/FieldAiPrompt.svelte +145 -0
  76. package/dist/data-ui/field/snippets/FieldAiPrompt.svelte.d.ts +14 -0
  77. package/dist/data-ui/field/snippets/FieldBoolean.svelte +43 -0
  78. package/dist/data-ui/field/snippets/FieldBoolean.svelte.d.ts +12 -0
  79. package/dist/data-ui/field/snippets/FieldColor.svelte +48 -0
  80. package/dist/data-ui/field/snippets/FieldColor.svelte.d.ts +10 -0
  81. package/dist/data-ui/field/snippets/FieldCurrency.svelte +105 -0
  82. package/dist/data-ui/field/snippets/FieldCurrency.svelte.d.ts +15 -0
  83. package/dist/data-ui/field/snippets/FieldEmail.svelte +77 -0
  84. package/dist/data-ui/field/snippets/FieldEmail.svelte.d.ts +14 -0
  85. package/dist/data-ui/field/snippets/FieldIcon.svelte +73 -0
  86. package/dist/data-ui/field/snippets/FieldIcon.svelte.d.ts +11 -0
  87. package/dist/data-ui/field/snippets/FieldSelect.svelte +71 -0
  88. package/dist/data-ui/field/snippets/FieldSelect.svelte.d.ts +15 -0
  89. package/dist/data-ui/field/snippets/FieldText.svelte +52 -0
  90. package/dist/data-ui/field/snippets/FieldText.svelte.d.ts +13 -0
  91. package/dist/data-ui/field/snippets/FieldTextarea.svelte +50 -0
  92. package/dist/data-ui/field/snippets/FieldTextarea.svelte.d.ts +13 -0
  93. package/dist/data-ui/field/snippets/index.d.ts +9 -0
  94. package/dist/data-ui/field/snippets/index.js +10 -0
  95. package/dist/data-ui/fragments/ContextMenu.svelte +109 -0
  96. package/dist/data-ui/fragments/ContextMenu.svelte.d.ts +4 -0
  97. package/dist/data-ui/fragments/ContextMenuContent.svelte +275 -0
  98. package/dist/data-ui/fragments/ContextMenuContent.svelte.d.ts +8 -0
  99. package/dist/data-ui/fragments/Frame.svelte +43 -0
  100. package/dist/data-ui/fragments/Frame.svelte.d.ts +10 -0
  101. package/dist/data-ui/fragments/InfoLine.svelte +123 -0
  102. package/dist/data-ui/fragments/InfoLine.svelte.d.ts +12 -0
  103. package/dist/data-ui/fragments/Selector.svelte +56 -0
  104. package/dist/data-ui/fragments/Selector.svelte.d.ts +10 -0
  105. package/dist/{fragments → data-ui/fragments}/Skeleton.svelte +3 -3
  106. package/dist/data-ui/fragments/Tile.svelte +126 -0
  107. package/dist/data-ui/fragments/Tile.svelte.d.ts +14 -0
  108. package/dist/data-ui/fragments/contextMenu.svelte.d.ts +22 -0
  109. package/dist/data-ui/fragments/contextMenu.svelte.js +31 -0
  110. package/dist/data-ui/fragments/dialog/Dialog.svelte +185 -0
  111. package/dist/data-ui/fragments/dialog/Dialog.svelte.d.ts +29 -0
  112. package/dist/data-ui/fragments/dialog/dialog.svelte.d.ts +27 -0
  113. package/dist/data-ui/fragments/dialog/dialog.svelte.js +41 -0
  114. package/dist/data-ui/fragments/index.d.ts +11 -0
  115. package/dist/data-ui/fragments/index.js +11 -0
  116. package/dist/data-ui/utils/__tests__/HostProbe.svelte +18 -0
  117. package/dist/data-ui/utils/__tests__/HostProbe.svelte.d.ts +8 -0
  118. package/dist/data-ui/utils/data-utils.d.ts +29 -0
  119. package/dist/data-ui/utils/data-utils.js +83 -0
  120. package/dist/data-ui/utils/dataRelationUtils.d.ts +37 -0
  121. package/dist/data-ui/utils/dataRelationUtils.js +125 -0
  122. package/dist/data-ui/utils/diagramUtils.d.ts +6 -0
  123. package/dist/data-ui/utils/diagramUtils.js +131 -0
  124. package/dist/data-ui/utils/draggable.d.ts +15 -0
  125. package/dist/data-ui/utils/draggable.js +61 -0
  126. package/dist/data-ui/utils/menuPrefs.d.ts +80 -0
  127. package/dist/data-ui/utils/menuPrefs.js +119 -0
  128. package/dist/data-ui/utils/useMachinePrefs.svelte.d.ts +38 -0
  129. package/dist/data-ui/utils/useMachinePrefs.svelte.js +117 -0
  130. package/dist/data-ui/utils/useMenuTree.svelte.d.ts +26 -0
  131. package/dist/data-ui/utils/useMenuTree.svelte.js +68 -0
  132. package/dist/data-ui/utils/useRecordData.svelte.d.ts +22 -0
  133. package/dist/data-ui/utils/useRecordData.svelte.js +50 -0
  134. package/dist/data-ui/utils/useViewFields.svelte.d.ts +22 -0
  135. package/dist/data-ui/utils/useViewFields.svelte.js +59 -0
  136. package/dist/demo/.gitkeep +0 -0
  137. package/dist/demo/demo-status.json +9 -0
  138. package/dist/idae/boot.d.ts +28 -0
  139. package/dist/idae/boot.js +43 -0
  140. package/dist/idae/bridge/register.d.ts +4 -0
  141. package/dist/idae/bridge/register.js +15 -0
  142. package/dist/idae/capabilities/Capabilities.d.ts +10 -0
  143. package/dist/idae/capabilities/Capabilities.js +34 -0
  144. package/dist/idae/codefield/CodeFieldConvention.d.ts +3 -0
  145. package/dist/idae/codefield/CodeFieldConvention.js +25 -0
  146. package/dist/idae/fieldcatalog/defaultFieldTypesDef.d.ts +2 -0
  147. package/dist/idae/fieldcatalog/defaultFieldTypesDef.js +104 -0
  148. package/dist/idae/frames/FrameCatalog.d.ts +31 -0
  149. package/dist/idae/frames/FrameCatalog.js +31 -0
  150. package/dist/idae/index.d.ts +14 -0
  151. package/dist/idae/index.js +13 -0
  152. package/dist/idae/menu/IdaeMenuManager.d.ts +79 -0
  153. package/dist/idae/menu/IdaeMenuManager.js +108 -0
  154. package/dist/idae/menu/IdaeMenuStore.d.ts +77 -0
  155. package/dist/idae/menu/IdaeMenuStore.js +68 -0
  156. package/dist/idae/menu/menuSnapshot.d.ts +30 -0
  157. package/dist/idae/menu/menuSnapshot.js +30 -0
  158. package/dist/idae/meta/MetaModelProvider.d.ts +11 -0
  159. package/dist/idae/meta/MetaModelProvider.js +43 -0
  160. package/dist/idae/relations/RelationPolicy.d.ts +19 -0
  161. package/dist/idae/relations/RelationPolicy.js +125 -0
  162. package/dist/idae/rights/RightsPolicy.d.ts +16 -0
  163. package/dist/idae/rights/RightsPolicy.js +80 -0
  164. package/dist/idae/userscope/UserScopePolicy.d.ts +9 -0
  165. package/dist/idae/userscope/UserScopePolicy.js +42 -0
  166. package/dist/idae/userscope/navTracking.d.ts +11 -0
  167. package/dist/idae/userscope/navTracking.js +15 -0
  168. package/dist/index.d.ts +68 -43
  169. package/dist/index.js +82 -44
  170. package/dist/main/__tests__/_relationTestUtils.d.ts +12 -0
  171. package/dist/main/__tests__/_relationTestUtils.js +53 -0
  172. package/dist/main/__tests__/helpers/mockCollection.d.ts +21 -0
  173. package/dist/main/__tests__/helpers/mockCollection.js +27 -0
  174. package/dist/main/api/types.d.ts +29 -0
  175. package/dist/main/ext/hooks.d.ts +32 -0
  176. package/dist/main/ext/hooks.js +31 -0
  177. package/dist/main/ext/interfaces.d.ts +69 -0
  178. package/dist/main/ext/interfaces.js +3 -0
  179. package/dist/main/ext/registry.d.ts +29 -0
  180. package/dist/main/ext/registry.js +30 -0
  181. package/dist/main/frame/MachineFrameManager.d.ts +187 -0
  182. package/dist/main/frame/MachineFrameManager.js +403 -0
  183. package/dist/main/frame/contextMenuSetup.d.ts +9 -0
  184. package/dist/main/frame/contextMenuSetup.js +42 -0
  185. package/dist/main/frame/frameUrl.d.ts +1 -0
  186. package/dist/main/frame/frameUrl.js +8 -0
  187. package/dist/main/frame/frameUtils.d.ts +16 -0
  188. package/dist/main/frame/frameUtils.js +26 -0
  189. package/dist/main/frame/linkParser.d.ts +9 -0
  190. package/dist/main/frame/linkParser.js +15 -0
  191. package/dist/main/index.d.ts +15 -0
  192. package/dist/main/index.js +19 -0
  193. package/dist/main/machine/MachineAction.d.ts +62 -0
  194. package/dist/main/machine/MachineAction.js +96 -0
  195. package/dist/main/machine/MachineError.d.ts +33 -0
  196. package/dist/main/machine/MachineError.js +49 -0
  197. package/dist/main/machine/MachineErrorValidation.d.ts +19 -0
  198. package/dist/main/machine/MachineErrorValidation.js +24 -0
  199. package/dist/main/machine/MachineFieldType.d.ts +140 -0
  200. package/dist/main/machine/MachineFieldType.js +341 -0
  201. package/dist/main/machine/MachineFkFold.d.ts +34 -0
  202. package/dist/main/machine/MachineFkFold.js +57 -0
  203. package/dist/main/machine/MachineRecordIdentity.d.ts +26 -0
  204. package/dist/main/machine/MachineRecordIdentity.js +44 -0
  205. package/dist/main/machine/MachineRights.d.ts +50 -0
  206. package/dist/main/machine/MachineRights.js +133 -0
  207. package/dist/main/machine/MachineRouter.d.ts +56 -0
  208. package/dist/main/machine/MachineRouter.js +250 -0
  209. package/dist/main/machine/MachineScheme.d.ts +54 -0
  210. package/dist/main/machine/MachineScheme.js +159 -0
  211. package/dist/main/machine/MachineSchemeField.js +67 -0
  212. package/dist/main/machine/MachineSchemeFieldForge.d.ts +84 -0
  213. package/dist/main/machine/MachineSchemeFieldForge.js +140 -0
  214. package/dist/main/machine/MachineSchemeFieldValues.d.ts +68 -0
  215. package/dist/main/machine/MachineSchemeFieldValues.js +97 -0
  216. package/dist/main/machine/MachineSchemeValidate.d.ts +107 -0
  217. package/dist/main/machine/MachineSchemeValidate.js +247 -0
  218. package/dist/main/machine/MachineSchemeValues.d.ts +120 -0
  219. package/dist/main/machine/MachineSchemeValues.js +306 -0
  220. package/dist/main/machine/SchemeFieldDefaultValues.d.ts +76 -0
  221. package/dist/main/machine/SchemeFieldDefaultValues.js +104 -0
  222. package/dist/main/machine/authState.svelte.d.ts +11 -0
  223. package/dist/main/machine/authState.svelte.js +17 -0
  224. package/dist/main/machine/fieldBuilder.d.ts +23 -0
  225. package/dist/main/machine/fieldBuilder.d.ts.map +1 -0
  226. package/dist/main/machine/fieldBuilder.js +10 -0
  227. package/dist/main/machine/fieldBuilder.js.map +1 -0
  228. package/dist/main/machine/machineLabel.d.ts +11 -0
  229. package/dist/main/machine/machineLabel.js +23 -0
  230. package/dist/main/machine/validateRules.d.ts +38 -0
  231. package/dist/main/machine/validateRules.js +109 -0
  232. package/dist/main/machine.d.ts +227 -61
  233. package/dist/main/machine.js +503 -86
  234. package/dist/main/machineDb.d.ts +25 -54
  235. package/dist/main/machineDb.js +40 -94
  236. package/dist/main/machineIdbAdapter.d.ts +83 -0
  237. package/dist/main/machineIdbAdapter.js +347 -0
  238. package/dist/main/machineModelBuilder.d.ts +31 -0
  239. package/dist/main/machineModelBuilder.js +58 -0
  240. package/dist/main/machineParserForge.d.ts +38 -0
  241. package/dist/main/machineParserForge.js +168 -0
  242. package/dist/main/machineSchemaCache.d.ts +8 -0
  243. package/dist/main/machineSchemaCache.js +58 -0
  244. package/dist/main/machineSchemaDoctor.d.ts +17 -0
  245. package/dist/main/machineSchemaDoctor.js +73 -0
  246. package/dist/main/machineSchemaLoader.d.ts +18 -0
  247. package/dist/main/machineSchemaLoader.js +43 -0
  248. package/dist/main/machineSeed.d.ts +21 -0
  249. package/dist/main/machineSeed.js +44 -0
  250. package/dist/main/router/componentRegistry.d.ts +35 -0
  251. package/dist/main/router/componentRegistry.js +35 -0
  252. package/dist/main/router/urlParser.d.ts +17 -0
  253. package/dist/main/router/urlParser.js +41 -0
  254. package/dist/main/warmupUtils.d.ts +40 -0
  255. package/dist/main/warmupUtils.js +73 -0
  256. package/dist/mcp/MachineMcpClient.d.ts +43 -0
  257. package/dist/mcp/MachineMcpClient.js +175 -0
  258. package/dist/shell/Frame.svelte +67 -0
  259. package/dist/shell/Frame.svelte.d.ts +11 -0
  260. package/dist/shell/auth/Login.svelte +244 -0
  261. package/dist/shell/auth/Login.svelte.d.ts +3 -0
  262. package/dist/shell/frame/dashboard/Dashboard.svelte +0 -0
  263. package/dist/shell/frame/dashboard/Dashboard.svelte.d.ts +26 -0
  264. package/dist/shell/frame/diagram/Diagram.svelte +244 -0
  265. package/dist/shell/frame/diagram/Diagram.svelte.d.ts +9 -0
  266. package/dist/shell/frame/explorer/Explorer.svelte +86 -0
  267. package/dist/shell/frame/explorer/Explorer.svelte.d.ts +29 -0
  268. package/dist/shell/frame/explorer/ExplorerContent.svelte +126 -0
  269. package/dist/shell/frame/explorer/ExplorerContent.svelte.d.ts +32 -0
  270. package/dist/shell/frame/index.d.ts +8 -0
  271. package/dist/shell/frame/index.js +9 -0
  272. package/dist/shell/frame/main-menu-content/MainMenuContent.svelte +100 -0
  273. package/dist/shell/frame/main-menu-content/MainMenuContent.svelte.d.ts +6 -0
  274. package/dist/shell/frame/planning/Planning.svelte +426 -0
  275. package/dist/shell/frame/planning/Planning.svelte.d.ts +12 -0
  276. package/dist/shell/frame/rbac/RbacMatrix.svelte +197 -0
  277. package/dist/shell/frame/rbac/RbacMatrix.svelte.d.ts +7 -0
  278. package/dist/shell/frame/space/Space.svelte +554 -0
  279. package/dist/shell/frame/space/Space.svelte.d.ts +8 -0
  280. package/dist/shell/frame/synthesis/Synthesis.svelte +383 -0
  281. package/dist/shell/frame/synthesis/Synthesis.svelte.d.ts +8 -0
  282. package/dist/shell/frame/today/Today.svelte +174 -0
  283. package/dist/shell/frame/today/Today.svelte.d.ts +3 -0
  284. package/dist/shell/layout/App.svelte +30 -0
  285. package/dist/shell/layout/App.svelte.d.ts +3 -0
  286. package/dist/shell/layout/Breadcrumb.svelte +67 -0
  287. package/dist/shell/layout/Breadcrumb.svelte.d.ts +12 -0
  288. package/dist/shell/layout/Columner.svelte +214 -0
  289. package/dist/shell/layout/Columner.svelte.d.ts +16 -0
  290. package/dist/shell/layout/DevResetPanel.svelte +194 -0
  291. package/dist/shell/layout/DevResetPanel.svelte.d.ts +7 -0
  292. package/dist/shell/layout/Fiche.svelte +111 -0
  293. package/dist/shell/layout/Fiche.svelte.d.ts +7 -0
  294. package/dist/shell/layout/FicheUpdate.svelte +53 -0
  295. package/dist/shell/layout/FicheUpdate.svelte.d.ts +7 -0
  296. package/dist/shell/layout/MainMenu.svelte +256 -0
  297. package/dist/shell/layout/MainMenu.svelte.d.ts +6 -0
  298. package/dist/shell/layout/MenuSettings.svelte +182 -0
  299. package/dist/shell/layout/MenuSettings.svelte.d.ts +6 -0
  300. package/dist/shell/layout/RecordTimeline.svelte +199 -0
  301. package/dist/shell/layout/RecordTimeline.svelte.d.ts +8 -0
  302. package/dist/shell/layout/RecordToolbar.svelte +39 -0
  303. package/dist/shell/layout/RecordToolbar.svelte.d.ts +7 -0
  304. package/dist/shell/layout/TaskBar.svelte +118 -0
  305. package/dist/shell/layout/TaskBar.svelte.d.ts +7 -0
  306. package/dist/shell/layout/TemplateShell.svelte +48 -0
  307. package/dist/shell/layout/TemplateShell.svelte.d.ts +15 -0
  308. package/dist/shell/layout/ThemeToggle.svelte +46 -0
  309. package/dist/shell/layout/ThemeToggle.svelte.d.ts +3 -0
  310. package/dist/shell/layout/index.d.ts +8 -0
  311. package/dist/shell/layout/index.js +9 -0
  312. package/dist/storage/ApiStorageAdapter.d.ts +41 -0
  313. package/dist/storage/ApiStorageAdapter.js +111 -0
  314. package/dist/storage/IdbStorageAdapter.d.ts +31 -0
  315. package/dist/storage/IdbStorageAdapter.js +72 -0
  316. package/dist/storage/MemoryStorageAdapter.d.ts +33 -0
  317. package/dist/storage/MemoryStorageAdapter.js +132 -0
  318. package/dist/storage/README.md +222 -0
  319. package/dist/storage/StorageAdapter.d.ts +75 -0
  320. package/dist/storage/StorageAdapter.js +7 -0
  321. package/dist/storage/demo/storage-demo.d.ts +22 -0
  322. package/dist/storage/demo/storage-demo.js +107 -0
  323. package/dist/storage/index.d.ts +9 -0
  324. package/dist/storage/index.js +9 -0
  325. package/dist/types/entity-types.d.ts +444 -0
  326. package/dist/types/entity-types.js +16 -0
  327. package/dist/types/index.d.ts +7 -0
  328. package/dist/types/index.js +6 -0
  329. package/dist/types/machine-model.d.ts +198 -0
  330. package/dist/types/machine-model.js +5 -0
  331. package/dist/types/qoolie-svelte.d.ts +11 -0
  332. package/dist/types/schema-utils.d.ts +32 -0
  333. package/dist/types/schema-utils.js +103 -0
  334. package/dist/utils/generateCode.d.ts +5 -0
  335. package/dist/utils/generateCode.js +9 -0
  336. package/dist/utils/logger.d.ts +10 -0
  337. package/dist/utils/logger.js +20 -0
  338. package/package.json +70 -31
  339. package/dist/db/CrudService.d.ts +0 -9
  340. package/dist/db/CrudService.js +0 -45
  341. package/dist/db/dbSchema.d.ts +0 -201
  342. package/dist/db/dbSchema.js +0 -205
  343. package/dist/db/fieldTypes.d.ts +0 -13
  344. package/dist/db/fieldTypes.js +0 -67
  345. package/dist/db/types.d.ts +0 -124
  346. package/dist/demo/form/CreateUpdate.svelte +0 -198
  347. package/dist/demo/form/CreateUpdate.svelte.d.ts +0 -29
  348. package/dist/demo/form/CrudZone.svelte +0 -22
  349. package/dist/demo/form/CrudZone.svelte.d.ts +0 -29
  350. package/dist/demo/form/DataProvider.svelte +0 -20
  351. package/dist/demo/form/DataProvider.svelte.d.ts +0 -9
  352. package/dist/demo/form/FieldInPlace.svelte +0 -49
  353. package/dist/demo/form/FieldInPlace.svelte.d.ts +0 -11
  354. package/dist/demo/form/FieldValue.svelte +0 -212
  355. package/dist/demo/form/FieldValue.svelte.d.ts +0 -35
  356. package/dist/demo/form/types.d.ts +0 -17
  357. package/dist/demo/form/types.js +0 -1
  358. package/dist/demo/testDbSchema.d.ts +0 -6
  359. package/dist/demo/testDbSchema.js +0 -58
  360. package/dist/demo/types.d.ts +0 -140
  361. package/dist/demo/types.js +0 -1
  362. package/dist/fragments/Confirm.svelte +0 -58
  363. package/dist/fragments/Confirm.svelte.d.ts +0 -11
  364. package/dist/fragments/Frame.svelte +0 -19
  365. package/dist/fragments/Frame.svelte.d.ts +0 -32
  366. package/dist/fragments/InfoLine.svelte +0 -21
  367. package/dist/fragments/InfoLine.svelte.d.ts +0 -35
  368. package/dist/fragments/List.svelte +0 -21
  369. package/dist/fragments/List.svelte.d.ts +0 -38
  370. package/dist/fragments/Selector.svelte +0 -26
  371. package/dist/fragments/Selector.svelte.d.ts +0 -38
  372. package/dist/main/machine/IDbCollection.d.ts +0 -69
  373. package/dist/main/machine/IDbCollection.js +0 -98
  374. package/dist/main/machine/IDbCollectionFieldForge.d.ts +0 -42
  375. package/dist/main/machine/IDbCollectionFieldForge.js +0 -74
  376. package/dist/main/machine/IDbCollectionFieldValues.d.ts +0 -46
  377. package/dist/main/machine/IDbCollectionFieldValues.js +0 -62
  378. package/dist/main/machine/IDbCollectionValues.d.ts +0 -78
  379. package/dist/main/machine/IDbCollectionValues.js +0 -203
  380. package/dist/main/machine/IDbError.d.ts +0 -6
  381. package/dist/main/machine/IDbError.js +0 -61
  382. package/dist/main/machine/IDbFormValidate.d.ts +0 -55
  383. package/dist/main/machine/IDbFormValidate.js +0 -183
  384. package/dist/main/machine/IDbValidationError.d.ts +0 -19
  385. package/dist/main/machine/IDbValidationError.js +0 -24
  386. package/dist/main/machine/types.d.ts +0 -1
  387. package/dist/main/machine/types.js +0 -1
  388. package/dist/main/machineForge.d.ts +0 -57
  389. package/dist/main/machineForge.js +0 -105
  390. package/dist/types/appschemeTypes.d.ts +0 -71
  391. package/dist/types/appschemeTypes.js +0 -83
  392. package/dist/ui/CollectionButton.svelte +0 -26
  393. package/dist/ui/CollectionButton.svelte.d.ts +0 -29
  394. package/dist/ui/CollectionFieldGuess.svelte +0 -29
  395. package/dist/ui/CollectionFieldGuess.svelte.d.ts +0 -11
  396. package/dist/ui/CollectionFks.svelte +0 -24
  397. package/dist/ui/CollectionFks.svelte.d.ts +0 -9
  398. package/dist/ui/CollectionList.svelte +0 -95
  399. package/dist/ui/CollectionList.svelte.d.ts +0 -37
  400. package/dist/ui/CollectionListMenu.svelte +0 -47
  401. package/dist/ui/CollectionListMenu.svelte.d.ts +0 -34
  402. package/dist/ui/CollectionReverseFks.svelte +0 -56
  403. package/dist/ui/CollectionReverseFks.svelte.d.ts +0 -18
  404. /package/dist/{fragments → data-ui/fragments}/Skeleton.svelte.d.ts +0 -0
  405. /package/dist/{db → main/api}/types.js +0 -0
@@ -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[];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Parse a URL containing one or more +targetId segments into LoadInSegment[].
3
+ *
4
+ * URL format: /+targetId/modulePath/collection[/collectionId][?vars]
5
+ * Multi-segment: /+t1/mod1/col1/42/+t2/mod2/col2?x=1
6
+ *
7
+ * Decision: URL without any + prefix returns [] (not an error).
8
+ * This allows the parser to be used safely on any URL.
9
+ */
10
+ export function parseLoadInUrl(url) {
11
+ if (!url.includes('+'))
12
+ return [];
13
+ const withoutQuery = url.split('?')[0];
14
+ const queryString = url.includes('?') ? url.split('?')[1] : '';
15
+ const segments = withoutQuery.split('/+').filter(Boolean);
16
+ const result = [];
17
+ for (let i = 0; i < segments.length; i++) {
18
+ const seg = segments[i];
19
+ const parts = seg.split('/');
20
+ const targetId = parts[0] ?? '';
21
+ const modulePath = parts[1] ?? '';
22
+ const collection = parts[2] ?? '';
23
+ const collectionId = parts[3] ?? undefined;
24
+ let vars;
25
+ if (i === segments.length - 1 && queryString) {
26
+ vars = parseQueryString(queryString);
27
+ }
28
+ result.push({ targetId, modulePath, collection, collectionId, vars });
29
+ }
30
+ return result;
31
+ }
32
+ function parseQueryString(query) {
33
+ const params = {};
34
+ for (const pair of query.split('&')) {
35
+ const [key, ...rest] = pair.split('=');
36
+ if (key) {
37
+ params[decodeURIComponent(key)] = rest.length > 0 ? decodeURIComponent(rest.join('=')) : '';
38
+ }
39
+ }
40
+ return params;
41
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Utilities for deriving warmup collection lists from the machine model
3
+ * Replaces hardcoded warmup arrays with model-driven collection selection
4
+ */
5
+ import type { MachineModel } from '../types/index.js';
6
+ /**
7
+ * Get collections that are critical for schema hydration (warmup candidates).
8
+ * These are collections with base='machine_app' that feed the shell UI.
9
+ * Delegates to the domain bridge if registered; falls back to inline implementation.
10
+ *
11
+ * @param model - The machine model to analyze
12
+ * @param bases - Array of bases to include (default: ['machine_app'])
13
+ * @returns Array of collection names that should be warmed up
14
+ */
15
+ export declare function getSchemaCriticalCollections(model: MachineModel, bases?: string[]): string[];
16
+ /**
17
+ * Get all collections that should be warmed up for optimal UI performance.
18
+ * Includes schema-critical collections plus other high-priority collections.
19
+ *
20
+ * @param model - The machine model to analyze
21
+ * @returns Array of collection names for comprehensive warmup
22
+ */
23
+ export declare function getComprehensiveWarmupCollections(model: MachineModel): string[];
24
+ /** Minimal interface — hydrateAll is a qoolie extension, not in the public type. */
25
+ type HydratableQoolie = {
26
+ hydrateAll?: (collections: string[]) => Promise<void>;
27
+ };
28
+ /**
29
+ * Pre-fetch collections into IDB. Derives the list from the model when not provided.
30
+ * Swallows errors so a warmup failure never blocks the app.
31
+ */
32
+ export declare function warmup(qoolie: HydratableQoolie, model: MachineModel, collections?: string[]): Promise<void>;
33
+ /**
34
+ * Get all base names used in the model
35
+ *
36
+ * @param model - The machine model to analyze
37
+ * @returns Array of unique base names
38
+ */
39
+ export declare function getModelBases(model: MachineModel): string[];
40
+ export {};
@@ -0,0 +1,73 @@
1
+ import { getMetaCollectionResolver } from './ext/hooks.js';
2
+ /**
3
+ * Get collections that are critical for schema hydration (warmup candidates).
4
+ * These are collections with base='machine_app' that feed the shell UI.
5
+ * Delegates to the domain bridge if registered; falls back to inline implementation.
6
+ *
7
+ * @param model - The machine model to analyze
8
+ * @param bases - Array of bases to include (default: ['machine_app'])
9
+ * @returns Array of collection names that should be warmed up
10
+ */
11
+ export function getSchemaCriticalCollections(model, bases = ['machine_app']) {
12
+ const resolver = getMetaCollectionResolver();
13
+ if (resolver)
14
+ return resolver.getSchemaCriticalCollections(bases);
15
+ const criticalCollections = [];
16
+ for (const [collectionName, collectionDef] of Object.entries(model)) {
17
+ if (collectionDef.base && bases.includes(collectionDef.base)) {
18
+ criticalCollections.push(collectionName);
19
+ }
20
+ }
21
+ return Array.from(new Set(criticalCollections)).sort();
22
+ }
23
+ /**
24
+ * Get all collections that should be warmed up for optimal UI performance.
25
+ * Includes schema-critical collections plus other high-priority collections.
26
+ *
27
+ * @param model - The machine model to analyze
28
+ * @returns Array of collection names for comprehensive warmup
29
+ */
30
+ export function getComprehensiveWarmupCollections(model) {
31
+ const collections = getSchemaCriticalCollections(model, ['machine_app', 'machine_user', 'machine_ai']);
32
+ const additionalCollections = [];
33
+ for (const collection of additionalCollections) {
34
+ if (model[collection] && !collections.includes(collection)) {
35
+ collections.push(collection);
36
+ }
37
+ }
38
+ return collections;
39
+ }
40
+ /**
41
+ * Pre-fetch collections into IDB. Derives the list from the model when not provided.
42
+ * Swallows errors so a warmup failure never blocks the app.
43
+ */
44
+ export async function warmup(qoolie, model, collections) {
45
+ const collectionsToWarm = (collections && collections.length > 0)
46
+ ? collections
47
+ : getSchemaCriticalCollections(model);
48
+ const hydratePromise = qoolie.hydrateAll?.(collectionsToWarm);
49
+ if (!hydratePromise)
50
+ return;
51
+ const timeout = new Promise((_, reject) => setTimeout(() => reject(new Error('[idae-machine] warmup timed out after 30s')), 30000));
52
+ try {
53
+ await Promise.race([hydratePromise, timeout]);
54
+ }
55
+ catch (err) {
56
+ console.warn('[idae-machine] warmup failed (non-blocking):', err);
57
+ }
58
+ }
59
+ /**
60
+ * Get all base names used in the model
61
+ *
62
+ * @param model - The machine model to analyze
63
+ * @returns Array of unique base names
64
+ */
65
+ export function getModelBases(model) {
66
+ const bases = new Set();
67
+ for (const collectionDef of Object.values(model)) {
68
+ if (collectionDef.base) {
69
+ bases.add(collectionDef.base);
70
+ }
71
+ }
72
+ return Array.from(bases).sort();
73
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * MachineMcpClient — browser-side WebMCP tool registration.
3
+ *
4
+ * Exposes machine state and actions to an in-browser AI agent via
5
+ * `navigator.modelContext` (WebMCP protocol). Call `registerMachineMcpTools(machine)`
6
+ * once, after `await machine.boot()`, in the app shell.
7
+ *
8
+ * Uses `machine.collection(name)` (imperative) — NOT machine.store() — because
9
+ * tools run outside a Svelte reactive frame and store() requires one.
10
+ *
11
+ * MCP.md phase 5 candidates:
12
+ * machine.collection → read/write IDB
13
+ * machine.framer → navigation
14
+ * machine.rights → user context
15
+ */
16
+ import type { Machine } from '../main/machine.js';
17
+ interface McpToolInput {
18
+ name: string;
19
+ description: string;
20
+ inputSchema: Record<string, unknown>;
21
+ handler(args: Record<string, unknown>): Promise<{
22
+ content: Array<{
23
+ type: 'text';
24
+ text: string;
25
+ }>;
26
+ isError?: boolean;
27
+ }>;
28
+ }
29
+ interface ModelContext {
30
+ addTool(tool: McpToolInput): void;
31
+ }
32
+ declare global {
33
+ interface Navigator {
34
+ modelContext?: ModelContext;
35
+ }
36
+ }
37
+ /**
38
+ * Register all machine WebMCP tools on `navigator.modelContext`.
39
+ * Call once, after `await machine.boot()`.
40
+ * No-op in non-browser environments or when modelContext is absent.
41
+ */
42
+ export declare function registerMachineMcpTools(machine: Machine): void;
43
+ export {};