@nocobase/plugin-workflow 0.9.1-alpha.2 → 0.9.2-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 (131) hide show
  1. package/lib/client/AddButton.js +17 -64
  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 +56 -127
  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 +31 -79
  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 +54 -3
  37. package/lib/client/nodes/calculation.js +136 -63
  38. package/lib/client/nodes/condition.d.ts +1 -1
  39. package/lib/client/nodes/condition.js +21 -76
  40. package/lib/client/nodes/create.d.ts +35 -9
  41. package/lib/client/nodes/create.js +13 -19
  42. package/lib/client/nodes/delay.d.ts +1 -3
  43. package/lib/client/nodes/delay.js +3 -10
  44. package/lib/client/nodes/destroy.d.ts +1 -6
  45. package/lib/client/nodes/destroy.js +12 -9
  46. package/lib/client/nodes/index.d.ts +2 -2
  47. package/lib/client/nodes/index.js +45 -147
  48. package/lib/client/nodes/manual/AssigneesSelect.js +6 -17
  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 +12 -1
  56. package/lib/client/nodes/manual/index.js +54 -41
  57. package/lib/client/nodes/parallel.js +7 -41
  58. package/lib/client/nodes/query.d.ts +28 -7
  59. package/lib/client/nodes/query.js +15 -22
  60. package/lib/client/nodes/request.d.ts +2 -3
  61. package/lib/client/nodes/request.js +5 -22
  62. package/lib/client/nodes/update.d.ts +1 -6
  63. package/lib/client/nodes/update.js +8 -16
  64. package/lib/client/schemas/collection.d.ts +20 -4
  65. package/lib/client/schemas/collection.js +26 -22
  66. package/lib/client/schemas/executions.js +3 -18
  67. package/lib/client/schemas/workflows.js +10 -33
  68. package/lib/client/style.js +24 -21
  69. package/lib/client/triggers/collection.d.ts +24 -20
  70. package/lib/client/triggers/collection.js +34 -123
  71. package/lib/client/triggers/index.d.ts +2 -5
  72. package/lib/client/triggers/index.js +34 -105
  73. package/lib/client/triggers/schedule/DateFieldsSelect.js +6 -29
  74. package/lib/client/triggers/schedule/EndsByField.js +1 -18
  75. package/lib/client/triggers/schedule/OnField.js +10 -38
  76. package/lib/client/triggers/schedule/RepeatField.js +4 -32
  77. package/lib/client/triggers/schedule/ScheduleConfig.js +10 -51
  78. package/lib/client/triggers/schedule/index.d.ts +21 -0
  79. package/lib/client/triggers/schedule/index.js +21 -22
  80. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +8 -4
  81. package/lib/client/utils.d.ts +1 -0
  82. package/lib/client/utils.js +31 -10
  83. package/lib/client/variable.d.ts +7 -6
  84. package/lib/client/variable.js +132 -71
  85. package/lib/index.js +0 -2
  86. package/lib/server/Plugin.d.ts +7 -7
  87. package/lib/server/Plugin.js +76 -111
  88. package/lib/server/Processor.d.ts +2 -0
  89. package/lib/server/Processor.js +62 -125
  90. package/lib/server/actions/index.js +3 -10
  91. package/lib/server/actions/nodes.js +34 -87
  92. package/lib/server/actions/workflows.js +46 -96
  93. package/lib/server/collections/executions.js +1 -1
  94. package/lib/server/collections/flow_nodes.js +7 -4
  95. package/lib/server/collections/jobs.js +1 -1
  96. package/lib/server/collections/workflows.js +3 -4
  97. package/lib/server/fields/expression-field.d.ts +8 -0
  98. package/lib/server/fields/expression-field.js +26 -0
  99. package/lib/server/fields/index.d.ts +1 -0
  100. package/lib/server/fields/index.js +12 -0
  101. package/lib/server/functions/index.js +3 -14
  102. package/lib/server/index.js +0 -6
  103. package/lib/server/instructions/calculation.js +22 -17
  104. package/lib/server/instructions/condition.js +8 -52
  105. package/lib/server/instructions/create.js +31 -15
  106. package/lib/server/instructions/delay.js +4 -32
  107. package/lib/server/instructions/destroy.js +6 -12
  108. package/lib/server/instructions/index.js +6 -23
  109. package/lib/server/instructions/manual/actions.js +22 -31
  110. package/lib/server/instructions/manual/collecions/users_jobs.js +1 -1
  111. package/lib/server/instructions/manual/index.d.ts +13 -12
  112. package/lib/server/instructions/manual/index.js +9 -47
  113. package/lib/server/instructions/parallel.js +9 -36
  114. package/lib/server/instructions/query.js +17 -15
  115. package/lib/server/instructions/request.js +7 -30
  116. package/lib/server/instructions/update.js +8 -14
  117. package/lib/server/migrations/20221129153547-calculation-variables.js +3 -27
  118. package/lib/server/migrations/20230221032941-change-request-body-type.js +3 -26
  119. package/lib/server/migrations/20230221071831-calculation-expression.js +1 -33
  120. package/lib/server/migrations/20230221121203-condition-calculation.js +5 -28
  121. package/lib/server/migrations/20230221162902-jsonb-to-json.js +3 -18
  122. package/lib/server/migrations/20230411034722-manual-multi-form.d.ts +4 -0
  123. package/lib/server/migrations/20230411034722-manual-multi-form.js +303 -0
  124. package/lib/server/models/Execution.js +0 -5
  125. package/lib/server/models/FlowNode.js +0 -5
  126. package/lib/server/models/Job.js +0 -5
  127. package/lib/server/models/Workflow.js +0 -5
  128. package/lib/server/triggers/collection.js +39 -61
  129. package/lib/server/triggers/index.js +3 -22
  130. package/lib/server/triggers/schedule.js +72 -194
  131. package/package.json +14 -11
