@nocobase/plugin-workflow 0.8.0-alpha.9 → 0.8.1-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 +21 -13
- package/lib/client/ExecutionCanvas.js +9 -21
- package/lib/client/ExecutionResourceProvider.d.ts +2 -1
- package/lib/client/ExecutionResourceProvider.js +4 -3
- package/lib/client/FlowContext.js +1 -1
- package/lib/client/WorkflowCanvas.js +135 -36
- package/lib/client/WorkflowProvider.d.ts +3 -0
- package/lib/client/WorkflowProvider.js +71 -16
- package/lib/client/WorkflowShortcut.d.ts +0 -1
- package/lib/client/WorkflowShortcut.js +4 -47
- package/lib/client/calculators.d.ts +27 -37
- package/lib/client/calculators.js +168 -150
- package/lib/client/components/CollectionFieldset.js +10 -20
- package/lib/client/components/Duration.js +3 -14
- package/lib/client/components/EjsTextArea.d.ts +2 -0
- package/lib/client/components/EjsTextArea.js +232 -0
- package/lib/client/components/OpenDrawer.d.ts +6 -0
- package/lib/client/components/OpenDrawer.js +93 -0
- package/lib/client/constants.js +11 -9
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +14 -0
- package/lib/client/locale/en-US.d.ts +105 -0
- package/lib/client/locale/en-US.js +111 -0
- package/lib/client/locale/index.d.ts +3 -0
- package/lib/client/locale/index.js +69 -0
- package/lib/client/locale/ja-JP.d.ts +88 -0
- package/lib/client/locale/ja-JP.js +94 -0
- package/lib/client/locale/ru-RU.d.ts +88 -0
- package/lib/client/locale/ru-RU.js +94 -0
- package/lib/client/locale/tr-TR.d.ts +88 -0
- package/lib/client/locale/tr-TR.js +94 -0
- package/lib/client/locale/zh-CN.d.ts +130 -0
- package/lib/client/locale/zh-CN.js +136 -0
- package/lib/client/nodes/calculation.d.ts +0 -1
- package/lib/client/nodes/calculation.js +9 -17
- package/lib/client/nodes/condition.js +16 -22
- package/lib/client/nodes/create.d.ts +3 -1
- package/lib/client/nodes/create.js +11 -11
- package/lib/client/nodes/delay.js +8 -6
- package/lib/client/nodes/index.js +46 -14
- package/lib/client/nodes/parallel.d.ts +0 -1
- package/lib/client/nodes/parallel.js +11 -32
- package/lib/client/nodes/query.js +9 -17
- package/lib/client/nodes/request.d.ts +138 -0
- package/lib/client/nodes/request.js +167 -0
- package/lib/client/nodes/update.js +4 -2
- package/lib/client/schemas/collection.js +3 -1
- package/lib/client/schemas/executions.d.ts +211 -207
- package/lib/client/schemas/executions.js +102 -96
- package/lib/client/schemas/workflows.js +112 -22
- package/lib/client/style.js +7 -7
- package/lib/client/triggers/collection.d.ts +2 -1
- package/lib/client/triggers/collection.js +49 -34
- package/lib/client/triggers/index.d.ts +3 -3
- package/lib/client/triggers/index.js +46 -46
- package/lib/client/triggers/schedule/EndsByField.js +13 -39
- package/lib/client/triggers/schedule/OnField.js +10 -5
- package/lib/client/triggers/schedule/RepeatField.js +6 -14
- package/lib/client/triggers/schedule/ScheduleConfig.js +25 -20
- package/lib/client/triggers/schedule/constants.d.ts +4 -0
- package/lib/client/triggers/schedule/constants.js +11 -0
- package/lib/client/triggers/schedule/index.d.ts +2 -3
- package/lib/client/triggers/schedule/index.js +55 -40
- package/lib/server/Plugin.d.ts +15 -5
- package/lib/server/Plugin.js +176 -61
- package/lib/server/Processor.d.ts +1 -2
- package/lib/server/Processor.js +3 -19
- package/lib/server/actions/jobs.js +2 -3
- package/lib/server/actions/workflows.js +13 -5
- package/lib/server/calculators/index.d.ts +4 -2
- package/lib/server/calculators/index.js +6 -4
- package/lib/server/collections/executions.js +2 -1
- package/lib/server/constants.d.ts +1 -0
- package/lib/server/constants.js +1 -0
- package/lib/server/extensions/assignees/actions.js +2 -3
- package/lib/server/extensions/assignees/collections/users_jobs.js +9 -1
- package/lib/server/index.d.ts +3 -4
- package/lib/server/index.js +21 -44
- package/lib/server/instructions/condition.js +1 -1
- package/lib/server/instructions/create.js +3 -1
- package/lib/server/instructions/delay.js +2 -3
- package/lib/server/instructions/destroy.js +3 -1
- package/lib/server/instructions/index.d.ts +3 -2
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/prompt.js +2 -1
- package/lib/server/instructions/query.js +3 -1
- package/lib/server/instructions/request.d.ts +14 -0
- package/lib/server/instructions/request.js +154 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/instructions/update.js +3 -1
- package/lib/server/migrations/20221129153547-calculation-variables.d.ts +5 -0
- package/lib/server/migrations/20221129153547-calculation-variables.js +116 -0
- package/lib/server/triggers/collection.js +5 -7
- package/lib/server/triggers/schedule.js +17 -6
- package/package.json +13 -8
|
@@ -93,6 +93,8 @@ var _collection = _interopRequireDefault(require("./collection"));
|
|
|
93
93
|
|
|
94
94
|
var _schedule = _interopRequireDefault(require("./schedule/"));
|
|
95
95
|
|
|
96
|
+
var _locale = require("../locale");
|
|
97
|
+
|
|
96
98
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
97
99
|
|
|
98
100
|
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); } }
|
|
@@ -119,6 +121,8 @@ function useUpdateConfigAction() {
|
|
|
119
121
|
return {
|
|
120
122
|
run() {
|
|
121
123
|
return _asyncToGenerator(function* () {
|
|
124
|
+
var _api$resource$update, _api$resource;
|
|
125
|
+
|
|
122
126
|
if (workflow.executed) {
|
|
123
127
|
_antd().message.error(t('Trigger in executed workflow cannot be modified'));
|
|
124
128
|
|
|
@@ -126,7 +130,7 @@ function useUpdateConfigAction() {
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
yield form.submit();
|
|
129
|
-
yield api.resource('workflows').update({
|
|
133
|
+
yield (_api$resource$update = (_api$resource = api.resource('workflows')).update) === null || _api$resource$update === void 0 ? void 0 : _api$resource$update.call(_api$resource, {
|
|
130
134
|
filterByTk: workflow.id,
|
|
131
135
|
values: form.values
|
|
132
136
|
});
|
|
@@ -160,54 +164,50 @@ function TriggerExecution() {
|
|
|
160
164
|
return _react2().default.createElement(_client2().SchemaComponent, {
|
|
161
165
|
schema: {
|
|
162
166
|
type: 'void',
|
|
167
|
+
name: 'execution',
|
|
168
|
+
'x-component': 'Action',
|
|
169
|
+
'x-component-props': {
|
|
170
|
+
title: _react2().default.createElement(_icons().InfoOutlined, null),
|
|
171
|
+
shape: 'circle',
|
|
172
|
+
className: 'workflow-node-job-button',
|
|
173
|
+
type: 'primary'
|
|
174
|
+
},
|
|
163
175
|
properties: {
|
|
164
|
-
|
|
176
|
+
[execution.id]: {
|
|
165
177
|
type: 'void',
|
|
166
|
-
'x-
|
|
167
|
-
'x-
|
|
168
|
-
|
|
169
|
-
shape: 'circle',
|
|
170
|
-
className: 'workflow-node-job-button',
|
|
171
|
-
type: 'primary'
|
|
178
|
+
'x-decorator': 'Form',
|
|
179
|
+
'x-decorator-props': {
|
|
180
|
+
initialValue: execution
|
|
172
181
|
},
|
|
182
|
+
'x-component': 'Action.Modal',
|
|
183
|
+
title: _react2().default.createElement("div", {
|
|
184
|
+
className: (0, _css().cx)(_style.nodeTitleClass)
|
|
185
|
+
}, _react2().default.createElement(_antd().Tag, null, compile(trigger.title)), _react2().default.createElement("strong", null, workflow.title), _react2().default.createElement("span", {
|
|
186
|
+
className: "workflow-node-id"
|
|
187
|
+
}, "#", execution.id)),
|
|
173
188
|
properties: {
|
|
174
|
-
|
|
175
|
-
type: '
|
|
176
|
-
|
|
177
|
-
'x-decorator
|
|
178
|
-
|
|
189
|
+
createdAt: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
title: `{{t("Triggered at", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
192
|
+
'x-decorator': 'FormItem',
|
|
193
|
+
'x-component': 'DatePicker',
|
|
194
|
+
'x-component-props': {
|
|
195
|
+
showTime: true
|
|
179
196
|
},
|
|
180
|
-
'x-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
'x-read-pretty': true
|
|
196
|
-
},
|
|
197
|
-
context: {
|
|
198
|
-
type: 'object',
|
|
199
|
-
title: '{{t("Trigger context")}}',
|
|
200
|
-
'x-decorator': 'FormItem',
|
|
201
|
-
'x-component': 'Input.JSON',
|
|
202
|
-
'x-component-props': {
|
|
203
|
-
className: (0, _css().css)`
|
|
204
|
-
padding: 1em;
|
|
205
|
-
background-color: #eee;
|
|
206
|
-
`
|
|
207
|
-
},
|
|
208
|
-
'x-read-pretty': true
|
|
209
|
-
}
|
|
210
|
-
}
|
|
197
|
+
'x-read-pretty': true
|
|
198
|
+
},
|
|
199
|
+
context: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
title: `{{t("Trigger variables", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
202
|
+
'x-decorator': 'FormItem',
|
|
203
|
+
'x-component': 'Input.JSON',
|
|
204
|
+
'x-component-props': {
|
|
205
|
+
className: (0, _css().css)`
|
|
206
|
+
padding: 1em;
|
|
207
|
+
background-color: #eee;
|
|
208
|
+
`
|
|
209
|
+
},
|
|
210
|
+
'x-read-pretty': true
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -240,7 +240,7 @@ const TriggerConfig = () => {
|
|
|
240
240
|
components = _triggers$get.components;
|
|
241
241
|
|
|
242
242
|
const detailText = executed ? '{{t("View")}}' : '{{t("Configure")}}';
|
|
243
|
-
const titleText = `${
|
|
243
|
+
const titleText = `${(0, _locale.lang)('Trigger')}: ${compile(title)}`;
|
|
244
244
|
return _react2().default.createElement("div", {
|
|
245
245
|
className: (0, _css().cx)(_style.nodeCardClass)
|
|
246
246
|
}, _react2().default.createElement("div", {
|
|
@@ -249,7 +249,7 @@ const TriggerConfig = () => {
|
|
|
249
249
|
className: (0, _css().cx)(_style.nodeMetaClass)
|
|
250
250
|
}, _react2().default.createElement(_antd().Tag, {
|
|
251
251
|
color: "gold"
|
|
252
|
-
},
|
|
252
|
+
}, (0, _locale.lang)('Trigger'))), _react2().default.createElement("h4", null, compile(title)), _react2().default.createElement(TriggerExecution, null)), _react2().default.createElement(_client2().SchemaComponent, {
|
|
253
253
|
schema: {
|
|
254
254
|
type: 'void',
|
|
255
255
|
title: detailText,
|
|
@@ -36,7 +36,7 @@ function _moment() {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function _react() {
|
|
39
|
-
const data =
|
|
39
|
+
const data = _interopRequireDefault(require("react"));
|
|
40
40
|
|
|
41
41
|
_react = function _react() {
|
|
42
42
|
return data;
|
|
@@ -45,48 +45,20 @@ function _react() {
|
|
|
45
45
|
return data;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
const data = require("react-i18next");
|
|
50
|
-
|
|
51
|
-
_reactI18next = function _reactI18next() {
|
|
52
|
-
return data;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
48
|
+
var _locale = require("../../locale");
|
|
57
49
|
|
|
58
50
|
var _OnField = require("./OnField");
|
|
59
51
|
|
|
60
|
-
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); }
|
|
61
|
-
|
|
62
|
-
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; }
|
|
63
|
-
|
|
64
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
65
53
|
|
|
66
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
67
|
-
|
|
68
|
-
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."); }
|
|
69
|
-
|
|
70
|
-
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); }
|
|
71
|
-
|
|
72
|
-
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; }
|
|
73
|
-
|
|
74
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
75
|
-
|
|
76
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
77
|
-
|
|
78
54
|
function EndsByField({
|
|
79
55
|
value,
|
|
80
56
|
onChange: _onChange
|
|
81
57
|
}) {
|
|
82
|
-
const
|
|
83
|
-
t =
|
|
84
|
-
|
|
85
|
-
const _useState = (0, _react().useState)(typeof value === 'object' && !(value instanceof Date) ? 'field' : 'date'),
|
|
86
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
-
type = _useState2[0],
|
|
88
|
-
setType = _useState2[1];
|
|
58
|
+
const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
|
|
59
|
+
t = _useWorkflowTranslati.t;
|
|
89
60
|
|
|
61
|
+
const type = value != null ? typeof value === 'object' && !(value instanceof Date) ? 'field' : 'date' : null;
|
|
90
62
|
return _react().default.createElement("fieldset", {
|
|
91
63
|
className: (0, _css().css)`
|
|
92
64
|
display: flex;
|
|
@@ -95,20 +67,22 @@ function EndsByField({
|
|
|
95
67
|
}, _react().default.createElement(_antd().Select, {
|
|
96
68
|
value: type,
|
|
97
69
|
onChange: t => {
|
|
98
|
-
_onChange(t === 'field' ? {} : null);
|
|
99
|
-
|
|
100
|
-
setType(t);
|
|
70
|
+
_onChange(t ? t === 'field' ? {} : new Date() : null);
|
|
101
71
|
}
|
|
102
72
|
}, _react().default.createElement(_antd().Select.Option, {
|
|
73
|
+
value: null
|
|
74
|
+
}, t('No end')), _react().default.createElement(_antd().Select.Option, {
|
|
103
75
|
value: 'field'
|
|
104
76
|
}, t('By field')), _react().default.createElement(_antd().Select.Option, {
|
|
105
77
|
value: 'date'
|
|
106
78
|
}, t('By custom date'))), type === 'field' ? _react().default.createElement(_OnField.OnField, {
|
|
107
79
|
value: value,
|
|
108
80
|
onChange: _onChange
|
|
109
|
-
}) : _react().default.createElement(_antd().DatePicker, {
|
|
81
|
+
}) : null, type === 'date' ? _react().default.createElement(_antd().DatePicker, {
|
|
110
82
|
showTime: true,
|
|
111
83
|
value: (0, _moment().default)(value),
|
|
112
|
-
onChange:
|
|
113
|
-
|
|
84
|
+
onChange: v => {
|
|
85
|
+
_onChange(v ? v.toDate() : null);
|
|
86
|
+
}
|
|
87
|
+
}) : null);
|
|
114
88
|
}
|
|
@@ -47,6 +47,8 @@ function _reactI18next() {
|
|
|
47
47
|
|
|
48
48
|
var _DateFieldsSelect = require("./DateFieldsSelect");
|
|
49
49
|
|
|
50
|
+
var _locale = require("../../locale");
|
|
51
|
+
|
|
50
52
|
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); }
|
|
51
53
|
|
|
52
54
|
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; }
|
|
@@ -76,6 +78,9 @@ function OnField({
|
|
|
76
78
|
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
77
79
|
t = _useTranslation.t;
|
|
78
80
|
|
|
81
|
+
const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
|
|
82
|
+
localT = _useWorkflowTranslati.t;
|
|
83
|
+
|
|
79
84
|
const _useState = (0, _react().useState)(value.offset ? value.offset / Math.abs(value.offset) : 0),
|
|
80
85
|
_useState2 = _slicedToArray(_useState, 2),
|
|
81
86
|
dir = _useState2[0],
|
|
@@ -102,7 +107,7 @@ function OnField({
|
|
|
102
107
|
}
|
|
103
108
|
}, _react().default.createElement(_antd().Select.Option, {
|
|
104
109
|
value: 0
|
|
105
|
-
},
|
|
110
|
+
}, localT('Exactly at')), _react().default.createElement(_antd().Select.Option, {
|
|
106
111
|
value: -1
|
|
107
112
|
}, t('Before')), _react().default.createElement(_antd().Select.Option, {
|
|
108
113
|
value: 1
|
|
@@ -118,11 +123,11 @@ function OnField({
|
|
|
118
123
|
}))
|
|
119
124
|
}, _react().default.createElement(_antd().Select.Option, {
|
|
120
125
|
value: 86400000
|
|
121
|
-
},
|
|
126
|
+
}, localT('Days')), _react().default.createElement(_antd().Select.Option, {
|
|
122
127
|
value: 3600000
|
|
123
|
-
},
|
|
128
|
+
}, localT('Hours')), _react().default.createElement(_antd().Select.Option, {
|
|
124
129
|
value: 60000
|
|
125
|
-
},
|
|
130
|
+
}, localT('Minutes')), _react().default.createElement(_antd().Select.Option, {
|
|
126
131
|
value: 1000
|
|
127
|
-
},
|
|
132
|
+
}, localT('Seconds')))) : null);
|
|
128
133
|
}
|
|
@@ -35,16 +35,6 @@ function _react() {
|
|
|
35
35
|
return data;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
function _reactI18next() {
|
|
39
|
-
const data = require("react-i18next");
|
|
40
|
-
|
|
41
|
-
_reactI18next = function _reactI18next() {
|
|
42
|
-
return data;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
38
|
function _reactJsCron() {
|
|
49
39
|
const data = require("react-js-cron");
|
|
50
40
|
|
|
@@ -55,6 +45,8 @@ function _reactJsCron() {
|
|
|
55
45
|
return data;
|
|
56
46
|
}
|
|
57
47
|
|
|
48
|
+
var _locale = require("../../locale");
|
|
49
|
+
|
|
58
50
|
var _Cron = _interopRequireDefault(require("./locale/Cron.zh-CN"));
|
|
59
51
|
|
|
60
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -112,8 +104,8 @@ function CommonRepeatField({
|
|
|
112
104
|
value,
|
|
113
105
|
onChange: _onChange
|
|
114
106
|
}) {
|
|
115
|
-
const
|
|
116
|
-
t =
|
|
107
|
+
const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
|
|
108
|
+
t = _useWorkflowTranslati.t;
|
|
117
109
|
|
|
118
110
|
const option = getNumberOption(value);
|
|
119
111
|
return _react().default.createElement(_antd().InputNumber, {
|
|
@@ -129,8 +121,8 @@ function RepeatField({
|
|
|
129
121
|
value = null,
|
|
130
122
|
onChange
|
|
131
123
|
}) {
|
|
132
|
-
const
|
|
133
|
-
t =
|
|
124
|
+
const _useWorkflowTranslati2 = (0, _locale.useWorkflowTranslation)(),
|
|
125
|
+
t = _useWorkflowTranslati2.t;
|
|
134
126
|
|
|
135
127
|
const typeValue = getRepeatTypeValue(value);
|
|
136
128
|
|
|
@@ -63,6 +63,10 @@ var _EndsByField = require("./EndsByField");
|
|
|
63
63
|
|
|
64
64
|
var _RepeatField = require("./RepeatField");
|
|
65
65
|
|
|
66
|
+
var _constants = require("./constants");
|
|
67
|
+
|
|
68
|
+
var _locale = require("../../locale");
|
|
69
|
+
|
|
66
70
|
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); }
|
|
67
71
|
|
|
68
72
|
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; }
|
|
@@ -86,11 +90,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
86
90
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
87
91
|
|
|
88
92
|
const ModeFieldsets = {
|
|
89
|
-
|
|
93
|
+
[_constants.SCHEDULE_MODE.STATIC]: {
|
|
90
94
|
startsOn: {
|
|
91
95
|
type: 'datetime',
|
|
92
96
|
name: 'startsOn',
|
|
93
|
-
title:
|
|
97
|
+
title: `{{t("Starts on", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
94
98
|
'x-decorator': 'FormItem',
|
|
95
99
|
'x-component': 'DatePicker',
|
|
96
100
|
'x-component-props': {
|
|
@@ -101,7 +105,7 @@ const ModeFieldsets = {
|
|
|
101
105
|
repeat: {
|
|
102
106
|
type: 'string',
|
|
103
107
|
name: 'repeat',
|
|
104
|
-
title:
|
|
108
|
+
title: `{{t("Repeat mode", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
105
109
|
'x-decorator': 'FormItem',
|
|
106
110
|
'x-component': 'RepeatField',
|
|
107
111
|
'x-reactions': [{
|
|
@@ -123,7 +127,7 @@ const ModeFieldsets = {
|
|
|
123
127
|
endsOn: {
|
|
124
128
|
type: 'datetime',
|
|
125
129
|
name: 'endsOn',
|
|
126
|
-
title:
|
|
130
|
+
title: `{{t("Ends on", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
127
131
|
'x-decorator': 'FormItem',
|
|
128
132
|
'x-component': 'DatePicker',
|
|
129
133
|
'x-component-props': {
|
|
@@ -133,16 +137,16 @@ const ModeFieldsets = {
|
|
|
133
137
|
limit: {
|
|
134
138
|
type: 'number',
|
|
135
139
|
name: 'limit',
|
|
136
|
-
title:
|
|
140
|
+
title: `{{t("Repeat limit", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
137
141
|
'x-decorator': 'FormItem',
|
|
138
142
|
'x-component': 'InputNumber',
|
|
139
143
|
'x-component-props': {
|
|
140
|
-
placeholder:
|
|
144
|
+
placeholder: `{{t("No limit", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
141
145
|
min: 0
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
},
|
|
145
|
-
|
|
149
|
+
[_constants.SCHEDULE_MODE.COLLECTION_FIELD]: {
|
|
146
150
|
collection: _objectSpread(_objectSpread({}, _collection.collection), {}, {
|
|
147
151
|
'x-reactions': [..._collection.collection['x-reactions'], {
|
|
148
152
|
// only full path works
|
|
@@ -156,7 +160,7 @@ const ModeFieldsets = {
|
|
|
156
160
|
}),
|
|
157
161
|
startsOn: {
|
|
158
162
|
type: 'object',
|
|
159
|
-
title:
|
|
163
|
+
title: `{{t("Starts on", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
160
164
|
'x-decorator': 'FormItem',
|
|
161
165
|
'x-component': 'OnField',
|
|
162
166
|
'x-reactions': [{
|
|
@@ -172,7 +176,7 @@ const ModeFieldsets = {
|
|
|
172
176
|
repeat: {
|
|
173
177
|
type: 'string',
|
|
174
178
|
name: 'repeat',
|
|
175
|
-
title:
|
|
179
|
+
title: `{{t("Repeat mode", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
176
180
|
'x-decorator': 'FormItem',
|
|
177
181
|
'x-component': 'RepeatField',
|
|
178
182
|
'x-reactions': [{
|
|
@@ -193,23 +197,30 @@ const ModeFieldsets = {
|
|
|
193
197
|
},
|
|
194
198
|
endsOn: {
|
|
195
199
|
type: 'object',
|
|
196
|
-
title:
|
|
200
|
+
title: `{{t("Ends on", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
197
201
|
'x-decorator': 'FormItem',
|
|
198
202
|
'x-component': 'EndsByField'
|
|
199
203
|
},
|
|
200
204
|
limit: {
|
|
201
205
|
type: 'number',
|
|
202
206
|
name: 'limit',
|
|
203
|
-
title:
|
|
207
|
+
title: `{{t("Repeat limit", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
204
208
|
'x-decorator': 'FormItem',
|
|
205
209
|
'x-component': 'InputNumber',
|
|
206
210
|
'x-component-props': {
|
|
207
|
-
placeholder:
|
|
211
|
+
placeholder: `{{t("No limit", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
208
212
|
min: 0
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
};
|
|
217
|
+
const scheduleModeOptions = [{
|
|
218
|
+
value: _constants.SCHEDULE_MODE.STATIC,
|
|
219
|
+
label: `{{t("Based on certain date", { ns: "${_locale.NAMESPACE}" })}}`
|
|
220
|
+
}, {
|
|
221
|
+
value: _constants.SCHEDULE_MODE.COLLECTION_FIELD,
|
|
222
|
+
label: `{{t("Based on date field of collection", { ns: "${_locale.NAMESPACE}" })}}`
|
|
223
|
+
}];
|
|
213
224
|
|
|
214
225
|
const ScheduleConfig = () => {
|
|
215
226
|
const _useForm = (0, _react2().useForm)(),
|
|
@@ -238,18 +249,12 @@ const ScheduleConfig = () => {
|
|
|
238
249
|
return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_client().SchemaComponent, {
|
|
239
250
|
schema: {
|
|
240
251
|
type: 'number',
|
|
241
|
-
title:
|
|
252
|
+
title: `{{t("Trigger mode", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
242
253
|
name: 'mode',
|
|
243
254
|
'x-decorator': 'FormItem',
|
|
244
255
|
'x-component': 'Radio.Group',
|
|
245
256
|
'x-component-props': {
|
|
246
|
-
options:
|
|
247
|
-
value: 0,
|
|
248
|
-
label: '{{t("Based on certain date")}}'
|
|
249
|
-
}, {
|
|
250
|
-
value: 1,
|
|
251
|
-
label: '{{t("Based on date field of collection")}}'
|
|
252
|
-
}]
|
|
257
|
+
options: scheduleModeOptions
|
|
253
258
|
},
|
|
254
259
|
required: true
|
|
255
260
|
}
|
|
@@ -16,9 +16,8 @@ declare const _default: {
|
|
|
16
16
|
components: {
|
|
17
17
|
ScheduleConfig: () => JSX.Element;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
options: any;
|
|
19
|
+
getOptions(config: any): any[];
|
|
20
|
+
getter({ onChange }: {
|
|
22
21
|
onChange: any;
|
|
23
22
|
}): JSX.Element;
|
|
24
23
|
};
|
|
@@ -15,16 +15,6 @@ function _react() {
|
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function _reactI18next() {
|
|
19
|
-
const data = require("react-i18next");
|
|
20
|
-
|
|
21
|
-
_reactI18next = function _reactI18next() {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
18
|
function _antd() {
|
|
29
19
|
const data = require("antd");
|
|
30
20
|
|
|
@@ -51,16 +41,14 @@ var _FlowContext = require("../../FlowContext");
|
|
|
51
41
|
|
|
52
42
|
var _calculators = require("../../calculators");
|
|
53
43
|
|
|
54
|
-
|
|
44
|
+
var _constants = require("./constants");
|
|
55
45
|
|
|
56
|
-
|
|
46
|
+
var _locale = require("../../locale");
|
|
57
47
|
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
48
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
49
|
|
|
62
50
|
var _default = {
|
|
63
|
-
title:
|
|
51
|
+
title: `{{t("Schedule event", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
64
52
|
type: 'schedule',
|
|
65
53
|
fieldset: {
|
|
66
54
|
config: {
|
|
@@ -77,15 +65,32 @@ var _default = {
|
|
|
77
65
|
ScheduleConfig: _ScheduleConfig.ScheduleConfig
|
|
78
66
|
},
|
|
79
67
|
|
|
68
|
+
getOptions(config) {
|
|
69
|
+
const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
|
|
70
|
+
t = _useWorkflowTranslati.t;
|
|
71
|
+
|
|
72
|
+
const options = [{
|
|
73
|
+
value: 'date',
|
|
74
|
+
label: t('Trigger time')
|
|
75
|
+
}];
|
|
76
|
+
|
|
77
|
+
if (config.mode === _constants.SCHEDULE_MODE.COLLECTION_FIELD) {
|
|
78
|
+
options.push({
|
|
79
|
+
value: 'data',
|
|
80
|
+
label: t('Trigger data')
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return options;
|
|
85
|
+
},
|
|
86
|
+
|
|
80
87
|
getter({
|
|
81
|
-
type,
|
|
82
|
-
options,
|
|
83
88
|
onChange: _onChange
|
|
84
89
|
}) {
|
|
85
|
-
var _collections$find
|
|
90
|
+
var _collections$find;
|
|
86
91
|
|
|
87
|
-
const
|
|
88
|
-
t =
|
|
92
|
+
const _useWorkflowTranslati2 = (0, _locale.useWorkflowTranslation)(),
|
|
93
|
+
t = _useWorkflowTranslati2.t;
|
|
89
94
|
|
|
90
95
|
const compile = (0, _client().useCompile)();
|
|
91
96
|
|
|
@@ -96,28 +101,38 @@ var _default = {
|
|
|
96
101
|
const _useFlowContext = (0, _FlowContext.useFlowContext)(),
|
|
97
102
|
workflow = _useFlowContext.workflow;
|
|
98
103
|
|
|
104
|
+
const _useOperandContext = (0, _calculators.useOperandContext)(),
|
|
105
|
+
options = _useOperandContext.options;
|
|
106
|
+
|
|
107
|
+
const path = (options === null || options === void 0 ? void 0 : options.path) ? options.path.split('.') : [];
|
|
108
|
+
|
|
109
|
+
if (!options.type || options.type === 'date') {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
99
113
|
const collection = (_collections$find = collections.find(item => item.name === workflow.config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
|
|
100
114
|
fields: []
|
|
101
115
|
};
|
|
102
|
-
return _react().default.createElement(_antd().
|
|
103
|
-
placeholder: t('
|
|
104
|
-
value:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
return _react().default.createElement(_antd().Cascader, {
|
|
117
|
+
placeholder: t('Trigger data'),
|
|
118
|
+
value: path,
|
|
119
|
+
options: collection.fields.filter(field => {
|
|
120
|
+
var _field$uiSchema;
|
|
121
|
+
|
|
122
|
+
return _calculators.BaseTypeSet.has(field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.type);
|
|
123
|
+
}).map(field => {
|
|
124
|
+
var _field$uiSchema2;
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
value: field.name,
|
|
128
|
+
label: compile((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title)
|
|
129
|
+
};
|
|
130
|
+
}),
|
|
131
|
+
onChange: next => {
|
|
132
|
+
_onChange(`{{$context.${next.join('.')}}}`);
|
|
133
|
+
},
|
|
134
|
+
allowClear: false
|
|
135
|
+
});
|
|
121
136
|
}
|
|
122
137
|
|
|
123
138
|
};
|
package/lib/server/Plugin.d.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import { Transactionable } from '@nocobase/database';
|
|
2
1
|
import { Plugin } from '@nocobase/server';
|
|
3
2
|
import { Registry } from '@nocobase/utils';
|
|
4
3
|
import { Instruction } from './instructions';
|
|
5
4
|
import ExecutionModel from './models/Execution';
|
|
6
5
|
import WorkflowModel from './models/Workflow';
|
|
7
|
-
import Processor from './Processor';
|
|
8
6
|
import { Trigger } from './triggers';
|
|
7
|
+
import JobModel from './models/Job';
|
|
8
|
+
declare type Pending = [ExecutionModel, JobModel?];
|
|
9
9
|
export default class WorkflowPlugin extends Plugin {
|
|
10
10
|
instructions: Registry<Instruction>;
|
|
11
11
|
triggers: Registry<Trigger>;
|
|
12
12
|
calculators: Registry<Function>;
|
|
13
13
|
extensions: typeof import("./extensions/assignees").default[];
|
|
14
|
+
executing: ExecutionModel | null;
|
|
15
|
+
pending: Pending[];
|
|
16
|
+
events: [WorkflowModel, any, {
|
|
17
|
+
context?: any;
|
|
18
|
+
}][];
|
|
14
19
|
onBeforeSave: (instance: WorkflowModel, options: any) => Promise<void>;
|
|
15
20
|
load(): Promise<void>;
|
|
16
21
|
toggle(workflow: WorkflowModel, enable?: boolean): void;
|
|
17
|
-
trigger(workflow: WorkflowModel, context: Object, options?:
|
|
22
|
+
trigger(workflow: WorkflowModel, context: Object, options?: {
|
|
18
23
|
context?: any;
|
|
19
|
-
}):
|
|
20
|
-
|
|
24
|
+
}): void;
|
|
25
|
+
private prepare;
|
|
26
|
+
resume(job: any): Promise<void>;
|
|
27
|
+
private dispatch;
|
|
28
|
+
private process;
|
|
29
|
+
private createProcessor;
|
|
21
30
|
}
|
|
31
|
+
export {};
|