@nocobase/plugin-workflow 0.7.0-alpha.4 → 0.7.0-alpha.58

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 (141) hide show
  1. package/lib/actions/index.d.ts +3 -1
  2. package/lib/actions/index.js +33 -26
  3. package/{esm/actions/flow_nodes.d.ts → lib/actions/nodes.d.ts} +1 -0
  4. package/lib/actions/nodes.js +321 -0
  5. package/lib/actions/workflows.d.ts +3 -0
  6. package/lib/actions/workflows.js +271 -0
  7. package/lib/calculators/index.js +143 -91
  8. package/lib/collections/executions.js +40 -38
  9. package/lib/collections/flow_nodes.js +60 -72
  10. package/lib/collections/jobs.js +45 -47
  11. package/lib/collections/workflows.js +78 -63
  12. package/lib/constants.js +22 -17
  13. package/lib/index.js +71 -22
  14. package/lib/instructions/calculation.js +34 -29
  15. package/lib/instructions/condition.js +94 -87
  16. package/lib/instructions/create.d.ts +1 -1
  17. package/lib/instructions/create.js +43 -25
  18. package/lib/instructions/destroy.js +42 -25
  19. package/lib/instructions/index.js +46 -25
  20. package/lib/instructions/parallel.js +99 -84
  21. package/lib/instructions/prompt.js +21 -13
  22. package/lib/instructions/query.js +46 -25
  23. package/lib/instructions/update.d.ts +2 -1
  24. package/lib/instructions/update.js +44 -25
  25. package/lib/models/Execution.d.ts +3 -2
  26. package/lib/models/Execution.js +400 -241
  27. package/lib/models/FlowNode.js +18 -5
  28. package/lib/models/Job.js +18 -5
  29. package/lib/models/Workflow.d.ts +4 -5
  30. package/lib/models/Workflow.js +95 -72
  31. package/lib/server.d.ts +7 -2
  32. package/lib/server.js +114 -65
  33. package/lib/triggers/collection.d.ts +16 -0
  34. package/lib/triggers/collection.js +162 -0
  35. package/lib/triggers/index.d.ts +3 -6
  36. package/lib/triggers/index.js +14 -11
  37. package/package.json +7 -12
  38. package/esm/actions/flow_nodes.js +0 -139
  39. package/esm/actions/flow_nodes.js.map +0 -1
  40. package/esm/actions/index.d.ts +0 -1
  41. package/esm/actions/index.js +0 -8
  42. package/esm/actions/index.js.map +0 -1
  43. package/esm/calculators/index.d.ts +0 -38
  44. package/esm/calculators/index.js +0 -128
  45. package/esm/calculators/index.js.map +0 -1
  46. package/esm/collections/executions.d.ts +0 -3
  47. package/esm/collections/executions.js +0 -38
  48. package/esm/collections/executions.js.map +0 -1
  49. package/esm/collections/flow_nodes.d.ts +0 -3
  50. package/esm/collections/flow_nodes.js +0 -72
  51. package/esm/collections/flow_nodes.js.map +0 -1
  52. package/esm/collections/jobs.d.ts +0 -3
  53. package/esm/collections/jobs.js +0 -47
  54. package/esm/collections/jobs.js.map +0 -1
  55. package/esm/collections/workflows.d.ts +0 -3
  56. package/esm/collections/workflows.js +0 -63
  57. package/esm/collections/workflows.js.map +0 -1
  58. package/esm/constants.d.ts +0 -17
  59. package/esm/constants.js +0 -18
  60. package/esm/constants.js.map +0 -1
  61. package/esm/index.d.ts +0 -5
  62. package/esm/index.js +0 -6
  63. package/esm/index.js.map +0 -1
  64. package/esm/instructions/calculation.d.ts +0 -8
  65. package/esm/instructions/calculation.js +0 -55
  66. package/esm/instructions/calculation.js.map +0 -1
  67. package/esm/instructions/condition.d.ts +0 -5
  68. package/esm/instructions/condition.js +0 -99
  69. package/esm/instructions/condition.js.map +0 -1
  70. package/esm/instructions/create.d.ts +0 -8
  71. package/esm/instructions/create.js +0 -25
  72. package/esm/instructions/create.js.map +0 -1
  73. package/esm/instructions/destroy.d.ts +0 -8
  74. package/esm/instructions/destroy.js +0 -25
  75. package/esm/instructions/destroy.js.map +0 -1
  76. package/esm/instructions/index.d.ts +0 -15
  77. package/esm/instructions/index.js +0 -20
  78. package/esm/instructions/index.js.map +0 -1
  79. package/esm/instructions/parallel.d.ts +0 -13
  80. package/esm/instructions/parallel.js +0 -88
  81. package/esm/instructions/parallel.js.map +0 -1
  82. package/esm/instructions/prompt.d.ts +0 -7
  83. package/esm/instructions/prompt.js +0 -13
  84. package/esm/instructions/prompt.js.map +0 -1
  85. package/esm/instructions/query.d.ts +0 -8
  86. package/esm/instructions/query.js +0 -25
  87. package/esm/instructions/query.js.map +0 -1
  88. package/esm/instructions/update.d.ts +0 -8
  89. package/esm/instructions/update.js +0 -25
  90. package/esm/instructions/update.js.map +0 -1
  91. package/esm/models/Execution.d.ts +0 -50
  92. package/esm/models/Execution.js +0 -250
  93. package/esm/models/Execution.js.map +0 -1
  94. package/esm/models/FlowNode.d.ts +0 -17
  95. package/esm/models/FlowNode.js +0 -4
  96. package/esm/models/FlowNode.js.map +0 -1
  97. package/esm/models/Job.d.ts +0 -15
  98. package/esm/models/Job.js +0 -4
  99. package/esm/models/Job.js.map +0 -1
  100. package/esm/models/Workflow.d.ts +0 -27
  101. package/esm/models/Workflow.js +0 -72
  102. package/esm/models/Workflow.js.map +0 -1
  103. package/esm/server.d.ts +0 -5
  104. package/esm/server.js +0 -62
  105. package/esm/server.js.map +0 -1
  106. package/esm/triggers/index.d.ts +0 -9
  107. package/esm/triggers/index.js +0 -6
  108. package/esm/triggers/index.js.map +0 -1
  109. package/esm/triggers/model.d.ts +0 -12
  110. package/esm/triggers/model.js +0 -47
  111. package/esm/triggers/model.js.map +0 -1
  112. package/lib/actions/flow_nodes.d.ts +0 -3
  113. package/lib/actions/flow_nodes.js +0 -163
  114. package/lib/actions/flow_nodes.js.map +0 -1
  115. package/lib/actions/index.js.map +0 -1
  116. package/lib/calculators/index.js.map +0 -1
  117. package/lib/collections/executions.js.map +0 -1
  118. package/lib/collections/flow_nodes.js.map +0 -1
  119. package/lib/collections/jobs.js.map +0 -1
  120. package/lib/collections/workflows.js.map +0 -1
  121. package/lib/constants.js.map +0 -1
  122. package/lib/index.js.map +0 -1
  123. package/lib/instructions/calculation.js.map +0 -1
  124. package/lib/instructions/condition.js.map +0 -1
  125. package/lib/instructions/create.js.map +0 -1
  126. package/lib/instructions/destroy.js.map +0 -1
  127. package/lib/instructions/index.js.map +0 -1
  128. package/lib/instructions/parallel.js.map +0 -1
  129. package/lib/instructions/prompt.js.map +0 -1
  130. package/lib/instructions/query.js.map +0 -1
  131. package/lib/instructions/update.js.map +0 -1
  132. package/lib/models/Execution.js.map +0 -1
  133. package/lib/models/FlowNode.js.map +0 -1
  134. package/lib/models/Job.js.map +0 -1
  135. package/lib/models/Workflow.js.map +0 -1
  136. package/lib/server.js.map +0 -1
  137. package/lib/triggers/index.js.map +0 -1
  138. package/lib/triggers/model.d.ts +0 -12
  139. package/lib/triggers/model.js +0 -49
  140. package/lib/triggers/model.js.map +0 -1
  141. package/tsconfig.build.json +0 -9
@@ -1,27 +1,44 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ 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
+ 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
+
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
+ 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
+ var _default = {
21
+ run(input, execution) {
22
+ var _this = this;
23
+
24
+ return _asyncToGenerator(function* () {
25
+ const _this$config = _this.config,
26
+ collection = _this$config.collection,
27
+ _this$config$params = _this$config.params,
28
+ params = _this$config$params === void 0 ? {} : _this$config$params;
29
+
30
+ const repo = _this.constructor.database.getRepository(collection);
31
+
32
+ const options = execution.getParsedValue(params);
33
+ const result = yield repo.destroy(_objectSpread(_objectSpread({}, options), {}, {
34
+ transaction: execution.tx
35
+ }));
36
+ return {
37
+ result,
38
+ status: _constants.JOB_STATUS.RESOLVED
39
+ };
40
+ })();
41
+ }
42
+
10
43
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const constants_1 = require("../constants");
13
- exports.default = {
14
- run(input, execution) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const { collection, params = {} } = this.config;
17
- const repo = this.constructor.database.getRepository(collection);
18
- const options = execution.getParsedValue(params);
19
- const result = yield repo.destroy(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
20
- return {
21
- result,
22
- status: constants_1.JOB_STATUS.RESOLVED
23
- };
24
- });
25
- }
26
- };
27
- //# sourceMappingURL=destroy.js.map
44
+ exports.default = _default;
@@ -1,26 +1,47 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.instructions = void 0;
7
- const utils_1 = require("@nocobase/utils");
8
- const prompt_1 = __importDefault(require("./prompt"));
9
- const calculation_1 = __importDefault(require("./calculation"));
10
- const condition_1 = __importDefault(require("./condition"));
11
- const parallel_1 = __importDefault(require("./parallel"));
12
- const query_1 = __importDefault(require("./query"));
13
- const create_1 = __importDefault(require("./create"));
14
- const update_1 = __importDefault(require("./update"));
15
- const destroy_1 = __importDefault(require("./destroy"));
16
- exports.instructions = new utils_1.Registry();
17
- exports.instructions.register('prompt', prompt_1.default);
18
- exports.instructions.register('calculation', calculation_1.default);
19
- exports.instructions.register('condition', condition_1.default);
20
- exports.instructions.register('parallel', parallel_1.default);
21
- exports.instructions.register('query', query_1.default);
22
- exports.instructions.register('create', create_1.default);
23
- exports.instructions.register('update', update_1.default);
24
- exports.instructions.register('destroy', destroy_1.default);
25
- exports.default = exports.instructions;
26
- //# sourceMappingURL=index.js.map
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.instructions = exports.default = void 0;
7
+
8
+ function _utils() {
9
+ const data = require("@nocobase/utils");
10
+
11
+ _utils = function _utils() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ var _prompt = _interopRequireDefault(require("./prompt"));
19
+
20
+ var _calculation = _interopRequireDefault(require("./calculation"));
21
+
22
+ var _condition = _interopRequireDefault(require("./condition"));
23
+
24
+ var _parallel = _interopRequireDefault(require("./parallel"));
25
+
26
+ var _query = _interopRequireDefault(require("./query"));
27
+
28
+ var _create = _interopRequireDefault(require("./create"));
29
+
30
+ var _update = _interopRequireDefault(require("./update"));
31
+
32
+ var _destroy = _interopRequireDefault(require("./destroy"));
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
+
36
+ const instructions = new (_utils().Registry)();
37
+ exports.instructions = instructions;
38
+ instructions.register('prompt', _prompt.default);
39
+ instructions.register('calculation', _calculation.default);
40
+ instructions.register('condition', _condition.default);
41
+ instructions.register('parallel', _parallel.default);
42
+ instructions.register('query', _query.default);
43
+ instructions.register('create', _create.default);
44
+ instructions.register('update', _update.default);
45
+ instructions.register('destroy', _destroy.default);
46
+ var _default = instructions;
47
+ exports.default = _default;
@@ -1,91 +1,106 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PARALLEL_MODE = void 0;
13
- const constants_1 = require("../constants");
14
- exports.PARALLEL_MODE = {
15
- ALL: 'all',
16
- ANY: 'any',
17
- RACE: 'race'
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.PARALLEL_MODE = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ 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); } }
11
+
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); }); }; }
13
+
14
+ const PARALLEL_MODE = {
15
+ ALL: 'all',
16
+ ANY: 'any',
17
+ RACE: 'race'
18
18
  };
