@nocobase/flow-engine 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (597) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +30 -0
  3. package/lib/ContextPathProxy.d.ts +17 -0
  4. package/lib/ContextPathProxy.js +65 -0
  5. package/lib/ElementProxy.d.ts +17 -0
  6. package/lib/ElementProxy.js +93 -0
  7. package/lib/FlowContextProvider.d.ts +24 -0
  8. package/lib/FlowContextProvider.js +82 -0
  9. package/lib/FlowDefinition.d.ts +423 -0
  10. package/lib/FlowDefinition.js +257 -0
  11. package/lib/JSRunner.d.ts +32 -0
  12. package/lib/JSRunner.js +95 -0
  13. package/lib/ReactView.d.ts +20 -0
  14. package/lib/ReactView.js +120 -0
  15. package/lib/ViewScopedFlowEngine.d.ts +23 -0
  16. package/lib/ViewScopedFlowEngine.js +81 -0
  17. package/lib/acl/Acl.d.ts +31 -0
  18. package/lib/acl/Acl.js +115 -0
  19. package/lib/action-registry/BaseActionRegistry.d.ts +23 -0
  20. package/lib/action-registry/BaseActionRegistry.js +57 -0
  21. package/lib/action-registry/EngineActionRegistry.d.ts +20 -0
  22. package/lib/action-registry/EngineActionRegistry.js +47 -0
  23. package/lib/action-registry/ModelActionRegistry.d.ts +34 -0
  24. package/lib/action-registry/ModelActionRegistry.js +79 -0
  25. package/lib/components/DynamicFlowsEditor.d.ts +17 -0
  26. package/lib/components/DynamicFlowsEditor.js +49 -0
  27. package/lib/components/FieldModelRenderer.d.ts +10 -0
  28. package/lib/components/FieldModelRenderer.js +94 -0
  29. package/lib/components/FlowContextSelector.d.ts +11 -0
  30. package/lib/components/FlowContextSelector.js +221 -0
  31. package/lib/components/FlowErrorFallback.d.ts +25 -0
  32. package/lib/components/FlowErrorFallback.js +264 -0
  33. package/lib/components/FlowModelRenderer.d.ts +64 -0
  34. package/lib/components/FlowModelRenderer.js +254 -0
  35. package/lib/components/FormItem.d.ts +18 -0
  36. package/lib/components/FormItem.js +147 -0
  37. package/lib/components/common/FlowSettingsButton.d.ts +11 -0
  38. package/lib/components/common/FlowSettingsButton.js +66 -0
  39. package/lib/components/common/index.d.ts +9 -0
  40. package/lib/components/common/index.js +30 -0
  41. package/lib/components/common/withFlowDesignMode.d.ts +26 -0
  42. package/lib/components/common/withFlowDesignMode.js +61 -0
  43. package/lib/components/dnd/getMousePositionOnElement.d.ts +50 -0
  44. package/lib/components/dnd/getMousePositionOnElement.js +95 -0
  45. package/lib/components/dnd/index.d.ts +24 -0
  46. package/lib/components/dnd/index.js +164 -0
  47. package/lib/components/dnd/moveBlock.d.ts +33 -0
  48. package/lib/components/dnd/moveBlock.js +302 -0
  49. package/lib/components/index.d.ts +18 -0
  50. package/lib/components/index.js +48 -0
  51. package/lib/components/settings/independents/dropdown/FlowsDropdownButton.d.ts +46 -0
  52. package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +225 -0
  53. package/lib/components/settings/independents/dropdown/index.d.ts +9 -0
  54. package/lib/components/settings/independents/dropdown/index.js +30 -0
  55. package/lib/components/settings/independents/index.d.ts +1 -0
  56. package/lib/components/settings/independents/index.js +30 -0
  57. package/lib/components/settings/index.d.ts +10 -0
  58. package/lib/components/settings/index.js +32 -0
  59. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +24 -0
  60. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +501 -0
  61. package/lib/components/settings/wrappers/contextual/FlowsContextMenu.d.ts +45 -0
  62. package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +231 -0
  63. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +111 -0
  64. package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +484 -0
  65. package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.d.ts +26 -0
  66. package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.js +342 -0
  67. package/lib/components/settings/wrappers/contextual/StepSettings.d.ts +23 -0
  68. package/lib/components/settings/wrappers/contextual/StepSettings.js +110 -0
  69. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.d.ts +20 -0
  70. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +206 -0
  71. package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.d.ts +20 -0
  72. package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.js +47 -0
  73. package/lib/components/settings/wrappers/contextual/index.d.ts +14 -0
  74. package/lib/components/settings/wrappers/contextual/index.js +40 -0
  75. package/lib/components/settings/wrappers/embedded/FlowSettings.d.ts +33 -0
  76. package/lib/components/settings/wrappers/embedded/FlowSettings.js +207 -0
  77. package/lib/components/settings/wrappers/embedded/FlowsSettings.d.ts +41 -0
  78. package/lib/components/settings/wrappers/embedded/FlowsSettings.js +84 -0
  79. package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.d.ts +16 -0
  80. package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +88 -0
  81. package/lib/components/settings/wrappers/embedded/index.d.ts +10 -0
  82. package/lib/components/settings/wrappers/embedded/index.js +32 -0
  83. package/lib/components/settings/wrappers/index.d.ts +2 -0
  84. package/lib/components/settings/wrappers/index.js +32 -0
  85. package/lib/components/subModel/AddSubModelButton.d.ts +62 -0
  86. package/lib/components/subModel/AddSubModelButton.js +415 -0
  87. package/lib/components/subModel/LazyDropdown.d.ts +55 -0
  88. package/lib/components/subModel/LazyDropdown.js +524 -0
  89. package/lib/components/subModel/index.d.ts +10 -0
  90. package/lib/components/subModel/index.js +32 -0
  91. package/lib/components/subModel/utils.d.ts +34 -0
  92. package/lib/components/subModel/utils.js +287 -0
  93. package/lib/components/variables/InlineVariableTag.d.ts +21 -0
  94. package/lib/components/variables/InlineVariableTag.js +123 -0
  95. package/lib/components/variables/SlateVariableEditor.d.ts +46 -0
  96. package/lib/components/variables/SlateVariableEditor.js +302 -0
  97. package/lib/components/variables/VariableInput.d.ts +11 -0
  98. package/lib/components/variables/VariableInput.js +322 -0
  99. package/lib/components/variables/VariableTag.d.ts +11 -0
  100. package/lib/components/variables/VariableTag.js +148 -0
  101. package/lib/components/variables/VariableTrigger.d.ts +20 -0
  102. package/lib/components/variables/VariableTrigger.js +136 -0
  103. package/lib/components/variables/index.d.ts +15 -0
  104. package/lib/components/variables/index.js +53 -0
  105. package/lib/components/variables/types.d.ts +93 -0
  106. package/lib/components/variables/types.js +24 -0
  107. package/lib/components/variables/useResolvedMetaTree.d.ts +19 -0
  108. package/lib/components/variables/useResolvedMetaTree.js +91 -0
  109. package/lib/components/variables/utils.d.ts +22 -0
  110. package/lib/components/variables/utils.js +177 -0
  111. package/lib/data-source/index.d.ts +180 -0
  112. package/lib/data-source/index.js +733 -0
  113. package/lib/data-source/jioToJoiSchema.d.ts +19 -0
  114. package/lib/data-source/jioToJoiSchema.js +114 -0
  115. package/lib/decorators/index.d.ts +9 -0
  116. package/lib/decorators/index.js +36 -0
  117. package/lib/decorators/largeField.d.ts +9 -0
  118. package/lib/decorators/largeField.js +42 -0
  119. package/lib/emitter.d.ts +16 -0
  120. package/lib/emitter.js +58 -0
  121. package/lib/event-registry/BaseEventRegistry.d.ts +22 -0
  122. package/lib/event-registry/BaseEventRegistry.js +57 -0
  123. package/lib/event-registry/EngineEventRegistry.d.ts +19 -0
  124. package/lib/event-registry/EngineEventRegistry.js +47 -0
  125. package/lib/event-registry/ModelEventRegistry.d.ts +33 -0
  126. package/lib/event-registry/ModelEventRegistry.js +79 -0
  127. package/lib/executor/FlowExecutor.d.ts +26 -0
  128. package/lib/executor/FlowExecutor.js +262 -0
  129. package/lib/flow-registry/BaseFlowRegistry.d.ts +46 -0
  130. package/lib/flow-registry/BaseFlowRegistry.js +86 -0
  131. package/lib/flow-registry/GlobalFlowRegistry.d.ts +22 -0
  132. package/lib/flow-registry/GlobalFlowRegistry.js +95 -0
  133. package/lib/flow-registry/InstanceFlowRegistry.d.ts +21 -0
  134. package/lib/flow-registry/InstanceFlowRegistry.js +59 -0
  135. package/lib/flow-registry/index.d.ts +11 -0
  136. package/lib/flow-registry/index.js +34 -0
  137. package/lib/flowContext.d.ts +215 -0
  138. package/lib/flowContext.js +1266 -0
  139. package/lib/flowEngine.d.ts +340 -0
  140. package/lib/flowEngine.js +781 -0
  141. package/lib/flowI18n.d.ts +46 -0
  142. package/lib/flowI18n.js +117 -0
  143. package/lib/flowSettings.d.ts +266 -0
  144. package/lib/flowSettings.js +850 -0
  145. package/lib/hooks/index.d.ts +14 -0
  146. package/lib/hooks/index.js +40 -0
  147. package/lib/hooks/useApplyAutoFlows.d.ts +21 -0
  148. package/lib/hooks/useApplyAutoFlows.js +62 -0
  149. package/lib/hooks/useFlowModel.d.ts +29 -0
  150. package/lib/hooks/useFlowModel.js +72 -0
  151. package/lib/hooks/useFlowModelById.d.ts +11 -0
  152. package/lib/hooks/useFlowModelById.js +61 -0
  153. package/lib/hooks/useFlowSettingsContext.d.ts +20 -0
  154. package/lib/hooks/useFlowSettingsContext.js +61 -0
  155. package/lib/hooks/useFlowStep.d.ts +17 -0
  156. package/lib/hooks/useFlowStep.js +56 -0
  157. package/lib/hooks/useNiceDropdownMaxHeight.d.ts +13 -0
  158. package/lib/hooks/useNiceDropdownMaxHeight.js +52 -0
  159. package/lib/index.d.ts +27 -0
  160. package/lib/index.js +73 -0
  161. package/lib/locale/en-US.json +61 -0
  162. package/lib/locale/index.d.ts +141 -0
  163. package/lib/locale/index.js +70 -0
  164. package/lib/locale/zh-CN.json +61 -0
  165. package/lib/models/CollectionFieldModel.d.ts +50 -0
  166. package/lib/models/CollectionFieldModel.js +242 -0
  167. package/lib/models/DisplayItemModel.d.ts +12 -0
  168. package/lib/models/DisplayItemModel.js +41 -0
  169. package/lib/models/EditableItemModel.d.ts +12 -0
  170. package/lib/models/EditableItemModel.js +41 -0
  171. package/lib/models/FilterableItemModel.d.ts +12 -0
  172. package/lib/models/FilterableItemModel.js +41 -0
  173. package/lib/models/flowModel.d.ts +344 -0
  174. package/lib/models/flowModel.js +1133 -0
  175. package/lib/models/forkFlowModel.d.ts +83 -0
  176. package/lib/models/forkFlowModel.js +257 -0
  177. package/lib/models/index.d.ts +14 -0
  178. package/lib/models/index.js +40 -0
  179. package/lib/provider.d.ts +22 -0
  180. package/lib/provider.js +114 -0
  181. package/lib/resources/apiResource.d.ts +34 -0
  182. package/lib/resources/apiResource.js +153 -0
  183. package/lib/resources/baseRecordResource.d.ts +61 -0
  184. package/lib/resources/baseRecordResource.js +264 -0
  185. package/lib/resources/filterItem.d.ts +33 -0
  186. package/lib/resources/filterItem.js +93 -0
  187. package/lib/resources/flowResource.d.ts +45 -0
  188. package/lib/resources/flowResource.js +146 -0
  189. package/lib/resources/index.d.ts +15 -0
  190. package/lib/resources/index.js +42 -0
  191. package/lib/resources/multiRecordResource.d.ts +53 -0
  192. package/lib/resources/multiRecordResource.js +230 -0
  193. package/lib/resources/singleRecordResource.d.ts +23 -0
  194. package/lib/resources/singleRecordResource.js +111 -0
  195. package/lib/resources/sqlResource.d.ts +73 -0
  196. package/lib/resources/sqlResource.js +294 -0
  197. package/lib/runjs-context/contexts/FlowRunJSContext.d.ts +38 -0
  198. package/lib/runjs-context/contexts/FlowRunJSContext.js +217 -0
  199. package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +16 -0
  200. package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +66 -0
  201. package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +16 -0
  202. package/lib/runjs-context/contexts/JSBlockRunJSContext.js +78 -0
  203. package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +12 -0
  204. package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +59 -0
  205. package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +16 -0
  206. package/lib/runjs-context/contexts/JSFieldRunJSContext.js +70 -0
  207. package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +16 -0
  208. package/lib/runjs-context/contexts/JSItemRunJSContext.js +66 -0
  209. package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +12 -0
  210. package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +61 -0
  211. package/lib/runjs-context/contexts/LinkageRunJSContext.d.ts +12 -0
  212. package/lib/runjs-context/contexts/LinkageRunJSContext.js +62 -0
  213. package/lib/runjs-context/helpers.d.ts +17 -0
  214. package/lib/runjs-context/helpers.js +79 -0
  215. package/lib/runjs-context/index.d.ts +19 -0
  216. package/lib/runjs-context/index.js +57 -0
  217. package/lib/runjs-context/registry.d.ts +17 -0
  218. package/lib/runjs-context/registry.js +93 -0
  219. package/lib/runjs-context/snippets/global/api-request-get.snippet.d.ts +16 -0
  220. package/lib/runjs-context/snippets/global/api-request-get.snippet.js +42 -0
  221. package/lib/runjs-context/snippets/global/api-request-post.snippet.d.ts +16 -0
  222. package/lib/runjs-context/snippets/global/api-request-post.snippet.js +42 -0
  223. package/lib/runjs-context/snippets/global/console-log-ctx.snippet.d.ts +16 -0
  224. package/lib/runjs-context/snippets/global/console-log-ctx.snippet.js +41 -0
  225. package/lib/runjs-context/snippets/global/copy-record-json.snippet.d.ts +11 -0
  226. package/lib/runjs-context/snippets/global/copy-record-json.snippet.js +42 -0
  227. package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.d.ts +11 -0
  228. package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.js +42 -0
  229. package/lib/runjs-context/snippets/global/log-json-record.snippet.d.ts +11 -0
  230. package/lib/runjs-context/snippets/global/log-json-record.snippet.js +42 -0
  231. package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
  232. package/lib/runjs-context/snippets/global/message-error.snippet.js +41 -0
  233. package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
  234. package/lib/runjs-context/snippets/global/message-success.snippet.js +41 -0
  235. package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +16 -0
  236. package/lib/runjs-context/snippets/global/notification-open.snippet.js +43 -0
  237. package/lib/runjs-context/snippets/global/open-view-dialog.snippet.d.ts +11 -0
  238. package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +47 -0
  239. package/lib/runjs-context/snippets/global/open-view-drawer.snippet.d.ts +11 -0
  240. package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +47 -0
  241. package/lib/runjs-context/snippets/global/requireAsync.snippet.d.ts +16 -0
  242. package/lib/runjs-context/snippets/global/requireAsync.snippet.js +46 -0
  243. package/lib/runjs-context/snippets/global/sleep.snippet.d.ts +16 -0
  244. package/lib/runjs-context/snippets/global/sleep.snippet.js +43 -0
  245. package/lib/runjs-context/snippets/global/try-catch-async.snippet.d.ts +16 -0
  246. package/lib/runjs-context/snippets/global/try-catch-async.snippet.js +44 -0
  247. package/lib/runjs-context/snippets/global/view-navigation-push.snippet.d.ts +11 -0
  248. package/lib/runjs-context/snippets/global/view-navigation-push.snippet.js +44 -0
  249. package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +16 -0
  250. package/lib/runjs-context/snippets/global/window-open.snippet.js +41 -0
  251. package/lib/runjs-context/snippets/index.d.ts +11 -0
  252. package/lib/runjs-context/snippets/index.js +94 -0
  253. package/lib/runjs-context/snippets/libs/echarts-init.snippet.d.ts +15 -0
  254. package/lib/runjs-context/snippets/libs/echarts-init.snippet.js +46 -0
  255. package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.d.ts +15 -0
  256. package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.js +44 -0
  257. package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.d.ts +15 -0
  258. package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.js +43 -0
  259. package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.d.ts +15 -0
  260. package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.js +43 -0
  261. package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.d.ts +15 -0
  262. package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.js +40 -0
  263. package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.d.ts +15 -0
  264. package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.js +46 -0
  265. package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.d.ts +15 -0
  266. package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.js +42 -0
  267. package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.d.ts +15 -0
  268. package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.js +46 -0
  269. package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.d.ts +15 -0
  270. package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.js +41 -0
  271. package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.d.ts +15 -0
  272. package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.js +41 -0
  273. package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.d.ts +15 -0
  274. package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.js +46 -0
  275. package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.d.ts +11 -0
  276. package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.js +45 -0
  277. package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.d.ts +15 -0
  278. package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.js +56 -0
  279. package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.d.ts +15 -0
  280. package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.js +42 -0
  281. package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.d.ts +15 -0
  282. package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.js +41 -0
  283. package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.d.ts +15 -0
  284. package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.js +40 -0
  285. package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.d.ts +15 -0
  286. package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.js +44 -0
  287. package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.d.ts +15 -0
  288. package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.js +60 -0
  289. package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.d.ts +15 -0
  290. package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.js +59 -0
  291. package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.d.ts +15 -0
  292. package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.js +60 -0
  293. package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.d.ts +15 -0
  294. package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.js +60 -0
  295. package/lib/runjs-context/snippets/types.d.ts +16 -0
  296. package/lib/runjs-context/snippets/types.js +24 -0
  297. package/lib/types.d.ts +398 -0
  298. package/lib/types.js +43 -0
  299. package/lib/utils/autoFlowError.d.ts +16 -0
  300. package/lib/utils/autoFlowError.js +53 -0
  301. package/lib/utils/constants.d.ts +29 -0
  302. package/lib/utils/constants.js +77 -0
  303. package/lib/utils/context.d.ts +40 -0
  304. package/lib/utils/context.js +63 -0
  305. package/lib/utils/createCollectionContextMeta.d.ts +11 -0
  306. package/lib/utils/createCollectionContextMeta.js +117 -0
  307. package/lib/utils/exceptions.d.ts +22 -0
  308. package/lib/utils/exceptions.js +62 -0
  309. package/lib/utils/flow-definitions.d.ts +11 -0
  310. package/lib/utils/flow-definitions.js +40 -0
  311. package/lib/utils/index.d.ts +22 -0
  312. package/lib/utils/index.js +117 -0
  313. package/lib/utils/inheritance.d.ts +16 -0
  314. package/lib/utils/inheritance.js +53 -0
  315. package/lib/utils/params-resolvers.d.ts +51 -0
  316. package/lib/utils/params-resolvers.js +309 -0
  317. package/lib/utils/parsePathnameToViewParams.d.ts +34 -0
  318. package/lib/utils/parsePathnameToViewParams.js +84 -0
  319. package/lib/utils/safeGlobals.d.ts +16 -0
  320. package/lib/utils/safeGlobals.js +179 -0
  321. package/lib/utils/schema-utils.d.ts +40 -0
  322. package/lib/utils/schema-utils.js +161 -0
  323. package/lib/utils/serverContextParams.d.ts +28 -0
  324. package/lib/utils/serverContextParams.js +106 -0
  325. package/lib/utils/setupRuntimeContextSteps.d.ts +19 -0
  326. package/lib/utils/setupRuntimeContextSteps.js +88 -0
  327. package/lib/utils/translation.d.ts +18 -0
  328. package/lib/utils/translation.js +58 -0
  329. package/lib/utils/variablesParams.d.ts +51 -0
  330. package/lib/utils/variablesParams.js +150 -0
  331. package/lib/views/DialogComponent.d.ts +22 -0
  332. package/lib/views/DialogComponent.js +98 -0
  333. package/lib/views/DrawerComponent.d.ts +11 -0
  334. package/lib/views/DrawerComponent.js +101 -0
  335. package/lib/views/FlowView.d.ts +76 -0
  336. package/lib/views/FlowView.js +81 -0
  337. package/lib/views/PageComponent.d.ts +10 -0
  338. package/lib/views/PageComponent.js +167 -0
  339. package/lib/views/ViewNavigation.d.ts +45 -0
  340. package/lib/views/ViewNavigation.js +97 -0
  341. package/lib/views/createViewMeta.d.ts +16 -0
  342. package/lib/views/createViewMeta.js +171 -0
  343. package/lib/views/index.d.ts +13 -0
  344. package/lib/views/index.js +48 -0
  345. package/lib/views/useDialog.d.ts +32 -0
  346. package/lib/views/useDialog.js +199 -0
  347. package/lib/views/useDrawer.d.ts +33 -0
  348. package/lib/views/useDrawer.js +206 -0
  349. package/lib/views/usePage.d.ts +32 -0
  350. package/lib/views/usePage.js +193 -0
  351. package/lib/views/usePatchElement.d.ts +10 -0
  352. package/lib/views/usePatchElement.js +54 -0
  353. package/lib/views/usePopover.d.ts +17 -0
  354. package/lib/views/usePopover.js +159 -0
  355. package/package.json +37 -0
  356. package/src/ContextPathProxy.ts +45 -0
  357. package/src/ElementProxy.ts +69 -0
  358. package/src/FlowContextProvider.tsx +40 -0
  359. package/src/FlowDefinition.ts +275 -0
  360. package/src/JSRunner.ts +84 -0
  361. package/src/ReactView.tsx +104 -0
  362. package/src/ViewScopedFlowEngine.ts +75 -0
  363. package/src/__tests__/ElementProxy.test.ts +51 -0
  364. package/src/__tests__/JSRunner.test.ts +92 -0
  365. package/src/__tests__/ReactView.test.tsx +63 -0
  366. package/src/__tests__/context-path-proxy.test.ts +35 -0
  367. package/src/__tests__/flow-engine.test.ts +189 -0
  368. package/src/__tests__/flowContext.test.ts +2012 -0
  369. package/src/__tests__/flowEngine.saveModel.test.ts +171 -0
  370. package/src/__tests__/flowI18n.test.ts +28 -0
  371. package/src/__tests__/flowModel.getFlows.test.ts +61 -0
  372. package/src/__tests__/flowModel.openView.navigation.test.ts +78 -0
  373. package/src/__tests__/flowRuntimeContext.test.ts +187 -0
  374. package/src/__tests__/flowSettings.open.test.tsx +1920 -0
  375. package/src/__tests__/flowSettings.test.ts +566 -0
  376. package/src/__tests__/globalFlowRegistry.test.ts +77 -0
  377. package/src/__tests__/isFieldInterfaceMatch.test.ts +51 -0
  378. package/src/__tests__/metaTreeNodeCache.test.ts +234 -0
  379. package/src/__tests__/path-aggregation.test.ts +85 -0
  380. package/src/__tests__/provider.test.tsx +28 -0
  381. package/src/__tests__/renderHiddenInConfig.test.tsx +91 -0
  382. package/src/__tests__/runjsContext.test.ts +60 -0
  383. package/src/__tests__/viewScopedFlowEngine.test.ts +212 -0
  384. package/src/acl/Acl.tsx +109 -0
  385. package/src/acl/__tests__/Acl.test.tsx +72 -0
  386. package/src/action-registry/BaseActionRegistry.ts +46 -0
  387. package/src/action-registry/EngineActionRegistry.ts +32 -0
  388. package/src/action-registry/ModelActionRegistry.ts +75 -0
  389. package/src/action-registry/__tests__/engineActionRegistry.test.ts +43 -0
  390. package/src/action-registry/__tests__/modelActionRegistry.test.ts +107 -0
  391. package/src/components/DynamicFlowsEditor.tsx +318 -0
  392. package/src/components/FieldModelRenderer.tsx +62 -0
  393. package/src/components/FlowContextSelector.tsx +255 -0
  394. package/src/components/FlowErrorFallback.tsx +316 -0
  395. package/src/components/FlowModelRenderer.tsx +428 -0
  396. package/src/components/FormItem.tsx +130 -0
  397. package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -0
  398. package/src/components/common/FlowSettingsButton.tsx +30 -0
  399. package/src/components/common/index.ts +10 -0
  400. package/src/components/common/withFlowDesignMode.tsx +49 -0
  401. package/src/components/dnd/getMousePositionOnElement.ts +115 -0
  402. package/src/components/dnd/index.tsx +128 -0
  403. package/src/components/dnd/moveBlock.ts +379 -0
  404. package/src/components/index.ts +20 -0
  405. package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +279 -0
  406. package/src/components/settings/independents/dropdown/index.ts +10 -0
  407. package/src/components/settings/independents/index.ts +2 -0
  408. package/src/components/settings/index.ts +11 -0
  409. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +617 -0
  410. package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +292 -0
  411. package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +655 -0
  412. package/src/components/settings/wrappers/contextual/StepRequiredSettingsDialog.tsx +446 -0
  413. package/src/components/settings/wrappers/contextual/StepSettings.tsx +109 -0
  414. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +217 -0
  415. package/src/components/settings/wrappers/contextual/StepSettingsDrawer.tsx +32 -0
  416. package/src/components/settings/wrappers/contextual/index.ts +15 -0
  417. package/src/components/settings/wrappers/embedded/FlowSettings.tsx +258 -0
  418. package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +111 -0
  419. package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +96 -0
  420. package/src/components/settings/wrappers/embedded/index.ts +11 -0
  421. package/src/components/settings/wrappers/index.ts +5 -0
  422. package/src/components/subModel/AddSubModelButton.tsx +575 -0
  423. package/src/components/subModel/LazyDropdown.tsx +714 -0
  424. package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1185 -0
  425. package/src/components/subModel/__tests__/buildWrapperFieldChildren.test.ts +192 -0
  426. package/src/components/subModel/__tests__/utils.test.ts +425 -0
  427. package/src/components/subModel/index.ts +12 -0
  428. package/src/components/subModel/utils.ts +278 -0
  429. package/src/components/variables/InlineVariableTag.tsx +97 -0
  430. package/src/components/variables/SlateVariableEditor.tsx +384 -0
  431. package/src/components/variables/VariableInput.tsx +342 -0
  432. package/src/components/variables/VariableTag.tsx +123 -0
  433. package/src/components/variables/VariableTrigger.tsx +116 -0
  434. package/src/components/variables/__tests__/FlowContextSelector.test.tsx +553 -0
  435. package/src/components/variables/__tests__/VariableInput.test.tsx +550 -0
  436. package/src/components/variables/__tests__/VariableTag.test.tsx +347 -0
  437. package/src/components/variables/__tests__/test-utils.tsx +62 -0
  438. package/src/components/variables/__tests__/utils.test.ts +310 -0
  439. package/src/components/variables/index.ts +16 -0
  440. package/src/components/variables/types.ts +100 -0
  441. package/src/components/variables/useResolvedMetaTree.ts +76 -0
  442. package/src/components/variables/utils.ts +192 -0
  443. package/src/data-source/__tests__/collection.test.ts +58 -0
  444. package/src/data-source/__tests__/index.test.ts +82 -0
  445. package/src/data-source/__tests__/jioToJoiSchema.test.ts +56 -0
  446. package/src/data-source/index.ts +812 -0
  447. package/src/data-source/jioToJoiSchema.ts +103 -0
  448. package/src/decorators/index.ts +10 -0
  449. package/src/decorators/largeField.ts +14 -0
  450. package/src/emitter.ts +33 -0
  451. package/src/event-registry/BaseEventRegistry.ts +40 -0
  452. package/src/event-registry/EngineEventRegistry.ts +26 -0
  453. package/src/event-registry/ModelEventRegistry.ts +69 -0
  454. package/src/event-registry/__tests__/engineEventRegistry.test.ts +48 -0
  455. package/src/executor/FlowExecutor.ts +256 -0
  456. package/src/executor/__tests__/eventStep.test.ts +157 -0
  457. package/src/executor/__tests__/flowExecutor.test.ts +163 -0
  458. package/src/flow-registry/BaseFlowRegistry.ts +91 -0
  459. package/src/flow-registry/GlobalFlowRegistry.ts +82 -0
  460. package/src/flow-registry/InstanceFlowRegistry.ts +39 -0
  461. package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +141 -0
  462. package/src/flow-registry/__tests__/instance-and-global-registry.test.ts +67 -0
  463. package/src/flow-registry/__tests__/instanceFlowRegistry.test.ts +83 -0
  464. package/src/flow-registry/index.ts +12 -0
  465. package/src/flowContext.ts +1639 -0
  466. package/src/flowEngine.ts +905 -0
  467. package/src/flowI18n.ts +96 -0
  468. package/src/flowSettings.ts +1045 -0
  469. package/src/hooks/index.ts +15 -0
  470. package/src/hooks/useApplyAutoFlows.ts +51 -0
  471. package/src/hooks/useFlowModel.tsx +59 -0
  472. package/src/hooks/useFlowModelById.ts +37 -0
  473. package/src/hooks/useFlowSettingsContext.tsx +37 -0
  474. package/src/hooks/useFlowStep.tsx +19 -0
  475. package/src/hooks/useNiceDropdownMaxHeight.ts +34 -0
  476. package/src/index.ts +38 -0
  477. package/src/locale/en-US.json +61 -0
  478. package/src/locale/index.ts +38 -0
  479. package/src/locale/zh-CN.json +61 -0
  480. package/src/models/CollectionFieldModel.tsx +269 -0
  481. package/src/models/DisplayItemModel.tsx +13 -0
  482. package/src/models/EditableItemModel.tsx +13 -0
  483. package/src/models/FilterableItemModel.tsx +13 -0
  484. package/src/models/__tests__/CollectionFieldModel.test.ts +122 -0
  485. package/src/models/__tests__/defaultParams-on-create.test.ts +83 -0
  486. package/src/models/__tests__/flow-model-oninit.test.ts +44 -0
  487. package/src/models/__tests__/flowModel.actions.integration.test.ts +100 -0
  488. package/src/models/__tests__/flowModel.getFlows.sort.test.ts +100 -0
  489. package/src/models/__tests__/flowModel.test.ts +2746 -0
  490. package/src/models/__tests__/flowRegistry.test.ts +512 -0
  491. package/src/models/__tests__/forkFlowModel.test.ts +1047 -0
  492. package/src/models/__tests__/model-actions.test.ts +70 -0
  493. package/src/models/__tests__/model-events.test.ts +69 -0
  494. package/src/models/flowModel.tsx +1398 -0
  495. package/src/models/forkFlowModel.ts +287 -0
  496. package/src/models/index.ts +17 -0
  497. package/src/provider.tsx +101 -0
  498. package/src/resources/__tests__/apiResource.test.ts +201 -0
  499. package/src/resources/__tests__/baseRecordResource.test.ts +262 -0
  500. package/src/resources/__tests__/filterItem.test.ts +260 -0
  501. package/src/resources/__tests__/flowResource.test.ts +127 -0
  502. package/src/resources/apiResource.ts +148 -0
  503. package/src/resources/baseRecordResource.ts +279 -0
  504. package/src/resources/filterItem.ts +74 -0
  505. package/src/resources/flowResource.ts +143 -0
  506. package/src/resources/index.ts +17 -0
  507. package/src/resources/multiRecordResource.ts +219 -0
  508. package/src/resources/singleRecordResource.ts +83 -0
  509. package/src/resources/sqlResource.ts +299 -0
  510. package/src/runjs-context/contexts/FlowRunJSContext.ts +190 -0
  511. package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +39 -0
  512. package/src/runjs-context/contexts/JSBlockRunJSContext.ts +52 -0
  513. package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +32 -0
  514. package/src/runjs-context/contexts/JSFieldRunJSContext.ts +43 -0
  515. package/src/runjs-context/contexts/JSItemRunJSContext.ts +39 -0
  516. package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +34 -0
  517. package/src/runjs-context/contexts/LinkageRunJSContext.ts +35 -0
  518. package/src/runjs-context/helpers.ts +56 -0
  519. package/src/runjs-context/index.ts +20 -0
  520. package/src/runjs-context/registry.ts +65 -0
  521. package/src/runjs-context/snippets/global/api-request-get.snippet.ts +20 -0
  522. package/src/runjs-context/snippets/global/api-request-post.snippet.ts +20 -0
  523. package/src/runjs-context/snippets/global/console-log-ctx.snippet.ts +19 -0
  524. package/src/runjs-context/snippets/global/copy-record-json.snippet.ts +21 -0
  525. package/src/runjs-context/snippets/global/copy-to-clipboard.snippet.ts +21 -0
  526. package/src/runjs-context/snippets/global/log-json-record.snippet.ts +21 -0
  527. package/src/runjs-context/snippets/global/message-error.snippet.ts +20 -0
  528. package/src/runjs-context/snippets/global/message-success.snippet.ts +20 -0
  529. package/src/runjs-context/snippets/global/notification-open.snippet.ts +21 -0
  530. package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +26 -0
  531. package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +26 -0
  532. package/src/runjs-context/snippets/global/requireAsync.snippet.ts +24 -0
  533. package/src/runjs-context/snippets/global/sleep.snippet.ts +21 -0
  534. package/src/runjs-context/snippets/global/try-catch-async.snippet.ts +22 -0
  535. package/src/runjs-context/snippets/global/view-navigation-push.snippet.ts +23 -0
  536. package/src/runjs-context/snippets/global/window-open.snippet.ts +19 -0
  537. package/src/runjs-context/snippets/index.ts +59 -0
  538. package/src/runjs-context/snippets/libs/echarts-init.snippet.ts +24 -0
  539. package/src/runjs-context/snippets/scene/actions/collection-selected-count.snippet.ts +22 -0
  540. package/src/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.ts +21 -0
  541. package/src/runjs-context/snippets/scene/actions/record-id-message.snippet.ts +21 -0
  542. package/src/runjs-context/snippets/scene/actions/run-action-basic.snippet.ts +18 -0
  543. package/src/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.ts +29 -0
  544. package/src/runjs-context/snippets/scene/jsblock/append-style.snippet.ts +20 -0
  545. package/src/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.ts +24 -0
  546. package/src/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.ts +19 -0
  547. package/src/runjs-context/snippets/scene/jsblock/render-basic.snippet.ts +24 -0
  548. package/src/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.ts +24 -0
  549. package/src/runjs-context/snippets/scene/jsblock/render-card.snippet.ts +30 -0
  550. package/src/runjs-context/snippets/scene/jsblock/render-react.snippet.ts +34 -0
  551. package/src/runjs-context/snippets/scene/jsfield/color-by-value.snippet.ts +20 -0
  552. package/src/runjs-context/snippets/scene/jsfield/format-number.snippet.ts +19 -0
  553. package/src/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.ts +18 -0
  554. package/src/runjs-context/snippets/scene/jsitem/render-basic.snippet.ts +27 -0
  555. package/src/runjs-context/snippets/scene/linkage/set-disabled.snippet.ts +38 -0
  556. package/src/runjs-context/snippets/scene/linkage/set-field-value.snippet.ts +37 -0
  557. package/src/runjs-context/snippets/scene/linkage/set-required.snippet.ts +38 -0
  558. package/src/runjs-context/snippets/scene/linkage/toggle-visible.snippet.ts +38 -0
  559. package/src/runjs-context/snippets/types.ts +17 -0
  560. package/src/types.ts +474 -0
  561. package/src/utils/__tests__/context.test.ts +93 -0
  562. package/src/utils/__tests__/params-resolvers.test.ts +652 -0
  563. package/src/utils/__tests__/parsePathnameToViewParams.test.ts +104 -0
  564. package/src/utils/__tests__/safeGlobals.test.ts +29 -0
  565. package/src/utils/__tests__/utils.test.ts +1021 -0
  566. package/src/utils/__tests__/variablesParams.test.ts +52 -0
  567. package/src/utils/autoFlowError.ts +29 -0
  568. package/src/utils/constants.ts +60 -0
  569. package/src/utils/context.ts +70 -0
  570. package/src/utils/createCollectionContextMeta.ts +122 -0
  571. package/src/utils/exceptions.ts +36 -0
  572. package/src/utils/flow-definitions.ts +16 -0
  573. package/src/utils/index.ts +63 -0
  574. package/src/utils/inheritance.ts +39 -0
  575. package/src/utils/params-resolvers.ts +482 -0
  576. package/src/utils/parsePathnameToViewParams.ts +103 -0
  577. package/src/utils/safeGlobals.ts +188 -0
  578. package/src/utils/schema-utils.ts +201 -0
  579. package/src/utils/serverContextParams.ts +111 -0
  580. package/src/utils/setupRuntimeContextSteps.ts +89 -0
  581. package/src/utils/translation.ts +37 -0
  582. package/src/utils/variablesParams.ts +175 -0
  583. package/src/views/DialogComponent.tsx +79 -0
  584. package/src/views/DrawerComponent.tsx +72 -0
  585. package/src/views/FlowView.tsx +103 -0
  586. package/src/views/PageComponent.tsx +150 -0
  587. package/src/views/ViewNavigation.ts +122 -0
  588. package/src/views/__tests__/FlowView.test.ts +31 -0
  589. package/src/views/__tests__/ViewNavigation.test.ts +191 -0
  590. package/src/views/__tests__/usePatchElement.test.tsx +28 -0
  591. package/src/views/createViewMeta.ts +157 -0
  592. package/src/views/index.tsx +14 -0
  593. package/src/views/useDialog.tsx +192 -0
  594. package/src/views/useDrawer.tsx +205 -0
  595. package/src/views/usePage.tsx +182 -0
  596. package/src/views/usePatchElement.tsx +27 -0
  597. package/src/views/usePopover.tsx +131 -0
