@nocobase/plugin-workflow 0.9.3-alpha.1 → 0.9.4-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.
Files changed (74) hide show
  1. package/lib/client/CanvasContent.d.ts +4 -0
  2. package/lib/client/CanvasContent.js +49 -0
  3. package/lib/client/ExecutionCanvas.js +110 -44
  4. package/lib/client/WorkflowCanvas.js +35 -18
  5. package/lib/client/components/CollectionFieldset.js +2 -2
  6. package/lib/client/components/NodeDescription.d.ts +2 -0
  7. package/lib/client/components/NodeDescription.js +59 -0
  8. package/lib/client/components/ValueBlock.d.ts +5 -0
  9. package/lib/client/components/ValueBlock.js +110 -0
  10. package/lib/client/index.d.ts +1 -0
  11. package/lib/client/index.js +12 -0
  12. package/lib/client/locale/es-ES.d.ts +130 -0
  13. package/lib/client/locale/es-ES.js +136 -0
  14. package/lib/client/locale/zh-CN.d.ts +35 -6
  15. package/lib/client/locale/zh-CN.js +35 -6
  16. package/lib/client/nodes/aggregate.d.ts +186 -0
  17. package/lib/client/nodes/aggregate.js +349 -0
  18. package/lib/client/nodes/calculation.d.ts +2 -1
  19. package/lib/client/nodes/calculation.js +28 -53
  20. package/lib/client/nodes/condition.d.ts +2 -6
  21. package/lib/client/nodes/condition.js +4 -3
  22. package/lib/client/nodes/create.d.ts +5 -3
  23. package/lib/client/nodes/create.js +16 -7
  24. package/lib/client/nodes/delay.d.ts +1 -0
  25. package/lib/client/nodes/delay.js +1 -0
  26. package/lib/client/nodes/destroy.d.ts +2 -2
  27. package/lib/client/nodes/destroy.js +1 -0
  28. package/lib/client/nodes/index.d.ts +5 -2
  29. package/lib/client/nodes/index.js +95 -97
  30. package/lib/client/nodes/loop.d.ts +29 -0
  31. package/lib/client/nodes/loop.js +165 -0
  32. package/lib/client/nodes/manual/AssigneesSelect.js +8 -6
  33. package/lib/client/nodes/manual/index.d.ts +6 -1
  34. package/lib/client/nodes/manual/index.js +6 -1
  35. package/lib/client/nodes/parallel.d.ts +1 -0
  36. package/lib/client/nodes/parallel.js +2 -1
  37. package/lib/client/nodes/query.d.ts +12 -3
  38. package/lib/client/nodes/query.js +24 -17
  39. package/lib/client/nodes/request.d.ts +1 -0
  40. package/lib/client/nodes/request.js +1 -0
  41. package/lib/client/nodes/update.d.ts +2 -2
  42. package/lib/client/nodes/update.js +1 -0
  43. package/lib/client/schemas/collection.d.ts +1 -2
  44. package/lib/client/schemas/collection.js +5 -6
  45. package/lib/client/style.d.ts +1 -0
  46. package/lib/client/style.js +40 -26
  47. package/lib/client/triggers/collection.d.ts +2 -11
  48. package/lib/client/triggers/collection.js +6 -7
  49. package/lib/client/triggers/index.d.ts +1 -1
  50. package/lib/client/triggers/index.js +5 -3
  51. package/lib/client/triggers/schedule/index.d.ts +3 -1
  52. package/lib/client/triggers/schedule/index.js +6 -4
  53. package/lib/client/variable.d.ts +27 -1
  54. package/lib/client/variable.js +65 -34
  55. package/lib/server/Plugin.js +2 -14
  56. package/lib/server/Processor.d.ts +3 -0
  57. package/lib/server/Processor.js +30 -3
  58. package/lib/server/actions/workflows.js +2 -2
  59. package/lib/server/collections/workflows.js +2 -1
  60. package/lib/server/instructions/aggregate.d.ts +9 -0
  61. package/lib/server/instructions/aggregate.js +57 -0
  62. package/lib/server/instructions/calculation.js +1 -1
  63. package/lib/server/instructions/condition.js +1 -1
  64. package/lib/server/instructions/create.js +1 -1
  65. package/lib/server/instructions/destroy.js +1 -1
  66. package/lib/server/instructions/index.d.ts +1 -0
  67. package/lib/server/instructions/index.js +1 -1
  68. package/lib/server/instructions/loop.d.ts +16 -0
  69. package/lib/server/instructions/loop.js +107 -0
  70. package/lib/server/instructions/parallel.js +17 -10
  71. package/lib/server/instructions/query.js +1 -4
  72. package/lib/server/instructions/request.js +1 -1
  73. package/lib/server/instructions/update.js +1 -1
  74. package/package.json +13 -13