@@ -4,59 +4,48 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _jsonTemplates() {
9
8
  const data = _interopRequireDefault(require("json-templates"));
10
-
11
9
  _jsonTemplates = function _jsonTemplates() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _database() {
19
15
  const data = require("@nocobase/database");
20
-
21
16
  _database = function _database() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
21
+ function _evaluators() {
22
+ const data = require("@nocobase/evaluators");
23
+ _evaluators = function _evaluators() {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
28
  var _constants = require("./constants");
29
-
30
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
30
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
33
-
34
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; }
35
-
36
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; }
37
-
38
- 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; }
39
-
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); }
40
36
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
-
42
37
  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."); }
43
-
44
38
  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); }
45
-
46
39
  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; }
47
-
48
- 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; }
49
-
40
+ 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; } }
50
41
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
-
52
42
  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
43
  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
44
  class Processor {
57
45
  constructor(execution, options) {
58
46
  this.execution = void 0;
59
47
  this.options = void 0;
48
+ this.logger = void 0;
60
49
  this.transaction = void 0;
61
50
  this.nodes = [];
62
51
  this.nodesMap = new Map();
@@ -64,9 +53,9 @@ class Processor {
64
53
  this.jobsMapByNodeId = {};
65
54
  this.execution = execution;
66
55
  this.options = options;
67
- } // make dual linked nodes list then cache
68
-
69
-
56
+ this.logger = options.plugin.getLogger(execution.workflowId);
57
+ }
58
+ // make dual linked nodes list then cache
70
59
  makeNodes(nodes = []) {
71
60
  this.nodes = nodes;
72
61
  nodes.forEach(node => {
@@ -76,112 +65,85 @@ class Processor {
76
65
  if (node.upstreamId) {
77
66
  node.upstream = this.nodesMap.get(node.upstreamId);
78
67
  }
79
-
80
68
  if (node.downstreamId) {
81
69
  node.downstream = this.nodesMap.get(node.downstreamId);
82
70
  }
83
71
  });
84
72
  }
85
-
86
73
  makeJobs(jobs) {
87
74
  jobs.forEach(job => {
88
- this.jobsMap.set(job.id, job); // TODO: should consider cycle, and from previous job
89
-
75
+ this.jobsMap.set(job.id, job);
76
+ // TODO: should consider cycle, and from previous job
90
77
  this.jobsMapByNodeId[job.nodeId] = job.result;
91
78
  });
92
79
  }
93
-
94
80
  getTransaction() {
95
81
  var _this = this;
96
-
97
82
  return _asyncToGenerator(function* () {
98
83
  if (!_this.execution.useTransaction) {
99
84
  return;
100
85
  }
101
-
102
- const options = _this.options; // @ts-ignore
103
-
86
+ const options = _this.options;
87
+ // @ts-ignore
104
88
  return options.transaction && !options.transaction.finished ? options.transaction : yield options.plugin.db.sequelize.transaction();
105
89
  })();
106
90
  }
107
-
108
91
  prepare() {
109
92
  var _this2 = this;
110
-
111
93
  return _asyncToGenerator(function* () {
112
94
  const transaction = yield _this2.getTransaction();
113
95
  _this2.transaction = transaction;
114
96
  const execution = _this2.execution;
115
-
116
97
  if (!execution.workflow) {
117
98
  execution.workflow = yield execution.getWorkflow({
118
99
  transaction
119
100
  });
120
101
  }
121
-
122
102
  const nodes = yield execution.workflow.getNodes({
123
103
  transaction
124
104
  });
125
-
126
105
  _this2.makeNodes(nodes);
127
-
128
106
  const jobs = yield execution.getJobs({
129
107
  order: [['id', 'ASC']],
130
108
  transaction
131
109
  });
132
-
133
110
  _this2.makeJobs(jobs);
134
111
  })();
135
112
  }
136
-
137
113
  start() {
138
114
  var _this3 = this;
139
-
140
115
  return _asyncToGenerator(function* () {
141
116
  const execution = _this3.execution;
142
-
143
117
  if (execution.status !== _constants.EXECUTION_STATUS.STARTED) {
144
118
  throw new Error(`execution was ended with status ${execution.status}`);
145
119
  }
146
-
147
120
  yield _this3.prepare();
148
-
149
121
  if (_this3.nodes.length) {
150
122
  const head = _this3.nodes.find(item => !item.upstream);
151
-
152
123
  yield _this3.run(head, {
153
124
  result: execution.context
154
125
  });
155
126
  } else {
156
127
  yield _this3.exit(null);
157
128
  }
158
-
159
129
  yield _this3.commit();
160
130
  })();
161
131
  }
162
-
163
132
  resume(job) {
164
133
  var _this4 = this;
165
-
166
134
  return _asyncToGenerator(function* () {
167
135
  const execution = _this4.execution;
168
-
169
136
  if (execution.status !== _constants.EXECUTION_STATUS.STARTED) {
170
137
  throw new Error(`execution was ended with status ${execution.status}`);
171
138
  }
172
-
173
139
  yield _this4.prepare();
174
-
175
140
  const node = _this4.nodesMap.get(job.nodeId);
176
-
177
141
  yield _this4.recall(node, job);
178
142
  yield _this4.commit();
179
143
  })();
180
144
  }
181
-
182
145
  commit() {
183
146
  var _this5 = this;
184
-
185
147
  return _asyncToGenerator(function* () {
186
148
  // @ts-ignore
187
149
  if (_this5.transaction && (!_this5.options.transaction || _this5.options.transaction.finished)) {
@@ -189,109 +151,101 @@ class Processor {
189
151
  }
190
152
  })();
191
153
  }
192
-
193
154
  exec(instruction, node, prevJob) {
194
155
  var _this6 = this;
195
-
196
156
  return _asyncToGenerator(function* () {
197
157
  let job;
198
-
199
158
  try {
200
159
  // call instruction to get result and status
160
+ _this6.logger.info(`execution (${_this6.execution.id}) run instruction [${node.type}] for node (${node.id})`);
161
+ _this6.logger.debug(`config of node`, {
162
+ data: node.config
163
+ });
201
164
  job = yield instruction(node, prevJob, _this6);
202
-
203
165
  if (!job) {
204
166
  return null;
205
167
  }
206
168
  } catch (err) {
207
169
  // for uncaught error, set to error
170
+ _this6.logger.error(`execution (${_this6.execution.id}) run instruction [${node.type}] for node (${node.id}) failed: `, {
171
+ error: err
172
+ });
208
173
  job = {
209
174
  result: err instanceof Error ? {
210
175
  message: err.message,
211
176
  stack: process.env.NODE_ENV === 'production' ? [] : err.stack
212
177
  } : err,
213
178
  status: _constants.JOB_STATUS.ERROR
214
- }; // if previous job is from resuming
215
-
179
+ };
180
+ // if previous job is from resuming
216
181
  if (prevJob && prevJob.nodeId === node.id) {
217
182
  prevJob.set(job);
218
183
  job = prevJob;
219
184
  }
220
185
  }
221
-
222
186
  if (!(job instanceof _database().Model)) {
223
187
  job.upstreamId = prevJob instanceof _database().Model ? prevJob.get('id') : null;
224
188
  job.nodeId = node.id;
225
189
  }
226
-
227
190
  const savedJob = yield _this6.saveJob(job);
228
-
191
+ _this6.logger.info(`execution (${_this6.execution.id}) run instruction [${node.type}] for node (${node.id}) finished as status: ${savedJob.status}`);
192
+ _this6.logger.debug(`result of node`, {
193
+ data: savedJob.result
194
+ });
229
195
  if (savedJob.status === _constants.JOB_STATUS.RESOLVED && node.downstream) {
230
196
  // run next node
197
+ _this6.logger.debug(`run next node (${node.id})`);
231
198
  return _this6.run(node.downstream, savedJob);
232
- } // all nodes in scope have been executed
233
-
234
-
199
+ }
200
+ // all nodes in scope have been executed
235
201
  return _this6.end(node, savedJob);
236
202
  })();
237
203
  }
238
-
239
204
  run(node, input) {
240
205
  var _this7 = this;
241
-
242
206
  return _asyncToGenerator(function* () {
243
207
  const instructions = _this7.options.plugin.instructions;
244
208
  const instruction = instructions.get(node.type);
245
-
246
209
  if (typeof instruction.run !== 'function') {
247
210
  return Promise.reject(new Error('`run` should be implemented for customized execution of the node'));
248
211
  }
249
-
250
212
  return _this7.exec(instruction.run.bind(instruction), node, input);
251
213
  })();
252
- } // parent node should take over the control
253
-
254
-
214
+ }
215
+ // parent node should take over the control
255
216
  end(node, job) {
256
217
  var _this8 = this;
257
-
258
218
  return _asyncToGenerator(function* () {
259
- const parentNode = _this8.findBranchParentNode(node); // no parent, means on main flow
260
-
261
-
219
+ _this8.logger.debug(`branch ended at node (${node.id})})`);
220
+ const parentNode = _this8.findBranchParentNode(node);
221
+ // no parent, means on main flow
262
222
  if (parentNode) {
223
+ _this8.logger.debug(`not on main, recall to parent entry node (${node.id})})`);
263
224
  yield _this8.recall(parentNode, job);
264
225
  return job;
265
- } // really done for all nodes
226
+ }
227
+ // really done for all nodes
266
228
  // * should mark execution as done with last job status
267
-
268
-
269
229
  return _this8.exit(job);
270
230
  })();
