@nocobase/plugin-workflow 0.9.1-alpha.2 → 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 (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,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  function _default() {
9
8
  return {
10
- namespace: 'workflow',
9
+ namespace: 'workflow.workflowConfig',
11
10
  duplicator: 'required',
12
11
  name: 'workflows',
13
12
  fields: [{
@@ -35,8 +34,8 @@ function _default() {
35
34
  defaultValue: {}
36
35
  }, {
37
36
  type: 'boolean',
38
- name: 'useTransaction',
39
- defaultValue: true
37
+ name: 'useTransaction'
38
+ // defaultValue: true,
40
39
  }, {
41
40
  type: 'hasMany',
42
41
  name: 'nodes',
@@ -0,0 +1,8 @@
1
+ import { DataTypes } from 'sequelize';
2
+ import { BaseFieldOptions, Field } from '@nocobase/database';
3
+ export interface ExpressionFieldOptions extends BaseFieldOptions {
4
+ type: 'expression';
5
+ }
6
+ export declare class ExpressionField extends Field {
7
+ get dataType(): DataTypes.TextDataTypeConstructor;
8
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ExpressionField = void 0;
7
+ function _sequelize() {
8
+ const data = require("sequelize");
9
+ _sequelize = function _sequelize() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _database() {
15
+ const data = require("@nocobase/database");
16
+ _database = function _database() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ class ExpressionField extends _database().Field {
22
+ get dataType() {
23
+ return _sequelize().DataTypes.TEXT;
24
+ }
25
+ }
26
+ exports.ExpressionField = ExpressionField;
@@ -0,0 +1 @@
1
+ export default function (plugin: any): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ var _expressionField = require("./expression-field");
8
+ function _default(plugin) {
9
+ plugin.db.registerFieldTypes({
10
+ expression: _expressionField.ExpressionField
11
+ });
12
+ }
@@ -4,35 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = _default;
7
-
8
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
-
10
8
  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."); }
11
-
12
9
  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); }
13
-
14
10
  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; }
15
-
16
- 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; }
17
-
11
+ 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; } }
18
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
-
20
13
  function now() {
21
14
  return new Date();
22
15
  }
23
-
24
16
  function _default({
25
17
  functions
26
18
  }, more = {}) {
27
19
  functions.register('now', now);
28
-
29
20
  for (var _i = 0, _Object$entries = Object.entries(more); _i < _Object$entries.length; _i++) {
30
21
  const _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
31
- name = _Object$entries$_i[0],
32
- fn = _Object$entries$_i[1];
33
-
22
+ name = _Object$entries$_i[0],
23
+ fn = _Object$entries$_i[1];
34
24
  functions.register(name, fn);
35
25
  }
36
26
  }
37
-
38
27
  ;
@@ -25,9 +25,7 @@ Object.defineProperty(exports, "default", {
25
25
  return _Plugin.default;
26
26
  }
27
27
  });
28
-
29
28
  var _constants = require("./constants");
30
-
31
29
  Object.keys(_constants).forEach(function (key) {
32
30
  if (key === "default" || key === "__esModule") return;
33
31
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -39,11 +37,7 @@ Object.keys(_constants).forEach(function (key) {
39
37
  }
40
38
  });
41
39
  });
42
-
43
40
  var _triggers = require("./triggers");
44
-
45
41
  var _Processor = _interopRequireDefault(require("./Processor"));
46
-
47
42
  var _Plugin = _interopRequireDefault(require("./Plugin"));
48
-
49
43
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4,38 +4,44 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
7
+ function _jsonTemplates() {
8
+ const data = _interopRequireDefault(require("json-templates"));
9
+ _jsonTemplates = function _jsonTemplates() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
8
14
  function _evaluators() {
9
15
  const data = _interopRequireDefault(require("@nocobase/evaluators"));
10
-
11
16
  _evaluators = function _evaluators() {
12
17
  return data;
13
18
  };
14
-
15
19
  return data;
16
20
  }
17
-
18
21
  var _constants = require("../constants");
19
-
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
23
  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); } }
