@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-alpha.2
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/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/lib/client/AddButton.d.ts +1 -1
- package/lib/client/AddButton.js +43 -27
- package/lib/client/Branch.d.ts +1 -1
- package/lib/client/ExecutionCanvas.js +5 -10
- package/lib/client/WorkflowCanvas.js +12 -42
- package/lib/client/WorkflowProvider.js +10 -1
- package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
- package/lib/client/components/CollectionBlockInitializer.js +81 -0
- package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
- package/lib/client/components/CollectionFieldInitializers.js +89 -0
- package/lib/client/components/CollectionFieldset.js +25 -33
- package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
- package/lib/client/components/FilterDynamicComponent.js +43 -0
- package/lib/client/components/NullRender.d.ts +1 -0
- package/lib/client/components/NullRender.js +10 -0
- package/lib/client/components/RadioWithTooltip.d.ts +7 -0
- package/lib/client/components/RadioWithTooltip.js +94 -0
- package/lib/client/constants.d.ts +10 -8
- package/lib/client/constants.js +52 -14
- package/lib/client/index.d.ts +0 -1
- package/lib/client/index.js +1 -10
- package/lib/client/locale/en-US.d.ts +18 -18
- package/lib/client/locale/en-US.js +19 -19
- package/lib/client/locale/zh-CN.d.ts +47 -20
- package/lib/client/locale/zh-CN.js +48 -21
- package/lib/client/nodes/calculation.d.ts +39 -7
- package/lib/client/nodes/calculation.js +165 -19
- package/lib/client/nodes/condition.d.ts +67 -4
- package/lib/client/nodes/condition.js +283 -31
- package/lib/client/nodes/create.d.ts +10 -10
- package/lib/client/nodes/create.js +28 -42
- package/lib/client/nodes/delay.d.ts +4 -4
- package/lib/client/nodes/delay.js +10 -8
- package/lib/client/nodes/destroy.d.ts +4 -7
- package/lib/client/nodes/destroy.js +4 -5
- package/lib/client/nodes/index.d.ts +10 -2
- package/lib/client/nodes/index.js +217 -110
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
- package/lib/client/nodes/manual/AssigneesSelect.js +65 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
- package/lib/client/nodes/manual/ModeConfig.js +160 -0
- package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
- package/lib/client/nodes/manual/SchemaConfig.js +715 -0
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
- package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
- package/lib/client/nodes/manual/index.d.ts +62 -0
- package/lib/client/nodes/manual/index.js +137 -0
- package/lib/client/nodes/parallel.d.ts +12 -7
- package/lib/client/nodes/parallel.js +32 -39
- package/lib/client/nodes/query.d.ts +11 -19
- package/lib/client/nodes/query.js +40 -47
- package/lib/client/nodes/request.d.ts +77 -42
- package/lib/client/nodes/request.js +123 -69
- package/lib/client/nodes/update.d.ts +33 -29
- package/lib/client/nodes/update.js +14 -7
- package/lib/client/schemas/collection.d.ts +0 -3
- package/lib/client/schemas/collection.js +2 -7
- package/lib/client/schemas/executions.js +1 -1
- package/lib/client/schemas/workflows.js +1 -1
- package/lib/client/style.js +51 -9
- package/lib/client/triggers/collection.d.ts +44 -15
- package/lib/client/triggers/collection.js +104 -82
- package/lib/client/triggers/index.d.ts +6 -3
- package/lib/client/triggers/index.js +167 -74
- package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -3
- package/lib/client/triggers/schedule/ScheduleConfig.js +15 -17
- package/lib/client/triggers/schedule/index.d.ts +7 -6
- package/lib/client/triggers/schedule/index.js +39 -81
- package/lib/client/utils.d.ts +1 -0
- package/lib/client/utils.js +38 -0
- package/lib/client/variable.d.ts +21 -0
- package/lib/client/variable.js +147 -0
- package/lib/server/Plugin.d.ts +3 -3
- package/lib/server/Plugin.js +12 -21
- package/lib/server/Processor.d.ts +9 -2
- package/lib/server/Processor.js +33 -33
- package/lib/server/actions/index.js +2 -4
- package/lib/server/actions/workflows.d.ts +1 -0
- package/lib/server/actions/workflows.js +80 -23
- package/lib/server/collections/executions.js +5 -7
- package/lib/server/collections/flow_nodes.js +6 -18
- package/lib/server/collections/jobs.js +3 -1
- package/lib/server/collections/workflows.js +8 -4
- package/lib/server/constants.d.ts +9 -3
- package/lib/server/constants.js +11 -5
- package/lib/server/functions/index.d.ts +4 -0
- package/lib/server/functions/index.js +38 -0
- package/lib/server/index.d.ts +0 -1
- package/lib/server/index.js +0 -14
- package/lib/server/instructions/calculation.d.ts +2 -7
- package/lib/server/instructions/calculation.js +32 -37
- package/lib/server/instructions/condition.d.ts +4 -4
- package/lib/server/instructions/condition.js +126 -54
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/manual/actions.js +101 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
- package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
- package/lib/server/instructions/manual/index.d.ts +25 -0
- package/lib/server/instructions/manual/index.js +200 -0
- package/lib/server/instructions/parallel.js +11 -7
- package/lib/server/instructions/request.d.ts +5 -4
- package/lib/server/instructions/request.js +60 -79
- package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
- package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
- package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
- package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
- package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
- package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
- package/lib/server/triggers/schedule.js +11 -3
- package/package.json +10 -10
- package/lib/client/calculators.d.ts +0 -89
- package/lib/client/calculators.js +0 -668
- package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
- package/lib/client/components/CollectionFieldSelect.js +0 -106
- package/lib/client/components/EjsTextArea.d.ts +0 -2
- package/lib/client/components/EjsTextArea.js +0 -232
- package/lib/server/actions/jobs.d.ts +0 -2
- package/lib/server/actions/jobs.js +0 -39
- package/lib/server/calculators/index.d.ts +0 -40
- package/lib/server/calculators/index.js +0 -187
- package/lib/server/extensions/assignees/actions.js +0 -75
- package/lib/server/extensions/assignees/index.d.ts +0 -2
- package/lib/server/extensions/assignees/index.js +0 -273
- package/lib/server/extensions/index.d.ts +0 -3
- package/lib/server/extensions/index.js +0 -13
- package/lib/server/instructions/prompt.d.ts +0 -19
- package/lib/server/instructions/prompt.js +0 -131
- /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
- /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
|
@@ -5,16 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
function _ejs() {
|
|
9
|
-
const data = require("ejs");
|
|
10
|
-
|
|
11
|
-
_ejs = function _ejs() {
|
|
12
|
-
return data;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
function _axios() {
|
|
19
9
|
const data = _interopRequireDefault(require("axios"));
|
|
20
10
|
|
|
@@ -33,91 +23,82 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
33
23
|
|
|
34
24
|
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); }); }; }
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
function request(_x) {
|
|
27
|
+
return _request.apply(this, arguments);
|
|
28
|
+
}
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
function _request() {
|
|
31
|
+
_request = _asyncToGenerator(function* (config) {
|
|
32
|
+
var _config$headers, _config$params;
|
|
33
|
+
|
|
34
|
+
// default headers
|
|
35
|
+
const url = config.url,
|
|
36
|
+
_config$method = config.method,
|
|
37
|
+
method = _config$method === void 0 ? 'POST' : _config$method,
|
|
38
|
+
data = config.data,
|
|
39
|
+
_config$timeout = config.timeout,
|
|
40
|
+
timeout = _config$timeout === void 0 ? 5000 : _config$timeout;
|
|
41
|
+
const headers = ((_config$headers = config.headers) !== null && _config$headers !== void 0 ? _config$headers : []).reduce((result, header) => {
|
|
42
|
+
if (header.name.toLowerCase() === 'content-type') {
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const templateVars = {
|
|
45
|
-
node: processor.jobsMapByNodeId,
|
|
46
|
-
ctx: processor.execution.context,
|
|
47
|
-
$jobsMapByNodeId: processor.jobsMapByNodeId,
|
|
48
|
-
$context: processor.execution.context
|
|
49
|
-
};
|
|
50
|
-
const requestConfig = node.config; // default headers
|
|
51
|
-
|
|
52
|
-
const headers = {
|
|
53
|
-
'Content-Type': 'application/json'
|
|
54
|
-
};
|
|
55
|
-
const _requestConfig$header = requestConfig.headers,
|
|
56
|
-
headerArr = _requestConfig$header === void 0 ? [] : _requestConfig$header,
|
|
57
|
-
_requestConfig$method = requestConfig.method,
|
|
58
|
-
method = _requestConfig$method === void 0 ? 'POST' : _requestConfig$method,
|
|
59
|
-
_requestConfig$timeou = requestConfig.timeout,
|
|
60
|
-
timeout = _requestConfig$timeou === void 0 ? 5000 : _requestConfig$timeou;
|
|
61
|
-
headerArr.forEach(header => headers[header.name] = header.value);
|
|
62
|
-
let url, data;
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
url = yield (0, _ejs().render)(requestConfig.url.trim(), templateVars, {
|
|
66
|
-
async: true
|
|
67
|
-
});
|
|
68
|
-
data = requestConfig.data ? yield (0, _ejs().render)(requestConfig.data.trim(), templateVars, {
|
|
69
|
-
async: true
|
|
70
|
-
}) : undefined;
|
|
71
|
-
} catch (error2) {
|
|
72
|
-
// console.error(error2);
|
|
73
|
-
job.set({
|
|
74
|
-
status: _constants.JOB_STATUS.REJECTED,
|
|
75
|
-
result: error2.message
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
const response = yield _axios().default.request({
|
|
81
|
-
url,
|
|
82
|
-
method,
|
|
83
|
-
headers,
|
|
84
|
-
data,
|
|
85
|
-
timeout
|
|
86
|
-
});
|
|
87
|
-
job.set({
|
|
88
|
-
status: _constants.JOB_STATUS.RESOLVED,
|
|
89
|
-
result: response.data
|
|
90
|
-
});
|
|
91
|
-
} catch (error1) {
|
|
92
|
-
// console.error('axios error?', error1);
|
|
93
|
-
job.set({
|
|
94
|
-
status: _constants.JOB_STATUS.REJECTED,
|
|
95
|
-
result: error1.isAxiosError ? error1.toJSON() : error1.message
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return _this.plugin.resume(job);
|
|
46
|
+
return Object.assign(result, {
|
|
47
|
+
[header.name]: header.value
|
|
100
48
|
});
|
|
49
|
+
}, {});
|
|
50
|
+
const params = ((_config$params = config.params) !== null && _config$params !== void 0 ? _config$params : []).reduce((result, param) => Object.assign(result, {
|
|
51
|
+
[param.name]: param.value
|
|
52
|
+
}), {}); // TODO(feat): only support JSON type for now, should support others in future
|
|
53
|
+
|
|
54
|
+
headers['Content-Type'] = 'application/json';
|
|
55
|
+
return _axios().default.request({
|
|
56
|
+
url,
|
|
57
|
+
method,
|
|
58
|
+
headers,
|
|
59
|
+
params,
|
|
60
|
+
data,
|
|
61
|
+
timeout
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
return _request.apply(this, arguments);
|
|
65
|
+
}
|
|
101
66
|
|
|
102
|
-
|
|
103
|
-
return _ref.apply(this, arguments);
|
|
104
|
-
};
|
|
105
|
-
}();
|
|
67
|
+
;
|
|
106
68
|
|
|
69
|
+
class _default {
|
|
70
|
+
constructor(plugin) {
|
|
71
|
+
this.plugin = void 0;
|
|
107
72
|
this.plugin = plugin;
|
|
108
73
|
}
|
|
109
74
|
|
|
110
75
|
run(node, input, processor) {
|
|
111
|
-
var
|
|
76
|
+
var _this = this;
|
|
112
77
|
|
|
113
78
|
return _asyncToGenerator(function* () {
|
|
114
79
|
const job = yield processor.saveJob({
|
|
115
80
|
status: _constants.JOB_STATUS.PENDING,
|
|
116
81
|
nodeId: node.id
|
|
117
82
|
});
|
|
118
|
-
|
|
119
|
-
|
|
83
|
+
const config = processor.getParsedValue(node.config);
|
|
84
|
+
request(config).then(response => {
|
|
85
|
+
job.set({
|
|
86
|
+
status: _constants.JOB_STATUS.RESOLVED,
|
|
87
|
+
result: response.data
|
|
88
|
+
});
|
|
89
|
+
}).catch(error => {
|
|
90
|
+
job.set({
|
|
91
|
+
status: _constants.JOB_STATUS.FAILED,
|
|
92
|
+
result: error.isAxiosError ? error.toJSON() : error.message
|
|
93
|
+
});
|
|
94
|
+
}).finally(() => {
|
|
95
|
+
_this.plugin.app.logger.info(`[Workflow] request (#${node.id}) response received, status: ${job.get('status')}`);
|
|
96
|
+
|
|
97
|
+
_this.plugin.resume(job);
|
|
120
98
|
});
|
|
99
|
+
|
|
100
|
+
_this.plugin.app.logger.info(`[Workflow] request (#${node.id}) sent to "${config.url}", waiting for response...`);
|
|
101
|
+
|
|
121
102
|
return job;
|
|
122
103
|
})();
|
|
123
104
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _server() {
|
|
9
|
+
const data = require("@nocobase/server");
|
|
10
|
+
|
|
11
|
+
_server = function _server() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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); } }
|
|
25
|
+
|
|
26
|
+
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); }); }; }
|
|
27
|
+
|
|
28
|
+
const EJS_RE = /"?<%=\s*(ctx|node)([\w\.\[\]-]+)\s*.*%>"?/;
|
|
29
|
+
|
|
30
|
+
function migrateData(input) {
|
|
31
|
+
if (typeof input !== 'string') {
|
|
32
|
+
return input;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!input) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const typeMap = {
|
|
40
|
+
ctx: '$context',
|
|
41
|
+
node: '$jobsMapByNodeId'
|
|
42
|
+
};
|
|
43
|
+
return input.replace(EJS_RE, (_, type, path) => {
|
|
44
|
+
if (type === 'ctx') {
|
|
45
|
+
return `"{{$context${path}}}"`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (type === 'node') {
|
|
49
|
+
return `"{{$jobsMapByNodeId${path.replace('[', '.').replace(']', '.').replace(/\.$/, '')}}}"`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return _;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class _default extends _server().Migration {
|
|
57
|
+
up() {
|
|
58
|
+
var _this = this;
|
|
59
|
+
|
|
60
|
+
return _asyncToGenerator(function* () {
|
|
61
|
+
const match = yield _this.app.version.satisfies('<0.9.0-alpha.3');
|
|
62
|
+
|
|
63
|
+
if (!match) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const NodeRepo = _this.context.db.getRepository('flow_nodes');
|
|
68
|
+
|
|
69
|
+
yield _this.context.db.sequelize.transaction( /*#__PURE__*/function () {
|
|
70
|
+
var _ref = _asyncToGenerator(function* (transaction) {
|
|
71
|
+
const nodes = yield NodeRepo.find({
|
|
72
|
+
filter: {
|
|
73
|
+
type: 'request'
|
|
74
|
+
},
|
|
75
|
+
transaction
|
|
76
|
+
});
|
|
77
|
+
console.log('%d nodes need to be migrated.', nodes.length);
|
|
78
|
+
yield nodes.reduce((promise, node) => promise.then( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
79
|
+
if (typeof node.config.data !== 'string') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let data = migrateData(node.config.data);
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
data = JSON.parse(node.config.data);
|
|
87
|
+
return node.update({
|
|
88
|
+
config: _objectSpread(_objectSpread({}, node.config), {}, {
|
|
89
|
+
data
|
|
90
|
+
})
|
|
91
|
+
}, {
|
|
92
|
+
transaction
|
|
93
|
+
});
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(`flow_node #${node.id} config migrating failed! you should migrate its format from ejs to json-templates manually in your db.`);
|
|
96
|
+
}
|
|
97
|
+
})), Promise.resolve());
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return function (_x) {
|
|
101
|
+
return _ref.apply(this, arguments);
|
|
102
|
+
};
|
|
103
|
+
}());
|
|
104
|
+
})();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
down() {
|
|
108
|
+
return _asyncToGenerator(function* () {})();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.default = _default;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _server() {
|
|
9
|
+
const data = require("@nocobase/server");
|
|
10
|
+
|
|
11
|
+
_server = function _server() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const _excluded = ["calculation"];
|
|
19
|
+
|
|
20
|
+
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); } }
|
|
21
|
+
|
|
22
|
+
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); }); }; }
|
|
23
|
+
|
|
24
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
25
|
+
|
|
26
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
|
+
|
|
28
|
+
function addQuote(v) {
|
|
29
|
+
if (typeof v !== 'string') {
|
|
30
|
+
return v;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (v.match(/^{{\s*([^{}]+)\s*}}$/)) {
|
|
34
|
+
return v;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return `'${v}'`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const calculatorsMap = {
|
|
41
|
+
'equal': '==',
|
|
42
|
+
'===': '==',
|
|
43
|
+
'notEqual': '!=',
|
|
44
|
+
'!==': '!=',
|
|
45
|
+
'gt': '>',
|
|
46
|
+
'gte': '>=',
|
|
47
|
+
'lt': '<',
|
|
48
|
+
'lte': '<=',
|
|
49
|
+
'add': '+',
|
|
50
|
+
'minus': '-',
|
|
51
|
+
'multiple': '*',
|
|
52
|
+
'divide': '/',
|
|
53
|
+
'mod': '%',
|
|
54
|
+
|
|
55
|
+
includes(a, b) {
|
|
56
|
+
return `SEARCH(${b}, ${a}) >= 0`;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
notIncludes(a, b) {
|
|
60
|
+
return `SEARCH(${b}, ${a}) < 0`;
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
startsWith(a, b) {
|
|
64
|
+
return `SEARCH(${b}, ${a}) == 0`;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
endsWith(a, b) {
|
|
68
|
+
return `RIGHT(${a}, LEN(${b})) == ${b}`;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
notStartsWith(a, b) {
|
|
72
|
+
return `SEARCH(${b}, ${a}) != 0`;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
notEndsWith(a, b) {
|
|
76
|
+
return `RIGHT(${a}, LEN(${b})) != ${b}`;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
concat(a, b) {
|
|
80
|
+
return `CONCATENATE(${a}, ${b})`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
function migrateConfig(_ref = {}) {
|
|
86
|
+
var _calculation$operands, _calculator$operands;
|
|
87
|
+
|
|
88
|
+
let calculation = _ref.calculation,
|
|
89
|
+
config = _objectWithoutProperties(_ref, _excluded);
|
|
90
|
+
|
|
91
|
+
if (!(calculation === null || calculation === void 0 ? void 0 : calculation.calculator) || !(calculation === null || calculation === void 0 ? void 0 : (_calculation$operands = calculation.operands) === null || _calculation$operands === void 0 ? void 0 : _calculation$operands.length)) {
|
|
92
|
+
return config;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const calculator = calculatorsMap[calculation.calculator];
|
|
96
|
+
const operands = ((_calculator$operands = calculator.operands) !== null && _calculator$operands !== void 0 ? _calculator$operands : []).map(operand => addQuote(operand));
|
|
97
|
+
return {
|
|
98
|
+
engine: 'formula.js',
|
|
99
|
+
expression: typeof calculator === 'function' ? calculator(...operands) : operands.join(` ${calculator !== null && calculator !== void 0 ? calculator : calculation.calculator} `)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
class _default extends _server().Migration {
|
|
104
|
+
up() {
|
|
105
|
+
var _this = this;
|
|
106
|
+
|
|
107
|
+
return _asyncToGenerator(function* () {
|
|
108
|
+
const match = yield _this.app.version.satisfies('<0.9.0-alpha.3');
|
|
109
|
+
|
|
110
|
+
if (!match) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const NodeRepo = _this.context.db.getRepository('flow_nodes');
|
|
115
|
+
|
|
116
|
+
yield _this.context.db.sequelize.transaction( /*#__PURE__*/function () {
|
|
117
|
+
var _ref2 = _asyncToGenerator(function* (transaction) {
|
|
118
|
+
const nodes = yield NodeRepo.find({
|
|
119
|
+
filter: {
|
|
120
|
+
type: 'calculation'
|
|
121
|
+
},
|
|
122
|
+
transaction
|
|
123
|
+
});
|
|
124
|
+
console.log('%d nodes need to be migrated.', nodes.length);
|
|
125
|
+
yield nodes.reduce((promise, node) => promise.then(() => {
|
|
126
|
+
return node.update({
|
|
127
|
+
config: migrateConfig(node.config)
|
|
128
|
+
}, {
|
|
129
|
+
transaction
|
|
130
|
+
});
|
|
131
|
+
}), Promise.resolve());
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return function (_x) {
|
|
135
|
+
return _ref2.apply(this, arguments);
|
|
136
|
+
};
|
|
137
|
+
}());
|
|
138
|
+
})();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
exports.default = _default;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _server() {
|
|
9
|
+
const data = require("@nocobase/server");
|
|
10
|
+
|
|
11
|
+
_server = function _server() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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); } }
|
|
25
|
+
|
|
26
|
+
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); }); }; }
|
|
27
|
+
|
|
28
|
+
const calculatorsMap = {
|
|
29
|
+
'equal': '==',
|
|
30
|
+
'===': '==',
|
|
31
|
+
'notEqual': '!=',
|
|
32
|
+
'!==': '!=',
|
|
33
|
+
'gt': '>',
|
|
34
|
+
'gte': '>=',
|
|
35
|
+
'lt': '<',
|
|
36
|
+
'lte': '<=',
|
|
37
|
+
|
|
38
|
+
includes(a, b) {
|
|
39
|
+
return `SEARCH('${b}', '${a}') >= 0`;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
notIncludes(a, b) {
|
|
43
|
+
return `SEARCH('${b}', '${a}') < 0`;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
startsWith(a, b) {
|
|
47
|
+
return `SEARCH('${b}', '${a}') == 0`;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
endsWith(a, b) {
|
|
51
|
+
return `RIGHT('${a}', LEN('${b}')) == '${b}'`;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
notStartsWith(a, b) {
|
|
55
|
+
return `SEARCH('${b}', '${a}') != 0`;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
notEndsWith(a, b) {
|
|
59
|
+
return `RIGHT('${a}', LEN('${b}')) != '${b}'`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function migrateConfig({
|
|
65
|
+
group: {
|
|
66
|
+
type = 'and',
|
|
67
|
+
calculations = []
|
|
68
|
+
}
|
|
69
|
+
}) {
|
|
70
|
+
return {
|
|
71
|
+
group: {
|
|
72
|
+
type,
|
|
73
|
+
calculations: calculations.map(({
|
|
74
|
+
calculator = '===',
|
|
75
|
+
operands = []
|
|
76
|
+
}) => {
|
|
77
|
+
return `(${operands.map(operand => (operand === null || operand === void 0 ? void 0 : operand.group) ? migrateConfig(operand) : operand).join(` ${calculatorsMap[calculator]} `)})`;
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class _default extends _server().Migration {
|
|
84
|
+
up() {
|
|
85
|
+
var _this = this;
|
|
86
|
+
|
|
87
|
+
return _asyncToGenerator(function* () {
|
|
88
|
+
const match = yield _this.app.version.satisfies('<0.9.0-alpha.3');
|
|
89
|
+
|
|
90
|
+
if (!match) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const NodeRepo = _this.context.db.getRepository('flow_nodes');
|
|
95
|
+
|
|
96
|
+
yield _this.context.db.sequelize.transaction( /*#__PURE__*/function () {
|
|
97
|
+
var _ref = _asyncToGenerator(function* (transaction) {
|
|
98
|
+
const nodes = yield NodeRepo.find({
|
|
99
|
+
filter: {
|
|
100
|
+
type: 'condition'
|
|
101
|
+
},
|
|
102
|
+
transaction
|
|
103
|
+
});
|
|
104
|
+
console.log('%d nodes need to be migrated.', nodes.length);
|
|
105
|
+
yield nodes.reduce((promise, node) => promise.then(() => {
|
|
106
|
+
return node.update({
|
|
107
|
+
config: _objectSpread(_objectSpread({}, node.config), {}, {
|
|
108
|
+
engine: 'basic' // calculation: migrateConfig(node.config.calculation)
|
|
109
|
+
|
|
110
|
+
})
|
|
111
|
+
}, {
|
|
112
|
+
transaction
|
|
113
|
+
});
|
|
114
|
+
}), Promise.resolve());
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return function (_x) {
|
|
118
|
+
return _ref.apply(this, arguments);
|
|
119
|
+
};
|
|
120
|
+
}());
|
|
121
|
+
})();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
exports.default = _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _sequelize() {
|
|
9
|
+
const data = require("sequelize");
|
|
10
|
+
|
|
11
|
+
_sequelize = function _sequelize() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _server() {
|
|
19
|
+
const data = require("@nocobase/server");
|
|
20
|
+
|
|
21
|
+
_server = function _server() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
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); } }
|
|
29
|
+
|
|
30
|
+
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); }); }; }
|
|
31
|
+
|
|
32
|
+
class _default extends _server().Migration {
|
|
33
|
+
up() {
|
|
34
|
+
var _arguments = arguments,
|
|
35
|
+
_this = this;
|
|
36
|
+
|
|
37
|
+
return _asyncToGenerator(function* () {
|
|
38
|
+
const match = yield _this.app.version.satisfies('<0.9.0-alpha.3');
|
|
39
|
+
|
|
40
|
+
if (!match) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const _arguments$0$context = _arguments[0].context,
|
|
45
|
+
sequelize = _arguments$0$context.sequelize,
|
|
46
|
+
queryInterface = _arguments$0$context.queryInterface;
|
|
47
|
+
const db = _this.app.db;
|
|
48
|
+
yield sequelize.transaction( /*#__PURE__*/function () {
|
|
49
|
+
var _ref = _asyncToGenerator(function* (transaction) {
|
|
50
|
+
yield queryInterface.changeColumn(db.getCollection('workflows').model.getTableName(), 'config', {
|
|
51
|
+
type: _sequelize().DataTypes.JSON
|
|
52
|
+
}, {
|
|
53
|
+
transaction
|
|
54
|
+
});
|
|
55
|
+
yield queryInterface.changeColumn(db.getCollection('flow_nodes').model.getTableName(), 'config', {
|
|
56
|
+
type: _sequelize().DataTypes.JSON
|
|
57
|
+
}, {
|
|
58
|
+
transaction
|
|
59
|
+
});
|
|
60
|
+
yield queryInterface.changeColumn(db.getCollection('executions').model.getTableName(), 'context', {
|
|
61
|
+
type: _sequelize().DataTypes.JSON
|
|
62
|
+
}, {
|
|
63
|
+
transaction
|
|
64
|
+
});
|
|
65
|
+
yield queryInterface.changeColumn(db.getCollection('jobs').model.getTableName(), 'result', {
|
|
66
|
+
type: _sequelize().DataTypes.JSON
|
|
67
|
+
}, {
|
|
68
|
+
transaction
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return function (_x) {
|
|
73
|
+
return _ref.apply(this, arguments);
|
|
74
|
+
};
|
|
75
|
+
}());
|
|
76
|
+
})();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.default = _default;
|
|
@@ -69,8 +69,12 @@ ScheduleModes.set(SCHEDULE_MODE.CONSTANT, {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (repeat) {
|
|
72
|
-
if (typeof repeat === 'number'
|
|
73
|
-
|
|
72
|
+
if (typeof repeat === 'number') {
|
|
73
|
+
const next = timestamp - (timestamp - startTime) % repeat + repeat;
|
|
74
|
+
|
|
75
|
+
if (next <= timestamp || next > timestamp + this.cacheCycle) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
if (endsOn) {
|
|
@@ -156,6 +160,10 @@ function getOnTimestampWithOffset(on, now) {
|
|
|
156
160
|
}
|
|
157
161
|
|
|
158
162
|
function getDataOptionTime(data, on, dir = 1) {
|
|
163
|
+
if (!on) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
159
167
|
switch (typeof on) {
|
|
160
168
|
case 'string':
|
|
161
169
|
const time = parseDateWithoutMs(on);
|
|
@@ -551,7 +559,7 @@ class ScheduleTrigger extends _.Trigger {
|
|
|
551
559
|
const should = yield _this6.shouldCache(workflow, now);
|
|
552
560
|
|
|
553
561
|
if (should) {
|
|
554
|
-
|
|
562
|
+
_this6.plugin.app.logger.info('caching scheduled workflow will run in next minute:', workflow.id);
|
|
555
563
|
}
|
|
556
564
|
|
|
557
565
|
_this6.setCache(workflow, !should);
|