@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.
Files changed (127) hide show
  1. package/client.d.ts +4 -0
  2. package/client.js +30 -0
  3. package/lib/client/ExecutionResourceProvider.d.ts +4 -0
  4. package/lib/client/ExecutionResourceProvider.js +64 -0
  5. package/lib/client/WorkflowCanvas.d.ts +15 -0
  6. package/lib/client/WorkflowCanvas.js +393 -0
  7. package/lib/client/WorkflowLink.d.ts +1 -0
  8. package/lib/client/WorkflowLink.js +66 -0
  9. package/lib/client/WorkflowPage.d.ts +1 -0
  10. package/lib/client/WorkflowPage.js +92 -0
  11. package/lib/client/WorkflowProvider.d.ts +1 -0
  12. package/lib/client/WorkflowProvider.js +78 -0
  13. package/lib/client/WorkflowShortcut.d.ts +1 -0
  14. package/lib/client/WorkflowShortcut.js +123 -0
  15. package/lib/client/calculators.d.ts +101 -0
  16. package/lib/client/calculators.js +739 -0
  17. package/lib/client/components/Duration.d.ts +5 -0
  18. package/lib/client/components/Duration.js +96 -0
  19. package/lib/client/index.d.ts +3 -0
  20. package/lib/client/index.js +38 -0
  21. package/lib/client/nodes/calculation.d.ts +25 -0
  22. package/lib/client/nodes/calculation.js +85 -0
  23. package/lib/client/nodes/condition.d.ts +46 -0
  24. package/lib/client/nodes/condition.js +346 -0
  25. package/lib/client/nodes/create.d.ts +46 -0
  26. package/lib/client/nodes/create.js +133 -0
  27. package/lib/client/nodes/delay.d.ts +36 -0
  28. package/lib/client/nodes/delay.js +49 -0
  29. package/lib/client/nodes/destroy.d.ts +55 -0
  30. package/lib/client/nodes/destroy.js +46 -0
  31. package/lib/client/nodes/index.d.ts +33 -0
  32. package/lib/client/nodes/index.js +390 -0
  33. package/lib/client/nodes/parallel.d.ts +24 -0
  34. package/lib/client/nodes/parallel.js +216 -0
  35. package/lib/client/nodes/query.d.ts +70 -0
  36. package/lib/client/nodes/query.js +143 -0
  37. package/lib/client/nodes/update.d.ts +60 -0
  38. package/lib/client/nodes/update.js +48 -0
  39. package/lib/client/schemas/collection.d.ts +42 -0
  40. package/lib/client/schemas/collection.js +98 -0
  41. package/lib/client/schemas/executions.d.ts +209 -0
  42. package/lib/client/schemas/executions.js +164 -0
  43. package/lib/client/schemas/workflows.d.ts +2 -0
  44. package/lib/client/schemas/workflows.js +328 -0
  45. package/lib/client/style.d.ts +12 -0
  46. package/lib/client/style.js +216 -0
  47. package/lib/client/triggers/collection.d.ts +92 -0
  48. package/lib/client/triggers/collection.js +253 -0
  49. package/lib/client/triggers/index.d.ts +26 -0
  50. package/lib/client/triggers/index.js +238 -0
  51. package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +2 -0
  52. package/lib/client/triggers/schedule/DateFieldsSelect.js +92 -0
  53. package/lib/client/triggers/schedule/EndsByField.d.ts +5 -0
  54. package/lib/client/triggers/schedule/EndsByField.js +102 -0
  55. package/lib/client/triggers/schedule/OnField.d.ts +5 -0
  56. package/lib/client/triggers/schedule/OnField.js +128 -0
  57. package/lib/client/triggers/schedule/RepeatField.d.ts +5 -0
  58. package/lib/client/triggers/schedule/RepeatField.js +191 -0
  59. package/lib/client/triggers/schedule/ScheduleConfig.d.ts +1 -0
  60. package/lib/client/triggers/schedule/ScheduleConfig.js +286 -0
  61. package/lib/client/triggers/schedule/index.d.ts +25 -0
  62. package/lib/client/triggers/schedule/index.js +124 -0
  63. package/lib/client/triggers/schedule/locale/Cron.zh-CN.d.ts +34 -0
  64. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +44 -0
  65. package/lib/index.d.ts +1 -6
  66. package/lib/index.js +2 -73
  67. package/lib/{Plugin.d.ts → server/Plugin.d.ts} +0 -0
  68. package/lib/{Plugin.js → server/Plugin.js} +0 -0
  69. package/lib/{Processor.d.ts → server/Processor.d.ts} +4 -3
  70. package/lib/{Processor.js → server/Processor.js} +40 -24
  71. package/lib/{actions → server/actions}/index.d.ts +0 -0
  72. package/lib/{actions → server/actions}/index.js +0 -0
  73. package/lib/{actions → server/actions}/nodes.d.ts +0 -0
  74. package/lib/{actions → server/actions}/nodes.js +1 -0
  75. package/lib/{actions → server/actions}/workflows.d.ts +0 -0
  76. package/lib/{actions → server/actions}/workflows.js +0 -0
  77. package/lib/{calculators → server/calculators}/index.d.ts +0 -0
  78. package/lib/{calculators → server/calculators}/index.js +0 -0
  79. package/lib/{collections → server/collections}/executions.d.ts +0 -0
  80. package/lib/{collections → server/collections}/executions.js +0 -0
  81. package/lib/{collections → server/collections}/flow_nodes.d.ts +0 -0
  82. package/lib/{collections → server/collections}/flow_nodes.js +0 -0
  83. package/lib/{collections → server/collections}/jobs.d.ts +0 -0
  84. package/lib/{collections → server/collections}/jobs.js +0 -0
  85. package/lib/{collections → server/collections}/workflows.d.ts +0 -0
  86. package/lib/{collections → server/collections}/workflows.js +0 -0
  87. package/lib/{constants.d.ts → server/constants.d.ts} +0 -0
  88. package/lib/{constants.js → server/constants.js} +0 -0
  89. package/lib/server/index.d.ts +6 -0
  90. package/lib/server/index.js +86 -0
  91. package/lib/{instructions → server/instructions}/calculation.d.ts +0 -0
  92. package/lib/{instructions → server/instructions}/calculation.js +0 -0
  93. package/lib/{instructions → server/instructions}/condition.d.ts +0 -0
  94. package/lib/{instructions → server/instructions}/condition.js +0 -0
  95. package/lib/{instructions → server/instructions}/create.d.ts +0 -0
  96. package/lib/{instructions → server/instructions}/create.js +0 -0
  97. package/lib/{instructions → server/instructions}/delay.d.ts +0 -0
  98. package/lib/{instructions → server/instructions}/delay.js +12 -5
  99. package/lib/{instructions → server/instructions}/destroy.d.ts +0 -0
  100. package/lib/{instructions → server/instructions}/destroy.js +0 -0
  101. package/lib/{instructions → server/instructions}/index.d.ts +0 -0
  102. package/lib/{instructions → server/instructions}/index.js +0 -0
  103. package/lib/{instructions → server/instructions}/parallel.d.ts +0 -0
  104. package/lib/{instructions → server/instructions}/parallel.js +62 -20
  105. package/lib/{instructions → server/instructions}/prompt.d.ts +0 -0
  106. package/lib/{instructions → server/instructions}/prompt.js +0 -0
  107. package/lib/{instructions → server/instructions}/query.d.ts +0 -0
  108. package/lib/{instructions → server/instructions}/query.js +0 -0
  109. package/lib/{instructions → server/instructions}/update.d.ts +0 -0
  110. package/lib/{instructions → server/instructions}/update.js +0 -0
  111. package/lib/{models → server/models}/Execution.d.ts +0 -0
  112. package/lib/{models → server/models}/Execution.js +0 -0
  113. package/lib/{models → server/models}/FlowNode.d.ts +0 -0
  114. package/lib/{models → server/models}/FlowNode.js +0 -0
  115. package/lib/{models → server/models}/Job.d.ts +0 -0
  116. package/lib/{models → server/models}/Job.js +0 -0
  117. package/lib/{models → server/models}/Workflow.d.ts +0 -0
  118. package/lib/{models → server/models}/Workflow.js +0 -0
  119. package/lib/{triggers → server/triggers}/collection.d.ts +0 -0
  120. package/lib/{triggers → server/triggers}/collection.js +0 -0
  121. package/lib/{triggers → server/triggers}/index.d.ts +0 -0
  122. package/lib/{triggers → server/triggers}/index.js +0 -0
  123. package/lib/{triggers → server/triggers}/schedule.d.ts +0 -0
  124. package/lib/{triggers → server/triggers}/schedule.js +2 -2
  125. package/package.json +10 -8
  126. package/server.d.ts +4 -0
  127. package/server.js +30 -0
