@nocobase/plugin-workflow 0.9.0-alpha.2 → 0.9.1-alpha.2

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 (138) hide show
  1. package/README.md +9 -0
  2. package/README.zh-CN.md +9 -0
  3. package/lib/client/AddButton.d.ts +1 -1
  4. package/lib/client/AddButton.js +43 -27
  5. package/lib/client/Branch.d.ts +1 -1
  6. package/lib/client/ExecutionCanvas.js +5 -10
  7. package/lib/client/WorkflowCanvas.js +12 -42
  8. package/lib/client/WorkflowProvider.js +10 -1
  9. package/lib/client/components/CollectionBlockInitializer.d.ts +7 -0
  10. package/lib/client/components/CollectionBlockInitializer.js +81 -0
  11. package/lib/client/components/CollectionFieldInitializers.d.ts +2 -0
  12. package/lib/client/components/CollectionFieldInitializers.js +89 -0
  13. package/lib/client/components/CollectionFieldset.js +25 -33
  14. package/lib/client/components/FilterDynamicComponent.d.ts +6 -0
  15. package/lib/client/components/FilterDynamicComponent.js +43 -0
  16. package/lib/client/components/NullRender.d.ts +1 -0
  17. package/lib/client/components/NullRender.js +10 -0
  18. package/lib/client/components/RadioWithTooltip.d.ts +7 -0
  19. package/lib/client/components/RadioWithTooltip.js +94 -0
  20. package/lib/client/constants.d.ts +10 -8
  21. package/lib/client/constants.js +52 -14
  22. package/lib/client/index.d.ts +0 -1
  23. package/lib/client/index.js +1 -10
  24. package/lib/client/locale/en-US.d.ts +18 -18
  25. package/lib/client/locale/en-US.js +19 -19
  26. package/lib/client/locale/zh-CN.d.ts +47 -20
  27. package/lib/client/locale/zh-CN.js +48 -21
  28. package/lib/client/nodes/calculation.d.ts +39 -7
  29. package/lib/client/nodes/calculation.js +165 -19
  30. package/lib/client/nodes/condition.d.ts +67 -4
  31. package/lib/client/nodes/condition.js +283 -31
  32. package/lib/client/nodes/create.d.ts +10 -10
  33. package/lib/client/nodes/create.js +28 -42
  34. package/lib/client/nodes/delay.d.ts +4 -4
  35. package/lib/client/nodes/delay.js +10 -8
  36. package/lib/client/nodes/destroy.d.ts +4 -7
  37. package/lib/client/nodes/destroy.js +4 -5
  38. package/lib/client/nodes/index.d.ts +10 -2
  39. package/lib/client/nodes/index.js +217 -110
  40. package/lib/client/nodes/manual/AssigneesSelect.d.ts +6 -0
  41. package/lib/client/nodes/manual/AssigneesSelect.js +65 -0
  42. package/lib/client/nodes/manual/ModeConfig.d.ts +5 -0
  43. package/lib/client/nodes/manual/ModeConfig.js +160 -0
  44. package/lib/client/nodes/manual/SchemaConfig.d.ts +6 -0
  45. package/lib/client/nodes/manual/SchemaConfig.js +715 -0
  46. package/lib/client/nodes/manual/WorkflowTodo.d.ts +8 -0
  47. package/lib/client/nodes/manual/WorkflowTodo.js +691 -0
  48. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +5 -0
  49. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +75 -0
  50. package/lib/client/nodes/manual/index.d.ts +62 -0
  51. package/lib/client/nodes/manual/index.js +137 -0
  52. package/lib/client/nodes/parallel.d.ts +12 -7
  53. package/lib/client/nodes/parallel.js +32 -39
  54. package/lib/client/nodes/query.d.ts +11 -19
  55. package/lib/client/nodes/query.js +40 -47
  56. package/lib/client/nodes/request.d.ts +77 -42
  57. package/lib/client/nodes/request.js +123 -69
  58. package/lib/client/nodes/update.d.ts +33 -29
  59. package/lib/client/nodes/update.js +14 -7
  60. package/lib/client/schemas/collection.d.ts +0 -3
  61. package/lib/client/schemas/collection.js +2 -7
  62. package/lib/client/schemas/executions.js +1 -1
  63. package/lib/client/schemas/workflows.js +1 -1
  64. package/lib/client/style.js +51 -9
  65. package/lib/client/triggers/collection.d.ts +44 -15
  66. package/lib/client/triggers/collection.js +104 -82
  67. package/lib/client/triggers/index.d.ts +6 -3
  68. package/lib/client/triggers/index.js +167 -74
  69. package/lib/client/triggers/schedule/DateFieldsSelect.js +1 -3
  70. package/lib/client/triggers/schedule/ScheduleConfig.js +15 -17
  71. package/lib/client/triggers/schedule/index.d.ts +7 -6
  72. package/lib/client/triggers/schedule/index.js +39 -81
  73. package/lib/client/utils.d.ts +1 -0
  74. package/lib/client/utils.js +38 -0
  75. package/lib/client/variable.d.ts +21 -0
  76. package/lib/client/variable.js +147 -0
  77. package/lib/server/Plugin.d.ts +3 -3
  78. package/lib/server/Plugin.js +12 -21
  79. package/lib/server/Processor.d.ts +9 -2
  80. package/lib/server/Processor.js +33 -33
  81. package/lib/server/actions/index.js +2 -4
  82. package/lib/server/actions/workflows.d.ts +1 -0
  83. package/lib/server/actions/workflows.js +80 -23
  84. package/lib/server/collections/executions.js +5 -7
  85. package/lib/server/collections/flow_nodes.js +6 -18
  86. package/lib/server/collections/jobs.js +3 -1
  87. package/lib/server/collections/workflows.js +8 -4
  88. package/lib/server/constants.d.ts +9 -3
  89. package/lib/server/constants.js +11 -5
  90. package/lib/server/functions/index.d.ts +4 -0
  91. package/lib/server/functions/index.js +38 -0
  92. package/lib/server/index.d.ts +0 -1
  93. package/lib/server/index.js +0 -14
  94. package/lib/server/instructions/calculation.d.ts +2 -7
  95. package/lib/server/instructions/calculation.js +32 -37
  96. package/lib/server/instructions/condition.d.ts +4 -4
  97. package/lib/server/instructions/condition.js +126 -54
  98. package/lib/server/instructions/index.js +1 -1
  99. package/lib/server/instructions/manual/actions.js +101 -0
  100. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.d.ts +2 -0
  101. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/jobs.js +2 -1
  102. package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.js +10 -10
  103. package/lib/server/instructions/manual/index.d.ts +25 -0
  104. package/lib/server/instructions/manual/index.js +200 -0
  105. package/lib/server/instructions/parallel.js +11 -7
  106. package/lib/server/instructions/request.d.ts +5 -4
  107. package/lib/server/instructions/request.js +60 -79
  108. package/lib/server/migrations/20230221032941-change-request-body-type.d.ts +5 -0
  109. package/lib/server/migrations/20230221032941-change-request-body-type.js +113 -0
  110. package/lib/server/migrations/20230221071831-calculation-expression.d.ts +4 -0
  111. package/lib/server/migrations/20230221071831-calculation-expression.js +143 -0
  112. package/lib/server/migrations/20230221121203-condition-calculation.d.ts +4 -0
  113. package/lib/server/migrations/20230221121203-condition-calculation.js +126 -0
  114. package/lib/server/migrations/20230221162902-jsonb-to-json.d.ts +4 -0
  115. package/lib/server/migrations/20230221162902-jsonb-to-json.js +81 -0
  116. package/lib/server/triggers/schedule.js +11 -3
  117. package/package.json +10 -10
  118. package/lib/client/calculators.d.ts +0 -89
  119. package/lib/client/calculators.js +0 -668
  120. package/lib/client/components/CollectionFieldSelect.d.ts +0 -2
  121. package/lib/client/components/CollectionFieldSelect.js +0 -106
  122. package/lib/client/components/EjsTextArea.d.ts +0 -2
  123. package/lib/client/components/EjsTextArea.js +0 -232
  124. package/lib/server/actions/jobs.d.ts +0 -2
  125. package/lib/server/actions/jobs.js +0 -39
  126. package/lib/server/calculators/index.d.ts +0 -40
  127. package/lib/server/calculators/index.js +0 -187
  128. package/lib/server/extensions/assignees/actions.js +0 -75
  129. package/lib/server/extensions/assignees/index.d.ts +0 -2
  130. package/lib/server/extensions/assignees/index.js +0 -273
  131. package/lib/server/extensions/index.d.ts +0 -3
  132. package/lib/server/extensions/index.js +0 -13
  133. package/lib/server/instructions/prompt.d.ts +0 -19
  134. package/lib/server/instructions/prompt.js +0 -131
  135. /package/lib/server/{extensions/assignees → instructions/manual}/actions.d.ts +0 -0
  136. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.d.ts +0 -0
  137. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users.js +0 -0
  138. /package/lib/server/{extensions/assignees/collections → instructions/manual/collecions}/users_jobs.d.ts +0 -0
