@nocobase/plugin-workflow 0.9.1-alpha.1 → 0.9.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 (132) hide show
  1. package/lib/client/AddButton.js +50 -86
  2. package/lib/client/Branch.js +0 -13
  3. package/lib/client/ExecutionCanvas.js +16 -63
  4. package/lib/client/ExecutionLink.js +3 -21
  5. package/lib/client/ExecutionPage.js +1 -19
  6. package/lib/client/ExecutionResourceProvider.js +6 -23
  7. package/lib/client/FlowContext.js +0 -8
  8. package/lib/client/WorkflowCanvas.js +57 -129
  9. package/lib/client/WorkflowLink.js +3 -21
  10. package/lib/client/WorkflowPage.js +1 -19
  11. package/lib/client/WorkflowProvider.js +24 -47
  12. package/lib/client/WorkflowShortcut.js +0 -16
  13. package/lib/client/components/CollectionBlockInitializer.js +12 -22
  14. package/lib/client/components/CollectionFieldInitializers.js +5 -24
  15. package/lib/client/components/CollectionFieldset.js +33 -85
  16. package/lib/client/components/Duration.js +0 -14
  17. package/lib/client/components/DynamicExpression.d.ts +4 -0
  18. package/lib/client/components/DynamicExpression.js +102 -0
  19. package/lib/client/components/FieldsSelect.d.ts +2 -0
  20. package/lib/client/components/FieldsSelect.js +66 -0
  21. package/lib/client/components/FilterDynamicComponent.js +1 -10
  22. package/lib/client/components/NullRender.js +0 -1
  23. package/lib/client/components/OpenDrawer.js +10 -35
  24. package/lib/client/components/RadioWithTooltip.js +5 -27
  25. package/lib/client/components/renderEngineReference.d.ts +1 -0
  26. package/lib/client/components/renderEngineReference.js +55 -0
  27. package/lib/client/constants.js +0 -9
  28. package/lib/client/index.js +0 -6
  29. package/lib/client/interfaces/expression.d.ts +3 -0
  30. package/lib/client/interfaces/expression.js +37 -0
  31. package/lib/client/locale/index.js +5 -15
  32. package/lib/client/locale/pt-BR.d.ts +130 -0
  33. package/lib/client/locale/pt-BR.js +136 -0
  34. package/lib/client/locale/zh-CN.d.ts +16 -1
  35. package/lib/client/locale/zh-CN.js +17 -2
  36. package/lib/client/nodes/calculation.d.ts +56 -7
  37. package/lib/client/nodes/calculation.js +141 -74
  38. package/lib/client/nodes/condition.d.ts +5 -9
  39. package/lib/client/nodes/condition.js +30 -93
  40. package/lib/client/nodes/create.d.ts +36 -12
  41. package/lib/client/nodes/create.js +14 -28
  42. package/lib/client/nodes/delay.d.ts +3 -7
  43. package/lib/client/nodes/delay.js +5 -14
  44. package/lib/client/nodes/destroy.d.ts +3 -11
  45. package/lib/client/nodes/destroy.js +14 -12
  46. package/lib/client/nodes/index.d.ts +2 -2
  47. package/lib/client/nodes/index.js +181 -222
  48. package/lib/client/nodes/manual/AssigneesSelect.js +8 -18
  49. package/lib/client/nodes/manual/ModeConfig.js +0 -27
  50. package/lib/client/nodes/manual/SchemaConfig.js +87 -449
  51. package/lib/client/nodes/manual/WorkflowTodo.js +99 -163
  52. package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +4 -20
  53. package/lib/client/nodes/manual/forms/customForm.d.ts +40 -0
  54. package/lib/client/nodes/manual/forms/customForm.js +411 -0
  55. package/lib/client/nodes/manual/index.d.ts +15 -6
  56. package/lib/client/nodes/manual/index.js +58 -54
  57. package/lib/client/nodes/parallel.d.ts +1 -2
  58. package/lib/client/nodes/parallel.js +16 -45
  59. package/lib/client/nodes/query.d.ts +30 -12
  60. package/lib/client/nodes/query.js +17 -25
  61. package/lib/client/nodes/request.d.ts +9 -17
  62. package/lib/client/nodes/request.js +13 -37
  63. package/lib/client/nodes/update.d.ts +27 -28
  64. package/lib/client/nodes/update.js +17 -18
  65. package/lib/client/schemas/collection.d.ts +20 -7
  66. package/lib/client/schemas/collection.js +27 -28
  67. package/lib/client/schemas/executions.js +3 -18
  68. package/lib/client/schemas/workflows.js +10 -33
  69. package/lib/client/style.js +75 -26
  70. package/lib/client/triggers/collection.d.ts +47 -18
  71. package/lib/client/triggers/collection.js +65 -123
  72. package/lib/client/triggers/index.d.ts +3 -6
  73. package/lib/client/triggers/index.js +146 -146
  74. package/lib/client/triggers/schedule/DateFieldsSelect.js +7 -32
  75. package/lib/client/triggers/schedule/EndsByField.js +1 -18
  76. package/lib/client/triggers/schedule/OnField.js +10 -38
  77. package/lib/client/triggers/schedule/RepeatField.js +4 -32
  78. package/lib/client/triggers/schedule/ScheduleConfig.js +25 -68
  79. package/lib/client/triggers/schedule/index.d.ts +21 -1
  80. package/lib/client/triggers/schedule/index.js +22 -24
  81. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +8 -4
  82. package/lib/client/utils.d.ts +1 -0
  83. package/lib/client/utils.js +31 -10
  84. package/lib/client/variable.d.ts +7 -6
  85. package/lib/client/variable.js +132 -71
  86. package/lib/index.js +0 -2
  87. package/lib/server/Plugin.d.ts +7 -7
  88. package/lib/server/Plugin.js +76 -111
  89. package/lib/server/Processor.d.ts +2 -0
  90. package/lib/server/Processor.js +62 -125
  91. package/lib/server/actions/index.js +3 -10
  92. package/lib/server/actions/nodes.js +34 -87
  93. package/lib/server/actions/workflows.js +46 -96
  94. package/lib/server/collections/executions.js +1 -1
  95. package/lib/server/collections/flow_nodes.js +7 -4
  96. package/lib/server/collections/jobs.js +1 -1
  97. package/lib/server/collections/workflows.js +3 -4
  98. package/lib/server/fields/expression-field.d.ts +8 -0
  99. package/lib/server/fields/expression-field.js +26 -0
  100. package/lib/server/fields/index.d.ts +1 -0
  101. package/lib/server/fields/index.js +12 -0
  102. package/lib/server/functions/index.js +3 -14
  103. package/lib/server/index.js +0 -6
  104. package/lib/server/instructions/calculation.js +22 -17
  105. package/lib/server/instructions/condition.js +8 -52
  106. package/lib/server/instructions/create.js +31 -15
  107. package/lib/server/instructions/delay.js +4 -32
  108. package/lib/server/instructions/destroy.js +6 -12
  109. package/lib/server/instructions/index.js +6 -23
  110. package/lib/server/instructions/manual/actions.js +22 -31
  111. package/lib/server/instructions/manual/collecions/users_jobs.js +1 -1
  112. package/lib/server/instructions/manual/index.d.ts +13 -12
  113. package/lib/server/instructions/manual/index.js +9 -47
  114. package/lib/server/instructions/parallel.js +9 -36
  115. package/lib/server/instructions/query.js +17 -15
  116. package/lib/server/instructions/request.js +7 -30
  117. package/lib/server/instructions/update.js +8 -14
  118. package/lib/server/migrations/20221129153547-calculation-variables.js +3 -27
  119. package/lib/server/migrations/20230221032941-change-request-body-type.js +3 -26
  120. package/lib/server/migrations/20230221071831-calculation-expression.js +1 -33
  121. package/lib/server/migrations/20230221121203-condition-calculation.js +5 -28
  122. package/lib/server/migrations/20230221162902-jsonb-to-json.js +3 -18
  123. package/lib/server/migrations/20230411034722-manual-multi-form.d.ts +4 -0
  124. package/lib/server/migrations/20230411034722-manual-multi-form.js +303 -0
  125. package/lib/server/models/Execution.js +0 -5
  126. package/lib/server/models/FlowNode.js +0 -5
  127. package/lib/server/models/Job.js +0 -5
  128. package/lib/server/models/Workflow.js +0 -5
  129. package/lib/server/triggers/collection.js +39 -61
  130. package/lib/server/triggers/index.js +3 -22
  131. package/lib/server/triggers/schedule.js +72 -194
  132. package/package.json +14 -11