23
-
24
24
  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); }); }; }
25
-
26
25
  var _default = {
27
26
  run(node, prevJob, processor) {
28
27
  return _asyncToGenerator(function* () {
29
28
  const _ref = node.config || {},
30
- _ref$engine = _ref.engine,
31
- engine = _ref$engine === void 0 ? 'math.js' : _ref$engine,
32
- _ref$expression = _ref.expression,
33
- expression = _ref$expression === void 0 ? '' : _ref$expression;
34
-
29
+ _ref$dynamic = _ref.dynamic,
30
+ dynamic = _ref$dynamic === void 0 ? false : _ref$dynamic;
31
+ let _node$config = node.config,
32
+ _node$config$engine = _node$config.engine,
33
+ engine = _node$config$engine === void 0 ? 'math.js' : _node$config$engine,
34
+ _node$config$expressi = _node$config.expression,
35
+ expression = _node$config$expressi === void 0 ? '' : _node$config$expressi;
36
+ let scope = processor.getScope();
37
+ if (dynamic) {
38
+ var _parse, _parse2, _node$config$scope;
39
+ const parsed = (_parse = (0, _jsonTemplates().default)(dynamic)(scope)) !== null && _parse !== void 0 ? _parse : {};
40
+ engine = parsed.engine;
41
+ expression = parsed.expression;
42
+ scope = (_parse2 = (0, _jsonTemplates().default)((_node$config$scope = node.config.scope) !== null && _node$config$scope !== void 0 ? _node$config$scope : '')(scope)) !== null && _parse2 !== void 0 ? _parse2 : {};
43
+ }
35
44
  const evaluator = _evaluators().default.get(engine);
36
-
37
- const scope = processor.getScope();
38
-
39
45
  try {
40
46
  const result = evaluator && expression ? evaluator(expression, scope) : null;
41
47
  return {
@@ -50,6 +56,5 @@ var _default = {
50
56
  }
51
57
  })();
52
58
  }
53
-
54
59
  };
55
60
  exports.default = _default;
@@ -4,63 +4,45 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.calculators = void 0;
7
-
8
7
  function _utils() {
9
8
  const data = require("@nocobase/utils");
10
-
11
9
  _utils = function _utils() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _evaluators() {
19
15
  const data = _interopRequireDefault(require("@nocobase/evaluators"));
20
-
21
16
  _evaluators = function _evaluators() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  var _constants = require("../constants");
29
-
30
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
23
  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); } }
33
-
34
24
  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); }); }; }
35
-
36
- const calculators = new (_utils().Registry)(); // built-in functions
37
-
25
+ const calculators = new (_utils().Registry)();
26
+ // built-in functions
38
27
  exports.calculators = calculators;
39
-
40
28
  function equal(a, b) {
41
29
  return a === b;
42
30
  }
43
-
44
31
  function notEqual(a, b) {
45
32
  return a !== b;
46
33
  }
47
-
48
34
  function gt(a, b) {
49
35
  return a > b;
50
36
  }
51
-
52
37
  function gte(a, b) {
53
38
  return a >= b;
54
39
  }
55
-
56
40
  function lt(a, b) {
57
41
  return a < b;
58
42
  }
59
-
60
43
  function lte(a, b) {
61
44
  return a <= b;
62
45
  }
63
-
64
46
  calculators.register('equal', equal);
65
47
  calculators.register('notEqual', notEqual);
66
48
  calculators.register('gt', gt);
@@ -73,78 +55,59 @@ calculators.register('>', gt);
73
55
  calculators.register('>=', gte);
74
56
  calculators.register('<', lt);
75
57
  calculators.register('<=', lte);
76
-
77
58
  function includes(a, b) {
78
59
  return a.includes(b);
79
60
  }
80
-
81
61
  function notIncludes(a, b) {
82
62
  return !a.includes(b);
83
63
  }
84
-
85
64
  function startsWith(a, b) {
86
65
  return a.startsWith(b);
87
66
  }
