@nocobase/flow-engine 2.0.0-beta.9 → 2.0.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 (245) hide show
  1. package/lib/BlockScopedFlowEngine.js +0 -1
  2. package/lib/FlowDefinition.d.ts +2 -0
  3. package/lib/JSRunner.d.ts +6 -0
  4. package/lib/JSRunner.js +32 -2
  5. package/lib/ViewScopedFlowEngine.js +3 -0
  6. package/lib/acl/Acl.js +13 -3
  7. package/lib/components/FlowContextSelector.js +155 -10
  8. package/lib/components/settings/wrappers/component/SwitchWithTitle.js +2 -1
  9. package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +76 -15
  10. package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +24 -4
  11. package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +5 -1
  12. package/lib/components/variables/VariableInput.js +9 -4
  13. package/lib/components/variables/VariableTag.js +46 -39
  14. package/lib/components/variables/utils.d.ts +7 -0
  15. package/lib/components/variables/utils.js +42 -2
  16. package/lib/data-source/index.d.ts +7 -27
  17. package/lib/data-source/index.js +81 -51
  18. package/lib/executor/FlowExecutor.d.ts +2 -1
  19. package/lib/executor/FlowExecutor.js +163 -22
  20. package/lib/flowContext.d.ts +230 -7
  21. package/lib/flowContext.js +2267 -148
  22. package/lib/flowEngine.d.ts +21 -0
  23. package/lib/flowEngine.js +56 -8
  24. package/lib/flowI18n.js +6 -4
  25. package/lib/flowSettings.js +17 -11
  26. package/lib/index.d.ts +7 -1
  27. package/lib/index.js +21 -0
  28. package/lib/locale/en-US.json +9 -2
  29. package/lib/locale/index.d.ts +14 -0
  30. package/lib/locale/zh-CN.json +8 -1
  31. package/lib/models/CollectionFieldModel.d.ts +1 -0
  32. package/lib/models/CollectionFieldModel.js +3 -2
  33. package/lib/models/flowModel.js +12 -1
  34. package/lib/provider.js +5 -5
  35. package/lib/resources/baseRecordResource.d.ts +5 -0
  36. package/lib/resources/baseRecordResource.js +24 -0
  37. package/lib/resources/multiRecordResource.d.ts +1 -0
  38. package/lib/resources/multiRecordResource.js +11 -4
  39. package/lib/resources/singleRecordResource.js +2 -0
  40. package/lib/resources/sqlResource.d.ts +4 -3
  41. package/lib/resources/sqlResource.js +8 -3
  42. package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +12 -2
  43. package/lib/runjs-context/contexts/JSBlockRunJSContext.js +2 -2
  44. package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.d.ts +16 -0
  45. package/lib/runjs-context/contexts/JSEditableFieldRunJSContext.js +125 -0
  46. package/lib/runjs-context/contexts/JSItemRunJSContext.js +12 -2
  47. package/lib/runjs-context/contexts/base.js +706 -41
  48. package/lib/runjs-context/contributions.d.ts +33 -0
  49. package/lib/runjs-context/contributions.js +88 -0
  50. package/lib/runjs-context/helpers.js +12 -1
  51. package/lib/runjs-context/setup.js +6 -0
  52. package/lib/runjs-context/snippets/global/api-request.snippet.js +3 -3
  53. package/lib/runjs-context/snippets/global/import-esm.snippet.js +2 -3
  54. package/lib/runjs-context/snippets/global/query-selector.snippet.js +8 -3
  55. package/lib/runjs-context/snippets/global/require-amd.snippet.js +1 -1
  56. package/lib/runjs-context/snippets/index.d.ts +11 -1
  57. package/lib/runjs-context/snippets/index.js +61 -40
  58. package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +10 -7
  59. package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +3 -3
  60. package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +2 -2
  61. package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +2 -2
  62. package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +2 -2
  63. package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +1 -1
  64. package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +1 -1
  65. package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +1 -1
  66. package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +5 -5
  67. package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +6 -6
  68. package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +3 -4
  69. package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +1 -1
  70. package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +20 -3
  71. package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +1 -1
  72. package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +1 -1
  73. package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +3 -3
  74. package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +3 -3
  75. package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +2 -2
  76. package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +1 -1
  77. package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +2 -2
  78. package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +6 -3
  79. package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +3 -1
  80. package/lib/runjsLibs.d.ts +28 -0
  81. package/lib/runjsLibs.js +532 -0
  82. package/lib/scheduler/ModelOperationScheduler.d.ts +2 -0
  83. package/lib/scheduler/ModelOperationScheduler.js +25 -21
  84. package/lib/types.d.ts +27 -0
  85. package/lib/utils/associationObjectVariable.d.ts +2 -2
  86. package/lib/utils/createCollectionContextMeta.js +1 -0
  87. package/lib/utils/createEphemeralContext.js +2 -2
  88. package/lib/utils/dateVariable.d.ts +16 -0
  89. package/lib/utils/dateVariable.js +380 -0
  90. package/lib/utils/exceptions.d.ts +7 -0
  91. package/lib/utils/exceptions.js +10 -0
  92. package/lib/utils/index.d.ts +8 -3
  93. package/lib/utils/index.js +45 -0
  94. package/lib/utils/params-resolvers.js +16 -9
  95. package/lib/utils/resolveModuleUrl.d.ts +58 -0
  96. package/lib/utils/resolveModuleUrl.js +65 -0
  97. package/lib/utils/resolveRunJSObjectValues.d.ts +16 -0
  98. package/lib/utils/resolveRunJSObjectValues.js +61 -0
  99. package/lib/utils/runjsModuleLoader.d.ts +58 -0
  100. package/lib/utils/runjsModuleLoader.js +422 -0
  101. package/lib/utils/runjsTemplateCompat.d.ts +35 -0
  102. package/lib/utils/runjsTemplateCompat.js +743 -0
  103. package/lib/utils/runjsValue.d.ts +29 -0
  104. package/lib/utils/runjsValue.js +275 -0
  105. package/lib/utils/safeGlobals.d.ts +18 -8
  106. package/lib/utils/safeGlobals.js +164 -17
  107. package/lib/utils/schema-utils.d.ts +10 -0
  108. package/lib/utils/schema-utils.js +61 -0
  109. package/lib/views/createViewMeta.d.ts +0 -7
  110. package/lib/views/createViewMeta.js +19 -70
  111. package/lib/views/index.d.ts +1 -2
  112. package/lib/views/index.js +4 -3
  113. package/lib/views/useDialog.js +7 -2
  114. package/lib/views/useDrawer.js +7 -2
  115. package/lib/views/usePage.d.ts +4 -0
  116. package/lib/views/usePage.js +43 -6
  117. package/lib/views/usePopover.js +4 -1
  118. package/lib/views/viewEvents.d.ts +17 -0
  119. package/lib/views/viewEvents.js +90 -0
  120. package/package.json +4 -4
  121. package/src/BlockScopedFlowEngine.ts +2 -5
  122. package/src/JSRunner.ts +44 -2
  123. package/src/ViewScopedFlowEngine.ts +4 -0
  124. package/src/__tests__/JSRunner.test.ts +64 -0
  125. package/src/__tests__/createViewMeta.popup.test.ts +62 -1
  126. package/src/__tests__/flowContext.test.ts +693 -1
  127. package/src/__tests__/flowEngine.dataSourceDirty.test.ts +63 -0
  128. package/src/__tests__/flowModel.openView.navigation.test.ts +28 -0
  129. package/src/__tests__/flowRunJSContextDefine.test.ts +63 -0
  130. package/src/__tests__/flowRuntimeContext.test.ts +2 -1
  131. package/src/__tests__/flowSettings.open.test.tsx +123 -19
  132. package/src/__tests__/runjsContext.test.ts +10 -7
  133. package/src/__tests__/runjsContextImplementations.test.ts +34 -3
  134. package/src/__tests__/runjsContextRuntime.test.ts +3 -3
  135. package/src/__tests__/runjsContributions.test.ts +89 -0
  136. package/src/__tests__/runjsExternalLibs.test.ts +242 -0
  137. package/src/__tests__/runjsLibsLazyLoading.test.ts +44 -0
  138. package/src/__tests__/runjsLocales.test.ts +4 -1
  139. package/src/__tests__/runjsPreprocessDefault.test.ts +49 -0
  140. package/src/__tests__/runjsRuntimeFeatures.test.ts +166 -0
  141. package/src/__tests__/runjsSnippets.test.ts +40 -3
  142. package/src/acl/Acl.tsx +3 -3
  143. package/src/components/FlowContextSelector.tsx +208 -12
  144. package/src/components/settings/wrappers/component/SwitchWithTitle.tsx +2 -1
  145. package/src/components/settings/wrappers/component/__tests__/InlineControls.test.tsx +74 -0
  146. package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +109 -16
  147. package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +41 -7
  148. package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +13 -2
  149. package/src/components/settings/wrappers/contextual/__tests__/DefaultSettingsIcon.test.tsx +157 -5
  150. package/src/components/variables/VariableInput.tsx +12 -4
  151. package/src/components/variables/VariableTag.tsx +54 -45
  152. package/src/components/variables/__tests__/FlowContextSelector.test.tsx +260 -3
  153. package/src/components/variables/__tests__/VariableTag.test.tsx +50 -0
  154. package/src/components/variables/__tests__/utils.test.ts +81 -3
  155. package/src/components/variables/utils.ts +67 -6
  156. package/src/data-source/index.ts +85 -110
  157. package/src/executor/FlowExecutor.ts +200 -23
  158. package/src/executor/__tests__/flowExecutor.test.ts +66 -0
  159. package/src/flowContext.ts +2986 -211
  160. package/src/flowEngine.ts +59 -8
  161. package/src/flowI18n.ts +7 -5
  162. package/src/flowSettings.ts +18 -12
  163. package/src/index.ts +14 -1
  164. package/src/locale/en-US.json +9 -2
  165. package/src/locale/zh-CN.json +8 -1
  166. package/src/models/CollectionFieldModel.tsx +3 -1
  167. package/src/models/__tests__/dispatchEvent.when.test.ts +554 -0
  168. package/src/models/__tests__/flowModel.test.ts +20 -4
  169. package/src/models/flowModel.tsx +13 -1
  170. package/src/provider.tsx +7 -6
  171. package/src/resources/__tests__/multiRecordResource.test.ts +44 -0
  172. package/src/resources/__tests__/sqlResource.test.ts +60 -0
  173. package/src/resources/baseRecordResource.ts +31 -0
  174. package/src/resources/multiRecordResource.ts +11 -4
  175. package/src/resources/singleRecordResource.ts +3 -0
  176. package/src/resources/sqlResource.ts +11 -6
  177. package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +10 -0
  178. package/src/runjs-context/contexts/JSBlockRunJSContext.ts +6 -2
  179. package/src/runjs-context/contexts/JSEditableFieldRunJSContext.ts +106 -0
  180. package/src/runjs-context/contexts/JSItemRunJSContext.ts +10 -0
  181. package/src/runjs-context/contexts/base.ts +715 -44
  182. package/src/runjs-context/contributions.ts +88 -0
  183. package/src/runjs-context/helpers.ts +11 -1
  184. package/src/runjs-context/setup.ts +6 -0
  185. package/src/runjs-context/snippets/global/api-request.snippet.ts +3 -3
  186. package/src/runjs-context/snippets/global/import-esm.snippet.ts +2 -3
  187. package/src/runjs-context/snippets/global/query-selector.snippet.ts +8 -3
  188. package/src/runjs-context/snippets/global/require-amd.snippet.ts +1 -1
  189. package/src/runjs-context/snippets/index.ts +75 -41
  190. package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +11 -13
  191. package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +3 -3
  192. package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +2 -2
  193. package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +2 -2
  194. package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +2 -2
  195. package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +1 -1
  196. package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +1 -1
  197. package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +1 -1
  198. package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +6 -11
  199. package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +6 -6
  200. package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +3 -4
  201. package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +1 -1
  202. package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +20 -3
  203. package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +1 -1
  204. package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +1 -1
  205. package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +3 -3
  206. package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +3 -3
  207. package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +2 -2
  208. package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +1 -1
  209. package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +3 -8
  210. package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +6 -3
  211. package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +3 -1
  212. package/src/runjsLibs.ts +622 -0
  213. package/src/scheduler/ModelOperationScheduler.ts +27 -21
  214. package/src/types.ts +38 -1
  215. package/src/utils/__tests__/dateVariable.test.ts +101 -0
  216. package/src/utils/__tests__/params-resolvers.test.ts +40 -0
  217. package/src/utils/__tests__/runjsRequireAsyncAutoWhitelist.test.ts +38 -0
  218. package/src/utils/__tests__/runjsTemplateCompat.test.ts +159 -0
  219. package/src/utils/__tests__/runjsValue.test.ts +44 -0
  220. package/src/utils/__tests__/safeGlobals.test.ts +57 -2
  221. package/src/utils/__tests__/utils.test.ts +95 -0
  222. package/src/utils/associationObjectVariable.ts +2 -2
  223. package/src/utils/createCollectionContextMeta.ts +1 -0
  224. package/src/utils/createEphemeralContext.ts +5 -4
  225. package/src/utils/dateVariable.ts +397 -0
  226. package/src/utils/exceptions.ts +11 -0
  227. package/src/utils/index.ts +37 -3
  228. package/src/utils/params-resolvers.ts +23 -9
  229. package/src/utils/resolveModuleUrl.ts +91 -0
  230. package/src/utils/resolveRunJSObjectValues.ts +46 -0
  231. package/src/utils/runjsModuleLoader.ts +553 -0
  232. package/src/utils/runjsTemplateCompat.ts +828 -0
  233. package/src/utils/runjsValue.ts +287 -0
  234. package/src/utils/safeGlobals.ts +188 -17
  235. package/src/utils/schema-utils.ts +79 -0
  236. package/src/views/__tests__/FlowView.usePage.test.tsx +54 -1
  237. package/src/views/__tests__/useDialog.closeDestroy.test.tsx +35 -8
  238. package/src/views/__tests__/viewEvents.resolveOpenerEngine.test.ts +28 -0
  239. package/src/views/createViewMeta.ts +22 -75
  240. package/src/views/index.tsx +1 -2
  241. package/src/views/useDialog.tsx +8 -1
  242. package/src/views/useDrawer.tsx +8 -1
  243. package/src/views/usePage.tsx +51 -5
  244. package/src/views/usePopover.tsx +4 -1
  245. package/src/views/viewEvents.ts +55 -0
