@nocobase/plugin-workflow 1.2.13-alpha → 1.3.0-alpha.20240710084543

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 (247) hide show
  1. package/package.json +3 -3
  2. package/dist/client/AddButton.d.ts +0 -16
  3. package/dist/client/Branch.d.ts +0 -17
  4. package/dist/client/CanvasContent.d.ts +0 -12
  5. package/dist/client/ExecutionCanvas.d.ts +0 -10
  6. package/dist/client/ExecutionContextProvider.d.ts +0 -15
  7. package/dist/client/ExecutionLink.d.ts +0 -10
  8. package/dist/client/ExecutionPage.d.ts +0 -10
  9. package/dist/client/ExecutionResourceProvider.d.ts +0 -14
  10. package/dist/client/FlowContext.d.ts +0 -11
  11. package/dist/client/WorkflowCanvas.d.ts +0 -10
  12. package/dist/client/WorkflowLink.d.ts +0 -10
  13. package/dist/client/WorkflowPage.d.ts +0 -10
  14. package/dist/client/WorkflowPane.d.ts +0 -10
  15. package/dist/client/components/AssignedFieldsFormSchemaConfig.d.ts +0 -10
  16. package/dist/client/components/CheckboxGroupWithTooltip.d.ts +0 -15
  17. package/dist/client/components/CollectionBlockInitializer.d.ts +0 -10
  18. package/dist/client/components/CollectionFieldset.d.ts +0 -14
  19. package/dist/client/components/DetailsBlockProvider.d.ts +0 -14
  20. package/dist/client/components/DrawerDescription.d.ts +0 -10
  21. package/dist/client/components/DrawerForm.d.ts +0 -13
  22. package/dist/client/components/ExecutionStatus.d.ts +0 -13
  23. package/dist/client/components/FieldsSelect.d.ts +0 -10
  24. package/dist/client/components/FilterDynamicComponent.d.ts +0 -14
  25. package/dist/client/components/OpenDrawer.d.ts +0 -14
  26. package/dist/client/components/RadioWithTooltip.d.ts +0 -15
  27. package/dist/client/components/SimpleDesigner.d.ts +0 -10
  28. package/dist/client/components/StatusButton.d.ts +0 -10
  29. package/dist/client/components/TriggerOptionRender.d.ts +0 -12
  30. package/dist/client/components/ValueBlock.d.ts +0 -14
  31. package/dist/client/components/index.d.ts +0 -16
  32. package/dist/client/components/renderEngineReference.d.ts +0 -10
  33. package/dist/client/constants.d.ts +0 -45
  34. package/dist/client/hooks/index.d.ts +0 -11
  35. package/dist/client/hooks/useGetAriaLabelOfAddButton.d.ts +0 -14
  36. package/dist/client/hooks/useRefreshActionProps.d.ts +0 -11
  37. package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +0 -20
  38. package/dist/client/hooks/useWorkflowExecuted.d.ts +0 -10
  39. package/dist/client/index.d.ts +0 -43
  40. package/dist/client/index.js +0 -569
  41. package/dist/client/locale/index.d.ts +0 -11
  42. package/dist/client/nodes/calculation.d.ts +0 -80
  43. package/dist/client/nodes/condition.d.ts +0 -108
  44. package/dist/client/nodes/create.d.ts +0 -110
  45. package/dist/client/nodes/destroy.d.ts +0 -54
  46. package/dist/client/nodes/end.d.ts +0 -30
  47. package/dist/client/nodes/index.d.ts +0 -76
  48. package/dist/client/nodes/query.d.ts +0 -236
  49. package/dist/client/nodes/update.d.ts +0 -114
  50. package/dist/client/schemas/collection.d.ts +0 -170
  51. package/dist/client/schemas/executions.d.ts +0 -282
  52. package/dist/client/schemas/workflows.d.ts +0 -10
  53. package/dist/client/settings/customizeSubmitToWorkflowActionSettings.d.ts +0 -10
  54. package/dist/client/style.d.ts +0 -30
  55. package/dist/client/triggers/collection.d.ts +0 -124
  56. package/dist/client/triggers/index.d.ts +0 -36
  57. package/dist/client/triggers/schedule/EndsByField.d.ts +0 -13
  58. package/dist/client/triggers/schedule/OnField.d.ts +0 -13
  59. package/dist/client/triggers/schedule/RepeatField.d.ts +0 -13
  60. package/dist/client/triggers/schedule/ScheduleConfig.d.ts +0 -10
  61. package/dist/client/triggers/schedule/constants.d.ts +0 -12
  62. package/dist/client/triggers/schedule/index.d.ts +0 -33
  63. package/dist/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -42
  64. package/dist/client/utils.d.ts +0 -12
  65. package/dist/client/variable.d.ts +0 -93
  66. package/dist/externalVersion.js +0 -34
  67. package/dist/index.d.ts +0 -10
  68. package/dist/index.js +0 -48
  69. package/dist/locale/en-US.json +0 -98
  70. package/dist/locale/es-ES.json +0 -98
  71. package/dist/locale/fr-FR.json +0 -98
  72. package/dist/locale/ja-JP.json +0 -82
  73. package/dist/locale/ko_KR.json +0 -168
  74. package/dist/locale/pt-BR.json +0 -98
  75. package/dist/locale/ru-RU.json +0 -82
  76. package/dist/locale/tr-TR.json +0 -82
  77. package/dist/locale/zh-CN.json +0 -205
  78. package/dist/node_modules/cron-parser/.eslintrc.json +0 -15
  79. package/dist/node_modules/cron-parser/.travis.yml +0 -7
  80. package/dist/node_modules/cron-parser/LICENSE +0 -21
  81. package/dist/node_modules/cron-parser/component.json +0 -11
  82. package/dist/node_modules/cron-parser/index.d.ts +0 -1
  83. package/dist/node_modules/cron-parser/lib/date.js +0 -252
  84. package/dist/node_modules/cron-parser/lib/expression.js +0 -983
  85. package/dist/node_modules/cron-parser/lib/field_compactor.js +0 -70
  86. package/dist/node_modules/cron-parser/lib/field_stringify.js +0 -38
  87. package/dist/node_modules/cron-parser/lib/parser.js +0 -1
  88. package/dist/node_modules/cron-parser/node_modules/luxon/build/amd/luxon.js +0 -8489
  89. package/dist/node_modules/cron-parser/node_modules/luxon/build/cjs-browser/luxon.js +0 -8487
  90. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.js +0 -8490
  91. package/dist/node_modules/cron-parser/node_modules/luxon/build/global/luxon.min.js +0 -1
  92. package/dist/node_modules/cron-parser/node_modules/luxon/build/node/luxon.js +0 -7522
  93. package/dist/node_modules/cron-parser/node_modules/luxon/package.json +0 -96
  94. package/dist/node_modules/cron-parser/node_modules/luxon/src/datetime.js +0 -2169
  95. package/dist/node_modules/cron-parser/node_modules/luxon/src/duration.js +0 -880
  96. package/dist/node_modules/cron-parser/node_modules/luxon/src/errors.js +0 -61
  97. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/conversions.js +0 -157
  98. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/diff.js +0 -80
  99. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/digits.js +0 -76
  100. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/english.js +0 -233
  101. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formats.js +0 -191
  102. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/formatter.js +0 -386
  103. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/invalid.js +0 -14
  104. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/locale.js +0 -482
  105. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/regexParser.js +0 -335
  106. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/tokenParser.js +0 -424
  107. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/util.js +0 -292
  108. package/dist/node_modules/cron-parser/node_modules/luxon/src/impl/zoneUtil.js +0 -36
  109. package/dist/node_modules/cron-parser/node_modules/luxon/src/info.js +0 -193
  110. package/dist/node_modules/cron-parser/node_modules/luxon/src/interval.js +0 -602
  111. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxon.js +0 -26
  112. package/dist/node_modules/cron-parser/node_modules/luxon/src/luxonFilled.js +0 -13
  113. package/dist/node_modules/cron-parser/node_modules/luxon/src/settings.js +0 -137
  114. package/dist/node_modules/cron-parser/node_modules/luxon/src/zone.js +0 -88
  115. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/IANAZone.js +0 -191
  116. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/fixedOffsetZone.js +0 -94
  117. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/invalidZone.js +0 -53
  118. package/dist/node_modules/cron-parser/node_modules/luxon/src/zones/localZone.js +0 -63
  119. package/dist/node_modules/cron-parser/package.json +0 -1
  120. package/dist/node_modules/cron-parser/test/31_of_month.js +0 -17
  121. package/dist/node_modules/cron-parser/test/bug.js +0 -29
  122. package/dist/node_modules/cron-parser/test/crondate.js +0 -16
  123. package/dist/node_modules/cron-parser/test/crontab.example +0 -7
  124. package/dist/node_modules/cron-parser/test/empty_around_comma.js +0 -22
  125. package/dist/node_modules/cron-parser/test/expression.js +0 -1489
  126. package/dist/node_modules/cron-parser/test/field_compactor.js +0 -250
  127. package/dist/node_modules/cron-parser/test/field_stringify.js +0 -84
  128. package/dist/node_modules/cron-parser/test/fields.js +0 -32
  129. package/dist/node_modules/cron-parser/test/increment_on_first_iteration.js +0 -22
  130. package/dist/node_modules/cron-parser/test/index-ts3.test-d.ts +0 -133
  131. package/dist/node_modules/cron-parser/test/index.test-d.ts +0 -138
  132. package/dist/node_modules/cron-parser/test/leap_year.js +0 -17
  133. package/dist/node_modules/cron-parser/test/parser.js +0 -46
  134. package/dist/node_modules/cron-parser/test/parser_crondate_formats.js +0 -145
  135. package/dist/node_modules/cron-parser/test/parser_day_of_month.js +0 -169
  136. package/dist/node_modules/cron-parser/test/prev_date.js +0 -32
  137. package/dist/node_modules/cron-parser/test/stringify.js +0 -402
  138. package/dist/node_modules/cron-parser/test/timezone.js +0 -422
  139. package/dist/node_modules/cron-parser/types/common.d.ts +0 -131
  140. package/dist/node_modules/cron-parser/types/index.d.ts +0 -45
  141. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +0 -28
  142. package/dist/node_modules/lru-cache/LICENSE +0 -15
  143. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.d.ts +0 -7
  144. package/dist/node_modules/lru-cache/dist/cjs/index-cjs.js +0 -1
  145. package/dist/node_modules/lru-cache/dist/cjs/index.d.ts +0 -807
  146. package/dist/node_modules/lru-cache/dist/cjs/index.js +0 -1334
  147. package/dist/node_modules/lru-cache/dist/cjs/index.min.js +0 -2
  148. package/dist/node_modules/lru-cache/dist/cjs/package.json +0 -3
  149. package/dist/node_modules/lru-cache/dist/mjs/index.d.ts +0 -807
  150. package/dist/node_modules/lru-cache/dist/mjs/index.js +0 -1330
  151. package/dist/node_modules/lru-cache/dist/mjs/index.min.js +0 -2
  152. package/dist/node_modules/lru-cache/dist/mjs/package.json +0 -3
  153. package/dist/node_modules/lru-cache/package.json +0 -1
  154. package/dist/server/Plugin.d.ts +0 -84
  155. package/dist/server/Plugin.js +0 -503
  156. package/dist/server/Processor.d.ts +0 -115
  157. package/dist/server/Processor.js +0 -363
  158. package/dist/server/actions/executions.d.ts +0 -11
  159. package/dist/server/actions/executions.js +0 -96
  160. package/dist/server/actions/index.d.ts +0 -11
  161. package/dist/server/actions/index.js +0 -66
  162. package/dist/server/actions/nodes.d.ts +0 -12
  163. package/dist/server/actions/nodes.js +0 -217
  164. package/dist/server/actions/workflows.d.ts +0 -14
  165. package/dist/server/actions/workflows.js +0 -184
  166. package/dist/server/collections/executions.d.ts +0 -11
  167. package/dist/server/collections/executions.js +0 -66
  168. package/dist/server/collections/flow_nodes.d.ts +0 -11
  169. package/dist/server/collections/flow_nodes.js +0 -87
  170. package/dist/server/collections/jobs.d.ts +0 -11
  171. package/dist/server/collections/jobs.js +0 -66
  172. package/dist/server/collections/workflows.d.ts +0 -10
  173. package/dist/server/collections/workflows.js +0 -126
  174. package/dist/server/constants.d.ts +0 -29
  175. package/dist/server/constants.js +0 -58
  176. package/dist/server/functions/index.d.ts +0 -17
  177. package/dist/server/functions/index.js +0 -40
  178. package/dist/server/index.d.ts +0 -15
  179. package/dist/server/index.js +0 -60
  180. package/dist/server/instructions/CalculationInstruction.d.ts +0 -25
  181. package/dist/server/instructions/CalculationInstruction.js +0 -59
  182. package/dist/server/instructions/ConditionInstruction.d.ts +0 -36
  183. package/dist/server/instructions/ConditionInstruction.js +0 -167
  184. package/dist/server/instructions/CreateInstruction.d.ts +0 -18
  185. package/dist/server/instructions/CreateInstruction.js +0 -75
  186. package/dist/server/instructions/DestroyInstruction.d.ts +0 -18
  187. package/dist/server/instructions/DestroyInstruction.js +0 -59
  188. package/dist/server/instructions/EndInstruction.d.ts +0 -14
  189. package/dist/server/instructions/EndInstruction.js +0 -55
  190. package/dist/server/instructions/QueryInstruction.d.ts +0 -21
  191. package/dist/server/instructions/QueryInstruction.js +0 -82
  192. package/dist/server/instructions/UpdateInstruction.d.ts +0 -18
  193. package/dist/server/instructions/UpdateInstruction.js +0 -59
  194. package/dist/server/instructions/index.d.ts +0 -31
  195. package/dist/server/instructions/index.js +0 -42
  196. package/dist/server/migrations/20221129153547-calculation-variables.d.ts +0 -14
  197. package/dist/server/migrations/20221129153547-calculation-variables.js +0 -92
  198. package/dist/server/migrations/20230221032941-change-request-body-type.d.ts +0 -14
  199. package/dist/server/migrations/20230221032941-change-request-body-type.js +0 -102
  200. package/dist/server/migrations/20230221071831-calculation-expression.d.ts +0 -13
  201. package/dist/server/migrations/20230221071831-calculation-expression.js +0 -121
  202. package/dist/server/migrations/20230221121203-condition-calculation.d.ts +0 -13
  203. package/dist/server/migrations/20230221121203-condition-calculation.js +0 -106
  204. package/dist/server/migrations/20230221162902-jsonb-to-json.d.ts +0 -13
  205. package/dist/server/migrations/20230221162902-jsonb-to-json.js +0 -63
  206. package/dist/server/migrations/20230411034722-manual-multi-form.d.ts +0 -13
  207. package/dist/server/migrations/20230411034722-manual-multi-form.js +0 -283
  208. package/dist/server/migrations/20230612021134-manual-collection-block.d.ts +0 -13
  209. package/dist/server/migrations/20230612021134-manual-collection-block.js +0 -152
  210. package/dist/server/migrations/20230710115902-manual-action-values.d.ts +0 -13
  211. package/dist/server/migrations/20230710115902-manual-action-values.js +0 -101
  212. package/dist/server/migrations/20230809113132-workflow-options.d.ts +0 -13
  213. package/dist/server/migrations/20230809113132-workflow-options.js +0 -64
  214. package/dist/server/migrations/20231024172342-add-node-key.d.ts +0 -13
  215. package/dist/server/migrations/20231024172342-add-node-key.js +0 -90
  216. package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +0 -13
  217. package/dist/server/migrations/20231122143143-split-to-plugins.js +0 -67
  218. package/dist/server/migrations/20240115220721-add-node-key-to-job.d.ts +0 -14
  219. package/dist/server/migrations/20240115220721-add-node-key-to-job.js +0 -63
  220. package/dist/server/migrations/20240613222612-fix-assign-field-config.d.ts +0 -13
  221. package/dist/server/migrations/20240613222612-fix-assign-field-config.js +0 -62
  222. package/dist/server/triggers/CollectionTrigger.d.ts +0 -22
  223. package/dist/server/triggers/CollectionTrigger.js +0 -184
  224. package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.d.ts +0 -39
  225. package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +0 -356
  226. package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.d.ts +0 -21
  227. package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.js +0 -152
  228. package/dist/server/triggers/ScheduleTrigger/index.d.ts +0 -18
  229. package/dist/server/triggers/ScheduleTrigger/index.js +0 -84
  230. package/dist/server/triggers/ScheduleTrigger/utils.d.ts +0 -13
  231. package/dist/server/triggers/ScheduleTrigger/utils.js +0 -44
  232. package/dist/server/triggers/index.d.ts +0 -21
  233. package/dist/server/triggers/index.js +0 -46
  234. package/dist/server/types/Execution.d.ts +0 -25
  235. package/dist/server/types/Execution.js +0 -34
  236. package/dist/server/types/FlowNode.d.ts +0 -24
  237. package/dist/server/types/FlowNode.js +0 -34
  238. package/dist/server/types/Job.d.ts +0 -22
  239. package/dist/server/types/Job.js +0 -34
  240. package/dist/server/types/Workflow.d.ts +0 -35
  241. package/dist/server/types/Workflow.js +0 -34
  242. package/dist/server/types/index.d.ts +0 -12
  243. package/dist/server/types/index.js +0 -24
  244. package/dist/server/utils.d.ts +0 -9
  245. package/dist/server/utils.js +0 -51
  246. package/dist/swagger/index.d.ts +0 -762
  247. package/dist/swagger/index.js +0 -807