@@ -4,6 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.triggers = exports.TriggerConfig = void 0;
7
+ exports.useTrigger = useTrigger;
8
+
9
+ function _react() {
10
+ const data = _interopRequireWildcard(require("react"));
11
+
12
+ _react = function _react() {
13
+ return data;
14
+ };
15
+
16
+ return data;
17
+ }
7
18
 
8
19
  function _css() {
9
20
  const data = require("@emotion/css");
@@ -15,10 +26,10 @@ function _css() {
15
26
  return data;
16
27
  }
17
28
 
18
- function _react() {
29
+ function _react2() {
19
30
  const data = require("@formily/react");
20
31
 
21
- _react = function _react() {
32
+ _react2 = function _react2() {
22
33
  return data;
23
34
  };
24
35
 
@@ -45,26 +56,6 @@ function _antd() {
45
56
  return data;
46
57
  }
47
58
 
48
- function _react2() {
49
- const data = _interopRequireDefault(require("react"));
50
-
51
- _react2 = function _react2() {
52
- return data;
53
- };
54
-
55
- return data;
56
- }
57
-
58
- function _reactI18next() {
59
- const data = require("react-i18next");
60
-
61
- _reactI18next = function _reactI18next() {
62
- return data;
63
- };
64
-
65
- return data;
66
- }
67
-
68
59
  function _icons() {
69
60
  const data = require("@ant-design/icons");
70
61
 
@@ -97,6 +88,28 @@ var _locale = require("../locale");
97
88
 
98
89
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
99
90
 
91
+ 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); }
92
+
93
+ 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; }
94
+
95
+ 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; }
96
+
97
+ 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; }
98
+
99
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
100
+
101
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
102
+
103
+ 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."); }
104
+
105
+ 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); }
106
+
107
+ 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; }
108
+
109
+ 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; }
110
+
111
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
112
+
100
113
  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); } }