@@ -0,0 +1,781 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __typeError = (msg) => {
17
+ throw TypeError(msg);
18
+ };
19
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
21
+ var __export = (target, all) => {
22
+ for (var name in all)
23
+ __defProp(target, name, { get: all[name], enumerable: true });
24
+ };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
44
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
46
+ var flowEngine_exports = {};
47
+ __export(flowEngine_exports, {
48
+ FlowEngine: () => FlowEngine
49
+ });
50
+ module.exports = __toCommonJS(flowEngine_exports);
51
+ var import_reactive = require("@formily/reactive");
52
+ var import_lodash = __toESM(require("lodash"));
53
+ var import_pino = __toESM(require("pino"));
54
+ var import_EngineActionRegistry = require("./action-registry/EngineActionRegistry");
55
+ var import_EngineEventRegistry = require("./event-registry/EngineEventRegistry");
56
+ var import_FlowExecutor = require("./executor/FlowExecutor");
57
+ var import_flowContext = require("./flowContext");
58
+ var import_flowSettings = require("./flowSettings");
59
+ var import_models = require("./models");
60
+ var import_ReactView = require("./ReactView");
61
+ var import_resources = require("./resources");
62
+ var import_utils = require("./utils");
63
+ var _FlowEngine_instances, registerModel_fn;
64
+ const _FlowEngine = class _FlowEngine {
65
+ /**
66
+ * Constructor. Initializes React view, registers default model and form scopes.
67
+ */
68
+ constructor() {
69
+ __privateAdd(this, _FlowEngine_instances);
70
+ /**
71
+ * Global action registry
72
+ */
73
+ __publicField(this, "_actionRegistry", new import_EngineActionRegistry.EngineActionRegistry());
74
+ /**
75
+ * Global event registry
76
+ */
77
+ __publicField(this, "_eventRegistry", new import_EngineEventRegistry.EngineEventRegistry());
78
+ /**
79
+ * Registered model classes.
80
+ * Key is the model class name, value is the model class constructor.
81
+ * @private
82
+ */
83
+ __publicField(this, "_modelClasses", import_reactive.observable.shallow(/* @__PURE__ */ new Map()));
84
+ /**
85
+ * Created model instances.
86
+ * Key is the model instance UID, value is the model instance object.
87
+ * @private
88
+ */
89
+ __publicField(this, "_modelInstances", /* @__PURE__ */ new Map());
90
+ /**
91
+ * The current model repository instance, implements IFlowModelRepository.
92
+ * Used for model persistence and queries.
93
+ * @private
94
+ */
95
+ __publicField(this, "_modelRepository", null);
96
+ /**
97
+ * Flow application cache.
98
+ * Key is the cache key, value is ApplyFlowCacheEntry.
99
+ * @private
100
+ */
101
+ __publicField(this, "_applyFlowCache", /* @__PURE__ */ new Map());
102
+ /**
103
+ * Model saving state tracking.
104
+ * Key is the model UID, value is the save promise.
105
+ * @private
106
+ */
107
+ __publicField(this, "_savingModels", /* @__PURE__ */ new Map());
108
+ /**
109
+ * Flow engine context object.
110
+ * @private
111
+ */
112
+ __publicField(this, "_flowContext");
113
+ /**
114
+ * 视图作用域引擎的栈式链表指针。
115
+ * - previousEngine:打开当前视图的上一个引擎
116
+ * - nextEngine:在当前之上的下一个引擎
117
+ */
118
+ __publicField(this, "_previousEngine");
119
+ __publicField(this, "_nextEngine");
120
+ __publicField(this, "_resources", /* @__PURE__ */ new Map());
121
+ __publicField(this, "logger");
122
+ /**
123
+ * Flow settings, including components and form scopes.
124
+ * @public
125
+ */
126
+ __publicField(this, "flowSettings");
127
+ /**
128
+ * Experimental API: Integrates React view rendering capability into FlowEngine.
129
+ * This property may change or be removed in the future. Use with caution.
130
+ * @experimental
131
+ * @public
132
+ */
133
+ __publicField(this, "reactView");
134
+ /**
135
+ * Flow executor that runs flows and auto-flows.
136
+ */
137
+ __publicField(this, "executor");
138
+ this.reactView = new import_ReactView.ReactView(this);
139
+ this.flowSettings = new import_flowSettings.FlowSettings(this);
140
+ this.flowSettings.registerScopes({ t: this.translate.bind(this) });
141
+ this.registerModels({ FlowModel: import_models.FlowModel });
142
+ this.registerResources({
143
+ FlowResource: import_resources.FlowResource,
144
+ SQLResource: import_resources.SQLResource,
145
+ APIResource: import_resources.APIResource,
146
+ SingleRecordResource: import_resources.SingleRecordResource,
147
+ MultiRecordResource: import_resources.MultiRecordResource
148
+ });
149
+ this.logger = (0, import_pino.default)({
150
+ level: "trace",
151
+ browser: {
152
+ write: {
153
+ fatal: /* @__PURE__ */ __name((o) => console.trace(o), "fatal"),
154
+ error: /* @__PURE__ */ __name((o) => console.error(o), "error"),
155
+ warn: /* @__PURE__ */ __name((o) => console.warn(o), "warn"),
156
+ info: /* @__PURE__ */ __name((o) => console.info(o), "info"),
157
+ debug: /* @__PURE__ */ __name((o) => console.debug(o), "debug"),
158
+ trace: /* @__PURE__ */ __name((o) => console.trace(o), "trace")
159
+ }
160
+ }
161
+ });
162
+ this.executor = new import_FlowExecutor.FlowExecutor(this);
163
+ }
164
+ /** 上一个引擎(根引擎为 undefined) */
165
+ get previousEngine() {
166
+ return this._previousEngine;
167
+ }
168
+ /** 下一个引擎(若存在) */
169
+ get nextEngine() {
170
+ return this._nextEngine;
171
+ }
172
+ /**
173
+ * 将当前引擎链接到 prev 之后(用于视图打开时形成栈关系)。
174
+ */
175
+ linkAfter(engine) {
176
+ let prev = engine;
177
+ while (prev._nextEngine) prev = prev._nextEngine;
178
+ this._previousEngine = prev;
179
+ if (prev) {
180
+ prev._nextEngine = this;
181
+ }
182
+ }
183
+ /**
184
+ * 将当前引擎从栈中移除并修复相邻指针(用于视图关闭时)。
185
+ */
186
+ unlinkFromStack() {
187
+ const prev = this._previousEngine;
188
+ const next = this._nextEngine;
189
+ if (prev) {
190
+ prev._nextEngine = void 0;
191
+ }
192
+ }
193
+ // (已移除)getModelGlobal/forEachModelGlobal/getAllModelsGlobal:不再维护冗余全局遍历 API
194
+ /**
195
+ * Get the flow engine context object.
196
+ * @returns {FlowEngineContext} Flow engine context
197
+ */
198
+ get context() {
199
+ if (!this._flowContext) {
200
+ this._flowContext = new import_flowContext.FlowEngineContext(this);
201
+ }
202
+ return this._flowContext;
203
+ }
204
+ get dataSourceManager() {
205
+ return this.context.dataSourceManager;
206
+ }
207
+ /**
208
+ * Get the flow application cache.
209
+ * @returns {Map<string, ApplyFlowCacheEntry>} Flow application cache map
210
+ * @internal
211
+ */
212
+ get applyFlowCache() {
213
+ return this._applyFlowCache;
214
+ }
215
+ /**
216
+ * Set the model repository for persisting and querying model instances.
217
+ * If a model repository was already set, it will be overwritten and a warning will be printed.
218
+ * @param {IFlowModelRepository} modelRepository The model repository instance implementing IFlowModelRepository.
219
+ * @example
220
+ * flowEngine.setModelRepository(new MyFlowModelRepository());
221
+ */
222
+ setModelRepository(modelRepository) {
223
+ if (this._modelRepository) {
224
+ console.warn("FlowEngine: Model repository is already set and will be overwritten.");
225
+ }
226
+ this._modelRepository = modelRepository;
227
+ }
228
+ get modelRepository() {
229
+ return this._modelRepository;
230
+ }
231
+ /**
232
+ * Internationalization translation method, calls the context's t method.
233
+ * @param {string} keyOrTemplate Translation key or template string
234
+ * @param {any} [options] Optional parameters
235
+ * @returns {string} Translated string
236
+ */
237
+ translate(keyOrTemplate, options) {
238
+ return this.context.t(keyOrTemplate, options);
239
+ }
240
+ /**
241
+ * Register multiple actions.
242
+ * @param {Record<string, ActionDefinition>} actions Action definition object collection
243
+ */
244
+ registerActions(actions) {
245
+ this._actionRegistry.registerActions(actions);
246
+ }
247
+ /**
248
+ * Get a registered action definition.
249
+ * @template TModel Specific FlowModel subclass type
250
+ * @param {string} name Action name
251
+ * @returns {ActionDefinition<TModel> | undefined} Action definition, or undefined if not found
252
+ */
253
+ getAction(name) {
254
+ return this._actionRegistry.getAction(name);
255
+ }
256
+ /**
257
+ * Get all registered global actions.
258
+ * Returns a new Map to avoid external mutation of internal state.
259
+ */
260
+ getActions() {
261
+ return this._actionRegistry.getActions();
262
+ }
263
+ /**
264
+ * Register multiple events.
265
+ */
266
+ registerEvents(events) {
267
+ this._eventRegistry.registerEvents(events);
268
+ }
269
+ /**
270
+ * Get a registered event definition.
271
+ */
272
+ getEvent(name) {
273
+ return this._eventRegistry.getEvent(name);
274
+ }
275
+ /**
276
+ * Get all registered global events.
277
+ */
278
+ getEvents() {
279
+ return this._eventRegistry.getEvents();
280
+ }
281
+ /**
282
+ * Register multiple model classes.
283
+ * @param {Record<string, ModelConstructor>} models Model class map, key is model name, value is model constructor
284
+ * @returns {void}
285
+ * @example
286
+ * flowEngine.registerModels({ UserModel, OrderModel });
287
+ */
288
+ registerModels(models) {
289
+ for (const [name, modelClass] of Object.entries(models)) {
290
+ __privateMethod(this, _FlowEngine_instances, registerModel_fn).call(this, name, modelClass);
291
+ }
292
+ }
293
+ registerResources(resources) {
294
+ for (const [name, resourceClass] of Object.entries(resources)) {
295
+ this._resources.set(name, resourceClass);
296
+ }
297
+ }
298
+ createResource(resourceType, options) {
299
+ if (typeof resourceType === "string") {
300
+ const ResourceClass = this._resources.get(resourceType);
301
+ if (!ResourceClass) {
302
+ throw new Error(`Resource class '${resourceType}' not found. Please register it first.`);
303
+ }
304
+ return new ResourceClass((options == null ? void 0 : options.context) || this.context);
305
+ }
306
+ const R = resourceType;
307
+ return new R((options == null ? void 0 : options.context) || this.context);
308
+ }
309
+ /**
310
+ * Get all registered model classes.
311
+ * @returns {Map<string, ModelConstructor>} Model class map
312
+ */
313
+ getModelClasses() {
314
+ return this._modelClasses;
315
+ }
316
+ /**
317
+ * Get a registered model class (constructor).
318
+ * @param {string} name Model class name
319
+ * @returns {ModelConstructor | undefined} Model constructor, or undefined if not found
320
+ */
321
+ getModelClass(name) {
322
+ return this._modelClasses.get(name);
323
+ }
324
+ /**
325
+ * Find a registered model class by predicate.
326
+ * @param predicate Callback function, arguments are (name, ModelClass), returns true if matched
327
+ * @returns {[string, ModelConstructor] | undefined} Matched model class and name
328
+ */
329
+ findModelClass(predicate) {
330
+ for (const [name, ModelClass] of this._modelClasses) {
331
+ if (predicate(name, ModelClass)) {
332
+ return [name, ModelClass];
333
+ }
334
+ }
335
+ return void 0;
336
+ }
337
+ /**
338
+ * Filter model classes by base class (supports multi-level inheritance), with optional custom filter.
339
+ * @param {string | ModelConstructor} baseClass Base class name or constructor
340
+ * @param {(ModelClass: ModelConstructor, className: string) => boolean} [filter] Optional filter function
341
+ * @returns {Map<string, ModelConstructor>} Model classes inherited from base class and passed the filter
342
+ */
343
+ getSubclassesOf(baseClass, filter) {
344
+ const parentModelClass = typeof baseClass === "string" ? this.getModelClass(baseClass) : baseClass;
345
+ const result = /* @__PURE__ */ new Map();
346
+ if (!parentModelClass) return result;
347
+ for (const [className, ModelClass] of this._modelClasses) {
348
+ if ((0, import_utils.isInheritedFrom)(ModelClass, parentModelClass)) {
349
+ if (!filter || filter(ModelClass, className)) {
350
+ result.set(className, ModelClass);
351
+ }
352
+ }
353
+ }
354
+ return result;
355
+ }
356
+ /**
357
+ * Create and register a model instance.
358
+ * If an instance with the same UID exists, returns the existing instance.
359
+ * @template T FlowModel subclass type, defaults to FlowModel.
360
+ * @param {CreateModelOptions} options Model creation options
361
+ * @returns {T} Created model instance
362
+ */
363
+ createModel(options, extra) {
364
+ const { parentId, uid, use: modelClassName, subModels } = options;
365
+ const ModelClass = typeof modelClassName === "string" ? this.getModelClass(modelClassName) : modelClassName;
366
+ if (uid && this._modelInstances.has(uid)) {
367
+ return this._modelInstances.get(uid);
368
+ }
369
+ let modelInstance;
370
+ if (!ModelClass) {
371
+ modelInstance = new import_models.ErrorFlowModel({ ...options, flowEngine: this });
372
+ modelInstance.setErrorMessage(`Model class '${modelClassName}' not found. Please register it first.`);
373
+ } else {
374
+ modelInstance = new ModelClass({ ...options, flowEngine: this });
375
+ }
376
+ if (extra == null ? void 0 : extra.delegate) {
377
+ modelInstance.context.addDelegate(extra.delegate);
378
+ }
379
+ if (parentId && this._modelInstances.has(parentId)) {
380
+ modelInstance.setParent(this._modelInstances.get(parentId));
381
+ if ((extra == null ? void 0 : extra.delegateToParent) === false) {
382
+ modelInstance.removeParentDelegate();
383
+ }
384
+ }
385
+ this._modelInstances.set(modelInstance.uid, modelInstance);
386
+ modelInstance.onInit(options);
387
+ this._applyFlowDefinitionDefaultParams(modelInstance).catch((err) => {
388
+ console.warn("FlowEngine: apply flow defaultParams failed:", err);
389
+ });
390
+ modelInstance._createSubModels(options.subModels);
391
+ return modelInstance;
392
+ }
393
+ /**
394
+ * 尝试应用当前模型可用 flow 的 defaultParams(如果存在)到 model.stepParams。
395
+ * 仅对尚未存在的步骤参数进行填充,不覆盖已有值。
396
+ */
397
+ async _applyFlowDefinitionDefaultParams(model) {
398
+ var _a;
399
+ try {
400
+ const flows = model.getFlows();
401
+ if (!flows || flows.size === 0) return;
402
+ const ctx = model.context;
403
+ for (const [flowKey, flowDef] of flows.entries()) {
404
+ const dp = flowDef.defaultParams;
405
+ if (!dp) continue;
406
+ let resolved;
407
+ try {
408
+ resolved = typeof dp === "function" ? await dp(ctx) : dp;
409
+ } catch (e) {
410
+ console.warn(`FlowEngine: resolve defaultParams of flow '${flowKey}' failed:`, e);
411
+ continue;
412
+ }
413
+ if (!resolved || typeof resolved !== "object") continue;
414
+ const stepsMap = (_a = flowDef.getSteps) == null ? void 0 : _a.call(flowDef);
415
+ const stepKeys = stepsMap ? Array.from(stepsMap.keys()) : Object.keys(flowDef.steps || {});
416
+ const entries = Object.entries(resolved).filter(([k]) => stepKeys.includes(k));
417
+ if (entries.length === 0) continue;
418
+ for (const [stepKey, params] of entries) {
419
+ const exists = model.getStepParams(flowKey, stepKey);
420
+ if (exists === void 0 && params && typeof params === "object") {
421
+ model.setStepParams(flowKey, stepKey, params);
422
+ }
423
+ }
424
+ }
425
+ } catch (error) {
426
+ console.warn("FlowEngine: apply flow defaultParams error:", error);
427
+ }
428
+ }
429
+ /**
430
+ * Get a model instance by UID.
431
+ * @template T FlowModel subclass type, defaults to FlowModel.
432
+ * @param {string} uid Model instance UID
433
+ * @returns {T | undefined} Model instance, or undefined if not found
434
+ */
435
+ getModel(uid, global) {
436
+ if (!global) {
437
+ return this._modelInstances.get(uid);
438
+ }
439
+ let top = this;
440
+ while (top.nextEngine) top = top.nextEngine;
441
+ let eng = top;
442
+ while (eng) {
443
+ const found = eng._modelInstances.get(uid);
444
+ if (found) return found;
445
+ eng = eng.previousEngine;
446
+ }
447
+ return void 0;
448
+ }
449
+ /**
450
+ * Iterate all registered model instances.
451
+ * @template T FlowModel subclass type, defaults to FlowModel.
452
+ * @param {(model: T) => void} callback Callback function
453
+ */
454
+ forEachModel(callback) {
455
+ this._modelInstances.forEach(callback);
456
+ }
457
+ /**
458
+ * Remove a local model instance.
459
+ * @param {string} uid UID of the model instance to destroy
460
+ * @returns {boolean} Returns true if successfully destroyed, false otherwise (e.g. instance does not exist)
461
+ */
462
+ removeModel(uid) {
463
+ var _a;
464
+ if (!this._modelInstances.has(uid)) {
465
+ console.warn(`FlowEngine: Model with UID '${uid}' does not exist.`);
466
+ return false;
467
+ }
468
+ const modelInstance = this._modelInstances.get(uid);
469
+ modelInstance.clearForks();
470
+ if ((_a = modelInstance.parent) == null ? void 0 : _a.subModels) {
471
+ for (const subKey in modelInstance.parent.subModels) {
472
+ const subModelValue = modelInstance.parent.subModels[subKey];
473
+ if (Array.isArray(subModelValue)) {
474
+ const index = subModelValue.findIndex((subModel) => subModel == modelInstance);
475
+ if (index !== -1) {
476
+ subModelValue.splice(index, 1);
477
+ modelInstance.parent.emitter.emit("onSubModelRemoved", modelInstance);
478
+ break;
479
+ }
480
+ } else if (subModelValue && subModelValue === modelInstance) {
481
+ delete modelInstance.parent.subModels[subKey];
482
+ modelInstance.parent.emitter.emit("onSubModelRemoved", modelInstance);
483
+ break;
484
+ }
485
+ }
486
+ }
487
+ this._modelInstances.delete(uid);
488
+ return true;
489
+ }
490
+ /**
491
+ * Check if the model repository is set.
492
+ * @returns {boolean} Returns true if set, false otherwise.
493
+ * @private
494
+ */
495
+ ensureModelRepository() {
496
+ if (!this._modelRepository) {
497
+ return false;
498
+ }
499
+ return true;
500
+ }
501
+ /**
502
+ * Load a model instance (prefers local, falls back to repository).
503
+ * @template T FlowModel subclass type, defaults to FlowModel.
504
+ * @param {any} options Load options
505
+ * @returns {Promise<T | null>} Loaded model instance or null
506
+ */
507
+ async loadModel(options) {
508
+ if (!this.ensureModelRepository()) return;
509
+ const model = this.findModelByParentId(options.parentId, options.subKey);
510
+ if (model) {
511
+ return model;
512
+ }
513
+ const data = await this._modelRepository.findOne(options);
514
+ return (data == null ? void 0 : data.uid) ? this.createModel(data) : null;
515
+ }
516
+ /**
517
+ * Find a sub-model by parent model ID and subKey.
518
+ * @template T FlowModel subclass type, defaults to FlowModel.
519
+ * @param {string} parentId Parent model UID
520
+ * @param {string} subKey Sub-model key
521
+ * @returns {T | null} Found sub-model or null
522
+ */
523
+ findModelByParentId(parentId, subKey) {
524
+ if (parentId && this._modelInstances.has(parentId)) {
525
+ const parentModel = this._modelInstances.get(parentId);
526
+ if (parentModel && parentModel.subModels[subKey]) {
527
+ const subModels = parentModel.subModels[subKey];
528
+ if (Array.isArray(subModels)) {
529
+ return subModels[0];
530
+ } else {
531
+ return subModels;
532
+ }
533
+ }
534
+ }
535
+ }
536
+ /**
537
+ * Load or create a model instance.
538
+ * @template T FlowModel subclass type, defaults to FlowModel.
539
+ * @param {any} options Load or create options
540
+ * @returns {Promise<T | null>} Model instance or null
541
+ */
542
+ async loadOrCreateModel(options, extra) {
543
+ if (!this.ensureModelRepository()) return;
544
+ const { uid, parentId, subKey } = options;
545
+ if (uid && this._modelInstances.has(uid)) {
546
+ return this._modelInstances.get(uid);
547
+ }
548
+ const m = this.findModelByParentId(parentId, subKey);
549
+ if (m) {
550
+ return m;
551
+ }
552
+ const data = await this._modelRepository.findOne(options);
553
+ let model = null;
554
+ if (data == null ? void 0 : data.uid) {
555
+ model = this.createModel(data, extra);
556
+ } else {
557
+ model = this.createModel(options, extra);
558
+ await model.save();
559
+ }
560
+ if (model.parent) {
561
+ const subModel = model.parent.findSubModel(model.subKey, (m2) => {
562
+ return m2.uid === model.uid;
563
+ });
564
+ if (subModel) {
565
+ return model;
566
+ }
567
+ if (model.subType === "array") {
568
+ model.parent.addSubModel(model.subKey, model);
569
+ } else {
570
+ model.parent.setSubModel(model.subKey, model);
571
+ }
572
+ }
573
+ return model;
574
+ }
575
+ /**
576
+ * Persist and save a model instance.
577
+ * Prevents concurrent saves of the same model by tracking save operations.
578
+ * If a model is already being saved, subsequent calls will wait for the existing save to complete.
579
+ *
580
+ * @template T FlowModel subclass type, defaults to FlowModel.
581
+ * @param {T} model Model instance to save
582
+ * @param {object} [options] Save options
583
+ * @param {boolean} [options.onlyStepParams] Whether to save only step parameters
584
+ * @returns {Promise<any>} Repository save result
585
+ */
586
+ async saveModel(model, options) {
587
+ if (!this.ensureModelRepository()) return;
588
+ const modelUid = model.uid;
589
+ if (this._savingModels.has(modelUid)) {
590
+ this.logger.debug(`Model ${modelUid} is already being saved, waiting for existing save operation`);
591
+ return await this._savingModels.get(modelUid);
592
+ }
593
+ const savePromise = this._performModelSave(model, options);
594
+ this._savingModels.set(modelUid, savePromise);
595
+ try {
596
+ const result = await savePromise;
597
+ return result;
598
+ } finally {
599
+ this._savingModels.delete(modelUid);
600
+ }
601
+ }
602
+ /**
603
+ * Perform the actual model save operation.
604
+ * @template T FlowModel subclass type, defaults to FlowModel.
605
+ * @param {T} model Model instance to save
606
+ * @param {object} [options] Save options
607
+ * @returns {Promise<any>} Repository save result
608
+ * @private
609
+ */
610
+ async _performModelSave(model, options) {
611
+ this.logger.debug(`Starting save operation for model ${model.uid}`);
612
+ try {
613
+ const result = await this._modelRepository.save(model, options);
614
+ this.logger.debug(`Successfully saved model ${model.uid}`);
615
+ return result;
616
+ } catch (error) {
617
+ this.logger.error(`Failed to save model ${model.uid}:`, error);
618
+ throw error;
619
+ }
620
+ }
621
+ /**
622
+ * Destroy a model instance (persistently delete and remove local instance).
623
+ * @param {string} uid UID of the model to destroy
624
+ * @returns {Promise<boolean>} Whether destroyed successfully
625
+ */
626
+ async destroyModel(uid) {
627
+ if (this.ensureModelRepository()) {
628
+ await this._modelRepository.destroy(uid);
629
+ }
630
+ return this.removeModel(uid);
631
+ }
632
+ /**
633
+ * Replace a model instance with a new instance of a class.
634
+ * @template T New model type
635
+ * @param {string} uid UID of the model to replace
636
+ * @param {Partial<FlowModelOptions> | ((oldModel: FlowModel) => Partial<FlowModelOptions>)} [optionsOrFn]
637
+ * Options for creating the new model, supports two forms:
638
+ * 1. Pass options directly
639
+ * 2. Pass a function that receives current options and returns new options
640
+ * @returns {Promise<T | null>} Newly created model instance
641
+ */
642
+ async replaceModel(uid, optionsOrFn) {
643
+ var _a;
644
+ const oldModel = this.getModel(uid);
645
+ if (!oldModel) {
646
+ console.warn(`FlowEngine: Cannot replace model. Model with UID '${uid}' not found.`);
647
+ return null;
648
+ }
649
+ const currentParent = oldModel.parent;
650
+ const currentSubKey = oldModel.subKey;
651
+ const currentSubType = oldModel.subType;
652
+ const currentOptions = oldModel.serialize();
653
+ let userOptions;
654
+ if (typeof optionsOrFn === "function") {
655
+ userOptions = optionsOrFn(oldModel);
656
+ } else {
657
+ userOptions = optionsOrFn || {};
658
+ }
659
+ const newOptions = {
660
+ ...import_lodash.default.omit(currentOptions, ["subModels"]),
661
+ ...userOptions
662
+ };
663
+ if (currentParent) {
664
+ currentParent.emitter.setPaused(true);
665
+ }
666
+ await oldModel.destroy();
667
+ const newModel = this.createModel(newOptions);
668
+ if (currentParent && currentSubKey) {
669
+ if (currentSubType === "array") {
670
+ currentParent.addSubModel(currentSubKey, newModel);
671
+ } else {
672
+ currentParent.setSubModel(currentSubKey, newModel);
673
+ }
674
+ }
675
+ if (currentParent) {
676
+ currentParent.emitter.setPaused(false);
677
+ currentParent.parent.invalidateAutoFlowCache(true);
678
+ (_a = currentParent.parent) == null ? void 0 : _a.rerender();
679
+ currentParent.emitter.emit("onSubModelReplaced", { oldModel, newModel });
680
+ }
681
+ await newModel.save();
682
+ return newModel;
683
+ }
684
+ /**
685
+ * Move a model instance within its parent model.
686
+ * @param {any} sourceId Source model UID
687
+ * @param {any} targetId Target model UID
688
+ * @returns {Promise<void>} No return value
689
+ */
690
+ async moveModel(sourceId, targetId, options) {
691
+ const sourceModel = this.getModel(sourceId);
692
+ const targetModel = this.getModel(targetId);
693
+ if (!sourceModel || !targetModel) {
694
+ console.warn(`FlowEngine: Cannot move model. Source or target model not found.`);
695
+ return;
696
+ }
697
+ const move = /* @__PURE__ */ __name((sourceModel2, targetModel2) => {
698
+ if (!sourceModel2.parent || !targetModel2.parent || sourceModel2.parent !== targetModel2.parent) {
699
+ console.error("FlowModel.moveTo: Both models must have the same parent to perform move operation.");
700
+ return false;
701
+ }
702
+ const subModels = sourceModel2.parent.subModels[sourceModel2.subKey];
703
+ if (!subModels || !Array.isArray(subModels)) {
704
+ console.error("FlowModel.moveTo: Parent subModels must be an array to perform move operation.");
705
+ return false;
706
+ }
707
+ const findIndex = /* @__PURE__ */ __name((model) => subModels.findIndex((item) => item.uid === model.uid), "findIndex");
708
+ const currentIndex = findIndex(sourceModel2);
709
+ const targetIndex = findIndex(targetModel2);
710
+ if (currentIndex === -1 || targetIndex === -1) {
711
+ console.error("FlowModel.moveTo: Current or target model not found in parent subModels.");
712
+ return false;
713
+ }
714
+ if (currentIndex === targetIndex) {
715
+ console.warn("FlowModel.moveTo: Current model is already at the target position. No action taken.");
716
+ return false;
717
+ }
718
+ const [movedModel] = subModels.splice(currentIndex, 1);
719
+ subModels.splice(targetIndex, 0, movedModel);
720
+ subModels.forEach((model, index) => {
721
+ model.sortIndex = index;
722
+ });
723
+ return true;
724
+ }, "move");
725
+ move(sourceModel, targetModel);
726
+ if ((options == null ? void 0 : options.persist) !== false && this.ensureModelRepository()) {
727
+ const position = sourceModel.sortIndex - targetModel.sortIndex > 0 ? "after" : "before";
728
+ await this._modelRepository.move(sourceId, targetId, position);
729
+ }
730
+ sourceModel.parent.emitter.emit("onSubModelMoved", { source: sourceModel, target: targetModel });
731
+ }
732
+ /**
733
+ * Filter model classes by parent class (supports multi-level inheritance).
734
+ * @param {string | ModelConstructor} parentClass Parent class name or constructor
735
+ * @returns {Map<string, ModelConstructor>} Model classes inherited from the specified parent class
736
+ */
737
+ filterModelClassByParent(parentClass) {
738
+ const parentModelClass = typeof parentClass === "string" ? this.getModelClass(parentClass) : parentClass;
739
+ if (!parentModelClass) {
740
+ return /* @__PURE__ */ new Map();
741
+ }
742
+ const modelClasses = /* @__PURE__ */ new Map();
743
+ for (const [className, ModelClass] of this._modelClasses) {
744
+ if ((0, import_utils.isInheritedFrom)(ModelClass, parentModelClass)) {
745
+ modelClasses.set(className, ModelClass);
746
+ }
747
+ }
748
+ return modelClasses;
749
+ }
750
+ /**
751
+ * Generate a unique key for the flow application cache.
752
+ * @param {string} prefix Prefix
753
+ * @param {string} flowKey Flow key
754
+ * @param {string} modelUid Model UID
755
+ * @returns {string} Unique cache key
756
+ * @internal
757
+ */
758
+ static generateApplyFlowCacheKey(prefix, flowKey, modelUid) {
759
+ return `${prefix}:${flowKey}:${modelUid}`;
760
+ }
761
+ };
762
+ _FlowEngine_instances = new WeakSet();
763
+ /**
764
+ * Register a single model class.
765
+ * @param {string} name Model class name
766
+ * @param {ModelConstructor} modelClass Model class constructor
767
+ * @private
768
+ */
769
+ registerModel_fn = /* @__PURE__ */ __name(function(name, modelClass) {
770
+ if (this._modelClasses.has(name)) {
771
+ console.warn(`FlowEngine: Model class with name '${name}' is already registered and will be overwritten.`);
772
+ }
773
+ Object.defineProperty(modelClass, "name", { value: name });
774
+ this._modelClasses.set(name, modelClass);
775
+ }, "#registerModel");
776
+ __name(_FlowEngine, "FlowEngine");
777
+ let FlowEngine = _FlowEngine;
778
+ // Annotate the CommonJS export names for ESM import in node:
779
+ 0 && (module.exports = {
780
+ FlowEngine
781
+ });