88
-
89
67
  function notStartsWith(a, b) {
90
68
  return !a.startsWith(b);
91
69
  }
92
-
93
70
  function endsWith(a, b) {
94
71
  return a.endsWith(b);
95
72
  }
96
-
97
73
  function notEndsWith(a, b) {
98
74
  return !a.endsWith(b);
99
75
  }
100
-
101
76
  calculators.register('includes', includes);
102
77
  calculators.register('notIncludes', notIncludes);
103
78
  calculators.register('startsWith', startsWith);
104
79
  calculators.register('notStartsWith', notStartsWith);
105
80
  calculators.register('endsWith', endsWith);
106
81
  calculators.register('notEndsWith', notEndsWith);
107
-
108
82
  function calculate(calculation = {}) {
109
83
  var _calculation$operands;
110
-
111
84
  let fn;
112
-
113
85
  if (!(calculation.calculator && (fn = calculators.get(calculation.calculator)))) {
114
86
  throw new Error(`no calculator function registered for "${calculation.calculator}"`);
115
87
  }
116
-
117
88
  return Boolean(fn(...((_calculation$operands = calculation.operands) !== null && _calculation$operands !== void 0 ? _calculation$operands : [])));
118
89
  }
119
-
120
90
  function logicCalculate(calculation) {
121
91
  if (!calculation) {
122
92
  return true;
123
93
  }
124
-
125
94
  if (typeof calculation['group'] === 'object') {
126
95
  var _calculation$group$ca;
127
-
128
96
  const method = calculation['group'].type === 'and' ? 'every' : 'some';
129
97
  return ((_calculation$group$ca = calculation['group'].calculations) !== null && _calculation$group$ca !== void 0 ? _calculation$group$ca : [])[method](item => logicCalculate(item));
130
98
  }
131
-
132
99
  return calculate(calculation);
133
100
  }
134
-
135
101
  var _default = {
136
102
  run(node, prevJob, processor) {
137
103
  return _asyncToGenerator(function* () {
138
104
  const _ref = node.config || {},
139
- engine = _ref.engine,
140
- calculation = _ref.calculation,
141
- expression = _ref.expression,
142
- rejectOnFalse = _ref.rejectOnFalse;
143
-
105
+ engine = _ref.engine,
106
+ calculation = _ref.calculation,
107
+ expression = _ref.expression,
108
+ rejectOnFalse = _ref.rejectOnFalse;
144
109
  const evaluator = _evaluators().default.get(engine);
145
-
146
110
  let result = true;
147
-
148
111
  try {
149
112
  result = evaluator ? evaluator(expression, processor.getScope()) : logicCalculate(processor.getParsedValue(calculation));
150
113
  } catch (e) {
@@ -153,14 +116,12 @@ var _default = {
153
116
  status: _constants.JOB_STATUS.ERROR
154
117
  };
155
118
  }
156
-
157
119
  if (!result && rejectOnFalse) {
158
120
  return {
159
121
  status: _constants.JOB_STATUS.FAILED,
160
122
  result
161
123
  };
162
124
  }
163
-
164
125
  const job = {
165
126
  status: _constants.JOB_STATUS.RESOLVED,
166
127
  result,
@@ -169,27 +130,22 @@ var _default = {
169
130
  upstreamId: prevJob && prevJob.id || null
170
131
  };
171
132
  const branchNode = processor.nodes.find(item => item.upstream === node && Boolean(item.branchIndex) === result);
172
-
173
133
  if (!branchNode) {
174
134
  return job;
175
135
  }
176
-
177
136
  const savedJob = yield processor.saveJob(job);
178
137
  return processor.run(branchNode, savedJob);
179
138
  })();
180
139
  },
181
-
182
140
  resume(node, branchJob, processor) {
183
141
  return _asyncToGenerator(function* () {
184
142
  if (branchJob.status === _constants.JOB_STATUS.RESOLVED) {
185
143
  // return to continue node.downstream
186
144
  return branchJob;
187
- } // pass control to upper scope by ending current scope
188
-
189
-
145
+ }
146
+ // pass control to upper scope by ending current scope
190
147
  return processor.end(node, branchJob);
191
148
  })();
192
149
  }
193
-
194
150
  };