19
+ exports.PARALLEL_MODE = PARALLEL_MODE;
19
20
  const StatusGetters = {
20
- [exports.PARALLEL_MODE.ALL](result) {
21
- if (result.some(j => j && j.status === constants_1.JOB_STATUS.REJECTED)) {
22
- return constants_1.JOB_STATUS.REJECTED;
23
- }
24
- if (result.every(j => j && j.status === constants_1.JOB_STATUS.RESOLVED)) {
25
- return constants_1.JOB_STATUS.RESOLVED;
26
- }
27
- return constants_1.JOB_STATUS.PENDING;
28
- },
29
- [exports.PARALLEL_MODE.ANY](result) {
30
- return result.some(j => j && j.status === constants_1.JOB_STATUS.RESOLVED)
31
- ? constants_1.JOB_STATUS.RESOLVED
32
- : (result.some(j => j && j.status === constants_1.JOB_STATUS.PENDING)
33
- ? constants_1.JOB_STATUS.PENDING
34
- : constants_1.JOB_STATUS.REJECTED);
35
- },
36
- [exports.PARALLEL_MODE.RACE](result) {
37
- return result.some(j => j && j.status === constants_1.JOB_STATUS.RESOLVED)
38
- ? constants_1.JOB_STATUS.RESOLVED
39
- : (result.some(j => j && j.status === constants_1.JOB_STATUS.REJECTED)
40
- ? constants_1.JOB_STATUS.REJECTED
41
- : constants_1.JOB_STATUS.PENDING);
21
+ [PARALLEL_MODE.ALL](result) {
22
+ if (result.some(j => j && j.status === _constants.JOB_STATUS.REJECTED)) {
23
+ return _constants.JOB_STATUS.REJECTED;
24
+ }
25
+
26
+ if (result.every(j => j && j.status === _constants.JOB_STATUS.RESOLVED)) {
27
+ return _constants.JOB_STATUS.RESOLVED;
42
28
  }
29
+
30
+ return _constants.JOB_STATUS.PENDING;
31
+ },
32
+
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
+ },
36
+
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
+ }
40
+
43
41
  };