@@ -1,115 +0,0 @@
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 { Transaction, Transactionable } from '@nocobase/database';
10
- import { Logger } from '@nocobase/logger';
11
- import type Plugin from './Plugin';
12
- import type { ExecutionModel, FlowNodeModel, JobModel } from './types';
13
- export interface ProcessorOptions extends Transactionable {
14
- plugin: Plugin;
15
- [key: string]: any;
16
- }
17
- export default class Processor {
18
- execution: ExecutionModel;
19
- options: ProcessorOptions;
20
- static StatusMap: {
21
- 0: 0;
22
- 1: 1;
23
- [-1]: -1;
24
- [-2]: -2;
25
- [-3]: -3;
26
- [-4]: -4;
27
- [-5]: -5;
28
- [-6]: -6;
29
- };
30
- logger: Logger;
31
- /**
32
- * @experimental
33
- */
34
- transaction: Transaction;
35
- /**
36
- * @experimental
37
- */
38
- nodes: FlowNodeModel[];
39
- /**
40
- * @experimental
41
- */
42
- nodesMap: Map<number, FlowNodeModel>;
43
- /**
44
- * @experimental
45
- */
46
- jobsMap: Map<number, JobModel>;
47
- /**
48
- * @experimental
49
- */
50
- jobsMapByNodeKey: {
51
- [key: string]: any;
52
- };
53
- /**
54
- * @experimental
55
- */
56
- lastSavedJob: JobModel | null;
57
- constructor(execution: ExecutionModel, options: ProcessorOptions);
58
- private makeNodes;
59
- private makeJobs;
60
- prepare(): Promise<void>;
61
- start(): Promise<void>;
62
- resume(job: JobModel): Promise<void>;
63
- private exec;
64
- run(node: any, input?: any): any;
65
- end(node: any, job: JobModel): Promise<any>;
66
- private recall;
67
- exit(s?: number): Promise<any>;
68
- /**
69
- * @experimental
70
- * @param {JobModel | Record<string, any>} payload
71
- * @returns {JobModel}
72
- */
73
- saveJob(payload: any): Promise<any>;
74
- /**
75
- * @experimental
76
- */
77
- getBranches(node: FlowNodeModel): FlowNodeModel[];
78
- /**
79
- * @experimental
80
- * find the first node in current branch
81
- */
82
- findBranchStartNode(node: FlowNodeModel, parent?: FlowNodeModel): FlowNodeModel | null;
83
- /**
84
- * @experimental
85
- * find the node start current branch
86
- */
87
- findBranchParentNode(node: FlowNodeModel): FlowNodeModel | null;
88
- /**
89
- * @experimental
90
- */
91
- findBranchEndNode(node: FlowNodeModel): FlowNodeModel | null;
92
- /**
93
- * @experimental
94
- */
95
- findBranchParentJob(job: JobModel, node: FlowNodeModel): JobModel | null;
96
- /**
97
- * @experimental
98
- */
99
- findBranchLastJob(node: FlowNodeModel, job: JobModel): JobModel | null;
100
- /**
101
- * @experimental
102
- */
103
- getScope(sourceNodeId: number): {
104
- $context: any;
105
- $jobsMapByNodeKey: {
106
- [key: string]: any;
107
- };
108
- $system: {};
109
- $scopes: {};
110
- };
111
- /**
112
- * @experimental
113
- */
114
- getParsedValue(value: any, sourceNodeId: number, additionalScope?: object): any;
115
- }
@@ -1,363 +0,0 @@
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 Processor_exports = {};
28
- __export(Processor_exports, {
29
- default: () => Processor
30
- });
31
- module.exports = __toCommonJS(Processor_exports);
32
- var import_database = require("@nocobase/database");
33
- var import_evaluators = require("@nocobase/evaluators");
34
- var import_utils = require("@nocobase/utils");
35
- var import_constants = require("./constants");
36
- class Processor {
37
- constructor(execution, options) {
38
- this.execution = execution;
39
- this.options = options;
40
- this.logger = options.plugin.getLogger(execution.workflowId);
41
- this.transaction = options.transaction;
42
- }
43
- static StatusMap = {
44
- [import_constants.JOB_STATUS.PENDING]: import_constants.EXECUTION_STATUS.STARTED,
45
- [import_constants.JOB_STATUS.RESOLVED]: import_constants.EXECUTION_STATUS.RESOLVED,
46
- [import_constants.JOB_STATUS.FAILED]: import_constants.EXECUTION_STATUS.FAILED,
47
- [import_constants.JOB_STATUS.ERROR]: import_constants.EXECUTION_STATUS.ERROR,
48
- [import_constants.JOB_STATUS.ABORTED]: import_constants.EXECUTION_STATUS.ABORTED,
49
- [import_constants.JOB_STATUS.CANCELED]: import_constants.EXECUTION_STATUS.CANCELED,
50
- [import_constants.JOB_STATUS.REJECTED]: import_constants.EXECUTION_STATUS.REJECTED,
51
- [import_constants.JOB_STATUS.RETRY_NEEDED]: import_constants.EXECUTION_STATUS.RETRY_NEEDED
52
- };
53
- logger;
54
- /**
55
- * @experimental
56
- */
57
- transaction;
58
- /**
59
- * @experimental
60
- */
61
- nodes = [];
62
- /**
63
- * @experimental
64
- */
65
- nodesMap = /* @__PURE__ */ new Map();
66
- /**
67
- * @experimental
68
- */
69
- jobsMap = /* @__PURE__ */ new Map();
70
- /**
71
- * @experimental
72
- */
73
- jobsMapByNodeKey = {};
74
- /**
75
- * @experimental
76
- */
77
- lastSavedJob = null;
78
- // make dual linked nodes list then cache
79
- makeNodes(nodes = []) {
80
- this.nodes = nodes;
81
- nodes.forEach((node) => {
82
- this.nodesMap.set(node.id, node);
83
- });
84
- nodes.forEach((node) => {
85
- if (node.upstreamId) {
86
- node.upstream = this.nodesMap.get(node.upstreamId);
87
- }
88
- if (node.downstreamId) {
89
- node.downstream = this.nodesMap.get(node.downstreamId);
90
- }
91
- });
92
- }
93
- makeJobs(jobs) {
94
- jobs.forEach((job) => {
95
- this.jobsMap.set(job.id, job);
96
- const node = this.nodesMap.get(job.nodeId);
97
- this.jobsMapByNodeKey[node.key] = job.result;
98
- });
99
- }
100
- async prepare() {
101
- const {
102
- execution,
103
- transaction,
104
- options: { plugin }
105
- } = this;
106
- if (!execution.workflow) {
107
- execution.workflow = plugin.enabledCache.get(execution.workflowId);
108
- }
109
- const nodes = await execution.workflow.getNodes({ transaction });
110
- this.makeNodes(nodes);
111
- const jobs = await execution.getJobs({
112
- order: [["id", "ASC"]],
113
- transaction
114
- });
115
- this.makeJobs(jobs);
116
- }
117
- async start() {
118
- const { execution } = this;
119
- if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
120
- throw new Error(`execution was ended with status ${execution.status} before, could not be started again`);
121
- }
122
- await this.prepare();
123
- if (this.nodes.length) {
124
- const head = this.nodes.find((item) => !item.upstream);
125
- await this.run(head, { result: execution.context });
126
- } else {
127
- await this.exit(import_constants.JOB_STATUS.RESOLVED);
128
- }
129
- }
130
- async resume(job) {
131
- const { execution } = this;
132
- if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
133
- throw new Error(`execution was ended with status ${execution.status} before, could not be resumed`);
134
- }
135
- await this.prepare();
136
- const node = this.nodesMap.get(job.nodeId);
137
- await this.recall(node, job);
138
- }
139
- async exec(instruction, node, prevJob) {
140
- let job;
141
- try {
142
- this.logger.info(`execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id})`);
143
- this.logger.debug(`config of node`, { data: node.config });
144
- job = await instruction(node, prevJob, this);
145
- if (!job) {
146
- return null;
147
- }
148
- } catch (err) {
149
- this.logger.error(
150
- `execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) failed: `,
151
- { error: err }
152
- );
153
- job = {
154
- result: err instanceof Error ? {
155
- message: err.message,
156
- ...err
157
- } : err,
158
- status: import_constants.JOB_STATUS.ERROR
159
- };
160
- if (prevJob && prevJob.nodeId === node.id) {
161
- prevJob.set(job);
162
- job = prevJob;
163
- }
164
- }
165
- if (!(job instanceof import_database.Model)) {
166
- job.upstreamId = prevJob instanceof import_database.Model ? prevJob.get("id") : null;
167
- job.nodeId = node.id;
168
- job.nodeKey = node.key;
169
- }
170
- const savedJob = await this.saveJob(job);
171
- this.logger.info(
172
- `execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) finished as status: ${savedJob.status}`
173
- );
174
- this.logger.debug(`result of node`, { data: savedJob.result });
175
- if (savedJob.status === import_constants.JOB_STATUS.RESOLVED && node.downstream) {
176
- this.logger.debug(`run next node (${node.downstreamId})`);
177
- return this.run(node.downstream, savedJob);
178
- }
179
- return this.end(node, savedJob);
180
- }
181
- async run(node, input) {
182
- const { instructions } = this.options.plugin;
183
- const instruction = instructions.get(node.type);
184
- if (typeof instruction.run !== "function") {
185
- return Promise.reject(new Error("`run` should be implemented for customized execution of the node"));
186
- }
187
- return this.exec(instruction.run.bind(instruction), node, input);
188
- }
189
- // parent node should take over the control
190
- async end(node, job) {
191
- this.logger.debug(`branch ended at node (${node.id})`);
192
- const parentNode = this.findBranchParentNode(node);
193
- if (parentNode) {
194
- this.logger.debug(`not on main, recall to parent entry node (${node.id})})`);
195
- await this.recall(parentNode, job);
196
- return job;
197
- }
198
- return this.exit(job.status);
199
- }
200
- async recall(node, job) {
201
- const { instructions } = this.options.plugin;
202
- const instruction = instructions.get(node.type);
203
- if (typeof instruction.resume !== "function") {
204
- return Promise.reject(
205
- new Error(`"resume" method should be implemented for [${node.type}] instruction of node (#${node.id})`)
206
- );
207
- }
208
- return this.exec(instruction.resume.bind(instruction), node, job);
209
- }
210
- async exit(s) {
211
- if (typeof s === "number") {
212
- const status = this.constructor.StatusMap[s] ?? Math.sign(s);
213
- await this.execution.update({ status }, { transaction: this.transaction });
214
- }
215
- this.logger.info(`execution (${this.execution.id}) exiting with status ${this.execution.status}`);
216
- return null;
217
- }
218
- // TODO(optimize)
219
- /**
220
- * @experimental
221
- * @param {JobModel | Record<string, any>} payload
222
- * @returns {JobModel}
223
- */
224
- async saveJob(payload) {
225
- const { database } = this.execution.constructor;
226
- const { transaction } = this;
227
- const { model } = database.getCollection("jobs");
228
- let job;
229
- if (payload instanceof model) {
230
- job = await payload.save({ transaction });
231
- } else if (payload.id) {
232
- job = await model.findByPk(payload.id, { transaction });
233
- await job.update(payload, { transaction });
234
- } else {
235
- job = await model.create(
236
- {
237
- ...payload,
238
- executionId: this.execution.id
239
- },
240
- { transaction }
241
- );
242
- }
243
- this.jobsMap.set(job.id, job);
244
- this.lastSavedJob = job;
245
- this.jobsMapByNodeKey[job.nodeKey] = job.result;
246
- return job;
247
- }
248
- /**
249
- * @experimental
250
- */
251
- getBranches(node) {
252
- return this.nodes.filter((item) => item.upstream === node && item.branchIndex !== null).sort((a, b) => Number(a.branchIndex) - Number(b.branchIndex));
253
- }
254
- /**
255
- * @experimental
256
- * find the first node in current branch
257
- */
258
- findBranchStartNode(node, parent) {
259
- for (let n = node; n; n = n.upstream) {
260
- if (!parent) {
261
- if (n.branchIndex !== null) {
262
- return n;
263
- }
264
- } else {
265
- if (n.upstream === parent) {
266
- return n;
267
- }
268
- }
269
- }
270
- return null;
271
- }
272
- /**
273
- * @experimental
274
- * find the node start current branch
275
- */
276
- findBranchParentNode(node) {
277
- for (let n = node; n; n = n.upstream) {
278
- if (n.branchIndex !== null) {
279
- return n.upstream;
280
- }
281
- }
282
- return null;
283
- }
284
- /**
285
- * @experimental
286
- */
287
- findBranchEndNode(node) {
288
- for (let n = node; n; n = n.downstream) {
289
- if (!n.downstream) {
290
- return n;
291
- }
292
- }
293
- return null;
294
- }
295
- /**
296
- * @experimental
297
- */
298
- findBranchParentJob(job, node) {
299
- for (let j = job; j; j = this.jobsMap.get(j.upstreamId)) {
300
- if (j.nodeId === node.id) {
301
- return j;
302
- }
303
- }
304
- return null;
305
- }
306
- /**
307
- * @experimental
308
- */
309
- findBranchLastJob(node, job) {
310
- const allJobs = Array.from(this.jobsMap.values());
311
- const branchJobs = [];
312
- for (let n = this.findBranchEndNode(node); n && n !== node.upstream; n = n.upstream) {
313
- branchJobs.push(...allJobs.filter((item) => item.nodeId === n.id));
314
- }
315
- branchJobs.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
316
- for (let i = branchJobs.length - 1; i >= 0; i -= 1) {
317
- for (let j = branchJobs[i]; j && j.id !== job.id; j = this.jobsMap.get(j.upstreamId)) {
318
- if (j.upstreamId === job.id) {
319
- return branchJobs[i];
320
- }
321
- }
322
- }
323
- return null;
324
- }
325
- /**
326
- * @experimental
327
- */
328
- getScope(sourceNodeId) {
329
- const node = this.nodesMap.get(sourceNodeId);
330
- const systemFns = {};
331
- const scope = {
332
- execution: this.execution,
333
- node
334
- };
335
- for (const [name, fn] of this.options.plugin.functions.getEntities()) {
336
- systemFns[name] = fn.bind(scope);
337
- }
338
- const $scopes = {};
339
- for (let n = this.findBranchParentNode(node); n; n = this.findBranchParentNode(n)) {
340
- const instruction = this.options.plugin.instructions.get(n.type);
341
- if (typeof instruction.getScope === "function") {
342
- $scopes[n.id] = $scopes[n.key] = instruction.getScope(n, this.jobsMapByNodeKey[n.key], this);
343
- }
344
- }
345
- return {
346
- $context: this.execution.context,
347
- $jobsMapByNodeKey: this.jobsMapByNodeKey,
348
- $system: systemFns,
349
- $scopes
350
- };
351
- }
352
- /**
353
- * @experimental
354
- */
355
- getParsedValue(value, sourceNodeId, additionalScope) {
356
- const template = (0, import_utils.parse)(value);
357
- const scope = Object.assign(this.getScope(sourceNodeId), additionalScope);
358
- template.parameters.forEach(({ key }) => {
359
- (0, import_evaluators.appendArrayColumn)(scope, key);
360
- });
361
- return template(scope);
362
- }
363
- }
@@ -1,11 +0,0 @@
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 destroy(context: Context, next: any): Promise<void>;
11
- export declare function cancel(context: Context, next: any): Promise<never>;
@@ -1,96 +0,0 @@
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 executions_exports = {};
38
- __export(executions_exports, {
39
- cancel: () => cancel,
40
- destroy: () => destroy
41
- });
42
- module.exports = __toCommonJS(executions_exports);
43
- var import_actions = __toESM(require("@nocobase/actions"));
44
- var import_database = require("@nocobase/database");
45
- var import_constants = require("../constants");
46
- async function destroy(context, next) {
47
- context.action.mergeParams({
48
- filter: {
49
- status: {
50
- [import_database.Op.ne]: import_constants.EXECUTION_STATUS.STARTED
51
- }
52
- }
53
- });
54
- await import_actions.default.destroy(context, next);
55
- }
56
- async function cancel(context, next) {
57
- const { filterByTk } = context.action.params;
58
- const ExecutionRepo = context.db.getRepository("executions");
59
- const JobRepo = context.db.getRepository("jobs");
60
- const execution = await ExecutionRepo.findOne({
61
- filterByTk,
62
- appends: ["jobs"]
63
- });
64
- if (!execution) {
65
- return context.throw(404);
66
- }
67
- if (execution.status) {
68
- return context.throw(400);
69
- }
70
- await context.db.sequelize.transaction(async (transaction) => {
71
- await execution.update(
72
- {
73
- status: import_constants.EXECUTION_STATUS.CANCELED
74
- },
75
- { transaction }
76
- );
77
- const pendingJobs = execution.jobs.filter((job) => job.status === import_constants.JOB_STATUS.PENDING);
78
- await JobRepo.update({
79
- values: {
80
- status: import_constants.JOB_STATUS.CANCELED
81
- },
82
- filter: {
83
- id: pendingJobs.map((job) => job.id)
84
- },
85
- individualHooks: false,
86
- transaction
87
- });
88
- });
89
- context.body = execution;
90
- await next();
91
- }
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
94
- cancel,
95
- destroy
96
- });
@@ -1,11 +0,0 @@
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
- export default function ({ app }: {
10
- app: any;
11
- }): void;
@@ -1,66 +0,0 @@
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 actions_exports = {};
38
- __export(actions_exports, {
39
- default: () => actions_default
40
- });
41
- module.exports = __toCommonJS(actions_exports);
42
- var workflows = __toESM(require("./workflows"));
43
- var nodes = __toESM(require("./nodes"));
44
- var executions = __toESM(require("./executions"));
45
- function make(name, mod) {
46
- return Object.keys(mod).reduce(
47
- (result, key) => ({
48
- ...result,
49
- [`${name}:${key}`]: mod[key]
50
- }),
51
- {}
52
- );
53
- }
54
- function actions_default({ app }) {
55
- app.actions({
56
- ...make("workflows", workflows),
57
- ...make("workflows.nodes", {
58
- create: nodes.create
59
- }),
60
- ...make("flow_nodes", {
61
- update: nodes.update,
62
- destroy: nodes.destroy
63
- }),
64
- ...make("executions", executions)
65
- });
66
- }
@@ -1,12 +0,0 @@
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 create(context: Context, next: any): Promise<void>;
11
- export declare function destroy(context: Context, next: any): Promise<void>;
12
- export declare function update(context: Context, next: any): Promise<void>;