@nocobase/plugin-workflow-loop 2.0.0-alpha.3 → 2.0.0-alpha.5

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.
package/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ # Limit of workflow loops executed in one loop node
2
+ # By default, no limit
3
+ # WORKFLOW_LOOP_LIMIT=100
@@ -13,9 +13,9 @@ module.exports = {
13
13
  "antd": "5.24.2",
14
14
  "@formily/antd-v5": "1.2.3",
15
15
  "@formily/react": "2.3.7",
16
- "@nocobase/client": "2.0.0-alpha.3",
17
- "@nocobase/plugin-workflow": "2.0.0-alpha.3",
16
+ "@nocobase/client": "2.0.0-alpha.5",
17
+ "@nocobase/plugin-workflow": "2.0.0-alpha.5",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/evaluators": "2.0.0-alpha.3",
20
- "@nocobase/server": "2.0.0-alpha.3"
19
+ "@nocobase/evaluators": "2.0.0-alpha.5",
20
+ "@nocobase/server": "2.0.0-alpha.5"
21
21
  };
@@ -42,6 +42,10 @@ module.exports = __toCommonJS(LoopInstruction_exports);
42
42
  var import_evaluators = __toESM(require("@nocobase/evaluators"));
43
43
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
44
44
  var import_constants = require("../constants");
45
+ function getLoopLimit() {
46
+ const limit = process.env.WORKFLOW_LOOP_LIMIT;
47
+ return limit ? parseInt(limit, 10) : null;
48
+ }
45
49
  function getTargetLength(target) {
46
50
  let length = 0;
47
51
  if (typeof target === "number") {
@@ -153,8 +157,15 @@ class LoopInstruction_default extends import_plugin_workflow.Instruction {
153
157
  job.changed("result", true);
154
158
  processor.saveJob(job);
155
159
  if (result.looped < length) {
156
- await processor.run(branch, job);
157
- return;
160
+ const loopLimit = getLoopLimit();
161
+ if (!loopLimit || result.done < loopLimit) {
162
+ await processor.run(branch, job);
163
+ return;
164
+ }
165
+ job.set({
166
+ status: import_plugin_workflow.JOB_STATUS.ERROR,
167
+ result: { ...result, exceeded: true }
168
+ });
158
169
  } else {
159
170
  job.set({
160
171
  status: import_plugin_workflow.JOB_STATUS.RESOLVED
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:循环节点",
5
5
  "description": "Used to repeat the sub-process processing of each value in an array, and can also be used for fixed times of sub-process processing.",
6
6
  "description.zh-CN": "用于对一个数组中的每个值进行重复的子流程处理,也可用于固定次数的重复子流程处理。",
7
- "version": "2.0.0-alpha.3",
7
+ "version": "2.0.0-alpha.5",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-loop",
@@ -22,7 +22,7 @@
22
22
  "@nocobase/server": "2.x",
23
23
  "@nocobase/test": "2.x"
24
24
  },
25
- "gitHead": "8efc23aa78058d871e98a91419f3c4a61762cc15",
25
+ "gitHead": "943e035bbec27f9ecfe8ce8857955945f20976f3",
26
26
  "keywords": [
27
27
  "Workflow"
28
28
  ]