@nocobase/plugin-workflow 2.2.0-beta.9 → 2.2.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 (271) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/119.e7dbd037d52d1286.js +10 -0
  4. package/dist/client/142.fb4936d78fc80007.js +10 -0
  5. package/dist/client/159.cc9a0f2d92cab2c1.js +10 -0
  6. package/dist/client/276.69fb2aea13bc7c37.js +10 -0
  7. package/dist/client/346.66d060d37843d3d1.js +10 -0
  8. package/dist/client/382.d37fba14a6b91b0b.js +10 -0
  9. package/dist/client/394.a37310b78419ad7a.js +10 -0
  10. package/dist/client/438.255c1f798203a3fc.js +10 -0
  11. package/dist/client/509.280de53e5e3e8874.js +10 -0
  12. package/dist/client/54.d81b710f7b4c1cd5.js +10 -0
  13. package/dist/client/618.1aa6c21d0f2840cb.js +10 -0
  14. package/dist/client/635.ff6085589e23d39b.js +10 -0
  15. package/dist/client/67.92c849b5dbe07c33.js +10 -0
  16. package/dist/client/719.f011fde3ad54571e.js +10 -0
  17. package/dist/client/728.e54be200a2eaac45.js +10 -0
  18. package/dist/client/739.49407722fca8d236.js +10 -0
  19. package/dist/client/759.13aab01e6912ed8d.js +10 -0
  20. package/dist/client/772.1ebaef11a0ac8688.js +10 -0
  21. package/dist/client/782.47792ce10fc0d5fb.js +10 -0
  22. package/dist/client/828.eda52a8918f0a56c.js +10 -0
  23. package/dist/client/87.083467b89aaf3e53.js +10 -0
  24. package/dist/client/938.26493fc09ba1ccbc.js +10 -0
  25. package/dist/client/964.5ab736effd480a42.js +10 -0
  26. package/dist/client/972.dd7f074d5f12e171.js +10 -0
  27. package/dist/client/AddNodeContext.d.ts +1 -9
  28. package/dist/client/BranchContext.d.ts +2 -10
  29. package/dist/client/FlowContext.d.ts +10 -5
  30. package/dist/client/NodeClipboardContext.d.ts +12 -2
  31. package/dist/client/NodeDragContext.d.ts +14 -2
  32. package/dist/client/RemoveNodeContext.d.ts +16 -2
  33. package/dist/client/WorkflowTasks.d.ts +5 -4
  34. package/dist/client/index.d.ts +2 -2
  35. package/dist/client/index.js +1 -1
  36. package/dist/client/nodeVariableUtils.d.ts +7 -6
  37. package/dist/client/nodes/calculation.d.ts +3 -75
  38. package/dist/client/nodes/condition.d.ts +7 -111
  39. package/dist/client/nodes/create.d.ts +3 -124
  40. package/dist/client/nodes/destroy.d.ts +2 -57
  41. package/dist/client/nodes/end.d.ts +2 -23
  42. package/dist/client/nodes/index.d.ts +2 -91
  43. package/dist/client/nodes/multi-conditions.d.ts +10 -48
  44. package/dist/client/nodes/output.d.ts +2 -44
  45. package/dist/client/nodes/query.d.ts +3 -255
  46. package/dist/client/nodes/update.d.ts +2 -117
  47. package/dist/client/style.d.ts +7 -27
  48. package/dist/client/triggers/collection.d.ts +3 -181
  49. package/dist/client/triggers/index.d.ts +2 -36
  50. package/dist/client/triggers/schedule/index.d.ts +8 -65
  51. package/dist/client/utils.d.ts +4 -5
  52. package/dist/client/variable.d.ts +7 -53
  53. package/dist/client-v2/119.81195bcd0d451279.js +10 -0
  54. package/dist/client-v2/142.a8c8df2a9abb43c5.js +10 -0
  55. package/dist/client-v2/159.cb221540c286cd32.js +10 -0
  56. package/dist/client-v2/276.7f746d899e221e2f.js +10 -0
  57. package/dist/client-v2/32.f7a2f5b51aac18b6.js +10 -0
  58. package/dist/client-v2/326.bdc99ad8e7590970.js +10 -0
  59. package/dist/client-v2/346.8c038b3c99d4fdc9.js +10 -0
  60. package/dist/client-v2/382.05f5482bb512b179.js +10 -0
  61. package/dist/client-v2/387.5e61d648d16dbf1b.js +10 -0
  62. package/dist/client-v2/394.515ed058e7f72797.js +10 -0
  63. package/dist/client-v2/438.76337ed02ad35e77.js +10 -0
  64. package/dist/client-v2/513.028d9992cc415e73.js +10 -0
  65. package/dist/client-v2/54.d3daf06e53092726.js +10 -0
  66. package/dist/client-v2/635.14a6f21cf4f16345.js +10 -0
  67. package/dist/client-v2/677.687ffa76229d7e48.js +10 -0
  68. package/dist/client-v2/719.05cf070ef89a78f4.js +10 -0
  69. package/dist/client-v2/739.5b60845103064f8d.js +10 -0
  70. package/dist/client-v2/759.7b162ad3adf450f1.js +10 -0
  71. package/dist/client-v2/772.8e5148d8c1518449.js +10 -0
  72. package/dist/client-v2/938.717e47af39485b29.js +10 -0
  73. package/dist/client-v2/ExecutionCanvas.d.ts +15 -0
  74. package/dist/client-v2/canvas/AddNodeContext.d.ts +35 -0
  75. package/dist/client-v2/canvas/AddNodeContext.shared.d.ts +33 -0
  76. package/dist/client-v2/canvas/AddNodeSlot.d.ts +20 -0
  77. package/dist/client-v2/canvas/Branch.d.ts +32 -0
  78. package/dist/client-v2/canvas/BranchContext.d.ts +29 -0
  79. package/dist/client-v2/canvas/BranchRenderContext.d.ts +14 -0
  80. package/dist/client-v2/canvas/CanvasContent.d.ts +20 -0
  81. package/dist/client-v2/canvas/DownstreamBranchIndex.d.ts +20 -0
  82. package/dist/client-v2/canvas/Instruction.d.ts +139 -0
  83. package/dist/{client/triggers/schedule/EndsByField.d.ts → client-v2/canvas/JobButton.d.ts} +3 -3
  84. package/dist/client-v2/canvas/Node.d.ts +38 -0
  85. package/dist/client-v2/canvas/NodeClipboardContext.d.ts +64 -0
  86. package/dist/client-v2/canvas/NodeConfigDrawer.d.ts +27 -0
  87. package/dist/client-v2/canvas/NodeDragContext.d.ts +83 -0
  88. package/dist/client-v2/canvas/RemoveNodeContext.d.ts +45 -0
  89. package/dist/client-v2/canvas/WorkflowTypedVariableInput.d.ts +16 -0
  90. package/dist/client-v2/canvas/WorkflowVariableInput.d.ts +47 -0
  91. package/dist/client-v2/canvas/WorkflowVariableJsonTextArea.d.ts +15 -0
  92. package/dist/client-v2/canvas/WorkflowVariableTag.d.ts +22 -0
  93. package/dist/client-v2/canvas/WorkflowVariableTextArea.d.ts +23 -0
  94. package/dist/client-v2/canvas/adaptVariableOptionToMetaTree.d.ts +48 -0
  95. package/dist/client-v2/canvas/addNodeController.d.ts +70 -0
  96. package/dist/client-v2/canvas/collectionFieldOptions.d.ts +57 -0
  97. package/dist/client-v2/canvas/contexts.d.ts +86 -0
  98. package/dist/client-v2/canvas/dropImpact.d.ts +28 -0
  99. package/dist/client-v2/canvas/instructionAvailability.d.ts +26 -0
  100. package/dist/client-v2/canvas/nodeRenderDispatch.d.ts +79 -0
  101. package/dist/client-v2/canvas/nodeTree.d.ts +21 -0
  102. package/dist/client-v2/canvas/nodeVariableUtils.d.ts +14 -0
  103. package/dist/client-v2/canvas/removeNodeUtils.d.ts +31 -0
  104. package/dist/client-v2/canvas/style.d.ts +35 -0
  105. package/dist/client-v2/canvas/textAreaInsertion.d.ts +14 -0
  106. package/dist/client-v2/canvas/useWorkflowInstruction.d.ts +23 -0
  107. package/dist/client-v2/canvas/useWorkflowVariableOptions.d.ts +40 -0
  108. package/dist/client-v2/canvas/workflowVariableConverters.d.ts +13 -0
  109. package/dist/client-v2/components/Calculation.d.ts +18 -0
  110. package/dist/client-v2/components/ExecutionStatusIcon.d.ts +18 -0
  111. package/dist/{client/triggers/schedule/RepeatField.d.ts → client-v2/components/ExecutionStatusTag.d.ts} +3 -4
  112. package/dist/client-v2/components/ExecutionViewHeader.d.ts +29 -0
  113. package/dist/client-v2/components/ExecutionsDropdown.d.ts +25 -0
  114. package/dist/client-v2/components/FilterDynamicComponent.d.ts +28 -0
  115. package/dist/client-v2/components/HideVariableContext.d.ts +11 -0
  116. package/dist/client-v2/components/JobResultModal.d.ts +11 -0
  117. package/dist/client-v2/components/RadioWithTooltip.d.ts +23 -0
  118. package/dist/client-v2/components/SyncModeSelect.d.ts +16 -0
  119. package/dist/{client/triggers/schedule/OnField.d.ts → client-v2/components/SyncModeTag.d.ts} +3 -3
  120. package/dist/client-v2/components/TestRunButton.d.ts +36 -0
  121. package/dist/client-v2/components/TimeoutInput.d.ts +15 -0
  122. package/dist/client-v2/components/WorkflowCanvasHeader.d.ts +17 -0
  123. package/dist/client-v2/components/WorkflowDetailsModal.d.ts +25 -0
  124. package/dist/client-v2/components/WorkflowEnabledSwitch.d.ts +16 -0
  125. package/dist/client-v2/components/WorkflowMenu.d.ts +17 -0
  126. package/dist/client-v2/components/WorkflowRevisionsDropdown.d.ts +15 -0
  127. package/dist/client-v2/components/WorkflowVariableWrapper.d.ts +25 -0
  128. package/dist/client-v2/components/collection/AppendsSelect.d.ts +15 -0
  129. package/dist/client-v2/components/collection/AssignedFieldsEditor.d.ts +24 -0
  130. package/dist/client-v2/components/collection/CollectionCascader.d.ts +15 -0
  131. package/dist/client-v2/components/collection/FieldsSelect.d.ts +16 -0
  132. package/dist/client-v2/components/collection/PaginationFields.d.ts +14 -0
  133. package/dist/client-v2/components/collection/SortFieldsInput.d.ts +19 -0
  134. package/dist/client-v2/components/collection/TriggerCollectionRecordSelect.d.ts +15 -0
  135. package/dist/client-v2/components/collection/index.d.ts +16 -0
  136. package/dist/client-v2/components/collection/utils.d.ts +42 -0
  137. package/dist/client-v2/components/formatResultForDisplay.d.ts +17 -0
  138. package/dist/client-v2/components/jobStatus.d.ts +27 -0
  139. package/dist/client-v2/components/renderEngineReference.d.ts +10 -0
  140. package/dist/client-v2/components/workflowCanvas.d.ts +41 -0
  141. package/dist/client-v2/constants.d.ts +23 -0
  142. package/dist/client-v2/hooks/useWorkflowRuntimePaths.d.ts +16 -0
  143. package/dist/client-v2/index.d.ts +48 -0
  144. package/dist/client-v2/index.js +10 -0
  145. package/dist/client-v2/locale.d.ts +41 -0
  146. package/dist/{client → client-v2}/models/NodeDetailsGridModel.d.ts +1 -1
  147. package/dist/{client → client-v2}/models/NodeDetailsModel.d.ts +1 -1
  148. package/dist/{client → client-v2}/models/NodeValueModel.d.ts +1 -1
  149. package/dist/{client → client-v2}/models/TaskCardCommonItemModel.d.ts +1 -1
  150. package/dist/client-v2/models/WorkflowTasksTopbarActionModel.d.ts +18 -0
  151. package/dist/{client → client-v2}/models/index.d.ts +2 -0
  152. package/dist/client-v2/models/triggerWorkflows.d.ts +43 -0
  153. package/dist/client-v2/nodes/calculation.d.ts +38 -0
  154. package/dist/client-v2/nodes/collectionNode.d.ts +29 -0
  155. package/dist/client-v2/nodes/components/calculation.d.ts +11 -0
  156. package/dist/client-v2/nodes/components/collection.d.ts +15 -0
  157. package/dist/client-v2/nodes/components/condition.d.ts +25 -0
  158. package/dist/client-v2/nodes/components/conditionShared.d.ts +20 -0
  159. package/dist/client-v2/nodes/components/create.d.ts +12 -0
  160. package/dist/client-v2/nodes/components/destroy.d.ts +12 -0
  161. package/dist/{client/triggers/schedule/ScheduleConfig.d.ts → client-v2/nodes/components/end.d.ts} +1 -1
  162. package/dist/client-v2/nodes/components/filter.d.ts +17 -0
  163. package/dist/client-v2/nodes/components/multi-conditions.d.ts +13 -0
  164. package/dist/client-v2/nodes/components/multiConditionsShared.d.ts +20 -0
  165. package/dist/client-v2/nodes/components/output.d.ts +10 -0
  166. package/dist/client-v2/nodes/components/query.d.ts +12 -0
  167. package/dist/client-v2/nodes/components/update.d.ts +12 -0
  168. package/dist/client-v2/nodes/condition.d.ts +46 -0
  169. package/dist/client-v2/nodes/create.d.ts +30 -0
  170. package/dist/client-v2/nodes/destroy.d.ts +24 -0
  171. package/dist/client-v2/nodes/end.d.ts +21 -0
  172. package/dist/client-v2/nodes/multi-conditions.d.ts +34 -0
  173. package/dist/client-v2/nodes/output.d.ts +29 -0
  174. package/dist/client-v2/nodes/query.d.ts +32 -0
  175. package/dist/client-v2/nodes/update.d.ts +25 -0
  176. package/dist/client-v2/pages/ExecutionHistoryDrawer.d.ts +13 -0
  177. package/dist/client-v2/pages/ExecutionViewPage.d.ts +10 -0
  178. package/dist/client-v2/pages/WorkflowCanvasPage.d.ts +10 -0
  179. package/dist/client-v2/pages/WorkflowCategoryTabs.d.ts +25 -0
  180. package/dist/client-v2/pages/WorkflowFormDrawer.d.ts +40 -0
  181. package/dist/client-v2/pages/WorkflowPane.d.ts +10 -0
  182. package/dist/client-v2/pages/WorkflowTasksPage.d.ts +10 -0
  183. package/dist/client-v2/plugin.d.ts +119 -0
  184. package/dist/client-v2/taskCenter.d.ts +107 -0
  185. package/dist/client-v2/triggers/ExecuteWorkflowButton.d.ts +35 -0
  186. package/dist/client-v2/triggers/TriggerConfig.d.ts +22 -0
  187. package/dist/client-v2/triggers/TriggerExecutionButton.d.ts +13 -0
  188. package/dist/client-v2/triggers/collection/CollectionConfig.d.ts +14 -0
  189. package/dist/client-v2/triggers/collection/TriggerCollectionConfig.d.ts +11 -0
  190. package/dist/client-v2/triggers/collection/constants.d.ts +28 -0
  191. package/dist/client-v2/triggers/collection/index.d.ts +40 -0
  192. package/dist/client-v2/triggers/index.d.ts +63 -0
  193. package/dist/client-v2/triggers/schedule/EndsByField.d.ts +17 -0
  194. package/dist/client-v2/triggers/schedule/OnField.d.ts +20 -0
  195. package/dist/client-v2/triggers/schedule/RepeatField.d.ts +23 -0
  196. package/dist/client-v2/triggers/schedule/ScheduleConfig.d.ts +17 -0
  197. package/dist/client-v2/triggers/schedule/ScheduleModes.d.ts +41 -0
  198. package/dist/{client → client-v2}/triggers/schedule/TriggerScheduleConfig.d.ts +1 -0
  199. package/dist/{client → client-v2}/triggers/schedule/constants.d.ts +8 -5
  200. package/dist/client-v2/triggers/schedule/index.d.ts +40 -0
  201. package/dist/client-v2/triggers/schedule/locale/Cron.zh-CN.d.ts +11 -0
  202. package/dist/client-v2/utils/contextSingleton.d.ts +9 -0
  203. package/dist/common/collections/jobs.js +2 -2
  204. package/dist/common/collections/userWorkflowTaskStats.d.ts +54 -0
  205. package/dist/common/collections/userWorkflowTaskStats.js +87 -0
  206. package/dist/common/collections/workflows.d.ts +16 -0
  207. package/dist/common/collections/workflows.js +5 -0
  208. package/dist/common/defaultWorkflowFilter.d.ts +21 -0
  209. package/dist/common/defaultWorkflowFilter.js +38 -0
  210. package/dist/common/executionStatus.d.ts +44 -0
  211. package/dist/common/executionStatus.js +133 -0
  212. package/dist/externalVersion.js +17 -14
  213. package/dist/locale/de-DE.json +17 -1
  214. package/dist/locale/en-US.json +32 -1
  215. package/dist/locale/es-ES.json +17 -1
  216. package/dist/locale/fr-FR.json +17 -1
  217. package/dist/locale/hu-HU.json +17 -1
  218. package/dist/locale/id-ID.json +17 -1
  219. package/dist/locale/it-IT.json +17 -1
  220. package/dist/locale/ja-JP.json +17 -1
  221. package/dist/locale/ko-KR.json +17 -1
  222. package/dist/locale/nl-NL.json +17 -1
  223. package/dist/locale/pt-BR.json +17 -1
  224. package/dist/locale/ru-RU.json +17 -1
  225. package/dist/locale/tr-TR.json +17 -1
  226. package/dist/locale/uk-UA.json +17 -1
  227. package/dist/locale/vi-VN.json +17 -1
  228. package/dist/locale/zh-CN.json +31 -1
  229. package/dist/locale/zh-TW.json +23 -1
  230. package/dist/node_modules/cron-parser/package.json +1 -1
  231. package/dist/node_modules/joi/package.json +1 -1
  232. package/dist/node_modules/lru-cache/package.json +1 -1
  233. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  234. package/dist/server/Dispatcher.d.ts +27 -15
  235. package/dist/server/Dispatcher.js +199 -161
  236. package/dist/server/ExecutionTimeoutManager.js +2 -1
  237. package/dist/server/Plugin.d.ts +59 -13
  238. package/dist/server/Plugin.js +356 -16
  239. package/dist/server/Processor.d.ts +2 -7
  240. package/dist/server/Processor.js +37 -18
  241. package/dist/server/RunningExecutionRegistry.d.ts +2 -2
  242. package/dist/server/RunningExecutionRegistry.js +21 -6
  243. package/dist/server/actions/executions.js +3 -6
  244. package/dist/server/actions/index.js +3 -1
  245. package/dist/server/actions/jobs.js +1 -2
  246. package/dist/server/actions/userWorkflowTaskStats.d.ts +10 -0
  247. package/dist/server/actions/userWorkflowTaskStats.js +112 -0
  248. package/dist/server/actions/workflows.d.ts +1 -0
  249. package/dist/server/actions/workflows.js +35 -3
  250. package/dist/server/collections/userWorkflowTaskStats.d.ts +11 -0
  251. package/dist/server/collections/userWorkflowTaskStats.js +43 -0
  252. package/dist/server/index.d.ts +1 -0
  253. package/dist/server/triggers/CollectionTrigger.d.ts +1 -1
  254. package/dist/server/triggers/CollectionTrigger.js +3 -0
  255. package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.d.ts +1 -1
  256. package/dist/server/triggers/index.d.ts +1 -1
  257. package/dist/server/types/Execution.d.ts +2 -0
  258. package/dist/server/types/Job.d.ts +6 -0
  259. package/dist/server/types/Workflow.d.ts +1 -0
  260. package/dist/server/utils.d.ts +2 -1
  261. package/dist/server/utils.js +19 -1
  262. package/dist/shared/WorkflowTaskNavigation.d.ts +56 -0
  263. package/dist/shared/WorkflowTaskNavigation.js +742 -0
  264. package/dist/swagger/index.d.ts +69 -1
  265. package/dist/swagger/index.js +65 -3
  266. package/package.json +4 -2
  267. package/dist/client/618.c91be3f6e4d73501.js +0 -10
  268. package/dist/client/67.61e70b8b777f8638.js +0 -10
  269. package/dist/client/964.5e11e1820fece37b.js +0 -10
  270. package/dist/client/triggers/schedule/ScheduleModes.d.ts +0 -170
  271. package/dist/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -42