@@ -6,67 +6,47 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.create = create;
7
7
  exports.destroy = destroy;
8
8
  exports.update = update;
9
-
10
9
  function _sequelize() {
11
10
  const data = require("sequelize");
12
-
13
11
  _sequelize = function _sequelize() {
14
12
  return data;
15
13
  };
16
-
17
14
  return data;
18
15
  }
19
-
20
16
  function _actions() {
21
17
  const data = require("@nocobase/actions");
22
-
23
18
  _actions = function _actions() {
24
19
  return data;
25
20
  };
26
-
27
21
  return data;
28
22
  }
29
-
30
23
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
31
-
32
24
  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."); }
33
-
34
25
  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); }
35
-
36
26
  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; }
37
-
38
- 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; }
39
-
27
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
40
28
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
41
-
42
29
  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); } }
43
-
44
30
  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); }); }; }
45
-
46
31
  function create(_x, _x2) {
47
32
  return _create.apply(this, arguments);
48
33
  }
49
-
50
34
  function _create() {
51
35
  _create = _asyncToGenerator(function* (context, next) {
52
36
  const db = context.db;
53
-
54
37
  const repository = _actions().utils.getRepositoryFromParams(context);
55
-
56
38
  const _context$action$param = context.action.params,
57
- whitelist = _context$action$param.whitelist,
58
- blacklist = _context$action$param.blacklist,
59
- updateAssociationValues = _context$action$param.updateAssociationValues,
60
- values = _context$action$param.values,
61
- workflowId = _context$action$param.associatedIndex;
39
+ whitelist = _context$action$param.whitelist,
40
+ blacklist = _context$action$param.blacklist,
41
+ updateAssociationValues = _context$action$param.updateAssociationValues,
42
+ values = _context$action$param.values,
43
+ workflowId = _context$action$param.associatedIndex;
62
44
  context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
63
45
  var _ref = _asyncToGenerator(function* (transaction) {
64
46
  const workflow = yield repository.getSourceModel(transaction);
65
-
66
47
  if (workflow.executed) {
67
48
  context.throw(400, 'Node could not be created in executed workflow');
68
49
  }
69
-
70
50
  const instance = yield repository.create({
71
51
  values,
72
52
  whitelist,
@@ -75,7 +55,6 @@ function _create() {
75
55
  context,
76
56
  transaction
77
57
  });
78
-
79
58
  if (!instance.upstreamId) {
80
59
  const previousHead = yield repository.findOne({
81
60
  filter: {
@@ -86,7 +65,6 @@ function _create() {
86
65
  },
87
66
  transaction
88
67
  });
89
-
90
68
  if (previousHead) {
91
69
  yield previousHead.setUpstream(instance, {
92
70
  transaction
@@ -96,19 +74,15 @@ function _create() {
96
74
  });
97
75
  instance.set('downstream', previousHead);
98
76
  }
99
-
100
77
  return instance;
101
78
  }
102
-
103
79
  const upstream = yield instance.getUpstream({
104
80
  transaction
105
81
  });
106
-
107
82
  if (instance.branchIndex == null) {
108
83
  const downstream = yield upstream.getDownstream({
109
84
  transaction
110
85
  });
111
-
112
86
  if (downstream) {
113
87
  yield downstream.setUpstream(instance, {
114
88
  transaction
@@ -118,7 +92,6 @@ function _create() {
118
92
  });
119
93
  instance.set('downstream', downstream);
120
94
  }
121
-
122
95
  yield upstream.update({
123
96
  downstreamId: instance.id
124
97
  }, {
@@ -127,17 +100,16 @@ function _create() {
127
100
  upstream.set('downstream', instance);
128
101
  } else {
129
102
  const _yield$upstream$getBr = yield upstream.getBranches({
130
- where: {
131
- id: {
132
- [_sequelize().Op.ne]: instance.id
103
+ where: {
104
+ id: {
105
+ [_sequelize().Op.ne]: instance.id
106
+ },
107
+ branchIndex: instance.branchIndex
133
108
  },
134
- branchIndex: instance.branchIndex
135
- },
136
- transaction
137
- }),
138
- _yield$upstream$getBr2 = _slicedToArray(_yield$upstream$getBr, 1),
139
- downstream = _yield$upstream$getBr2[0];
140
-
109
+ transaction
110
+ }),
111
+ _yield$upstream$getBr2 = _slicedToArray(_yield$upstream$getBr, 1),
112
+ downstream = _yield$upstream$getBr2[0];
141
113
  if (downstream) {
142
114
  yield downstream.update({
143
115
  upstreamId: instance.id,
@@ -151,11 +123,9 @@ function _create() {
151
123
  instance.set('downstream', downstream);
152
124
  }
153
125
  }
154
-
155
126
  instance.set('upstream', upstream);
156
127
  return instance;
157
128
  });
158
-
159
129
  return function (_x7) {
160
130
  return _ref.apply(this, arguments);
161
131
  };
@@ -164,41 +134,31 @@ function _create() {
164
134
  });
165
135
  return _create.apply(this, arguments);
166
136
  }
167
-
168
137
  function searchBranchNodes(nodes, from) {
169
138
  const branchHeads = nodes.filter(item => item.upstreamId === from.id && item.branchIndex != null);
170
139
  return branchHeads.reduce((flatten, head) => flatten.concat(searchBranchDownstreams(nodes, head)), []);
171
140
  }
172
-
173
141
  function searchBranchDownstreams(nodes, from) {
174
142
  let result = [];
175
-
176
143
  for (let search = from; search; search = search.downstream) {
177
144
  result = [...result, search, ...searchBranchNodes(nodes, search)];
178
145
  }
179
-
180
146
  return result;
181
147
  }
182
-
183
148
  function destroy(_x3, _x4) {
184
149
  return _destroy.apply(this, arguments);
185
150
  }
186
-
187
151
  function _destroy() {
188
152
  _destroy = _asyncToGenerator(function* (context, next) {
189
153
  const db = context.db;
190
-
191
154
  const repository = _actions().utils.getRepositoryFromParams(context);
192
-
193
155
  const filterByTk = context.action.params.filterByTk;
194
156
  context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
195
157
  var _ref2 = _asyncToGenerator(function* (transaction) {
196
158
  const workflow = yield repository.getSourceModel(transaction);
197
-
198
159
  if (workflow.executed) {
199
160
  context.throw(400, 'Nodes in executed workflow could not be deleted');
200
161
  }
201
-
202
162
  const fields = ['id', 'upstreamId', 'downstreamId', 'branchIndex'];
203
163
  const instance = yield repository.findOne({
204
164
  filterByTk,
@@ -206,11 +166,9 @@ function _destroy() {
206
166
  appends: ['upstream', 'downstream'],
207
167
  transaction
208
168
  });
209
-
210
169
  const _instance$get = instance.get(),
211
- upstream = _instance$get.upstream,
212
- downstream = _instance$get.downstream;
213
-
170
+ upstream = _instance$get.upstream,
171
+ downstream = _instance$get.downstream;
214
172
  if (upstream && upstream.downstreamId === instance.id) {
215
173
  yield upstream.update({
216
174
  downstreamId: instance.downstreamId
@@ -218,7 +176,6 @@ function _destroy() {
218
176
  transaction
219
177
  });
220
178
  }
221
-
222
179
  if (downstream) {
223
180
  yield downstream.update({
224
181
  upstreamId: instance.upstreamId,
@@ -227,7 +184,6 @@ function _destroy() {
227
184
  transaction
228
185
  });
229
186
  }
230
-
231
187
  const nodes = yield repository.find({
232
188
  filter: {
233
189
  workflowId: instance.workflowId
@@ -235,19 +191,18 @@ function _destroy() {
235
191
  fields,
236
192
  transaction
237
193
  });
238
- const nodesMap = new Map(); // make map
239
-
194
+ const nodesMap = new Map();
195
+ // make map
240
196
  nodes.forEach(item => {
241
197
  nodesMap.set(item.id, item);
242
- }); // overwrite
243
-
244
- nodesMap.set(instance.id, instance); // make linked list
245
-
198
+ });
199
+ // overwrite
200
+ nodesMap.set(instance.id, instance);
201
+ // make linked list
246
202
  nodes.forEach(item => {
247
203
  if (item.upstreamId) {
248
204
  item.upstream = nodesMap.get(item.upstreamId);
249
205
  }
250
-
251
206
  if (item.downstreamId) {
252
207
  item.downstream = nodesMap.get(item.downstreamId);
253
208
  }
@@ -259,7 +214,6 @@ function _destroy() {
259
214
  });
260
215
  return instance;
261
216
  });
262
-
263
217
  return function (_x8) {
264
218
  return _ref2.apply(this, arguments);
265
219
  };
@@ -268,38 +222,32 @@ function _destroy() {
268
222
  });
269
223
  return _destroy.apply(this, arguments);
270
224
  }
271
-
272
225
  function update(_x5, _x6) {
273
226
  return _update.apply(this, arguments);
274
227
  }
275
-
276
228
  function _update() {
277
229
  _update = _asyncToGenerator(function* (context, next) {
278
230
  const db = context.db;
279
-
280
231
  const repository = _actions().utils.getRepositoryFromParams(context);
281
-
282
232
  const _context$action$param2 = context.action.params,
283
- filterByTk = _context$action$param2.filterByTk,
284
- values = _context$action$param2.values,
285
- whitelist = _context$action$param2.whitelist,
286
- blacklist = _context$action$param2.blacklist,
287
- filter = _context$action$param2.filter,
288
- updateAssociationValues = _context$action$param2.updateAssociationValues;
233
+ filterByTk = _context$action$param2.filterByTk,
234
+ values = _context$action$param2.values,
235
+ whitelist = _context$action$param2.whitelist,
236
+ blacklist = _context$action$param2.blacklist,
237
+ filter = _context$action$param2.filter,
238
+ updateAssociationValues = _context$action$param2.updateAssociationValues;
289
239
  context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
290
240
  var _ref3 = _asyncToGenerator(function* (transaction) {
291
241
  // TODO(optimize): duplicated instance query
292
242
  const _yield$repository$fin = yield repository.findOne({
293
- filterByTk,
294
- appends: ['workflow.executed'],
295
- transaction
296
- }),
297
- workflow = _yield$repository$fin.workflow;
298
-
243
+ filterByTk,
244
+ appends: ['workflow.executed'],
245
+ transaction
246
+ }),
247
+ workflow = _yield$repository$fin.workflow;
299
248
  if (workflow.executed) {
300
249
  context.throw(400, 'Nodes in executed workflow could not be reconfigured');
301
250
  }
302
-
303
251
  return repository.update({
304
252
  filterByTk,
305
253
  values,
@@ -311,7 +259,6 @@ function _update() {
311
259
  transaction
312
260
  });
313
261
  });
314
-
315
262
  return function (_x9) {
316
263
  return _ref3.apply(this, arguments);
317
264
  };
@@ -6,96 +6,69 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.destroy = destroy;
7
7
  exports.revision = revision;
8
8
  exports.update = update;
9
-
10
9
  function _actions() {
11
10
  const data = _interopRequireWildcard(require("@nocobase/actions"));
12
-
13
11
  _actions = function _actions() {
14
12
  return data;
15
13
  };
16
-
17
14
  return data;
18
15
  }
19
-
20
16
  function _database() {
21
17
  const data = require("@nocobase/database");
22
-
23
18
  _database = function _database() {
24
19
  return data;
25
20
  };
26
-
27
21
  return data;
28
22
  }
29
-
30
23
  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); }
31
-
32
24
  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; }
33
-
34
25
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
-
36
26
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
37
-
38
27
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
39
-
40
28
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
41
-
42
- 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; }
43
-
29
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
44
30
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
-
46
31
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
47
-
48
32
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
-
50
- 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; }
51
-
33
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
34
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
35
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
52
36
  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); } }
53
-
54
37
  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); }); }; }
55
-
56
38
  function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
57
-
58
39
  function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
59
-
60
40
  function update(_x, _x2) {
61
41
  return _update.apply(this, arguments);
62
42
  }
63
-
64
43
  function _update() {
65
44
  _update = _asyncToGenerator(function* (context, next) {
66
45
  const repository = _actions().utils.getRepositoryFromParams(context);
67
-
68
46
  const _context$action$param = context.action.params,
69
- filterByTk = _context$action$param.filterByTk,
70
- values = _context$action$param.values;
47
+ filterByTk = _context$action$param.filterByTk,
48
+ values = _context$action$param.values;
71
49
  context.action.mergeParams({
72
50
  whitelist: ['title', 'description', 'enabled', 'config']
73
- }); // only enable/disable
74
-
51
+ });
52
+ // only enable/disable
75
53
  if (Object.keys(values).includes('config')) {
76
54
  const workflow = yield repository.findById(filterByTk);
77
-
78
55
  if (workflow.get('executed')) {
79
56
  return context.throw(400, 'config of executed workflow can not be updated');
80
57
  }
81
58
  }
82
-
83
59
  return _actions().default.update(context, next);
84
60
  });
85
61
  return _update.apply(this, arguments);
86
62
  }
87
-
88
63
  function destroy(_x3, _x4) {
89
64
  return _destroy.apply(this, arguments);
90
65
  }
91
-
92
66
  function _destroy() {
93
67
  _destroy = _asyncToGenerator(function* (context, next) {
94
68
  const repository = _actions().utils.getRepositoryFromParams(context);
95
-
96
69
  const _context$action$param2 = context.action.params,
97
- filterByTk = _context$action$param2.filterByTk,
98
- filter = _context$action$param2.filter;
70
+ filterByTk = _context$action$param2.filterByTk,
71
+ filter = _context$action$param2.filter;
99
72
  yield context.db.sequelize.transaction( /*#__PURE__*/function () {
100
73
  var _ref = _asyncToGenerator(function* (transaction) {
101
74
  const items = yield repository.find({
@@ -123,7 +96,6 @@ function _destroy() {
123
96
  transaction
124
97
  });
125
98
  });
126
-
127
99
  return function (_x7) {
128
100
  return _ref.apply(this, arguments);
129
101
  };
@@ -132,7 +104,6 @@ function _destroy() {
132
104
  });
133
105
  return _destroy.apply(this, arguments);
134
106
  }
135
-
136
107
  function typeOf(value) {
137
108
  if (Array.isArray(value)) {
138
109
  return 'array';
@@ -141,64 +112,50 @@ function typeOf(value) {
141
112
  } else if (value === null) {
142
113
  return 'null';
143
114
  }
144
-
145
115
  return typeof value;
146
116
  }
147
-
148
117
  function migrateConfig(config, oldToNew) {
149
118
  function migrate(value) {
150
119
  switch (typeOf(value)) {
151
120
  case 'object':
152
121
  if (value.type === '$jobsMapByNodeId') {
153
122
  var _oldToNew$get, _value$options;
154
-
155
123
  return _objectSpread(_objectSpread({}, value), {}, {
156
124
  options: _objectSpread(_objectSpread({}, value.options), {}, {
157
125
  nodeId: (_oldToNew$get = oldToNew.get((_value$options = value.options) === null || _value$options === void 0 ? void 0 : _value$options.nodeId)) === null || _oldToNew$get === void 0 ? void 0 : _oldToNew$get.id
158
126
  })
159
127
  });
160
128
  }
161
-
162
129
  return Object.keys(value).reduce((result, key) => _objectSpread(_objectSpread({}, result), {}, {
163
130
  [key]: migrate(value[key])
164
131
  }), {});
165
-
166
132
  case 'array':
167
133
  return value.map(item => migrate(item));
168
-
169
134
  case 'string':
170
135
  return value.replace(/(\{\{\$jobsMapByNodeId\.)([\w-]+)/g, (_, jobVar, oldNodeId) => {
171
136
  const newNode = oldToNew.get(Number.parseInt(oldNodeId, 10));
172
-
173
137
  if (!newNode) {
174
138
  throw new Error('node configurated for result is not existed');
175
139
  }
176
-
177
140
  return `{{$jobsMapByNodeId.${newNode.id}`;
178
141
  });
179
-
180
142
  default:
181
143
  return value;
182
144
  }
183
145
  }
184
-
185
146
  return migrate(config);
186
147
  }
187
-
188
148
  function revision(_x5, _x6) {
189
149
  return _revision.apply(this, arguments);
190
150
  }
191
-
192
151
  function _revision() {
193
152
  _revision = _asyncToGenerator(function* (context, next) {
194
153
  const db = context.db;
195
-
196
154
  const repository = _actions().utils.getRepositoryFromParams(context);
197
-
198
155
  const _context$action$param3 = context.action.params,
199
- filterByTk = _context$action$param3.filterByTk,
200
- _context$action$param4 = _context$action$param3.filter,
201
- filter = _context$action$param4 === void 0 ? {} : _context$action$param4;
156
+ filterByTk = _context$action$param3.filterByTk,
157
+ _context$action$param4 = _context$action$param3.filter,
158
+ filter = _context$action$param4 === void 0 ? {} : _context$action$param4;
202
159
  context.body = yield db.sequelize.transaction( /*#__PURE__*/function () {
203
160
  var _ref2 = _asyncToGenerator(function* (transaction) {
204
161
  const origin = yield repository.findOne({
@@ -230,23 +187,23 @@ function _revision() {
230
187
  const newToOld = new Map();
231
188
  var _iteratorAbruptCompletion = false;
232
189
  var _didIteratorError = false;
233
-
234
190
  var _iteratorError;
235
-
236
191
  try {
237
192
  for (var _iterator = _asyncIterator(origin.nodes), _step; _iteratorAbruptCompletion = !(_step = yield _iterator.next()).done; _iteratorAbruptCompletion = false) {
238
193
  const node = _step.value;
239
- const newNode = yield instance.createNode({
240
- type: node.type,
241
- config: node.config,
242
- title: node.title,
243
- branchIndex: node.branchIndex
244
- }, {
245
- transaction
246
- }); // NOTE: keep original node references for later replacement
247
-
248
- oldToNew.set(node.id, newNode);
249
- newToOld.set(newNode.id, node);
194
+ {
195
+ const newNode = yield instance.createNode({
196
+ type: node.type,
197
+ config: node.config,
198
+ title: node.title,
199
+ branchIndex: node.branchIndex
200
+ }, {
201
+ transaction
202
+ });
203
+ // NOTE: keep original node references for later replacement
204
+ oldToNew.set(node.id, newNode);
205
+ newToOld.set(newNode.id, node);
206
+ }
250
207
  }
251
208
  } catch (err) {
252
209
  _didIteratorError = true;
@@ -262,38 +219,33 @@ function _revision() {
262
219
  }
263
220
  }
264
221
  }
265
-
266
222
  var _iteratorAbruptCompletion2 = false;
267
223
  var _didIteratorError2 = false;
268
-
269
224
  var _iteratorError2;
270
-
271
225
  try {
272
226
  for (var _iterator2 = _asyncIterator(oldToNew.entries()), _step2; _iteratorAbruptCompletion2 = !(_step2 = yield _iterator2.next()).done; _iteratorAbruptCompletion2 = false) {
273
- var _newUpstream$id, _newDownstream$id;
274
-
275
227
  const _step2$value = _slicedToArray(_step2.value, 2),
276
- oldId = _step2$value[0],
277
- newNode = _step2$value[1];
278
-
279
- const oldNode = originalNodesMap.get(oldId);
280
- const newUpstream = oldNode.upstreamId ? oldToNew.get(oldNode.upstreamId) : null;
281
- const newDownstream = oldNode.downstreamId ? oldToNew.get(oldNode.downstreamId) : null;
282
- let migratedConfig;
283
-
284
- try {
285
- migratedConfig = migrateConfig(oldNode.config, oldToNew);
286
- } catch (err) {
287
- return context.throw(400, err.message);
228
+ oldId = _step2$value[0],
229
+ newNode = _step2$value[1];
230
+ {
231
+ var _newUpstream$id, _newDownstream$id;
232
+ const oldNode = originalNodesMap.get(oldId);
233
+ const newUpstream = oldNode.upstreamId ? oldToNew.get(oldNode.upstreamId) : null;
234
+ const newDownstream = oldNode.downstreamId ? oldToNew.get(oldNode.downstreamId) : null;
235
+ let migratedConfig;
236
+ try {
237
+ migratedConfig = migrateConfig(oldNode.config, oldToNew);
238
+ } catch (err) {
239
+ return context.throw(400, err.message);
240
+ }
241
+ yield newNode.update({
242
+ upstreamId: (_newUpstream$id = newUpstream === null || newUpstream === void 0 ? void 0 : newUpstream.id) !== null && _newUpstream$id !== void 0 ? _newUpstream$id : null,
243
+ downstreamId: (_newDownstream$id = newDownstream === null || newDownstream === void 0 ? void 0 : newDownstream.id) !== null && _newDownstream$id !== void 0 ? _newDownstream$id : null,
244
+ config: migratedConfig
245
+ }, {
246
+ transaction
247
+ });
288
248
  }
289
-
290
- yield newNode.update({
291
- upstreamId: (_newUpstream$id = newUpstream === null || newUpstream === void 0 ? void 0 : newUpstream.id) !== null && _newUpstream$id !== void 0 ? _newUpstream$id : null,
292
- downstreamId: (_newDownstream$id = newDownstream === null || newDownstream === void 0 ? void 0 : newDownstream.id) !== null && _newDownstream$id !== void 0 ? _newDownstream$id : null,
293
- config: migratedConfig
294
- }, {
295
- transaction
296
- });
297
249
  }
298
250
  } catch (err) {
299
251
  _didIteratorError2 = true;
@@ -309,10 +261,8 @@ function _revision() {
309
261
  }
310
262
  }
311
263
  }
312
-
313
264
  return instance;
314
265
  });
315
-
316
266
  return function (_x8) {
317
267
  return _ref2.apply(this, arguments);
318
268
  };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = {
8
- namespace: 'workflow',
8
+ namespace: 'workflow.executionLogs',
9
9
  duplicator: 'optional',
10
10
  name: 'executions',
11
11
  fields: [{
@@ -5,13 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = {
8
- namespace: 'workflow',
8
+ namespace: 'workflow.workflowConfig',
9
9
  duplicator: 'required',
10
10
  name: 'flow_nodes',
11
11
  fields: [{
12
12
  type: 'string',
13
13
  name: 'title'
14
- }, // which workflow belongs to
14
+ },
15
+ // which workflow belongs to
15
16
  {
16
17
  name: 'workflow',
17
18
  type: 'belongsTo'
@@ -25,13 +26,15 @@ var _default = {
25
26
  target: 'flow_nodes',
26
27
  sourceKey: 'id',
27
28
  foreignKey: 'upstreamId'
28
- }, // only works when upstream node is branching type, such as condition and parallel.
29
+ },
30
+ // only works when upstream node is branching type, such as condition and parallel.
29
31
  // put here because the design of flow-links model is not really necessary for now.
30
32
  // or it should be put into flow-links model.
31
33
  {
32
34
  name: 'branchIndex',
33
35
  type: 'integer'
34
- }, // Note: for reasons:
36
+ },
37
+ // Note: for reasons:
35
38
  // 1. redirect type node to solve cycle flow.
36
39
  // 2. recognize as real next node after branches.
37
40
  {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = {
8
- namespace: 'workflow',
8
+ namespace: 'workflow.executionLogs',
9
9
  duplicator: 'optional',
10
10
  name: 'jobs',
11
11
  fields: [{