101
114
 
102
115
  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); }); }; }
@@ -104,10 +117,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
104
117
  function useUpdateConfigAction() {
105
118
  var _useFlowContext;
106
119
 
107
- const _useTranslation = (0, _reactI18next().useTranslation)(),
108
- t = _useTranslation.t;
109
-
110
- const form = (0, _react().useForm)();
120
+ const form = (0, _react2().useForm)();
111
121
  const api = (0, _client2().useAPIClient)();
112
122
 
113
123
  const _ref = (_useFlowContext = (0, _FlowContext.useFlowContext)()) !== null && _useFlowContext !== void 0 ? _useFlowContext : {},
@@ -124,7 +134,7 @@ function useUpdateConfigAction() {
124
134
  var _api$resource$update, _api$resource;
125
135
 
126
136
  if (workflow.executed) {
127
- _antd().message.error(t('Trigger in executed workflow cannot be modified'));
137
+ _antd().message.error((0, _locale.lang)('Trigger in executed workflow cannot be modified'));
128
138
 
129
139
  return;
130
140
  }
@@ -132,7 +142,9 @@ function useUpdateConfigAction() {
132
142
  yield form.submit();
133
143
  yield (_api$resource$update = (_api$resource = api.resource('workflows')).update) === null || _api$resource$update === void 0 ? void 0 : _api$resource$update.call(_api$resource, {
134
144
  filterByTk: workflow.id,
135
- values: form.values
145
+ values: {
146
+ config: form.values
147
+ }
136
148
  });
137
149
  ctx.setVisible(false);
138
150
  refresh();
@@ -161,13 +173,13 @@ function TriggerExecution() {
161
173
  }
162
174
 
163
175
  const trigger = triggers.get(workflow.type);
164
- return _react2().default.createElement(_client2().SchemaComponent, {
176
+ return _react().default.createElement(_client2().SchemaComponent, {
165
177
  schema: {
166
178
  type: 'void',
167
179
  name: 'execution',
168
180
  'x-component': 'Action',
169
181
  'x-component-props': {
170
- title: _react2().default.createElement(_icons().InfoOutlined, null),
182
+ title: _react().default.createElement(_icons().InfoOutlined, null),
171
183
  shape: 'circle',
172
184
  className: 'workflow-node-job-button',
173
185
  type: 'primary'
@@ -180,9 +192,9 @@ function TriggerExecution() {
180
192
  initialValue: execution
181
193
  },
182
194
  'x-component': 'Action.Modal',
183
- title: _react2().default.createElement("div", {
195
+ title: _react().default.createElement("div", {
184
196
  className: (0, _css().cx)(_style.nodeTitleClass)
185
- }, _react2().default.createElement(_antd().Tag, null, compile(trigger.title)), _react2().default.createElement("strong", null, workflow.title), _react2().default.createElement("span", {
197
+ }, _react().default.createElement(_antd().Tag, null, compile(trigger.title)), _react().default.createElement("strong", null, workflow.title), _react().default.createElement("span", {
186
198
  className: "workflow-node-id"
187
199
  }, "#", execution.id)),
188
200
  properties: {
@@ -217,87 +229,161 @@ function TriggerExecution() {
217
229
  }
218
230
 
219
231
  const TriggerConfig = () => {
220
- const _useTranslation2 = (0, _reactI18next().useTranslation)(),
221
- t = _useTranslation2.t;
222
-
232
+ const api = (0, _client2().useAPIClient)();
223
233
  const compile = (0, _client2().useCompile)();
224
234
 
225
235
  const _useFlowContext3 = (0, _FlowContext.useFlowContext)(),
226
- workflow = _useFlowContext3.workflow;
236
+ workflow = _useFlowContext3.workflow,
237
+ refresh = _useFlowContext3.refresh;
227
238
 
228
239
  if (!workflow || !workflow.type) {
229
240
  return null;
230
241
  }
231
242
 
232
- const type = workflow.type,
243
+ const title = workflow.title,
244
+ type = workflow.type,
233
245
  config = workflow.config,
234
246
  executed = workflow.executed;
235
247
 
236
248
  const _triggers$get = triggers.get(type),
237
- title = _triggers$get.title,
249
+ typeTitle = _triggers$get.title,
238
250
  fieldset = _triggers$get.fieldset,
239
251
  scope = _triggers$get.scope,
240
252
  components = _triggers$get.components;
241
253
 
242
254
  const detailText = executed ? '{{t("View")}}' : '{{t("Configure")}}';
243
- const titleText = `${(0, _locale.lang)('Trigger')}: ${compile(title)}`;
244
- return _react2().default.createElement("div", {
245
- className: (0, _css().cx)(_style.nodeCardClass)
246
- }, _react2().default.createElement("div", {
247
- className: (0, _css().cx)(_style.nodeHeaderClass)
248
- }, _react2().default.createElement("div", {
249
- className: (0, _css().cx)(_style.nodeMetaClass)
250
- }, _react2().default.createElement(_antd().Tag, {
255
+ const titleText = `${(0, _locale.lang)('Trigger')}: ${compile(typeTitle)}`;
256
+
257
+ const _useState = (0, _react().useState)(title !== null && title !== void 0 ? title : typeTitle),
258
+ _useState2 = _slicedToArray(_useState, 2),
259
+ editingTitle = _useState2[0],
260
+ setEditingTitle = _useState2[1];
261
+
262
+ const _useState3 = (0, _react().useState)(false),
263
+ _useState4 = _slicedToArray(_useState3, 2),
264
+ editingConfig = _useState4[0],
265
+ setEditingConfig = _useState4[1];
266
+
267
+ function onChangeTitle(_x) {
268
+ return _onChangeTitle.apply(this, arguments);
269
+ }
270
+
271
+ function _onChangeTitle() {
272
+ _onChangeTitle = _asyncToGenerator(function* (next) {
273
+ var _api$resource$update2, _api$resource2;
274
+
275
+ const t = next || typeTitle;
276
+ setEditingTitle(t);
277
+
278
+ if (t === title) {
279
+ return;
280
+ }
281
+
282
+ yield (_api$resource$update2 = (_api$resource2 = api.resource('workflows')).update) === null || _api$resource$update2 === void 0 ? void 0 : _api$resource$update2.call(_api$resource2, {
283
+ filterByTk: workflow.id,
284
+ values: {
285
+ title: t
286
+ }
287
+ });
288
+ refresh();
289
+ });
290
+ return _onChangeTitle.apply(this, arguments);
291
+ }
292
+
293
+ function onOpenDrawer(ev) {
294
+ if (ev.target === ev.currentTarget) {
295
+ setEditingConfig(true);
296
+ return;
297
+ }
298
+
299
+ const whiteSet = new Set(['workflow-node-meta', 'workflow-node-config-button', 'ant-input-disabled']);
300
+
301
+ for (let el = ev.target; el && el !== ev.currentTarget; el = el.parentNode) {
302
+ if (Array.from(el.classList).some(name => whiteSet.has(name))) {
303
+ setEditingConfig(true);
304
+ ev.stopPropagation();
305
+ return;
306
+ }
307
+ }
308
+ }
309
+
310
+ return _react().default.createElement("div", {
311
+ className: (0, _css().cx)(_style.nodeCardClass),
312
+ onClick: onOpenDrawer
313
+ }, _react().default.createElement("div", {
314
+ className: (0, _css().cx)(_style.nodeMetaClass, 'workflow-node-meta')
315
+ }, _react().default.createElement(_antd().Tag, {
251
316
  color: "gold"
252
- }, (0, _locale.lang)('Trigger'))), _react2().default.createElement("h4", null, compile(title)), _react2().default.createElement(TriggerExecution, null)), _react2().default.createElement(_client2().SchemaComponent, {
317
+ }, titleText)), _react().default.createElement("div", null, _react().default.createElement(_antd().Input.TextArea, {
318
+ value: editingTitle,
319
+ onChange: ev => setEditingTitle(ev.target.value),
320
+ onBlur: ev => onChangeTitle(ev.target.value),
321
+ autoSize: true
322
+ })), _react().default.createElement(TriggerExecution, null), _react().default.createElement(_client2().ActionContext.Provider, {
323
+ value: {
324
+ visible: editingConfig,
325
+ setVisible: setEditingConfig
326
+ }
327
+ }, _react().default.createElement(_client2().SchemaComponent, {
253
328
  schema: {
254
329
  type: 'void',
255
- title: detailText,
256
- 'x-component': 'Action.Link',
257
- name: 'drawer',
258
330
  properties: {
331
+ config: {
332
+ type: 'void',
333
+ 'x-content': detailText,
334
+ 'x-component': _antd().Button,
335
+ 'x-component-props': {
336
+ type: 'link',
337
+ className: 'workflow-node-config-button'
338
+ }
339
+ },
259
340
  drawer: {
260
341
  type: 'void',
261
342
  title: titleText,
262
343
  'x-component': 'Action.Drawer',
263
344
  'x-decorator': 'Form',
264
345
  'x-decorator-props': {
346
+ disabled: workflow.executed,
347
+
265
348
  useValues(options) {
266
349
  return (0, _client2().useRequest)(() => Promise.resolve({
267
- data: {
268
- config
269
- }
350
+ data: config
270
351
  }), options);
271
352
  }
272
353
 
273
354
  },
274
- properties: {
275
- config: {
355
+ properties: _objectSpread(_objectSpread({}, executed ? {
356
+ alert: {
357
+ 'x-component': _antd().Alert,
358
+ 'x-component-props': {
359
+ type: 'warning',
360
+ showIcon: true,
361
+ message: `{{t("Trigger in executed workflow cannot be modified", { ns: "${_locale.NAMESPACE}" })}}`,
362
+ className: (0, _css().css)`
363
+ width: 100%;
364
+ font-size: 85%;
365
+ margin-bottom: 2em;
366
+ `
367
+ }
368
+ }
369
+ } : {}), {}, {
370
+ fieldset: {
276
371
  type: 'void',
277
- name: 'config',
278
372
  'x-component': 'fieldset',
279
373
  'x-component-props': {
280
374
  className: (0, _css().css)`
281
- .ant-select{
282
- width: auto;
283
- min-width: 6em;
284
- }
285
- `
375
+ .ant-select{
376
+ width: auto;
377
+ min-width: 6em;
378
+ }
379
+ `
286
380
  },
287
381
  properties: fieldset
288
382
  },
289
- actions: {
383
+ actions: executed ? null : {
290
384
  type: 'void',
291
385
  'x-component': 'Action.Drawer.Footer',
292
- properties: executed ? {
293
- close: {
294
- title: '{{t("Close")}}',
295
- 'x-component': 'Action',
296
- 'x-component-props': {
297
- useAction: '{{ cm.useCancelAction }}'
298
- }
299
- }
300
- } : {
386
+ properties: {
301
387
  cancel: {
302
388
  title: '{{t("Cancel")}}',
303
389
  'x-component': 'Action',
@@ -315,13 +401,20 @@ const TriggerConfig = () => {
315
401
  }
316
402
  }
317
403
  }
318
- }
404
+ })
319
405
  }
320
406
  }
321
407
  },
322
408
  scope: scope,
323
409
  components: components
324
- }));
410
+ })));
325
411
  };
326
412
 
327
- exports.TriggerConfig = TriggerConfig;
413
+ exports.TriggerConfig = TriggerConfig;
414
+
415
+ function useTrigger() {
416
+ const _useFlowContext4 = (0, _FlowContext.useFlowContext)(),
417
+ workflow = _useFlowContext4.workflow;
418
+
419
+ return triggers.get(workflow.type);
420
+ }
@@ -64,8 +64,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
64
64
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
65
65
 
66
66
  const DateFieldsSelect = (0, _react2().observer)(props => {
67
- var _values$config;
68
-
69
67
  const _useTranslation = (0, _reactI18next().useTranslation)(),
70
68
  t = _useTranslation.t;
71
69
 
@@ -77,7 +75,7 @@ const DateFieldsSelect = (0, _react2().observer)(props => {
77
75
  const _useForm = (0, _react2().useForm)(),
78
76
  values = _useForm.values;
79
77
 
80
- const fields = getCollectionFields(values === null || values === void 0 ? void 0 : (_values$config = values.config) === null || _values$config === void 0 ? void 0 : _values$config.collection);
78
+ const fields = getCollectionFields(values === null || values === void 0 ? void 0 : values.collection);
81
79
  return _react().default.createElement(_antd().Select, _objectSpread({
82
80
  placeholder: t('Select Field')
83
81
  }, props), fields.filter(field => !field.hidden && (field.uiSchema ? field.type === 'date' : false)).map(field => {
@@ -109,14 +109,14 @@ const ModeFieldsets = {
109
109
  'x-decorator': 'FormItem',
110
110
  'x-component': 'RepeatField',
111
111
  'x-reactions': [{
112
- target: 'config.endsOn',
112
+ target: 'endsOn',
113
113
  fulfill: {
114
114
  state: {
115
115
  visible: '{{!!$self.value}}'
116
116
  }
117
117
  }
118
118
  }, {
119
- target: 'config.limit',
119
+ target: 'limit',
120
120
  fulfill: {
121
121
  state: {
122
122
  visible: '{{!!$self.value}}'
@@ -150,7 +150,7 @@ const ModeFieldsets = {
150
150
  collection: _objectSpread(_objectSpread({}, _collection.collection), {}, {
151
151
  'x-reactions': [..._collection.collection['x-reactions'], {
152
152
  // only full path works
153
- target: 'config.startsOn',
153
+ target: 'startsOn',
154
154
  fulfill: {
155
155
  state: {
156
156
  visible: '{{!!$self.value}}'
@@ -164,7 +164,7 @@ const ModeFieldsets = {
164
164
  'x-decorator': 'FormItem',
165
165
  'x-component': 'OnField',
166
166
  'x-reactions': [{
167
- target: 'config.repeat',
167
+ target: 'repeat',
168
168
  fulfill: {
169
169
  state: {
170
170
  visible: '{{!!$self.value}}'
@@ -180,14 +180,14 @@ const ModeFieldsets = {
180
180
  'x-decorator': 'FormItem',
181
181
  'x-component': 'RepeatField',
182
182
  'x-reactions': [{
183
- target: 'config.endsOn',
183
+ target: 'endsOn',
184
184
  fulfill: {
185
185
  state: {
186
186
  visible: '{{!!$self.value}}'
187
187
  }
188
188
  }
189
189
  }, {
190
- target: 'config.limit',
190
+ target: 'limit',
191
191
  fulfill: {
192
192
  state: {
193
193
  visible: '{{!!$self.value}}'
@@ -228,22 +228,19 @@ const ScheduleConfig = () => {
228
228
  values = _useForm$values === void 0 ? {} : _useForm$values,
229
229
  clearFormGraph = _useForm.clearFormGraph;
230
230
 
231
- const _values$config = values.config,
232
- config = _values$config === void 0 ? {} : _values$config;
233
-
234
- const _useState = (0, _react().useState)(config.mode),
231
+ const _useState = (0, _react().useState)(values.mode),
235
232
  _useState2 = _slicedToArray(_useState, 2),
236
233
  mode = _useState2[0],
237
234
  setMode = _useState2[1];
238
235
 
239
236
  (0, _react2().useFormEffects)(() => {
240
- (0, _core().onFieldValueChange)('config.mode', field => {
237
+ (0, _core().onFieldValueChange)('mode', field => {
241
238
  setMode(field.value);
242
- clearFormGraph('config.collection');
243
- clearFormGraph('config.startsOn');
244
- clearFormGraph('config.repeat');
245
- clearFormGraph('config.endsOn');
246
- clearFormGraph('config.limit');
239
+ clearFormGraph('collection');
240
+ clearFormGraph('startsOn');
241
+ clearFormGraph('repeat');
242
+ clearFormGraph('endsOn');
243
+ clearFormGraph('limit');
247
244
  });
248
245
  });
249
246
  return _react().default.createElement(_react().default.Fragment, null, _react().default.createElement(_client().SchemaComponent, {
@@ -256,7 +253,8 @@ const ScheduleConfig = () => {
256
253
  'x-component-props': {
257
254
  options: scheduleModeOptions
258
255
  },
259
- required: true
256
+ required: true,
257
+ default: _constants.SCHEDULE_MODE.STATIC
260
258
  }
261
259
  }), _react().default.createElement(_client().SchemaComponent, {
262
260
  schema: {
@@ -1,11 +1,11 @@
1
- import { useCollectionDataSource } from '@nocobase/client';
1
+ import { useCollectionDataSource, SchemaInitializerItemOptions } from '@nocobase/client';
2
+ import { CollectionFieldInitializers } from '../../components/CollectionFieldInitializers';
2
3
  declare const _default: {
3
4
  title: string;
4
5
  type: string;
5
6
  fieldset: {
6
7
  config: {
7
8
  type: string;
8
- name: string;
9
9
  'x-component': string;
10
10
  'x-component-props': {};
11
11
  };
@@ -16,9 +16,10 @@ declare const _default: {
16
16
  components: {
17
17
  ScheduleConfig: () => JSX.Element;
18
18
  };
19
- getOptions(config: any): any[];
20
- getter({ onChange }: {
21
- onChange: any;
22
- }): JSX.Element;
19
+ getOptions(config: any, types: any): any[];
20
+ useInitializers(config: any): SchemaInitializerItemOptions | null;
21
+ initializers: {
22
+ CollectionFieldInitializers: typeof CollectionFieldInitializers;
23
+ };
23
24
  };
24
25
  export default _default;
@@ -5,26 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- function _react() {
9
- const data = _interopRequireDefault(require("react"));
10
-
11
- _react = function _react() {
12
- return data;
13
- };
14
-
15
- return data;
16
- }
17
-
18
- function _antd() {
19
- const data = require("antd");
20
-
21
- _antd = function _antd() {
22
- return data;
23
- };
24
-
25
- return data;
26
- }
27
-
28
8
  function _client() {
29
9
  const data = require("@nocobase/client");
30
10
 
@@ -37,23 +17,22 @@ function _client() {
37
17
 
38
18
  var _ScheduleConfig = require("./ScheduleConfig");
39
19
 
40
- var _FlowContext = require("../../FlowContext");
41
-
42
- var _calculators = require("../../calculators");
43
-
44
20
  var _constants = require("./constants");
45
21
 
46
22
  var _locale = require("../../locale");
47
23
 
48
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ var _CollectionFieldInitializers = require("../../components/CollectionFieldInitializers");
25
+
26
+ var _CollectionBlockInitializer = require("../../components/CollectionBlockInitializer");
27
+
28
+ var _variable = require("../../variable");
49
29
 
50
30
  var _default = {
51
31
  title: `{{t("Schedule event", { ns: "${_locale.NAMESPACE}" })}}`,
52
32
  type: 'schedule',
53
33
  fieldset: {
54
34
  config: {
55
- type: 'object',
56
- name: 'config',
35
+ type: 'void',
57
36
  'x-component': 'ScheduleConfig',
58
37
  'x-component-props': {}
59
38
  }
@@ -65,75 +44,54 @@ var _default = {
65
44
  ScheduleConfig: _ScheduleConfig.ScheduleConfig
66
45
  },
67
46
 
68
- getOptions(config) {
47
+ getOptions(config, types) {
69
48
  const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
70
49
  t = _useWorkflowTranslati.t;
71
50
 
72
- const options = [{
73
- value: 'date',
74
- label: t('Trigger time')
75
- }];
51
+ const options = [];
76
52
 
77
- if (config.mode === _constants.SCHEDULE_MODE.COLLECTION_FIELD) {
53
+ if (!types || types.includes('date')) {
78
54
  options.push({
79
- value: 'data',
80
- label: t('Trigger data')
55
+ key: 'date',
56
+ value: 'date',
57
+ label: t('Trigger time')
81
58
  });
82
59
  }
83
60
 
84
- return options;
85
- },
86
-
87
- getter({
88
- onChange: _onChange
89
- }) {
90
- var _collections$find;
91
-
92
- const _useWorkflowTranslati2 = (0, _locale.useWorkflowTranslation)(),
93
- t = _useWorkflowTranslati2.t;
94
-
95
- const compile = (0, _client().useCompile)();
96
-
97
- const _useCollectionManager = (0, _client().useCollectionManager)(),
98
- _useCollectionManager2 = _useCollectionManager.collections,
99
- collections = _useCollectionManager2 === void 0 ? [] : _useCollectionManager2;
100
-
101
- const _useFlowContext = (0, _FlowContext.useFlowContext)(),
102
- workflow = _useFlowContext.workflow;
61
+ if (config.mode === _constants.SCHEDULE_MODE.COLLECTION_FIELD) {
62
+ const fieldOptions = (0, _variable.useCollectionFieldOptions)({
63
+ collection: config.collection
64
+ });
103
65
 
104
- const _useOperandContext = (0, _calculators.useOperandContext)(),
105
- options = _useOperandContext.options;
66
+ if (fieldOptions.length) {
67
+ options.push({
68
+ key: 'data',
69
+ value: 'data',
70
+ label: t('Trigger data'),
71
+ children: fieldOptions
72
+ });
73
+ }
74
+ }
106
75
 
107
- const path = (options === null || options === void 0 ? void 0 : options.path) ? options.path.split('.') : [];
76
+ return options;
77
+ },
108
78
 
109
- if (!options.type || options.type === 'date') {
79
+ useInitializers(config) {
80
+ if (!config.collection) {
110
81
  return null;
111
82
  }
112
83
 
113
- const collection = (_collections$find = collections.find(item => item.name === workflow.config.collection)) !== null && _collections$find !== void 0 ? _collections$find : {
114
- fields: []
84
+ return {
85
+ type: 'item',
86
+ title: `{{t("Trigger data", { ns: "${_locale.NAMESPACE}" })}}`,
87
+ component: _CollectionBlockInitializer.CollectionBlockInitializer,
88
+ collection: config.collection,
89
+ dataSource: '{{$context.data}}'
115
90
  };
116
- return _react().default.createElement(_antd().Cascader, {
117
- placeholder: t('Trigger data'),
118
- value: path,
119
- options: collection.fields.filter(field => {
120
- var _field$uiSchema;
121
-
122
- return _calculators.BaseTypeSet.has(field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.type);
123
- }).map(field => {
124
- var _field$uiSchema2;
125
-
126
- return {
127
- value: field.name,
128
- label: compile((_field$uiSchema2 = field.uiSchema) === null || _field$uiSchema2 === void 0 ? void 0 : _field$uiSchema2.title)
129
- };
130
- }),
131
- onChange: next => {
132
- _onChange(`{{$context.${next.join('.')}}}`);
133
- },
134
- allowClear: false
135
- });
136
- }
91
+ },
137
92
 
93
+ initializers: {
94
+ CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
95
+ }
138
96
  };
139
97
  exports.default = _default;
@@ -0,0 +1 @@
1
+ export declare function linkNodes(nodes: any): void;