@@ -98,12 +98,9 @@ async function rerun(context, next) {
98
98
  if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
99
99
  return context.throw(400, "Only started executions can be rerun");
100
100
  }
101
- await workflowPlugin.run({
102
- execution,
103
- rerun: {
104
- nodeId,
105
- overwrite: overwrite === true
106
- }
101
+ await workflowPlugin.rerun(execution, {
102
+ nodeId,
103
+ overwrite: overwrite === true
107
104
  });
108
105
  context.body = execution;
109
106
  context.status = 202;
@@ -44,6 +44,7 @@ var nodes = __toESM(require("./nodes"));
44
44
  var jobs = __toESM(require("./jobs"));
45
45
  var executions = __toESM(require("./executions"));
46
46
  var userWorkflowTasks = __toESM(require("./userWorkflowTasks"));
47
+ var userWorkflowTaskStats = __toESM(require("./userWorkflowTaskStats"));
47
48
  function make(name, mod) {
48
49
  return Object.keys(mod).reduce(
49
50
  (result, key) => ({
@@ -69,6 +70,7 @@ function actions_default({ app }) {
69
70
  }),
70
71
  ...make("jobs", jobs),
71
72
  ...make("executions", executions),
72
- ...make("userWorkflowTasks", userWorkflowTasks)
73
+ ...make("userWorkflowTasks", userWorkflowTasks),
74
+ ...make("userWorkflowTaskStats", userWorkflowTaskStats)
73
75
  });
74
76
  }
@@ -82,8 +82,7 @@ async function resume(context, next) {
82
82
  context.body = job;
83
83
  context.status = 202;
84
84
  await next();
85
- job.execution = execution;
86
- workflowPlugin.resume(job);
85
+ await workflowPlugin.resume(job);
87
86
  }
88
87
  // Annotate the CommonJS export names for ESM import in node:
89
88
  0 && (module.exports = {
@@ -0,0 +1,10 @@
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
+ import { Context } from '@nocobase/actions';
10
+ export declare function listMine(context: Context, next: any): Promise<void>;
@@ -0,0 +1,112 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var userWorkflowTaskStats_exports = {};
28
+ __export(userWorkflowTaskStats_exports, {
29
+ listMine: () => listMine
30
+ });
31
+ module.exports = __toCommonJS(userWorkflowTaskStats_exports);
32
+ var import_actions = require("@nocobase/actions");
33
+ async function listMine(context, next) {
34
+ const { type, search } = context.action.params;
35
+ const normalizedSearch = typeof search === "string" ? search.trim() : "";
36
+ const page = Math.max(Number.parseInt(String(context.action.params.page ?? 1), 10) || 1, 1);
37
+ const pageSize = Math.min(
38
+ Math.max(Number.parseInt(String(context.action.params.pageSize ?? 200), 10) || 200, 1),
39
+ 200
40
+ );
41
+ const pagination = import_actions.utils.pageArgsToLimitArgs(page, pageSize);
42
+ const repository = context.db.getRepository("userWorkflowTaskStats");
43
+ const rows = await repository.find({
44
+ filter: {
45
+ userId: context.state.currentUser.id,
46
+ ...type ? { type } : {},
47
+ all: {
48
+ $gt: 0
49
+ }
50
+ },
51
+ fields: ["workflowKey", "pending", "all"]
52
+ });
53
+ const statsMap = /* @__PURE__ */ new Map();
54
+ for (const row of rows) {
55
+ if (!row.workflowKey) {
56
+ continue;
57
+ }
58
+ const existed = statsMap.get(row.workflowKey) ?? {
59
+ workflowKey: row.workflowKey,
60
+ stats: { pending: 0, all: 0 }
61
+ };
62
+ existed.stats.pending += Number(row.pending) || 0;
63
+ existed.stats.all += Number(row.all) || 0;
64
+ statsMap.set(row.workflowKey, existed);
65
+ }
66
+ const workflowKeys = Array.from(statsMap.keys());
67
+ if (!workflowKeys.length) {
68
+ context.body = {
69
+ rows: [],
70
+ page,
71
+ pageSize,
72
+ hasNext: false
73
+ };
74
+ await next();
75
+ return;
76
+ }
77
+ const workflows = await context.db.getRepository("workflows").find({
78
+ filter: {
79
+ key: workflowKeys,
80
+ current: true,
81
+ ...normalizedSearch ? {
82
+ title: {
83
+ $includes: normalizedSearch
84
+ }
85
+ } : {}
86
+ },
87
+ fields: ["key", "title"],
88
+ sort: ["title"],
89
+ limit: pagination.limit + 1,
90
+ offset: pagination.offset
91
+ });
92
+ const hasNext = workflows.length > pageSize;
93
+ const data = workflows.slice(0, pageSize).map((workflow) => {
94
+ var _a;
95
+ return {
96
+ workflowKey: workflow.key,
97
+ title: workflow.title,
98
+ stats: ((_a = statsMap.get(workflow.key)) == null ? void 0 : _a.stats) ?? { pending: 0, all: 0 }
99
+ };
100
+ });
101
+ context.body = {
102
+ rows: data,
103
+ page,
104
+ pageSize,
105
+ hasNext
106
+ };
107
+ await next();
108
+ }
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ listMine
112
+ });
@@ -12,6 +12,7 @@ export declare class WorkflowValidationError extends Error {
12
12
  errors: Record<string, string>;
13
13
  constructor(errors: Record<string, string>);
14
14
  }
15
+ export declare function list(context: Context, next: any): Promise<void>;
15
16
  export declare function create(context: Context, next: any): Promise<void>;
16
17
  export declare function update(context: Context, next: any): Promise<void>;
17
18
  export declare function destroy(context: Context, next: any): Promise<void>;
@@ -40,6 +40,7 @@ __export(workflows_exports, {
40
40
  create: () => create,
41
41
  destroy: () => destroy,
42
42
  execute: () => execute,
43
+ list: () => list,
43
44
  revision: () => revision,
44
45
  sync: () => sync,
45
46
  update: () => update
@@ -72,9 +73,14 @@ function validateWorkflow(context, plugin, { type, config }) {
72
73
  }
73
74
  }
74
75
  }
76
+ async function list(context, next) {
77
+ return import_actions.default.list(context, next);
78
+ }
75
79
  async function create(context, next) {
76
80
  const plugin = context.app.pm.get(import_Plugin.default);
77
- const { values } = context.action.params;
81
+ const values = { ...context.action.params.values || {} };
82
+ delete values.invalid;
83
+ context.action.mergeParams({ values }, { values: "overwrite" });
78
84
  validateWorkflow(context, plugin, values);
79
85
  return import_actions.default.create(context, next);
80
86
  }
@@ -100,6 +106,7 @@ async function update(context, next) {
100
106
  return import_actions.default.update(context, next);
101
107
  }
102
108
  async function destroy(context, next) {
109
+ const plugin = context.app.pm.get(import_Plugin.default);
103
110
  const repository = import_actions.utils.getRepositoryFromParams(context);
104
111
  const { filterByTk, filter } = context.action.params;
105
112
  await context.db.sequelize.transaction(async (transaction) => {
@@ -110,6 +117,15 @@ async function destroy(context, next) {
110
117
  transaction
111
118
  });
112
119
  const ids = new Set(items.map((item) => item.id));
120
+ const affectedKeys = Array.from(new Set(items.map((item) => item.get("key"))));
121
+ const affectedTaskStats = affectedKeys.length ? await context.db.getRepository("userWorkflowTaskStats").find({
122
+ filter: {
123
+ workflowKey: affectedKeys
124
+ },
125
+ fields: ["userId"],
126
+ transaction
127
+ }) : [];
128
+ const affectedUserIds = Array.from(new Set(affectedTaskStats.map((item) => item.get("userId"))));
113
129
  const keysSet = new Set(items.filter((item) => item.current).map((item) => item.key));
114
130
  const revisions = await repository.find({
115
131
  filter: {
@@ -132,6 +148,13 @@ async function destroy(context, next) {
132
148
  },
133
149
  transaction
134
150
  });
151
+ if (affectedKeys.length) {
152
+ await plugin.repairTaskStats({
153
+ workflowKeys: affectedKeys,
154
+ ...affectedUserIds.length ? { userIds: affectedUserIds } : {},
155
+ transaction
156
+ });
157
+ }
135
158
  context.body = deleted;
136
159
  });
137
160
  next();
@@ -139,10 +162,12 @@ async function destroy(context, next) {
139
162
  async function revision(context, next) {
140
163
  const repository = import_actions.utils.getRepositoryFromParams(context);
141
164
  const { filterByTk, filter = {}, values = {} } = context.action.params;
165
+ const revisionValues = { ...values };
166
+ delete revisionValues.invalid;
142
167
  context.body = await repository.revision({
143
168
  filterByTk,
144
169
  filter,
145
- values,
170
+ values: revisionValues,
146
171
  context
147
172
  });
148
173
  await next();
@@ -184,6 +209,12 @@ async function execute(context, next) {
184
209
  let processor;
185
210
  try {
186
211
  processor = await plugin.execute(workflow, values, { manually: true });
212
+ if (processor === null) {
213
+ context.body = {
214
+ execution: null
215
+ };
216
+ return next();
217
+ }
187
218
  if (!processor) {
188
219
  return context.throw(400, "workflow not triggered");
189
220
  }
@@ -194,7 +225,7 @@ async function execute(context, next) {
194
225
  filter: { key: workflow.key }
195
226
  });
196
227
  let newVersion;
197
- if (executed == 0 && autoRevision) {
228
+ if (executed === 0 && Number(autoRevision) === 1) {
198
229
  newVersion = await repository.revision({
199
230
  filterByTk: workflow.id,
200
231
  filter: { key: workflow.key },
@@ -220,6 +251,7 @@ async function execute(context, next) {
220
251
  create,
221
252
  destroy,
222
253
  execute,
254
+ list,
223
255
  revision,
224
256
  sync,
225
257
  update
@@ -0,0 +1,11 @@
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
+ import { CollectionOptions } from '@nocobase/database';
10
+ declare const _default: CollectionOptions;
11
+ export default _default;
@@ -0,0 +1,43 @@
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 __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var userWorkflowTaskStats_exports = {};
38
+ __export(userWorkflowTaskStats_exports, {
39
+ default: () => userWorkflowTaskStats_default
40
+ });
41
+ module.exports = __toCommonJS(userWorkflowTaskStats_exports);
42
+ var import_userWorkflowTaskStats = __toESM(require("../../common/collections/userWorkflowTaskStats"));
43
+ var userWorkflowTaskStats_default = import_userWorkflowTaskStats.default;
@@ -17,4 +17,5 @@ export type { EventOptions } from './Dispatcher';
17
17
  export { default as Processor } from './Processor';
18
18
  export type { BackgroundAbortHandle, ProcessorOptions, ScopeTransaction } from './Processor';
19
19
  export { default } from './Plugin';
20
+ export type { RepairTaskStatsOptions, TaskStatsProvider, TaskStatsRow } from './Plugin';
20
21
  export * from './types';
@@ -30,7 +30,7 @@ export default class CollectionTrigger extends Trigger {
30
30
  code?: string;
31
31
  };
32
32
  prepare(workflow: WorkflowModel, data: Model | Record<string, any> | string | number, options: any): Promise<{
33
- data: any;
33
+ data: string | number | Record<string, any> | Model<any, any>;
34
34
  }>;
35
35
  on(workflow: WorkflowModel): void;
36
36
  off(workflow: WorkflowModel): void;
@@ -305,6 +305,9 @@ class CollectionTrigger extends import__.default {
305
305
  // }
306
306
  async execute(workflow, values, options) {
307
307
  const ctx = await this.prepare(workflow, values == null ? void 0 : values.data, options);
308
+ if (!ctx) {
309
+ return null;
310
+ }
308
311
  const [dataSourceName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
309
312
  const { transaction } = options;
310
313
  return this.workflow.trigger(workflow, ctx, {
@@ -20,5 +20,5 @@ export default class StaticScheduleTrigger {
20
20
  trigger(workflow: WorkflowModel, time: number): Promise<void>;
21
21
  on(workflow: any): void;
22
22
  off(workflow: any): void;
23
- execute(workflow: any, values: any, options: any): void | Promise<import("../..").Processor>;
23
+ execute(workflow: any, values: any, options: any): void | Promise<void | import("../..").Processor>;
24
24
  }
@@ -26,6 +26,6 @@ export declare abstract class Trigger {
26
26
  [key: string]: string;
27
27
  };
28
28
  sync?: boolean;
29
- execute?(workflow: WorkflowModel, values: any, options: Transactionable): void | Processor | Promise<void | Processor>;
29
+ execute?(workflow: WorkflowModel, values: any, options: Transactionable): void | Processor | null | Promise<void | Processor | null>;
30
30
  }
31
31
  export default Trigger;
@@ -12,11 +12,13 @@ import WorkflowModel from './Workflow';
12
12
  export default class ExecutionModel extends Model {
13
13
  static readonly database: Database;
14
14
  id: number;
15
+ workflowId: number;
15
16
  title: string;
16
17
  context: any;
17
18
  status: number;
18
19
  reason?: string | null;
19
20
  dispatched: boolean;
21
+ manually?: boolean | null;
20
22
  parentExecutionId?: number | null;
21
23
  stack?: Array<number | string>;
22
24
  startedAt?: Date | null;
@@ -8,11 +8,15 @@
8
8
  */
9
9
  import { BelongsToGetAssociationMixin, Model } from '@nocobase/database';
10
10
  import FlowNodeModel from './FlowNode';
11
+ import ExecutionModel from './Execution';
11
12
  export default class JobModel extends Model {
12
13
  id: number;
14
+ executionId: number;
15
+ workflowId?: number;
13
16
  status: number;
14
17
  result?: any;
15
18
  meta?: any;
19
+ startedAt?: Date | null;
16
20
  createdAt: Date;
17
21
  updatedAt: Date;
18
22
  upstreamId: number;
@@ -20,4 +24,6 @@ export default class JobModel extends Model {
20
24
  nodeId: number;
21
25
  node?: FlowNodeModel;
22
26
  getNode: BelongsToGetAssociationMixin<FlowNodeModel>;
27
+ execution?: ExecutionModel;
28
+ getExecution: BelongsToGetAssociationMixin<ExecutionModel>;
23
29
  }
@@ -19,6 +19,7 @@ export default class WorkflowModel extends Model {
19
19
  description?: string;
20
20
  type: string;
21
21
  config: any;
22
+ invalid: boolean;
22
23
  options: {
23
24
  timeout?: number;
24
25
  stackLimit?: number;
@@ -16,6 +16,7 @@ type AbortOptions = Transactionable & {
16
16
  reason?: (typeof EXECUTION_REASON)[keyof typeof EXECUTION_REASON];
17
17
  };
18
18
  export declare function getExecutionLockKey(executionId: number | string): string;
19
+ export declare function getJobLockKey(jobId: number | string): string;
19
20
  export declare function isLockAcquireError(error: unknown): boolean;
20
21
  export declare function validateCollectionField(collection: string, dataSourceManager: DataSourceManager): Record<string, string> | null;
21
22
  export declare function getExecutionStatusName(status: number | null | undefined): string;
@@ -32,5 +33,5 @@ export declare function getWorkflowExecutionLogMeta(workflow: WorkflowModel, pro
32
33
  lastJobStatus: number;
33
34
  };
34
35
  export declare function abortExecution(plugin: PluginWorkflowServer, execution: ExecutionModel, options?: AbortOptions): Promise<boolean>;
35
- export declare function toJSON(data: any): any;
36
+ export declare function toJSON<T>(data: T): T;
36
37
  export {};
@@ -29,6 +29,7 @@ __export(utils_exports, {
29
29
  abortExecution: () => abortExecution,
30
30
  getExecutionLockKey: () => getExecutionLockKey,
31
31
  getExecutionStatusName: () => getExecutionStatusName,
32
+ getJobLockKey: () => getJobLockKey,
32
33
  getWorkflowExecutionLogMeta: () => getWorkflowExecutionLogMeta,
33
34
  isLockAcquireError: () => isLockAcquireError,
34
35
  toJSON: () => toJSON,
@@ -41,6 +42,9 @@ var import_constants = require("./constants");
41
42
  function getExecutionLockKey(executionId) {
42
43
  return `workflow:execution:${executionId}`;
43
44
  }
45
+ function getJobLockKey(jobId) {
46
+ return `workflow:job:${jobId}`;
47
+ }
44
48
  function isLockAcquireError(error) {
45
49
  return error instanceof Error && error.constructor.name === "LockAcquireError";
46
50
  }
@@ -164,6 +168,16 @@ async function abortExecution(plugin, execution, options = {}) {
164
168
  throw error;
165
169
  }
166
170
  }
171
+ function getHiddenFieldNames(model) {
172
+ const { collection } = model.constructor;
173
+ if (!(collection == null ? void 0 : collection.fields)) {
174
+ return [];
175
+ }
176
+ return Array.from(collection.fields.values()).filter((field) => {
177
+ var _a;
178
+ return (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.hidden;
179
+ }).map((field) => field.options.name).filter((name) => typeof name === "string");
180
+ }
167
181
  function toJSON(data) {
168
182
  if (Array.isArray(data)) {
169
183
  return data.map(toJSON);
@@ -171,7 +185,10 @@ function toJSON(data) {
171
185
  if (!(data instanceof import_database.Model) || !data) {
172
186
  return data;
173
187
  }
174
- const result = data.get();
188
+ const result = { ...data.get() };
189
+ for (const fieldName of getHiddenFieldNames(data)) {
190
+ delete result[fieldName];
191
+ }
175
192
  Object.keys(data.constructor.associations).forEach((key) => {
176
193
  if (result[key] != null && typeof result[key] === "object") {
177
194
  result[key] = toJSON(result[key]);
@@ -184,6 +201,7 @@ function toJSON(data) {
184
201
  abortExecution,
185
202
  getExecutionLockKey,
186
203
  getExecutionStatusName,
204
+ getJobLockKey,
187
205
  getWorkflowExecutionLogMeta,
188
206
  isLockAcquireError,
189
207
  toJSON,
@@ -0,0 +1,56 @@
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
+ import React from 'react';
10
+ export interface WorkflowTaskStatsItem {
11
+ workflowKey: string;
12
+ title: string;
13
+ stats: {
14
+ pending: number;
15
+ all: number;
16
+ };
17
+ }
18
+ export interface WorkflowTaskNavigationType {
19
+ count: number;
20
+ key: string;
21
+ title: React.ReactNode;
22
+ }
23
+ interface WorkflowTaskStatsListParams {
24
+ page: number;
25
+ pageSize: number;
26
+ search?: string;
27
+ type: string;
28
+ }
29
+ export type LoadWorkflowTaskStats = (params: WorkflowTaskStatsListParams) => Promise<unknown>;
30
+ export interface WorkflowTaskFilterContextValue {
31
+ selectedWorkflow: WorkflowTaskStatsItem | null;
32
+ selectWorkflow: (workflow: WorkflowTaskStatsItem | null) => void;
33
+ workflows: WorkflowTaskStatsItem[];
34
+ loading: boolean;
35
+ loadingMore: boolean;
36
+ hasNext: boolean;
37
+ error: boolean;
38
+ search: string;
39
+ setSearch: (search: string) => void;
40
+ loadMore: () => void;
41
+ reload: () => void;
42
+ }
43
+ export declare function useWorkflowTaskFilterContext(): WorkflowTaskFilterContextValue;
44
+ export declare function WorkflowTaskFilterProvider(props: React.PropsWithChildren<{
45
+ eventBus?: EventTarget;
46
+ loadWorkflowTaskStats: LoadWorkflowTaskStats;
47
+ typeKey?: string;
48
+ }>): React.JSX.Element;
49
+ export declare function WorkflowTaskNavigation(props: {
50
+ currentTypeKey?: string;
51
+ mobile: boolean;
52
+ onTaskTypeSelect: (typeKey: string) => void;
53
+ taskTypes: WorkflowTaskNavigationType[];
54
+ t: (key: string) => string;
55
+ }): React.JSX.Element;
56
+ export {};