@@ -51,6 +51,10 @@ const _FlowExecutor = class _FlowExecutor {
51
51
  constructor(engine) {
52
52
  this.engine = engine;
53
53
  }
54
+ async emitModelEventIf(eventName, topic, payload) {
55
+ if (!eventName) return;
56
+ await this.engine.emitter.emitAsync(`model:event:${eventName}:${topic}`, payload);
57
+ }
54
58
  /** Cache wrapper for applyFlow cache lifecycle */
55
59
  async withApplyFlowCache(cacheKey, executor) {
56
60
  if (!cacheKey || !this.engine) return await executor();
@@ -81,7 +85,7 @@ const _FlowExecutor = class _FlowExecutor {
81
85
  /**
82
86
  * Execute a single flow on model.
83
87
  */
84
- async runFlow(model, flowKey, inputArgs, runId) {
88
+ async runFlow(model, flowKey, inputArgs, runId, eventName) {
85
89
  var _a;
86
90
  const flow = model.getFlow(flowKey);
87
91
  if (!flow) {
@@ -113,6 +117,14 @@ const _FlowExecutor = class _FlowExecutor {
113
117
  const stepDefs = eventStep ? { eventStep, ...flow.steps } : flow.steps;
114
118
  (0, import_setupRuntimeContextSteps.setupRuntimeContextSteps)(flowContext, stepDefs, model, flowKey);
115
119
  const stepsRuntime = flowContext.steps;
120
+ const flowEventBasePayload = {
121
+ uid: model.uid,
122
+ model,
123
+ runId: flowContext.runId,
124
+ inputArgs,
125
+ flowKey
126
+ };
127
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:start`, flowEventBasePayload);
116
128
  for (const [stepKey, step] of Object.entries(stepDefs)) {
117
129
  let handler;
118
130
  let combinedParams = {};
@@ -163,20 +175,56 @@ const _FlowExecutor = class _FlowExecutor {
163
175
  );
164
176
  continue;
165
177
  }
178
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:step:${stepKey}:start`, {
179
+ ...flowEventBasePayload,
180
+ stepKey
181
+ });
166
182
  const currentStepResult = handler(runtimeCtx, combinedParams);
167
183
  const isAwait = step.isAwait !== false;
168
184
  lastResult = isAwait ? await currentStepResult : currentStepResult;
169
185
  stepResults[stepKey] = lastResult;
170
186
  stepsRuntime[stepKey].result = stepResults[stepKey];
187
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:step:${stepKey}:end`, {
188
+ ...flowEventBasePayload,
189
+ result: lastResult,
190
+ stepKey
191
+ });
171
192
  } catch (error) {
193
+ if (!(error instanceof import_utils.FlowExitException) && !(error instanceof import_exceptions.FlowExitAllException)) {
194
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:step:${stepKey}:error`, {
195
+ ...flowEventBasePayload,
196
+ error,
197
+ stepKey
198
+ });
199
+ }
172
200
  if (error instanceof import_utils.FlowExitException) {
173
201
  flowContext.logger.info(`[FlowEngine] ${error.message}`);
202
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:step:${stepKey}:end`, {
203
+ ...flowEventBasePayload,
204
+ stepKey
205
+ });
206
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:end`, {
207
+ ...flowEventBasePayload,
208
+ result: stepResults
209
+ });
174
210
  return Promise.resolve(stepResults);
175
211
  }
176
212
  if (error instanceof import_exceptions.FlowExitAllException) {
177
213
  flowContext.logger.info(`[FlowEngine] ${error.message}`);
214
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:step:${stepKey}:end`, {
215
+ ...flowEventBasePayload,
216
+ stepKey
217
+ });
218
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:end`, {
219
+ ...flowEventBasePayload,
220
+ result: error
221
+ });
178
222
  return Promise.resolve(error);
179
223
  }
224
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:error`, {
225
+ ...flowEventBasePayload,
226
+ error
227
+ });
180
228
  flowContext.logger.error(
181
229
  { err: error },
182
230
  `BaseModel.applyFlow: Error executing step '${stepKey}' in flow '${flowKey}':`
@@ -184,9 +232,12 @@ const _FlowExecutor = class _FlowExecutor {
184
232
  return Promise.reject(error);
185
233
  }
186
234
  }
235
+ await this.emitModelEventIf(eventName, `flow:${flowKey}:end`, {
236
+ ...flowEventBasePayload,
237
+ result: stepResults
238
+ });
187
239
  return Promise.resolve(stepResults);
188
240
  }
189
- // runAutoFlows 已移除:统一通过 dispatchEvent('beforeRender') + useCache 控制
190
241
  /**
191
242
  * Dispatch an event to flows bound via flow.on and execute them.
192
243
  */
@@ -198,13 +249,14 @@ const _FlowExecutor = class _FlowExecutor {
198
249
  const throwOnError = isBeforeRender;
199
250
  const runId = `${model.uid}-${eventName}-${Date.now()}`;
200
251
  const logger = model.context.logger;
252
+ const eventBasePayload = {
253
+ uid: model.uid,
254
+ model,
255
+ runId,
256
+ inputArgs
257
+ };
201
258
  try {
202
- await this.engine.emitter.emitAsync(`model:event:${eventName}:start`, {
203
- uid: model.uid,
204
- model,
205
- runId,
206
- inputArgs
207
- });
259
+ await this.emitModelEventIf(eventName, "start", eventBasePayload);
208
260
  await ((_a = model.onDispatchEventStart) == null ? void 0 : _a.call(model, eventName, options, inputArgs));
209
261
  } catch (err) {
210
262
  if (isBeforeRender && err instanceof import_utils.FlowExitException) {
@@ -226,9 +278,17 @@ const _FlowExecutor = class _FlowExecutor {
226
278
  if (typeof on === "object") return on.eventName === eventName;
227
279
  return false;
228
280
  });
281
+ const isRouterReplayClick = eventName === "click" && (inputArgs == null ? void 0 : inputArgs.triggerByRouter) === true;
282
+ const flowsToRun = isRouterReplayClick ? flows.filter((flow) => {
283
+ var _a2;
284
+ const reg = flow["flowRegistry"];
285
+ const type = (_a2 = reg == null ? void 0 : reg.constructor) == null ? void 0 : _a2._type;
286
+ return type !== "instance";
287
+ }) : flows;
288
+ const scheduledCancels = [];
229
289
  const execute = /* @__PURE__ */ __name(async () => {
230
290
  if (sequential) {
231
- const flowsWithIndex = flows.map((f, i) => ({ f, i }));
291
+ const flowsWithIndex = flowsToRun.map((f, i) => ({ f, i }));
232
292
  const ordered = flowsWithIndex.slice().sort((a, b) => {
233
293
  var _a2, _b2;
234
294
  const regA = a.f["flowRegistry"];
@@ -244,18 +304,101 @@ const _FlowExecutor = class _FlowExecutor {
244
304
  return a.i - b.i;
245
305
  }).map((x) => x.f);
246
306
  const results2 = [];
307
+ const staticFlowsByKey = new Map(
308
+ ordered.filter((f) => {
309
+ var _a2;
310
+ const reg = f["flowRegistry"];
311
+ const type = (_a2 = reg == null ? void 0 : reg.constructor) == null ? void 0 : _a2._type;
312
+ return type !== "instance";
313
+ }).map((f) => [f.key, f])
314
+ );
315
+ const scheduled = /* @__PURE__ */ new Set();
316
+ const scheduleGroups = /* @__PURE__ */ new Map();
317
+ ordered.forEach((flow, indexInOrdered) => {
318
+ var _a2;
319
+ const on = flow.on;
320
+ const onObj = typeof on === "object" ? on : void 0;
321
+ if (!onObj) return;
322
+ const phase = onObj.phase;
323
+ const flowKey = onObj.flowKey;
324
+ const stepKey = onObj.stepKey;
325
+ if (!phase || phase === "beforeAllFlows") return;
326
+ let whenKey = null;
327
+ if (phase === "afterAllFlows") {
328
+ whenKey = `event:${eventName}:end`;
329
+ } else if (phase === "beforeFlow" || phase === "afterFlow") {
330
+ if (!flowKey) {
331
+ whenKey = `event:${eventName}:end`;
332
+ } else {
333
+ const anchorFlow = staticFlowsByKey.get(String(flowKey));
334
+ if (anchorFlow) {
335
+ const anchorPhase = phase === "beforeFlow" ? "start" : "end";
336
+ whenKey = `event:${eventName}:flow:${String(flowKey)}:${anchorPhase}`;
337
+ } else {
338
+ whenKey = `event:${eventName}:end`;
339
+ }
340
+ }
341
+ } else if (phase === "beforeStep" || phase === "afterStep") {
342
+ if (!flowKey || !stepKey) {
343
+ whenKey = `event:${eventName}:end`;
344
+ } else {
345
+ const anchorFlow = staticFlowsByKey.get(String(flowKey));
346
+ const anchorStepExists = !!((_a2 = anchorFlow == null ? void 0 : anchorFlow.hasStep) == null ? void 0 : _a2.call(anchorFlow, String(stepKey)));
347
+ if (anchorFlow && anchorStepExists) {
348
+ const anchorPhase = phase === "beforeStep" ? "start" : "end";
349
+ whenKey = `event:${eventName}:flow:${String(flowKey)}:step:${String(stepKey)}:${anchorPhase}`;
350
+ } else {
351
+ whenKey = `event:${eventName}:end`;
352
+ }
353
+ }
354
+ } else {
355
+ return;
356
+ }
357
+ if (!whenKey) return;
358
+ scheduled.add(flow.key);
359
+ const list = scheduleGroups.get(whenKey) || [];
360
+ list.push({ flow, order: indexInOrdered });
361
+ scheduleGroups.set(whenKey, list);
362
+ });
363
+ for (const [whenKey, list] of scheduleGroups.entries()) {
364
+ const sorted = list.slice().sort((a, b) => {
365
+ const sa = a.flow.sort ?? 0;
366
+ const sb = b.flow.sort ?? 0;
367
+ if (sa !== sb) return sa - sb;
368
+ return a.order - b.order;
369
+ });
370
+ for (const it of sorted) {
371
+ const cancel = model.scheduleModelOperation(
372
+ model.uid,
373
+ async (m) => {
374
+ const res = await this.runFlow(m, it.flow.key, inputArgs, runId, eventName);
375
+ if (res instanceof import_exceptions.FlowExitAllException) {
376
+ throw res;
377
+ }
378
+ results2.push(res);
379
+ },
380
+ { when: whenKey }
381
+ );
382
+ scheduledCancels.push(cancel);
383
+ }
384
+ }
247
385
  for (const flow of ordered) {
386
+ if (scheduled.has(flow.key)) continue;
248
387
  try {
249
388
  logger.debug(
250
389
  `BaseModel '${model.uid}' dispatching event '${eventName}' to flow '${flow.key}' (sequential).`
251
390
  );
252
- const result = await this.runFlow(model, flow.key, inputArgs, runId);
391
+ const result = await this.runFlow(model, flow.key, inputArgs, runId, eventName);
253
392
  if (result instanceof import_exceptions.FlowExitAllException) {
254
393
  logger.debug(`[FlowEngine.dispatchEvent] ${result.message}`);
255
394
  break;
256
395
  }
257
396
  results2.push(result);
258
397
  } catch (error) {
398
+ if (error instanceof import_exceptions.FlowExitAllException) {
399
+ logger.debug(`[FlowEngine.dispatchEvent] ${error.message}`);
400
+ break;
401
+ }
259
402
  logger.error(
260
403
  { err: error },
261
404
  `BaseModel.dispatchEvent: Error executing event-triggered flow '${flow.key}' for event '${eventName}' (sequential):`
@@ -266,10 +409,10 @@ const _FlowExecutor = class _FlowExecutor {
266
409
  return results2;
267
410
  }
268
411
  const results = await Promise.all(
269
- flows.map(async (flow) => {
412
+ flowsToRun.map(async (flow) => {
270
413
  logger.debug(`BaseModel '${model.uid}' dispatching event '${eventName}' to flow '${flow.key}'.`);
271
414
  try {
272
- return await this.runFlow(model, flow.key, inputArgs, runId);
415
+ return await this.runFlow(model, flow.key, inputArgs, runId, eventName);
273
416
  } catch (error) {
274
417
  logger.error(
275
418
  { err: error },
@@ -295,11 +438,8 @@ const _FlowExecutor = class _FlowExecutor {
295
438
  } catch (hookErr) {
296
439
  logger.error({ err: hookErr }, `BaseModel.dispatchEvent: End hook error for event '${eventName}'`);
297
440
  }
298
- await this.engine.emitter.emitAsync(`model:event:${eventName}:end`, {
299
- uid: model.uid,
300
- model,
301
- runId,
302
- inputArgs,
441
+ await this.emitModelEventIf(eventName, "end", {
442
+ ...eventBasePayload,
303
443
  result
304
444
  });
305
445
  return result;
@@ -312,14 +452,15 @@ const _FlowExecutor = class _FlowExecutor {
312
452
  { err: error },
313
453
  `BaseModel.dispatchEvent: Error executing event '${eventName}' for model '${model.uid}':`
314
454
  );
315
- await this.engine.emitter.emitAsync(`model:event:${eventName}:error`, {
316
- uid: model.uid,
317
- model,
318
- runId,
319
- inputArgs,
455
+ await this.emitModelEventIf(eventName, "error", {
456
+ ...eventBasePayload,
320
457
  error
321
458
  });
322
459
  if (throwOnError) throw error;
460
+ } finally {
461
+ for (const cancel of scheduledCancels) {
462
+ cancel();
463
+ }
323
464
  }
324
465
  }
325
466
  };
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { ISchema } from '@formily/json-schema';
10
- import { APIClient } from '@nocobase/sdk';
10
+ import { APIClient, RequestOptions } from '@nocobase/sdk';
11
11
  import type { Router } from '@remix-run/router';
12
12
  import { MessageInstance } from 'antd/es/message/interface';
13
13
  import type { HookAPI } from 'antd/es/modal/useModal';
@@ -25,12 +25,51 @@ import type { ActionDefinition, EventDefinition, ResourceType } from './types';
25
25
  import { JSONValue } from './utils/params-resolvers';
26
26
  import type { RecordRef } from './utils/serverContextParams';
27
27
  import { FlowView, FlowViewer } from './views/FlowView';
28
+ import { type RunJSVersion } from './runjs-context/registry';
28
29
  type Getter<T = any> = (ctx: FlowContext) => T | Promise<T>;
30
+ export type FlowContextDocRef = string | {
31
+ url: string;
32
+ title?: string;
33
+ };
34
+ export type FlowDeprecationDoc = boolean | {
35
+ /**
36
+ * 废弃说明(面向人/大模型)。
37
+ */
38
+ message?: string;
39
+ /**
40
+ * 推荐替代 API(例如 'ctx.resolveJsonTemplate')。
41
+ */
42
+ replacedBy?: string | string[];
43
+ /**
44
+ * 开始废弃的版本号(可选)。
45
+ */
46
+ since?: string;
47
+ /**
48
+ * 预计移除的版本号(可选)。
49
+ */
50
+ removedIn?: string;
51
+ /**
52
+ * 参考链接(可选)。
53
+ */
54
+ ref?: FlowContextDocRef;
55
+ };
56
+ export type FlowContextDocParam = {
57
+ name: string;
58
+ description?: string;
59
+ type?: string;
60
+ optional?: boolean;
61
+ default?: JSONValue;
62
+ };
63
+ export type FlowContextDocReturn = {
64
+ description?: string;
65
+ type?: string;
66
+ };
29
67
  export interface MetaTreeNode {
30
68
  name: string;
31
69
  title: string;
32
70
  type: string;
33
71
  interface?: string;
72
+ options?: any;
34
73
  uiSchema?: ISchema;
35
74
  render?: (props: any) => JSX.Element;
36
75
  paths: string[];
@@ -44,13 +83,14 @@ export interface PropertyMeta {
44
83
  type: string;
45
84
  title: string;
46
85
  interface?: string;
86
+ options?: any;
47
87
  uiSchema?: ISchema;
48
88
  render?: (props: any) => JSX.Element;
49
89
  sort?: number;
50
90
  properties?: Record<string, PropertyMeta> | (() => Promise<Record<string, PropertyMeta>>);
51
- disabled?: boolean | (() => boolean);
52
- disabledReason?: string | (() => string | undefined);
53
- hidden?: boolean | (() => boolean);
91
+ disabled?: boolean | (() => boolean | Promise<boolean>);
92
+ disabledReason?: string | (() => string | undefined | Promise<string | undefined>);
93
+ hidden?: boolean | (() => boolean | Promise<boolean>);
54
94
  buildVariablesParams?: (ctx: FlowContext) => RecordRef | Record<string, any> | Promise<RecordRef | Record<string, any> | undefined> | undefined;
55
95
  }
56
96
  export type PropertyMetaFactory = {
@@ -73,9 +113,130 @@ export interface PropertyOptions {
73
113
  cache?: boolean;
74
114
  observable?: boolean;
75
115
  meta?: PropertyMetaOrFactory;
116
+ /**
117
+ * 面向工具/大模型的静态文档信息(不影响变量选择器 UI)。
118
+ * - `getApiInfos()` 仅使用 RunJS doc + 这里的 `info`(不会读取/展开 `meta`)
119
+ * - 变量结构信息请使用 `getVarInfos()`(来源于 `meta`)
120
+ */
121
+ info?: FlowContextPropertyInfoOrFactory;
76
122
  resolveOnServer?: boolean | ((subPath: string) => boolean);
77
123
  serverOnlyWhenContextParams?: boolean;
78
124
  }
125
+ export type FlowContextMethodInfoInput = {
126
+ description?: string;
127
+ detail?: string;
128
+ examples?: string[];
129
+ completion?: RunJSDocCompletionDoc;
130
+ ref?: FlowContextDocRef;
131
+ deprecated?: FlowDeprecationDoc;
132
+ params?: FlowContextDocParam[];
133
+ returns?: FlowContextDocReturn;
134
+ hidden?: boolean | ((ctx: any) => boolean | Promise<boolean>);
135
+ disabled?: boolean | ((ctx: any) => boolean | Promise<boolean>);
136
+ disabledReason?: string | ((ctx: any) => string | undefined | Promise<string | undefined>);
137
+ };
138
+ export type FlowContextMethodInfo = {
139
+ description?: string;
140
+ detail?: string;
141
+ examples?: string[];
142
+ completion?: RunJSDocCompletionDoc;
143
+ ref?: FlowContextDocRef;
144
+ deprecated?: FlowDeprecationDoc;
145
+ params?: FlowContextDocParam[];
146
+ returns?: FlowContextDocReturn;
147
+ disabled?: boolean;
148
+ disabledReason?: string;
149
+ };
150
+ export type FlowContextPropertyInfoObjectInput = Omit<FlowContextPropertyInfo, 'disabled' | 'disabledReason' | 'properties'> & {
151
+ properties?: Record<string, FlowContextPropertyInfoInput> | (() => Promise<Record<string, FlowContextPropertyInfoInput>>);
152
+ hidden?: RunJSDocHiddenOrPathsDoc;
153
+ disabled?: boolean | ((ctx: any) => boolean | Promise<boolean>);
154
+ disabledReason?: string | ((ctx: any) => string | undefined | Promise<string | undefined>);
155
+ };
156
+ export type FlowContextPropertyInfoInput = string | FlowContextPropertyInfoObjectInput;
157
+ export type FlowContextPropertyInfoFactory = {
158
+ (): FlowContextPropertyInfoInput | Promise<FlowContextPropertyInfoInput | null> | null;
159
+ };
160
+ export type FlowContextPropertyInfoOrFactory = FlowContextPropertyInfoInput | FlowContextPropertyInfoFactory;
161
+ export type FlowContextPropertyInfo = {
162
+ title?: string;
163
+ type?: string;
164
+ interface?: string;
165
+ description?: string;
166
+ detail?: string;
167
+ examples?: string[];
168
+ completion?: RunJSDocCompletionDoc;
169
+ ref?: FlowContextDocRef;
170
+ deprecated?: FlowDeprecationDoc;
171
+ params?: FlowContextDocParam[];
172
+ returns?: FlowContextDocReturn;
173
+ disabled?: boolean;
174
+ disabledReason?: string;
175
+ properties?: Record<string, FlowContextPropertyInfo>;
176
+ };
177
+ export type FlowContextApiInfo = {
178
+ title?: string;
179
+ type?: string;
180
+ interface?: string;
181
+ description?: string;
182
+ examples?: string[];
183
+ completion?: RunJSDocCompletionDoc;
184
+ ref?: FlowContextDocRef;
185
+ deprecated?: FlowDeprecationDoc;
186
+ params?: FlowContextDocParam[];
187
+ returns?: FlowContextDocReturn;
188
+ disabled?: boolean;
189
+ disabledReason?: string;
190
+ properties?: Record<string, FlowContextApiInfo>;
191
+ };
192
+ export type FlowContextInfosEnvNode = {
193
+ /**
194
+ * 说明(面向人/大模型)。建议为一句话。
195
+ */
196
+ description?: string;
197
+ /**
198
+ * 可用于 `await ctx.getVar(getVar)` 的表达式字符串,推荐以 `ctx.` 开头。
199
+ * 例如:'ctx.popup'、'ctx.resource.collectionName'
200
+ */
201
+ getVar?: string;
202
+ /**
203
+ * 已解析/可序列化的静态值(用于 prompt 直接使用)。
204
+ * 注意:应保持小体积,避免放入 record 等大对象。
205
+ */
206
+ value?: JSONValue;
207
+ /**
208
+ * 子节点(用于表达 popup.resource.xxx 等层级结构)。
209
+ */
210
+ properties?: Record<string, FlowContextInfosEnvNode>;
211
+ };
212
+ export type FlowContextInfosEnvs = {
213
+ popup?: FlowContextInfosEnvNode;
214
+ block?: FlowContextInfosEnvNode;
215
+ currentViewBlocks?: FlowContextInfosEnvNode;
216
+ flowModel?: FlowContextInfosEnvNode;
217
+ resource?: FlowContextInfosEnvNode;
218
+ record?: FlowContextInfosEnvNode;
219
+ };
220
+ export type FlowContextGetApiInfosOptions = {
221
+ /**
222
+ * RunJS 文档版本(默认 v1)。
223
+ */
224
+ version?: RunJSVersion;
225
+ };
226
+ export type FlowContextGetVarInfosOptions = {
227
+ /**
228
+ * 最大展开层级(默认 3)。
229
+ * - 当不传 path 时,top-level property depth=1。
230
+ * - 当传 path 时,path 对应节点 depth=1。
231
+ */
232
+ maxDepth?: number;
233
+ /**
234
+ * 剪裁:仅收集指定 path 下的变量结构信息。
235
+ * - string 形式支持:'record'、'record.id'、'ctx.record'、'{{ ctx.record }}'
236
+ * - string[] 表示多个剪裁路径合并
237
+ */
238
+ path?: string | string[];
239
+ };
79
240
  type RouteOptions = {
80
241
  name?: string;
81
242
  path?: string;
@@ -86,6 +247,7 @@ export declare class FlowContext {
86
247
  #private;
87
248
  _props: Record<string, PropertyOptions>;
88
249
  _methods: Record<string, (...args: any[]) => any>;
250
+ _methodInfos: Record<string, FlowContextMethodInfoInput>;
89
251
  protected _cache: Record<string, any>;
90
252
  protected _observableCache: Record<string, any>;
91
253
  protected _delegates: FlowContext[];
@@ -95,7 +257,7 @@ export declare class FlowContext {
95
257
  createProxy(): FlowContext;
96
258
  constructor();
97
259
  defineProperty(key: string, options: PropertyOptions): void;
98
- defineMethod(name: string, fn: (...args: any[]) => any, des?: string): void;
260
+ defineMethod(name: string, fn: (...args: any[]) => any, info?: string | FlowContextMethodInfoInput): void;
99
261
  removeCache(key: string): boolean;
100
262
  delegate(ctx: FlowContext): void;
101
263
  addDelegate(ctx: FlowContext): void;
@@ -125,6 +287,26 @@ export declare class FlowContext {
125
287
  getPropertyMetaTree(value?: string, options?: {
126
288
  flatten?: boolean;
127
289
  }): MetaTreeNode[];
290
+ /**
291
+ * 获取静态 API 文档信息(仅顶层一层)。
292
+ *
293
+ * - 输出仅来自 RunJS doc 与 defineProperty/defineMethod 的 info
294
+ * - 不读取/展开 PropertyMeta(变量结构)
295
+ * - 不自动展开深层 properties
296
+ * - 不返回自动补全字段(例如 completion)
297
+ */
298
+ getApiInfos(options?: FlowContextGetApiInfosOptions): Promise<Record<string, FlowContextApiInfo>>;
299
+ /**
300
+ * 获取运行时环境快照信息(小体积、可序列化)。
301
+ */
302
+ getEnvInfos(): Promise<FlowContextInfosEnvs>;
303
+ /**
304
+ * 获取变量结构信息(来源于 PropertyMeta)。
305
+ *
306
+ * - 返回静态 plain object(不包含函数)
307
+ * - 支持 maxDepth(默认 3)与 path 剪裁
308
+ */
309
+ getVarInfos(options?: FlowContextGetVarInfosOptions): Promise<Record<string, FlowContextApiInfo>>;
128
310
  _getPropertiesMeta(): Record<string, PropertyMetaOrFactory>;
129
311
  protected _getOwnProperty(key: string, currentContext: any): any;
130
312
  protected _getOwnMethod(key: string, flowContext?: FlowContext): any;
@@ -147,7 +329,7 @@ declare class BaseFlowEngineContext extends FlowContext {
147
329
  dataSourceManager: DataSourceManager;
148
330
  requireAsync: (url: string) => Promise<any>;
149
331
  importAsync: (url: string) => Promise<any>;
150
- createJSRunner: (options?: JSRunnerOptions) => JSRunner;
332
+ createJSRunner: (options?: JSRunnerOptions) => Promise<JSRunner>;
151
333
  pageInfo: {
152
334
  version?: 'v1' | 'v2';
153
335
  };
@@ -156,6 +338,8 @@ declare class BaseFlowEngineContext extends FlowContext {
156
338
  */
157
339
  renderJson: (template: JSONValue) => Promise<any>;
158
340
  resolveJsonTemplate: (template: JSONValue) => Promise<any>;
341
+ getVar: (path: string) => Promise<any>;
342
+ request: (options: RequestOptions) => Promise<any>;
159
343
  runjs: (code: string, variables?: Record<string, any>, options?: JSRunnerOptions) => Promise<any>;
160
344
  getAction: <TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext>(name: string) => ActionDefinition<TModel, TCtx> | undefined;
161
345
  getActions: <TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext>() => Map<string, ActionDefinition<TModel, TCtx>>;
@@ -172,6 +356,7 @@ declare class BaseFlowEngineContext extends FlowContext {
172
356
  location: Location;
173
357
  sql: FlowSQLRepository;
174
358
  logger: pino.Logger;
359
+ constructor();
175
360
  }
176
361
  declare class BaseFlowModelContext extends BaseFlowEngineContext {
177
362
  model: FlowModel;
@@ -180,7 +365,16 @@ declare class BaseFlowModelContext extends BaseFlowEngineContext {
180
365
  getActions: <TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext>() => Map<string, ActionDefinition<TModel, TCtx>>;
181
366
  getEvents: <TModel extends FlowModel = FlowModel, TCtx extends FlowContext = FlowContext>() => Map<string, EventDefinition<TModel, TCtx>>;
182
367
  runAction: (actionName: string, params?: Record<string, any>) => Promise<any> | any;
368
+ /**
369
+ * @deprecated use `makeResource` instead
370
+ */
183
371
  createResource: <T extends FlowResource = FlowResource>(resourceType: ResourceType<T>) => T;
372
+ /**
373
+ * Create a new resource instance without adding it to the context.
374
+ * @param resourceType - The resource type.
375
+ * @returns The resource instance.
376
+ */
377
+ makeResource: <T extends FlowResource = FlowResource>(resourceType: ResourceType<T>) => T;
184
378
  }
185
379
  export declare class FlowEngineContext extends BaseFlowEngineContext {
186
380
  engine: FlowEngine;
@@ -204,7 +398,15 @@ export declare class FlowRuntimeContext<TModel extends FlowModel = FlowModel, TM
204
398
  result?: any;
205
399
  }>;
206
400
  stepResults: Record<string, any>;
207
- useResource: (className: 'APIResource' | 'SingleRecordResource' | 'MultiRecordResource') => void;
401
+ /**
402
+ * @deprecated use `initResource` instead
403
+ */
404
+ useResource: (className: 'APIResource' | 'SingleRecordResource' | 'MultiRecordResource' | 'SQLResource') => void;
405
+ /**
406
+ * Initialize a resource instance without adding it to the context.
407
+ * @param className - The resource class name.
408
+ */
409
+ initResource: (className: 'APIResource' | 'SingleRecordResource' | 'MultiRecordResource' | 'SQLResource') => void;
208
410
  getStepParams: (stepKey: string) => Record<string, any>;
209
411
  setStepParams: (stepKey: string, params?: any) => void;
210
412
  getStepResults: (stepKey: string) => any;
@@ -219,19 +421,35 @@ export type FlowSettingsContext<TModel extends FlowModel = FlowModel> = FlowRunt
219
421
  export type RunJSDocCompletionDoc = {
220
422
  insertText?: string;
221
423
  };
424
+ export type RunJSDocHiddenDoc = boolean | ((ctx: any) => boolean | Promise<boolean>);
425
+ export type RunJSDocHiddenOrPathsDoc = boolean | string[] | ((ctx: any) => boolean | string[] | Promise<boolean | string[]>);
222
426
  export type RunJSDocPropertyDoc = string | {
223
427
  description?: string;
224
428
  detail?: string;
225
429
  type?: string;
226
430
  examples?: string[];
227
431
  completion?: RunJSDocCompletionDoc;
432
+ ref?: FlowContextDocRef;
433
+ deprecated?: FlowDeprecationDoc;
434
+ params?: FlowContextDocParam[];
435
+ returns?: FlowContextDocReturn;
228
436
  properties?: Record<string, RunJSDocPropertyDoc>;
437
+ hidden?: RunJSDocHiddenOrPathsDoc;
438
+ disabled?: boolean | ((ctx: any) => boolean | Promise<boolean>);
439
+ disabledReason?: string | ((ctx: any) => string | undefined | Promise<string | undefined>);
229
440
  };
230
441
  export type RunJSDocMethodDoc = string | {
231
442
  description?: string;
232
443
  detail?: string;
233
444
  examples?: string[];
234
445
  completion?: RunJSDocCompletionDoc;
446
+ ref?: FlowContextDocRef;
447
+ deprecated?: FlowDeprecationDoc;
448
+ params?: FlowContextDocParam[];
449
+ returns?: FlowContextDocReturn;
450
+ hidden?: RunJSDocHiddenDoc;
451
+ disabled?: boolean | ((ctx: any) => boolean | Promise<boolean>);
452
+ disabledReason?: string | ((ctx: any) => string | undefined | Promise<string | undefined>);
235
453
  };
236
454
  export type RunJSDocMeta = {
237
455
  label?: string;
@@ -239,8 +457,13 @@ export type RunJSDocMeta = {
239
457
  methods?: Record<string, RunJSDocMethodDoc>;
240
458
  snippets?: Record<string, any>;
241
459
  };
460
+ export declare function createRunJSDeprecationProxy(ctx: any, options?: {
461
+ doc?: RunJSDocMeta;
462
+ }): any;
242
463
  export declare class FlowRunJSContext extends FlowContext {
243
464
  constructor(delegate: FlowContext);
465
+ exit(): void;
466
+ exitAll(): void;
244
467
  static define(meta: RunJSDocMeta, options?: {
245
468
  locale?: string;
246
469
  }): void;