195
151
  exports.default = _default;
@@ -4,41 +4,57 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _constants = require("../constants");
9
-
8
+ const _excluded = ["appends"];
10
9
  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; }
11
-
12
10
  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; }
13
-
14
- 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; }
15
-
11
+ 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; }
12
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
+ 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); }
14
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
16
  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); } }
17
-
18
17
  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); }); }; }
19
-
20
18
  var _default = {
21
19
  run(node, input, processor) {
22
20
  return _asyncToGenerator(function* () {
23
21
  const _node$config = node.config,
24
- collection = _node$config.collection,
25
- _node$config$params = _node$config.params,
26
- params = _node$config$params === void 0 ? {} : _node$config$params;
27
- const repo = node.constructor.database.getRepository(collection);
22
+ collection = _node$config.collection,
23
+ _node$config$params = _node$config.params,
24
+ _node$config$params2 = _node$config$params === void 0 ? {} : _node$config$params,
25
+ _node$config$params2$ = _node$config$params2.appends,
26
+ appends = _node$config$params2$ === void 0 ? [] : _node$config$params2$,
27
+ params = _objectWithoutProperties(_node$config$params2, _excluded);
28
+ const _node$constructor$dat = node.constructor.database.getCollection(collection),
29
+ repository = _node$constructor$dat.repository,
30
+ model = _node$constructor$dat.model;
28
31
  const options = processor.getParsedValue(params);
29
- const result = yield repo.create(_objectSpread(_objectSpread({}, options), {}, {
32
+ const result = yield repository.create(_objectSpread(_objectSpread({}, options), {}, {
30
33
  context: {
31
34
  executionId: processor.execution.id
32
35
  },
33
36
  transaction: processor.transaction
34
37
  }));
38
+ if (result && appends.length) {
39
+ const includeFields = appends.filter(field => !result.get(field) || !result[field]);
40
+ const included = yield model.findByPk(result[model.primaryKeyAttribute], {
41
+ attributes: [model.primaryKeyAttribute],
42
+ include: includeFields,
43
+ transaction: processor.transaction
44
+ });
45
+ includeFields.forEach(field => {
46
+ const value = included.get(field);
47
+ result.set(field, Array.isArray(value) ? value.map(item => item.toJSON()) : value.toJSON(), {
48
+ raw: true
49
+ });
50
+ });
51
+ }
35
52
  return {
36
53
  // NOTE: get() for non-proxied instance (#380)
37
- result: result.get(),
54
+ result: result === null || result === void 0 ? void 0 : result.toJSON(),
38
55
  status: _constants.JOB_STATUS.RESOLVED
39
56
  };
40
57
  })();
41
58
  }
42
-
43
59
  };
44
60
  exports.default = _default;
@@ -4,72 +4,54 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _constants = require("../constants");
9
-
10
8
  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(_e) { throw _e; }, 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(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
-
12
9
  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); }
13
-
14
10
  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; }
15
-
16
11
  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); } }
17
-
18
12
  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); }); }; }
