@nocobase/plugin-workflow 0.7.1-alpha.5 → 0.7.2-alpha.1
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/client.d.ts +4 -0
- package/client.js +30 -0
- package/lib/client/ExecutionResourceProvider.d.ts +4 -0
- package/lib/client/ExecutionResourceProvider.js +64 -0
- package/lib/client/WorkflowCanvas.d.ts +15 -0
- package/lib/client/WorkflowCanvas.js +393 -0
- package/lib/client/WorkflowLink.d.ts +1 -0
- package/lib/client/WorkflowLink.js +66 -0
- package/lib/client/WorkflowPage.d.ts +1 -0
- package/lib/client/WorkflowPage.js +92 -0
- package/lib/client/WorkflowProvider.d.ts +1 -0
- package/lib/client/WorkflowProvider.js +78 -0
- package/lib/client/WorkflowShortcut.d.ts +1 -0
- package/lib/client/WorkflowShortcut.js +123 -0
- package/lib/client/calculators.d.ts +101 -0
- package/lib/client/calculators.js +739 -0
- package/lib/client/components/Duration.d.ts +5 -0
- package/lib/client/components/Duration.js +96 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +38 -0
- package/lib/client/nodes/calculation.d.ts +25 -0
- package/lib/client/nodes/calculation.js +85 -0
- package/lib/client/nodes/condition.d.ts +46 -0
- package/lib/client/nodes/condition.js +346 -0
- package/lib/client/nodes/create.d.ts +46 -0
- package/lib/client/nodes/create.js +133 -0
- package/lib/client/nodes/delay.d.ts +36 -0
- package/lib/client/nodes/delay.js +49 -0
- package/lib/client/nodes/destroy.d.ts +55 -0
- package/lib/client/nodes/destroy.js +46 -0
- package/lib/client/nodes/index.d.ts +33 -0
- package/lib/client/nodes/index.js +390 -0
- package/lib/client/nodes/parallel.d.ts +24 -0
- package/lib/client/nodes/parallel.js +216 -0
- package/lib/client/nodes/query.d.ts +70 -0
- package/lib/client/nodes/query.js +143 -0
- package/lib/client/nodes/update.d.ts +60 -0
- package/lib/client/nodes/update.js +48 -0
- package/lib/client/schemas/collection.d.ts +42 -0
- package/lib/client/schemas/collection.js +98 -0
- package/lib/client/schemas/executions.d.ts +209 -0
- package/lib/client/schemas/executions.js +164 -0
- package/lib/client/schemas/workflows.d.ts +2 -0
- package/lib/client/schemas/workflows.js +328 -0
- package/lib/client/style.d.ts +12 -0
- package/lib/client/style.js +216 -0
- package/lib/client/triggers/collection.d.ts +92 -0
- package/lib/client/triggers/collection.js +253 -0
- package/lib/client/triggers/index.d.ts +26 -0
- package/lib/client/triggers/index.js +238 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +2 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.js +92 -0
- package/lib/client/triggers/schedule/EndsByField.d.ts +5 -0
- package/lib/client/triggers/schedule/EndsByField.js +102 -0
- package/lib/client/triggers/schedule/OnField.d.ts +5 -0
- package/lib/client/triggers/schedule/OnField.js +128 -0
- package/lib/client/triggers/schedule/RepeatField.d.ts +5 -0
- package/lib/client/triggers/schedule/RepeatField.js +191 -0
- package/lib/client/triggers/schedule/ScheduleConfig.d.ts +1 -0
- package/lib/client/triggers/schedule/ScheduleConfig.js +286 -0
- package/lib/client/triggers/schedule/index.d.ts +25 -0
- package/lib/client/triggers/schedule/index.js +124 -0
- package/lib/client/triggers/schedule/locale/Cron.zh-CN.d.ts +34 -0
- package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +44 -0
- package/lib/index.d.ts +1 -6
- package/lib/index.js +2 -73
- package/lib/{Plugin.d.ts → server/Plugin.d.ts} +0 -0
- package/lib/{Plugin.js → server/Plugin.js} +0 -0
- package/lib/{Processor.d.ts → server/Processor.d.ts} +4 -3
- package/lib/{Processor.js → server/Processor.js} +40 -24
- package/lib/{actions → server/actions}/index.d.ts +0 -0
- package/lib/{actions → server/actions}/index.js +0 -0
- package/lib/{actions → server/actions}/nodes.d.ts +0 -0
- package/lib/{actions → server/actions}/nodes.js +1 -0
- package/lib/{actions → server/actions}/workflows.d.ts +0 -0
- package/lib/{actions → server/actions}/workflows.js +0 -0
- package/lib/{calculators → server/calculators}/index.d.ts +0 -0
- package/lib/{calculators → server/calculators}/index.js +0 -0
- package/lib/{collections → server/collections}/executions.d.ts +0 -0
- package/lib/{collections → server/collections}/executions.js +0 -0
- package/lib/{collections → server/collections}/flow_nodes.d.ts +0 -0
- package/lib/{collections → server/collections}/flow_nodes.js +0 -0
- package/lib/{collections → server/collections}/jobs.d.ts +0 -0
- package/lib/{collections → server/collections}/jobs.js +0 -0
- package/lib/{collections → server/collections}/workflows.d.ts +0 -0
- package/lib/{collections → server/collections}/workflows.js +0 -0
- package/lib/{constants.d.ts → server/constants.d.ts} +0 -0
- package/lib/{constants.js → server/constants.js} +0 -0
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +86 -0
- package/lib/{instructions → server/instructions}/calculation.d.ts +0 -0
- package/lib/{instructions → server/instructions}/calculation.js +0 -0
- package/lib/{instructions → server/instructions}/condition.d.ts +0 -0
- package/lib/{instructions → server/instructions}/condition.js +0 -0
- package/lib/{instructions → server/instructions}/create.d.ts +0 -0
- package/lib/{instructions → server/instructions}/create.js +0 -0
- package/lib/{instructions → server/instructions}/delay.d.ts +0 -0
- package/lib/{instructions → server/instructions}/delay.js +12 -5
- package/lib/{instructions → server/instructions}/destroy.d.ts +0 -0
- package/lib/{instructions → server/instructions}/destroy.js +0 -0
- package/lib/{instructions → server/instructions}/index.d.ts +0 -0
- package/lib/{instructions → server/instructions}/index.js +0 -0
- package/lib/{instructions → server/instructions}/parallel.d.ts +0 -0
- package/lib/{instructions → server/instructions}/parallel.js +62 -20
- package/lib/{instructions → server/instructions}/prompt.d.ts +0 -0
- package/lib/{instructions → server/instructions}/prompt.js +0 -0
- package/lib/{instructions → server/instructions}/query.d.ts +0 -0
- package/lib/{instructions → server/instructions}/query.js +0 -0
- package/lib/{instructions → server/instructions}/update.d.ts +0 -0
- package/lib/{instructions → server/instructions}/update.js +0 -0
- package/lib/{models → server/models}/Execution.d.ts +0 -0
- package/lib/{models → server/models}/Execution.js +0 -0
- package/lib/{models → server/models}/FlowNode.d.ts +0 -0
- package/lib/{models → server/models}/FlowNode.js +0 -0
- package/lib/{models → server/models}/Job.d.ts +0 -0
- package/lib/{models → server/models}/Job.js +0 -0
- package/lib/{models → server/models}/Workflow.d.ts +0 -0
- package/lib/{models → server/models}/Workflow.js +0 -0
- package/lib/{triggers → server/triggers}/collection.d.ts +0 -0
- package/lib/{triggers → server/triggers}/collection.js +0 -0
- package/lib/{triggers → server/triggers}/index.d.ts +0 -0
- package/lib/{triggers → server/triggers}/index.js +0 -0
- package/lib/{triggers → server/triggers}/schedule.d.ts +0 -0
- package/lib/{triggers → server/triggers}/schedule.js +2 -2
- package/package.json +10 -8
- package/server.d.ts +4 -0
- package/server.js +30 -0
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BaseTypeSet = void 0;
|
|
7
|
+
exports.Calculation = Calculation;
|
|
8
|
+
exports.CollectionFieldset = void 0;
|
|
9
|
+
exports.Operand = Operand;
|
|
10
|
+
exports.VariableComponent = VariableComponent;
|
|
11
|
+
exports.calculators = exports.VariableTypesContext = exports.VariableTypes = void 0;
|
|
12
|
+
exports.parseStringValue = parseStringValue;
|
|
13
|
+
exports.useVariableTypes = useVariableTypes;
|
|
14
|
+
|
|
15
|
+
function _react() {
|
|
16
|
+
const data = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
_react = function _react() {
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function _react2() {
|
|
26
|
+
const data = require("@formily/react");
|
|
27
|
+
|
|
28
|
+
_react2 = function _react2() {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _antd() {
|
|
36
|
+
const data = require("antd");
|
|
37
|
+
|
|
38
|
+
_antd = function _antd() {
|
|
39
|
+
return data;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _css() {
|
|
46
|
+
const data = require("@emotion/css");
|
|
47
|
+
|
|
48
|
+
_css = function _css() {
|
|
49
|
+
return data;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _icons() {
|
|
56
|
+
const data = require("@ant-design/icons");
|
|
57
|
+
|
|
58
|
+
_icons = function _icons() {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return data;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function _client() {
|
|
66
|
+
const data = require("@nocobase/client");
|
|
67
|
+
|
|
68
|
+
_client = function _client() {
|
|
69
|
+
return data;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var _nodes = require("./nodes");
|
|
76
|
+
|
|
77
|
+
var _WorkflowCanvas = require("./WorkflowCanvas");
|
|
78
|
+
|
|
79
|
+
var _triggers = require("./triggers");
|
|
80
|
+
|
|
81
|
+
function _reactI18next() {
|
|
82
|
+
const data = require("react-i18next");
|
|
83
|
+
|
|
84
|
+
_reactI18next = function _reactI18next() {
|
|
85
|
+
return data;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
92
|
+
|
|
93
|
+
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; }
|
|
94
|
+
|
|
95
|
+
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; }
|
|
96
|
+
|
|
97
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
98
|
+
|
|
99
|
+
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); }
|
|
100
|
+
|
|
101
|
+
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; }
|
|
102
|
+
|
|
103
|
+
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; }
|
|
104
|
+
|
|
105
|
+
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; }
|
|
106
|
+
|
|
107
|
+
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
108
|
+
|
|
109
|
+
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."); }
|
|
110
|
+
|
|
111
|
+
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); }
|
|
112
|
+
|
|
113
|
+
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; }
|
|
114
|
+
|
|
115
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
116
|
+
|
|
117
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
118
|
+
|
|
119
|
+
function NullRender() {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const calculators = [{
|
|
124
|
+
value: 'boolean',
|
|
125
|
+
title: '{{t("Comparison")}}',
|
|
126
|
+
children: [{
|
|
127
|
+
value: 'equal',
|
|
128
|
+
name: '='
|
|
129
|
+
}, {
|
|
130
|
+
value: 'notEqual',
|
|
131
|
+
name: '≠'
|
|
132
|
+
}, {
|
|
133
|
+
value: 'gt',
|
|
134
|
+
name: '>'
|
|
135
|
+
}, {
|
|
136
|
+
value: 'gte',
|
|
137
|
+
name: '≥'
|
|
138
|
+
}, {
|
|
139
|
+
value: 'lt',
|
|
140
|
+
name: '<'
|
|
141
|
+
}, {
|
|
142
|
+
value: 'lte',
|
|
143
|
+
name: '≤'
|
|
144
|
+
}]
|
|
145
|
+
}, {
|
|
146
|
+
value: 'number',
|
|
147
|
+
title: '{{t("Arithmetic calculation")}}',
|
|
148
|
+
children: [{
|
|
149
|
+
value: 'add',
|
|
150
|
+
name: '+'
|
|
151
|
+
}, {
|
|
152
|
+
value: 'minus',
|
|
153
|
+
name: '-'
|
|
154
|
+
}, {
|
|
155
|
+
value: 'multiple',
|
|
156
|
+
name: '*'
|
|
157
|
+
}, {
|
|
158
|
+
value: 'divide',
|
|
159
|
+
name: '/'
|
|
160
|
+
}, {
|
|
161
|
+
value: 'mod',
|
|
162
|
+
name: '%'
|
|
163
|
+
}]
|
|
164
|
+
}, {
|
|
165
|
+
value: 'string',
|
|
166
|
+
title: '{{t("String operation")}}',
|
|
167
|
+
children: [{
|
|
168
|
+
value: 'includes',
|
|
169
|
+
name: '{{t("contains")}}'
|
|
170
|
+
}, {
|
|
171
|
+
value: 'notIncludes',
|
|
172
|
+
name: '{{t("does not contain")}}'
|
|
173
|
+
}, {
|
|
174
|
+
value: 'startsWith',
|
|
175
|
+
name: '{{t("starts with")}}'
|
|
176
|
+
}, {
|
|
177
|
+
value: 'notStartsWith',
|
|
178
|
+
name: '{{t("not starts with")}}'
|
|
179
|
+
}, {
|
|
180
|
+
value: 'endsWith',
|
|
181
|
+
name: '{{t("ends with")}}'
|
|
182
|
+
}, {
|
|
183
|
+
value: 'notEndsWith',
|
|
184
|
+
name: '{{t("not ends with")}}'
|
|
185
|
+
}]
|
|
186
|
+
}, {
|
|
187
|
+
value: 'date',
|
|
188
|
+
title: '{{t("Date")}}',
|
|
189
|
+
children: []
|
|
190
|
+
}];
|
|
191
|
+
exports.calculators = calculators;
|
|
192
|
+
const JT_VALUE_RE = /^\s*\{\{([\s\S]*)\}\}\s*$/;
|
|
193
|
+
|
|
194
|
+
function parseStringValue(value, Types) {
|
|
195
|
+
var _type;
|
|
196
|
+
|
|
197
|
+
const matcher = value.match(JT_VALUE_RE);
|
|
198
|
+
|
|
199
|
+
if (!matcher) {
|
|
200
|
+
return {
|
|
201
|
+
type: 'constant',
|
|
202
|
+
value,
|
|
203
|
+
options: {
|
|
204
|
+
type: 'string'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const _matcher$1$split = matcher[1].split('.'),
|
|
210
|
+
_matcher$1$split2 = _toArray(_matcher$1$split),
|
|
211
|
+
type = _matcher$1$split2[0],
|
|
212
|
+
paths = _matcher$1$split2.slice(1);
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
type,
|
|
216
|
+
options: paths.length ? (_type = (Types || VariableTypes)[type]) === null || _type === void 0 ? void 0 : _type.parse(paths) : {}
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const BaseTypeSet = new Set(['boolean', 'number', 'string', 'date']);
|
|
221
|
+
exports.BaseTypeSet = BaseTypeSet;
|
|
222
|
+
const ConstantTypes = {
|
|
223
|
+
string: {
|
|
224
|
+
title: '{{t("String")}}',
|
|
225
|
+
value: 'string',
|
|
226
|
+
|
|
227
|
+
component({
|
|
228
|
+
onChange: _onChange,
|
|
229
|
+
type,
|
|
230
|
+
options,
|
|
231
|
+
value
|
|
232
|
+
}) {
|
|
233
|
+
return _react().default.createElement(_antd().Input, {
|
|
234
|
+
value: value,
|
|
235
|
+
onChange: ev => _onChange({
|
|
236
|
+
value: ev.target.value,
|
|
237
|
+
type,
|
|
238
|
+
options
|
|
239
|
+
})
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
default: ''
|
|
244
|
+
},
|
|
245
|
+
number: {
|
|
246
|
+
title: '{{t("Number")}}',
|
|
247
|
+
value: 'number',
|
|
248
|
+
|
|
249
|
+
component({
|
|
250
|
+
onChange: _onChange2,
|
|
251
|
+
type,
|
|
252
|
+
options,
|
|
253
|
+
value
|
|
254
|
+
}) {
|
|
255
|
+
return _react().default.createElement(_antd().InputNumber, {
|
|
256
|
+
value: value,
|
|
257
|
+
onChange: v => _onChange2({
|
|
258
|
+
value: v,
|
|
259
|
+
type,
|
|
260
|
+
options
|
|
261
|
+
})
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
|
|
265
|
+
default: 0
|
|
266
|
+
},
|
|
267
|
+
boolean: {
|
|
268
|
+
title: '{{t("Boolean")}}',
|
|
269
|
+
value: 'boolean',
|
|
270
|
+
|
|
271
|
+
component({
|
|
272
|
+
onChange: _onChange3,
|
|
273
|
+
type,
|
|
274
|
+
options,
|
|
275
|
+
value
|
|
276
|
+
}) {
|
|
277
|
+
const _useTranslation = (0, _reactI18next().useTranslation)(),
|
|
278
|
+
t = _useTranslation.t;
|
|
279
|
+
|
|
280
|
+
return _react().default.createElement(_antd().Select, {
|
|
281
|
+
value: value,
|
|
282
|
+
onChange: v => _onChange3({
|
|
283
|
+
value: v,
|
|
284
|
+
type,
|
|
285
|
+
options
|
|
286
|
+
}),
|
|
287
|
+
placeholder: t('Select')
|
|
288
|
+
}, _react().default.createElement(_antd().Select.Option, {
|
|
289
|
+
value: true
|
|
290
|
+
}, t('True')), _react().default.createElement(_antd().Select.Option, {
|
|
291
|
+
value: false
|
|
292
|
+
}, t('False')));
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
default: false
|
|
296
|
+
} // date: {
|
|
297
|
+
// title: '日期',
|
|
298
|
+
// value: 'date',
|
|
299
|
+
// component({ onChange, type, options, value }) {
|
|
300
|
+
// return <DatePicker value={value} onChange={v => onChange({ value: v, type, options })}/>;
|
|
301
|
+
// },
|
|
302
|
+
// default: new Date()
|
|
303
|
+
// }
|
|
304
|
+
|
|
305
|
+
};
|
|
306
|
+
const VariableTypes = {
|
|
307
|
+
constant: {
|
|
308
|
+
title: '{{t("Constant")}}',
|
|
309
|
+
value: 'constant',
|
|
310
|
+
options: Object.values(ConstantTypes).map(item => ({
|
|
311
|
+
value: item.value,
|
|
312
|
+
label: item.title
|
|
313
|
+
})),
|
|
314
|
+
|
|
315
|
+
component({
|
|
316
|
+
options = {
|
|
317
|
+
type: 'string'
|
|
318
|
+
}
|
|
319
|
+
}) {
|
|
320
|
+
var _ConstantTypes$option, _ConstantTypes$option2;
|
|
321
|
+
|
|
322
|
+
return (_ConstantTypes$option = (_ConstantTypes$option2 = ConstantTypes[options.type]) === null || _ConstantTypes$option2 === void 0 ? void 0 : _ConstantTypes$option2.component) !== null && _ConstantTypes$option !== void 0 ? _ConstantTypes$option : NullRender;
|
|
323
|
+
},
|
|
324
|
+
|
|
325
|
+
appendTypeValue({
|
|
326
|
+
options = {
|
|
327
|
+
type: 'string'
|
|
328
|
+
}
|
|
329
|
+
}) {
|
|
330
|
+
return (options === null || options === void 0 ? void 0 : options.type) ? [options.type] : [];
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
onTypeChange(old, [type, optionsType], onChange) {
|
|
334
|
+
var _old$options;
|
|
335
|
+
|
|
336
|
+
if ((old === null || old === void 0 ? void 0 : (_old$options = old.options) === null || _old$options === void 0 ? void 0 : _old$options.type) === optionsType) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const value = ConstantTypes[optionsType].default;
|
|
341
|
+
onChange({
|
|
342
|
+
value,
|
|
343
|
+
type,
|
|
344
|
+
options: _objectSpread(_objectSpread({}, old.options), {}, {
|
|
345
|
+
type: optionsType
|
|
346
|
+
})
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
parse(path) {
|
|
351
|
+
return {
|
|
352
|
+
path
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
},
|
|
357
|
+
$jobsMapByNodeId: {
|
|
358
|
+
title: '{{t("Node result")}}',
|
|
359
|
+
value: '$jobsMapByNodeId',
|
|
360
|
+
|
|
361
|
+
options() {
|
|
362
|
+
const node = (0, _nodes.useNodeContext)();
|
|
363
|
+
const stack = [];
|
|
364
|
+
|
|
365
|
+
for (let current = node.upstream; current; current = current.upstream) {
|
|
366
|
+
const _instructions$get = _nodes.instructions.get(current.type),
|
|
367
|
+
getter = _instructions$get.getter; // Note: consider `getter` as the key of a value available node
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
if (getter) {
|
|
371
|
+
var _current$title;
|
|
372
|
+
|
|
373
|
+
stack.push({
|
|
374
|
+
value: current.id,
|
|
375
|
+
label: (_current$title = current.title) !== null && _current$title !== void 0 ? _current$title : `#${current.id}`
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return stack;
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
component({
|
|
384
|
+
options
|
|
385
|
+
}) {
|
|
386
|
+
var _instruction$getter;
|
|
387
|
+
|
|
388
|
+
const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
|
|
389
|
+
nodes = _useFlowContext.nodes;
|
|
390
|
+
|
|
391
|
+
if (!(options === null || options === void 0 ? void 0 : options.nodeId)) {
|
|
392
|
+
return NullRender;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const node = nodes.find(n => n.id == options.nodeId);
|
|
396
|
+
|
|
397
|
+
if (!node) {
|
|
398
|
+
return NullRender;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const instruction = _nodes.instructions.get(node.type);
|
|
402
|
+
|
|
403
|
+
return (_instruction$getter = instruction === null || instruction === void 0 ? void 0 : instruction.getter) !== null && _instruction$getter !== void 0 ? _instruction$getter : NullRender;
|
|
404
|
+
},
|
|
405
|
+
|
|
406
|
+
appendTypeValue({
|
|
407
|
+
options = {}
|
|
408
|
+
}) {
|
|
409
|
+
return options.nodeId ? [Number.parseInt(options.nodeId, 10)] : [];
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
onTypeChange(old, [type, nodeId], onChange) {
|
|
413
|
+
onChange({
|
|
414
|
+
// ...old,
|
|
415
|
+
type,
|
|
416
|
+
options: {
|
|
417
|
+
nodeId
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
parse([nodeId, ...path]) {
|
|
423
|
+
return {
|
|
424
|
+
nodeId,
|
|
425
|
+
path: path.join('.')
|
|
426
|
+
};
|
|
427
|
+
},
|
|
428
|
+
|
|
429
|
+
stringify({
|
|
430
|
+
options
|
|
431
|
+
}) {
|
|
432
|
+
const stack = ['$jobsMapByNodeId'];
|
|
433
|
+
|
|
434
|
+
if (options.nodeId) {
|
|
435
|
+
stack.push(options.nodeId);
|
|
436
|
+
|
|
437
|
+
if (options.path) {
|
|
438
|
+
stack.push(options.path);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return `{{${stack.join('.')}}}`;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
},
|
|
446
|
+
$context: {
|
|
447
|
+
title: '{{t("Trigger context")}}',
|
|
448
|
+
value: '$context',
|
|
449
|
+
|
|
450
|
+
component() {
|
|
451
|
+
var _trigger$getter;
|
|
452
|
+
|
|
453
|
+
const _useFlowContext2 = (0, _WorkflowCanvas.useFlowContext)(),
|
|
454
|
+
workflow = _useFlowContext2.workflow;
|
|
455
|
+
|
|
456
|
+
const trigger = _triggers.triggers.get(workflow.type);
|
|
457
|
+
|
|
458
|
+
return (_trigger$getter = trigger === null || trigger === void 0 ? void 0 : trigger.getter) !== null && _trigger$getter !== void 0 ? _trigger$getter : NullRender;
|
|
459
|
+
},
|
|
460
|
+
|
|
461
|
+
parse([prefix, ...path]) {
|
|
462
|
+
return {
|
|
463
|
+
path: path.join('.')
|
|
464
|
+
};
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
stringify({
|
|
468
|
+
options
|
|
469
|
+
}) {
|
|
470
|
+
const stack = ['$context'];
|
|
471
|
+
|
|
472
|
+
if (options === null || options === void 0 ? void 0 : options.path) {
|
|
473
|
+
stack.push(options.path);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return `{{${stack.join('.')}}}`;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
} // calculation: Calculation
|
|
480
|
+
|
|
481
|
+
};
|
|
482
|
+
exports.VariableTypes = VariableTypes;
|
|
483
|
+
|
|
484
|
+
const VariableTypesContext = _react().default.createContext(null);
|
|
485
|
+
|
|
486
|
+
exports.VariableTypesContext = VariableTypesContext;
|
|
487
|
+
|
|
488
|
+
function useVariableTypes() {
|
|
489
|
+
return _react().default.useContext(VariableTypesContext);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function Operand({
|
|
493
|
+
value: operand = {
|
|
494
|
+
type: 'constant',
|
|
495
|
+
value: '',
|
|
496
|
+
options: {
|
|
497
|
+
type: 'string'
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
onChange: _onChange4,
|
|
501
|
+
children
|
|
502
|
+
}) {
|
|
503
|
+
const compile = (0, _client().useCompile)();
|
|
504
|
+
const Types = useVariableTypes();
|
|
505
|
+
const type = operand.type;
|
|
506
|
+
|
|
507
|
+
const _ref = Types[type] || {},
|
|
508
|
+
component = _ref.component,
|
|
509
|
+
appendTypeValue = _ref.appendTypeValue;
|
|
510
|
+
|
|
511
|
+
const VariableComponent = typeof component === 'function' ? component(operand) : NullRender;
|
|
512
|
+
return _react().default.createElement("div", {
|
|
513
|
+
className: (0, _css().css)`
|
|
514
|
+
display: flex;
|
|
515
|
+
gap: .5em;
|
|
516
|
+
align-items: center;
|
|
517
|
+
`
|
|
518
|
+
}, _react().default.createElement(_antd().Cascader, {
|
|
519
|
+
allowClear: false,
|
|
520
|
+
value: [type, ...(appendTypeValue ? appendTypeValue(operand) : [])],
|
|
521
|
+
options: Object.values(Types).map(item => {
|
|
522
|
+
const options = typeof item.options === 'function' ? item.options() : item.options;
|
|
523
|
+
return {
|
|
524
|
+
label: compile(item.title),
|
|
525
|
+
value: item.value,
|
|
526
|
+
children: compile(options),
|
|
527
|
+
disabled: options && !options.length,
|
|
528
|
+
isLeaf: !options
|
|
529
|
+
};
|
|
530
|
+
}),
|
|
531
|
+
onChange: next => {
|
|
532
|
+
const onTypeChange = Types[next[0]].onTypeChange;
|
|
533
|
+
|
|
534
|
+
if (typeof onTypeChange === 'function') {
|
|
535
|
+
onTypeChange(operand, next, _onChange4);
|
|
536
|
+
} else {
|
|
537
|
+
if (next[0] !== type) {
|
|
538
|
+
_onChange4({
|
|
539
|
+
type: next[0],
|
|
540
|
+
value: null
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}), children !== null && children !== void 0 ? children : _react().default.createElement(VariableComponent, _objectSpread(_objectSpread({}, operand), {}, {
|
|
546
|
+
onChange: op => _onChange4(_objectSpread({}, op))
|
|
547
|
+
})));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
function Calculation({
|
|
551
|
+
calculator,
|
|
552
|
+
operands = [],
|
|
553
|
+
onChange: _onChange5
|
|
554
|
+
}) {
|
|
555
|
+
const _useTranslation2 = (0, _reactI18next().useTranslation)(),
|
|
556
|
+
t = _useTranslation2.t;
|
|
557
|
+
|
|
558
|
+
const compile = (0, _client().useCompile)();
|
|
559
|
+
return _react().default.createElement(VariableTypesContext.Provider, {
|
|
560
|
+
value: VariableTypes
|
|
561
|
+
}, _react().default.createElement("div", {
|
|
562
|
+
className: (0, _css().css)`
|
|
563
|
+
display: flex;
|
|
564
|
+
gap: .5em;
|
|
565
|
+
align-items: center;
|
|
566
|
+
`
|
|
567
|
+
}, _react().default.createElement(Operand, {
|
|
568
|
+
value: operands[0],
|
|
569
|
+
onChange: v => _onChange5({
|
|
570
|
+
calculator,
|
|
571
|
+
operands: [v, operands[1]]
|
|
572
|
+
})
|
|
573
|
+
}), operands[0] ? _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_antd().Select, {
|
|
574
|
+
value: calculator,
|
|
575
|
+
onChange: v => _onChange5({
|
|
576
|
+
operands,
|
|
577
|
+
calculator: v
|
|
578
|
+
}),
|
|
579
|
+
placeholder: t('Calculator')
|
|
580
|
+
}, calculators.map(group => _react().default.createElement(_antd().Select.OptGroup, {
|
|
581
|
+
key: group.value,
|
|
582
|
+
label: compile(group.title)
|
|
583
|
+
}, group.children.map(item => _react().default.createElement(_antd().Select.Option, {
|
|
584
|
+
key: item.value,
|
|
585
|
+
value: item.value
|
|
586
|
+
}, compile(item.name)))))), _react().default.createElement(Operand, {
|
|
587
|
+
value: operands[1],
|
|
588
|
+
onChange: v => _onChange5({
|
|
589
|
+
calculator,
|
|
590
|
+
operands: [operands[0], v]
|
|
591
|
+
})
|
|
592
|
+
})) : null));
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function VariableComponent({
|
|
596
|
+
value,
|
|
597
|
+
onChange: _onChange6,
|
|
598
|
+
renderSchemaComponent
|
|
599
|
+
}) {
|
|
600
|
+
const VTypes = _objectSpread(_objectSpread({}, VariableTypes), {}, {
|
|
601
|
+
constant: {
|
|
602
|
+
title: '{{t("Constant")}}',
|
|
603
|
+
value: 'constant',
|
|
604
|
+
options: undefined
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
const operand = typeof value === 'string' ? parseStringValue(value, VTypes) : {
|
|
609
|
+
type: 'constant',
|
|
610
|
+
value
|
|
611
|
+
};
|
|
612
|
+
return _react().default.createElement(VariableTypesContext.Provider, {
|
|
613
|
+
value: VTypes
|
|
614
|
+
}, _react().default.createElement(Operand, {
|
|
615
|
+
value: operand,
|
|
616
|
+
onChange: next => {
|
|
617
|
+
if (next.type !== operand.type && next.type === 'constant') {
|
|
618
|
+
_onChange6(null);
|
|
619
|
+
} else {
|
|
620
|
+
const stringify = VTypes[next.type].stringify;
|
|
621
|
+
|
|
622
|
+
_onChange6(stringify(next));
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}, operand.type === 'constant' ? renderSchemaComponent() : null));
|
|
626
|
+
} // NOTE: observer for watching useProps
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
const CollectionFieldset = (0, _react2().observer)(({
|
|
630
|
+
value,
|
|
631
|
+
onChange: _onChange7
|
|
632
|
+
}) => {
|
|
633
|
+
var _data$config;
|
|
634
|
+
|
|
635
|
+
const _useTranslation3 = (0, _reactI18next().useTranslation)(),
|
|
636
|
+
t = _useTranslation3.t;
|
|
637
|
+
|
|
638
|
+
const compile = (0, _client().useCompile)();
|
|
639
|
+
|
|
640
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
641
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
642
|
+
|
|
643
|
+
const _useForm = (0, _react2().useForm)(),
|
|
644
|
+
data = _useForm.values;
|
|
645
|
+
|
|
646
|
+
const fields = getCollectionFields(data === null || data === void 0 ? void 0 : (_data$config = data.config) === null || _data$config === void 0 ? void 0 : _data$config.collection).filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : false));
|
|
647
|
+
|
|
648
|
+
const VTypes = _objectSpread(_objectSpread({}, VariableTypes), {}, {
|
|
649
|
+
constant: {
|
|
650
|
+
title: '{{t("Constant")}}',
|
|
651
|
+
value: 'constant',
|
|
652
|
+
options: undefined
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
return _react().default.createElement("fieldset", {
|
|
657
|
+
className: (0, _css().css)`
|
|
658
|
+
margin-top: .5em;
|
|
659
|
+
|
|
660
|
+
> .ant-formily-item{
|
|
661
|
+
flex-direction: column;
|
|
662
|
+
|
|
663
|
+
> .ant-formily-item-label{
|
|
664
|
+
line-height: 32px;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
`
|
|
668
|
+
}, fields.length ? _react().default.createElement(_react().default.Fragment, null, fields.filter(field => field.name in value).map(field => {
|
|
669
|
+
var _field$uiSchema$title, _field$uiSchema;
|
|
670
|
+
|
|
671
|
+
const operand = typeof value[field.name] === 'string' ? parseStringValue(value[field.name], VTypes) : {
|
|
672
|
+
type: 'constant',
|
|
673
|
+
value: value[field.name]
|
|
674
|
+
}; // TODO: try to use <ObjectField> to replace this map
|
|
675
|
+
|
|
676
|
+
return _react().default.createElement(_antd().Form.Item, {
|
|
677
|
+
key: field.name,
|
|
678
|
+
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),
|
|
679
|
+
labelAlign: "left",
|
|
680
|
+
className: (0, _css().css)`
|
|
681
|
+
.ant-form-item-control-input-content{
|
|
682
|
+
display: flex;
|
|
683
|
+
}
|
|
684
|
+
`
|
|
685
|
+
}, _react().default.createElement(VariableTypesContext.Provider, {
|
|
686
|
+
value: VTypes
|
|
687
|
+
}, _react().default.createElement(Operand, {
|
|
688
|
+
value: operand,
|
|
689
|
+
onChange: next => {
|
|
690
|
+
if (next.type !== operand.type && next.type === 'constant') {
|
|
691
|
+
_onChange7(_objectSpread(_objectSpread({}, value), {}, {
|
|
692
|
+
[field.name]: null
|
|
693
|
+
}));
|
|
694
|
+
} else {
|
|
695
|
+
const stringify = VTypes[next.type].stringify;
|
|
696
|
+
|
|
697
|
+
_onChange7(_objectSpread(_objectSpread({}, value), {}, {
|
|
698
|
+
[field.name]: stringify(next)
|
|
699
|
+
}));
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}, operand.type === 'constant' ? _react().default.createElement(_client().SchemaComponent, {
|
|
703
|
+
schema: _objectSpread(_objectSpread({}, field.uiSchema), {}, {
|
|
704
|
+
name: field.name
|
|
705
|
+
})
|
|
706
|
+
}) : null), _react().default.createElement(_antd().Button, {
|
|
707
|
+
type: "link",
|
|
708
|
+
icon: _react().default.createElement(_icons().CloseCircleOutlined, null),
|
|
709
|
+
onClick: () => {
|
|
710
|
+
const _field$name = field.name,
|
|
711
|
+
_ = value[_field$name],
|
|
712
|
+
rest = _objectWithoutProperties(value, [_field$name].map(_toPropertyKey));
|
|
713
|
+
|
|
714
|
+
_onChange7(rest);
|
|
715
|
+
}
|
|
716
|
+
})));
|
|
717
|
+
}), Object.keys(value).length < fields.length ? _react().default.createElement(_antd().Dropdown, {
|
|
718
|
+
overlay: _react().default.createElement(_antd().Menu, {
|
|
719
|
+
onClick: ({
|
|
720
|
+
key
|
|
721
|
+
}) => _onChange7(_objectSpread(_objectSpread({}, value), {}, {
|
|
722
|
+
[key]: null
|
|
723
|
+
})),
|
|
724
|
+
className: (0, _css().css)`
|
|
725
|
+
max-height: 300px;
|
|
726
|
+
overflow-y: auto;
|
|
727
|
+
`
|
|
728
|
+
}, fields.filter(field => !(field.name in value)).map(field => {
|
|
729
|
+
var _field$uiSchema$title2, _field$uiSchema2;
|
|
730
|
+
|
|
731
|
+
return _react().default.createElement(_antd().Menu.Item, {
|
|
732
|
+
key: field.name
|
|
733
|
+
}, 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));
|
|
734
|
+
}))
|
|
735
|
+
}, _react().default.createElement(_antd().Button, {
|
|
736
|
+
icon: _react().default.createElement(_icons().PlusOutlined, null)
|
|
737
|
+
}, t('Add field'))) : null) : _react().default.createElement("p", null, t('Please select collection first')));
|
|
738
|
+
});
|
|
739
|
+
exports.CollectionFieldset = CollectionFieldset;
|