@nocobase/plugin-workflow 0.7.1-alpha.5 → 0.7.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/client.d.ts +4 -0
  2. package/client.js +30 -0
  3. package/lib/client/ExecutionResourceProvider.d.ts +4 -0
  4. package/lib/client/ExecutionResourceProvider.js +64 -0
  5. package/lib/client/WorkflowCanvas.d.ts +15 -0
  6. package/lib/client/WorkflowCanvas.js +393 -0
  7. package/lib/client/WorkflowLink.d.ts +1 -0
  8. package/lib/client/WorkflowLink.js +66 -0
  9. package/lib/client/WorkflowPage.d.ts +1 -0
  10. package/lib/client/WorkflowPage.js +92 -0
  11. package/lib/client/WorkflowProvider.d.ts +1 -0
  12. package/lib/client/WorkflowProvider.js +78 -0
  13. package/lib/client/WorkflowShortcut.d.ts +1 -0
  14. package/lib/client/WorkflowShortcut.js +123 -0
  15. package/lib/client/calculators.d.ts +101 -0
  16. package/lib/client/calculators.js +739 -0
  17. package/lib/client/components/Duration.d.ts +5 -0
  18. package/lib/client/components/Duration.js +96 -0
  19. package/lib/client/index.d.ts +3 -0
  20. package/lib/client/index.js +38 -0
  21. package/lib/client/nodes/calculation.d.ts +25 -0
  22. package/lib/client/nodes/calculation.js +85 -0
  23. package/lib/client/nodes/condition.d.ts +46 -0
  24. package/lib/client/nodes/condition.js +346 -0
  25. package/lib/client/nodes/create.d.ts +46 -0
  26. package/lib/client/nodes/create.js +133 -0
  27. package/lib/client/nodes/delay.d.ts +36 -0
  28. package/lib/client/nodes/delay.js +49 -0
  29. package/lib/client/nodes/destroy.d.ts +55 -0
  30. package/lib/client/nodes/destroy.js +46 -0
  31. package/lib/client/nodes/index.d.ts +33 -0
  32. package/lib/client/nodes/index.js +390 -0
  33. package/lib/client/nodes/parallel.d.ts +24 -0
  34. package/lib/client/nodes/parallel.js +216 -0
  35. package/lib/client/nodes/query.d.ts +70 -0
  36. package/lib/client/nodes/query.js +143 -0
  37. package/lib/client/nodes/update.d.ts +60 -0
  38. package/lib/client/nodes/update.js +48 -0
  39. package/lib/client/schemas/collection.d.ts +42 -0
  40. package/lib/client/schemas/collection.js +98 -0
  41. package/lib/client/schemas/executions.d.ts +209 -0
  42. package/lib/client/schemas/executions.js +164 -0
  43. package/lib/client/schemas/workflows.d.ts +2 -0
  44. package/lib/client/schemas/workflows.js +328 -0
  45. package/lib/client/style.d.ts +12 -0
  46. package/lib/client/style.js +216 -0
  47. package/lib/client/triggers/collection.d.ts +92 -0
  48. package/lib/client/triggers/collection.js +253 -0
  49. package/lib/client/triggers/index.d.ts +26 -0
  50. package/lib/client/triggers/index.js +238 -0
  51. package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +2 -0
  52. package/lib/client/triggers/schedule/DateFieldsSelect.js +92 -0
  53. package/lib/client/triggers/schedule/EndsByField.d.ts +5 -0
  54. package/lib/client/triggers/schedule/EndsByField.js +102 -0
  55. package/lib/client/triggers/schedule/OnField.d.ts +5 -0
  56. package/lib/client/triggers/schedule/OnField.js +128 -0
  57. package/lib/client/triggers/schedule/RepeatField.d.ts +5 -0
  58. package/lib/client/triggers/schedule/RepeatField.js +191 -0
  59. package/lib/client/triggers/schedule/ScheduleConfig.d.ts +1 -0
  60. package/lib/client/triggers/schedule/ScheduleConfig.js +286 -0
  61. package/lib/client/triggers/schedule/index.d.ts +25 -0
  62. package/lib/client/triggers/schedule/index.js +124 -0
  63. package/lib/client/triggers/schedule/locale/Cron.zh-CN.d.ts +34 -0
  64. package/lib/client/triggers/schedule/locale/Cron.zh-CN.js +44 -0
  65. package/lib/index.d.ts +1 -6
  66. package/lib/index.js +2 -73
  67. package/lib/{Plugin.d.ts → server/Plugin.d.ts} +0 -0
  68. package/lib/{Plugin.js → server/Plugin.js} +0 -0
  69. package/lib/{Processor.d.ts → server/Processor.d.ts} +4 -3
  70. package/lib/{Processor.js → server/Processor.js} +40 -24
  71. package/lib/{actions → server/actions}/index.d.ts +0 -0
  72. package/lib/{actions → server/actions}/index.js +0 -0
  73. package/lib/{actions → server/actions}/nodes.d.ts +0 -0
  74. package/lib/{actions → server/actions}/nodes.js +1 -0
  75. package/lib/{actions → server/actions}/workflows.d.ts +0 -0
  76. package/lib/{actions → server/actions}/workflows.js +0 -0
  77. package/lib/{calculators → server/calculators}/index.d.ts +0 -0
  78. package/lib/{calculators → server/calculators}/index.js +0 -0
  79. package/lib/{collections → server/collections}/executions.d.ts +0 -0
  80. package/lib/{collections → server/collections}/executions.js +0 -0
  81. package/lib/{collections → server/collections}/flow_nodes.d.ts +0 -0
  82. package/lib/{collections → server/collections}/flow_nodes.js +0 -0
  83. package/lib/{collections → server/collections}/jobs.d.ts +0 -0
  84. package/lib/{collections → server/collections}/jobs.js +0 -0
  85. package/lib/{collections → server/collections}/workflows.d.ts +0 -0
  86. package/lib/{collections → server/collections}/workflows.js +0 -0
  87. package/lib/{constants.d.ts → server/constants.d.ts} +0 -0
  88. package/lib/{constants.js → server/constants.js} +0 -0
  89. package/lib/server/index.d.ts +6 -0
  90. package/lib/server/index.js +86 -0
  91. package/lib/{instructions → server/instructions}/calculation.d.ts +0 -0
  92. package/lib/{instructions → server/instructions}/calculation.js +0 -0
  93. package/lib/{instructions → server/instructions}/condition.d.ts +0 -0
  94. package/lib/{instructions → server/instructions}/condition.js +0 -0
  95. package/lib/{instructions → server/instructions}/create.d.ts +0 -0
  96. package/lib/{instructions → server/instructions}/create.js +0 -0
  97. package/lib/{instructions → server/instructions}/delay.d.ts +0 -0
  98. package/lib/{instructions → server/instructions}/delay.js +12 -5
  99. package/lib/{instructions → server/instructions}/destroy.d.ts +0 -0
  100. package/lib/{instructions → server/instructions}/destroy.js +0 -0
  101. package/lib/{instructions → server/instructions}/index.d.ts +0 -0
  102. package/lib/{instructions → server/instructions}/index.js +0 -0
  103. package/lib/{instructions → server/instructions}/parallel.d.ts +0 -0
  104. package/lib/{instructions → server/instructions}/parallel.js +62 -20
  105. package/lib/{instructions → server/instructions}/prompt.d.ts +0 -0
  106. package/lib/{instructions → server/instructions}/prompt.js +0 -0
  107. package/lib/{instructions → server/instructions}/query.d.ts +0 -0
  108. package/lib/{instructions → server/instructions}/query.js +0 -0
  109. package/lib/{instructions → server/instructions}/update.d.ts +0 -0
  110. package/lib/{instructions → server/instructions}/update.js +0 -0
  111. package/lib/{models → server/models}/Execution.d.ts +0 -0
  112. package/lib/{models → server/models}/Execution.js +0 -0
  113. package/lib/{models → server/models}/FlowNode.d.ts +0 -0
  114. package/lib/{models → server/models}/FlowNode.js +0 -0
  115. package/lib/{models → server/models}/Job.d.ts +0 -0
  116. package/lib/{models → server/models}/Job.js +0 -0
  117. package/lib/{models → server/models}/Workflow.d.ts +0 -0
  118. package/lib/{models → server/models}/Workflow.js +0 -0
  119. package/lib/{triggers → server/triggers}/collection.d.ts +0 -0
  120. package/lib/{triggers → server/triggers}/collection.js +0 -0
  121. package/lib/{triggers → server/triggers}/index.d.ts +0 -0
  122. package/lib/{triggers → server/triggers}/index.js +0 -0
  123. package/lib/{triggers → server/triggers}/schedule.d.ts +0 -0
  124. package/lib/{triggers → server/triggers}/schedule.js +2 -2
  125. package/package.json +10 -8
  126. package/server.d.ts +4 -0
  127. package/server.js +30 -0
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ everyText: '每',
9
+ emptyMonths: '每月',
10
+ emptyMonthDays: '每日(月)',
11
+ emptyMonthDaysShort: '每日',
12
+ emptyWeekDays: '每天(周)',
13
+ emptyWeekDaysShort: '每天(周)',
14
+ emptyHours: '每小时',
15
+ emptyMinutes: '每分钟',
16
+ emptyMinutesForHourPeriod: '每',
17
+ yearOption: '年',
18
+ monthOption: '月',
19
+ weekOption: '周',
20
+ dayOption: '天',
21
+ hourOption: '小时',
22
+ minuteOption: '分钟',
23
+ rebootOption: '重启',
24
+ prefixPeriod: '每',
25
+ prefixMonths: '的',
26
+ prefixMonthDays: '的',
27
+ prefixWeekDays: '的',
28
+ prefixWeekDaysForMonthAndYearPeriod: '并且',
29
+ prefixHours: '的',
30
+ prefixMinutes: ':',
31
+ prefixMinutesForHourPeriod: '的',
32
+ suffixMinutesForHourPeriod: '分钟',
33
+ errorInvalidCron: '不符合 cron 规则的表达式',
34
+ clearButtonText: '清空',
35
+ weekDays: [// Order is important, the index will be used as value
36
+ '周日', '周一', '周二', '周三', '周四', '周五', '周六'],
37
+ months: [// Order is important, the index will be used as value
38
+ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
39
+ altWeekDays: [// Order is important, the index will be used as value
40
+ '周日', '周一', '周二', '周三', '周四', '周五', '周六'],
41
+ altMonths: [// Order is important, the index will be used as value
42
+ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
43
+ };
44
+ exports.default = _default;
package/lib/index.d.ts CHANGED
@@ -1,6 +1 @@
1
- export * from './calculators';
2
- export * from './constants';
3
- export * from './instructions';
4
- export * from './triggers';
5
- export * from './Processor';
6
- export { default } from './Plugin';
1
+ export { default } from './server';
package/lib/index.js CHANGED
@@ -3,84 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {};
7
6
  Object.defineProperty(exports, "default", {
8
7
  enumerable: true,
9
8
  get: function get() {
10
- return _Plugin.default;
9
+ return _server.default;
11
10
  }
12
11
  });
13
12
 
14
- var _calculators = require("./calculators");
15
-
16
- Object.keys(_calculators).forEach(function (key) {
17
- if (key === "default" || key === "__esModule") return;
18
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
- if (key in exports && exports[key] === _calculators[key]) return;
20
- Object.defineProperty(exports, key, {
21
- enumerable: true,
22
- get: function get() {
23
- return _calculators[key];
24
- }
25
- });
26
- });
27
-
28
- var _constants = require("./constants");
29
-
30
- Object.keys(_constants).forEach(function (key) {
31
- if (key === "default" || key === "__esModule") return;
32
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
33
- if (key in exports && exports[key] === _constants[key]) return;
34
- Object.defineProperty(exports, key, {
35
- enumerable: true,
36
- get: function get() {
37
- return _constants[key];
38
- }
39
- });
40
- });
41
-
42
- var _instructions = require("./instructions");
43
-
44
- Object.keys(_instructions).forEach(function (key) {
45
- if (key === "default" || key === "__esModule") return;
46
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
- if (key in exports && exports[key] === _instructions[key]) return;
48
- Object.defineProperty(exports, key, {
49
- enumerable: true,
50
- get: function get() {
51
- return _instructions[key];
52
- }
53
- });
54
- });
55
-
56
- var _triggers = require("./triggers");
57
-
58
- Object.keys(_triggers).forEach(function (key) {
59
- if (key === "default" || key === "__esModule") return;
60
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
61
- if (key in exports && exports[key] === _triggers[key]) return;
62
- Object.defineProperty(exports, key, {
63
- enumerable: true,
64
- get: function get() {
65
- return _triggers[key];
66
- }
67
- });
68
- });
69
-
70
- var _Processor = require("./Processor");
71
-
72
- Object.keys(_Processor).forEach(function (key) {
73
- if (key === "default" || key === "__esModule") return;
74
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
75
- if (key in exports && exports[key] === _Processor[key]) return;
76
- Object.defineProperty(exports, key, {
77
- enumerable: true,
78
- get: function get() {
79
- return _Processor[key];
80
- }
81
- });
82
- });
83
-
84
- var _Plugin = _interopRequireDefault(require("./Plugin"));
13
+ var _server = _interopRequireDefault(require("./server"));
85
14
 
86
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
File without changes
File without changes
@@ -29,11 +29,12 @@ export default class Processor {
29
29
  private commit;
30
30
  private exec;
31
31
  run(node: any, input?: any): any;
32
- end(node: any, job: any): any;
33
- recall(node: any, job: any): any;
32
+ end(node: any, job: any): Promise<any>;
33
+ recall(node: any, job: any): Promise<any>;
34
34
  exit(job: JobModel | null): Promise<any>;
35
35
  saveJob(payload: any): Promise<any>;
36
- findBranchStartNode(node: FlowNodeModel): FlowNodeModel | null;
36
+ getBranches(node: FlowNodeModel): FlowNodeModel[];
37
+ findBranchStartNode(node: FlowNodeModel, parent?: FlowNodeModel): FlowNodeModel | null;
37
38
  findBranchParentNode(node: FlowNodeModel): FlowNodeModel | null;
38
39
  findBranchParentJob(job: JobModel, node: FlowNodeModel): JobModel | null;
39
40
  getParsedValue(value: any, node?: any): any;
@@ -281,22 +281,28 @@ class Processor {
281
281
 
282
282
 
283
283
  end(node, job) {
284
- const parentNode = this.findBranchParentNode(node); // no parent, means on main flow
284
+ var _this8 = this;
285
+
286
+ return _asyncToGenerator(function* () {
287
+ const parentNode = _this8.findBranchParentNode(node); // no parent, means on main flow
288
+
285
289
 
286
- if (parentNode) {
287
- return this.recall(parentNode, job);
288
- } // really done for all nodes
289
- // * should mark execution as done with last job status
290
+ if (parentNode) {
291
+ yield _this8.recall(parentNode, job);
292
+ return job;
293
+ } // really done for all nodes
294
+ // * should mark execution as done with last job status
290
295
 
291
296
 
292
- return this.exit(job);
297
+ return _this8.exit(job);
298
+ })();
293
299
  }
294
300
 
295
301
  recall(node, job) {
296
- var _this8 = this;
302
+ var _this9 = this;
297
303
 
298
304
  return _asyncToGenerator(function* () {
299
- const instructions = _this8.options.plugin.instructions;
305
+ const instructions = _this9.options.plugin.instructions;
300
306
 
301
307
  const _instructions$get2 = instructions.get(node.type),
302
308
  resume = _instructions$get2.resume;
@@ -305,19 +311,19 @@ class Processor {
305
311
  return Promise.reject(new Error('`resume` should be implemented'));
306
312
  }
307
313
 
308
- return _this8.exec(resume, node, job);
314
+ return _this9.exec(resume, node, job);
309
315
  })();
310
316
  }
311
317
 
312
318
  exit(job) {
313
- var _this9 = this;
319
+ var _this10 = this;
314
320
 
315
321
  return _asyncToGenerator(function* () {
316
- const status = job ? _this9.constructor.StatusMap[job.status] : _constants.EXECUTION_STATUS.RESOLVED;
317
- yield _this9.execution.update({
322
+ const status = job ? _this10.constructor.StatusMap[job.status] : _constants.EXECUTION_STATUS.RESOLVED;
323
+ yield _this10.execution.update({
318
324
  status
319
325
  }, {
320
- transaction: _this9.transaction
326
+ transaction: _this10.transaction
321
327
  });
322
328
  return null;
323
329
  })();
@@ -325,10 +331,10 @@ class Processor {
325
331
 
326
332
 
327
333
  saveJob(payload) {
328
- var _this10 = this;
334
+ var _this11 = this;
329
335
 
330
336
  return _asyncToGenerator(function* () {
331
- const database = _this10.execution.constructor.database;
337
+ const database = _this11.execution.constructor.database;
332
338
 
333
339
  const _database$getCollecti = database.getCollection('jobs'),
334
340
  model = _database$getCollecti.model;
@@ -337,7 +343,7 @@ class Processor {
337
343
 
338
344
  if (payload instanceof model) {
339
345
  job = yield payload.save({
340
- transaction: _this10.transaction
346
+ transaction: _this11.transaction
341
347
  });
342
348
  } else if (payload.id) {
343
349
  var _yield$model$update = yield model.update(payload, {
@@ -345,7 +351,7 @@ class Processor {
345
351
  id: payload.id
346
352
  },
347
353
  returning: true,
348
- transaction: _this10.transaction
354
+ transaction: _this11.transaction
349
355
  });
350
356
 
351
357
  var _yield$model$update2 = _slicedToArray(_yield$model$update, 1);
@@ -353,24 +359,34 @@ class Processor {
353
359
  job = _yield$model$update2[0];
354
360
  } else {
355
361
  job = yield model.create(_objectSpread(_objectSpread({}, payload), {}, {
356
- executionId: _this10.execution.id
362
+ executionId: _this11.execution.id
357
363
  }), {
358
- transaction: _this10.transaction
364
+ transaction: _this11.transaction
359
365
  });
360
366
  }
361
367
 
362
- _this10.jobsMap.set(job.id, job);
368
+ _this11.jobsMap.set(job.id, job);
363
369
 
364
- _this10.jobsMapByNodeId[job.nodeId] = job.result;
370
+ _this11.jobsMapByNodeId[job.nodeId] = job.result;
365
371
  return job;
366
372
  })();
373
+ }
374
+
375
+ getBranches(node) {
376
+ return this.nodes.filter(item => item.upstream === node && item.branchIndex !== null).sort((a, b) => a.branchIndex - b.branchIndex);
367
377
  } // find the first node in current branch
368
378
 
369
379
 
370
- findBranchStartNode(node) {
380
+ findBranchStartNode(node, parent) {
371
381
  for (let n = node; n; n = n.upstream) {
372
- if (n.branchIndex !== null) {
373
- return n;
382
+ if (!parent) {
383
+ if (n.branchIndex !== null) {
384
+ return n;
385
+ }
386
+ } else {
387
+ if (n.upstream === parent) {
388
+ return n;
389
+ }
374
390
  }
375
391
  }
376
392
 
File without changes
File without changes
File without changes
@@ -153,6 +153,7 @@ function _create() {
153
153
  }
154
154
 
155
155
  instance.set('upstream', upstream);
156
+ return instance;
156
157
  });
157
158
 
158
159
  return function (_x7) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ export * from './calculators';
2
+ export * from './constants';
3
+ export * from './instructions';
4
+ export * from './triggers';
5
+ export * from './Processor';
6
+ export { default } from './Plugin';
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {};
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _Plugin.default;
11
+ }
12
+ });
13
+
14
+ var _calculators = require("./calculators");
15
+
16
+ Object.keys(_calculators).forEach(function (key) {
17
+ if (key === "default" || key === "__esModule") return;
18
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
+ if (key in exports && exports[key] === _calculators[key]) return;
20
+ Object.defineProperty(exports, key, {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _calculators[key];
24
+ }
25
+ });
26
+ });
27
+
28
+ var _constants = require("./constants");
29
+
30
+ Object.keys(_constants).forEach(function (key) {
31
+ if (key === "default" || key === "__esModule") return;
32
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
33
+ if (key in exports && exports[key] === _constants[key]) return;
34
+ Object.defineProperty(exports, key, {
35
+ enumerable: true,
36
+ get: function get() {
37
+ return _constants[key];
38
+ }
39
+ });
40
+ });
41
+
42
+ var _instructions = require("./instructions");
43
+
44
+ Object.keys(_instructions).forEach(function (key) {
45
+ if (key === "default" || key === "__esModule") return;
46
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
47
+ if (key in exports && exports[key] === _instructions[key]) return;
48
+ Object.defineProperty(exports, key, {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _instructions[key];
52
+ }
53
+ });
54
+ });
55
+
56
+ var _triggers = require("./triggers");
57
+
58
+ Object.keys(_triggers).forEach(function (key) {
59
+ if (key === "default" || key === "__esModule") return;
60
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
61
+ if (key in exports && exports[key] === _triggers[key]) return;
62
+ Object.defineProperty(exports, key, {
63
+ enumerable: true,
64
+ get: function get() {
65
+ return _triggers[key];
66
+ }
67
+ });
68
+ });
69
+
70
+ var _Processor = require("./Processor");
71
+
72
+ Object.keys(_Processor).forEach(function (key) {
73
+ if (key === "default" || key === "__esModule") return;
74
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
75
+ if (key in exports && exports[key] === _Processor[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function get() {
79
+ return _Processor[key];
80
+ }
81
+ });
82
+ });
83
+
84
+ var _Plugin = _interopRequireDefault(require("./Plugin"));
85
+
86
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -75,9 +75,15 @@ class _default {
75
75
  status: _constants.JOB_STATUS.PENDING
76
76
  },
77
77
  include: [{
78
- association: 'execution'
78
+ association: 'execution',
79
+ attributes: [],
80
+ where: {
81
+ status: _constants.EXECUTION_STATUS.STARTED
82
+ },
83
+ required: true
79
84
  }, {
80
85
  association: 'node',
86
+ attributes: ['config'],
81
87
  where: {
82
88
  type: 'delay'
83
89
  },
@@ -120,12 +126,13 @@ class _default {
120
126
  var _this3 = this;
121
127
 
122
128
  return _asyncToGenerator(function* () {
123
- const _job$execution = job.execution,
124
- execution = _job$execution === void 0 ? yield job.getExecution() : _job$execution;
129
+ const execution = yield job.getExecution();
125
130
 
126
- const processor = _this3.plugin.createProcessor(execution);
131
+ if (execution.status === _constants.EXECUTION_STATUS.STARTED) {
132
+ const processor = _this3.plugin.createProcessor(execution);
127
133
 
128
- yield processor.resume(job);
134
+ yield processor.resume(job);
135
+ }
129
136
 
130
137
  if (_this3.timers.get(job.id)) {
131
138
  _this3.timers.delete(job.id);
@@ -17,34 +17,68 @@ const PARALLEL_MODE = {
17
17
  RACE: 'race'
18
18
  };
19
19
  exports.PARALLEL_MODE = PARALLEL_MODE;
20
- const StatusGetters = {
21
- [PARALLEL_MODE.ALL](result) {
22
- if (result.some(j => j && j.status === _constants.JOB_STATUS.REJECTED)) {
23
- return _constants.JOB_STATUS.REJECTED;
24
- }
20
+ const Modes = {
21
+ [PARALLEL_MODE.ALL]: {
22
+ next(previous) {
23
+ return previous.status !== _constants.JOB_STATUS.REJECTED;
24
+ },
25
+
26
+ getStatus(result) {
27
+ if (result.some(status => status != null && status === _constants.JOB_STATUS.REJECTED)) {
28
+ return _constants.JOB_STATUS.REJECTED;
29
+ }
30
+
31
+ if (result.every(status => status != null && status === _constants.JOB_STATUS.RESOLVED)) {
32
+ return _constants.JOB_STATUS.RESOLVED;
33
+ }
25
34
 
26
- if (result.every(j => j && j.status === _constants.JOB_STATUS.RESOLVED)) {
27
- return _constants.JOB_STATUS.RESOLVED;
35
+ return _constants.JOB_STATUS.PENDING;
28
36
  }
29
37
 
30
- return _constants.JOB_STATUS.PENDING;
31
38
  },
39
+ [PARALLEL_MODE.ANY]: {
40
+ next(previous) {
41
+ return previous.status !== _constants.JOB_STATUS.RESOLVED;
42
+ },
43
+
44
+ getStatus(result) {
45
+ if (result.some(status => status != null && status === _constants.JOB_STATUS.RESOLVED)) {
46
+ return _constants.JOB_STATUS.RESOLVED;
47
+ }
48
+
49
+ if (result.some(status => status != null ? status === _constants.JOB_STATUS.PENDING : true)) {
50
+ return _constants.JOB_STATUS.PENDING;
51
+ }
52
+
53
+ return _constants.JOB_STATUS.REJECTED;
54
+ }
32
55
 
33
- [PARALLEL_MODE.ANY](result) {
34
- return result.some(j => j && j.status === _constants.JOB_STATUS.RESOLVED) ? _constants.JOB_STATUS.RESOLVED : result.some(j => j && j.status === _constants.JOB_STATUS.PENDING) ? _constants.JOB_STATUS.PENDING : _constants.JOB_STATUS.REJECTED;
35
56
  },
57
+ [PARALLEL_MODE.RACE]: {
58
+ next(previous) {
59
+ return previous.status === _constants.JOB_STATUS.PENDING;
60
+ },
61
+
62
+ getStatus(result) {
63
+ if (result.some(status => status != null && status === _constants.JOB_STATUS.RESOLVED)) {
64
+ return _constants.JOB_STATUS.RESOLVED;
65
+ }
36
66
 
37
- [PARALLEL_MODE.RACE](result) {
38
- return result.some(j => j && j.status === _constants.JOB_STATUS.RESOLVED) ? _constants.JOB_STATUS.RESOLVED : result.some(j => j && j.status === _constants.JOB_STATUS.REJECTED) ? _constants.JOB_STATUS.REJECTED : _constants.JOB_STATUS.PENDING;
39
- }
67
+ if (result.some(status => status != null && status === _constants.JOB_STATUS.REJECTED)) {
68
+ return _constants.JOB_STATUS.REJECTED;
69
+ }
40
70
 
71
+ return _constants.JOB_STATUS.PENDING;
72
+ }
73
+
74
+ }
41
75
  };
42
76
  var _default = {
43
77
  run(node, prevJob, processor) {
44
78
  return _asyncToGenerator(function* () {
45
79
  var _prevJob$id;
46
80
 
47
- const branches = processor.nodes.filter(item => item.upstream === node && item.branchIndex !== null).sort((a, b) => a.branchIndex - b.branchIndex);
81
+ const branches = processor.getBranches(node);
48
82
  const job = yield processor.saveJob({
49
83
  status: _constants.JOB_STATUS.PENDING,
50
84
  result: Array(branches.length).fill(null),
@@ -56,7 +90,15 @@ var _default = {
56
90
  // because of the delay is not significant sensible.
57
91
  // another benifit of this is, it could handle sequenced branches in future.
58
92
 
59
- yield branches.reduce((promise, branch) => promise.then(() => processor.run(branch, job)), Promise.resolve());
93
+ const _node$config$mode = node.config.mode,
94
+ mode = _node$config$mode === void 0 ? PARALLEL_MODE.ALL : _node$config$mode;
95
+ yield branches.reduce((promise, branch, i) => promise.then(previous => {
96
+ if (i && !Modes[mode].next(previous)) {
97
+ return Promise.resolve(previous);
98
+ }
99
+
100
+ return processor.run(branch, job);
101
+ }), Promise.resolve());
60
102
  return processor.end(node, job);
61
103
  })();
62
104
  },
@@ -73,18 +115,18 @@ var _default = {
73
115
 
74
116
 
75
117
  const jobNode = processor.nodesMap.get(branchJob.nodeId);
76
-
77
- const _processor$findBranch = processor.findBranchStartNode(jobNode),
78
- branchIndex = _processor$findBranch.branchIndex;
118
+ const branchStartNode = processor.findBranchStartNode(jobNode, node);
119
+ const branches = processor.getBranches(node);
120
+ const branchIndex = branches.indexOf(branchStartNode);
79
121
 
80
122
  const _ref = node.config || {},
81
123
  _ref$mode = _ref.mode,
82
124
  mode = _ref$mode === void 0 ? PARALLEL_MODE.ALL : _ref$mode;
83
125
 
84
- const newResult = [...result.slice(0, branchIndex), branchJob.get(), ...result.slice(branchIndex + 1)];
126
+ const newResult = [...result.slice(0, branchIndex), branchJob.status, ...result.slice(branchIndex + 1)];
85
127
  job.set({
86
128
  result: newResult,
87
- status: StatusGetters[mode](newResult)
129
+ status: Modes[mode].getStatus(newResult)
88
130
  });
89
131
 
90
132
  if (job.status === _constants.JOB_STATUS.PENDING) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes