@nocobase/plugin-workflow 0.7.0-alpha.9 → 0.7.1-alpha.6
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/Plugin.d.ts +18 -0
- package/lib/Plugin.js +285 -0
- package/lib/Processor.d.ts +40 -0
- package/lib/Processor.js +440 -0
- package/lib/actions/index.d.ts +3 -1
- package/lib/actions/index.js +33 -26
- package/{esm/actions/flow_nodes.d.ts → lib/actions/nodes.d.ts} +1 -0
- package/lib/actions/nodes.js +321 -0
- package/lib/actions/workflows.d.ts +2 -0
- package/lib/actions/workflows.js +197 -0
- package/lib/calculators/index.d.ts +2 -2
- package/lib/calculators/index.js +144 -92
- package/lib/collections/executions.js +32 -38
- package/lib/collections/flow_nodes.js +60 -72
- package/lib/collections/jobs.js +26 -47
- package/lib/collections/workflows.d.ts +1 -2
- package/lib/collections/workflows.js +70 -63
- package/lib/constants.js +22 -17
- package/lib/index.d.ts +4 -3
- package/lib/index.js +85 -22
- package/lib/instructions/calculation.d.ts +1 -1
- package/lib/instructions/calculation.js +32 -29
- package/lib/instructions/condition.d.ts +2 -2
- package/lib/instructions/condition.js +91 -88
- package/lib/instructions/create.d.ts +2 -2
- package/lib/instructions/create.js +39 -25
- package/lib/instructions/delay.d.ts +14 -0
- package/lib/instructions/delay.js +138 -0
- package/lib/instructions/destroy.d.ts +1 -1
- package/lib/instructions/destroy.js +38 -25
- package/lib/instructions/index.d.ts +11 -8
- package/lib/instructions/index.js +76 -25
- package/lib/instructions/parallel.d.ts +3 -3
- package/lib/instructions/parallel.js +95 -84
- package/lib/instructions/prompt.d.ts +2 -2
- package/lib/instructions/prompt.js +21 -13
- package/lib/instructions/query.d.ts +2 -1
- package/lib/instructions/query.js +42 -25
- package/lib/instructions/update.d.ts +2 -1
- package/lib/instructions/update.js +40 -25
- package/lib/models/Execution.d.ts +3 -33
- package/lib/models/Execution.js +18 -254
- package/lib/models/FlowNode.js +18 -5
- package/lib/models/Job.js +18 -5
- package/lib/models/Workflow.d.ts +5 -6
- package/lib/models/Workflow.js +18 -76
- package/lib/triggers/collection.d.ts +12 -0
- package/lib/triggers/collection.js +184 -0
- package/lib/triggers/index.d.ts +11 -7
- package/lib/triggers/index.js +64 -11
- package/lib/triggers/schedule.d.ts +38 -0
- package/lib/triggers/schedule.js +672 -0
- package/package.json +8 -12
- package/esm/actions/flow_nodes.js +0 -139
- package/esm/actions/flow_nodes.js.map +0 -1
- package/esm/actions/index.d.ts +0 -1
- package/esm/actions/index.js +0 -8
- package/esm/actions/index.js.map +0 -1
- package/esm/calculators/index.d.ts +0 -38
- package/esm/calculators/index.js +0 -128
- package/esm/calculators/index.js.map +0 -1
- package/esm/collections/executions.d.ts +0 -3
- package/esm/collections/executions.js +0 -38
- package/esm/collections/executions.js.map +0 -1
- package/esm/collections/flow_nodes.d.ts +0 -3
- package/esm/collections/flow_nodes.js +0 -72
- package/esm/collections/flow_nodes.js.map +0 -1
- package/esm/collections/jobs.d.ts +0 -3
- package/esm/collections/jobs.js +0 -47
- package/esm/collections/jobs.js.map +0 -1
- package/esm/collections/workflows.d.ts +0 -3
- package/esm/collections/workflows.js +0 -63
- package/esm/collections/workflows.js.map +0 -1
- package/esm/constants.d.ts +0 -17
- package/esm/constants.js +0 -18
- package/esm/constants.js.map +0 -1
- package/esm/index.d.ts +0 -5
- package/esm/index.js +0 -6
- package/esm/index.js.map +0 -1
- package/esm/instructions/calculation.d.ts +0 -8
- package/esm/instructions/calculation.js +0 -55
- package/esm/instructions/calculation.js.map +0 -1
- package/esm/instructions/condition.d.ts +0 -5
- package/esm/instructions/condition.js +0 -99
- package/esm/instructions/condition.js.map +0 -1
- package/esm/instructions/create.d.ts +0 -8
- package/esm/instructions/create.js +0 -25
- package/esm/instructions/create.js.map +0 -1
- package/esm/instructions/destroy.d.ts +0 -8
- package/esm/instructions/destroy.js +0 -25
- package/esm/instructions/destroy.js.map +0 -1
- package/esm/instructions/index.d.ts +0 -15
- package/esm/instructions/index.js +0 -20
- package/esm/instructions/index.js.map +0 -1
- package/esm/instructions/parallel.d.ts +0 -13
- package/esm/instructions/parallel.js +0 -88
- package/esm/instructions/parallel.js.map +0 -1
- package/esm/instructions/prompt.d.ts +0 -7
- package/esm/instructions/prompt.js +0 -13
- package/esm/instructions/prompt.js.map +0 -1
- package/esm/instructions/query.d.ts +0 -8
- package/esm/instructions/query.js +0 -25
- package/esm/instructions/query.js.map +0 -1
- package/esm/instructions/update.d.ts +0 -8
- package/esm/instructions/update.js +0 -25
- package/esm/instructions/update.js.map +0 -1
- package/esm/models/Execution.d.ts +0 -50
- package/esm/models/Execution.js +0 -250
- package/esm/models/Execution.js.map +0 -1
- package/esm/models/FlowNode.d.ts +0 -17
- package/esm/models/FlowNode.js +0 -4
- package/esm/models/FlowNode.js.map +0 -1
- package/esm/models/Job.d.ts +0 -15
- package/esm/models/Job.js +0 -4
- package/esm/models/Job.js.map +0 -1
- package/esm/models/Workflow.d.ts +0 -27
- package/esm/models/Workflow.js +0 -72
- package/esm/models/Workflow.js.map +0 -1
- package/esm/server.d.ts +0 -5
- package/esm/server.js +0 -62
- package/esm/server.js.map +0 -1
- package/esm/triggers/index.d.ts +0 -9
- package/esm/triggers/index.js +0 -6
- package/esm/triggers/index.js.map +0 -1
- package/esm/triggers/model.d.ts +0 -12
- package/esm/triggers/model.js +0 -47
- package/esm/triggers/model.js.map +0 -1
- package/lib/actions/flow_nodes.d.ts +0 -3
- package/lib/actions/flow_nodes.js +0 -163
- package/lib/actions/flow_nodes.js.map +0 -1
- package/lib/actions/index.js.map +0 -1
- package/lib/calculators/index.js.map +0 -1
- package/lib/collections/executions.js.map +0 -1
- package/lib/collections/flow_nodes.js.map +0 -1
- package/lib/collections/jobs.js.map +0 -1
- package/lib/collections/workflows.js.map +0 -1
- package/lib/constants.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/instructions/calculation.js.map +0 -1
- package/lib/instructions/condition.js.map +0 -1
- package/lib/instructions/create.js.map +0 -1
- package/lib/instructions/destroy.js.map +0 -1
- package/lib/instructions/index.js.map +0 -1
- package/lib/instructions/parallel.js.map +0 -1
- package/lib/instructions/prompt.js.map +0 -1
- package/lib/instructions/query.js.map +0 -1
- package/lib/instructions/update.js.map +0 -1
- package/lib/models/Execution.js.map +0 -1
- package/lib/models/FlowNode.js.map +0 -1
- package/lib/models/Job.js.map +0 -1
- package/lib/models/Workflow.js.map +0 -1
- package/lib/server.d.ts +0 -5
- package/lib/server.js +0 -68
- package/lib/server.js.map +0 -1
- package/lib/triggers/index.js.map +0 -1
- package/lib/triggers/model.d.ts +0 -12
- package/lib/triggers/model.js +0 -49
- package/lib/triggers/model.js.map +0 -1
- package/tsconfig.build.json +0 -9
|
@@ -1,65 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
|
|
8
|
+
function _default() {
|
|
9
|
+
return {
|
|
4
10
|
name: 'workflows',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
11
|
+
fields: [{
|
|
12
|
+
name: 'key',
|
|
13
|
+
type: 'uid'
|
|
14
|
+
}, {
|
|
15
|
+
type: 'string',
|
|
16
|
+
name: 'title',
|
|
17
|
+
required: true
|
|
18
|
+
}, {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
name: 'enabled',
|
|
21
|
+
defaultValue: false
|
|
22
|
+
}, {
|
|
23
|
+
type: 'text',
|
|
24
|
+
name: 'description'
|
|
25
|
+
}, {
|
|
26
|
+
type: 'string',
|
|
27
|
+
name: 'type',
|
|
28
|
+
required: true
|
|
29
|
+
}, {
|
|
30
|
+
type: 'jsonb',
|
|
31
|
+
name: 'config',
|
|
32
|
+
required: true,
|
|
33
|
+
defaultValue: {}
|
|
34
|
+
}, {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
name: 'useTransaction',
|
|
37
|
+
defaultValue: true
|
|
38
|
+
}, {
|
|
39
|
+
type: 'hasMany',
|
|
40
|
+
name: 'nodes',
|
|
41
|
+
target: 'flow_nodes'
|
|
42
|
+
}, {
|
|
43
|
+
type: 'hasMany',
|
|
44
|
+
name: 'executions'
|
|
45
|
+
}, {
|
|
46
|
+
type: 'integer',
|
|
47
|
+
name: 'executed',
|
|
48
|
+
defaultValue: 0
|
|
49
|
+
}, {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
name: 'allExecuted',
|
|
52
|
+
defaultValue: 0
|
|
53
|
+
}, {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
name: 'current',
|
|
56
|
+
defaultValue: null
|
|
57
|
+
}, {
|
|
58
|
+
type: 'hasMany',
|
|
59
|
+
name: 'revisions',
|
|
60
|
+
target: 'workflows',
|
|
61
|
+
foreignKey: 'key',
|
|
62
|
+
sourceKey: 'key',
|
|
63
|
+
// NOTE: no constraints needed here because tricky self-referencing
|
|
64
|
+
constraints: false
|
|
65
|
+
}],
|
|
66
|
+
// NOTE: use unique index for avoiding deadlock in mysql when setCurrent
|
|
67
|
+
indexes: [{
|
|
68
|
+
unique: true,
|
|
69
|
+
fields: ['key', 'current']
|
|
70
|
+
}]
|
|
71
|
+
};
|
|
72
|
+
}
|
package/lib/constants.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JOB_STATUS = exports.EXECUTION_STATUS = exports.BRANCH_INDEX = void 0;
|
|
7
|
+
const EXECUTION_STATUS = {
|
|
8
|
+
STARTED: 0,
|
|
9
|
+
RESOLVED: 1,
|
|
10
|
+
REJECTED: -1,
|
|
11
|
+
CANCELLED: -2
|
|
9
12
|
};
|
|
10
|
-
exports.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
exports.EXECUTION_STATUS = EXECUTION_STATUS;
|
|
14
|
+
const JOB_STATUS = {
|
|
15
|
+
PENDING: 0,
|
|
16
|
+
RESOLVED: 1,
|
|
17
|
+
REJECTED: -1,
|
|
18
|
+
CANCELLED: -2
|
|
15
19
|
};
|
|
16
|
-
exports.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
exports.JOB_STATUS = JOB_STATUS;
|
|
21
|
+
const BRANCH_INDEX = {
|
|
22
|
+
DEFAULT: null,
|
|
23
|
+
ON_TRUE: 1,
|
|
24
|
+
ON_FALSE: 0
|
|
20
25
|
};
|
|
21
|
-
|
|
26
|
+
exports.BRANCH_INDEX = BRANCH_INDEX;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
1
|
export * from './calculators';
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './constants';
|
|
4
3
|
export * from './instructions';
|
|
5
|
-
export
|
|
4
|
+
export * from './triggers';
|
|
5
|
+
export * from './Processor';
|
|
6
|
+
export { default } from './Plugin';
|
package/lib/index.js
CHANGED
|
@@ -1,23 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {};
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _Plugin.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
var _calculators = require("./calculators");
|
|
15
|
+
|
|
16
|
+
Object.keys(_calculators).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
+
if (key in exports && exports[key] === _calculators[key]) return;
|
|
20
|
+
Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _calculators[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
var _constants = require("./constants");
|
|
29
|
+
|
|
30
|
+
Object.keys(_constants).forEach(function (key) {
|
|
31
|
+
if (key === "default" || key === "__esModule") return;
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
33
|
+
if (key in exports && exports[key] === _constants[key]) return;
|
|
34
|
+
Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function get() {
|
|
37
|
+
return _constants[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
var _instructions = require("./instructions");
|
|
43
|
+
|
|
44
|
+
Object.keys(_instructions).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _instructions[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _instructions[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var _triggers = require("./triggers");
|
|
57
|
+
|
|
58
|
+
Object.keys(_triggers).forEach(function (key) {
|
|
59
|
+
if (key === "default" || key === "__esModule") return;
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
61
|
+
if (key in exports && exports[key] === _triggers[key]) return;
|
|
62
|
+
Object.defineProperty(exports, key, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function get() {
|
|
65
|
+
return _triggers[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var _Processor = require("./Processor");
|
|
71
|
+
|
|
72
|
+
Object.keys(_Processor).forEach(function (key) {
|
|
73
|
+
if (key === "default" || key === "__esModule") return;
|
|
74
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
75
|
+
if (key in exports && exports[key] === _Processor[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function get() {
|
|
79
|
+
return _Processor[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
var _Plugin = _interopRequireDefault(require("./Plugin"));
|
|
85
|
+
|
|
86
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
var _calculators = require("../calculators");
|
|
11
|
+
|
|
12
|
+
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); } }
|
|
13
|
+
|
|
14
|
+
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); }); }; }
|
|
15
|
+
|
|
14
16
|
// @calculation: {
|
|
15
17
|
// calculator: 'concat',
|
|
16
18
|
// operands: [
|
|
@@ -37,21 +39,22 @@ const calculators_1 = require("../calculators");
|
|
|
37
39
|
// }
|
|
38
40
|
// ]
|
|
39
41
|
// }
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
var _default = {
|
|
43
|
+
run(node, prevJob, processor) {
|
|
44
|
+
return _asyncToGenerator(function* () {
|
|
45
|
+
const _ref = node.config || {},
|
|
46
|
+
calculation = _ref.calculation;
|
|
47
|
+
|
|
48
|
+
const result = calculation ? (0, _calculators.calculate)({
|
|
49
|
+
type: '$calculation',
|
|
50
|
+
options: processor.getParsedValue(calculation)
|
|
51
|
+
}, prevJob, processor) : null;
|
|
52
|
+
return {
|
|
53
|
+
result,
|
|
54
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
55
|
+
};
|
|
56
|
+
})();
|
|
57
|
+
}
|
|
58
|
+
|
|
56
59
|
};
|
|
57
|
-
|
|
60
|
+
exports.default = _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
run(
|
|
3
|
-
resume(
|
|
2
|
+
run(node: any, prevJob: any, processor: any): Promise<any>;
|
|
3
|
+
resume(node: any, branchJob: any, processor: any): Promise<any>;
|
|
4
4
|
};
|
|
5
5
|
export default _default;
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
13
5
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
const calculators_1 = __importStar(require("../calculators"));
|
|
32
|
-
const constants_1 = require("../constants");
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _calculators = _interopRequireWildcard(require("../calculators"));
|
|
9
|
+
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
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); } }
|
|
17
|
+
|
|
18
|
+
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); }); }; }
|
|
19
|
+
|
|
33
20
|
// @calculation: {
|
|
34
21
|
// not: false,
|
|
35
22
|
// group: {
|
|
@@ -57,64 +44,80 @@ const constants_1 = require("../constants");
|
|
|
57
44
|
// ]
|
|
58
45
|
// }
|
|
59
46
|
// }
|
|
60
|
-
function logicCalculate(calculation, input,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
47
|
+
function logicCalculate(calculation, input, processor) {
|
|
48
|
+
if (!calculation) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const not = calculation.not,
|
|
53
|
+
group = calculation.group;
|
|
54
|
+
let result;
|
|
55
|
+
|
|
56
|
+
if (group) {
|
|
57
|
+
const method = group.type === 'and' ? 'every' : 'some';
|
|
58
|
+
result = group.calculations[method](item => logicCalculate(item, input, processor));
|
|
59
|
+
} else {
|
|
60
|
+
const args = calculation.operands.map(operand => (0, _calculators.calculate)(operand, input, processor));
|
|
61
|
+
|
|
62
|
+
const fn = _calculators.default.get(calculation.calculator);
|
|
63
|
+
|
|
64
|
+
if (!fn) {
|
|
65
|
+
throw new Error(`no calculator function registered for "${calculation.calculator}"`);
|
|
69
66
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
result = fn(...args);
|
|
77
|
-
}
|
|
78
|
-
return not ? !result : result;
|
|
67
|
+
|
|
68
|
+
result = fn(...args);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return not ? !result : result;
|
|
79
72
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
73
|
+
|
|
74
|
+
var _default = {
|
|
75
|
+
run(node, prevJob, processor) {
|
|
76
|
+
return _asyncToGenerator(function* () {
|
|
77
|
+
// TODO(optimize): loading of jobs could be reduced and turned into incrementally in processor
|
|
78
|
+
// const jobs = await processor.getJobs();
|
|
79
|
+
const _ref = node.config || {},
|
|
80
|
+
calculation = _ref.calculation,
|
|
81
|
+
rejectOnFalse = _ref.rejectOnFalse;
|
|
82
|
+
|
|
83
|
+
const result = logicCalculate(calculation, prevJob, processor);
|
|
84
|
+
|
|
85
|
+
if (!result && rejectOnFalse) {
|
|
86
|
+
return {
|
|
87
|
+
status: _constants.JOB_STATUS.REJECTED,
|
|
88
|
+
result
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const job = {
|
|
93
|
+
status: _constants.JOB_STATUS.RESOLVED,
|
|
94
|
+
result,
|
|
95
|
+
// TODO(optimize): try unify the building of job
|
|
96
|
+
nodeId: node.id,
|
|
97
|
+
upstreamId: prevJob && prevJob.id || null
|
|
98
|
+
};
|
|
99
|
+
const branchNode = processor.nodes.find(item => item.upstream === node && Boolean(item.branchIndex) === result);
|
|
100
|
+
|
|
101
|
+
if (!branchNode) {
|
|
102
|
+
return job;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const savedJob = yield processor.saveJob(job);
|
|
106
|
+
return processor.run(branchNode, savedJob);
|
|
107
|
+
})();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
resume(node, branchJob, processor) {
|
|
111
|
+
return _asyncToGenerator(function* () {
|
|
112
|
+
if (branchJob.status === _constants.JOB_STATUS.RESOLVED) {
|
|
113
|
+
// return to continue node.downstream
|
|
114
|
+
return branchJob;
|
|
115
|
+
} // pass control to upper scope by ending current scope
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
return processor.end(node, branchJob);
|
|
119
|
+
})();
|
|
120
|
+
}
|
|
121
|
+
|
|
119
122
|
};
|
|
120
|
-
|
|
123
|
+
exports.default = _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import FlowNodeModel from "../models/FlowNode";
|
|
2
2
|
declare const _default: {
|
|
3
|
-
run(
|
|
4
|
-
result:
|
|
3
|
+
run(node: FlowNodeModel, input: any, processor: any): Promise<{
|
|
4
|
+
result: any;
|
|
5
5
|
status: number;
|
|
6
6
|
}>;
|
|
7
7
|
};
|