@nocobase/plugin-workflow 0.9.3-alpha.1 → 0.9.4-alpha.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.
- package/lib/client/CanvasContent.d.ts +4 -0
- package/lib/client/CanvasContent.js +49 -0
- package/lib/client/ExecutionCanvas.js +110 -44
- package/lib/client/WorkflowCanvas.js +35 -18
- package/lib/client/components/CollectionFieldset.js +2 -2
- package/lib/client/components/NodeDescription.d.ts +2 -0
- package/lib/client/components/NodeDescription.js +59 -0
- package/lib/client/components/ValueBlock.d.ts +5 -0
- package/lib/client/components/ValueBlock.js +110 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +12 -0
- package/lib/client/locale/es-ES.d.ts +130 -0
- package/lib/client/locale/es-ES.js +136 -0
- package/lib/client/locale/zh-CN.d.ts +35 -6
- package/lib/client/locale/zh-CN.js +35 -6
- package/lib/client/nodes/aggregate.d.ts +186 -0
- package/lib/client/nodes/aggregate.js +349 -0
- package/lib/client/nodes/calculation.d.ts +2 -1
- package/lib/client/nodes/calculation.js +28 -53
- package/lib/client/nodes/condition.d.ts +2 -6
- package/lib/client/nodes/condition.js +4 -3
- package/lib/client/nodes/create.d.ts +5 -3
- package/lib/client/nodes/create.js +16 -7
- package/lib/client/nodes/delay.d.ts +1 -0
- package/lib/client/nodes/delay.js +1 -0
- package/lib/client/nodes/destroy.d.ts +2 -2
- package/lib/client/nodes/destroy.js +1 -0
- package/lib/client/nodes/index.d.ts +5 -2
- package/lib/client/nodes/index.js +95 -97
- package/lib/client/nodes/loop.d.ts +29 -0
- package/lib/client/nodes/loop.js +165 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +8 -6
- package/lib/client/nodes/manual/index.d.ts +6 -1
- package/lib/client/nodes/manual/index.js +6 -1
- package/lib/client/nodes/parallel.d.ts +1 -0
- package/lib/client/nodes/parallel.js +2 -1
- package/lib/client/nodes/query.d.ts +12 -3
- package/lib/client/nodes/query.js +24 -17
- package/lib/client/nodes/request.d.ts +1 -0
- package/lib/client/nodes/request.js +1 -0
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -0
- package/lib/client/schemas/collection.d.ts +1 -2
- package/lib/client/schemas/collection.js +5 -6
- package/lib/client/style.d.ts +1 -0
- package/lib/client/style.js +40 -26
- package/lib/client/triggers/collection.d.ts +2 -11
- package/lib/client/triggers/collection.js +6 -7
- package/lib/client/triggers/index.d.ts +1 -1
- package/lib/client/triggers/index.js +5 -3
- package/lib/client/triggers/schedule/index.d.ts +3 -1
- package/lib/client/triggers/schedule/index.js +6 -4
- package/lib/client/variable.d.ts +27 -1
- package/lib/client/variable.js +65 -34
- package/lib/server/Plugin.js +2 -14
- package/lib/server/Processor.d.ts +3 -0
- package/lib/server/Processor.js +30 -3
- package/lib/server/actions/workflows.js +2 -2
- package/lib/server/collections/workflows.js +2 -1
- package/lib/server/instructions/aggregate.d.ts +9 -0
- package/lib/server/instructions/aggregate.js +57 -0
- package/lib/server/instructions/calculation.js +1 -1
- package/lib/server/instructions/condition.js +1 -1
- package/lib/server/instructions/create.js +1 -1
- package/lib/server/instructions/destroy.js +1 -1
- package/lib/server/instructions/index.d.ts +1 -0
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/loop.d.ts +16 -0
- package/lib/server/instructions/loop.js +107 -0
- package/lib/server/instructions/parallel.js +17 -10
- package/lib/server/instructions/query.js +1 -4
- package/lib/server/instructions/request.js +1 -1
- package/lib/server/instructions/update.js +1 -1
- package/package.json +13 -13
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _constants = require("../constants");
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
+
function getTargetLength(target) {
|
|
17
|
+
let length = 0;
|
|
18
|
+
if (typeof target === 'number') {
|
|
19
|
+
if (target < 0) {
|
|
20
|
+
throw new Error('Loop target in number type must be greater than 0');
|
|
21
|
+
}
|
|
22
|
+
length = Math.floor(target);
|
|
23
|
+
} else {
|
|
24
|
+
const targets = (Array.isArray(target) ? target : [target]).filter(t => t != null);
|
|
25
|
+
length = targets.length;
|
|
26
|
+
}
|
|
27
|
+
return length;
|
|
28
|
+
}
|
|
29
|
+
var _default = {
|
|
30
|
+
run(node, prevJob, processor) {
|
|
31
|
+
return _asyncToGenerator(function* () {
|
|
32
|
+
var _prevJob$id;
|
|
33
|
+
const _processor$getBranche = processor.getBranches(node),
|
|
34
|
+
_processor$getBranche2 = _slicedToArray(_processor$getBranche, 1),
|
|
35
|
+
branch = _processor$getBranche2[0];
|
|
36
|
+
const target = processor.getParsedValue(node.config.target, node);
|
|
37
|
+
const length = getTargetLength(target);
|
|
38
|
+
if (!branch || !length) {
|
|
39
|
+
return {
|
|
40
|
+
status: _constants.JOB_STATUS.RESOLVED,
|
|
41
|
+
result: 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const job = yield processor.saveJob({
|
|
45
|
+
status: _constants.JOB_STATUS.PENDING,
|
|
46
|
+
// save loop index
|
|
47
|
+
result: 0,
|
|
48
|
+
nodeId: node.id,
|
|
49
|
+
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
50
|
+
});
|
|
51
|
+
// TODO: add loop scope to stack
|
|
52
|
+
// processor.stack.push({
|
|
53
|
+
// label: node.title,
|
|
54
|
+
// value: node.id
|
|
55
|
+
// });
|
|
56
|
+
yield processor.run(branch, job);
|
|
57
|
+
return null;
|
|
58
|
+
})();
|
|
59
|
+
},
|
|
60
|
+
resume(node, branchJob, processor) {
|
|
61
|
+
return _asyncToGenerator(function* () {
|
|
62
|
+
const job = processor.findBranchParentJob(branchJob, node);
|
|
63
|
+
const loop = processor.nodesMap.get(job.nodeId);
|
|
64
|
+
const _processor$getBranche3 = processor.getBranches(node),
|
|
65
|
+
_processor$getBranche4 = _slicedToArray(_processor$getBranche3, 1),
|
|
66
|
+
branch = _processor$getBranche4[0];
|
|
67
|
+
const result = job.result,
|
|
68
|
+
status = job.status;
|
|
69
|
+
// if loop has been done (resolved / rejected), do not care newly executed branch jobs.
|
|
70
|
+
if (status !== _constants.JOB_STATUS.PENDING) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const nextIndex = result + 1;
|
|
74
|
+
const target = processor.getParsedValue(loop.config.target, node);
|
|
75
|
+
// branchJob.status === JOB_STATUS.RESOLVED means branchJob is done, try next loop or exit as resolved
|
|
76
|
+
if (branchJob.status > _constants.JOB_STATUS.PENDING) {
|
|
77
|
+
job.set({
|
|
78
|
+
result: nextIndex
|
|
79
|
+
});
|
|
80
|
+
const length = getTargetLength(target);
|
|
81
|
+
if (nextIndex < length) {
|
|
82
|
+
yield processor.saveJob(job);
|
|
83
|
+
yield processor.run(branch, job);
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// branchJob.status < JOB_STATUS.PENDING means branchJob is rejected, any rejection should cause loop rejected
|
|
88
|
+
job.set({
|
|
89
|
+
status: branchJob.status
|
|
90
|
+
});
|
|
91
|
+
return job;
|
|
92
|
+
})();
|
|
93
|
+
},
|
|
94
|
+
getScope(node, index, processor) {
|
|
95
|
+
const target = processor.getParsedValue(node.config.target, node);
|
|
96
|
+
const targets = (Array.isArray(target) ? target : [target]).filter(t => t != null);
|
|
97
|
+
const length = getTargetLength(target);
|
|
98
|
+
const item = typeof target === 'number' ? index : targets[index];
|
|
99
|
+
const result = {
|
|
100
|
+
item,
|
|
101
|
+
index,
|
|
102
|
+
length
|
|
103
|
+
};
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.default = _default;
|
|
@@ -77,13 +77,20 @@ var _default = {
|
|
|
77
77
|
// another benifit of this is, it could handle sequenced branches in future.
|
|
78
78
|
const _node$config$mode = node.config.mode,
|
|
79
79
|
mode = _node$config$mode === void 0 ? PARALLEL_MODE.ALL : _node$config$mode;
|
|
80
|
-
yield branches.reduce((promise, branch, i) => promise.then(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
yield branches.reduce((promise, branch, i) => promise.then( /*#__PURE__*/function () {
|
|
81
|
+
var _ref = _asyncToGenerator(function* (previous) {
|
|
82
|
+
if (i && !Modes[mode].next(previous)) {
|
|
83
|
+
return previous;
|
|
84
|
+
}
|
|
85
|
+
yield processor.run(branch, job);
|
|
86
|
+
// find last job of the branch
|
|
87
|
+
return processor.findBranchLastJob(branch);
|
|
88
|
+
});
|
|
89
|
+
return function (_x) {
|
|
90
|
+
return _ref.apply(this, arguments);
|
|
91
|
+
};
|
|
92
|
+
}()), Promise.resolve());
|
|
93
|
+
return null;
|
|
87
94
|
})();
|
|
88
95
|
},
|
|
89
96
|
resume(node, branchJob, processor) {
|
|
@@ -100,9 +107,9 @@ var _default = {
|
|
|
100
107
|
const branchStartNode = processor.findBranchStartNode(jobNode, node);
|
|
101
108
|
const branches = processor.getBranches(node);
|
|
102
109
|
const branchIndex = branches.indexOf(branchStartNode);
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
mode =
|
|
110
|
+
const _ref2 = node.config || {},
|
|
111
|
+
_ref2$mode = _ref2.mode,
|
|
112
|
+
mode = _ref2$mode === void 0 ? PARALLEL_MODE.ALL : _ref2$mode;
|
|
106
113
|
const newResult = [...result.slice(0, branchIndex), branchJob.status, ...result.slice(branchIndex + 1)];
|
|
107
114
|
job.set({
|
|
108
115
|
result: newResult,
|
|
@@ -23,11 +23,8 @@ var _default = {
|
|
|
23
23
|
_node$config$failOnEm = _node$config.failOnEmpty,
|
|
24
24
|
failOnEmpty = _node$config$failOnEm === void 0 ? false : _node$config$failOnEm;
|
|
25
25
|
const repo = node.constructor.database.getRepository(collection);
|
|
26
|
-
const options = processor.getParsedValue(params);
|
|
26
|
+
const options = processor.getParsedValue(params, node);
|
|
27
27
|
const result = yield (multiple ? repo.find : repo.findOne).call(repo, _objectSpread(_objectSpread({}, options), {}, {
|
|
28
|
-
context: {
|
|
29
|
-
executionId: processor.execution.id
|
|
30
|
-
},
|
|
31
28
|
transaction: processor.transaction
|
|
32
29
|
}));
|
|
33
30
|
if (failOnEmpty && (multiple ? !result.length : !result)) {
|
|
@@ -64,7 +64,7 @@ class _default {
|
|
|
64
64
|
status: _constants.JOB_STATUS.PENDING,
|
|
65
65
|
nodeId: node.id
|
|
66
66
|
});
|
|
67
|
-
const config = processor.getParsedValue(node.config);
|
|
67
|
+
const config = processor.getParsedValue(node.config, node);
|
|
68
68
|
request(config).then(response => {
|
|
69
69
|
job.set({
|
|
70
70
|
status: _constants.JOB_STATUS.RESOLVED,
|
|
@@ -22,7 +22,7 @@ var _default = {
|
|
|
22
22
|
_node$config$params = _node$config.params,
|
|
23
23
|
params = _node$config$params === void 0 ? {} : _node$config$params;
|
|
24
24
|
const repo = node.constructor.database.getRepository(collection);
|
|
25
|
-
const options = processor.getParsedValue(params);
|
|
25
|
+
const options = processor.getParsedValue(params, node);
|
|
26
26
|
const result = yield repo.update(_objectSpread(_objectSpread({}, options), {}, {
|
|
27
27
|
context: {
|
|
28
28
|
executionId: processor.execution.id
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "0.9.
|
|
10
|
-
"@nocobase/client": "0.9.
|
|
11
|
-
"@nocobase/database": "0.9.
|
|
12
|
-
"@nocobase/evaluators": "0.9.
|
|
13
|
-
"@nocobase/logger": "0.9.
|
|
14
|
-
"@nocobase/resourcer": "0.9.
|
|
15
|
-
"@nocobase/server": "0.9.
|
|
16
|
-
"@nocobase/utils": "0.9.
|
|
17
|
-
"antd": "4.
|
|
9
|
+
"@nocobase/actions": "0.9.4-alpha.1",
|
|
10
|
+
"@nocobase/client": "0.9.4-alpha.1",
|
|
11
|
+
"@nocobase/database": "0.9.4-alpha.1",
|
|
12
|
+
"@nocobase/evaluators": "0.9.4-alpha.1",
|
|
13
|
+
"@nocobase/logger": "0.9.4-alpha.1",
|
|
14
|
+
"@nocobase/resourcer": "0.9.4-alpha.1",
|
|
15
|
+
"@nocobase/server": "0.9.4-alpha.1",
|
|
16
|
+
"@nocobase/utils": "0.9.4-alpha.1",
|
|
17
|
+
"antd": "^4.24.8",
|
|
18
18
|
"axios": "^0.27.2",
|
|
19
19
|
"classnames": "^2.3.1",
|
|
20
20
|
"cron-parser": "4.4.0",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"react-js-cron": "^3.1.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@nocobase/plugin-formula-field": "0.9.
|
|
27
|
-
"@nocobase/test": "0.9.
|
|
26
|
+
"@nocobase/plugin-formula-field": "0.9.4-alpha.1",
|
|
27
|
+
"@nocobase/test": "0.9.4-alpha.1",
|
|
28
28
|
"@types/ejs": "^3.1.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "0b4936be557be918dbdf8196dadcbc7eb395906d"
|
|
31
31
|
}
|