@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,65 +1,80 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- name: 'workflows',
5
- model: 'WorkflowModel',
6
- title: '自动化',
7
- fields: [
8
- {
9
- interface: 'string',
10
- type: 'string',
11
- name: 'title',
12
- title: '自动化名称',
13
- required: true
14
- },
15
- {
16
- interface: 'boolean',
17
- type: 'boolean',
18
- name: 'enabled',
19
- title: '启用'
20
- },
21
- {
22
- interface: 'textarea',
23
- type: 'text',
24
- name: 'description',
25
- title: '描述'
26
- },
27
- {
28
- interface: 'select',
29
- type: 'string',
30
- title: '触发方式',
31
- name: 'type',
32
- required: true
33
- },
34
- {
35
- interface: 'json',
36
- type: 'jsonb',
37
- title: '触发配置',
38
- name: 'config',
39
- required: true,
40
- defaultValue: {}
41
- },
42
- {
43
- interface: 'boolean',
44
- type: 'boolean',
45
- title: '使用事务',
46
- name: 'useTransaction',
47
- defaultValue: true
48
- },
49
- {
50
- interface: 'linkTo',
51
- type: 'hasMany',
52
- name: 'nodes',
53
- target: 'flow_nodes',
54
- title: '流程节点'
55
- },
56
- {
57
- interface: 'linkTo',
58
- type: 'hasMany',
59
- name: 'executions',
60
- target: 'executions',
61
- title: '触发执行'
62
- }
63
- ]
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ name: 'workflows',
9
+ model: 'WorkflowModel',
10
+ title: '自动化',
11
+ fields: [{
12
+ name: 'key',
13
+ type: 'uid'
14
+ }, {
15
+ interface: 'string',
16
+ type: 'string',
17
+ name: 'title',
18
+ title: '工作流名称',
19
+ required: true
20
+ }, {
21
+ interface: 'boolean',
22
+ type: 'boolean',
23
+ name: 'enabled',
24
+ title: '启用',
25
+ defaultValue: false
26
+ }, {
27
+ interface: 'textarea',
28
+ type: 'text',
29
+ name: 'description',
30
+ title: '描述'
31
+ }, {
32
+ interface: 'select',
33
+ type: 'string',
34
+ title: '触发方式',
35
+ name: 'type',
36
+ required: true
37
+ }, {
38
+ interface: 'json',
39
+ type: 'jsonb',
40
+ title: '触发配置',
41
+ name: 'config',
42
+ required: true,
43
+ defaultValue: {}
44
+ }, {
45
+ interface: 'boolean',
46
+ type: 'boolean',
47
+ title: '使用事务',
48
+ name: 'useTransaction',
49
+ defaultValue: true
50
+ }, {
51
+ interface: 'linkTo',
52
+ type: 'hasMany',
53
+ name: 'nodes',
54
+ target: 'flow_nodes',
55
+ title: '流程节点'
56
+ }, {
57
+ interface: 'linkTo',
58
+ type: 'hasMany',
59
+ name: 'executions',
60
+ target: 'executions',
61
+ title: '触发执行'
62
+ }, {
63
+ type: 'boolean',
64
+ name: 'executed',
65
+ defaultValue: false
66
+ }, {
67
+ type: 'boolean',
68
+ name: 'current',
69
+ defaultValue: false
70
+ }, {
71
+ type: 'hasMany',
72
+ name: 'revisions',
73
+ target: 'workflows',
74
+ foreignKey: 'key',
75
+ sourceKey: 'key',
76
+ // NOTE: no constraints needed here because tricky self-referencing
77
+ constraints: false
78
+ }]
64
79
  };
