@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,120 @@
1
+ import type { TplCollectionName, TplFields } from '../../types/index.js';
2
+ import { MachineDb } from '../machineDb.js';
3
+ /**
4
+ * @class MachineSchemeValues
5
+ * @role Provides utilities to display, format, and introspect field values for a given collection, using the schema and provided data.
6
+ *
7
+ * This class is typically used via IDbBase.getCollectionValues for shared instance management.
8
+ *
9
+ * @template T The type of the data object for the collection.
10
+ */
11
+ export declare class MachineSchemeValues<T extends Record<string, unknown>> {
12
+ #private;
13
+ /**
14
+ * The IDbBase instance used for schema introspection.
15
+ */
16
+ machine: MachineDb;
17
+ /**
18
+ * The collection name this instance operates on.
19
+ */
20
+ private collectionName;
21
+ /**
22
+ * Create a new IDbCollectionValues instance for a given collection.
23
+ * @role Constructor
24
+ * @param {TplCollectionName} collectionName The collection name.
25
+ * @param {MachineDb} machine The MachineDb instance.
26
+ */
27
+ constructor(collectionName: TplCollectionName, machine: MachineDb);
28
+ /**
29
+ * Get the presentation string for a data object, using the collection's presentation template.
30
+ * @role Presentation logic
31
+ * @param {Record<string, unknown>} data The data object.
32
+ * @return {string} The formatted presentation string.
33
+ */
34
+ presentation(data: Record<string, unknown>): string;
35
+ /**
36
+ * Get the value of the index field for a data object.
37
+ * @param data The data object.
38
+ * @returns The value of the index field, or null if not found.
39
+ */
40
+ /**
41
+ * Get the value of the index field for a data object.
42
+ * @role Index accessor
43
+ * @param {Record<string, unknown>} data The data object.
44
+ * @return {unknown | null} The value of the index field, or null if not found.
45
+ */
46
+ indexValue(data: Record<string, unknown>): unknown | null;
47
+ /**
48
+ * Format a field value for display, using the field type and schema.
49
+ * @param fieldName The field name.
50
+ * @param data The data object.
51
+ * @returns The formatted value as a string.
52
+ */
53
+ /**
54
+ * Format a field value for display, using the field type and schema.
55
+ * @role Field formatting
56
+ * @param {keyof T} fieldName The field name.
57
+ * @param {T} data The data object.
58
+ * @return {string} The formatted value as a string.
59
+ */
60
+ format(fieldName: keyof T, data: T): string;
61
+ /**
62
+ * Get a set of data-* attributes for a field, for use in form generation or UI.
63
+ * @param fieldName The field name.
64
+ * @param data The data object.
65
+ * @returns An object with data-* attributes for the field.
66
+ */
67
+ /**
68
+ * Get a set of data-* attributes for a field, for use in form generation or UI.
69
+ * @role Input attribute generation
70
+ * @param {string} fieldName The field name.
71
+ * @param {T} data The data object.
72
+ * @return {Record<`data-${'collection' | 'collectionId' | 'fieldName' | 'fieldType' | 'fieldArgs'}`, string>} The data-* attributes for the field.
73
+ */
74
+ getInputDataSet(fieldName: string, data: T): Record<`data-${'collection' | 'collection-id' | 'fieldName' | 'fieldType' | 'fieldArgs' | 'inputSize'}`, string>;
75
+ /**
76
+ * Iterate over an array field and return an array of IDbForge objects for each element.
77
+ * @param fieldName The field name.
78
+ * @param data The array data.
79
+ * @returns An array of IDbForge objects.
80
+ */
81
+ /**
82
+ * Iterate over an array field and return an array of IDbForge objects for each element.
83
+ * @role Array field iteration
84
+ * @param {keyof TplFields} fieldName The field name.
85
+ * @param {unknown[]} data The array data.
86
+ * @return {Array<Record<string, unknown>>} An array of IDbForge objects.
87
+ */
88
+ iterateArrayField(fieldName: keyof TplFields, data: unknown[]): Array<Record<string, unknown>>;
89
+ /**
90
+ * Iterate over an object field and return data rows keyed by property name.
91
+ * @param fieldName The field name.
92
+ * @param data The object data.
93
+ * @returns Data rows derived from the object's properties.
94
+ */
95
+ iterateObjectField(fieldName: keyof TplFields, data: Record<string, unknown>): Array<Record<string, unknown>>;
96
+ /**
97
+ * Resolved descriptor for a single field — the machine-native equivalent of the legacy
98
+ * `columnModel[]` entry. Scalar-vs-FK divergence is decided HERE, never in a component.
99
+ */
100
+ descriptor(fieldName: string): {
101
+ kind: 'scalar' | 'fk';
102
+ fieldName: string;
103
+ fieldType: string;
104
+ title: string;
105
+ fkCollection?: string;
106
+ fkIndexField?: string;
107
+ } | null;
108
+ /**
109
+ * Human-readable display value for a field.
110
+ * Scalar → MachineSchemeFieldType.format(). FK → presentation(targetRecord).
111
+ * `resolveTarget` is injected by the caller (keeps this class pure/testable).
112
+ */
113
+ displayValue(fieldName: keyof T, data: T, resolveTarget?: (fkCollection: string, fkIndexField: string, value: unknown) => Record<string, unknown> | undefined): string;
114
+ /**
115
+ * Get default values for the collection, using global and collection-specific factories.
116
+ * @role Default values
117
+ * @returns {Record<string, unknown>} An object with default values for each field in the collection.
118
+ */
119
+ getDefaults(): Record<string, unknown>;
120
+ }
@@ -0,0 +1,306 @@
1
+ import { MachineDb } from '../machineDb.js';
2
+ import { MachineError } from './MachineError.js';
3
+ import { SchemeFieldDefaultValues } from './SchemeFieldDefaultValues.js';
4
+ import { MachineSchemeFieldType } from './MachineFieldType.js';
5
+ import { getRelationResolver } from '../ext/hooks.js';
6
+ /** Walk a plain dot-path into an object (no FK awareness). */
7
+ function walkPath(root, segments) {
8
+ return segments.reduce((acc, key) => (acc != null && typeof acc === 'object') ? acc[key] : undefined, root);
9
+ }
10
+ /**
11
+ * Resolve a presentation token against a record.
12
+ * Delegates to the domain bridge first; falls back to built-in bag walk.
13
+ */
14
+ function resolvePresentationToken(data, token) {
15
+ const segments = token.split('.');
16
+ const resolver = getRelationResolver();
17
+ if (resolver?.resolvePresentationToken && segments.length >= 2) {
18
+ const resolved = resolver.resolvePresentationToken(data, segments);
19
+ if (resolved !== undefined)
20
+ return resolved;
21
+ }
22
+ // Fallback: plain path walk (also handles bare fks.<base>.<field> for tests without domain)
23
+ return walkPath(data, segments);
24
+ }
25
+ /**
26
+ * @class MachineSchemeValues
27
+ * @role Provides utilities to display, format, and introspect field values for a given collection, using the schema and provided data.
28
+ *
29
+ * This class is typically used via IDbBase.getCollectionValues for shared instance management.
30
+ *
31
+ * @template T The type of the data object for the collection.
32
+ */
33
+ export class MachineSchemeValues {
34
+ /**
35
+ * The IDbBase instance used for schema introspection.
36
+ */
37
+ machine;
38
+ /**
39
+ * The collection name this instance operates on.
40
+ */
41
+ collectionName;
42
+ /**
43
+ * Create a new IDbCollectionValues instance for a given collection.
44
+ * @role Constructor
45
+ * @param {TplCollectionName} collectionName The collection name.
46
+ * @param {MachineDb} machine The MachineDb instance.
47
+ */
48
+ constructor(collectionName, machine) {
49
+ this.collectionName = collectionName;
50
+ this.machine = machine;
51
+ }
52
+ /**
53
+ * Get the presentation string for a data object, using the collection's presentation template.
54
+ * @role Presentation logic
55
+ * @param {Record<string, unknown>} data The data object.
56
+ * @return {string} The formatted presentation string.
57
+ */
58
+ presentation(data) {
59
+ try {
60
+ const scheme = this.machine.collection(this.collectionName);
61
+ const presentation = scheme.template?.presentation;
62
+ this.#checkError(!presentation, 'Presentation template not found', 'TEMPLATE_NOT_FOUND');
63
+ const tokens = presentation.split(' ').filter(Boolean);
64
+ return tokens
65
+ .map((token) => {
66
+ // Dot notation: 'fks.firm.name', 'address.city', etc.
67
+ const value = resolvePresentationToken(data, token);
68
+ if (value === null || value === undefined)
69
+ return '';
70
+ // For dot-notation tokens, skip type-aware formatting (no field metadata at depth).
71
+ if (token.includes('.'))
72
+ return String(value);
73
+ const fieldInfo = scheme.field(token).parse();
74
+ return fieldInfo?.fieldType
75
+ ? MachineSchemeFieldType.format(value, fieldInfo.fieldType)
76
+ : String(value);
77
+ })
78
+ .filter(Boolean)
79
+ .join(' ');
80
+ }
81
+ catch (error) {
82
+ MachineError.handleError(error);
83
+ return '';
84
+ }
85
+ }
86
+ /**
87
+ * Get the value of the index field for a data object.
88
+ * @param data The data object.
89
+ * @returns The value of the index field, or null if not found.
90
+ */
91
+ /**
92
+ * Get the value of the index field for a data object.
93
+ * @role Index accessor
94
+ * @param {Record<string, unknown>} data The data object.
95
+ * @return {unknown | null} The value of the index field, or null if not found.
96
+ */
97
+ indexValue(data) {
98
+ try {
99
+ const indexName = this.machine.collection(this.collectionName).index;
100
+ this.#checkError(!indexName, 'Index not found for collection', 'INDEX_NOT_FOUND');
101
+ this.#checkError(!(indexName in data), `Index field ${indexName} not found in data`, 'FIELD_NOT_FOUND');
102
+ return data[indexName];
103
+ }
104
+ catch (error) {
105
+ MachineError.handleError(error);
106
+ return null;
107
+ }
108
+ }
109
+ /**
110
+ * Format a field value for display, using the field type and schema.
111
+ * @param fieldName The field name.
112
+ * @param data The data object.
113
+ * @returns The formatted value as a string.
114
+ */
115
+ /**
116
+ * Format a field value for display, using the field type and schema.
117
+ * @role Field formatting
118
+ * @param {keyof T} fieldName The field name.
119
+ * @param {T} data The data object.
120
+ * @return {string} The formatted value as a string.
121
+ */
122
+ format(fieldName, data) {
123
+ try {
124
+ this.#checkError(!(fieldName in data), `Field ${String(fieldName)} not found in data`, 'FIELD_NOT_FOUND');
125
+ const fieldInfo = this.machine
126
+ .collection(this.collectionName)
127
+ .field(String(fieldName))
128
+ .parse();
129
+ this.#checkError(!fieldInfo, `Field ${String(fieldName)} not found in collection`, 'FIELD_NOT_FOUND');
130
+ if (!fieldInfo) {
131
+ return String(data[fieldName]);
132
+ }
133
+ return MachineSchemeFieldType.format(data[fieldName], fieldInfo.fieldType);
134
+ }
135
+ catch (error) {
136
+ MachineError.handleError(error);
137
+ return '';
138
+ }
139
+ }
140
+ /**
141
+ * Get a set of data-* attributes for a field, for use in form generation or UI.
142
+ * @param fieldName The field name.
143
+ * @param data The data object.
144
+ * @returns An object with data-* attributes for the field.
145
+ */
146
+ /**
147
+ * Get a set of data-* attributes for a field, for use in form generation or UI.
148
+ * @role Input attribute generation
149
+ * @param {string} fieldName The field name.
150
+ * @param {T} data The data object.
151
+ * @return {Record<`data-${'collection' | 'collectionId' | 'fieldName' | 'fieldType' | 'fieldArgs'}`, string>} The data-* attributes for the field.
152
+ */
153
+ getInputDataSet(fieldName, data) {
154
+ const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
155
+ const fieldType = fieldInfo?.fieldType ?? '';
156
+ const fieldArgs = fieldInfo?.fieldArgs?.join(' ') ?? '';
157
+ const inputSize = fieldInfo?.inputSize ?? '';
158
+ const indexName = this.machine.collection(this.collectionName).index;
159
+ return {
160
+ 'data-collection': this.collectionName,
161
+ 'data-collection-id': indexName && data?.[indexName] !== undefined
162
+ ? String(data?.[indexName])
163
+ : '',
164
+ 'data-fieldName': String(fieldName),
165
+ 'data-fieldType': fieldType,
166
+ 'data-fieldArgs': fieldArgs,
167
+ 'data-inputSize': inputSize
168
+ };
169
+ }
170
+ /**
171
+ * Iterate over an array field and return an array of IDbForge objects for each element.
172
+ * @param fieldName The field name.
173
+ * @param data The array data.
174
+ * @returns An array of IDbForge objects.
175
+ */
176
+ /**
177
+ * Iterate over an array field and return an array of IDbForge objects for each element.
178
+ * @role Array field iteration
179
+ * @param {keyof TplFields} fieldName The field name.
180
+ * @param {unknown[]} data The array data.
181
+ * @return {Array<Record<string, unknown>>} An array of IDbForge objects.
182
+ */
183
+ // NOTE: Return type is Array<Record<string, unknown>> to match actual runtime type from parser
184
+ iterateArrayField(fieldName, data) {
185
+ const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
186
+ if (fieldInfo?.is !== 'array' || !Array.isArray(data)) {
187
+ return [];
188
+ }
189
+ return data
190
+ .map((_, idx) => fieldInfo && fieldInfo.fieldType
191
+ ? {
192
+ ...fieldInfo,
193
+ fieldName: `${String(fieldName)}[${idx}]`,
194
+ collection: this.collectionName
195
+ }
196
+ : undefined)
197
+ .filter((x) => x !== undefined);
198
+ }
199
+ /**
200
+ * Iterate over an object field and return data rows keyed by property name.
201
+ * @param fieldName The field name.
202
+ * @param data The object data.
203
+ * @returns Data rows derived from the object's properties.
204
+ */
205
+ iterateObjectField(fieldName, data) {
206
+ const fieldInfo = this.machine.collection(this.collectionName).field(fieldName).parse();
207
+ if (fieldInfo?.is !== 'object' || typeof data !== 'object' || data === null) {
208
+ return [];
209
+ }
210
+ return Object.keys(data)
211
+ .map((key) => fieldInfo && fieldInfo.fieldType
212
+ ? {
213
+ ...fieldInfo,
214
+ fieldName: `${String(fieldName)}.${key}`,
215
+ collection: this.collectionName
216
+ }
217
+ : undefined)
218
+ .filter((x) => x !== undefined);
219
+ }
220
+ /**
221
+ * Internal: Throw an error if a condition is met.
222
+ * @param condition The condition to check.
223
+ * @param message The error message.
224
+ * @param code The error code.
225
+ */
226
+ /**
227
+ * Internal: Throw an error if a condition is met.
228
+ * @role Error handling
229
+ * @param {boolean} condition The condition to check.
230
+ * @param {string} message The error message.
231
+ * @param {string} code The error code.
232
+ */
233
+ #checkError(condition, message, code) {
234
+ if (condition) {
235
+ MachineError.throwError(message, code);
236
+ }
237
+ }
238
+ /**
239
+ * Resolved descriptor for a single field — the machine-native equivalent of the legacy
240
+ * `columnModel[]` entry. Scalar-vs-FK divergence is decided HERE, never in a component.
241
+ */
242
+ descriptor(fieldName) {
243
+ try {
244
+ const scheme = this.machine.collection(this.collectionName);
245
+ // FK detection from the structured `fks` block (canonical). The relation key
246
+ // is the field name; the join index is the semantic `code`. No magic-string
247
+ // fieldType parsing — the synthesized `fk-X.code` field is deprecated.
248
+ const fkDef = scheme.fks?.[fieldName];
249
+ if (fkDef?.code) {
250
+ return {
251
+ kind: 'fk',
252
+ fieldName,
253
+ fieldType: `fk-${fkDef.code}.code`,
254
+ title: fieldName,
255
+ fkCollection: fkDef.code,
256
+ fkIndexField: 'code'
257
+ };
258
+ }
259
+ const info = scheme.field(fieldName).parse();
260
+ if (!info)
261
+ return null;
262
+ const type = (info.fieldType ?? '');
263
+ const title = info.title ?? fieldName;
264
+ return { kind: 'scalar', fieldName, fieldType: type, title };
265
+ }
266
+ catch {
267
+ return null;
268
+ }
269
+ }
270
+ /**
271
+ * Human-readable display value for a field.
272
+ * Scalar → MachineSchemeFieldType.format(). FK → presentation(targetRecord).
273
+ * `resolveTarget` is injected by the caller (keeps this class pure/testable).
274
+ */
275
+ displayValue(fieldName, data, resolveTarget) {
276
+ const d = this.descriptor(String(fieldName));
277
+ if (!d)
278
+ return String(data[fieldName] ?? '');
279
+ if (d.kind === 'scalar') {
280
+ return MachineSchemeFieldType.format(data[fieldName], d.fieldType);
281
+ }
282
+ // FK path — resolve target record, then use its presentation template
283
+ const raw = data[fieldName];
284
+ if (raw == null)
285
+ return '—';
286
+ const target = resolveTarget?.(d.fkCollection, d.fkIndexField, raw);
287
+ if (!target)
288
+ return String(raw);
289
+ try {
290
+ const fkValues = new MachineSchemeValues(d.fkCollection, this.machine);
291
+ return fkValues.presentation(target) || String(raw);
292
+ }
293
+ catch {
294
+ return String(raw);
295
+ }
296
+ }
297
+ /**
298
+ * Get default values for the collection, using global and collection-specific factories.
299
+ * @role Default values
300
+ * @returns {Record<string, unknown>} An object with default values for each field in the collection.
301
+ */
302
+ getDefaults() {
303
+ const fields = Object.keys(this.machine.collection(this.collectionName).fields || {});
304
+ return SchemeFieldDefaultValues.getDefaults(fields, this.collectionName);
305
+ }
306
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Example: Using SchemeFieldDefaultValues to get default values for a collection
3
+ *
4
+ * import { SchemeFieldDefaultValues } from './SchemeFieldDefaultValues';
5
+ *
6
+ * // For a collection 'agents' with fields ['name', 'role', 'createdAt']
7
+ * const defaults = SchemeFieldDefaultValues.getDefaults(['name', 'role', 'createdAt'], 'agents');
8
+ * // defaults = { name: ..., role: ..., createdAt: ... }
9
+ *
10
+ * // In a Svelte form (pseudo-code):
11
+ * let formData = { ...SchemeFieldDefaultValues.getDefaults(Object.keys(formFields), collection) };
12
+ *
13
+ * // When rendering the form, fields with no user value will use the default
14
+ * <input name="name" bind:value={formData.name} />
15
+ * <input name="role" bind:value={formData.role} />
16
+ * <input name="createdAt" bind:value={formData.createdAt} />
17
+ *
18
+ * // To set or override a default globally:
19
+ * SchemeFieldDefaultValues.setDefault('role', () => 'admin');
20
+ *
21
+ * // To set a default for a specific collection:
22
+ * SchemeFieldDefaultValues.setDefault('role', () => 'user', 'agents');
23
+ *
24
+ * // To set multiple defaults at once:
25
+ * SchemeFieldDefaultValues.setDefaults({ status: () => 'active', country: () => 'FR' });
26
+ *
27
+ * // To set multiple defaults for a collection:
28
+ * SchemeFieldDefaultValues.setDefaults({ status: () => 'pending' }, 'orders');
29
+ */
30
+ import type { TplCollectionName } from '../../types/index.js';
31
+ export declare class SchemeFieldDefaultValues {
32
+ /**
33
+ * Default value factories for all collections (global fields).
34
+ * Each key is a field name, value is a function returning the default value.
35
+ * Using `any` return type is intentional: factories must work with all field types.
36
+ * @type {Record<string, () => any>}
37
+ */
38
+ static defaultFieldFactories: Record<string, () => any>;
39
+ /**
40
+ * Default value factories per collection.
41
+ * Each key is a collection name, value is an object of field factories.
42
+ * Using `any` return type is intentional: factories must work with all field types.
43
+ * @type {Record<string, Record<string, () => any>>}
44
+ */
45
+ static defaultCollectionFactories: Record<string, Record<string, () => any>>;
46
+ /**
47
+ * Add or update a default value factory for a single field (global or collection-specific).
48
+ * @param {string} field - The field name.
49
+ * @param {() => any} factory - The factory function.
50
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific default.
51
+ */
52
+ static setDefault(field: string, factory: () => any, collectionName?: TplCollectionName): void;
53
+ /**
54
+ * Add or update multiple default value factories at once (global or collection-specific).
55
+ * @param {Record<string, () => any>} factories - Object of field:factory pairs.
56
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific defaults.
57
+ */
58
+ static setDefaults(factories: Record<string, () => any>, collectionName?: TplCollectionName): void;
59
+ /**
60
+ * Get default values for a set of fields, using global and optionally collection-specific factories.
61
+ * If collectionName is provided, collection-specific factories take priority over global ones.
62
+ * If not, only global defaults are used.
63
+ *
64
+ * @param {string[]} fields - The list of field names.
65
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific defaults.
66
+ * @returns {Record<string, any>} An object with default values for each field.
67
+ */
68
+ static getDefaults(fields: string[], collectionName?: TplCollectionName): Record<string, any>;
69
+ /**
70
+ * Get the default value for a single field, using collection-specific or global factory.
71
+ * @param {string} field - The field name.
72
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific default.
73
+ * @returns {any} The default value for the field, or undefined if none.
74
+ */
75
+ static getDefault(field: string, collectionName?: TplCollectionName): unknown;
76
+ }
@@ -0,0 +1,104 @@
1
+ // Example: How to use SchemeFieldDefaultValues in a Svelte form
2
+ // (for documentation/demo, not for direct import)
3
+ // Single class declaration with all static methods and properties
4
+ export class SchemeFieldDefaultValues {
5
+ /**
6
+ * Default value factories for all collections (global fields).
7
+ * Each key is a field name, value is a function returning the default value.
8
+ * Using `any` return type is intentional: factories must work with all field types.
9
+ * @type {Record<string, () => any>}
10
+ */
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ static defaultFieldFactories = {
13
+ createdAt: () => new Date(),
14
+ updatedAt: () => new Date(),
15
+ status: () => 'draft'
16
+ // Add more global defaults here
17
+ };
18
+ /**
19
+ * Default value factories per collection.
20
+ * Each key is a collection name, value is an object of field factories.
21
+ * Using `any` return type is intentional: factories must work with all field types.
22
+ * @type {Record<string, Record<string, () => any>>}
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ static defaultCollectionFactories = {
26
+ // Example:
27
+ // agents: {
28
+ // role: () => "user",
29
+ // },
30
+ };
31
+ /**
32
+ * Add or update a default value factory for a single field (global or collection-specific).
33
+ * @param {string} field - The field name.
34
+ * @param {() => any} factory - The factory function.
35
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific default.
36
+ */
37
+ static setDefault(field, factory, collectionName) {
38
+ if (collectionName) {
39
+ if (!this.defaultCollectionFactories[collectionName]) {
40
+ this.defaultCollectionFactories[collectionName] = {};
41
+ }
42
+ this.defaultCollectionFactories[collectionName][field] = factory;
43
+ }
44
+ else {
45
+ this.defaultFieldFactories[field] = factory;
46
+ }
47
+ }
48
+ /**
49
+ * Add or update multiple default value factories at once (global or collection-specific).
50
+ * @param {Record<string, () => any>} factories - Object of field:factory pairs.
51
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific defaults.
52
+ */
53
+ static setDefaults(factories, collectionName) {
54
+ if (collectionName) {
55
+ if (!this.defaultCollectionFactories[collectionName]) {
56
+ this.defaultCollectionFactories[collectionName] = {};
57
+ }
58
+ Object.assign(this.defaultCollectionFactories[collectionName], factories);
59
+ }
60
+ else {
61
+ Object.assign(this.defaultFieldFactories, factories);
62
+ }
63
+ }
64
+ /**
65
+ * Get default values for a set of fields, using global and optionally collection-specific factories.
66
+ * If collectionName is provided, collection-specific factories take priority over global ones.
67
+ * If not, only global defaults are used.
68
+ *
69
+ * @param {string[]} fields - The list of field names.
70
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific defaults.
71
+ * @returns {Record<string, any>} An object with default values for each field.
72
+ */
73
+ static getDefaults(fields, collectionName) {
74
+ const result = {};
75
+ const collectionDefaults = collectionName
76
+ ? this.defaultCollectionFactories[collectionName] || {}
77
+ : {};
78
+ for (const field of fields) {
79
+ if (collectionDefaults[field]) {
80
+ result[field] = collectionDefaults[field]();
81
+ }
82
+ else if (this.defaultFieldFactories[field]) {
83
+ result[field] = this.defaultFieldFactories[field]();
84
+ }
85
+ // else: no default
86
+ }
87
+ return result;
88
+ }
89
+ /**
90
+ * Get the default value for a single field, using collection-specific or global factory.
91
+ * @param {string} field - The field name.
92
+ * @param {TplCollectionName} [collectionName] - Optional collection name for specific default.
93
+ * @returns {any} The default value for the field, or undefined if none.
94
+ */
95
+ static getDefault(field, collectionName) {
96
+ if (collectionName && this.defaultCollectionFactories[collectionName]?.[field]) {
97
+ return this.defaultCollectionFactories[collectionName][field]();
98
+ }
99
+ if (this.defaultFieldFactories[field]) {
100
+ return this.defaultFieldFactories[field]();
101
+ }
102
+ return undefined;
103
+ }
104
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * authState — reactive client auth gate.
3
+ *
4
+ * A tiny `$state`-backed signal so the boot layout can react to login success.
5
+ * Props/callbacks can't cross the framer mount boundary (the login dialog is
6
+ * mounted dynamically, not as a child of `+layout`), so this module is the
7
+ * shared channel between `Login.svelte` and the gate in `+layout.svelte`.
8
+ */
9
+ export declare const authState: {
10
+ authed: boolean;
11
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * authState — reactive client auth gate.
3
+ *
4
+ * A tiny `$state`-backed signal so the boot layout can react to login success.
5
+ * Props/callbacks can't cross the framer mount boundary (the login dialog is
6
+ * mounted dynamically, not as a child of `+layout`), so this module is the
7
+ * shared channel between `Login.svelte` and the gate in `+layout.svelte`.
8
+ */
9
+ let _authed = $state(false);
10
+ export const authState = {
11
+ get authed() {
12
+ return _authed;
13
+ },
14
+ set authed(v) {
15
+ _authed = v;
16
+ }
17
+ };
@@ -0,0 +1,23 @@
1
+ import type { MachineFieldDef, ImageFieldDef, InputSize } from '../../types/index.js';
2
+ type BaseFieldOptions = {
3
+ required?: boolean;
4
+ readonly?: boolean;
5
+ private?: boolean;
6
+ inputSize?: InputSize;
7
+ };
8
+ type ImageFieldOptions = Omit<ImageFieldDef, 'type'>;
9
+ /**
10
+ * Builder helper for machine field declarations.
11
+ *
12
+ * @example
13
+ * fields: {
14
+ * id: field('id', { readonly: true }),
15
+ * name: field('text', { required: true }),
16
+ * catId: field('fk-category.id'),
17
+ * photo: field('image', { presets: ['thumb', 'banner'] }),
18
+ * }
19
+ */
20
+ export declare function field(type: 'image', opts?: ImageFieldOptions): ImageFieldDef;
21
+ export declare function field(type: string, opts?: BaseFieldOptions): MachineFieldDef;
22
+ export {};
23
+ //# sourceMappingURL=fieldBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldBuilder.d.ts","sourceRoot":"","sources":["fieldBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErF,KAAK,gBAAgB,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAC7G,KAAK,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;AAC9E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAG,IAAI,CAAC,EAAE,gBAAgB,GAAI,eAAe,CAAC"}
@@ -0,0 +1,10 @@
1
+ export function field(type, opts) {
2
+ if (type === 'image') {
3
+ const o = opts;
4
+ if (o?.preset && o?.presets)
5
+ throw new Error('Use preset OR presets, not both');
6
+ const hasPresets = !!(o?.presets ?? o?.preset);
7
+ return { type: 'image', ...o, free: o?.free ?? (hasPresets ? false : true) };
8
+ }
9
+ return { type, ...opts };
10
+ }