@nocobase/plugin-workflow 0.7.0-alpha.4 → 0.7.0-alpha.56
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/actions/index.js +31 -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 +3 -0
- package/lib/actions/workflows.js +271 -0
- package/lib/calculators/index.js +143 -91
- package/lib/collections/executions.js +40 -38
- package/lib/collections/flow_nodes.js +60 -72
- package/lib/collections/jobs.js +45 -47
- package/lib/collections/workflows.js +78 -63
- package/lib/constants.js +22 -17
- package/lib/index.js +71 -22
- package/lib/instructions/calculation.js +34 -29
- package/lib/instructions/condition.js +94 -87
- package/lib/instructions/create.d.ts +1 -1
- package/lib/instructions/create.js +43 -25
- package/lib/instructions/destroy.js +42 -25
- package/lib/instructions/index.js +46 -25
- package/lib/instructions/parallel.js +99 -84
- package/lib/instructions/prompt.js +21 -13
- package/lib/instructions/query.js +47 -25
- package/lib/instructions/update.d.ts +2 -1
- package/lib/instructions/update.js +44 -25
- package/lib/models/Execution.d.ts +3 -2
- package/lib/models/Execution.js +400 -241
- package/lib/models/FlowNode.js +18 -5
- package/lib/models/Job.js +18 -5
- package/lib/models/Workflow.d.ts +3 -1
- package/lib/models/Workflow.js +132 -72
- package/lib/server.js +93 -66
- package/{esm/triggers/model.d.ts → lib/triggers/collection.d.ts} +1 -1
- package/lib/triggers/collection.js +125 -0
- package/lib/triggers/index.js +25 -11
- package/package.json +7 -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.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.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,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
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
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'workflows',
|
|
9
|
+
model: 'WorkflowModel',
|
|
10
|
+
title: '自动化',
|
|
11
|
+
fields: [{
|
|
12
|
+
name: 'key',
|
|
13
|
+
type: 'uid'
|
|
14
|
+
}, {
|
|
15
|
+
interface: 'string',
|
|
16
|
+
type: 'string',
|
|
17
|
+
name: 'title',
|
|
18
|
+
title: '工作流名称',
|
|
19
|
+
required: true
|
|
20
|
+
}, {
|
|
21
|
+
interface: 'boolean',
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
name: 'enabled',
|
|
24
|
+
title: '启用',
|
|
25
|
+
defaultValue: false
|
|
26
|
+
}, {
|
|
27
|
+
interface: 'textarea',
|
|
28
|
+
type: 'text',
|
|
29
|
+
name: 'description',
|
|
30
|
+
title: '描述'
|
|
31
|
+
}, {
|
|
32
|
+
interface: 'select',
|
|
33
|
+
type: 'string',
|
|
34
|
+
title: '触发方式',
|
|
35
|
+
name: 'type',
|
|
36
|
+
required: true
|
|
37
|
+
}, {
|
|
38
|
+
interface: 'json',
|
|
39
|
+
type: 'jsonb',
|
|
40
|
+
title: '触发配置',
|
|
41
|
+
name: 'config',
|
|
42
|
+
required: true,
|
|
43
|
+
defaultValue: {}
|
|
44
|
+
}, {
|
|
45
|
+
interface: 'boolean',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
title: '使用事务',
|
|
48
|
+
name: 'useTransaction',
|
|
49
|
+
defaultValue: true
|
|
50
|
+
}, {
|
|
51
|
+
interface: 'linkTo',
|
|
52
|
+
type: 'hasMany',
|
|
53
|
+
name: 'nodes',
|
|
54
|
+
target: 'flow_nodes',
|
|
55
|
+
title: '流程节点'
|
|
56
|
+
}, {
|
|
57
|
+
interface: 'linkTo',
|
|
58
|
+
type: 'hasMany',
|
|
59
|
+
name: 'executions',
|
|
60
|
+
target: 'executions',
|
|
61
|
+
title: '触发执行'
|
|
62
|
+
}, {
|
|
63
|
+
type: 'boolean',
|
|
64
|
+
name: 'executed',
|
|
65
|
+
defaultValue: false
|
|
66
|
+
}, {
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
name: 'current',
|
|
69
|
+
defaultValue: false
|
|
70
|
+
}, {
|
|
71
|
+
type: 'hasMany',
|
|
72
|
+
name: 'revisions',
|
|
73
|
+
target: 'workflows',
|
|
74
|
+
foreignKey: 'key',
|
|
75
|
+
sourceKey: 'key',
|
|
76
|
+
// NOTE: no constraints needed here because tricky self-referencing
|
|
77
|
+
constraints: false
|
|
78
|
+
}]
|
|
64
79
|
};
|
|
65
|
-
|
|
80
|
+
exports.default = _default;
|
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.js
CHANGED
|
@@ -1,23 +1,72 @@
|
|
|
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 _server.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
var _constants = require("./constants");
|
|
15
|
+
|
|
16
|
+
Object.keys(_constants).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] === _constants[key]) return;
|
|
20
|
+
Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _constants[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
var _calculators = require("./calculators");
|
|
29
|
+
|
|
30
|
+
Object.keys(_calculators).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] === _calculators[key]) return;
|
|
34
|
+
Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function get() {
|
|
37
|
+
return _calculators[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
var _triggers = require("./triggers");
|
|
43
|
+
|
|
44
|
+
Object.keys(_triggers).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] === _triggers[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _triggers[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var _instructions = require("./instructions");
|
|
57
|
+
|
|
58
|
+
Object.keys(_instructions).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] === _instructions[key]) return;
|
|
62
|
+
Object.defineProperty(exports, key, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function get() {
|
|
65
|
+
return _instructions[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var _server = _interopRequireDefault(require("./server"));
|
|
71
|
+
|
|
72
|
+
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,24 @@ 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(prevJob, execution) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
|
|
46
|
+
return _asyncToGenerator(function* () {
|
|
47
|
+
const _ref = _this.config || {},
|
|
48
|
+
calculation = _ref.calculation;
|
|
49
|
+
|
|
50
|
+
const result = calculation ? (0, _calculators.calculate)({
|
|
51
|
+
type: '$calculation',
|
|
52
|
+
options: execution.getParsedValue(calculation)
|
|
53
|
+
}, prevJob, execution) : null;
|
|
54
|
+
return {
|
|
55
|
+
result,
|
|
56
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
};
|
|
57
|
-
|
|
62
|
+
exports.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: {
|
|
@@ -58,63 +45,83 @@ const constants_1 = require("../constants");
|
|
|
58
45
|
// }
|
|
59
46
|
// }
|
|
60
47
|
function logicCalculate(calculation, input, execution) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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, execution));
|
|
59
|
+
} else {
|
|
60
|
+
const args = calculation.operands.map(operand => (0, _calculators.calculate)(operand, input, execution));
|
|
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(prevJob, execution) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
|
|
78
|
+
return _asyncToGenerator(function* () {
|
|
79
|
+
// TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution
|
|
80
|
+
// const jobs = await execution.getJobs();
|
|
81
|
+
const _ref = _this.config || {},
|
|
82
|
+
calculation = _ref.calculation,
|
|
83
|
+
rejectOnFalse = _ref.rejectOnFalse;
|
|
84
|
+
|
|
85
|
+
const result = logicCalculate(calculation, prevJob, execution);
|
|
86
|
+
|
|
87
|
+
if (!result && rejectOnFalse) {
|
|
88
|
+
return {
|
|
89
|
+
status: _constants.JOB_STATUS.REJECTED,
|
|
90
|
+
result
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const job = {
|
|
95
|
+
status: _constants.JOB_STATUS.RESOLVED,
|
|
96
|
+
result,
|
|
97
|
+
// TODO(optimize): try unify the building of job
|
|
98
|
+
nodeId: _this.id,
|
|
99
|
+
upstreamId: prevJob && prevJob.id || null
|
|
100
|
+
};
|
|
101
|
+
const branchNode = execution.nodes.find(item => item.upstream === _this && Boolean(item.branchIndex) === result);
|
|
102
|
+
|
|
103
|
+
if (!branchNode) {
|
|
104
|
+
return job;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const savedJob = yield execution.saveJob(job);
|
|
108
|
+
return execution.run(branchNode, savedJob);
|
|
109
|
+
})();
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
resume(branchJob, execution) {
|
|
113
|
+
var _this2 = this;
|
|
114
|
+
|
|
115
|
+
return _asyncToGenerator(function* () {
|
|
116
|
+
if (branchJob.status === _constants.JOB_STATUS.RESOLVED) {
|
|
117
|
+
// return to continue this.downstream
|
|
118
|
+
return branchJob;
|
|
119
|
+
} // pass control to upper scope by ending current scope
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
return execution.end(_this2, branchJob);
|
|
123
|
+
})();
|
|
124
|
+
}
|
|
125
|
+
|
|
119
126
|
};
|
|
120
|
-
|
|
127
|
+
exports.default = _default;
|
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("../constants");
|
|
9
|
+
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
run(input, execution) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
|
|
24
|
+
return _asyncToGenerator(function* () {
|
|
25
|
+
const _this$config = _this.config,
|
|
26
|
+
collection = _this$config.collection,
|
|
27
|
+
_this$config$params = _this$config.params,
|
|
28
|
+
params = _this$config$params === void 0 ? {} : _this$config$params;
|
|
29
|
+
|
|
30
|
+
const repo = _this.constructor.database.getRepository(collection);
|
|
31
|
+
|
|
32
|
+
const options = execution.getParsedValue(params);
|
|
33
|
+
const result = yield repo.create(_objectSpread(_objectSpread({}, options), {}, {
|
|
34
|
+
transaction: execution.tx
|
|
35
|
+
}));
|
|
36
|
+
return {
|
|
37
|
+
// NOTE: get() for non-proxied instance (#380)
|
|
38
|
+
result: result.get(),
|
|
39
|
+
status: _constants.JOB_STATUS.RESOLVED
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
}
|
|
43
|
+
|
|
10
44
|
};
|
|
11
|
-
|
|
12
|
-
const constants_1 = require("../constants");
|
|
13
|
-
exports.default = {
|
|
14
|
-
run(input, execution) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const { collection, params = {} } = this.config;
|
|
17
|
-
const repo = this.constructor.database.getRepository(collection);
|
|
18
|
-
const options = execution.getParsedValue(params);
|
|
19
|
-
const result = yield repo.create(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
|
|
20
|
-
return {
|
|
21
|
-
result,
|
|
22
|
-
status: constants_1.JOB_STATUS.RESOLVED
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=create.js.map
|
|
45
|
+
exports.default = _default;
|