@@ -0,0 +1,186 @@
1
+ import React from 'react';
2
+ import { SchemaInitializerItemOptions, useCollectionDataSource } from '@nocobase/client';
3
+ import { FilterDynamicComponent } from '../components/FilterDynamicComponent';
4
+ declare function AssociatedConfig({ value, onChange, ...props }: {
5
+ [x: string]: any;
6
+ value: any;
7
+ onChange: any;
8
+ }): JSX.Element;
9
+ declare const _default: {
10
+ title: string;
11
+ type: string;
12
+ group: string;
13
+ description: string;
14
+ fieldset: {
15
+ aggregator: {
16
+ type: string;
17
+ title: string;
18
+ 'x-decorator': string;
19
+ 'x-component': string;
20
+ enum: {
21
+ label: string;
22
+ value: string;
23
+ }[];
24
+ required: boolean;
25
+ default: string;
26
+ };
27
+ associated: {
28
+ type: string;
29
+ title: string;
30
+ 'x-decorator': string;
31
+ 'x-component': string;
32
+ enum: {
33
+ label: string;
34
+ value: boolean;
35
+ }[];
36
+ required: boolean;
37
+ default: boolean;
38
+ 'x-reactions': {
39
+ target: string;
40
+ effects: string[];
41
+ fulfill: {
42
+ state: {
43
+ value: any;
44
+ };
45
+ };
46
+ }[];
47
+ };
48
+ collectionField: {
49
+ type: string;
50
+ 'x-decorator': string;
51
+ 'x-decorator-props': {
52
+ value: {
53
+ designable: boolean;
54
+ };
55
+ };
56
+ 'x-component': string;
57
+ properties: {
58
+ row: {
59
+ type: string;
60
+ 'x-component': string;
61
+ properties: {
62
+ target: {
63
+ type: string;
64
+ 'x-component': string;
65
+ properties: {
66
+ collection: {
67
+ title: string;
68
+ 'x-component-props': {
69
+ className: string;
70
+ dropdownMatchSelectWidth: boolean;
71
+ };
72
+ 'x-reactions': any[];
73
+ type: string;
74
+ required: boolean;
75
+ 'x-decorator': string;
76
+ 'x-component': string;
77
+ };
78
+ association: {
79
+ type: string;
80
+ title: string;
81
+ 'x-decorator': string;
82
+ 'x-component': string;
83
+ 'x-component-props': {
84
+ className: string;
85
+ };
86
+ 'x-reactions': {
87
+ dependencies: string[];
88
+ fulfill: {
89
+ state: {
90
+ visible: string;
91
+ };
92
+ };
93
+ }[];
94
+ required: boolean;
95
+ };
96
+ };
97
+ };
98
+ field: {
99
+ type: string;
100
+ 'x-component': string;
101
+ properties: {
102
+ 'params.field': {
103
+ type: string;
104
+ title: string;
105
+ 'x-decorator': string;
106
+ 'x-component': string;
107
+ 'x-component-props': {
108
+ filter(field: any): boolean;
109
+ };
110
+ required: boolean;
111
+ 'x-reactions': {
112
+ dependencies: string[];
113
+ fulfill: {
114
+ state: {
115
+ visible: string;
116
+ };
117
+ };
118
+ }[];
119
+ };
120
+ };
121
+ };
122
+ };
123
+ };
124
+ };
125
+ };
126
+ params: {
127
+ type: string;
128
+ properties: {
129
+ distinct: {
130
+ type: string;
131
+ title: string;
132
+ 'x-decorator': string;
133
+ 'x-component': string;
134
+ 'x-reactions': {
135
+ dependencies: string[];
136
+ fulfill: {
137
+ state: {
138
+ visible: string;
139
+ };
140
+ };
141
+ }[];
142
+ };
143
+ filter: {
144
+ 'x-reactions': {
145
+ dependencies: string[];
146
+ fulfill: {
147
+ state: {
148
+ visible: string;
149
+ };
150
+ };
151
+ }[];
152
+ type: string;
153
+ title: string;
154
+ 'x-decorator': string;
155
+ 'x-component': string;
156
+ 'x-component-props': {
157
+ useProps(): {
158
+ options: any[];
159
+ className: string;
160
+ };
161
+ dynamicComponent: string;
162
+ };
163
+ };
164
+ };
165
+ };
166
+ };
167
+ view: {};
168
+ scope: {
169
+ useCollectionDataSource: typeof useCollectionDataSource;
170
+ };
171
+ components: {
172
+ SchemaComponentContext: React.Context<import("@nocobase/client").ISchemaComponentContext>;
173
+ FilterDynamicComponent: typeof FilterDynamicComponent;
174
+ FieldsSelect: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
175
+ ValueBlock: (() => JSX.Element) & {
176
+ Initializer: (props: any) => JSX.Element;
177
+ Result: (props: any) => JSX.Element;
178
+ };
179
+ AssociatedConfig: typeof AssociatedConfig;
180
+ };
181
+ useVariables(current: any, { types }: {
182
+ types: any;
183
+ }): any[];
184
+ useInitializers(node: any): SchemaInitializerItemOptions | null;
185
+ };
186
+ export default _default;
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function _react() {
8
+ const data = _interopRequireWildcard(require("react"));
9
+ _react = function _react() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _antd() {
15
+ const data = require("antd");
16
+ _antd = function _antd() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _react2() {
22
+ const data = require("@formily/react");
23
+ _react2 = function _react2() {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _client() {
29
+ const data = require("@nocobase/client");
30
+ _client = function _client() {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ var _collection = require("../schemas/collection");
36
+ var _locale = require("../locale");
37
+ var _FilterDynamicComponent = require("../components/FilterDynamicComponent");
38
+ var _variable = require("../variable");
39
+ var _FieldsSelect = require("../components/FieldsSelect");
40
+ var _ValueBlock = require("../components/ValueBlock");
41
+ var _ = require(".");
42
+ const _excluded = ["value", "onChange"];
43
+ 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); }
44
+ 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; }
45
+ 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; }
46
+ 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; }
47
+ 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; }
48
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
49
+ 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); }
50
+ 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; }
51
+ 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; }
52
+ function matchToManyField(field, depth) {
53
+ return ['hasMany', 'belongsToMany'].includes(field.type) && depth;
54
+ }
55
+ function AssociatedConfig(_ref) {
56
+ let value = _ref.value,
57
+ onChange = _ref.onChange,
58
+ props = _objectWithoutProperties(_ref, _excluded);
59
+ const _useForm = (0, _react2().useForm)(),
60
+ setValuesIn = _useForm.setValuesIn;
61
+ const compile = (0, _client().useCompile)();
62
+ const _useCollectionManager = (0, _client().useCollectionManager)(),
63
+ getCollection = _useCollectionManager.getCollection;
64
+ const current = (0, _.useNodeContext)();
65
+ const options = [_variable.nodesOptions, _variable.triggerOptions].map(item => {
66
+ var _item$useOptions;
67
+ const children = (_item$useOptions = item.useOptions({
68
+ types: [matchToManyField]
69
+ })) === null || _item$useOptions === void 0 ? void 0 : _item$useOptions.filter(Boolean);
70
+ return {
71
+ label: compile(item.label),
72
+ value: item.value,
73
+ key: item.value,
74
+ children: compile(children),
75
+ disabled: children && !children.length
76
+ };
77
+ });
78
+ const _ref2 = value !== null && value !== void 0 ? value : {},
79
+ _ref2$associatedKey = _ref2.associatedKey,
80
+ associatedKey = _ref2$associatedKey === void 0 ? '' : _ref2$associatedKey,
81
+ fieldName = _ref2.name;
82
+ let p = [];
83
+ const matched = associatedKey.match(/^{{(.*)}}$/);
84
+ if (matched) {
85
+ p = [...matched[1].trim().split('.').slice(0, -1), fieldName];
86
+ }
87
+ const onSelectChange = (0, _react().useCallback)((path, option) => {
88
+ if (!(path === null || path === void 0 ? void 0 : path.length)) {
89
+ setValuesIn('collection', null);
90
+ onChange({});
91
+ return;
92
+ }
93
+ // const associationFieldName = path.pop();
94
+ const _option$pop = option.pop(),
95
+ field = _option$pop.field;
96
+ // need to get:
97
+ // * source collection (from node.config)
98
+ // * target collection (from field name)
99
+ const collectionName = field.collectionName,
100
+ target = field.target,
101
+ name = field.name;
102
+ const collection = getCollection(collectionName);
103
+ const primaryKeyField = collection.fields.find(f => f.primaryKey);
104
+ setValuesIn('collection', target);
105
+ onChange({
106
+ name,
107
+ // primary key data path
108
+ associatedKey: `{{${path.slice(0, -1).join('.')}.${primaryKeyField.name}}}`,
109
+ // data associated collection name
110
+ associatedCollection: collectionName
111
+ });
112
+ }, [onChange]);
113
+ return _react().default.createElement(_antd().Cascader, _objectSpread(_objectSpread({}, props), {}, {
114
+ value: p,
115
+ options: options,
116
+ onChange: onSelectChange
117
+ }));
118
+ }
119
+ // based on collection:
120
+ // { collection, field }
121
+ // based on data associated collection
122
+ // { key: '{{$context.data.id}}', collection: "collection.association", field }
123
+ // select data based
124
+ var _default = {
125
+ title: `{{t("Aggregate", { ns: "${_locale.NAMESPACE}" })}}`,
126
+ type: 'aggregate',
127
+ group: 'collection',
128
+ description: `{{t("Counting, summing, finding maximum, minimum, and average values for multiple records of a collection or associated data of a record.", { ns: "${_locale.NAMESPACE}" })}}`,
129
+ fieldset: {
130
+ aggregator: {
131
+ type: 'string',
132
+ title: `{{t("Aggregator function", { ns: "${_locale.NAMESPACE}" })}}`,
133
+ 'x-decorator': 'FormItem',
134
+ 'x-component': 'Radio.Group',
135
+ enum: [{
136
+ label: 'COUNT',
137
+ value: 'count'
138
+ }, {
139
+ label: 'SUM',
140
+ value: 'sum'
141
+ }, {
142
+ label: 'AVG',
143
+ value: 'avg'
144
+ }, {
145
+ label: 'MIN',
146
+ value: 'min'
147
+ }, {
148
+ label: 'MAX',
149
+ value: 'max'
150
+ }],
151
+ required: true,
152
+ default: 'count'
153
+ },
154
+ associated: {
155
+ type: 'boolean',
156
+ title: `{{t("Target type", { ns: "${_locale.NAMESPACE}" })}}`,
157
+ 'x-decorator': 'FormItem',
158
+ 'x-component': 'Radio.Group',
159
+ enum: [{
160
+ label: `{{t("Data of collection", { ns: "${_locale.NAMESPACE}" })}}`,
161
+ value: false
162
+ }, {
163
+ label: `{{t("Data of associated collection", { ns: "${_locale.NAMESPACE}" })}}`,
164
+ value: true
165
+ }],
166
+ required: true,
167
+ default: false,
168
+ 'x-reactions': [{
169
+ target: 'collection',
170
+ effects: ['onFieldValueChange'],
171
+ fulfill: {
172
+ state: {
173
+ value: null
174
+ }
175
+ }
176
+ }, {
177
+ target: 'association',
178
+ effects: ['onFieldValueChange'],
179
+ fulfill: {
180
+ state: {
181
+ value: null
182
+ }
183
+ }
184
+ }]
185
+ },
186
+ collectionField: {
187
+ type: 'void',
188
+ 'x-decorator': 'SchemaComponentContext.Provider',
189
+ 'x-decorator-props': {
190
+ value: {
191
+ designable: false
192
+ }
193
+ },
194
+ 'x-component': 'Grid',
195
+ properties: {
196
+ row: {
197
+ type: 'void',
198
+ 'x-component': 'Grid.Row',
199
+ properties: {
200
+ target: {
201
+ type: 'void',
202
+ 'x-component': 'Grid.Col',
203
+ properties: {
204
+ collection: _objectSpread(_objectSpread({}, _collection.collection), {}, {
205
+ title: `{{t("Data of collection", { ns: "${_locale.NAMESPACE}" })}}`,
206
+ 'x-component-props': _objectSpread(_objectSpread({}, _collection.collection['x-component-props']), {}, {
207
+ className: 'full-width'
208
+ }),
209
+ 'x-reactions': [..._collection.collection['x-reactions'], {
210
+ dependencies: ['associated'],
211
+ fulfill: {
212
+ state: {
213
+ display: '{{$deps[0] ? "hidden" : "visible"}}'
214
+ }
215
+ }
216
+ }, {
217
+ target: 'params.field',
218
+ effects: ['onFieldValueChange'],
219
+ fulfill: {
220
+ state: {
221
+ value: null
222
+ }
223
+ }
224
+ }, {
225
+ target: 'params.filter',
226
+ effects: ['onFieldValueChange'],
227
+ fulfill: {
228
+ state: {
229
+ value: null
230
+ }
231
+ }
232
+ }]
233
+ }),
234
+ association: {
235
+ type: 'object',
236
+ title: `{{t("Data of associated collection", { ns: "${_locale.NAMESPACE}" })}}`,
237
+ 'x-decorator': 'FormItem',
238
+ 'x-component': 'AssociatedConfig',
239
+ 'x-component-props': {
240
+ className: 'full-width'
241
+ },
242
+ 'x-reactions': [{
243
+ dependencies: ['associated'],
244
+ fulfill: {
245
+ state: {
246
+ visible: '{{!!$deps[0]}}'
247
+ }
248
+ }
249
+ }],
250
+ required: true
251
+ }
252
+ }
253
+ },
254
+ field: {
255
+ type: 'void',
256
+ 'x-component': 'Grid.Col',
257
+ properties: {
258
+ 'params.field': {
259
+ type: 'string',
260
+ title: `{{t("Field to aggregate", { ns: "${_locale.NAMESPACE}" })}}`,
261
+ 'x-decorator': 'FormItem',
262
+ 'x-component': 'FieldsSelect',
263
+ 'x-component-props': {
264
+ filter(field) {
265
+ return !field.hidden && field.interface && !['belongsTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
266
+ }
267
+ },
268
+ required: true,
269
+ 'x-reactions': [{
270
+ dependencies: ['collection'],
271
+ fulfill: {
272
+ state: {
273
+ visible: '{{!!$deps[0]}}'
274
+ }
275
+ }
276
+ }]
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
282
+ }
283
+ },
284
+ params: {
285
+ type: 'object',
286
+ properties: {
287
+ distinct: {
288
+ type: 'boolean',
289
+ title: `{{t("Distinct", { ns: "${_locale.NAMESPACE}" })}}`,
290
+ 'x-decorator': 'FormItem',
291
+ 'x-component': 'Checkbox',
292
+ 'x-reactions': [{
293
+ dependencies: ['collection', 'aggregator'],
294
+ fulfill: {
295
+ state: {
296
+ visible: '{{!!$deps[0] && ["count"].includes($deps[1])}}'
297
+ }
298
+ }
299
+ }]
300
+ },
301
+ filter: _objectSpread(_objectSpread({}, _collection.filter), {}, {
302
+ 'x-reactions': [{
303
+ dependencies: ['collection'],
304
+ fulfill: {
305
+ state: {
306
+ visible: '{{!!$deps[0]}}'
307
+ }
308
+ }
309
+ }]
310
+ })
311
+ }
312
+ }
313
+ },
314
+ view: {},
315
+ scope: {
316
+ useCollectionDataSource: _client().useCollectionDataSource
317
+ },
318
+ components: {
319
+ SchemaComponentContext: _client().SchemaComponentContext,
320
+ FilterDynamicComponent: _FilterDynamicComponent.FilterDynamicComponent,
321
+ FieldsSelect: _FieldsSelect.FieldsSelect,
322
+ ValueBlock: _ValueBlock.ValueBlock,
323
+ AssociatedConfig
324
+ },
325
+ useVariables(current, {
326
+ types
327
+ }) {
328
+ if (types && !types.some(type => type in _variable.BaseTypeSets || Object.values(_variable.BaseTypeSets).some(set => set.has(type)))) {
329
+ return null;
330
+ }
331
+ return [
332
+ // { key: '', value: '', label: lang('Calculation result') }
333
+ ];
334
+ },
335
+ useInitializers(node) {
336
+ var _node$title;
337
+ if (!node.config.collection) {
338
+ return null;
339
+ }
340
+ return {
341
+ type: 'item',
342
+ title: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
343
+ component: _ValueBlock.ValueBlock.Initializer,
344
+ node,
345
+ resultTitle: (0, _locale.lang)('Query result')
346
+ };
347
+ }
348
+ };
349
+ exports.default = _default;
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  title: string;
13
13
  type: string;
14
14
  group: string;
15
+ description: string;
15
16
  fieldset: {
16
17
  dynamic: {
17
18
  type: string;
@@ -101,7 +102,7 @@ declare const _default: {
101
102
  onChange: any;
102
103
  }) => JSX.Element;
103
104
  };
104
- getOptions(config: any, types: any): any[];
105
+ useVariables(current: any, options: any): any[];
105
106
  useInitializers(node: any): SchemaInitializerItemOptions;
106
107
  };
107
108
  export default _default;
@@ -65,19 +65,11 @@ var _RadioWithTooltip = require("../components/RadioWithTooltip");
65
65
  var _renderEngineReference = require("../components/renderEngineReference");
66
66
  var _locale = require("../locale");
67
67
  var _variable = require("../variable");
68
- const _excluded = ["node", "insert"];
68
+ var _ValueBlock = require("../components/ValueBlock");
69
69
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
- 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; }
71
- 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; }
72
- 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; }
73
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
74
- 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); }
75
- 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; }
76
- 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; }
77
- function matchDynamicExpressionCollectionField(field) {
70
+ function useDynamicExpressionCollectionFieldMatcher(field) {
78
71
  const _useCollectionManager = (0, _client().useCollectionManager)(),
79
- getCollectionFields = _useCollectionManager.getCollectionFields,
80
- getCollection = _useCollectionManager.getCollection;
72
+ getCollectionFields = _useCollectionManager.getCollectionFields;
81
73
  if (field.type !== 'belongsTo') {
82
74
  return false;
83
75
  }
@@ -90,10 +82,13 @@ const DynamicConfig = ({
90
82
  }) => {
91
83
  const _useTranslation = (0, _reactI18next().useTranslation)(),
92
84
  t = _useTranslation.t;
93
- const scope = (0, _variable.useWorkflowVariableOptions)([matchDynamicExpressionCollectionField]);
85
+ const scope = (0, _variable.useWorkflowVariableOptions)({
86
+ types: [useDynamicExpressionCollectionFieldMatcher]
87
+ });
94
88
  return _react().default.createElement(_antd().FormLayout, {
95
89
  layout: "vertical"
96
90
  }, _react().default.createElement(_antd().FormItem, {
91
+ colon: true,
97
92
  label: t('Expression type', {
98
93
  ns: _locale.NAMESPACE
99
94
  })
@@ -113,6 +108,9 @@ const DynamicConfig = ({
113
108
  })))), value !== false ? _react().default.createElement(_antd().FormItem, {
114
109
  label: t('Select dynamic expression', {
115
110
  ns: _locale.NAMESPACE
111
+ }),
112
+ extra: t('Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.', {
113
+ ns: _locale.NAMESPACE
116
114
  })
117
115
  }, _react().default.createElement(_client().Variable.Input, {
118
116
  value: value || null,
@@ -121,22 +119,26 @@ const DynamicConfig = ({
121
119
  })) : null);
122
120
  };
123
121
  function useWorkflowVariableEntityOptions() {
124
- return (0, _variable.useWorkflowVariableOptions)([{
125
- type: 'reference',
126
- options: {
127
- collection: '*',
128
- entity: true
129
- }
130
- }]);
122
+ return (0, _variable.useWorkflowVariableOptions)({
123
+ types: [{
124
+ type: 'reference',
125
+ options: {
126
+ collection: '*',
127
+ entity: true
128
+ }
129
+ }]
130
+ });
131
131
  }
132
132
  var _default = {
133
133
  title: `{{t("Calculation", { ns: "${_locale.NAMESPACE}" })}}`,
134
134
  type: 'calculation',
135
135
  group: 'control',
136
+ description: `{{t("Calculate an expression based on a calculation engine and obtain a value as the result. Variables in the upstream nodes can be used in the expression. The expression can be static or dynamic one from an expression collections.", { ns: "${_locale.NAMESPACE}" })}}`,
136
137
  fieldset: {
137
138
  dynamic: {
138
139
  type: 'string',
139
140
  'x-component': 'DynamicConfig',
141
+ // description: `{{t("Select the dynamic expression queried from the upstream node. You need to query it from an expression collection.", { ns: "${NAMESPACE}" })}}`,
140
142
  default: false
141
143
  },
142
144
  engine: {
@@ -245,7 +247,9 @@ var _default = {
245
247
  RadioWithTooltip: _RadioWithTooltip.RadioWithTooltip,
246
248
  DynamicConfig
247
249
  },
248
- getOptions(config, types) {
250
+ useVariables(current, options) {
251
+ const _ref = options !== null && options !== void 0 ? options : {},
252
+ types = _ref.types;
249
253
  if (types && !types.some(type => type in _variable.BaseTypeSets || Object.values(_variable.BaseTypeSets).some(set => set.has(type)))) {
250
254
  return null;
251
255
  }
@@ -258,39 +262,10 @@ var _default = {
258
262
  return {
259
263
  type: 'item',
260
264
  title: (_node$title = node.title) !== null && _node$title !== void 0 ? _node$title : `#${node.id}`,
261
- component: CalculationInitializer,
262
- node
265
+ component: _ValueBlock.ValueBlock.Initializer,
266
+ node,
267
+ resultTitle: (0, _locale.lang)('Calculation result')
263
268
  };
264
269
  }
265
270
  };
266
- exports.default = _default;
267
- function CalculationInitializer(_ref) {
268
- let node = _ref.node,
269
- insert = _ref.insert,
270
- props = _objectWithoutProperties(_ref, _excluded);
271
- return _react().default.createElement(_client().SchemaInitializer.Item, _objectSpread(_objectSpread({}, props), {}, {
272
- onClick: () => {
273
- var _node$title2;
274
- insert({
275
- type: 'void',
276
- name: node.id,
277
- title: node.title,
278
- 'x-component': 'CardItem',
279
- 'x-component-props': {
280
- title: (_node$title2 = node.title) !== null && _node$title2 !== void 0 ? _node$title2 : `#${node.id}`
281
- },
282
- 'x-designer': 'SimpleDesigner',
283
- properties: {
284
- result: {
285
- type: 'void',
286
- 'x-component': 'CalculationResult',
287
- 'x-component-props': {
288
- // NOTE: as same format as other reference for migration of revision
289
- dataSource: `{{$jobsMapByNodeId.${node.id}}}`
290
- }
291
- }
292
- }
293
- });
294
- }
295
- }));
296
- }
271
+ exports.default = _default;