@@ -0,0 +1,390 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Node = Node;
7
+ exports.NodeDefaultView = NodeDefaultView;
8
+ exports.RemoveButton = RemoveButton;
9
+ exports.instructions = void 0;
10
+ exports.useNodeContext = useNodeContext;
11
+
12
+ function _icons() {
13
+ const data = require("@ant-design/icons");
14
+
15
+ _icons = function _icons() {
16
+ return data;
17
+ };
18
+
19
+ return data;
20
+ }
21
+
22
+ function _css() {
23
+ const data = require("@emotion/css");
24
+
25
+ _css = function _css() {
26
+ return data;
27
+ };
28
+
29
+ return data;
30
+ }
31
+
32
+ function _react() {
33
+ const data = require("@formily/react");
34
+
35
+ _react = function _react() {
36
+ return data;
37
+ };
38
+
39
+ return data;
40
+ }
41
+
42
+ function _client() {
43
+ const data = require("@nocobase/utils/client");
44
+
45
+ _client = function _client() {
46
+ return data;
47
+ };
48
+
49
+ return data;
50
+ }
51
+
52
+ function _antd() {
53
+ const data = require("antd");
54
+
55
+ _antd = function _antd() {
56
+ return data;
57
+ };
58
+
59
+ return data;
60
+ }
61
+
62
+ function _react2() {
63
+ const data = _interopRequireWildcard(require("react"));
64
+
65
+ _react2 = function _react2() {
66
+ return data;
67
+ };
68
+
69
+ return data;
70
+ }
71
+
72
+ function _reactI18next() {
73
+ const data = require("react-i18next");
74
+
75
+ _reactI18next = function _reactI18next() {
76
+ return data;
77
+ };
78
+
79
+ return data;
80
+ }
81
+
82
+ function _client2() {
83
+ const data = require("@nocobase/client");
84
+
85
+ _client2 = function _client2() {
86
+ return data;
87
+ };
88
+
89
+ return data;
90
+ }
91
+
92
+ var _style = require("../style");
93
+
94
+ var _WorkflowCanvas = require("../WorkflowCanvas");
95
+
96
+ var _calculation = _interopRequireDefault(require("./calculation"));
97
+
98
+ var _condition = _interopRequireDefault(require("./condition"));
99
+
100
+ var _parallel = _interopRequireDefault(require("./parallel"));
101
+
102
+ var _delay = _interopRequireDefault(require("./delay"));
103
+
104
+ var _query = _interopRequireDefault(require("./query"));
105
+
106
+ var _create = _interopRequireDefault(require("./create"));
107
+
108
+ var _update = _interopRequireDefault(require("./update"));
109
+
110
+ var _destroy = _interopRequireDefault(require("./destroy"));
111
+
112
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
113
+
114
+ 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); }
115
+
116
+ 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; }
117
+
118
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
119
+
120
+ 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); }); }; }
121
+
122
+ ;
123
+ const instructions = new (_client().Registry)();
124
+ exports.instructions = instructions;
125
+ instructions.register('condition', _condition.default);
126
+ instructions.register('parallel', _parallel.default);
127
+ instructions.register('calculation', _calculation.default);
128
+ instructions.register('delay', _delay.default);
129
+ instructions.register('query', _query.default);
130
+ instructions.register('create', _create.default);
131
+ instructions.register('update', _update.default);
132
+ instructions.register('destroy', _destroy.default);
133
+
134
+ function useUpdateAction() {
135
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
136
+ t = _useTranslation.t;
137
+
138
+ const form = (0, _react().useForm)();
139
+ const api = (0, _client2().useAPIClient)();
140
+ const ctx = (0, _client2().useActionContext)();
141
+
142
+ const _useResourceActionCon = (0, _client2().useResourceActionContext)(),
143
+ refresh = _useResourceActionCon.refresh;
144
+
145
+ const data = useNodeContext();
146
+
147
+ const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
148
+ workflow = _useFlowContext.workflow;
149
+
150
+ return {
151
+ run() {
152
+ return _asyncToGenerator(function* () {
153
+ if (workflow.executed) {
154
+ _antd().message.error(t('Node in executed workflow cannot be modified'));
155
+
156
+ return;
157
+ }
158
+
159
+ yield form.submit();
160
+ yield api.resource('flow_nodes', data.id).update({
161
+ filterByTk: data.id,
162
+ values: {
163
+ title: form.values.title,
164
+ config: form.values.config
165
+ }
166
+ });
167
+ ctx.setVisible(false);
168
+ refresh();
169
+ })();
170
+ }
171
+
172
+ };
173
+ }
174
+
175
+ ;
176
+
177
+ const NodeContext = _react2().default.createContext(null);
178
+
179
+ function useNodeContext() {
180
+ return (0, _react2().useContext)(NodeContext);
181
+ }
182
+
183
+ function Node({
184
+ data
185
+ }) {
186
+ const instruction = instructions.get(data.type);
187
+ return _react2().default.createElement(NodeContext.Provider, {
188
+ value: data
189
+ }, _react2().default.createElement("div", {
190
+ className: (0, _css().cx)(_style.nodeBlockClass)
191
+ }, instruction.render ? instruction.render(data) : _react2().default.createElement(NodeDefaultView, {
192
+ data: data
193
+ }), !instruction.endding ? _react2().default.createElement(_WorkflowCanvas.AddButton, {
194
+ upstream: data
195
+ }) : _react2().default.createElement("div", {
196
+ className: (0, _css().css)`
197
+ flex-grow: 1;
198
+ display: flex;
199
+ flex-direction: column;
200
+ align-items: center;
201
+ justify-content: center;
202
+ width: 1px;
203
+ height: 6em;
204
+ padding: 2em 0;
205
+ background-color: #f0f2f5;
206
+
207
+ .anticon{
208
+ font-size: 1.5em;
209
+ line-height: 100%;
210
+ }
211
+ `
212
+ }, _react2().default.createElement(_icons().CloseOutlined, null))));
213
+ }
214
+
215
+ function RemoveButton() {
216
+ const _useTranslation2 = (0, _reactI18next().useTranslation)(),
217
+ t = _useTranslation2.t;
218
+
219
+ const api = (0, _client2().useAPIClient)();
220
+
221
+ const _useFlowContext2 = (0, _WorkflowCanvas.useFlowContext)(),
222
+ workflow = _useFlowContext2.workflow;
223
+
224
+ const resource = api.resource('workflows.nodes', workflow.id);
225
+ const current = useNodeContext();
226
+
227
+ const _useFlowContext3 = (0, _WorkflowCanvas.useFlowContext)(),
228
+ nodes = _useFlowContext3.nodes,
229
+ onNodeRemoved = _useFlowContext3.onNodeRemoved;
230
+
231
+ function onRemove() {
232
+ return _onRemove.apply(this, arguments);
233
+ }
234
+
235
+ function _onRemove() {
236
+ _onRemove = _asyncToGenerator(function* () {
237
+ function onOk() {
238
+ return _onOk.apply(this, arguments);
239
+ }
240
+
241
+ function _onOk() {
242
+ _onOk = _asyncToGenerator(function* () {
243
+ const _yield$resource$destr = yield resource.destroy({
244
+ filterByTk: current.id
245
+ }),
246
+ node = _yield$resource$destr.data.data;
247
+
248
+ onNodeRemoved(node);
249
+ });
250
+ return _onOk.apply(this, arguments);
251
+ }
252
+
253
+ const hasBranches = !nodes.find(item => item.upstream === current && item.branchIndex != null);
254
+ const message = hasBranches ? t('Are you sure you want to delete it?') : t('This node contains branches, deleting will also be preformed to them, are you sure?');
255
+
256
+ _antd().Modal.confirm({
257
+ title: t('Delete'),
258
+ content: message,
259
+ onOk
260
+ });
261
+ });
262
+ return _onRemove.apply(this, arguments);
263
+ }
264
+
265
+ return workflow.executed ? null : _react2().default.createElement(_antd().Button, {
266
+ type: "text",
267
+ shape: "circle",
268
+ icon: _react2().default.createElement(_icons().DeleteOutlined, null),
269
+ onClick: onRemove,
270
+ className: "workflow-node-remove-button"
271
+ });
272
+ }
273
+
274
+ function NodeDefaultView(props) {
275
+ const compile = (0, _client2().useCompile)();
276
+
277
+ const _useFlowContext4 = (0, _WorkflowCanvas.useFlowContext)(),
278
+ workflow = _useFlowContext4.workflow;
279
+
280
+ const data = props.data,
281
+ children = props.children;
282
+ const instruction = instructions.get(data.type);
283
+ const detailText = workflow.executed ? '{{t("View")}}' : '{{t("Configure")}}';
284
+ return _react2().default.createElement("div", {
285
+ className: (0, _css().cx)(_style.nodeClass, `workflow-node-type-${data.type}`)
286
+ }, _react2().default.createElement("div", {
287
+ className: (0, _css().cx)(_style.nodeCardClass)
288
+ }, _react2().default.createElement("div", {
289
+ className: (0, _css().cx)(_style.nodeHeaderClass)
290
+ }, _react2().default.createElement("div", {
291
+ className: (0, _css().cx)(_style.nodeMetaClass)
292
+ }, _react2().default.createElement(_antd().Tag, null, compile(instruction.title))), _react2().default.createElement("h4", {
293
+ className: (0, _css().cx)(_style.nodeTitleClass)
294
+ }, _react2().default.createElement("strong", null, data.title), _react2().default.createElement("span", {
295
+ className: "workflow-node-id"
296
+ }, "#", data.id)), _react2().default.createElement(RemoveButton, null)), _react2().default.createElement(_client2().SchemaComponent, {
297
+ scope: instruction.scope,
298
+ components: instruction.components,
299
+ schema: {
300
+ type: 'void',
301
+ properties: {
302
+ view: instruction.view,
303
+ config: {
304
+ type: 'void',
305
+ title: detailText,
306
+ 'x-component': 'Action.Link',
307
+ 'x-component-props': {
308
+ type: 'primary'
309
+ },
310
+ properties: {
311
+ [instruction.type]: {
312
+ type: 'void',
313
+ title: instruction.title,
314
+ 'x-component': 'Action.Drawer',
315
+ 'x-decorator': 'Form',
316
+ 'x-decorator-props': {
317
+ useValues(options) {
318
+ const d = useNodeContext();
319
+ return (0, _client2().useRequest)(() => {
320
+ return Promise.resolve({
321
+ data: d
322
+ });
323
+ }, options);
324
+ }
325
+
326
+ },
327
+ properties: {
328
+ title: {
329
+ type: 'string',
330
+ name: 'title',
331
+ title: '{{t("Name")}}',
332
+ 'x-decorator': 'FormItem',
333
+ 'x-component': 'Input'
334
+ },
335
+ config: {
336
+ type: 'void',
337
+ name: 'config',
338
+ 'x-component': 'fieldset',
339
+ 'x-component-props': {
340
+ disabled: workflow.executed,
341
+ className: (0, _css().css)`
342
+ .ant-select,
343
+ .ant-cascader-picker,
344
+ .ant-picker,
345
+ .ant-input-number,
346
+ .ant-input-affix-wrapper{
347
+ width: auto;
348
+ min-width: 6em;
349
+ }
350
+ `
351
+ },
352
+ properties: instruction.fieldset
353
+ },
354
+ actions: {
355
+ type: 'void',
356
+ 'x-component': 'Action.Drawer.Footer',
357
+ properties: workflow.executed ? {
358
+ close: {
359
+ title: '{{t("Close")}}',
360
+ 'x-component': 'Action',
361
+ 'x-component-props': {
362
+ useAction: '{{ cm.useCancelAction }}'
363
+ }
364
+ }
365
+ } : {
366
+ cancel: {
367
+ title: '{{t("Cancel")}}',
368
+ 'x-component': 'Action',
369
+ 'x-component-props': {
370
+ useAction: '{{ cm.useCancelAction }}'
371
+ }
372
+ },
373
+ submit: {
374
+ title: '{{t("Submit")}}',
375
+ 'x-component': 'Action',
376
+ 'x-component-props': {
377
+ type: 'primary',
378
+ useAction: useUpdateAction
379
+ }
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
385
+ }
386
+ }
387
+ }
388
+ }
389
+ })), children);
390
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ declare const _default: {
3
+ title: string;
4
+ type: string;
5
+ group: string;
6
+ fieldset: {
7
+ 'config.mode': {
8
+ type: string;
9
+ name: string;
10
+ title: string;
11
+ 'x-decorator': string;
12
+ 'x-component': string;
13
+ 'x-component-props': {};
14
+ enum: {
15
+ value: string;
16
+ label: JSX.Element;
17
+ }[];
18
+ default: string;
19
+ };
20
+ };
21
+ view: {};
22
+ render(data: any): JSX.Element;
23
+ };
24
+ export default _default;
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function _react() {
9
+ const data = _interopRequireWildcard(require("react"));
10
+
11
+ _react = function _react() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _css() {
19
+ const data = require("@emotion/css");
20
+
21
+ _css = function _css() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _icons() {
29
+ const data = require("@ant-design/icons");
30
+
31
+ _icons = function _icons() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _antd() {
39
+ const data = require("antd");
40
+
41
+ _antd = function _antd() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _reactI18next() {
49
+ const data = require("react-i18next");
50
+
51
+ _reactI18next = function _reactI18next() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ function _client() {
59
+ const data = require("@nocobase/client");
60
+
61
+ _client = function _client() {
62
+ return data;
63
+ };
64
+
65
+ return data;
66
+ }
67
+
68
+ var _2 = require(".");
69
+
70
+ var _WorkflowCanvas = require("../WorkflowCanvas");
71
+
72
+ var _style = require("../style");
73
+
74
+ 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); }
75
+
76
+ 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; }
77
+
78
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
79
+
80
+ 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."); }
81
+
82
+ 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); }
83
+
84
+ 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; }
85
+
86
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
87
+
88
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
89
+
90
+ var _default = {
91
+ title: '{{t("Parallel branch")}}',
92
+ type: 'parallel',
93
+ group: 'control',
94
+ fieldset: {
95
+ 'config.mode': {
96
+ type: 'string',
97
+ name: 'config.mode',
98
+ title: '{{t("Mode")}}',
99
+ 'x-decorator': 'FormItem',
100
+ 'x-component': 'Radio.Group',
101
+ 'x-component-props': {},
102
+ enum: [{
103
+ value: 'all',
104
+ label: _react().default.createElement(_antd().Tooltip, {
105
+ title: _client().i18n.t('Continue after all branches succeeded'),
106
+ placement: "bottom"
107
+ }, _client().i18n.t('All succeeded'), " ", _react().default.createElement(_icons().QuestionCircleOutlined, {
108
+ style: {
109
+ color: '#999'
110
+ }
111
+ }))
112
+ }, {
113
+ value: 'any',
114
+ label: _react().default.createElement(_antd().Tooltip, {
115
+ title: _client().i18n.t('Continue after any branch succeeded'),
116
+ placement: "bottom"
117
+ }, _client().i18n.t('Any succeeded'), " ", _react().default.createElement(_icons().QuestionCircleOutlined, {
118
+ style: {
119
+ color: '#999'
120
+ }
121
+ }))
122
+ }, {
123
+ value: 'race',
124
+ label: _react().default.createElement(_antd().Tooltip, {
125
+ title: _client().i18n.t('Continue after any branch succeeded, or exit after any branch failed'),
126
+ placement: "bottom"
127
+ }, _client().i18n.t('Any succeeded or failed'), " ", _react().default.createElement(_icons().QuestionCircleOutlined, {
128
+ style: {
129
+ color: '#999'
130
+ }
131
+ }))
132
+ }],
133
+ default: 'all'
134
+ }
135
+ },
136
+ view: {},
137
+
138
+ render(data) {
139
+ const id = data.id,
140
+ mode = data.config.mode;
141
+
142
+ const _useTranslation = (0, _reactI18next().useTranslation)(),
143
+ t = _useTranslation.t;
144
+
145
+ const _useFlowContext = (0, _WorkflowCanvas.useFlowContext)(),
146
+ nodes = _useFlowContext.nodes;
147
+
148
+ const branches = nodes.reduce((result, node) => {
149
+ if (node.upstreamId === id && node.branchIndex != null) {
150
+ return result.concat(node);
151
+ }
152
+
153
+ return result;
154
+ }, []).sort((a, b) => a.branchIndex - b.branchIndex);
155
+
156
+ const _useState = (0, _react().useState)(Math.max(2, branches.length)),
157
+ _useState2 = _slicedToArray(_useState, 2),
158
+ branchCount = _useState2[0],
159
+ setBranchCount = _useState2[1];
160
+
161
+ const tempBranches = Array(Math.max(0, branchCount - branches.length)).fill(null);
162
+ const lastBranchHead = branches[branches.length - 1];
163
+ return _react().default.createElement(_2.NodeDefaultView, {
164
+ data: data
165
+ }, _react().default.createElement("div", {
166
+ className: (0, _css().cx)(_style.nodeSubtreeClass)
167
+ }, _react().default.createElement("div", {
168
+ className: (0, _css().cx)(_style.branchBlockClass)
169
+ }, branches.map(branch => _react().default.createElement(_WorkflowCanvas.Branch, {
170
+ key: branch.id,
171
+ from: data,
172
+ entry: branch,
173
+ branchIndex: branch.branchIndex
174
+ })), tempBranches.map((_, i) => _react().default.createElement(_WorkflowCanvas.Branch, {
175
+ key: `temp_${branches.length + i}`,
176
+ from: data,
177
+ branchIndex: (lastBranchHead ? lastBranchHead.branchIndex : 0) + i + 1,
178
+ controller: branches.length + i > 1 ? _react().default.createElement("div", {
179
+ className: (0, _css().css)`
180
+ padding-top: 2em;
181
+
182
+ > button{
183
+ .anticon{
184
+ transform: rotate(45deg)
185
+ }
186
+ }
187
+ `
188
+ }, _react().default.createElement(_antd().Button, {
189
+ shape: "circle",
190
+ icon: _react().default.createElement(_icons().PlusOutlined, null),
191
+ onClick: () => setBranchCount(branchCount - 1)
192
+ })) : null
193
+ }))), _react().default.createElement("div", {
194
+ className: (0, _css().css)`
195
+ position: relative;
196
+ height: 2em;
197
+ `
198
+ }, _react().default.createElement(_antd().Tooltip, {
199
+ title: t('Add branch')
200
+ }, _react().default.createElement(_antd().Button, {
201
+ icon: _react().default.createElement(_icons().PlusOutlined, null),
202
+ className: (0, _css().css)`
203
+ position: absolute;
204
+ top: calc(50% - 1px);
205
+ transform: translateX(-50%) rotate(45deg);
206
+
207
+ .anticon{
208
+ transform: rotate(-45deg);
209
+ }
210
+ `,
211
+ onClick: () => setBranchCount(branchCount + 1)
212
+ })))));
213
+ }
214
+
215
+ };
216
+ exports.default = _default;
@@ -0,0 +1,70 @@
1
+ import { useCollectionDataSource } from '@nocobase/client';
2
+ import { VariableComponent } from '../calculators';
3
+ declare const _default: {
4
+ title: string;
5
+ type: string;
6
+ group: string;
7
+ fieldset: {
8
+ 'config.collection': {
9
+ type: string;
10
+ title: string;
11
+ name: string;
12
+ required: boolean;
13
+ 'x-reactions': string[];
14
+ 'x-decorator': string;
15
+ 'x-component': string;
16
+ 'x-component-props': {
17
+ placeholder: string;
18
+ };
19
+ };
20
+ 'config.multiple': {
21
+ type: string;
22
+ title: string;
23
+ name: string;
24
+ 'x-decorator': string;
25
+ 'x-component': string;
26
+ 'x-component-props': {
27
+ disabled: boolean;
28
+ };
29
+ };
30
+ 'config.params': {
31
+ type: string;
32
+ name: string;
33
+ title: string;
34
+ 'x-decorator': string;
35
+ properties: {
36
+ filter: {
37
+ type: string;
38
+ title: string;
39
+ name: string;
40
+ 'x-decorator': string;
41
+ 'x-decorator-props': {
42
+ labelAlign: string;
43
+ className: string;
44
+ };
45
+ 'x-component': string;
46
+ 'x-component-props': {
47
+ useProps(): {
48
+ options: any[];
49
+ className: string;
50
+ };
51
+ dynamicComponent: string;
52
+ };
53
+ };
54
+ };
55
+ };
56
+ };
57
+ view: {};
58
+ scope: {
59
+ useCollectionDataSource: typeof useCollectionDataSource;
60
+ };
61
+ components: {
62
+ VariableComponent: typeof VariableComponent;
63
+ };
64
+ getter({ type, options, onChange }: {
65
+ type: any;
66
+ options: any;
67
+ onChange: any;
68
+ }): JSX.Element;
69
+ };
70
+ export default _default;