65
- //# sourceMappingURL=workflows.js.map
80
+ exports.default = _default;
package/lib/constants.js CHANGED
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BRANCH_INDEX = exports.JOB_STATUS = exports.EXECUTION_STATUS = void 0;
4
- exports.EXECUTION_STATUS = {
5
- STARTED: 0,
6
- RESOLVED: 1,
7
- REJECTED: -1,
8
- CANCELLED: -2
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JOB_STATUS = exports.EXECUTION_STATUS = exports.BRANCH_INDEX = void 0;
7
+ const EXECUTION_STATUS = {
8
+ STARTED: 0,
9
+ RESOLVED: 1,
10
+ REJECTED: -1,
11
+ CANCELLED: -2
9
12
  };
10
- exports.JOB_STATUS = {
11
- PENDING: 0,
12
- RESOLVED: 1,
13
- REJECTED: -1,
14
- CANCELLED: -2
13
+ exports.EXECUTION_STATUS = EXECUTION_STATUS;
14
+ const JOB_STATUS = {
15
+ PENDING: 0,
16
+ RESOLVED: 1,
17
+ REJECTED: -1,
18
+ CANCELLED: -2
15
19
  };
16
- exports.BRANCH_INDEX = {
17
- DEFAULT: null,
18
- ON_TRUE: 1,
19
- ON_FALSE: 0
20
+ exports.JOB_STATUS = JOB_STATUS;
21
+ const BRANCH_INDEX = {
22
+ DEFAULT: null,
23
+ ON_TRUE: 1,
24
+ ON_FALSE: 0
20
25
  };
21
- //# sourceMappingURL=constants.js.map
26
+ exports.BRANCH_INDEX = BRANCH_INDEX;
package/lib/index.js CHANGED
@@ -1,23 +1,72 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.default = void 0;
17
- __exportStar(require("./constants"), exports);
18
- __exportStar(require("./calculators"), exports);
19
- __exportStar(require("./triggers"), exports);
20
- __exportStar(require("./instructions"), exports);
21
- var server_1 = require("./server");
22
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(server_1).default; } });
23
- //# sourceMappingURL=index.js.map
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 _server.default;
11
+ }
12
+ });
13
+
14
+ var _constants = require("./constants");
15
+
16
+ Object.keys(_constants).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] === _constants[key]) return;
20
+ Object.defineProperty(exports, key, {
21
+ enumerable: true,
22
+ get: function get() {
23
+ return _constants[key];
24
+ }
25
+ });
26
+ });
27
+
28
+ var _calculators = require("./calculators");
29
+
30
+ Object.keys(_calculators).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] === _calculators[key]) return;
34
+ Object.defineProperty(exports, key, {
35
+ enumerable: true,
36
+ get: function get() {
37
+ return _calculators[key];
38
+ }
39
+ });
40
+ });
41
+
42
+ var _triggers = require("./triggers");
43
+
44
+ Object.keys(_triggers).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] === _triggers[key]) return;
48
+ Object.defineProperty(exports, key, {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _triggers[key];
52
+ }
53
+ });
54
+ });
55
+
56
+ var _instructions = require("./instructions");
57
+
58
+ Object.keys(_instructions).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] === _instructions[key]) return;
62
+ Object.defineProperty(exports, key, {
63
+ enumerable: true,
64
+ get: function get() {
65
+ return _instructions[key];
66
+ }
67
+ });
68
+ });
69
+
70
+ var _server = _interopRequireDefault(require("./server"));
71
+
72
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,16 +1,18 @@
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
- const constants_1 = require("../constants");
13
- const calculators_1 = require("../calculators");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _constants = require("../constants");
9
+
10
+ var _calculators = require("../calculators");
11
+
12
+ 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); } }
13
+
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); }); }; }
15
+
14
16
  // @calculation: {
15
17
  // calculator: 'concat',
16
18
  // operands: [
@@ -37,21 +39,24 @@ const calculators_1 = require("../calculators");
37
39
  // }
38
40
  // ]
39
41
  // }
40
- exports.default = {
41
- run(prevJob, execution) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const { calculation } = this.config || {};
44
- const result = calculation
45
- ? (0, calculators_1.calculate)({
46
- type: '$calculation',
47
- options: execution.getParsedValue(calculation)
48
- }, prevJob, execution)
49
- : null;
50
- return {
51
- result,
52
- status: constants_1.JOB_STATUS.RESOLVED
53
- };
54
- });
55
- }
42
+ var _default = {
43
+ run(prevJob, execution) {
44
+ var _this = this;
45
+
46
+ return _asyncToGenerator(function* () {
47
+ const _ref = _this.config || {},
48
+ calculation = _ref.calculation;
49
+
50
+ const result = calculation ? (0, _calculators.calculate)({
51
+ type: '$calculation',
52
+ options: execution.getParsedValue(calculation)
53
+ }, prevJob, execution) : null;
54
+ return {
55
+ result,
56
+ status: _constants.JOB_STATUS.RESOLVED
57
+ };
58
+ })();
59
+ }
60
+
56
61
  };
57
- //# sourceMappingURL=calculation.js.map
62
+ exports.default = _default;
@@ -1,35 +1,22 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
13
5
  });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- const calculators_1 = __importStar(require("../calculators"));
32
- const constants_1 = require("../constants");
6
+ exports.default = void 0;
7
+
8
+ var _calculators = _interopRequireWildcard(require("../calculators"));
9
+
10
+ var _constants = require("../constants");
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ 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
+
33
20
  // @calculation: {
34
21
  // not: false,
35
22
  // group: {
@@ -58,63 +45,83 @@ const constants_1 = require("../constants");
58
45
  // }
59
46
  // }
