@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
@@ -16,10 +16,6 @@ function _css() {
16
16
  }
17
17
 
18
18
  const workflowPageClass = (0, _css().css)`
19
- height: 100%;
20
- width: 100%;
21
- overflow: auto;
22
-
23
19
  .workflow-toolbar{
24
20
  display: flex;
25
21
  align-items: center;
@@ -176,19 +172,27 @@ const nodeClass = (0, _css().css)`
176
172
  `;
177
173
  exports.nodeClass = nodeClass;
178
174
  const nodeCardClass = (0, _css().css)`
175
+ position: relative;
179
176
  width: 20em;
180
177
  background: #fff;
181
178
  padding: 1em;
182
179
  box-shadow: 0 .25em .5em rgba(0, 0, 0, .1);
180
+ border-radius: .5em;
181
+ cursor: pointer;
182
+ transition: box-shadow .3s ease;
183
+
184
+ &.configuring{
185
+ box-shadow: 0 .25em 1em rgba(0, 100, 200, .25);
186
+ }
183
187
 
184
188
  .workflow-node-remove-button,
185
189
  .workflow-node-job-button{
186
190
  position: absolute;
187
- right: -.5em;
188
- top: -.5em;
189
191
  }
190
192
 
191
193
  .workflow-node-remove-button{
194
+ right: .5em;
195
+ top: .5em;
192
196
  color: #999;
193
197
  opacity: 0;
194
198
  transition: opacity .3s ease;
@@ -204,8 +208,8 @@ const nodeCardClass = (0, _css().css)`
204
208
 
205
209
  .workflow-node-job-button{
206
210
  display: flex;
207
- top: 0;
208
- right: 0;
211
+ top: 1em;
212
+ right: 1em;
209
213
  width: 1.25rem;
210
214
  height: 1.25rem;
211
215
  min-width: 1.25rem;
@@ -219,7 +223,32 @@ const nodeCardClass = (0, _css().css)`
219
223
  }
220
224
  }
221
225
 
