@nocobase/plugin-workflow 0.10.0-alpha.2 → 0.10.0-alpha.4
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.js +76 -65
- package/lib/client/WorkflowCanvas.js +2 -2
- package/lib/client/components/CollectionFieldset.d.ts +1 -0
- package/lib/client/components/CollectionFieldset.js +73 -63
- package/lib/client/locale/zh-CN.d.ts +5 -0
- package/lib/client/locale/zh-CN.js +5 -0
- package/lib/client/nodes/index.js +2 -2
- package/lib/client/nodes/update.d.ts +24 -1
- package/lib/client/nodes/update.js +76 -3
- package/lib/client/style.js +4 -0
- package/lib/client/triggers/index.js +20 -13
- package/lib/client/triggers/schedule/ScheduleConfig.js +11 -1
- package/lib/client/triggers/schedule/index.d.ts +0 -20
- package/lib/client/triggers/schedule/index.js +1 -17
- package/lib/server/Plugin.js +6 -3
- package/lib/server/Processor.d.ts +2 -2
- package/lib/server/Processor.js +21 -24
- 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 +1 -1
- 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/package.json +12 -12
package/lib/client/AddButton.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.AddButton = AddButton;
|
|
7
|
-
function
|
|
8
|
-
const data =
|
|
9
|
-
|
|
7
|
+
function _icons() {
|
|
8
|
+
const data = require("@ant-design/icons");
|
|
9
|
+
_icons = function _icons() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -18,45 +18,46 @@ function _css() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const data = require("
|
|
23
|
-
|
|
21
|
+
function _client() {
|
|
22
|
+
const data = require("@nocobase/client");
|
|
23
|
+
_client = function _client() {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("
|
|
30
|
-
|
|
28
|
+
function _antd() {
|
|
29
|
+
const data = require("antd");
|
|
30
|
+
_antd = function _antd() {
|
|
31
31
|
return data;
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const data = require("
|
|
37
|
-
|
|
35
|
+
function _react() {
|
|
36
|
+
const data = _interopRequireWildcard(require("react"));
|
|
37
|
+
_react = function _react() {
|
|
38
38
|
return data;
|
|
39
39
|
};
|
|
40
40
|
return data;
|
|
41
41
|
}
|
|
42
42
|
var _FlowContext = require("./FlowContext");
|
|
43
|
+
var _locale = require("./locale");
|
|
43
44
|
var _nodes = require("./nodes");
|
|
44
45
|
var _style = require("./style");
|
|
45
|
-
|
|
46
|
-
function
|
|
46
|
+
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); }
|
|
47
|
+
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; }
|
|
47
48
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
48
49
|
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."); }
|
|
49
50
|
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); }
|
|
50
51
|
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; }
|
|
51
52
|
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; } }
|
|
52
53
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
54
|
+
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); } }
|
|
55
|
+
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); }); }; }
|
|
53
56
|
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; }
|
|
54
57
|
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; }
|
|
55
58
|
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; }
|
|
56
59
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
57
60
|
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); }
|
|
58
|
-
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); } }
|
|
59
|
-
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); }); }; }
|
|
60
61
|
function AddButton({
|
|
61
62
|
upstream,
|
|
62
63
|
branchIndex = null
|
|
@@ -67,18 +68,46 @@ function AddButton({
|
|
|
67
68
|
const _ref = (_useFlowContext = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext !== void 0 ? _useFlowContext : {},
|
|
68
69
|
workflow = _ref.workflow,
|
|
69
70
|
refresh = _ref.refresh;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
const instructionList = Array.from(_nodes.instructions.getValues());
|
|
72
|
+
const groups = (0, _react().useMemo)(() => {
|
|
73
|
+
return [{
|
|
74
|
+
key: 'control',
|
|
75
|
+
label: `{{t("Control", { ns: "${_locale.NAMESPACE}" })}}`
|
|
76
|
+
}, {
|
|
77
|
+
key: 'collection',
|
|
78
|
+
label: `{{t("Collection operations", { ns: "${_locale.NAMESPACE}" })}}`
|
|
79
|
+
}, {
|
|
80
|
+
key: 'manual',
|
|
81
|
+
label: `{{t("Manual", { ns: "${_locale.NAMESPACE}" })}}`
|
|
82
|
+
}, {
|
|
83
|
+
key: 'extended',
|
|
84
|
+
label: `{{t("Extended types", { ns: "${_locale.NAMESPACE}" })}}`
|
|
85
|
+
}].filter(group => instructionList.filter(item => item.group === group.key).length).map(group => {
|
|
86
|
+
const groupInstructions = instructionList.filter(item => item.group === group.key);
|
|
87
|
+
return _objectSpread(_objectSpread({}, group), {}, {
|
|
88
|
+
type: 'group',
|
|
89
|
+
children: groupInstructions.map(item => ({
|
|
90
|
+
key: item.type,
|
|
91
|
+
label: item.title,
|
|
92
|
+
type: item.options ? 'subMenu' : null,
|
|
93
|
+
children: item.options ? item.options.map(option => ({
|
|
94
|
+
key: option.key,
|
|
95
|
+
label: option.label
|
|
96
|
+
})) : null
|
|
97
|
+
}))
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}, [instructionList]);
|
|
101
|
+
const resource = (0, _react().useMemo)(() => {
|
|
102
|
+
if (!workflow) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return api.resource('workflows.nodes', workflow.id);
|
|
106
|
+
}, [workflow === null || workflow === void 0 ? void 0 : workflow.id]);
|
|
107
|
+
const onCreate = (0, _react().useCallback)( /*#__PURE__*/function () {
|
|
108
|
+
var _ref2 = _asyncToGenerator(function* ({
|
|
79
109
|
keyPath
|
|
80
110
|
}) {
|
|
81
|
-
var _upstream$id;
|
|
82
111
|
const type = keyPath.pop();
|
|
83
112
|
const config = {};
|
|
84
113
|
const _keyPath = _slicedToArray(keyPath, 1),
|
|
@@ -86,11 +115,13 @@ function AddButton({
|
|
|
86
115
|
const instruction = _nodes.instructions.get(type);
|
|
87
116
|
if (optionKey) {
|
|
88
117
|
var _instruction$options$, _instruction$options;
|
|
89
|
-
const
|
|
90
|
-
value =
|
|
118
|
+
const _ref3 = (_instruction$options$ = (_instruction$options = instruction.options) === null || _instruction$options === void 0 ? void 0 : _instruction$options.find(item => item.key === optionKey)) !== null && _instruction$options$ !== void 0 ? _instruction$options$ : {},
|
|
119
|
+
value = _ref3.value;
|
|
91
120
|
Object.assign(config, value);
|
|
92
121
|
}
|
|
93
|
-
|
|
122
|
+
if (resource) {
|
|
123
|
+
var _upstream$id;
|
|
124
|
+
yield resource.create({
|
|
94
125
|
values: {
|
|
95
126
|
type,
|
|
96
127
|
upstreamId: (_upstream$id = upstream === null || upstream === void 0 ? void 0 : upstream.id) !== null && _upstream$id !== void 0 ? _upstream$id : null,
|
|
@@ -98,48 +129,28 @@ function AddButton({
|
|
|
98
129
|
title: compile(instruction.title),
|
|
99
130
|
config
|
|
100
131
|
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
|
|
132
|
+
});
|
|
133
|
+
refresh();
|
|
134
|
+
}
|
|
104
135
|
});
|
|
105
|
-
return
|
|
136
|
+
return function (_x) {
|
|
137
|
+
return _ref2.apply(this, arguments);
|
|
138
|
+
};
|
|
139
|
+
}(), [branchIndex, resource === null || resource === void 0 ? void 0 : resource.create, upstream === null || upstream === void 0 ? void 0 : upstream.id]);
|
|
140
|
+
const menu = (0, _react().useMemo)(() => {
|
|
141
|
+
return {
|
|
142
|
+
onClick: ev => onCreate(ev),
|
|
143
|
+
items: compile(groups)
|
|
144
|
+
};
|
|
145
|
+
}, [groups, onCreate]);
|
|
146
|
+
if (!workflow) {
|
|
147
|
+
return null;
|
|
106
148
|
}
|
|
107
|
-
const instructionList = Array.from(_nodes.instructions.getValues());
|
|
108
|
-
const groups = [{
|
|
109
|
-
key: 'control',
|
|
110
|
-
label: `{{t("Control", { ns: "${_locale.NAMESPACE}" })}}`
|
|
111
|
-
}, {
|
|
112
|
-
key: 'collection',
|
|
113
|
-
label: `{{t("Collection operations", { ns: "${_locale.NAMESPACE}" })}}`
|
|
114
|
-
}, {
|
|
115
|
-
key: 'manual',
|
|
116
|
-
label: `{{t("Manual", { ns: "${_locale.NAMESPACE}" })}}`
|
|
117
|
-
}, {
|
|
118
|
-
key: 'extended',
|
|
119
|
-
label: `{{t("Extended types", { ns: "${_locale.NAMESPACE}" })}}`
|
|
120
|
-
}].filter(group => instructionList.filter(item => item.group === group.key).length).map(group => {
|
|
121
|
-
const groupInstructions = instructionList.filter(item => item.group === group.key);
|
|
122
|
-
return _objectSpread(_objectSpread({}, group), {}, {
|
|
123
|
-
type: 'group',
|
|
124
|
-
children: groupInstructions.map(item => ({
|
|
125
|
-
key: item.type,
|
|
126
|
-
label: item.title,
|
|
127
|
-
type: item.options ? 'subMenu' : null,
|
|
128
|
-
children: item.options ? item.options.map(option => ({
|
|
129
|
-
key: option.key,
|
|
130
|
-
label: option.label
|
|
131
|
-
})) : null
|
|
132
|
-
}))
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
149
|
return _react().default.createElement("div", {
|
|
136
150
|
className: (0, _css().cx)(_style.addButtonClass)
|
|
137
151
|
}, _react().default.createElement(_antd().Dropdown, {
|
|
138
152
|
trigger: ['click'],
|
|
139
|
-
|
|
140
|
-
onClick: ev => onCreate(ev),
|
|
141
|
-
items: compile(groups)
|
|
142
|
-
}),
|
|
153
|
+
menu: menu,
|
|
143
154
|
disabled: workflow.executed
|
|
144
155
|
}, _react().default.createElement(_antd().Button, {
|
|
145
156
|
shape: "circle",
|
|
@@ -129,8 +129,8 @@ function WorkflowCanvas() {
|
|
|
129
129
|
title = _ref2.title;
|
|
130
130
|
setTitle === null || setTitle === void 0 ? void 0 : setTitle(`${(0, _locale.lang)('Workflow')}${title ? `: ${title}` : ''}`);
|
|
131
131
|
}, [data === null || data === void 0 ? void 0 : data.data]);
|
|
132
|
-
if (!(data === null || data === void 0 ? void 0 : data.data)
|
|
133
|
-
return _react().default.createElement("div", null, (0, _locale.lang)('Load failed'));
|
|
132
|
+
if (!(data === null || data === void 0 ? void 0 : data.data)) {
|
|
133
|
+
return _react().default.createElement("div", null, loading ? (0, _locale.lang)('Loading') : (0, _locale.lang)('Load failed'));
|
|
134
134
|
}
|
|
135
135
|
const _ref3 = (_data$data2 = data === null || data === void 0 ? void 0 : data.data) !== null && _data$data2 !== void 0 ? _data$data2 : {},
|
|
136
136
|
_ref3$nodes = _ref3.nodes,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
export declare function useCollectionUIFields(collection: any): import("@nocobase/client").CollectionFieldOptions[];
|
|
2
3
|
declare const CollectionFieldSet: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
|
|
3
4
|
export default CollectionFieldSet;
|
|
@@ -4,16 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
exports.useCollectionUIFields = useCollectionUIFields;
|
|
8
|
+
function _icons() {
|
|
9
|
+
const data = require("@ant-design/icons");
|
|
10
|
+
_icons = function _icons() {
|
|
10
11
|
return data;
|
|
11
12
|
};
|
|
12
13
|
return data;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function _css() {
|
|
16
|
+
const data = require("@emotion/css");
|
|
17
|
+
_css = function _css() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _react() {
|
|
15
23
|
const data = require("@formily/react");
|
|
16
|
-
|
|
24
|
+
_react = function _react() {
|
|
17
25
|
return data;
|
|
18
26
|
};
|
|
19
27
|
return data;
|
|
@@ -25,9 +33,9 @@ function _antd() {
|
|
|
25
33
|
};
|
|
26
34
|
return data;
|
|
27
35
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("
|
|
30
|
-
|
|
36
|
+
function _react2() {
|
|
37
|
+
const data = _interopRequireWildcard(require("react"));
|
|
38
|
+
_react2 = function _react2() {
|
|
31
39
|
return data;
|
|
32
40
|
};
|
|
33
41
|
return data;
|
|
@@ -39,13 +47,6 @@ function _reactI18next() {
|
|
|
39
47
|
};
|
|
40
48
|
return data;
|
|
41
49
|
}
|
|
42
|
-
function _css() {
|
|
43
|
-
const data = require("@emotion/css");
|
|
44
|
-
_css = function _css() {
|
|
45
|
-
return data;
|
|
46
|
-
};
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
50
|
function _client() {
|
|
50
51
|
const data = require("@nocobase/client");
|
|
51
52
|
_client = function _client() {
|
|
@@ -55,7 +56,8 @@ function _client() {
|
|
|
55
56
|
}
|
|
56
57
|
var _locale = require("../locale");
|
|
57
58
|
var _variable = require("../variable");
|
|
58
|
-
function
|
|
59
|
+
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); }
|
|
60
|
+
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; }
|
|
59
61
|
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; }
|
|
60
62
|
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; }
|
|
61
63
|
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; }
|
|
@@ -66,10 +68,10 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
66
68
|
function AssociationInput(props) {
|
|
67
69
|
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
68
70
|
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
69
|
-
const _useField = (0,
|
|
71
|
+
const _useField = (0, _react().useField)(),
|
|
70
72
|
path = _useField.path;
|
|
71
73
|
const fieldName = path.segments[path.segments.length - 1];
|
|
72
|
-
const _useForm = (0,
|
|
74
|
+
const _useForm = (0, _react().useForm)(),
|
|
73
75
|
config = _useForm.values;
|
|
74
76
|
const fields = getCollectionFields(config === null || config === void 0 ? void 0 : config.collection);
|
|
75
77
|
const _fields$find = fields.find(item => item.name === fieldName),
|
|
@@ -79,34 +81,59 @@ function AssociationInput(props) {
|
|
|
79
81
|
const trimed = ev.target.value.trim();
|
|
80
82
|
props.onChange(['belongsTo', 'hasOne'].includes(type) ? trimed : trimed.split(/[,\s]+/));
|
|
81
83
|
}
|
|
82
|
-
return
|
|
84
|
+
return _react2().default.createElement(_antd().Input, _objectSpread(_objectSpread({}, props), {}, {
|
|
83
85
|
value: value,
|
|
84
86
|
onChange: onChange
|
|
85
87
|
}));
|
|
86
88
|
}
|
|
89
|
+
function useCollectionUIFields(collection) {
|
|
90
|
+
const _useCollectionManager2 = (0, _client().useCollectionManager)(),
|
|
91
|
+
getCollectionFields = _useCollectionManager2.getCollectionFields;
|
|
92
|
+
return getCollectionFields(collection).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false));
|
|
93
|
+
}
|
|
87
94
|
// NOTE: observer for watching useProps
|
|
88
|
-
const CollectionFieldSet = (0,
|
|
95
|
+
const CollectionFieldSet = (0, _react().observer)(({
|
|
89
96
|
value,
|
|
90
97
|
disabled,
|
|
91
|
-
onChange: _onChange
|
|
98
|
+
onChange: _onChange,
|
|
99
|
+
filter
|
|
92
100
|
}) => {
|
|
93
101
|
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
94
102
|
t = _useTranslation.t;
|
|
95
103
|
const compile = (0, _client().useCompile)();
|
|
96
|
-
const form = (0,
|
|
97
|
-
const
|
|
98
|
-
getCollection =
|
|
99
|
-
getCollectionFields = _useCollectionManager2.getCollectionFields;
|
|
100
|
-
const _useForm2 = (0, _react2().useForm)(),
|
|
101
|
-
config = _useForm2.values;
|
|
102
|
-
const collectionName = config === null || config === void 0 ? void 0 : config.collection;
|
|
103
|
-
const fields = getCollectionFields(collectionName).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false) &&
|
|
104
|
-
// TODO: should use some field option but not type to control this
|
|
105
|
-
!['formula'].includes(field.type));
|
|
106
|
-
const unassignedFields = fields.filter(field => !value || !(field.name in value));
|
|
104
|
+
const form = (0, _react().useForm)();
|
|
105
|
+
const _useCollectionManager3 = (0, _client().useCollectionManager)(),
|
|
106
|
+
getCollection = _useCollectionManager3.getCollection;
|
|
107
107
|
const scope = (0, _variable.useWorkflowVariableOptions)();
|
|
108
|
+
const config = form.values;
|
|
109
|
+
const collectionName = config === null || config === void 0 ? void 0 : config.collection;
|
|
110
|
+
const collectionFields = useCollectionUIFields(collectionName);
|
|
111
|
+
const fields = filter ? collectionFields.filter(filter.bind(config)) : collectionFields;
|
|
112
|
+
const unassignedFields = (0, _react2().useMemo)(() => fields.filter(field => !value || !(field.name in value)), [fields, value]);
|
|
108
113
|
const mergedDisabled = disabled || form.disabled;
|
|
109
|
-
|
|
114
|
+
const menu = (0, _react2().useMemo)(() => {
|
|
115
|
+
return {
|
|
116
|
+
onClick: ({
|
|
117
|
+
key
|
|
118
|
+
}) => {
|
|
119
|
+
_onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
120
|
+
[key]: null
|
|
121
|
+
}));
|
|
122
|
+
},
|
|
123
|
+
style: {
|
|
124
|
+
maxHeight: 300,
|
|
125
|
+
overflowY: 'auto'
|
|
126
|
+
},
|
|
127
|
+
items: unassignedFields.map(field => {
|
|
128
|
+
var _field$uiSchema$title, _field$uiSchema;
|
|
129
|
+
return {
|
|
130
|
+
key: field.name,
|
|
131
|
+
label: compile((_field$uiSchema$title = (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) !== null && _field$uiSchema$title !== void 0 ? _field$uiSchema$title : field.name)
|
|
132
|
+
};
|
|
133
|
+
})
|
|
134
|
+
};
|
|
135
|
+
}, [_onChange, unassignedFields, value]);
|
|
136
|
+
return _react2().default.createElement("fieldset", {
|
|
110
137
|
className: (0, _css().css)`
|
|
111
138
|
margin-top: 0.5em;
|
|
112
139
|
|
|
@@ -118,24 +145,24 @@ const CollectionFieldSet = (0, _react2().observer)(({
|
|
|
118
145
|
}
|
|
119
146
|
}
|
|
120
147
|
`
|
|
121
|
-
}, fields.length ?
|
|
148
|
+
}, fields.length ? _react2().default.createElement(_client().CollectionProvider, {
|
|
122
149
|
collection: getCollection(collectionName)
|
|
123
150
|
}, fields.filter(field => value && field.name in value).map(field => {
|
|
124
|
-
var _field$uiSchema$
|
|
151
|
+
var _field$uiSchema$title2, _field$uiSchema2;
|
|
125
152
|
// constant for associations to use Input, others to use CollectionField
|
|
126
153
|
// dynamic values only support belongsTo/hasOne association, other association type should disable
|
|
127
154
|
const ConstantCompoent = ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type) ? AssociationInput : _client().CollectionField;
|
|
128
155
|
// TODO: try to use <ObjectField> to replace this map
|
|
129
|
-
return
|
|
156
|
+
return _react2().default.createElement(_antd().Form.Item, {
|
|
130
157
|
key: field.name,
|
|
131
|
-
label: compile((_field$uiSchema$
|
|
158
|
+
label: compile((_field$uiSchema$title2 = (_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title) !== null && _field$uiSchema$title2 !== void 0 ? _field$uiSchema$title2 : field.name),
|
|
132
159
|
labelAlign: "left",
|
|
133
160
|
className: (0, _css().css)`
|
|
134
161
|
.ant-form-item-control-input-content {
|
|
135
162
|
display: flex;
|
|
136
163
|
}
|
|
137
164
|
`
|
|
138
|
-
},
|
|
165
|
+
}, _react2().default.createElement(_client().Variable.Input, {
|
|
139
166
|
scope: scope,
|
|
140
167
|
value: value[field.name],
|
|
141
168
|
onChange: next => {
|
|
@@ -143,7 +170,7 @@ const CollectionFieldSet = (0, _react2().observer)(({
|
|
|
143
170
|
[field.name]: next
|
|
144
171
|
}));
|
|
145
172
|
}
|
|
146
|
-
},
|
|
173
|
+
}, _react2().default.createElement(_client().SchemaComponent, {
|
|
147
174
|
schema: {
|
|
148
175
|
type: 'void',
|
|
149
176
|
properties: {
|
|
@@ -155,9 +182,9 @@ const CollectionFieldSet = (0, _react2().observer)(({
|
|
|
155
182
|
}
|
|
156
183
|
}
|
|
157
184
|
}
|
|
158
|
-
})), !mergedDisabled ?
|
|
185
|
+
})), !mergedDisabled ? _react2().default.createElement(_antd().Button, {
|
|
159
186
|
type: "link",
|
|
160
|
-
icon:
|
|
187
|
+
icon: _react2().default.createElement(_icons().CloseCircleOutlined, null),
|
|
161
188
|
onClick: () => {
|
|
162
189
|
const _field$name = field.name,
|
|
163
190
|
_ = value[_field$name],
|
|
@@ -165,28 +192,11 @@ const CollectionFieldSet = (0, _react2().observer)(({
|
|
|
165
192
|
_onChange(rest);
|
|
166
193
|
}
|
|
167
194
|
}) : null);
|
|
168
|
-
}), unassignedFields.length ?
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
key: field.name,
|
|
174
|
-
label: compile((_field$uiSchema$title2 = (_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title) !== null && _field$uiSchema$title2 !== void 0 ? _field$uiSchema$title2 : field.name)
|
|
175
|
-
};
|
|
176
|
-
}),
|
|
177
|
-
onClick: ({
|
|
178
|
-
key
|
|
179
|
-
}) => _onChange(_objectSpread(_objectSpread({}, value), {}, {
|
|
180
|
-
[key]: null
|
|
181
|
-
})),
|
|
182
|
-
className: (0, _css().css)`
|
|
183
|
-
max-height: 300px;
|
|
184
|
-
overflow-y: auto;
|
|
185
|
-
`
|
|
186
|
-
})
|
|
187
|
-
}, _react().default.createElement(_antd().Button, {
|
|
188
|
-
icon: _react().default.createElement(_icons().PlusOutlined, null)
|
|
189
|
-
}, t('Add field'))) : null) : _react().default.createElement("p", null, (0, _locale.lang)('Please select collection first')));
|
|
195
|
+
}), unassignedFields.length ? _react2().default.createElement(_antd().Dropdown, {
|
|
196
|
+
menu: menu
|
|
197
|
+
}, _react2().default.createElement(_antd().Button, {
|
|
198
|
+
icon: _react2().default.createElement(_icons().PlusOutlined, null)
|
|
199
|
+
}, t('Add field'))) : null) : _react2().default.createElement("p", null, (0, _locale.lang)('Please select collection first')));
|
|
190
200
|
}, {
|
|
191
201
|
displayName: 'CollectionFieldSet'
|
|
192
202
|
});
|
|
@@ -153,6 +153,11 @@ declare const _default: {
|
|
|
153
153
|
'Add new record to a collection. You can use variables from upstream nodes to assign values to fields.': string;
|
|
154
154
|
'Update record': string;
|
|
155
155
|
'Update records of a collection. You can use variables from upstream nodes as query conditions and field values.': string;
|
|
156
|
+
'Update mode': string;
|
|
157
|
+
'Update in a batch': string;
|
|
158
|
+
'Update one by one': string;
|
|
159
|
+
'Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.': string;
|
|
160
|
+
'The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.': string;
|
|
156
161
|
'Query record': string;
|
|
157
162
|
'Query records from a collection. You can use variables from upstream nodes as query conditions.': string;
|
|
158
163
|
'Allow multiple records as result': string;
|
|
@@ -159,6 +159,11 @@ var _default = {
|
|
|
159
159
|
'Add new record to a collection. You can use variables from upstream nodes to assign values to fields.': '向一个数据表中添加新的数据。可以使用上游节点里的变量为字段赋值。',
|
|
160
160
|
'Update record': '更新数据',
|
|
161
161
|
'Update records of a collection. You can use variables from upstream nodes as query conditions and field values.': '更新一个数据表中的数据。可以使用上游节点里的变量作为查询条件和数据值。',
|
|
162
|
+
'Update mode': '更新模式',
|
|
163
|
+
'Update in a batch': '批量更新',
|
|
164
|
+
'Update one by one': '逐条更新',
|
|
165
|
+
'Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.': '一次性更新所有符合条件的数据,在数据量较大时有比较好的性能;但被更新的数据不会触发其他工作流,也不会记录更新日志。',
|
|
166
|
+
'The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.': '被更新的数据可以再次触发其他工作流,也会记录更新日志;但通常只适用于数条或数十条数据,否则会有性能问题。',
|
|
162
167
|
'Query record': '查询数据',
|
|
163
168
|
'Query records from a collection. You can use variables from upstream nodes as query conditions.': '查询一个数据表中的数据。可以使用上游节点里的变量作为查询条件。',
|
|
164
169
|
'Allow multiple records as result': '允许结果是多条数据',
|
|
@@ -287,7 +287,7 @@ function InnerJobButton(_ref2) {
|
|
|
287
287
|
color = _JobStatusOptionsMap$.color;
|
|
288
288
|
return _react().default.createElement(_antd().Button, _objectSpread(_objectSpread({}, props), {}, {
|
|
289
289
|
shape: "circle",
|
|
290
|
-
className: _style.nodeJobButtonClass
|
|
290
|
+
className: (0, _css().cx)(_style.nodeJobButtonClass, props.className)
|
|
291
291
|
}), _react().default.createElement(_antd().Tag, {
|
|
292
292
|
color: color
|
|
293
293
|
}, icon));
|
|
@@ -336,7 +336,7 @@ function JobButton() {
|
|
|
336
336
|
}
|
|
337
337
|
`
|
|
338
338
|
}, _react().default.createElement("span", {
|
|
339
|
-
className: _style.nodeJobButtonClass
|
|
339
|
+
className: (0, _css().cx)(_style.nodeJobButtonClass, 'inner')
|
|
340
340
|
}, _react().default.createElement(_antd().Tag, {
|
|
341
341
|
color: color
|
|
342
342
|
}, icon)), _react().default.createElement("time", null, (0, _client().str2moment)(job.updatedAt).format('YYYY-MM-DD HH:mm:ss')))
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { useCollectionDataSource } from '@nocobase/client';
|
|
2
3
|
import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
|
|
4
|
+
declare function IndividualHooksRadioWithTooltip({ onChange, ...props }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
onChange: any;
|
|
7
|
+
}): React.JSX.Element;
|
|
3
8
|
declare const _default: {
|
|
4
9
|
title: string;
|
|
5
10
|
type: string;
|
|
@@ -20,6 +25,20 @@ declare const _default: {
|
|
|
20
25
|
params: {
|
|
21
26
|
type: string;
|
|
22
27
|
properties: {
|
|
28
|
+
individualHooks: {
|
|
29
|
+
type: string;
|
|
30
|
+
title: string;
|
|
31
|
+
'x-decorator': string;
|
|
32
|
+
'x-component': string;
|
|
33
|
+
'x-component-props': {
|
|
34
|
+
options: {
|
|
35
|
+
label: string;
|
|
36
|
+
value: boolean;
|
|
37
|
+
tooltip: string;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
23
42
|
filter: {
|
|
24
43
|
title: string;
|
|
25
44
|
"x-validator"(value: any): string;
|
|
@@ -35,6 +54,9 @@ declare const _default: {
|
|
|
35
54
|
};
|
|
36
55
|
};
|
|
37
56
|
values: {
|
|
57
|
+
'x-component-props': {
|
|
58
|
+
filter(this: any, field: any): any;
|
|
59
|
+
};
|
|
38
60
|
type: string;
|
|
39
61
|
title: string;
|
|
40
62
|
'x-decorator': string;
|
|
@@ -54,7 +76,8 @@ declare const _default: {
|
|
|
54
76
|
};
|
|
55
77
|
components: {
|
|
56
78
|
FilterDynamicComponent: typeof FilterDynamicComponent;
|
|
57
|
-
CollectionFieldset:
|
|
79
|
+
CollectionFieldset: React.MemoExoticComponent<import("@formily/react").ReactFC<Pick<any, string | number | symbol>>>;
|
|
80
|
+
IndividualHooksRadioWithTooltip: typeof IndividualHooksRadioWithTooltip;
|
|
58
81
|
};
|
|
59
82
|
};
|
|
60
83
|
export default _default;
|
|
@@ -4,6 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
function _react() {
|
|
8
|
+
const data = _interopRequireDefault(require("react"));
|
|
9
|
+
_react = function _react() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react2() {
|
|
15
|
+
const data = require("@formily/react");
|
|
16
|
+
_react2 = function _react2() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
7
21
|
function _client() {
|
|
8
22
|
const data = require("@nocobase/client");
|
|
9
23
|
_client = function _client() {
|
|
@@ -12,16 +26,49 @@ function _client() {
|
|
|
12
26
|
return data;
|
|
13
27
|
}
|
|
14
28
|
var _FilterDynamicComponent = require("../components/FilterDynamicComponent");
|
|
15
|
-
var _CollectionFieldset =
|
|
29
|
+
var _CollectionFieldset = _interopRequireWildcard(require("../components/CollectionFieldset"));
|
|
16
30
|
var _utils = require("../utils");
|
|
17
31
|
var _locale = require("../locale");
|
|
18
32
|
var _collection = require("../schemas/collection");
|
|
33
|
+
var _RadioWithTooltip = require("../components/RadioWithTooltip");
|
|
34
|
+
const _excluded = ["onChange"];
|
|
35
|
+
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); }
|
|
36
|
+
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; }
|
|
19
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
38
|
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; }
|
|
21
39
|
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; }
|
|
22
40
|
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; }
|
|
23
41
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
42
|
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); }
|
|
43
|
+
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; }
|
|
44
|
+
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; }
|
|
45
|
+
function IndividualHooksRadioWithTooltip(_ref) {
|
|
46
|
+
let onChange = _ref.onChange,
|
|
47
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
48
|
+
const form = (0, _react2().useForm)();
|
|
49
|
+
const collection = form.values.collection;
|
|
50
|
+
const fields = (0, _CollectionFieldset.useCollectionUIFields)(collection);
|
|
51
|
+
const field = (0, _react2().useField)();
|
|
52
|
+
function onValueChange({
|
|
53
|
+
target
|
|
54
|
+
}) {
|
|
55
|
+
const valuesField = field.query('.values').take();
|
|
56
|
+
if (!valuesField) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const filteredValues = fields.reduce((result, item) => {
|
|
60
|
+
if (item.name in valuesField.value && (target.value || !['hasOne', 'hasMany', 'belongsToMany'].includes(item.type))) {
|
|
61
|
+
result[item.name] = valuesField.value[item.name];
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}, {});
|
|
65
|
+
form.setValuesIn('params.values', filteredValues);
|
|
66
|
+
onChange(target.value);
|
|
67
|
+
}
|
|
68
|
+
return _react().default.createElement(_RadioWithTooltip.RadioWithTooltip, _objectSpread(_objectSpread({}, props), {}, {
|
|
69
|
+
onChange: onValueChange
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
25
72
|
var _default = {
|
|
26
73
|
title: `{{t("Update record", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
27
74
|
type: 'update',
|
|
@@ -32,13 +79,38 @@ var _default = {
|
|
|
32
79
|
params: {
|
|
33
80
|
type: 'object',
|
|
34
81
|
properties: {
|
|
82
|
+
individualHooks: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
title: `{{t("Update mode", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
85
|
+
'x-decorator': 'FormItem',
|
|
86
|
+
'x-component': 'IndividualHooksRadioWithTooltip',
|
|
87
|
+
'x-component-props': {
|
|
88
|
+
options: [{
|
|
89
|
+
label: `{{t("Update in a batch", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
90
|
+
value: false,
|
|
91
|
+
tooltip: `{{t("Update all eligible data at one time, which has better performance when the amount of data is large. But the updated data will not trigger other workflows, and will not record audit logs.", { ns: "${_locale.NAMESPACE}" })}}`
|
|
92
|
+
}, {
|
|
93
|
+
label: `{{t("Update one by one", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
94
|
+
value: true,
|
|
95
|
+
tooltip: `{{t("The updated data can trigger other workflows, and the audit log will also be recorded. But it is usually only applicable to several or dozens of pieces of data, otherwise there will be performance problems.", { ns: "${_locale.NAMESPACE}" })}}`
|
|
96
|
+
}]
|
|
97
|
+
},
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
35
100
|
filter: _objectSpread(_objectSpread({}, _collection.filter), {}, {
|
|
36
101
|
title: `{{t("Only update records matching conditions", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
37
102
|
['x-validator'](value) {
|
|
38
103
|
return (0, _utils.isValidFilter)(value) ? '' : `{{t("Please add at least one condition", { ns: "${_locale.NAMESPACE}" })}}`;
|
|
39
104
|
}
|
|
40
105
|
}),
|
|
41
|
-
values: _collection.values
|
|
106
|
+
values: _objectSpread(_objectSpread({}, _collection.values), {}, {
|
|
107
|
+
'x-component-props': {
|
|
108
|
+
filter(field) {
|
|
109
|
+
var _this$params;
|
|
110
|
+
return ((_this$params = this.params) === null || _this$params === void 0 ? void 0 : _this$params.individualHooks) || !['hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
})
|
|
42
114
|
}
|
|
43
115
|
}
|
|
44
116
|
},
|
|
@@ -48,7 +120,8 @@ var _default = {
|
|
|
48
120
|
},
|
|
49
121
|
components: {
|
|
50
122
|
FilterDynamicComponent: _FilterDynamicComponent.FilterDynamicComponent,
|
|
51
|
-
CollectionFieldset: _CollectionFieldset.default
|
|
123
|
+
CollectionFieldset: _CollectionFieldset.default,
|
|
124
|
+
IndividualHooksRadioWithTooltip
|
|
52
125
|
}
|
|
53
126
|
};
|
|
54
127
|
exports.default = _default;
|
package/lib/client/style.js
CHANGED
|
@@ -19,6 +19,13 @@ function _css() {
|
|
|
19
19
|
};
|
|
20
20
|
return data;
|
|
21
21
|
}
|
|
22
|
+
function _core() {
|
|
23
|
+
const data = require("@formily/core");
|
|
24
|
+
_core = function _core() {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
22
29
|
function _react2() {
|
|
23
30
|
const data = require("@formily/react");
|
|
24
31
|
_react2 = function _react2() {
|
|
@@ -186,24 +193,28 @@ const TriggerConfig = () => {
|
|
|
186
193
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
187
194
|
editingConfig = _useState4[0],
|
|
188
195
|
setEditingConfig = _useState4[1];
|
|
196
|
+
let typeTitle = '';
|
|
189
197
|
(0, _react().useEffect)(() => {
|
|
190
198
|
if (workflow) {
|
|
191
199
|
var _workflow$title;
|
|
192
200
|
setEditingTitle((_workflow$title = workflow.title) !== null && _workflow$title !== void 0 ? _workflow$title : typeTitle);
|
|
193
201
|
}
|
|
194
202
|
}, [workflow]);
|
|
203
|
+
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
204
|
+
values: workflow === null || workflow === void 0 ? void 0 : workflow.config,
|
|
205
|
+
disabled: workflow === null || workflow === void 0 ? void 0 : workflow.executed
|
|
206
|
+
}), [workflow]);
|
|
195
207
|
if (!workflow || !workflow.type) {
|
|
196
208
|
return null;
|
|
197
209
|
}
|
|
198
210
|
const title = workflow.title,
|
|
199
211
|
type = workflow.type,
|
|
200
|
-
config = workflow.config,
|
|
201
212
|
executed = workflow.executed;
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
const trigger = triggers.get(type);
|
|
214
|
+
const fieldset = trigger.fieldset,
|
|
215
|
+
scope = trigger.scope,
|
|
216
|
+
components = trigger.components;
|
|
217
|
+
typeTitle = trigger.title;
|
|
207
218
|
const detailText = executed ? '{{t("View")}}' : '{{t("Configure")}}';
|
|
208
219
|
const titleText = `${(0, _locale.lang)('Trigger')}: ${compile(typeTitle)}`;
|
|
209
220
|
function onChangeTitle(_x2) {
|
|
@@ -261,6 +272,7 @@ const TriggerConfig = () => {
|
|
|
261
272
|
}
|
|
262
273
|
}, _react().default.createElement(_client2().SchemaComponent, {
|
|
263
274
|
schema: {
|
|
275
|
+
name: `workflow-trigger-${workflow.id}`,
|
|
264
276
|
type: 'void',
|
|
265
277
|
properties: {
|
|
266
278
|
config: {
|
|
@@ -276,14 +288,9 @@ const TriggerConfig = () => {
|
|
|
276
288
|
type: 'void',
|
|
277
289
|
title: titleText,
|
|
278
290
|
'x-component': 'Action.Drawer',
|
|
279
|
-
'x-decorator': '
|
|
291
|
+
'x-decorator': 'FormV2',
|
|
280
292
|
'x-decorator-props': {
|
|
281
|
-
|
|
282
|
-
useValues(options) {
|
|
283
|
-
return (0, _client2().useRequest)(() => Promise.resolve({
|
|
284
|
-
data: config
|
|
285
|
-
}), options);
|
|
286
|
-
}
|
|
293
|
+
form
|
|
287
294
|
},
|
|
288
295
|
properties: _objectSpread(_objectSpread({}, executed ? {
|
|
289
296
|
alert: {
|
|
@@ -174,7 +174,17 @@ const ModeFieldsets = {
|
|
|
174
174
|
placeholder: `{{t("No limit", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
175
175
|
min: 0
|
|
176
176
|
}
|
|
177
|
-
}
|
|
177
|
+
},
|
|
178
|
+
appends: _objectSpread(_objectSpread({}, _collection.appends), {}, {
|
|
179
|
+
'x-reactions': [{
|
|
180
|
+
dependencies: ['mode', 'collection'],
|
|
181
|
+
fulfill: {
|
|
182
|
+
state: {
|
|
183
|
+
visible: `{{$deps[0] === ${_constants.SCHEDULE_MODE.COLLECTION_FIELD} && $deps[1]}}`
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}]
|
|
187
|
+
})
|
|
178
188
|
}
|
|
179
189
|
};
|
|
180
190
|
const scheduleModeOptions = [{
|
|
@@ -8,26 +8,6 @@ declare const _default: {
|
|
|
8
8
|
'x-component': string;
|
|
9
9
|
'x-component-props': {};
|
|
10
10
|
};
|
|
11
|
-
appends: {
|
|
12
|
-
'x-reactions': {
|
|
13
|
-
dependencies: string[];
|
|
14
|
-
fulfill: {
|
|
15
|
-
state: {
|
|
16
|
-
visible: string;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}[];
|
|
20
|
-
type: string;
|
|
21
|
-
title: string;
|
|
22
|
-
description: string;
|
|
23
|
-
'x-decorator': string;
|
|
24
|
-
'x-component': string;
|
|
25
|
-
'x-component-props': {
|
|
26
|
-
mode: string;
|
|
27
|
-
placeholder: string;
|
|
28
|
-
filter(field: any): boolean;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
11
|
};
|
|
32
12
|
scope: {
|
|
33
13
|
useCollectionDataSource: typeof useCollectionDataSource;
|
|
@@ -16,13 +16,7 @@ var _constants = require("./constants");
|
|
|
16
16
|
var _locale = require("../../locale");
|
|
17
17
|
var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
|
|
18
18
|
var _variable = require("../../variable");
|
|
19
|
-
var _collection = require("../../schemas/collection");
|
|
20
19
|
var _FieldsSelect = require("../../components/FieldsSelect");
|
|
21
|
-
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; }
|
|
22
|
-
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; }
|
|
23
|
-
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; }
|
|
24
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
25
|
-
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); }
|
|
26
20
|
var _default = {
|
|
27
21
|
title: `{{t("Schedule event", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
28
22
|
type: 'schedule',
|
|
@@ -31,17 +25,7 @@ var _default = {
|
|
|
31
25
|
type: 'void',
|
|
32
26
|
'x-component': 'ScheduleConfig',
|
|
33
27
|
'x-component-props': {}
|
|
34
|
-
}
|
|
35
|
-
appends: _objectSpread(_objectSpread({}, _collection.appends), {}, {
|
|
36
|
-
'x-reactions': [{
|
|
37
|
-
dependencies: ['mode', 'collection'],
|
|
38
|
-
fulfill: {
|
|
39
|
-
state: {
|
|
40
|
-
visible: `{{$deps[0] === ${_constants.SCHEDULE_MODE.COLLECTION_FIELD} && $deps[1]}}`
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}]
|
|
44
|
-
})
|
|
28
|
+
}
|
|
45
29
|
},
|
|
46
30
|
scope: {
|
|
47
31
|
useCollectionDataSource: _client().useCollectionDataSource
|
package/lib/server/Plugin.js
CHANGED
|
@@ -265,9 +265,11 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
265
265
|
workflows.forEach(workflow => {
|
|
266
266
|
_this2.toggle(workflow);
|
|
267
267
|
});
|
|
268
|
+
}));
|
|
269
|
+
_this2.app.on('afterStart', () => {
|
|
268
270
|
// check for not started executions
|
|
269
271
|
_this2.dispatch();
|
|
270
|
-
})
|
|
272
|
+
});
|
|
271
273
|
_this2.app.on('beforeStop', /*#__PURE__*/_asyncToGenerator(function* () {
|
|
272
274
|
const collection = db.getCollection('workflows');
|
|
273
275
|
const workflows = yield collection.repository.find({
|
|
@@ -301,8 +303,9 @@ class WorkflowPlugin extends _server().Plugin {
|
|
|
301
303
|
return;
|
|
302
304
|
}
|
|
303
305
|
this.events.push([workflow, context, options]);
|
|
304
|
-
this.getLogger(workflow.id).
|
|
305
|
-
|
|
306
|
+
this.getLogger(workflow.id).info(`new event triggered, now events: ${this.events.length}`);
|
|
307
|
+
this.getLogger(workflow.id).debug(`event data:`, {
|
|
308
|
+
data: context
|
|
306
309
|
});
|
|
307
310
|
if (this.events.length > 1) {
|
|
308
311
|
return;
|
|
@@ -31,9 +31,9 @@ export default class Processor {
|
|
|
31
31
|
private commit;
|
|
32
32
|
private exec;
|
|
33
33
|
run(node: any, input?: any): any;
|
|
34
|
-
end(node: any, job:
|
|
34
|
+
end(node: any, job: JobModel): Promise<any>;
|
|
35
35
|
recall(node: any, job: any): Promise<any>;
|
|
36
|
-
exit(
|
|
36
|
+
exit(s?: number): Promise<any>;
|
|
37
37
|
saveJob(payload: any): Promise<any>;
|
|
38
38
|
getBranches(node: FlowNodeModel): FlowNodeModel[];
|
|
39
39
|
findBranchStartNode(node: FlowNodeModel, parent?: FlowNodeModel): FlowNodeModel | null;
|
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,7 +123,7 @@ 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
128
|
})();
|
|
129
129
|
}
|
|
@@ -223,7 +223,7 @@ class Processor {
|
|
|
223
223
|
}
|
|
224
224
|
// really done for all nodes
|
|
225
225
|
// * should mark execution as done with last job status
|
|
226
|
-
return _this8.exit(job);
|
|
226
|
+
return _this8.exit(job.status);
|
|
227
227
|
})();
|
|
228
228
|
}
|
|
229
229
|
recall(node, job) {
|
|
@@ -237,17 +237,19 @@ class Processor {
|
|
|
237
237
|
return _this9.exec(instruction.resume.bind(instruction), node, job);
|
|
238
238
|
})();
|
|
239
239
|
}
|
|
240
|
-
exit(
|
|
240
|
+
exit(s) {
|
|
241
241
|
var _this10 = this;
|
|
242
242
|
return _asyncToGenerator(function* () {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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}`);
|
|
251
253
|
yield _this10.commit();
|
|
252
254
|
return null;
|
|
253
255
|
})();
|
|
@@ -265,15 +267,10 @@ class Processor {
|
|
|
265
267
|
transaction: _this11.transaction
|
|
266
268
|
});
|
|
267
269
|
} else if (payload.id) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
id: payload.id
|
|
271
|
-
},
|
|
272
|
-
returning: true,
|
|
270
|
+
job = yield model.findByPk(payload.id);
|
|
271
|
+
yield job.update(payload, {
|
|
273
272
|
transaction: _this11.transaction
|
|
274
273
|
});
|
|
275
|
-
var _yield$model$update2 = _slicedToArray(_yield$model$update, 1);
|
|
276
|
-
job = _yield$model$update2[0];
|
|
277
274
|
} else {
|
|
278
275
|
job = yield model.create(_objectSpread(_objectSpread({}, payload), {}, {
|
|
279
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);
|
|
@@ -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
|
})();
|
package/package.json
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": " a powerful workflow plugin designed to support business process management and automation. .",
|
|
6
6
|
"description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
|
|
7
|
-
"version": "0.10.0-alpha.
|
|
7
|
+
"version": "0.10.0-alpha.4",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./lib/index.js",
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@nocobase/actions": "0.10.0-alpha.
|
|
13
|
-
"@nocobase/client": "0.10.0-alpha.
|
|
14
|
-
"@nocobase/database": "0.10.0-alpha.
|
|
15
|
-
"@nocobase/evaluators": "0.10.0-alpha.
|
|
16
|
-
"@nocobase/logger": "0.10.0-alpha.
|
|
17
|
-
"@nocobase/resourcer": "0.10.0-alpha.
|
|
18
|
-
"@nocobase/server": "0.10.0-alpha.
|
|
19
|
-
"@nocobase/utils": "0.10.0-alpha.
|
|
12
|
+
"@nocobase/actions": "0.10.0-alpha.4",
|
|
13
|
+
"@nocobase/client": "0.10.0-alpha.4",
|
|
14
|
+
"@nocobase/database": "0.10.0-alpha.4",
|
|
15
|
+
"@nocobase/evaluators": "0.10.0-alpha.4",
|
|
16
|
+
"@nocobase/logger": "0.10.0-alpha.4",
|
|
17
|
+
"@nocobase/resourcer": "0.10.0-alpha.4",
|
|
18
|
+
"@nocobase/server": "0.10.0-alpha.4",
|
|
19
|
+
"@nocobase/utils": "0.10.0-alpha.4",
|
|
20
20
|
"antd": "^4.24.8",
|
|
21
21
|
"axios": "^0.27.2",
|
|
22
22
|
"classnames": "^2.3.1",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"react-js-cron": "^3.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@nocobase/plugin-formula-field": "0.10.0-alpha.
|
|
30
|
-
"@nocobase/test": "0.10.0-alpha.
|
|
29
|
+
"@nocobase/plugin-formula-field": "0.10.0-alpha.4",
|
|
30
|
+
"@nocobase/test": "0.10.0-alpha.4",
|
|
31
31
|
"@types/ejs": "^3.1.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "62dacadb2a83d30cb36dda9074f2f3a072a37484"
|
|
34
34
|
}
|