60
47
  function logicCalculate(calculation, input, execution) {
61
- if (!calculation) {
62
- return true;
63
- }
64
- const { not, group } = calculation;
65
- let result;
66
- if (group) {
67
- const method = group.type === 'and' ? 'every' : 'some';
68
- result = group.calculations[method](item => logicCalculate(item, input, execution));
48
+ if (!calculation) {
49
+ return true;
50
+ }
51
+
52
+ const not = calculation.not,
53
+ group = calculation.group;
54
+ let result;
55
+
56
+ if (group) {
57
+ const method = group.type === 'and' ? 'every' : 'some';
58
+ result = group.calculations[method](item => logicCalculate(item, input, execution));
59
+ } else {
60
+ const args = calculation.operands.map(operand => (0, _calculators.calculate)(operand, input, execution));
61
+
62
+ const fn = _calculators.default.get(calculation.calculator);
63
+
64
+ if (!fn) {
65
+ throw new Error(`no calculator function registered for "${calculation.calculator}"`);
69
66
  }
70
- else {
71
- const args = calculation.operands.map(operand => (0, calculators_1.calculate)(operand, input, execution));
72
- const fn = calculators_1.default.get(calculation.calculator);
73
- if (!fn) {
74
- throw new Error(`no calculator function registered for "${calculation.calculator}"`);
75
- }
76
- result = fn(...args);
77
- }
78
- return not ? !result : result;
67
+
68
+ result = fn(...args);
69
+ }
70
+
71
+ return not ? !result : result;
79
72
  }
80
- exports.default = {
81
- run(prevJob, execution) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- // TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution
84
- // const jobs = await execution.getJobs();
85
- const { calculation, rejectOnFalse } = this.config || {};
86
- const result = logicCalculate(calculation, prevJob, execution);
87
- if (!result && rejectOnFalse) {
88
- return {
89
- status: constants_1.JOB_STATUS.REJECTED,
90
- result
91
- };
92
- }
93
- const job = {
94
- status: constants_1.JOB_STATUS.RESOLVED,
95
- result,
96
- // TODO(optimize): try unify the building of job
97
- nodeId: this.id,
98
- upstreamId: prevJob && prevJob.id || null
99
- };
100
- const branchNode = execution.nodes
101
- .find(item => item.upstream === this && Boolean(item.branchIndex) === result);
102
- if (!branchNode) {
103
- return job;
104
- }
105
- const savedJob = yield execution.saveJob(job);
106
- return execution.run(branchNode, savedJob);
107
- });
108
- },
109
- resume(branchJob, execution) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- if (branchJob.status === constants_1.JOB_STATUS.RESOLVED) {
112
- // return to continue this.downstream
113
- return branchJob;
114
- }
115
- // pass control to upper scope by ending current scope
116
- return execution.end(this, branchJob);
117
- });
118
- }
73
+
74
+ var _default = {
75
+ run(prevJob, execution) {
76
+ var _this = this;
77
+
78
+ return _asyncToGenerator(function* () {
79
+ // TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution
80
+ // const jobs = await execution.getJobs();
81
+ const _ref = _this.config || {},
82
+ calculation = _ref.calculation,
83
+ rejectOnFalse = _ref.rejectOnFalse;
84
+
85
+ const result = logicCalculate(calculation, prevJob, execution);
86
+
87
+ if (!result && rejectOnFalse) {
88
+ return {
89
+ status: _constants.JOB_STATUS.REJECTED,
90
+ result
91
+ };
92
+ }
93
+
94
+ const job = {
95
+ status: _constants.JOB_STATUS.RESOLVED,
96
+ result,
97
+ // TODO(optimize): try unify the building of job
98
+ nodeId: _this.id,
99
+ upstreamId: prevJob && prevJob.id || null
100
+ };
101
+ const branchNode = execution.nodes.find(item => item.upstream === _this && Boolean(item.branchIndex) === result);
102
+
103
+ if (!branchNode) {
104
+ return job;
105
+ }
106
+
107
+ const savedJob = yield execution.saveJob(job);
108
+ return execution.run(branchNode, savedJob);
109
+ })();
110
+ },
111
+
112
+ resume(branchJob, execution) {
113
+ var _this2 = this;
114
+
115
+ return _asyncToGenerator(function* () {
116
+ if (branchJob.status === _constants.JOB_STATUS.RESOLVED) {
117
+ // return to continue this.downstream
118
+ return branchJob;
119
+ } // pass control to upper scope by ending current scope
120
+
121
+
122
+ return execution.end(_this2, branchJob);
123
+ })();
124
+ }
125
+
119
126
  };
120
- //# sourceMappingURL=condition.js.map
127
+ exports.default = _default;
@@ -1,7 +1,7 @@
1
1
  import FlowNodeModel from "../models/FlowNode";
2
2
  declare const _default: {
3
3
  run(this: FlowNodeModel, input: any, execution: any): Promise<{
4
- result: import("@nocobase/database").Model<any, any>;
4
+ result: any;
5
5
  status: number;
6
6
  }>;
7
7
  };
@@ -1,27 +1,45 @@
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.create(_objectSpread(_objectSpread({}, options), {}, {
34
+ transaction: execution.tx
35
+ }));
36
+ return {
37
+ // NOTE: get() for non-proxied instance (#380)
38
+ result: result.get(),
39
+ status: _constants.JOB_STATUS.RESOLVED
40
+ };
41
+ })();
42
+ }
43
+
10
44
  };
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.create(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=create.js.map
45
+ exports.default = _default;