226
+ .ant-input{
227
+ font-weight: bold;
228
+
229
+ &:not(:focus){
230
+ transition: background-color .3s ease, border-color .3s ease;
231
+ border-color: #f7f7f7;
232
+ background-color: #f7f7f7;
233
+
234
+ &:not(:disabled):hover{
235
+ border-color: #eee;
236
+ background-color: #eee;
237
+ }
238
+
239
+ &:disabled:hover{
240
+ border-color: #f7f7f7;
241
+ }
242
+ }
243
+ }
244
+
245
+ .workflow-node-config-button{
246
+ padding: 0;
247
+ }
248
+
222
249
  &:hover{
250
+ box-shadow: 0 .25em .5em rgba(0, 0, 0, .25);
251
+
223
252
  .workflow-node-remove-button{
224
253
  opacity: 1;
225
254
  }
@@ -232,13 +261,20 @@ const nodeHeaderClass = (0, _css().css)`
232
261
  exports.nodeHeaderClass = nodeHeaderClass;
233
262
  const nodeMetaClass = (0, _css().css)`
234
263
  margin-bottom: .5em;
264
+
265
+ .workflow-node-id{
266
+ color: #999;
267
+
268
+ &:before{
269
+ content: "#"
270
+ }
271
+ }
235
272
  `;
236
273
  exports.nodeMetaClass = nodeMetaClass;
237
274
  const nodeTitleClass = (0, _css().css)`
238
275
  display: flex;
239
276
  align-items: center;
240
277
  font-weight: normal;
241
-
242
278
  .workflow-node-id{
243
279
  color: #999;
244
280
  }
@@ -253,5 +289,11 @@ exports.nodeSubtreeClass = nodeSubtreeClass;
253
289
  const addButtonClass = (0, _css().css)`
254
290
  flex-shrink: 0;
255
291
  padding: 2em 0;
292
+
293
+ > .ant-btn{
294
+ &:disabled{
295
+ visibility: hidden;
296
+ }
297
+ }
256
298
  `;
257
299
  exports.addButtonClass = addButtonClass;
@@ -1,21 +1,22 @@
1
1
  import React from 'react';
2
- import { useCollectionDataSource } from '@nocobase/client';
2
+ import { SchemaInitializerItemOptions, useCollectionDataSource } from '@nocobase/client';
3
+ import { CollectionFieldInitializers } from '../components/CollectionFieldInitializers';
3
4
  declare const _default: {
4
5
  title: string;
5
6
  type: string;
6
7
  fieldset: {
7
- 'config.collection': {
8
+ collection: {
8
9
  "x-reactions": (string | {
9
10
  target: string;
11
+ effects: string[];
10
12
  fulfill: {
11
13
  state: {
12
- visible: string;
14
+ value: any[];
13
15
  };
14
16
  };
15
17
  })[];
16
18
  type: string;
17
19
  title: string;
18
- name: string;
19
20
  required: boolean;
20
21
  'x-decorator': string;
21
22
  'x-component': string;
@@ -23,10 +24,9 @@ declare const _default: {
23
24
  placeholder: string;
24
25
  };
25
26
  };
26
- 'config.mode': {
27
+ mode: {
27
28
  type: string;
28
29
  title: string;
29
- name: string;
30
30
  'x-decorator': string;
31
31
  'x-component': string;
32
32
  'x-component-props': {
@@ -37,18 +37,28 @@ declare const _default: {
37
37
  placeholder: string;
38
38
  };
39
39
  required: boolean;
40
- 'x-reactions': {
40
+ 'x-reactions': ({
41
+ dependencies: string[];
42
+ fulfill: {
43
+ state: {
44
+ visible: string;
45
+ disabled?: undefined;
46
+ };
47
+ };
48
+ target?: undefined;
49
+ } | {
41
50
  target: string;
42
51
  fulfill: {
43
52
  state: {
44
53
  disabled: string;
54
+ visible?: undefined;
45
55
  };
46
56
  };
47
- }[];
57
+ dependencies?: undefined;
58
+ })[];
48
59
  };
49
- 'config.changed': {
60
+ changed: {
50
61
  type: string;
51
- name: string;
52
62
  title: string;
53
63
  description: string;
54
64
  'x-decorator': string;
@@ -56,11 +66,27 @@ declare const _default: {
56
66
  'x-component-props': {
57
67
  mode: string;
58
68
  placeholder: string;
69
+ filter(field: any): boolean;
59
70
  };
71
+ 'x-reactions': {
72
+ dependencies: string[];
73
+ fulfill: {
74
+ state: {
75
+ visible: string;
76
+ };
77
+ };
78
+ }[];
60
79
  };
61
- 'config.condition': {
62
- name: string;
80
+ condition: {
63
81
  title: string;
82
+ 'x-reactions': {
83
+ dependencies: string[];
84
+ fulfill: {
85
+ state: {
86
+ visible: string;
87
+ };
88
+ };
89
+ }[];
64
90
  type: string;
65
91
  'x-decorator': string;
66
92
  'x-decorator-props': {
@@ -81,9 +107,12 @@ declare const _default: {
81
107
  useCollectionDataSource: typeof useCollectionDataSource;
82
108
  };
83
109
  components: {
84
- FieldsSelect: React.MemoExoticComponent<React.FunctionComponent<unknown>>;
110
+ FieldsSelect: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
111
+ };
112
+ getOptions(config: any, types: any): any[];
113
+ useInitializers(config: any): SchemaInitializerItemOptions | null;
114
+ initializers: {
115
+ CollectionFieldInitializers: typeof CollectionFieldInitializers;
85
116
  };
86
- getOptions(config: any): any[];
87
- getter(props: any): JSX.Element;
88
117
  };
89
118
  export default _default;
@@ -45,35 +45,17 @@ function _client() {
45
45
  return data;
46
46
  }
47
47
 
48
- var _FlowContext = require("../FlowContext");
49
-
50
48
  var _collection = require("../schemas/collection");
51
49
 
52
- function _css() {
53
- const data = require("@emotion/css");
54
-
55
- _css = function _css() {
56
- return data;
57
- };
58
-
59
- return data;
60
- }
50
+ var _variable = require("../variable");
61
51
 
62
- function _core() {
63
- const data = require("@formily/core");
64
-
65
- _core = function _core() {
66
- return data;
67
- };
68
-
69
- return data;
70
- }
52
+ var _CollectionBlockInitializer = require("../components/CollectionBlockInitializer");
71
53
 
72
- var _CollectionFieldSelect = _interopRequireDefault(require("../components/CollectionFieldSelect"));
54
+ var _CollectionFieldInitializers = require("../components/CollectionFieldInitializers");
73
55
 
74
56
  var _locale = require("../locale");
75
57
 
76
- var _calculators = require("../calculators");
58
+ const _excluded = ["filter"];
77
59
 
78
60
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
79
61
 
@@ -83,8 +65,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
83
65
 
84
66
  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; }
85
67
 
68
+ 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; }
69
+
70
+ 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; }
71
+
86
72
  const FieldsSelect = (0, _react2().observer)(props => {
87
- var _values$config;
73
+ const _props$filter = props.filter,
74
+ filter = _props$filter === void 0 ? () => true : _props$filter,
75
+ others = _objectWithoutProperties(props, _excluded);
88
76
 
89
77
  const compile = (0, _client().useCompile)();
90
78
 
@@ -92,22 +80,10 @@ const FieldsSelect = (0, _react2().observer)(props => {
92
80
  getCollectionFields = _useCollectionManager.getCollectionFields;
93
81
 
94
82
  const _useForm = (0, _react2().useForm)(),
95
- values = _useForm.values,
96
- clearFormGraph = _useForm.clearFormGraph,
97
- setValuesIn = _useForm.setValuesIn;
98
-
99
- const fields = getCollectionFields(values === null || values === void 0 ? void 0 : (_values$config = values.config) === null || _values$config === void 0 ? void 0 : _values$config.collection);
100
- (0, _react2().useFormEffects)(() => {
101
- (0, _core().onFieldValueChange)('config.collection', field => {
102
- clearFormGraph('config.changed');
103
- setValuesIn('config.condition', null);
104
- });
105
- });
106
- return _react().default.createElement(_antd().Select, _objectSpread(_objectSpread({}, props), {}, {
107
- className: (0, _css().css)`
108
- min-width: 6em;
109
- `
110
- }), fields.filter(field => !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : true) && !['linkTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type)).map(field => {
83
+ values = _useForm.values;
84
+
85
+ const fields = getCollectionFields(values === null || values === void 0 ? void 0 : values.collection);
86
+ return _react().default.createElement(_antd().Select, _objectSpread({}, others), fields.filter(filter).map(field => {
111
87
  var _field$uiSchema;
112
88
 
113
89
  return _react().default.createElement(_antd().Select.Option, {
@@ -139,34 +115,28 @@ var _default = {
139
115
  title: `{{t("Collection event", { ns: "${_locale.NAMESPACE}" })}}`,
140
116
  type: 'collection',
141
117
  fieldset: {
142
- 'config.collection': _objectSpread(_objectSpread({}, _collection.collection), {}, {
118
+ collection: _objectSpread(_objectSpread({}, _collection.collection), {}, {
143
119
  ['x-reactions']: [..._collection.collection['x-reactions'], {
144
- target: 'config.mode',
145
- fulfill: {
146
- state: {
147
- visible: '{{!!$self.value}}'
148
- }
149
- }
150
- }, {
151
- target: 'config.changed',
120
+ target: 'changed',
121
+ effects: ['onFieldValueChange'],
152
122
  fulfill: {
153
123
  state: {
154
- visible: '{{!!$self.value}}'
124
+ value: []
155
125
  }
156
126
  }
157
127
  }, {
158
- target: 'config.condition',
128
+ target: 'condition',
129
+ effects: ['onFieldValueChange'],
159
130
  fulfill: {
160
131
  state: {
161
- visible: '{{!!$self.value}}'
132
+ value: null
162
133
  }
163
134
  }
164
135
  }]
165
136
  }),
166
- 'config.mode': {
137
+ mode: {
167
138
  type: 'number',
168
139
  title: `{{t("Trigger on", { ns: "${_locale.NAMESPACE}" })}}`,
169
- name: 'config.mode',
170
140
  'x-decorator': 'FormItem',
171
141
  'x-component': 'Select',
172
142
  'x-component-props': {
@@ -175,7 +145,14 @@ var _default = {
175
145
  },
176
146
  required: true,
177
147
  'x-reactions': [{
178
- target: 'config.changed',
148
+ dependencies: ['collection'],
149
+ fulfill: {
150
+ state: {
151
+ visible: '{{!!$deps[0]}}'
152
+ }
153
+ }
154
+ }, {
155
+ target: 'changed',
179
156
  fulfill: {
180
157
  state: {
181
158
  disabled: `{{!($self.value & ${COLLECTION_TRIGGER_MODE.UPDATED})}}`
@@ -183,22 +160,62 @@ var _default = {
183
160
  }
184
161
  }]
185
162
  },
186
- 'config.changed': {
163
+ changed: {
187
164
  type: 'array',
188
- name: 'changed',
189
165
  title: `{{t("Changed fields", { ns: "${_locale.NAMESPACE}" })}}`,
190
166
  description: `{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${_locale.NAMESPACE}" })}}`,
191
167
  'x-decorator': 'FormItem',
192
168
  'x-component': 'FieldsSelect',
193
169
  'x-component-props': {
194
170
  mode: 'multiple',
195
- placeholder: '{{t("Select Field")}}'
196
- }
171
+ placeholder: '{{t("Select Field")}}',
172
+
173
+ filter(field) {
174
+ return !field.hidden && (field.uiSchema ? !field.uiSchema['x-read-pretty'] : true) && !['linkTo', 'hasOne', 'hasMany', 'belongsToMany'].includes(field.type);
175
+ }
176
+
177
+ },
178
+ 'x-reactions': [{
179
+ dependencies: ['collection'],
180
+ fulfill: {
181
+ state: {
182
+ visible: '{{!!$deps[0]}}'
183
+ }
184
+ }
185
+ }]
197
186
  },
198
- 'config.condition': _objectSpread(_objectSpread({}, _collection.filter), {}, {
199
- name: 'config.condition',
200
- title: `{{t("Only triggers when match conditions", { ns: "${_locale.NAMESPACE}" })}}`
201
- })
187
+ condition: _objectSpread(_objectSpread({}, _collection.filter), {}, {
188
+ title: `{{t("Only triggers when match conditions", { ns: "${_locale.NAMESPACE}" })}}`,
189
+ 'x-reactions': [{
190
+ dependencies: ['collection'],
191
+ fulfill: {
192
+ state: {
193
+ visible: '{{!!$deps[0]}}'
194
+ }
195
+ }
196
+ }]
197
+ }) // appends: {
198
+ // type: 'array',
199
+ // title: `{{t("Prefetch fields", { ns: "${NAMESPACE}" })}}`,
200
+ // description: `{{t("Triggered only if one of the selected fields changes. If unselected, it means that it will be triggered when any field changes. When record is added or deleted, any field is considered to have been changed.", { ns: "${NAMESPACE}" })}}`,
201
+ // 'x-decorator': 'FormItem',
202
+ // 'x-component': 'FieldsSelect',
203
+ // 'x-component-props': {
204
+ // mode: 'multiple',
205
+ // placeholder: '{{t("Select Field")}}'
206
+ // },
207
+ // 'x-reactions': [
208
+ // {
209
+ // dependencies: ['collection'],
210
+ // fulfill: {
211
+ // state: {
212
+ // visible: '{{!!$deps[0]}}',
213
+ // },
214
+ // }
215
+ // },
216
+ // ]
217
+ // },
218
+
202
219
  },
203
220
  scope: {
204
221
  useCollectionDataSource: _client().useCollectionDataSource
@@ -207,34 +224,39 @@ var _default = {
207
224
  FieldsSelect
208
225
  },
209
226
 
210
- getOptions(config) {
227
+ getOptions(config, types) {
211
228
  const _useWorkflowTranslati = (0, _locale.useWorkflowTranslation)(),
212
229
  t = _useWorkflowTranslati.t;
213
230
 
214
- const options = [{
231
+ const fieldOptions = (0, _variable.useCollectionFieldOptions)({
232
+ collection: config.collection,
233
+ types
234
+ });
235
+ const options = [...((fieldOptions === null || fieldOptions === void 0 ? void 0 : fieldOptions.length) ? [{
236
+ label: t('Trigger data'),
237
+ key: 'data',
215
238
  value: 'data',
216
- label: t('Trigger data')
217
- }];
239
+ children: fieldOptions
240
+ }] : [])];
218
241
  return options;
219
242
  },
220
243
 
221
- getter(props) {
222
- const _onChange = props.onChange;
223
-
224
- const _useFlowContext = (0, _FlowContext.useFlowContext)(),
225
- workflow = _useFlowContext.workflow;
226
-
227
- const _useOperandContext = (0, _calculators.useOperandContext)(),
228
- options = _useOperandContext.options;
244
+ useInitializers(config) {
245
+ if (!config.collection) {
246
+ return null;
247
+ }
248
+
249
+ return {
250
+ type: 'item',
251
+ title: `{{t("Trigger data", { ns: "${_locale.NAMESPACE}" })}}`,
252
+ component: _CollectionBlockInitializer.CollectionBlockInitializer,
253
+ collection: config.collection,
254
+ dataSource: '{{$context.data}}'
255
+ };
256
+ },
229
257
 
230
- return _react().default.createElement(_CollectionFieldSelect.default, {
231
- collection: workflow.config.collection,
232
- value: options === null || options === void 0 ? void 0 : options.path,
233
- onChange: path => {
234
- _onChange(`{{$context.data.${path}}}`);
235
- }
236
- });
258
+ initializers: {
259
+ CollectionFieldInitializers: _CollectionFieldInitializers.CollectionFieldInitializers
237
260
  }
238
-
239
261
  };
240
262
  exports.default = _default;
@@ -1,10 +1,11 @@
1
+ import React from "react";
1
2
  import { ISchema } from "@formily/react";
2
3
  import { Registry } from "@nocobase/utils/client";
3
- import React from "react";
4
+ import { SchemaInitializerItemOptions } from '@nocobase/client';
4
5
  export interface Trigger {
5
6
  title: string;
6
7
  type: string;
7
- getOptions?(config: any): {
8
+ getOptions?(config: any, types: any[]): {
8
9
  label: string;
9
10
  value: any;
10
11
  key: string;
@@ -20,7 +21,9 @@ export interface Trigger {
20
21
  [key: string]: any;
21
22
  };
22
23
  render?(props: any): React.ReactNode;
23
- getter?(node: any): React.ReactNode;
24
+ useInitializers?(config: any): SchemaInitializerItemOptions | null;
25
+ initializers?: any;
24
26
  }
25
27
  export declare const triggers: Registry<Trigger>;
26
28
  export declare const TriggerConfig: () => JSX.Element;
29
+ export declare function useTrigger(): Trigger;