19
-
20
13
  class _default {
21
14
  constructor(plugin) {
22
15
  var _this = this;
23
-
24
16
  this.plugin = void 0;
25
17
  this.timers = new Map();
26
-
27
18
  this.run = /*#__PURE__*/function () {
28
19
  var _ref = _asyncToGenerator(function* (node, prevJob, processor) {
29
20
  var _prevJob$id;
30
-
31
21
  const job = yield processor.saveJob({
32
22
  status: _constants.JOB_STATUS.PENDING,
33
23
  result: null,
34
24
  nodeId: node.id,
35
25
  upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
36
26
  });
37
- const duration = node.config.duration; // add to schedule
38
-
27
+ const duration = node.config.duration;
28
+ // add to schedule
39
29
  _this.schedule(job, duration);
40
-
41
30
  return processor.end(node, job);
42
31
  });
43
-
44
32
  return function (_x, _x2, _x3) {
45
33
  return _ref.apply(this, arguments);
46
34
  };
47
35
  }();
48
-
49
36
  this.resume = /*#__PURE__*/function () {
50
37
  var _ref2 = _asyncToGenerator(function* (node, prevJob, processor) {
51
38
  const endStatus = node.config.endStatus;
52
39
  prevJob.set('status', endStatus);
53
40
  return prevJob;
54
41
  });
55
-
56
42
  return function (_x4, _x5, _x6) {
57
43
  return _ref2.apply(this, arguments);
58
44
  };
59
45
  }();
60
-
61
46
  this.plugin = plugin;
62
47
  plugin.app.on('beforeStart', () => this.load());
63
48
  plugin.app.on('beforeStop', () => this.unload());
64
49
  }
65
-
66
50
  load() {
67
51
  var _this2 = this;
68
-
69
52
  return _asyncToGenerator(function* () {
70
53
  const _this2$plugin$db$getC = _this2.plugin.db.getCollection('jobs'),
71
- model = _this2$plugin$db$getC.model;
72
-
54
+ model = _this2$plugin$db$getC.model;
73
55
  const jobs = yield model.findAll({
74
56
  where: {
75
57
  status: _constants.JOB_STATUS.PENDING
@@ -95,11 +77,9 @@ class _default {
95
77
  });
96
78
  })();
97
79
  }
98
-
99
80
  unload() {
100
81
  var _iterator = _createForOfIteratorHelper(this.timers.values()),
101
- _step;
102
-
82
+ _step;
103
83
  try {
104
84
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
105
85
  const timer = _step.value;
@@ -110,10 +90,8 @@ class _default {
110
90
  } finally {
111
91
  _iterator.f();
112
92
  }
113
-
114
93
  this.timers = new Map();
115
94
  }
116
-
117
95
  schedule(job, duration) {
118
96
  const now = new Date();
119
97
  const createdAt = Date.parse(job.createdAt);
@@ -121,24 +99,18 @@ class _default {
121
99
  const trigger = this.trigger.bind(this, job);
122
100
  this.timers.set(job.id, setTimeout(trigger, Math.max(0, delay)));
123
101
  }
124
-
125
102
  trigger(job) {
126
103
  var _this3 = this;
127
-
128
104
  return _asyncToGenerator(function* () {
129
105
  const execution = yield job.getExecution();
130
-
131
106
  if (execution.status === _constants.EXECUTION_STATUS.STARTED) {
132
107
  job.execution = execution;
133
108
  yield _this3.plugin.resume(job);
134
109
  }
135
-
136
110
  if (_this3.timers.get(job.id)) {
137
111
  _this3.timers.delete(job.id);
138
112
  }
139
113
  })();
140
114
  }
141
-
142
115
  }
143
-
144
116
  exports.default = _default;
@@ -4,26 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _constants = require("../constants");
9
-
10
8
  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; }
11
-
12
9
  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; }
13
-
14
- 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; }
15
-
10
+ 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; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
+ 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); }
16
13
  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); } }
17
-
18
14
  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); }); }; }
19
-
20
15
  var _default = {
21
16
  run(node, input, processor) {
22
17
  return _asyncToGenerator(function* () {
23
18
  const _node$config = node.config,
24
- collection = _node$config.collection,
25
- _node$config$params = _node$config.params,
26
- params = _node$config$params === void 0 ? {} : _node$config$params;
19
+ collection = _node$config.collection,
20
+ _node$config$params = _node$config.params,
21
+ params = _node$config$params === void 0 ? {} : _node$config$params;
27
22
  const repo = node.constructor.database.getRepository(collection);
28
23
  const options = processor.getParsedValue(params);
29
24
  const result = yield repo.destroy(_objectSpread(_objectSpread({}, options), {}, {
@@ -38,6 +33,5 @@ var _default = {
38
33
  };
39
34
  })();
40
35
  }
41
-
42
36
  };
43
37
  exports.default = _default;