44
- exports.default = {
45
- run(prevJob, execution) {
46
- var _a;
47
- return __awaiter(this, void 0, void 0, function* () {
48
- const branches = execution.nodes
49
- .filter(item => item.upstream === this && item.branchIndex !== null)
50
- .sort((a, b) => a.branchIndex - b.branchIndex);
51
- const job = yield execution.saveJob({
52
- status: constants_1.JOB_STATUS.PENDING,
53
- result: Array(branches.length).fill(null),
54
- nodeId: this.id,
55
- upstreamId: (_a = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _a !== void 0 ? _a : null
56
- });
57
- // NOTE:
58
- // use `reduce` but not `Promise.all` here to avoid racing manupulating db.
59
- // for users, this is almost equivalent to `Promise.all`,
60
- // because of the delay is not significant sensible.
61
- // another better aspect of this is, it could handle sequenced branches in future.
62
- yield branches.reduce((promise, branch) => promise.then(() => execution.run(branch, job)), Promise.resolve());
63
- return execution.end(this, job);
42
+ var _default = {
43
+ run(prevJob, execution) {
44
+ var _this = this;
45
+
46
+ return _asyncToGenerator(function* () {
47
+ var _prevJob$id;
48
+
49
+ const branches = execution.nodes.filter(item => item.upstream === _this && item.branchIndex !== null).sort((a, b) => a.branchIndex - b.branchIndex);
50
+ const job = yield execution.saveJob({
51
+ status: _constants.JOB_STATUS.PENDING,
52
+ result: Array(branches.length).fill(null),
53
+ nodeId: _this.id,
54
+ upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
55
+ }); // NOTE:
56
+ // use `reduce` but not `Promise.all` here to avoid racing manupulating db.
57
+ // for users, this is almost equivalent to `Promise.all`,
58
+ // because of the delay is not significant sensible.
59
+ // another better aspect of this is, it could handle sequenced branches in future.
60
+
61
+ yield branches.reduce((promise, branch) => promise.then(() => execution.run(branch, job)), Promise.resolve());
62
+ return execution.end(_this, job);
63
+ })();
64
+ },
65
+
66
+ resume(branchJob, execution) {
67
+ var _this2 = this;
68
+
69
+ return _asyncToGenerator(function* () {
70
+ const job = execution.findBranchParentJob(branchJob, _this2);
71
+ const result = job.result,
72
+ status = job.status; // if parallel has been done (resolved / rejected), do not care newly executed branch jobs.
73
+
74
+ if (status !== _constants.JOB_STATUS.PENDING) {
75
+ return null;
76
+ } // find the index of the node which start the branch
77
+
78
+
79
+ const jobNode = execution.nodesMap.get(branchJob.nodeId);
80
+
81
+ const _execution$findBranch = execution.findBranchStartNode(jobNode),
82
+ branchIndex = _execution$findBranch.branchIndex;
83
+
84
+ const _ref = _this2.config || {},
85
+ _ref$mode = _ref.mode,
86
+ mode = _ref$mode === void 0 ? PARALLEL_MODE.ALL : _ref$mode;
87
+
88
+ const newResult = [...result.slice(0, branchIndex), branchJob.get(), ...result.slice(branchIndex + 1)];
89
+ job.set({
90
+ result: newResult,
91
+ status: StatusGetters[mode](newResult)
92
+ });
93
+
94
+ if (job.status === _constants.JOB_STATUS.PENDING) {
95
+ yield job.save({
96
+ transaction: execution.tx
64
97
  });
65
- },
66
- resume(branchJob, execution) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const job = execution.findBranchParentJob(branchJob, this);
69
- const { result, status } = job;
70
- // if parallel has been done (resolved / rejected), do not care newly executed branch jobs.
71
- if (status !== constants_1.JOB_STATUS.PENDING) {
72
- return null;
73
- }
74
- // find the index of the node which start the branch
75
- const jobNode = execution.nodesMap.get(branchJob.nodeId);
76
- const { branchIndex } = execution.findBranchStartNode(jobNode);
77
- const { mode = exports.PARALLEL_MODE.ALL } = this.config || {};
78
- const newResult = [...result.slice(0, branchIndex), branchJob.get(), ...result.slice(branchIndex + 1)];
79
- job.set({
80
- result: newResult,
81
- status: StatusGetters[mode](newResult)
82
- });
83
- if (job.status === constants_1.JOB_STATUS.PENDING) {
84
- yield job.save({ transaction: execution.transaction });
85
- return execution.end(this, job);
86
- }
87
- return job;
88
- });
89
- }
98
+ return execution.end(_this2, job);
99
+ }
100
+
101
+ return job;
102
+ })();
103
+ }
104
+
90
105
  };
91
- //# sourceMappingURL=parallel.js.map
106
+ exports.default = _default;
@@ -1,15 +1,23 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../constants");
4
- exports.default = {
5
- run(input, execution) {
6
- return {
7
- status: constants_1.JOB_STATUS.PENDING
8
- };
9
- },
10
- resume(job, execution) {
11
- job.set('status', constants_1.JOB_STATUS.RESOLVED);
12
- return job;
13
- }
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ var _default = {
11
+ run(input, execution) {
12
+ return {
13
+ status: _constants.JOB_STATUS.PENDING
14
+ };
15
+ },
16
+
17
+ resume(job, execution) {
18
+ job.set('status', _constants.JOB_STATUS.RESOLVED);
19
+ return job;
20
+ }
21
+
14
22
  };
15
- //# sourceMappingURL=prompt.js.map
23
+ exports.default = _default;
@@ -1,27 +1,48 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ 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
+ 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
+
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
+ 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
+ var _default = {
21
+ run(input, execution) {
22
+ var _this = this;
23
+
24
+ return _asyncToGenerator(function* () {
25
+ const _this$config = _this.config,
26
+ collection = _this$config.collection,
27
+ multiple = _this$config.multiple,
28
+ _this$config$params = _this$config.params,
29
+ params = _this$config$params === void 0 ? {} : _this$config$params;
30
+
31
+ const repo = _this.constructor.database.getRepository(collection);
32
+
33
+ const options = execution.getParsedValue(params);
34
+ const result = yield (multiple ? repo.find : repo.findOne).call(repo, _objectSpread(_objectSpread({}, options), {}, {
35
+ transaction: execution.tx
36
+ })); // NOTE: `toJSON()` to avoid getting undefined value from Proxied model instance (#380)
37
+ // e.g. Object.prototype.hasOwnProperty.call(result, 'id') // false
38
+ // so the properties can not be get by json-templates(object-path)
39
+
40
+ return {
41
+ result: multiple ? result.map(item => item.toJSON()) : result === null || result === void 0 ? void 0 : result.toJSON(),
42
+ status: _constants.JOB_STATUS.RESOLVED
43
+ };
44
+ })();
45
+ }
46
+
10
47
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const constants_1 = require("../constants");
13
- exports.default = {
14
- run(input, execution) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const { collection, multiple, params = {} } = this.config;
17
- const repo = this.constructor.database.getRepository(collection);
18
- const options = execution.getParsedValue(params);
19
- const result = yield (multiple ? repo.find : repo.findOne).call(repo, Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
20
- return {
21
- result,
22
- status: constants_1.JOB_STATUS.RESOLVED
23
- };
24
- });
25
- }
26
- };
27
- //# sourceMappingURL=query.js.map
48
+ exports.default = _default;
@@ -1,6 +1,7 @@
1
+ import ExecutionModel from "../models/Execution";
1
2
  import FlowNodeModel from "../models/FlowNode";
2
3
  declare const _default: {
3
- run(this: FlowNodeModel, input: any, execution: any): Promise<{
4
+ run(this: FlowNodeModel, input: any, execution: ExecutionModel): Promise<{
4
5
  result: import("@nocobase/database").Model<any, any> | import("@nocobase/database").Model<any, any>[];
5
6
  status: number;
6
7
  }>;
@@ -1,27 +1,46 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ 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
+ 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
+
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
+ 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
+ var _default = {
21
+ run(input, execution) {
22
+ var _this = this;
23
+
24
+ return _asyncToGenerator(function* () {
25
+ const _this$config = _this.config,
26
+ collection = _this$config.collection,
27
+ _this$config$multiple = _this$config.multiple,
28
+ multiple = _this$config$multiple === void 0 ? false : _this$config$multiple,
29
+ _this$config$params = _this$config.params,
30
+ params = _this$config$params === void 0 ? {} : _this$config$params;
31
+
32
+ const repo = _this.constructor.database.getRepository(collection);
33
+
34
+ const options = execution.getParsedValue(params);
35
+ const result = yield repo.update(_objectSpread(_objectSpread({}, options), {}, {
36
+ transaction: execution.tx
37
+ }));
38
+ return {
39
+ result: multiple ? result : result[0] || null,
40
+ status: _constants.JOB_STATUS.RESOLVED
41
+ };
42
+ })();
43
+ }
44
+
10
45
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const constants_1 = require("../constants");
13
- exports.default = {
14
- run(input, execution) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const { collection, multiple = false, params = {} } = this.config;
17
- const repo = this.constructor.database.getRepository(collection);
18
- const options = execution.getParsedValue(params);
19
- const result = yield repo.update(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
20
- return {
21
- result: multiple ? result : (result[0] || null),
22
- status: constants_1.JOB_STATUS.RESOLVED
23
- };
24
- });
25
- }
26
- };
27
- //# sourceMappingURL=update.js.map
46
+ exports.default = _default;
@@ -13,6 +13,7 @@ export default class ExecutionModel extends Model {
13
13
  context: any;
14
14
  status: number;
15
15
  useTransaction: boolean;
16
+ transaction: string;
16
17
  createdAt: Date;
17
18
  updatedAt: Date;
18
19
  workflow?: WorkflowModel;
@@ -20,7 +21,7 @@ export default class ExecutionModel extends Model {
20
21
  jobs?: JobModel[];
21
22
  getJobs: HasManyGetAssociationsMixin<JobModel>;
22
23
  options: ExecutionOptions;
23
- transaction: Transaction;
24
+ tx: Transaction;
24
25
  nodes: Array<FlowNodeModel>;
25
26
  nodesMap: Map<number, FlowNodeModel>;
26
27
  jobsMap: Map<number, JobModel>;
@@ -32,7 +33,7 @@ export default class ExecutionModel extends Model {
32
33
  };
33
34
  makeNodes(nodes?: any[]): void;
34
35
  makeJobs(jobs: Array<JobModel>): void;
35
- getTransaction(): Transaction | Promise<Transaction>;
36
+ getTransaction(): Promise<Transaction>;
36
37
  prepare(options: any, commit?: boolean): Promise<void>;
37
38
  start(options: ExecutionOptions): Promise<void>;
38
39
  resume(job: JobModel, options: ExecutionOptions): Promise<void>;