@nocobase/plugin-workflow 0.9.4-alpha.2 → 0.10.0-alpha.3
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/AddButton.d.ts +2 -2
- package/lib/client/AddButton.js +76 -65
- package/lib/client/Branch.d.ts +2 -2
- package/lib/client/CanvasContent.d.ts +2 -2
- package/lib/client/ExecutionCanvas.d.ts +2 -2
- package/lib/client/ExecutionCanvas.js +1 -1
- package/lib/client/ExecutionLink.d.ts +2 -1
- package/lib/client/ExecutionPage.d.ts +2 -1
- package/lib/client/ExecutionPage.js +14 -15
- package/lib/client/ExecutionResourceProvider.d.ts +2 -1
- package/lib/client/WorkflowCanvas.d.ts +2 -2
- package/lib/client/WorkflowCanvas.js +31 -31
- package/lib/client/WorkflowLink.d.ts +2 -1
- package/lib/client/WorkflowPage.d.ts +2 -1
- package/lib/client/WorkflowPage.js +11 -10
- package/lib/client/WorkflowProvider.d.ts +1 -1
- package/lib/client/WorkflowProvider.js +15 -15
- package/lib/client/components/CollectionBlockInitializer.d.ts +2 -7
- package/lib/client/components/CollectionBlockInitializer.js +49 -17
- package/lib/client/components/CollectionFieldset.d.ts +3 -2
- package/lib/client/components/CollectionFieldset.js +87 -74
- package/lib/client/components/Duration.d.ts +2 -2
- package/lib/client/components/DynamicExpression.d.ts +3 -1
- package/lib/client/components/DynamicExpression.js +2 -0
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +2 -0
- package/lib/client/components/FilterDynamicComponent.d.ts +2 -2
- package/lib/client/components/NodeDescription.d.ts +2 -2
- package/lib/client/components/OpenDrawer.d.ts +2 -2
- package/lib/client/components/OpenDrawer.js +1 -1
- package/lib/client/components/RadioWithTooltip.d.ts +2 -2
- package/lib/client/components/renderEngineReference.d.ts +2 -1
- package/lib/client/constants.d.ts +2 -1
- package/lib/client/locale/zh-CN.d.ts +8 -0
- package/lib/client/locale/zh-CN.js +8 -0
- package/lib/client/nodes/aggregate.d.ts +1 -1
- package/lib/client/nodes/calculation.d.ts +4 -3
- package/lib/client/nodes/condition.d.ts +6 -4
- package/lib/client/nodes/condition.js +3 -1
- package/lib/client/nodes/create.d.ts +3 -6
- package/lib/client/nodes/create.js +1 -4
- package/lib/client/nodes/index.d.ts +5 -5
- package/lib/client/nodes/index.js +9 -6
- package/lib/client/nodes/loop.d.ts +4 -1
- package/lib/client/nodes/loop.js +3 -1
- package/lib/client/nodes/manual/AssigneesSelect.d.ts +2 -2
- package/lib/client/nodes/manual/DetailsBlockProvider.d.ts +2 -0
- package/lib/client/nodes/manual/DetailsBlockProvider.js +106 -0
- package/lib/client/nodes/manual/FormBlockInitializer.d.ts +2 -0
- package/lib/client/nodes/manual/FormBlockInitializer.js +106 -0
- package/lib/client/nodes/manual/FormBlockProvider.d.ts +2 -0
- package/lib/client/nodes/manual/FormBlockProvider.js +113 -0
- package/lib/client/nodes/manual/ModeConfig.d.ts +2 -2
- package/lib/client/nodes/manual/SchemaConfig.d.ts +43 -3
- package/lib/client/nodes/manual/SchemaConfig.js +42 -79
- package/lib/client/nodes/manual/WorkflowTodo.d.ts +5 -8
- package/lib/client/nodes/manual/WorkflowTodo.js +111 -76
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -2
- package/lib/client/nodes/manual/forms/create.d.ts +3 -0
- package/lib/client/nodes/manual/forms/create.js +104 -0
- package/lib/client/nodes/manual/forms/custom.d.ts +3 -0
- package/lib/client/nodes/manual/forms/{customForm.js → custom.js} +63 -45
- package/lib/client/nodes/manual/forms/update.d.ts +3 -0
- package/lib/client/nodes/manual/forms/update.js +161 -0
- package/lib/client/nodes/manual/index.d.ts +2 -5
- package/lib/client/nodes/manual/index.js +17 -16
- package/lib/client/nodes/manual/utils.d.ts +2 -0
- package/lib/client/nodes/manual/utils.js +31 -0
- package/lib/client/nodes/parallel.d.ts +4 -1
- package/lib/client/nodes/parallel.js +3 -1
- package/lib/client/nodes/query.d.ts +2 -5
- package/lib/client/nodes/query.js +2 -5
- package/lib/client/nodes/request.d.ts +1 -1
- package/lib/client/nodes/request.js +1 -11
- package/lib/client/nodes/update.d.ts +24 -1
- package/lib/client/nodes/update.js +76 -3
- package/lib/client/schemas/collection.js +1 -1
- package/lib/client/schemas/executions.d.ts +2 -0
- package/lib/client/style.js +4 -0
- package/lib/client/triggers/collection.d.ts +2 -5
- package/lib/client/triggers/collection.js +5 -8
- package/lib/client/triggers/index.d.ts +1 -2
- package/lib/client/triggers/index.js +10 -8
- package/lib/client/triggers/schedule/DateFieldsSelect.js +14 -12
- package/lib/client/triggers/schedule/EndsByField.d.ts +2 -2
- package/lib/client/triggers/schedule/OnField.d.ts +2 -2
- package/lib/client/triggers/schedule/RepeatField.d.ts +2 -2
- package/lib/client/triggers/schedule/ScheduleConfig.d.ts +2 -1
- package/lib/client/triggers/schedule/index.d.ts +3 -6
- package/lib/client/triggers/schedule/index.js +1 -4
- package/lib/server/Plugin.js +6 -3
- package/lib/server/Processor.d.ts +2 -2
- package/lib/server/Processor.js +22 -26
- package/lib/server/instructions/delay.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -1
- package/lib/server/instructions/loop.js +1 -1
- package/lib/server/instructions/manual/actions.js +42 -47
- package/lib/server/instructions/manual/forms/create.d.ts +5 -0
- package/lib/server/instructions/manual/forms/create.js +46 -0
- package/lib/server/instructions/manual/forms/index.d.ts +6 -0
- package/lib/server/instructions/manual/forms/index.js +15 -0
- package/lib/server/instructions/manual/forms/update.d.ts +6 -0
- package/lib/server/instructions/manual/forms/update.js +47 -0
- package/lib/server/instructions/manual/index.d.ts +3 -0
- package/lib/server/instructions/manual/index.js +16 -3
- package/lib/server/instructions/parallel.js +2 -2
- package/lib/server/instructions/request.js +3 -3
- package/lib/server/instructions/update.js +2 -3
- package/lib/server/migrations/20230612021134-manual-collection-block.d.ts +4 -0
- package/lib/server/migrations/20230612021134-manual-collection-block.js +155 -0
- package/package.json +16 -13
- package/lib/client/WorkflowShortcut.d.ts +0 -1
- package/lib/client/WorkflowShortcut.js +0 -48
- package/lib/client/components/CollectionFieldInitializers.d.ts +0 -2
- package/lib/client/components/CollectionFieldInitializers.js +0 -70
- package/lib/client/nodes/manual/forms/customForm.d.ts +0 -40
package/lib/server/Processor.js
CHANGED
|
@@ -26,18 +26,18 @@ function _utils() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
var _constants = require("./constants");
|
|
29
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
30
|
+
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."); }
|
|
31
|
+
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; } }
|
|
32
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
33
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
34
|
+
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); }
|
|
35
|
+
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; }
|
|
30
36
|
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; }
|
|
31
37
|
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; }
|
|
32
38
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
39
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
34
40
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
35
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
36
|
-
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."); }
|
|
37
|
-
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); }
|
|
38
|
-
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; }
|
|
39
|
-
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; } }
|
|
40
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
41
|
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); } }
|
|
42
42
|
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); }); }; }
|
|
43
43
|
class Processor {
|
|
@@ -123,9 +123,8 @@ class Processor {
|
|
|
123
123
|
result: execution.context
|
|
124
124
|
});
|
|
125
125
|
} else {
|
|
126
|
-
yield _this3.exit(
|
|
126
|
+
yield _this3.exit(_constants.JOB_STATUS.RESOLVED);
|
|
127
127
|
}
|
|
128
|
-
yield _this3.commit();
|
|
129
128
|
})();
|
|
130
129
|
}
|
|
131
130
|
resume(job) {
|
|
@@ -138,7 +137,6 @@ class Processor {
|
|
|
138
137
|
yield _this4.prepare();
|
|
139
138
|
const node = _this4.nodesMap.get(job.nodeId);
|
|
140
139
|
yield _this4.recall(node, job);
|
|
141
|
-
yield _this4.commit();
|
|
142
140
|
})();
|
|
143
141
|
}
|
|
144
142
|
commit() {
|
|
@@ -225,7 +223,7 @@ class Processor {
|
|
|
225
223
|
}
|
|
226
224
|
// really done for all nodes
|
|
227
225
|
// * should mark execution as done with last job status
|
|
228
|
-
return _this8.exit(job);
|
|
226
|
+
return _this8.exit(job.status);
|
|
229
227
|
})();
|
|
230
228
|
}
|
|
231
229
|
recall(node, job) {
|
|
@@ -239,17 +237,20 @@ class Processor {
|
|
|
239
237
|
return _this9.exec(instruction.resume.bind(instruction), node, job);
|
|
240
238
|
})();
|
|
241
239
|
}
|
|
242
|
-
exit(
|
|
240
|
+
exit(s) {
|
|
243
241
|
var _this10 = this;
|
|
244
242
|
return _asyncToGenerator(function* () {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
243
|
+
if (typeof s === 'number') {
|
|
244
|
+
var _this10$constructor$S;
|
|
245
|
+
const status = (_this10$constructor$S = _this10.constructor.StatusMap[s]) !== null && _this10$constructor$S !== void 0 ? _this10$constructor$S : Math.sign(s);
|
|
246
|
+
yield _this10.execution.update({
|
|
247
|
+
status
|
|
248
|
+
}, {
|
|
249
|
+
transaction: _this10.transaction
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
_this10.logger.info(`execution (${_this10.execution.id}) exiting with status ${_this10.execution.status}`);
|
|
253
|
+
yield _this10.commit();
|
|
253
254
|
return null;
|
|
254
255
|
})();
|
|
255
256
|
}
|
|
@@ -266,15 +267,10 @@ class Processor {
|
|
|
266
267
|
transaction: _this11.transaction
|
|
267
268
|
});
|
|
268
269
|
} else if (payload.id) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
id: payload.id
|
|
272
|
-
},
|
|
273
|
-
returning: true,
|
|
270
|
+
job = yield model.findByPk(payload.id);
|
|
271
|
+
yield job.update(payload, {
|
|
274
272
|
transaction: _this11.transaction
|
|
275
273
|
});
|
|
276
|
-
var _yield$model$update2 = _slicedToArray(_yield$model$update, 1);
|
|
277
|
-
job = _yield$model$update2[0];
|
|
278
274
|
} else {
|
|
279
275
|
job = yield model.create(_objectSpread(_objectSpread({}, payload), {}, {
|
|
280
276
|
executionId: _this11.execution.id
|
|
@@ -27,7 +27,7 @@ class _default {
|
|
|
27
27
|
const duration = node.config.duration;
|
|
28
28
|
// add to schedule
|
|
29
29
|
_this.schedule(job, duration);
|
|
30
|
-
return processor.
|
|
30
|
+
return processor.exit();
|
|
31
31
|
});
|
|
32
32
|
return function (_x, _x2, _x3) {
|
|
33
33
|
return _ref.apply(this, arguments);
|
|
@@ -6,7 +6,7 @@ declare const _default: {
|
|
|
6
6
|
status: number;
|
|
7
7
|
result: number;
|
|
8
8
|
}>;
|
|
9
|
-
resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<
|
|
9
|
+
resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<any>;
|
|
10
10
|
getScope(node: any, index: any, processor: any): {
|
|
11
11
|
item: any;
|
|
12
12
|
index: any;
|
|
@@ -68,7 +68,7 @@ var _default = {
|
|
|
68
68
|
status = job.status;
|
|
69
69
|
// if loop has been done (resolved / rejected), do not care newly executed branch jobs.
|
|
70
70
|
if (status !== _constants.JOB_STATUS.PENDING) {
|
|
71
|
-
return
|
|
71
|
+
return processor.exit();
|
|
72
72
|
}
|
|
73
73
|
const nextIndex = result + 1;
|
|
74
74
|
const target = processor.getParsedValue(loop.config.target, node);
|
|
@@ -25,6 +25,7 @@ function submit(_x, _x2) {
|
|
|
25
25
|
}
|
|
26
26
|
function _submit() {
|
|
27
27
|
_submit = _asyncToGenerator(function* (context, next) {
|
|
28
|
+
var _values$result, _forms$formKey, _forms$formKey$action, _userJob$node$config$2, _userJob$result;
|
|
28
29
|
const repository = _actions().utils.getRepositoryFromParams(context);
|
|
29
30
|
const _context$action$param = context.action.params,
|
|
30
31
|
filterByTk = _context$action$param.filterByTk,
|
|
@@ -34,53 +35,47 @@ function _submit() {
|
|
|
34
35
|
return context.throw(401);
|
|
35
36
|
}
|
|
36
37
|
const plugin = context.app.pm.get('workflow');
|
|
37
|
-
const
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
return function (_x3) {
|
|
80
|
-
return _ref.apply(this, arguments);
|
|
81
|
-
};
|
|
82
|
-
}());
|
|
83
|
-
// await transaction.commit();
|
|
38
|
+
const instruction = plugin.instructions.get('manual');
|
|
39
|
+
const userJob = yield repository.findOne({
|
|
40
|
+
filterByTk,
|
|
41
|
+
// filter: {
|
|
42
|
+
// userId: currentUser?.id
|
|
43
|
+
// },
|
|
44
|
+
appends: ['job', 'node', 'execution', 'workflow'],
|
|
45
|
+
context
|
|
46
|
+
});
|
|
47
|
+
if (!userJob) {
|
|
48
|
+
return context.throw(404);
|
|
49
|
+
}
|
|
50
|
+
const _userJob$node$config$ = userJob.node.config.forms,
|
|
51
|
+
forms = _userJob$node$config$ === void 0 ? {} : _userJob$node$config$;
|
|
52
|
+
const _Object$keys = Object.keys((_values$result = values.result) !== null && _values$result !== void 0 ? _values$result : {}),
|
|
53
|
+
_Object$keys2 = _slicedToArray(_Object$keys, 1),
|
|
54
|
+
formKey = _Object$keys2[0];
|
|
55
|
+
// NOTE: validate status
|
|
56
|
+
if (userJob.status !== _constants.JOB_STATUS.PENDING || userJob.job.status !== _constants.JOB_STATUS.PENDING || userJob.execution.status !== _constants.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !((_forms$formKey = forms[formKey]) === null || _forms$formKey === void 0 ? void 0 : (_forms$formKey$action = _forms$formKey.actions) === null || _forms$formKey$action === void 0 ? void 0 : _forms$formKey$action.includes(values.status))) {
|
|
57
|
+
return context.throw(400);
|
|
58
|
+
}
|
|
59
|
+
userJob.execution.workflow = userJob.workflow;
|
|
60
|
+
const processor = plugin.createProcessor(userJob.execution);
|
|
61
|
+
yield processor.prepare();
|
|
62
|
+
// NOTE: validate assignee
|
|
63
|
+
const assignees = processor.getParsedValue((_userJob$node$config$2 = userJob.node.config.assignees) !== null && _userJob$node$config$2 !== void 0 ? _userJob$node$config$2 : []);
|
|
64
|
+
if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
|
|
65
|
+
return context.throw(403);
|
|
66
|
+
}
|
|
67
|
+
userJob.set({
|
|
68
|
+
status: values.status,
|
|
69
|
+
result: values.status ? values.result : Object.assign((_userJob$result = userJob.result) !== null && _userJob$result !== void 0 ? _userJob$result : {}, values.result)
|
|
70
|
+
});
|
|
71
|
+
const handler = instruction.formTypes.get(forms[formKey].type);
|
|
72
|
+
if (handler && userJob.status) {
|
|
73
|
+
yield handler.call(instruction, userJob, forms[formKey], processor);
|
|
74
|
+
}
|
|
75
|
+
yield userJob.save({
|
|
76
|
+
transaction: processor.transaction
|
|
77
|
+
});
|
|
78
|
+
yield processor.exit();
|
|
84
79
|
context.body = userJob;
|
|
85
80
|
context.status = 202;
|
|
86
81
|
yield next();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
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); } }
|
|
19
|
+
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); }); }; }
|
|
20
|
+
function _default(_x, _x2, _x3) {
|
|
21
|
+
return _ref.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
function _ref() {
|
|
24
|
+
_ref = _asyncToGenerator(function* (instance, {
|
|
25
|
+
collection
|
|
26
|
+
}, processor) {
|
|
27
|
+
const repo = this.plugin.db.getRepository(collection);
|
|
28
|
+
if (!repo) {
|
|
29
|
+
throw new Error(`collection ${collection} for create data on manual node not found`);
|
|
30
|
+
}
|
|
31
|
+
const _Object$values = Object.values(instance.result),
|
|
32
|
+
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
33
|
+
values = _Object$values2[0];
|
|
34
|
+
yield repo.create({
|
|
35
|
+
values: _objectSpread(_objectSpread({}, values !== null && values !== void 0 ? values : {}), {}, {
|
|
36
|
+
createdBy: instance.userId,
|
|
37
|
+
updatedBy: instance.userId
|
|
38
|
+
}),
|
|
39
|
+
context: {
|
|
40
|
+
executionId: processor.execution.id
|
|
41
|
+
},
|
|
42
|
+
transaction: processor.transaction
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return _ref.apply(this, arguments);
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Processor } from '../../..';
|
|
2
|
+
import ManualInstruction from '..';
|
|
3
|
+
export declare type FormHandler = (this: ManualInstruction, instance: any, formConfig: any, processor: Processor) => Promise<void>;
|
|
4
|
+
export default function ({ formTypes }: {
|
|
5
|
+
formTypes: any;
|
|
6
|
+
}): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
var _create = _interopRequireDefault(require("./create"));
|
|
8
|
+
var _update = _interopRequireDefault(require("./update"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function _default({
|
|
11
|
+
formTypes
|
|
12
|
+
}) {
|
|
13
|
+
formTypes.register('create', _create.default);
|
|
14
|
+
formTypes.register('update', _update.default);
|
|
15
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = _default;
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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); }
|
|
15
|
+
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
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); } }
|
|
19
|
+
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); }); }; }
|
|
20
|
+
function _default(_x, _x2, _x3) {
|
|
21
|
+
return _ref.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
function _ref() {
|
|
24
|
+
_ref = _asyncToGenerator(function* (instance, {
|
|
25
|
+
collection,
|
|
26
|
+
filter = {}
|
|
27
|
+
}, processor) {
|
|
28
|
+
const repo = this.plugin.db.getRepository(collection);
|
|
29
|
+
if (!repo) {
|
|
30
|
+
throw new Error(`collection ${collection} for update data on manual node not found`);
|
|
31
|
+
}
|
|
32
|
+
const _Object$values = Object.values(instance.result),
|
|
33
|
+
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
34
|
+
values = _Object$values2[0];
|
|
35
|
+
yield repo.update({
|
|
36
|
+
filter: processor.getParsedValue(filter),
|
|
37
|
+
values: _objectSpread(_objectSpread({}, values !== null && values !== void 0 ? values : {}), {}, {
|
|
38
|
+
updatedBy: instance.userId
|
|
39
|
+
}),
|
|
40
|
+
context: {
|
|
41
|
+
executionId: processor.execution.id
|
|
42
|
+
},
|
|
43
|
+
transaction: processor.transaction
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return _ref.apply(this, arguments);
|
|
47
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Registry } from '@nocobase/utils';
|
|
1
2
|
import Plugin from '../..';
|
|
2
3
|
import { Instruction } from '..';
|
|
4
|
+
import { FormHandler } from './forms';
|
|
3
5
|
declare type FormType = {
|
|
4
6
|
type: 'custom' | 'create' | 'update';
|
|
5
7
|
actions: number[];
|
|
@@ -19,6 +21,7 @@ export interface ManualConfig {
|
|
|
19
21
|
}
|
|
20
22
|
export default class implements Instruction {
|
|
21
23
|
protected plugin: Plugin;
|
|
24
|
+
formTypes: Registry<FormHandler>;
|
|
22
25
|
constructor(plugin: Plugin);
|
|
23
26
|
run(node: any, prevJob: any, processor: any): Promise<any>;
|
|
24
27
|
resume(node: any, job: any, processor: any): Promise<any>;
|
|
@@ -11,11 +11,19 @@ function _actions() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
+
function _utils() {
|
|
15
|
+
const data = require("@nocobase/utils");
|
|
16
|
+
_utils = function _utils() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
14
21
|
var _constants = require("../../constants");
|
|
15
22
|
var _jobs = _interopRequireDefault(require("./collecions/jobs"));
|
|
16
23
|
var _users = _interopRequireDefault(require("./collecions/users"));
|
|
17
24
|
var _users_jobs = _interopRequireDefault(require("./collecions/users_jobs"));
|
|
18
25
|
var _actions2 = require("./actions");
|
|
26
|
+
var _forms = _interopRequireDefault(require("./forms"));
|
|
19
27
|
const _excluded = ["mode"];
|
|
20
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
29
|
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; }
|
|
@@ -81,6 +89,7 @@ function getMode(mode) {
|
|
|
81
89
|
class _default {
|
|
82
90
|
constructor(plugin) {
|
|
83
91
|
this.plugin = void 0;
|
|
92
|
+
this.formTypes = new (_utils().Registry)();
|
|
84
93
|
this.plugin = plugin;
|
|
85
94
|
plugin.db.collection(_users_jobs.default);
|
|
86
95
|
plugin.db.extendCollection(_users.default);
|
|
@@ -104,6 +113,7 @@ class _default {
|
|
|
104
113
|
submit: _actions2.submit
|
|
105
114
|
}
|
|
106
115
|
});
|
|
116
|
+
(0, _forms.default)(this);
|
|
107
117
|
}
|
|
108
118
|
run(node, prevJob, processor) {
|
|
109
119
|
return _asyncToGenerator(function* () {
|
|
@@ -135,7 +145,7 @@ class _default {
|
|
|
135
145
|
}
|
|
136
146
|
resume(node, job, processor) {
|
|
137
147
|
return _asyncToGenerator(function* () {
|
|
138
|
-
var _job$latestUserJob$re, _job$latestUserJob
|
|
148
|
+
var _getMode$getStatus, _job$latestUserJob$re, _job$latestUserJob;
|
|
139
149
|
// NOTE: check all users jobs related if all done then continue as parallel
|
|
140
150
|
const _node$config2 = node.config,
|
|
141
151
|
_node$config2$assigne = _node$config2.assignees,
|
|
@@ -146,12 +156,15 @@ class _default {
|
|
|
146
156
|
where: {
|
|
147
157
|
jobId: job.id
|
|
148
158
|
},
|
|
149
|
-
group: ['status']
|
|
159
|
+
group: ['status'],
|
|
160
|
+
transaction: processor.transaction
|
|
150
161
|
});
|
|
151
162
|
const submitted = distribution.reduce((count, item) => item.status !== _constants.JOB_STATUS.PENDING ? count + item.count : count, 0);
|
|
163
|
+
const status = job.status || ((_getMode$getStatus = getMode(mode).getStatus(distribution, assignees)) !== null && _getMode$getStatus !== void 0 ? _getMode$getStatus : _constants.JOB_STATUS.PENDING);
|
|
152
164
|
const result = mode ? (submitted || 0) / assignees.length : (_job$latestUserJob$re = (_job$latestUserJob = job.latestUserJob) === null || _job$latestUserJob === void 0 ? void 0 : _job$latestUserJob.result) !== null && _job$latestUserJob$re !== void 0 ? _job$latestUserJob$re : job.result;
|
|
165
|
+
processor.logger.debug(`manual resume job and next status: ${status}`);
|
|
153
166
|
job.set({
|
|
154
|
-
status
|
|
167
|
+
status,
|
|
155
168
|
result
|
|
156
169
|
});
|
|
157
170
|
return job;
|
|
@@ -100,7 +100,7 @@ var _default = {
|
|
|
100
100
|
status = job.status;
|
|
101
101
|
// if parallel has been done (resolved / rejected), do not care newly executed branch jobs.
|
|
102
102
|
if (status !== _constants.JOB_STATUS.PENDING) {
|
|
103
|
-
return
|
|
103
|
+
return processor.exit();
|
|
104
104
|
}
|
|
105
105
|
// find the index of the node which start the branch
|
|
106
106
|
const jobNode = processor.nodesMap.get(branchJob.nodeId);
|
|
@@ -119,7 +119,7 @@ var _default = {
|
|
|
119
119
|
yield job.save({
|
|
120
120
|
transaction: processor.transaction
|
|
121
121
|
});
|
|
122
|
-
return processor.
|
|
122
|
+
return processor.exit();
|
|
123
123
|
}
|
|
124
124
|
return job;
|
|
125
125
|
})();
|
|
@@ -76,11 +76,11 @@ class _default {
|
|
|
76
76
|
result: error.isAxiosError ? error.toJSON() : error.message
|
|
77
77
|
});
|
|
78
78
|
}).finally(() => {
|
|
79
|
-
|
|
79
|
+
processor.logger.info(`request (#${node.id}) response received, status: ${job.get('status')}`);
|
|
80
80
|
_this.plugin.resume(job);
|
|
81
81
|
});
|
|
82
|
-
|
|
83
|
-
return
|
|
82
|
+
processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
|
|
83
|
+
return processor.exit();
|
|
84
84
|
})();
|
|
85
85
|
}
|
|
86
86
|
resume(node, job, processor) {
|
|
@@ -15,10 +15,9 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
15
15
|
var _default = {
|
|
16
16
|
run(node, input, processor) {
|
|
17
17
|
return _asyncToGenerator(function* () {
|
|
18
|
+
var _result$length;
|
|
18
19
|
const _node$config = node.config,
|
|
19
20
|
collection = _node$config.collection,
|
|
20
|
-
_node$config$multiple = _node$config.multiple,
|
|
21
|
-
multiple = _node$config$multiple === void 0 ? false : _node$config$multiple,
|
|
22
21
|
_node$config$params = _node$config.params,
|
|
23
22
|
params = _node$config$params === void 0 ? {} : _node$config$params;
|
|
24
23
|
const repo = node.constructor.database.getRepository(collection);
|
|
@@ -30,7 +29,7 @@ var _default = {
|
|
|
30
29
|
transaction: processor.transaction
|
|
31
30
|
}));
|
|
32
31
|
return {
|
|
33
|
-
result:
|
|
32
|
+
result: (_result$length = result.length) !== null && _result$length !== void 0 ? _result$length : result,
|
|
34
33
|
status: _constants.JOB_STATUS.RESOLVED
|
|
35
34
|
};
|
|
36
35
|
})();
|