@nocobase/plugin-workflow 0.10.0-alpha.4 → 0.10.1-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/lib/client/components/Duration.js +7 -6
- package/lib/client/components/DynamicExpression.js +14 -4
- package/lib/client/nodes/aggregate.d.ts +8 -2
- package/lib/client/nodes/aggregate.js +11 -8
- package/lib/client/nodes/calculation.d.ts +10 -15
- package/lib/client/nodes/calculation.js +56 -29
- package/lib/client/nodes/condition.d.ts +1 -3
- package/lib/client/nodes/condition.js +7 -4
- package/lib/client/nodes/create.d.ts +4 -2
- package/lib/client/nodes/create.js +34 -7
- package/lib/client/nodes/index.d.ts +2 -2
- package/lib/client/nodes/loop.d.ts +2 -0
- package/lib/client/nodes/loop.js +14 -2
- package/lib/client/nodes/manual/WorkflowTodo.js +5 -3
- package/lib/client/nodes/manual/index.d.ts +11 -5
- package/lib/client/nodes/manual/index.js +21 -10
- package/lib/client/nodes/query.d.ts +4 -2
- package/lib/client/nodes/query.js +34 -7
- package/lib/client/nodes/request.d.ts +10 -6
- package/lib/client/nodes/request.js +34 -6
- package/lib/client/triggers/collection.js +20 -6
- package/lib/client/triggers/index.js +1 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.js +8 -7
- package/lib/client/triggers/schedule/index.d.ts +1 -3
- package/lib/client/triggers/schedule/index.js +21 -11
- package/lib/client/variable.d.ts +1 -2
- package/lib/client/variable.js +106 -41
- package/package.json +12 -12
|
@@ -22,6 +22,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
22
22
|
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
23
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
24
|
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); }
|
|
25
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
+
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."); }
|
|
27
|
+
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); }
|
|
28
|
+
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; }
|
|
29
|
+
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; } }
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
31
|
var _default = {
|
|
26
32
|
title: `{{t("Query record", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
27
33
|
type: 'query',
|
|
@@ -59,15 +65,36 @@ var _default = {
|
|
|
59
65
|
FieldsSelect: _FieldsSelect.FieldsSelect
|
|
60
66
|
},
|
|
61
67
|
useVariables({
|
|
68
|
+
id,
|
|
69
|
+
title,
|
|
62
70
|
config
|
|
63
71
|
}, options) {
|
|
64
|
-
var
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
var _config$params, _config$params$append;
|
|
73
|
+
const compile = (0, _client().useCompile)();
|
|
74
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
75
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
76
|
+
// const depth = config?.params?.appends?.length
|
|
77
|
+
// ? config?.params?.appends.reduce((max, item) => Math.max(max, item.split('.').length), 1)
|
|
78
|
+
// : 0;
|
|
79
|
+
const name = `${id}`;
|
|
80
|
+
const _getCollectionFieldOp = (0, _variable.getCollectionFieldOptions)(_objectSpread(_objectSpread({}, options), {}, {
|
|
81
|
+
fields: [{
|
|
82
|
+
collectionName: config.collection,
|
|
83
|
+
name,
|
|
84
|
+
type: 'hasOne',
|
|
85
|
+
target: config.collection,
|
|
86
|
+
uiSchema: {
|
|
87
|
+
title
|
|
88
|
+
}
|
|
89
|
+
}],
|
|
90
|
+
// depth: options?.depth ?? depth,
|
|
91
|
+
appends: [name, ...(((_config$params = config.params) === null || _config$params === void 0 ? void 0 : (_config$params$append = _config$params.appends) === null || _config$params$append === void 0 ? void 0 : _config$params$append.map(item => `${name}.${item}`)) || [])],
|
|
92
|
+
compile,
|
|
93
|
+
getCollectionFields
|
|
94
|
+
})),
|
|
95
|
+
_getCollectionFieldOp2 = _slicedToArray(_getCollectionFieldOp, 1),
|
|
96
|
+
result = _getCollectionFieldOp2[0];
|
|
97
|
+
return result;
|
|
71
98
|
},
|
|
72
99
|
useInitializers(node) {
|
|
73
100
|
var _node$title;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { useWorkflowVariableOptions } from '../variable';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
title: string;
|
|
@@ -59,7 +60,7 @@ declare const _default: {
|
|
|
59
60
|
'x-decorator': string;
|
|
60
61
|
'x-component': string;
|
|
61
62
|
'x-component-props': {
|
|
62
|
-
scope:
|
|
63
|
+
scope: string;
|
|
63
64
|
useTypedConstant: boolean;
|
|
64
65
|
};
|
|
65
66
|
};
|
|
@@ -105,7 +106,7 @@ declare const _default: {
|
|
|
105
106
|
'x-decorator': string;
|
|
106
107
|
'x-component': string;
|
|
107
108
|
'x-component-props': {
|
|
108
|
-
scope:
|
|
109
|
+
scope: string;
|
|
109
110
|
useTypedConstant: boolean;
|
|
110
111
|
};
|
|
111
112
|
};
|
|
@@ -133,7 +134,7 @@ declare const _default: {
|
|
|
133
134
|
'x-decorator-props': {};
|
|
134
135
|
'x-component': string;
|
|
135
136
|
'x-component-props': {
|
|
136
|
-
|
|
137
|
+
changeOnSelect: boolean;
|
|
137
138
|
autoSize: {
|
|
138
139
|
minRows: number;
|
|
139
140
|
};
|
|
@@ -163,13 +164,16 @@ declare const _default: {
|
|
|
163
164
|
};
|
|
164
165
|
};
|
|
165
166
|
view: {};
|
|
166
|
-
scope: {
|
|
167
|
+
scope: {
|
|
168
|
+
useWorkflowVariableOptions: typeof useWorkflowVariableOptions;
|
|
169
|
+
};
|
|
167
170
|
components: {
|
|
168
|
-
ArrayItems:
|
|
169
|
-
Item?:
|
|
171
|
+
ArrayItems: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement> & import("@formily/antd").IArrayBaseProps>> & import("@formily/antd").ArrayBaseMixins & {
|
|
172
|
+
Item?: React.FC<React.HTMLAttributes<HTMLDivElement> & {
|
|
170
173
|
type?: "divide" | "card";
|
|
171
174
|
}>;
|
|
172
175
|
};
|
|
176
|
+
RequestBody(props: any): React.JSX.Element;
|
|
173
177
|
};
|
|
174
178
|
};
|
|
175
179
|
export default _default;
|
|
@@ -4,6 +4,13 @@ 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
|
+
}
|
|
7
14
|
function _antd() {
|
|
8
15
|
const data = require("@formily/antd");
|
|
9
16
|
_antd = function _antd() {
|
|
@@ -11,8 +18,21 @@ function _antd() {
|
|
|
11
18
|
};
|
|
12
19
|
return data;
|
|
13
20
|
}
|
|
21
|
+
function _client() {
|
|
22
|
+
const data = require("@nocobase/client");
|
|
23
|
+
_client = function _client() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
14
28
|
var _locale = require("../locale");
|
|
15
29
|
var _variable = require("../variable");
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
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; }
|
|
32
|
+
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; }
|
|
33
|
+
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; }
|
|
34
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
35
|
+
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); }
|
|
16
36
|
var _default = {
|
|
17
37
|
title: `{{t("HTTP request", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
18
38
|
type: 'request',
|
|
@@ -85,7 +105,7 @@ var _default = {
|
|
|
85
105
|
'x-decorator': 'FormItem',
|
|
86
106
|
'x-component': 'Variable.Input',
|
|
87
107
|
'x-component-props': {
|
|
88
|
-
scope:
|
|
108
|
+
scope: '{{useWorkflowVariableOptions()}}',
|
|
89
109
|
useTypedConstant: true
|
|
90
110
|
}
|
|
91
111
|
},
|
|
@@ -131,7 +151,7 @@ var _default = {
|
|
|
131
151
|
'x-decorator': 'FormItem',
|
|
132
152
|
'x-component': 'Variable.Input',
|
|
133
153
|
'x-component-props': {
|
|
134
|
-
scope:
|
|
154
|
+
scope: '{{useWorkflowVariableOptions()}}',
|
|
135
155
|
useTypedConstant: true
|
|
136
156
|
}
|
|
137
157
|
},
|
|
@@ -157,9 +177,9 @@ var _default = {
|
|
|
157
177
|
title: `{{t("Body", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
158
178
|
'x-decorator': 'FormItem',
|
|
159
179
|
'x-decorator-props': {},
|
|
160
|
-
'x-component': '
|
|
180
|
+
'x-component': 'RequestBody',
|
|
161
181
|
'x-component-props': {
|
|
162
|
-
|
|
182
|
+
changeOnSelect: true,
|
|
163
183
|
autoSize: {
|
|
164
184
|
minRows: 10
|
|
165
185
|
},
|
|
@@ -189,9 +209,17 @@ var _default = {
|
|
|
189
209
|
}
|
|
190
210
|
},
|
|
191
211
|
view: {},
|
|
192
|
-
scope: {
|
|
212
|
+
scope: {
|
|
213
|
+
useWorkflowVariableOptions: _variable.useWorkflowVariableOptions
|
|
214
|
+
},
|
|
193
215
|
components: {
|
|
194
|
-
ArrayItems: _antd().ArrayItems
|
|
216
|
+
ArrayItems: _antd().ArrayItems,
|
|
217
|
+
RequestBody(props) {
|
|
218
|
+
const scope = (0, _variable.useWorkflowVariableOptions)();
|
|
219
|
+
return _react().default.createElement(_client().Variable.JSON, _objectSpread({
|
|
220
|
+
scope: scope
|
|
221
|
+
}, props));
|
|
222
|
+
}
|
|
195
223
|
}
|
|
196
224
|
};
|
|
197
225
|
exports.default = _default;
|
|
@@ -61,6 +61,14 @@ var _default = {
|
|
|
61
61
|
value: null
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
}, {
|
|
65
|
+
target: 'appends',
|
|
66
|
+
effects: ['onFieldValueChange'],
|
|
67
|
+
fulfill: {
|
|
68
|
+
state: {
|
|
69
|
+
value: []
|
|
70
|
+
}
|
|
71
|
+
}
|
|
64
72
|
}]
|
|
65
73
|
}),
|
|
66
74
|
mode: {
|
|
@@ -134,21 +142,27 @@ var _default = {
|
|
|
134
142
|
FieldsSelect: _FieldsSelect.FieldsSelect
|
|
135
143
|
},
|
|
136
144
|
useVariables(config, options) {
|
|
137
|
-
var
|
|
138
|
-
const
|
|
139
|
-
|
|
145
|
+
var _config$appends;
|
|
146
|
+
const compile = (0, _client().useCompile)();
|
|
147
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
148
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
140
149
|
const rootFields = [{
|
|
141
150
|
collectionName: config.collection,
|
|
142
151
|
name: 'data',
|
|
143
152
|
type: 'hasOne',
|
|
144
153
|
target: config.collection,
|
|
145
154
|
uiSchema: {
|
|
146
|
-
title:
|
|
155
|
+
title: (0, _locale.lang)('Trigger data')
|
|
147
156
|
}
|
|
148
157
|
}];
|
|
149
|
-
const
|
|
158
|
+
// const depth = config.appends?.length
|
|
159
|
+
// ? config.appends.reduce((max, item) => Math.max(max, item.split('.').length), 1) + 1
|
|
160
|
+
// : 1;
|
|
161
|
+
const result = (0, _variable.getCollectionFieldOptions)(_objectSpread(_objectSpread({}, options), {}, {
|
|
150
162
|
fields: rootFields,
|
|
151
|
-
|
|
163
|
+
appends: ['data', ...(((_config$appends = config.appends) === null || _config$appends === void 0 ? void 0 : _config$appends.map(item => `data.${item}`)) || [])],
|
|
164
|
+
compile,
|
|
165
|
+
getCollectionFields
|
|
152
166
|
}));
|
|
153
167
|
return result;
|
|
154
168
|
},
|
|
@@ -201,6 +201,7 @@ const TriggerConfig = () => {
|
|
|
201
201
|
}
|
|
202
202
|
}, [workflow]);
|
|
203
203
|
const form = (0, _react().useMemo)(() => (0, _core().createForm)({
|
|
204
|
+
initialValues: workflow === null || workflow === void 0 ? void 0 : workflow.config,
|
|
204
205
|
values: workflow === null || workflow === void 0 ? void 0 : workflow.config,
|
|
205
206
|
disabled: workflow === null || workflow === void 0 ? void 0 : workflow.executed
|
|
206
207
|
}), [workflow]);
|
|
@@ -11,6 +11,13 @@ function _react() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
+
function _client() {
|
|
15
|
+
const data = require("@nocobase/client");
|
|
16
|
+
_client = function _client() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
14
21
|
function _antd() {
|
|
15
22
|
const data = require("antd");
|
|
16
23
|
_antd = function _antd() {
|
|
@@ -32,13 +39,6 @@ function _reactI18next() {
|
|
|
32
39
|
};
|
|
33
40
|
return data;
|
|
34
41
|
}
|
|
35
|
-
function _client() {
|
|
36
|
-
const data = require("@nocobase/client");
|
|
37
|
-
_client = function _client() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
43
|
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; }
|
|
44
44
|
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,6 +55,7 @@ const DateFieldsSelect = (0, _react().observer)(props => {
|
|
|
55
55
|
values = _useForm.values;
|
|
56
56
|
const fields = getCollectionFields(values === null || values === void 0 ? void 0 : values.collection);
|
|
57
57
|
return _react2().default.createElement(_antd().Select, _objectSpread({
|
|
58
|
+
dropdownMatchSelectWidth: false,
|
|
58
59
|
placeholder: t('Select field')
|
|
59
60
|
}, props), fields.filter(field => !field.hidden && (field.uiSchema ? field.type === 'date' : false)).map(field => {
|
|
60
61
|
var _field$uiSchema;
|
|
@@ -16,9 +16,7 @@ declare const _default: {
|
|
|
16
16
|
ScheduleConfig: () => import("react").JSX.Element;
|
|
17
17
|
FieldsSelect: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Pick<any, string | number | symbol>>>;
|
|
18
18
|
};
|
|
19
|
-
useVariables(config: any,
|
|
20
|
-
types: any;
|
|
21
|
-
}): any[];
|
|
19
|
+
useVariables(config: any, opts: any): any[];
|
|
22
20
|
useInitializers(config: any): SchemaInitializerItemOptions | null;
|
|
23
21
|
initializers: {};
|
|
24
22
|
};
|
|
@@ -17,6 +17,11 @@ var _locale = require("../../locale");
|
|
|
17
17
|
var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
|
|
18
18
|
var _variable = require("../../variable");
|
|
19
19
|
var _FieldsSelect = require("../../components/FieldsSelect");
|
|
20
|
+
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
|
+
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
|
+
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
|
+
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); }
|
|
20
25
|
var _default = {
|
|
21
26
|
title: `{{t("Schedule event", { ns: "${_locale.NAMESPACE}" })}}`,
|
|
22
27
|
type: 'schedule',
|
|
@@ -34,28 +39,33 @@ var _default = {
|
|
|
34
39
|
ScheduleConfig: _ScheduleConfig.ScheduleConfig,
|
|
35
40
|
FieldsSelect: _FieldsSelect.FieldsSelect
|
|
36
41
|
},
|
|
37
|
-
useVariables(config, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
+
useVariables(config, opts) {
|
|
43
|
+
var _config$appends;
|
|
44
|
+
const compile = (0, _client().useCompile)();
|
|
45
|
+
const _useCollectionManager = (0, _client().useCollectionManager)(),
|
|
46
|
+
getCollectionFields = _useCollectionManager.getCollectionFields;
|
|
42
47
|
const options = [];
|
|
43
|
-
if (!types || types.includes('date')) {
|
|
48
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.types) || opts.types.includes('date')) {
|
|
44
49
|
options.push({
|
|
45
50
|
key: 'date',
|
|
46
51
|
value: 'date',
|
|
47
|
-
label:
|
|
52
|
+
label: (0, _locale.lang)('Trigger time')
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
const depth = ((_config$appends = config.appends) === null || _config$appends === void 0 ? void 0 : _config$appends.length) ? config.appends.reduce((max, item) => Math.max(max, item.split('.').length), 1) + 1 : 1;
|
|
56
|
+
const fieldOptions = (0, _variable.getCollectionFieldOptions)(_objectSpread(_objectSpread({
|
|
57
|
+
depth
|
|
58
|
+
}, opts), {}, {
|
|
59
|
+
collection: config.collection,
|
|
60
|
+
compile,
|
|
61
|
+
getCollectionFields
|
|
62
|
+
}));
|
|
53
63
|
if (config.mode === _constants.SCHEDULE_MODE.COLLECTION_FIELD) {
|
|
54
64
|
if (fieldOptions.length) {
|
|
55
65
|
options.push({
|
|
56
66
|
key: 'data',
|
|
57
67
|
value: 'data',
|
|
58
|
-
label:
|
|
68
|
+
label: (0, _locale.lang)('Trigger data'),
|
|
59
69
|
children: fieldOptions
|
|
60
70
|
});
|
|
61
71
|
}
|
package/lib/client/variable.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export declare const BaseTypeSets: {
|
|
|
37
37
|
string: Set<string>;
|
|
38
38
|
date: Set<string>;
|
|
39
39
|
};
|
|
40
|
-
export declare function filterTypedFields(fields: any, types: any, depth?: number): any;
|
|
41
40
|
export declare function useWorkflowVariableOptions(options?: {}): {
|
|
42
41
|
label: any;
|
|
43
42
|
value: any;
|
|
@@ -45,4 +44,4 @@ export declare function useWorkflowVariableOptions(options?: {}): {
|
|
|
45
44
|
children: any;
|
|
46
45
|
disabled: boolean;
|
|
47
46
|
}[];
|
|
48
|
-
export declare function
|
|
47
|
+
export declare function getCollectionFieldOptions(options: any): VariableOption[];
|
package/lib/client/variable.js
CHANGED
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BaseTypeSets = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.getCollectionFieldOptions = getCollectionFieldOptions;
|
|
8
8
|
exports.triggerOptions = exports.systemOptions = exports.scopeOptions = exports.nodesOptions = void 0;
|
|
9
|
-
exports.useCollectionFieldOptions = useCollectionFieldOptions;
|
|
10
9
|
exports.useWorkflowVariableOptions = useWorkflowVariableOptions;
|
|
11
10
|
function _client() {
|
|
12
11
|
const data = require("@nocobase/client");
|
|
@@ -19,6 +18,8 @@ var _FlowContext = require("./FlowContext");
|
|
|
19
18
|
var _locale = require("./locale");
|
|
20
19
|
var _nodes = require("./nodes");
|
|
21
20
|
var _triggers = require("./triggers");
|
|
21
|
+
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); } }
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
22
23
|
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; }
|
|
23
24
|
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; }
|
|
24
25
|
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; }
|
|
@@ -34,15 +35,9 @@ const nodesOptions = {
|
|
|
34
35
|
upstreams.forEach(node => {
|
|
35
36
|
var _instruction$useVaria;
|
|
36
37
|
const instruction = _nodes.instructions.get(node.type);
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
result.push({
|
|
41
|
-
key: node.id.toString(),
|
|
42
|
-
value: node.id.toString(),
|
|
43
|
-
label: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
44
|
-
children: subOptions
|
|
45
|
-
});
|
|
38
|
+
const subOption = (_instruction$useVaria = instruction.useVariables) === null || _instruction$useVaria === void 0 ? void 0 : _instruction$useVaria.call(instruction, node, options);
|
|
39
|
+
if (subOption) {
|
|
40
|
+
result.push(subOption);
|
|
46
41
|
}
|
|
47
42
|
});
|
|
48
43
|
return result;
|
|
@@ -73,11 +68,11 @@ const scopeOptions = {
|
|
|
73
68
|
const instruction = _nodes.instructions.get(node.type);
|
|
74
69
|
const subOptions = (_instruction$useScope = instruction.useScopeVariables) === null || _instruction$useScope === void 0 ? void 0 : _instruction$useScope.call(instruction, node, options);
|
|
75
70
|
if (subOptions) {
|
|
76
|
-
var _node$
|
|
71
|
+
var _node$title;
|
|
77
72
|
result.push({
|
|
78
73
|
key: node.id.toString(),
|
|
79
74
|
value: node.id.toString(),
|
|
80
|
-
label: (_node$
|
|
75
|
+
label: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
|
|
81
76
|
children: subOptions
|
|
82
77
|
});
|
|
83
78
|
}
|
|
@@ -95,7 +90,7 @@ const systemOptions = {
|
|
|
95
90
|
return [...(!types || types.includes('date') ? [{
|
|
96
91
|
key: 'now',
|
|
97
92
|
value: 'now',
|
|
98
|
-
label:
|
|
93
|
+
label: (0, _locale.lang)('System time')
|
|
99
94
|
}] : [])];
|
|
100
95
|
}
|
|
101
96
|
};
|
|
@@ -110,7 +105,7 @@ const BaseTypeSets = {
|
|
|
110
105
|
// { type: 'reference', options: { collection: 'attachments', multiple: false } }
|
|
111
106
|
// { type: 'reference', options: { collection: 'myExpressions', entity: false } }
|
|
112
107
|
exports.BaseTypeSets = BaseTypeSets;
|
|
113
|
-
function matchFieldType(field, type,
|
|
108
|
+
function matchFieldType(field, type, appends) {
|
|
114
109
|
const inputType = typeof type;
|
|
115
110
|
if (inputType === 'string') {
|
|
116
111
|
var _BaseTypeSets$type;
|
|
@@ -128,42 +123,67 @@ function matchFieldType(field, type, depth) {
|
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
125
|
if (inputType === 'function') {
|
|
131
|
-
return type(field,
|
|
126
|
+
return type(field, appends);
|
|
132
127
|
}
|
|
133
128
|
return false;
|
|
134
129
|
}
|
|
135
130
|
function isAssociationField(field) {
|
|
136
131
|
return ['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
|
|
137
132
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
function getNextAppends(field, appends) {
|
|
134
|
+
const fieldPrefix = `${field.name}.`;
|
|
135
|
+
return appends.filter(item => item.startsWith(fieldPrefix)).map(item => item.replace(fieldPrefix, ''));
|
|
136
|
+
}
|
|
137
|
+
function filterTypedFields({
|
|
138
|
+
fields,
|
|
139
|
+
types,
|
|
140
|
+
appends,
|
|
141
|
+
compile,
|
|
142
|
+
getCollectionFields
|
|
143
|
+
}) {
|
|
142
144
|
return fields.filter(field => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
const match = (types === null || types === void 0 ? void 0 : types.length) ? types.some(type => matchFieldType(field, type, appends)) : true;
|
|
146
|
+
if (isAssociationField(field)) {
|
|
147
|
+
const nextAppends = getNextAppends(field, appends);
|
|
148
|
+
const included = appends.includes(field.name);
|
|
149
|
+
if (match) {
|
|
150
|
+
return included;
|
|
151
|
+
} else {
|
|
152
|
+
return (nextAppends.length || included) && filterTypedFields({
|
|
153
|
+
fields: getNormalizedFields(field.target, {
|
|
154
|
+
compile,
|
|
155
|
+
getCollectionFields
|
|
156
|
+
}),
|
|
157
|
+
types,
|
|
158
|
+
// depth: depth - 1,
|
|
159
|
+
appends: nextAppends,
|
|
160
|
+
compile,
|
|
161
|
+
getCollectionFields
|
|
162
|
+
}).length;
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
return match;
|
|
145
166
|
}
|
|
146
|
-
return types.some(type => matchFieldType(field, type, depth));
|
|
147
167
|
});
|
|
148
168
|
}
|
|
149
169
|
function useWorkflowVariableOptions(options = {}) {
|
|
150
170
|
const compile = (0, _client().useCompile)();
|
|
151
171
|
const result = [scopeOptions, nodesOptions, triggerOptions, systemOptions].map(item => {
|
|
152
|
-
const opts =
|
|
172
|
+
const opts = item.useOptions(options).filter(Boolean);
|
|
153
173
|
return {
|
|
154
174
|
label: compile(item.label),
|
|
155
175
|
value: item.value,
|
|
156
176
|
key: item.value,
|
|
157
|
-
children:
|
|
177
|
+
children: opts,
|
|
158
178
|
disabled: opts && !opts.length
|
|
159
179
|
};
|
|
160
180
|
});
|
|
161
181
|
return result;
|
|
162
182
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
function getNormalizedFields(collectionName, {
|
|
184
|
+
compile,
|
|
185
|
+
getCollectionFields
|
|
186
|
+
}) {
|
|
167
187
|
const fields = getCollectionFields(collectionName);
|
|
168
188
|
const foreignKeyFields = [];
|
|
169
189
|
const otherFields = [];
|
|
@@ -211,28 +231,73 @@ function useNormalizedFields(collectionName) {
|
|
|
211
231
|
}
|
|
212
232
|
return otherFields.filter(field => field.interface && !field.hidden);
|
|
213
233
|
}
|
|
214
|
-
function
|
|
234
|
+
function loadChildren(_x) {
|
|
235
|
+
return _loadChildren.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
function _loadChildren() {
|
|
238
|
+
_loadChildren = _asyncToGenerator(function* (option) {
|
|
239
|
+
const result = getCollectionFieldOptions({
|
|
240
|
+
collection: option.field.target,
|
|
241
|
+
types: option.types,
|
|
242
|
+
appends: getNextAppends(option.field, option.appends),
|
|
243
|
+
sourceKey: option.field.key,
|
|
244
|
+
compile: this.compile,
|
|
245
|
+
getCollectionFields: this.getCollectionFields
|
|
246
|
+
});
|
|
247
|
+
if (result.length) {
|
|
248
|
+
option.children = result;
|
|
249
|
+
} else {
|
|
250
|
+
var _option$types;
|
|
251
|
+
option.isLeaf = true;
|
|
252
|
+
option.loadChildren = null;
|
|
253
|
+
const matchingType = (_option$types = option.types) === null || _option$types === void 0 ? void 0 : _option$types.some(type => matchFieldType(option.field, type, 0));
|
|
254
|
+
if (!matchingType) {
|
|
255
|
+
option.disabled = true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return _loadChildren.apply(this, arguments);
|
|
260
|
+
}
|
|
261
|
+
function getCollectionFieldOptions(options) {
|
|
215
262
|
const fields = options.fields,
|
|
216
263
|
collection = options.collection,
|
|
217
264
|
types = options.types,
|
|
218
|
-
_options$
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
265
|
+
_options$appends = options.appends,
|
|
266
|
+
appends = _options$appends === void 0 ? [] : _options$appends,
|
|
267
|
+
compile = options.compile,
|
|
268
|
+
getCollectionFields = options.getCollectionFields;
|
|
269
|
+
const normalizedFields = getNormalizedFields(collection, {
|
|
270
|
+
compile,
|
|
271
|
+
getCollectionFields
|
|
272
|
+
});
|
|
222
273
|
const computedFields = fields !== null && fields !== void 0 ? fields : normalizedFields;
|
|
223
|
-
const
|
|
274
|
+
const boundLoadChildren = loadChildren.bind({
|
|
275
|
+
compile,
|
|
276
|
+
getCollectionFields
|
|
277
|
+
});
|
|
278
|
+
const result = filterTypedFields({
|
|
279
|
+
fields: computedFields,
|
|
280
|
+
types,
|
|
281
|
+
// depth,
|
|
282
|
+
appends,
|
|
283
|
+
compile,
|
|
284
|
+
getCollectionFields
|
|
285
|
+
}).map(field => {
|
|
224
286
|
var _field$uiSchema5;
|
|
225
287
|
const label = compile(((_field$uiSchema5 = field.uiSchema) === null || _field$uiSchema5 === void 0 ? void 0 : _field$uiSchema5.title) || field.name);
|
|
288
|
+
const nextAppends = getNextAppends(field, appends);
|
|
289
|
+
// TODO: no matching fields in next appends should consider isLeaf as true
|
|
290
|
+
const isLeaf = !isAssociationField(field) || !nextAppends.length && !appends.includes(field.name);
|
|
226
291
|
return {
|
|
227
292
|
label,
|
|
228
293
|
key: field.name,
|
|
229
294
|
value: field.name,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
295
|
+
isLeaf,
|
|
296
|
+
loadChildren: isLeaf ? null : boundLoadChildren,
|
|
297
|
+
field,
|
|
298
|
+
// depth,
|
|
299
|
+
appends,
|
|
300
|
+
types
|
|
236
301
|
};
|
|
237
302
|
});
|
|
238
303
|
return result;
|