271
231
  }
272
-
273
232
  recall(node, job) {
274
233
  var _this9 = this;
275
-
276
234
  return _asyncToGenerator(function* () {
277
235
  const instructions = _this9.options.plugin.instructions;
278
236
  const instruction = instructions.get(node.type);
279
-
280
237
  if (typeof instruction.resume !== 'function') {
281
238
  return Promise.reject(new Error('`resume` should be implemented'));
282
239
  }
283
-
284
240
  return _this9.exec(instruction.resume.bind(instruction), node, job);
285
241
  })();
286
242
  }
287
-
288
243
  exit(job) {
289
244
  var _this10 = this;
290
-
291
245
  return _asyncToGenerator(function* () {
292
246
  var _this10$constructor$S;
293
-
294
247
  const status = job ? (_this10$constructor$S = _this10.constructor.StatusMap[job.status]) !== null && _this10$constructor$S !== void 0 ? _this10$constructor$S : Math.sign(job.status) : _constants.EXECUTION_STATUS.RESOLVED;
248
+ _this10.logger.info(`execution (${_this10.execution.id}) all nodes finished, finishing execution...`);
295
249
  yield _this10.execution.update({
296
250
  status
297
251
  }, {
@@ -299,20 +253,15 @@ class Processor {
299
253
  });
300
254
  return null;
301
255
  })();
302
- } // TODO(optimize)
303
-
304
-
256
+ }
257
+ // TODO(optimize)
305
258
  saveJob(payload) {
306
259
  var _this11 = this;
307
-
308
260
  return _asyncToGenerator(function* () {
309
261
  const database = _this11.execution.constructor.database;
310
-
311
262
  const _database$getCollecti = database.getCollection('jobs'),
312
- model = _database$getCollecti.model;
313
-
263
+ model = _database$getCollecti.model;
314
264
  let job;
315
-
316
265
  if (payload instanceof model) {
317
266
  job = yield payload.save({
318
267
  transaction: _this11.transaction
@@ -325,9 +274,7 @@ class Processor {
325
274
  returning: true,
326
275
  transaction: _this11.transaction
327
276
  });
328
-
329
277
  var _yield$model$update2 = _slicedToArray(_yield$model$update, 1);
330
-
331
278
  job = _yield$model$update2[0];
332
279
  } else {
333
280
  job = yield model.create(_objectSpread(_objectSpread({}, payload), {}, {
@@ -336,19 +283,15 @@ class Processor {
336
283
  transaction: _this11.transaction
337
284
  });
338
285
  }
339
-
340
286
  _this11.jobsMap.set(job.id, job);
341
-
342
287
  _this11.jobsMapByNodeId[job.nodeId] = job.result;
343
288
  return job;
344
289
  })();
345
290
  }
346
-
347
291
  getBranches(node) {
348
292
  return this.nodes.filter(item => item.upstream === node && item.branchIndex !== null).sort((a, b) => Number(a.branchIndex) - Number(b.branchIndex));
349
- } // find the first node in current branch
350
-
351
-
293
+ }
294
+ // find the first node in current branch
352
295
  findBranchStartNode(node, parent) {
353
296
  for (let n = node; n; n = n.upstream) {
354
297
  if (!parent) {
@@ -361,47 +304,38 @@ class Processor {
361
304
  }
362
305
  }
363
306
  }
364
-
365
307
  return null;
366
- } // find the node start current branch
367
-
368
-
308
+ }
309
+ // find the node start current branch
369
310
  findBranchParentNode(node) {
370
311
  for (let n = node; n; n = n.upstream) {
371
312
  if (n.branchIndex !== null) {
372
313
  return n.upstream;
373
314
  }
374
315
  }
375
-
376
316
  return null;
377
317
  }
378
-
379
318
  findBranchParentJob(job, node) {
380
319
  for (let j = job; j; j = this.jobsMap.get(j.upstreamId)) {
381
320
  if (j.nodeId === node.id) {
382
321
  return j;
383
322
  }
384
323
  }
385
-
386
324
  return null;
387
325
  }
388
-
389
326
  getScope(node) {
390
327
  const systemFns = {};
391
328
  const scope = {
392
329
  execution: this.execution,
393
330
  node
394
331
  };
395
-
396
332
  var _iterator = _createForOfIteratorHelper(this.options.plugin.functions.getEntities()),
397
- _step;
398
-
333
+ _step;
399
334
  try {
400
335
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
401
336
  let _step$value = _slicedToArray(_step.value, 2),
402
- name = _step$value[0],
403
- fn = _step$value[1];
404
-
337
+ name = _step$value[0],
338
+ fn = _step$value[1];
405
339
  systemFns[name] = fn.bind(scope);
406
340
  }
407
341
  } catch (err) {
@@ -409,20 +343,23 @@ class Processor {
409
343
  } finally {
410
344
  _iterator.f();
411
345
  }
412
-
413
346
  return {
414
347
  $context: this.execution.context,
415
348
  $jobsMapByNodeId: this.jobsMapByNodeId,
416
349
  $system: systemFns
417
350
  };
418
351
  }
419
-
420
352
  getParsedValue(value, node) {
421
- return (0, _jsonTemplates().default)(value)(this.getScope(node));
353
+ const template = (0, _jsonTemplates().default)(value);
354
+ const scope = this.getScope(node);
355
+ template.parameters.forEach(({
356
+ key
357
+ }) => {
358
+ (0, _evaluators().appendArrayColumn)(scope, key);
359
+ });
360
+ return template(scope);
422
361
  }
423
-
424
362
  }
425
-
426
363
  exports.default = Processor;
427
364
  Processor.StatusMap = {
428
365
  [_constants.JOB_STATUS.PENDING]: _constants.EXECUTION_STATUS.STARTED,
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  var workflows = _interopRequireWildcard(require("./workflows"));
9
-
10
8
  var nodes = _interopRequireWildcard(require("./nodes"));
11
-
12
9
  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); }
13
-
14
10
  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; }
15
-
16
11
  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; }
17
-
18
12
  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; }
19
-
20
- 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; }
21
-
13
+ 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; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ 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); }
22
16
  function make(name, mod) {
23
17
  return Object.keys(mod).reduce((result, key) => _objectSpread(_objectSpread({}, result), {}, {
24
18
  [`${name}:${key}`]: mod[key]
25
19
  }), {});
26
20
  }
27
-
28
21
  function _default({
29
22
  app
30
23
  }) {