@nocobase/plugin-workflow 0.10.1-alpha.1 → 0.11.1-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.
- package/client.d.ts +2 -3
- package/client.js +1 -30
- package/lib/client/AddButton.js +13 -11
- package/lib/client/Branch.js +10 -8
- package/lib/client/CanvasContent.js +12 -10
- package/lib/client/ExecutionCanvas.js +37 -33
- package/lib/client/ExecutionPage.js +4 -9
- package/lib/client/WorkflowCanvas.js +18 -15
- package/lib/client/WorkflowPage.js +4 -9
- package/lib/client/WorkflowProvider.js +1 -40
- package/lib/client/components/CollectionBlockInitializer.js +3 -3
- package/lib/client/components/CollectionFieldset.d.ts +1 -1
- package/lib/client/components/CollectionFieldset.js +15 -16
- package/lib/client/components/Duration.js +5 -5
- package/lib/client/components/DynamicExpression.d.ts +3 -3
- package/lib/client/components/FieldsSelect.d.ts +1 -1
- package/lib/client/components/FieldsSelect.js +10 -7
- package/lib/client/components/NodeDescription.js +45 -31
- package/lib/client/components/RadioWithTooltip.js +13 -20
- package/lib/client/components/ValueBlock.js +14 -21
- package/lib/client/components/renderEngineReference.js +1 -8
- package/lib/client/index.d.ts +12 -4
- package/lib/client/index.js +78 -15
- package/lib/client/locale/zh-CN.d.ts +5 -1
- package/lib/client/locale/zh-CN.js +6 -2
- package/lib/client/nodes/aggregate.d.ts +8 -3
- package/lib/client/nodes/aggregate.js +5 -4
- package/lib/client/nodes/calculation.d.ts +6 -4
- package/lib/client/nodes/calculation.js +22 -28
- package/lib/client/nodes/condition.d.ts +2 -10
- package/lib/client/nodes/condition.js +19 -37
- package/lib/client/nodes/create.d.ts +5 -6
- package/lib/client/nodes/create.js +1 -3
- package/lib/client/nodes/destroy.d.ts +1 -1
- package/lib/client/nodes/index.d.ts +2 -3
- package/lib/client/nodes/index.js +95 -102
- package/lib/client/nodes/loop.d.ts +1 -1
- package/lib/client/nodes/loop.js +46 -54
- package/lib/client/nodes/manual/FormBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/ModeConfig.js +23 -30
- package/lib/client/nodes/manual/SchemaConfig.d.ts +4 -5
- package/lib/client/nodes/manual/SchemaConfig.js +180 -25
- package/lib/client/nodes/manual/WorkflowTodo.js +95 -110
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +2 -5
- package/lib/client/nodes/manual/WorkflowTodoBlockInitializer.js +6 -5
- package/lib/client/nodes/manual/forms/create.js +8 -1
- package/lib/client/nodes/manual/forms/custom.js +22 -22
- package/lib/client/nodes/manual/forms/update.js +8 -1
- package/lib/client/nodes/manual/index.d.ts +6 -1
- package/lib/client/nodes/manual/index.js +5 -4
- package/lib/client/nodes/parallel.js +23 -20
- package/lib/client/nodes/query.d.ts +3 -5
- package/lib/client/nodes/query.js +1 -3
- package/lib/client/nodes/request.d.ts +2 -2
- package/lib/client/nodes/request.js +7 -7
- package/lib/client/nodes/sql.d.ts +26 -0
- package/lib/client/{triggers/schedule/DateFieldsSelect.js → nodes/sql.js} +37 -46
- package/lib/client/nodes/update.d.ts +2 -2
- package/lib/client/nodes/update.js +1 -1
- package/lib/client/schemas/collection.d.ts +3 -4
- package/lib/client/schemas/collection.js +11 -17
- package/lib/client/style.d.ts +18 -13
- package/lib/client/style.js +315 -292
- package/lib/client/triggers/collection.d.ts +13 -13
- package/lib/client/triggers/collection.js +5 -1
- package/lib/client/triggers/index.d.ts +3 -4
- package/lib/client/triggers/index.js +51 -53
- package/lib/client/triggers/schedule/EndsByField.js +11 -11
- package/lib/client/triggers/schedule/OnField.js +45 -33
- package/lib/client/triggers/schedule/RepeatField.js +4 -4
- package/lib/client/triggers/schedule/ScheduleConfig.js +24 -31
- package/lib/client/triggers/schedule/index.d.ts +1 -1
- package/lib/client/triggers/schedule/index.js +32 -20
- package/lib/client/variable.d.ts +31 -13
- package/lib/client/variable.js +44 -29
- package/lib/server/Plugin.d.ts +3 -6
- package/lib/server/Plugin.js +15 -12
- package/lib/server/Processor.d.ts +3 -5
- package/lib/server/Processor.js +2 -2
- package/lib/server/actions/nodes.js +7 -7
- package/lib/server/fields/expression-field.d.ts +1 -2
- package/lib/server/fields/expression-field.js +1 -8
- package/lib/server/functions/index.d.ts +2 -3
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +12 -0
- package/lib/server/instructions/aggregate.d.ts +1 -1
- package/lib/server/instructions/aggregate.js +5 -5
- package/lib/server/instructions/condition.d.ts +2 -1
- package/lib/server/instructions/create.d.ts +2 -2
- package/lib/server/instructions/create.js +13 -13
- package/lib/server/instructions/delay.d.ts +3 -3
- package/lib/server/instructions/delay.js +66 -64
- package/lib/server/instructions/destroy.d.ts +1 -1
- package/lib/server/instructions/index.d.ts +5 -5
- package/lib/server/instructions/index.js +1 -1
- package/lib/server/instructions/loop.d.ts +1 -2
- package/lib/server/instructions/manual/actions.js +19 -7
- package/lib/server/instructions/manual/forms/create.js +7 -1
- package/lib/server/instructions/manual/forms/index.d.ts +1 -1
- package/lib/server/instructions/manual/forms/update.js +7 -1
- package/lib/server/instructions/manual/index.d.ts +1 -1
- package/lib/server/instructions/parallel.d.ts +1 -2
- package/lib/server/instructions/query.d.ts +1 -1
- package/lib/server/instructions/query.js +8 -1
- package/lib/server/instructions/request.d.ts +3 -3
- package/lib/server/instructions/request.js +5 -2
- package/lib/server/instructions/sql.d.ts +12 -0
- package/lib/server/instructions/sql.js +34 -0
- package/lib/server/instructions/update.d.ts +1 -1
- package/lib/server/migrations/20230221071831-calculation-expression.js +1 -1
- package/lib/server/migrations/20230221121203-condition-calculation.js +1 -1
- package/lib/server/migrations/20230221162902-jsonb-to-json.js +7 -7
- package/lib/server/migrations/20230411034722-manual-multi-form.js +1 -8
- package/lib/server/migrations/20230710115902-manual-action-values.d.ts +4 -0
- package/lib/server/migrations/20230710115902-manual-action-values.js +97 -0
- package/lib/server/triggers/collection.d.ts +1 -1
- package/lib/server/triggers/collection.js +15 -13
- package/lib/server/triggers/index.d.ts +1 -1
- package/lib/server/triggers/schedule.d.ts +1 -1
- package/lib/server/triggers/schedule.js +18 -18
- package/lib/server/{models → types}/Execution.d.ts +2 -3
- package/lib/server/{models → types}/FlowNode.d.ts +1 -2
- package/lib/server/{models → types}/Job.d.ts +1 -2
- package/lib/server/{models → types}/Workflow.d.ts +1 -2
- package/lib/server/types/index.d.ts +4 -0
- package/lib/server/types/index.js +5 -0
- package/lib/server/utils.d.ts +2 -0
- package/lib/server/utils.js +21 -0
- package/package.json +39 -18
- package/server.d.ts +2 -3
- package/server.js +1 -30
- package/src/client/AddButton.tsx +111 -0
- package/src/client/Branch.tsx +37 -0
- package/src/client/CanvasContent.tsx +25 -0
- package/src/client/ExecutionCanvas.tsx +166 -0
- package/src/client/ExecutionLink.tsx +16 -0
- package/src/client/ExecutionPage.tsx +45 -0
- package/src/client/ExecutionResourceProvider.tsx +21 -0
- package/src/client/FlowContext.ts +7 -0
- package/src/client/WorkflowCanvas.tsx +221 -0
- package/src/client/WorkflowLink.tsx +16 -0
- package/src/client/WorkflowPage.tsx +52 -0
- package/src/client/WorkflowProvider.tsx +84 -0
- package/src/client/components/CollectionBlockInitializer.tsx +71 -0
- package/src/client/components/CollectionFieldset.tsx +160 -0
- package/src/client/components/Duration.tsx +45 -0
- package/src/client/components/DynamicExpression.tsx +53 -0
- package/src/client/components/FieldsSelect.tsx +32 -0
- package/src/client/components/FilterDynamicComponent.tsx +15 -0
- package/src/client/components/NodeDescription.tsx +51 -0
- package/src/client/components/NullRender.tsx +3 -0
- package/src/client/components/OpenDrawer.tsx +24 -0
- package/src/client/components/RadioWithTooltip.tsx +38 -0
- package/src/client/components/ValueBlock.tsx +67 -0
- package/src/client/components/renderEngineReference.tsx +30 -0
- package/src/client/constants.tsx +91 -0
- package/src/client/index.tsx +51 -0
- package/src/client/interfaces/expression.tsx +25 -0
- package/src/client/locale/en-US.ts +136 -0
- package/src/client/locale/es-ES.ts +129 -0
- package/src/client/locale/index.ts +18 -0
- package/src/client/locale/ja-JP.ts +90 -0
- package/src/client/locale/pt-BR.ts +136 -0
- package/src/client/locale/ru-RU.ts +90 -0
- package/src/client/locale/tr-TR.ts +90 -0
- package/src/client/locale/zh-CN.ts +248 -0
- package/src/client/nodes/aggregate.tsx +327 -0
- package/src/client/nodes/calculation.tsx +216 -0
- package/src/client/nodes/condition.tsx +463 -0
- package/src/client/nodes/create.tsx +85 -0
- package/src/client/nodes/delay.tsx +37 -0
- package/src/client/nodes/destroy.tsx +34 -0
- package/src/client/nodes/index.tsx +485 -0
- package/src/client/nodes/loop.tsx +144 -0
- package/src/client/nodes/manual/AssigneesSelect.tsx +33 -0
- package/src/client/nodes/manual/DetailsBlockProvider.tsx +80 -0
- package/src/client/nodes/manual/FormBlockInitializer.tsx +69 -0
- package/src/client/nodes/manual/FormBlockProvider.tsx +75 -0
- package/src/client/nodes/manual/ModeConfig.tsx +84 -0
- package/src/client/nodes/manual/SchemaConfig.tsx +509 -0
- package/src/client/nodes/manual/WorkflowTodo.tsx +607 -0
- package/src/client/nodes/manual/WorkflowTodoBlockInitializer.tsx +28 -0
- package/src/client/nodes/manual/forms/create.tsx +92 -0
- package/src/client/nodes/manual/forms/custom.tsx +392 -0
- package/src/client/nodes/manual/forms/update.tsx +134 -0
- package/src/client/nodes/manual/index.tsx +162 -0
- package/src/client/nodes/manual/utils.ts +28 -0
- package/src/client/nodes/parallel.tsx +138 -0
- package/src/client/nodes/query.tsx +88 -0
- package/src/client/nodes/request.tsx +185 -0
- package/src/client/nodes/sql.tsx +37 -0
- package/src/client/nodes/update.tsx +99 -0
- package/src/client/schemas/collection.ts +75 -0
- package/src/client/schemas/executions.tsx +169 -0
- package/src/client/schemas/workflows.ts +364 -0
- package/src/client/style.tsx +347 -0
- package/src/client/triggers/collection.tsx +190 -0
- package/src/client/triggers/index.tsx +311 -0
- package/src/client/triggers/schedule/EndsByField.tsx +40 -0
- package/src/client/triggers/schedule/OnField.tsx +64 -0
- package/src/client/triggers/schedule/RepeatField.tsx +116 -0
- package/src/client/triggers/schedule/ScheduleConfig.tsx +227 -0
- package/src/client/triggers/schedule/constants.ts +4 -0
- package/src/client/triggers/schedule/index.tsx +78 -0
- package/src/client/triggers/schedule/locale/Cron.zh-CN.ts +79 -0
- package/src/client/utils.ts +36 -0
- package/src/client/variable.tsx +318 -0
- package/src/index.ts +1 -0
- package/src/server/Plugin.ts +355 -0
- package/src/server/Processor.ts +354 -0
- package/src/server/__tests__/Plugin.test.ts +398 -0
- package/src/server/__tests__/Processor.test.ts +474 -0
- package/src/server/__tests__/actions/workflows.test.ts +419 -0
- package/src/server/__tests__/collections/categories.ts +27 -0
- package/src/server/__tests__/collections/comments.ts +24 -0
- package/src/server/__tests__/collections/posts.ts +42 -0
- package/src/server/__tests__/collections/replies.ts +9 -0
- package/src/server/__tests__/collections/tags.ts +15 -0
- package/src/server/__tests__/index.ts +89 -0
- package/src/server/__tests__/instructions/aggregate.test.ts +294 -0
- package/src/server/__tests__/instructions/calculation.test.ts +265 -0
- package/src/server/__tests__/instructions/condition.test.ts +335 -0
- package/src/server/__tests__/instructions/create.test.ts +129 -0
- package/src/server/__tests__/instructions/delay.test.ts +182 -0
- package/src/server/__tests__/instructions/destroy.test.ts +58 -0
- package/src/server/__tests__/instructions/loop.test.ts +331 -0
- package/src/server/__tests__/instructions/manual.test.ts +1173 -0
- package/src/server/__tests__/instructions/parallel.test.ts +445 -0
- package/src/server/__tests__/instructions/query.test.ts +359 -0
- package/src/server/__tests__/instructions/request.test.ts +247 -0
- package/src/server/__tests__/instructions/sql.test.ts +162 -0
- package/src/server/__tests__/instructions/update.test.ts +189 -0
- package/src/server/__tests__/triggers/collection.test.ts +333 -0
- package/src/server/__tests__/triggers/schedule.test.ts +369 -0
- package/src/server/actions/index.ts +25 -0
- package/src/server/actions/nodes.ts +214 -0
- package/src/server/actions/workflows.ts +178 -0
- package/src/server/collections/executions.ts +35 -0
- package/src/server/collections/flow_nodes.ts +54 -0
- package/src/server/collections/jobs.ts +31 -0
- package/src/server/collections/workflows.ts +88 -0
- package/src/server/constants.ts +26 -0
- package/src/server/fields/expression-field.ts +11 -0
- package/src/server/fields/index.ts +7 -0
- package/src/server/functions/index.ts +16 -0
- package/src/server/index.ts +6 -0
- package/src/server/instructions/aggregate.ts +42 -0
- package/src/server/instructions/calculation.ts +41 -0
- package/src/server/instructions/condition.ts +172 -0
- package/src/server/instructions/create.ts +39 -0
- package/src/server/instructions/delay.ts +105 -0
- package/src/server/instructions/destroy.ts +23 -0
- package/src/server/instructions/index.ts +64 -0
- package/src/server/instructions/loop.ts +99 -0
- package/src/server/instructions/manual/actions.ts +91 -0
- package/src/server/instructions/manual/collecions/jobs.ts +17 -0
- package/src/server/instructions/manual/collecions/users.ts +15 -0
- package/src/server/instructions/manual/collecions/users_jobs.ts +50 -0
- package/src/server/instructions/manual/forms/create.ts +23 -0
- package/src/server/instructions/manual/forms/index.ts +12 -0
- package/src/server/instructions/manual/forms/update.ts +23 -0
- package/src/server/instructions/manual/index.ts +184 -0
- package/src/server/instructions/parallel.ts +121 -0
- package/src/server/instructions/query.ts +42 -0
- package/src/server/instructions/request.ts +88 -0
- package/src/server/instructions/sql.ts +25 -0
- package/src/server/instructions/update.ts +24 -0
- package/src/server/migrations/20221129153547-calculation-variables.ts +64 -0
- package/src/server/migrations/20230221032941-change-request-body-type.ts +76 -0
- package/src/server/migrations/20230221071831-calculation-expression.ts +102 -0
- package/src/server/migrations/20230221121203-condition-calculation.ts +82 -0
- package/src/server/migrations/20230221162902-jsonb-to-json.ts +51 -0
- package/src/server/migrations/20230411034722-manual-multi-form.ts +282 -0
- package/src/server/migrations/20230612021134-manual-collection-block.ts +138 -0
- package/src/server/migrations/20230710115902-manual-action-values.ts +78 -0
- package/src/server/triggers/collection.ts +146 -0
- package/src/server/triggers/index.ts +22 -0
- package/src/server/triggers/schedule.ts +567 -0
- package/src/server/types/Execution.ts +26 -0
- package/src/server/types/FlowNode.ts +21 -0
- package/src/server/types/Job.ts +18 -0
- package/src/server/types/Workflow.ts +36 -0
- package/src/server/types/index.ts +4 -0
- package/src/server/utils.ts +17 -0
- package/lib/client/triggers/schedule/DateFieldsSelect.d.ts +0 -2
- /package/lib/server/{models → types}/Execution.js +0 -0
- /package/lib/server/{models → types}/FlowNode.js +0 -0
- /package/lib/server/{models → types}/Job.js +0 -0
- /package/lib/server/{models → types}/Workflow.js +0 -0
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _constants = require("../constants");
|
|
8
|
+
var _utils = require("../utils");
|
|
8
9
|
const _excluded = ["appends"];
|
|
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; }
|
|
10
11
|
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; }
|
|
@@ -29,29 +30,28 @@ var _default = {
|
|
|
29
30
|
repository = _node$constructor$dat.repository,
|
|
30
31
|
model = _node$constructor$dat.model;
|
|
31
32
|
const options = processor.getParsedValue(params, node);
|
|
32
|
-
const
|
|
33
|
+
const created = yield repository.create(_objectSpread(_objectSpread({}, options), {}, {
|
|
33
34
|
context: {
|
|
34
35
|
executionId: processor.execution.id
|
|
35
36
|
},
|
|
36
37
|
transaction: processor.transaction
|
|
37
38
|
}));
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
let result = created;
|
|
40
|
+
if (created && appends.length) {
|
|
41
|
+
const includeFields = appends.reduce((set, field) => {
|
|
42
|
+
set.add(field.split('.')[0]);
|
|
43
|
+
set.add(field);
|
|
44
|
+
return set;
|
|
45
|
+
}, new Set());
|
|
46
|
+
result = yield repository.findOne({
|
|
47
|
+
filterByTk: created[model.primaryKeyAttribute],
|
|
48
|
+
appends: Array.from(includeFields),
|
|
43
49
|
transaction: processor.transaction
|
|
44
50
|
});
|
|
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
51
|
}
|
|
52
52
|
return {
|
|
53
53
|
// NOTE: get() for non-proxied instance (#380)
|
|
54
|
-
result:
|
|
54
|
+
result: (0, _utils.toJSON)(result),
|
|
55
55
|
status: _constants.JOB_STATUS.RESOLVED
|
|
56
56
|
};
|
|
57
57
|
})();
|
|
@@ -6,9 +6,9 @@ export default class implements Instruction {
|
|
|
6
6
|
protected plugin: Plugin;
|
|
7
7
|
timers: Map<number, NodeJS.Timeout>;
|
|
8
8
|
constructor(plugin: Plugin);
|
|
9
|
-
load()
|
|
10
|
-
unload()
|
|
11
|
-
schedule(job: any
|
|
9
|
+
load: () => Promise<void>;
|
|
10
|
+
unload: () => void;
|
|
11
|
+
schedule(job: any): void;
|
|
12
12
|
trigger(job: any): Promise<void>;
|
|
13
13
|
run: (node: any, prevJob: any, processor: Processor) => Promise<any>;
|
|
14
14
|
resume: (node: any, prevJob: any, processor: Processor) => Promise<any>;
|
|
@@ -15,43 +15,9 @@ class _default {
|
|
|
15
15
|
var _this = this;
|
|
16
16
|
this.plugin = void 0;
|
|
17
17
|
this.timers = new Map();
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const job = yield processor.saveJob({
|
|
22
|
-
status: _constants.JOB_STATUS.PENDING,
|
|
23
|
-
result: null,
|
|
24
|
-
nodeId: node.id,
|
|
25
|
-
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
26
|
-
});
|
|
27
|
-
const duration = node.config.duration;
|
|
28
|
-
// add to schedule
|
|
29
|
-
_this.schedule(job, duration);
|
|
30
|
-
return processor.exit();
|
|
31
|
-
});
|
|
32
|
-
return function (_x, _x2, _x3) {
|
|
33
|
-
return _ref.apply(this, arguments);
|
|
34
|
-
};
|
|
35
|
-
}();
|
|
36
|
-
this.resume = /*#__PURE__*/function () {
|
|
37
|
-
var _ref2 = _asyncToGenerator(function* (node, prevJob, processor) {
|
|
38
|
-
const endStatus = node.config.endStatus;
|
|
39
|
-
prevJob.set('status', endStatus);
|
|
40
|
-
return prevJob;
|
|
41
|
-
});
|
|
42
|
-
return function (_x4, _x5, _x6) {
|
|
43
|
-
return _ref2.apply(this, arguments);
|
|
44
|
-
};
|
|
45
|
-
}();
|
|
46
|
-
this.plugin = plugin;
|
|
47
|
-
plugin.app.on('beforeStart', () => this.load());
|
|
48
|
-
plugin.app.on('beforeStop', () => this.unload());
|
|
49
|
-
}
|
|
50
|
-
load() {
|
|
51
|
-
var _this2 = this;
|
|
52
|
-
return _asyncToGenerator(function* () {
|
|
53
|
-
const _this2$plugin$db$getC = _this2.plugin.db.getCollection('jobs'),
|
|
54
|
-
model = _this2$plugin$db$getC.model;
|
|
18
|
+
this.load = /*#__PURE__*/_asyncToGenerator(function* () {
|
|
19
|
+
const _this$plugin$db$getCo = _this.plugin.db.getCollection('jobs'),
|
|
20
|
+
model = _this$plugin$db$getCo.model;
|
|
55
21
|
const jobs = yield model.findAll({
|
|
56
22
|
where: {
|
|
57
23
|
status: _constants.JOB_STATUS.PENDING
|
|
@@ -73,42 +39,78 @@ class _default {
|
|
|
73
39
|
}]
|
|
74
40
|
});
|
|
75
41
|
jobs.forEach(job => {
|
|
76
|
-
|
|
42
|
+
_this.schedule(job);
|
|
77
43
|
});
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
44
|
+
});
|
|
45
|
+
this.unload = () => {
|
|
46
|
+
var _iterator = _createForOfIteratorHelper(this.timers.values()),
|
|
47
|
+
_step;
|
|
48
|
+
try {
|
|
49
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
|
+
const timer = _step.value;
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
}
|
|
53
|
+
} catch (err) {
|
|
54
|
+
_iterator.e(err);
|
|
55
|
+
} finally {
|
|
56
|
+
_iterator.f();
|
|
87
57
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
58
|
+
this.timers = new Map();
|
|
59
|
+
};
|
|
60
|
+
this.run = /*#__PURE__*/function () {
|
|
61
|
+
var _ref2 = _asyncToGenerator(function* (node, prevJob, processor) {
|
|
62
|
+
var _prevJob$id;
|
|
63
|
+
const job = yield processor.saveJob({
|
|
64
|
+
status: _constants.JOB_STATUS.PENDING,
|
|
65
|
+
result: null,
|
|
66
|
+
nodeId: node.id,
|
|
67
|
+
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
68
|
+
});
|
|
69
|
+
job.node = node;
|
|
70
|
+
// add to schedule
|
|
71
|
+
_this.schedule(job);
|
|
72
|
+
return processor.exit();
|
|
73
|
+
});
|
|
74
|
+
return function (_x, _x2, _x3) {
|
|
75
|
+
return _ref2.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
}();
|
|
78
|
+
this.resume = /*#__PURE__*/function () {
|
|
79
|
+
var _ref3 = _asyncToGenerator(function* (node, prevJob, processor) {
|
|
80
|
+
const endStatus = node.config.endStatus;
|
|
81
|
+
prevJob.set('status', endStatus);
|
|
82
|
+
return prevJob;
|
|
83
|
+
});
|
|
84
|
+
return function (_x4, _x5, _x6) {
|
|
85
|
+
return _ref3.apply(this, arguments);
|
|
86
|
+
};
|
|
87
|
+
}();
|
|
88
|
+
this.plugin = plugin;
|
|
89
|
+
plugin.app.on('beforeStart', this.load);
|
|
90
|
+
plugin.app.on('beforeStop', this.unload);
|
|
94
91
|
}
|
|
95
|
-
schedule(job
|
|
92
|
+
schedule(job) {
|
|
96
93
|
const now = new Date();
|
|
97
94
|
const createdAt = Date.parse(job.createdAt);
|
|
98
|
-
const delay = createdAt + duration - now.getTime();
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const delay = createdAt + job.node.config.duration - now.getTime();
|
|
96
|
+
if (delay > 0) {
|
|
97
|
+
const trigger = this.trigger.bind(this, job);
|
|
98
|
+
this.timers.set(job.id, setTimeout(trigger, delay));
|
|
99
|
+
} else {
|
|
100
|
+
this.trigger(job);
|
|
101
|
+
}
|
|
101
102
|
}
|
|
102
103
|
trigger(job) {
|
|
103
|
-
var
|
|
104
|
+
var _this2 = this;
|
|
104
105
|
return _asyncToGenerator(function* () {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
if (!job.execution) {
|
|
107
|
+
job.execution = yield job.getExecution();
|
|
108
|
+
}
|
|
109
|
+
if (job.execution.status === _constants.EXECUTION_STATUS.STARTED) {
|
|
110
|
+
_this2.plugin.resume(job);
|
|
109
111
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
+
if (_this2.timers.get(job.id)) {
|
|
113
|
+
_this2.timers.delete(job.id);
|
|
112
114
|
}
|
|
113
115
|
})();
|
|
114
116
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import FlowNodeModel from '../models/FlowNode';
|
|
2
1
|
import Plugin from '..';
|
|
3
2
|
import Processor from '../Processor';
|
|
4
|
-
|
|
3
|
+
import type { FlowNodeModel } from '../types';
|
|
4
|
+
export type Job = {
|
|
5
5
|
status: number;
|
|
6
6
|
result?: unknown;
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
} | null;
|
|
9
|
-
export
|
|
10
|
-
export
|
|
9
|
+
export type InstructionResult = Job | Promise<Job>;
|
|
10
|
+
export type Runner = (node: FlowNodeModel, input: any, processor: Processor) => InstructionResult;
|
|
11
11
|
export interface Instruction {
|
|
12
12
|
run: Runner;
|
|
13
13
|
resume?: Runner;
|
|
14
14
|
getScope?: (node: FlowNodeModel, job: any, processor: Processor) => any;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
type InstructionConstructor<T> = {
|
|
17
17
|
new (p: Plugin): T;
|
|
18
18
|
};
|
|
19
19
|
export default function <T extends Instruction>(plugin: any, more?: {
|
|
@@ -32,7 +32,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
32
32
|
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); }
|
|
33
33
|
function _default(plugin, more = {}) {
|
|
34
34
|
const instructions = plugin.instructions;
|
|
35
|
-
const natives = ['calculation', 'condition', 'parallel', 'loop', 'delay', 'manual', 'query', 'create', 'update', 'destroy', 'aggregate', 'request'].reduce((result, key) => Object.assign(result, {
|
|
35
|
+
const natives = ['calculation', 'condition', 'parallel', 'loop', 'delay', 'manual', 'query', 'create', 'update', 'destroy', 'aggregate', 'request', 'sql'].reduce((result, key) => Object.assign(result, {
|
|
36
36
|
[key]: (0, _utils().requireModule)(_path().default.isAbsolute(key) ? key : _path().default.join(__dirname, key))
|
|
37
37
|
}), {});
|
|
38
38
|
for (var _i = 0, _Object$entries = Object.entries(_objectSpread(_objectSpread({}, more), natives)); _i < _Object$entries.length; _i++) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import FlowNodeModel from '../models/FlowNode';
|
|
2
|
-
import JobModel from '../models/Job';
|
|
3
1
|
import Processor from '../Processor';
|
|
2
|
+
import type { FlowNodeModel, JobModel } from '../types';
|
|
4
3
|
declare const _default: {
|
|
5
4
|
run(node: FlowNodeModel, prevJob: JobModel, processor: Processor): Promise<{
|
|
6
5
|
status: number;
|
|
@@ -25,7 +25,7 @@ function submit(_x, _x2) {
|
|
|
25
25
|
}
|
|
26
26
|
function _submit() {
|
|
27
27
|
_submit = _asyncToGenerator(function* (context, next) {
|
|
28
|
-
var _values$result, _forms$formKey, _forms$formKey$action, _userJob$node$config$2, _userJob$result;
|
|
28
|
+
var _values$result, _values$result2, _forms$formKey, _forms$formKey$action, _userJob$node$config$2, _actionItem$values, _userJob$result;
|
|
29
29
|
const repository = _actions().utils.getRepositoryFromParams(context);
|
|
30
30
|
const _context$action$param = context.action.params,
|
|
31
31
|
filterByTk = _context$action$param.filterByTk,
|
|
@@ -49,11 +49,13 @@ function _submit() {
|
|
|
49
49
|
}
|
|
50
50
|
const _userJob$node$config$ = userJob.node.config.forms,
|
|
51
51
|
forms = _userJob$node$config$ === void 0 ? {} : _userJob$node$config$;
|
|
52
|
-
const _Object$keys = Object.keys((_values$result = values.result) !== null && _values$result !== void 0 ? _values$result : {}),
|
|
53
|
-
_Object$
|
|
54
|
-
formKey = _Object$
|
|
52
|
+
const _Object$keys$filter = Object.keys((_values$result = values.result) !== null && _values$result !== void 0 ? _values$result : {}).filter(key => key !== '_'),
|
|
53
|
+
_Object$keys$filter2 = _slicedToArray(_Object$keys$filter, 1),
|
|
54
|
+
formKey = _Object$keys$filter2[0];
|
|
55
|
+
const actionKey = (_values$result2 = values.result) === null || _values$result2 === void 0 ? void 0 : _values$result2._;
|
|
56
|
+
const actionItem = (_forms$formKey = forms[formKey]) === null || _forms$formKey === void 0 ? void 0 : (_forms$formKey$action = _forms$formKey.actions) === null || _forms$formKey$action === void 0 ? void 0 : _forms$formKey$action.find(item => item.key === actionKey);
|
|
55
57
|
// NOTE: validate status
|
|
56
|
-
if (userJob.status !== _constants.JOB_STATUS.PENDING || userJob.job.status !== _constants.JOB_STATUS.PENDING || userJob.execution.status !== _constants.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !
|
|
58
|
+
if (userJob.status !== _constants.JOB_STATUS.PENDING || userJob.job.status !== _constants.JOB_STATUS.PENDING || userJob.execution.status !== _constants.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !actionKey || (actionItem === null || actionItem === void 0 ? void 0 : actionItem.status) == null) {
|
|
57
59
|
return context.throw(400);
|
|
58
60
|
}
|
|
59
61
|
userJob.execution.workflow = userJob.workflow;
|
|
@@ -64,9 +66,17 @@ function _submit() {
|
|
|
64
66
|
if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
|
|
65
67
|
return context.throw(403);
|
|
66
68
|
}
|
|
69
|
+
const presetValues = processor.getParsedValue((_actionItem$values = actionItem.values) !== null && _actionItem$values !== void 0 ? _actionItem$values : {}, null, {
|
|
70
|
+
currentUser: currentUser.toJSON(),
|
|
71
|
+
currentRecord: values.result[formKey],
|
|
72
|
+
currentTime: new Date()
|
|
73
|
+
});
|
|
67
74
|
userJob.set({
|
|
68
|
-
status:
|
|
69
|
-
result:
|
|
75
|
+
status: actionItem.status,
|
|
76
|
+
result: actionItem.status > _constants.JOB_STATUS.PENDING ? {
|
|
77
|
+
[formKey]: Object.assign(values.result[formKey], presetValues),
|
|
78
|
+
_: actionKey
|
|
79
|
+
} : Object.assign((_userJob$result = userJob.result) !== null && _userJob$result !== void 0 ? _userJob$result : {}, values.result)
|
|
70
80
|
});
|
|
71
81
|
const handler = instruction.formTypes.get(forms[formKey].type);
|
|
72
82
|
if (handler && userJob.status) {
|
|
@@ -79,8 +89,10 @@ function _submit() {
|
|
|
79
89
|
context.body = userJob;
|
|
80
90
|
context.status = 202;
|
|
81
91
|
yield next();
|
|
92
|
+
userJob.job.execution = userJob.execution;
|
|
82
93
|
userJob.job.latestUserJob = userJob;
|
|
83
94
|
// NOTE: resume the process and no `await` for quick returning
|
|
95
|
+
processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
|
|
84
96
|
plugin.resume(userJob.job);
|
|
85
97
|
});
|
|
86
98
|
return _submit.apply(this, arguments);
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
+
const _excluded = ["_"];
|
|
7
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; }
|
|
8
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; }
|
|
9
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; }
|
|
@@ -15,6 +16,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
15
16
|
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; }
|
|
16
17
|
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; } }
|
|
17
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
18
21
|
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); } }
|
|
19
22
|
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); }); }; }
|
|
20
23
|
function _default(_x, _x2, _x3) {
|
|
@@ -28,7 +31,10 @@ function _ref() {
|
|
|
28
31
|
if (!repo) {
|
|
29
32
|
throw new Error(`collection ${collection} for create data on manual node not found`);
|
|
30
33
|
}
|
|
31
|
-
const
|
|
34
|
+
const _instance$result = instance.result,
|
|
35
|
+
_ = _instance$result._,
|
|
36
|
+
form = _objectWithoutProperties(_instance$result, _excluded);
|
|
37
|
+
const _Object$values = Object.values(form),
|
|
32
38
|
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
33
39
|
values = _Object$values2[0];
|
|
34
40
|
yield repo.create({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Processor } from '../../..';
|
|
2
2
|
import ManualInstruction from '..';
|
|
3
|
-
export
|
|
3
|
+
export type FormHandler = (this: ManualInstruction, instance: any, formConfig: any, processor: Processor) => Promise<void>;
|
|
4
4
|
export default function ({ formTypes }: {
|
|
5
5
|
formTypes: any;
|
|
6
6
|
}): void;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
+
const _excluded = ["_"];
|
|
7
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; }
|
|
8
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; }
|
|
9
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; }
|
|
@@ -15,6 +16,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
15
16
|
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; }
|
|
16
17
|
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; } }
|
|
17
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
18
21
|
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); } }
|
|
19
22
|
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); }); }; }
|
|
20
23
|
function _default(_x, _x2, _x3) {
|
|
@@ -29,7 +32,10 @@ function _ref() {
|
|
|
29
32
|
if (!repo) {
|
|
30
33
|
throw new Error(`collection ${collection} for update data on manual node not found`);
|
|
31
34
|
}
|
|
32
|
-
const
|
|
35
|
+
const _instance$result = instance.result,
|
|
36
|
+
_ = _instance$result._,
|
|
37
|
+
form = _objectWithoutProperties(_instance$result, _excluded);
|
|
38
|
+
const _Object$values = Object.values(form),
|
|
33
39
|
_Object$values2 = _slicedToArray(_Object$values, 1),
|
|
34
40
|
values = _Object$values2[0];
|
|
35
41
|
yield repo.update({
|
|
@@ -2,7 +2,7 @@ import { Registry } from '@nocobase/utils';
|
|
|
2
2
|
import Plugin from '../..';
|
|
3
3
|
import { Instruction } from '..';
|
|
4
4
|
import { FormHandler } from './forms';
|
|
5
|
-
|
|
5
|
+
type FormType = {
|
|
6
6
|
type: 'custom' | 'create' | 'update';
|
|
7
7
|
actions: number[];
|
|
8
8
|
options: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import FlowNodeModel from '../models/FlowNode';
|
|
2
|
-
import JobModel from '../models/Job';
|
|
3
1
|
import Processor from '../Processor';
|
|
2
|
+
import type { FlowNodeModel, JobModel } from '../types';
|
|
4
3
|
export declare const PARALLEL_MODE: {
|
|
5
4
|
readonly ALL: "all";
|
|
6
5
|
readonly ANY: "any";
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _constants = require("../constants");
|
|
8
|
+
var _utils = require("../utils");
|
|
8
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; }
|
|
9
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; }
|
|
10
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; }
|
|
@@ -24,7 +25,13 @@ var _default = {
|
|
|
24
25
|
failOnEmpty = _node$config$failOnEm === void 0 ? false : _node$config$failOnEm;
|
|
25
26
|
const repo = node.constructor.database.getRepository(collection);
|
|
26
27
|
const options = processor.getParsedValue(params, node);
|
|
28
|
+
const appends = options.appends ? Array.from(options.appends.reduce((set, field) => {
|
|
29
|
+
set.add(field.split('.')[0]);
|
|
30
|
+
set.add(field);
|
|
31
|
+
return set;
|
|
32
|
+
}, new Set())) : options.appends;
|
|
27
33
|
const result = yield (multiple ? repo.find : repo.findOne).call(repo, _objectSpread(_objectSpread({}, options), {}, {
|
|
34
|
+
appends: appends,
|
|
28
35
|
transaction: processor.transaction
|
|
29
36
|
}));
|
|
30
37
|
if (failOnEmpty && (multiple ? !result.length : !result)) {
|
|
@@ -37,7 +44,7 @@ var _default = {
|
|
|
37
44
|
// e.g. Object.prototype.hasOwnProperty.call(result, 'id') // false
|
|
38
45
|
// so the properties can not be get by json-templates(object-path)
|
|
39
46
|
return {
|
|
40
|
-
result:
|
|
47
|
+
result: (0, _utils.toJSON)(result),
|
|
41
48
|
status: _constants.JOB_STATUS.RESOLVED
|
|
42
49
|
};
|
|
43
50
|
})();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { Instruction } from './index';
|
|
3
3
|
import Processor from '../Processor';
|
|
4
|
-
import FlowNodeModel from '../
|
|
4
|
+
import type { FlowNodeModel } from '../types';
|
|
5
5
|
export interface Header {
|
|
6
6
|
name: string;
|
|
7
7
|
value: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
|
|
10
10
|
headers: Array<Header>;
|
|
11
11
|
ignoreFail: boolean;
|
|
12
12
|
};
|
|
13
13
|
export default class implements Instruction {
|
|
14
14
|
plugin: any;
|
|
15
15
|
constructor(plugin: any);
|
|
16
|
-
run(node: FlowNodeModel,
|
|
16
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
|
|
17
17
|
resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
|
|
18
18
|
}
|
|
@@ -57,14 +57,17 @@ class _default {
|
|
|
57
57
|
this.plugin = void 0;
|
|
58
58
|
this.plugin = plugin;
|
|
59
59
|
}
|
|
60
|
-
run(node,
|
|
60
|
+
run(node, prevJob, processor) {
|
|
61
61
|
var _this = this;
|
|
62
62
|
return _asyncToGenerator(function* () {
|
|
63
|
+
var _prevJob$id;
|
|
63
64
|
const job = yield processor.saveJob({
|
|
64
65
|
status: _constants.JOB_STATUS.PENDING,
|
|
65
|
-
nodeId: node.id
|
|
66
|
+
nodeId: node.id,
|
|
67
|
+
upstreamId: (_prevJob$id = prevJob === null || prevJob === void 0 ? void 0 : prevJob.id) !== null && _prevJob$id !== void 0 ? _prevJob$id : null
|
|
66
68
|
});
|
|
67
69
|
const config = processor.getParsedValue(node.config, node);
|
|
70
|
+
// eslint-disable-next-line promise/catch-or-return
|
|
68
71
|
request(config).then(response => {
|
|
69
72
|
job.set({
|
|
70
73
|
status: _constants.JOB_STATUS.RESOLVED,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Processor } from '..';
|
|
2
|
+
import type { FlowNodeModel } from '../types';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
5
|
+
status: number;
|
|
6
|
+
result?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
result: [unknown[], unknown];
|
|
9
|
+
status: number;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _ = require("..");
|
|
8
|
+
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); } }
|
|
9
|
+
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); }); }; }
|
|
10
|
+
var _default = {
|
|
11
|
+
run(node, input, processor) {
|
|
12
|
+
return _asyncToGenerator(function* () {
|
|
13
|
+
var _node$config$sql;
|
|
14
|
+
const sequelize = node.constructor.database.sequelize;
|
|
15
|
+
const sql = processor.getParsedValue((_node$config$sql = node.config.sql) !== null && _node$config$sql !== void 0 ? _node$config$sql : '', node).trim();
|
|
16
|
+
if (!sql) {
|
|
17
|
+
return {
|
|
18
|
+
status: _.JOB_STATUS.RESOLVED
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const result = yield sequelize.query(sql, {
|
|
22
|
+
transaction: processor.transaction
|
|
23
|
+
// plain: true,
|
|
24
|
+
// model: db.getCollection(node.config.collection).model
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
result,
|
|
29
|
+
status: _.JOB_STATUS.RESOLVED
|
|
30
|
+
};
|
|
31
|
+
})();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.default = _default;
|
|
@@ -65,7 +65,7 @@ function migrateConfig(_ref = {}) {
|
|
|
65
65
|
var _calculation$operands, _calculator$operands;
|
|
66
66
|
let calculation = _ref.calculation,
|
|
67
67
|
config = _objectWithoutProperties(_ref, _excluded);
|
|
68
|
-
if (!(calculation
|
|
68
|
+
if (!(calculation !== null && calculation !== void 0 && calculation.calculator) || !(calculation !== null && calculation !== void 0 && (_calculation$operands = calculation.operands) !== null && _calculation$operands !== void 0 && _calculation$operands.length)) {
|
|
69
69
|
return config;
|
|
70
70
|
}
|
|
71
71
|
const calculator = calculatorsMap[calculation.calculator];
|
|
@@ -59,7 +59,7 @@ function migrateConfig({
|
|
|
59
59
|
calculator = '===',
|
|
60
60
|
operands = []
|
|
61
61
|
}) => {
|
|
62
|
-
return `(${operands.map(operand =>
|
|
62
|
+
return `(${operands.map(operand => operand !== null && operand !== void 0 && operand.group ? migrateConfig(operand) : operand).join(` ${calculatorsMap[calculator]} `)})`;
|
|
63
63
|
})
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
function
|
|
8
|
-
const data = require("
|
|
9
|
-
|
|
7
|
+
function _database() {
|
|
8
|
+
const data = require("@nocobase/database");
|
|
9
|
+
_database = function _database() {
|
|
10
10
|
return data;
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
@@ -34,22 +34,22 @@ class _default extends _server().Migration {
|
|
|
34
34
|
yield sequelize.transaction( /*#__PURE__*/function () {
|
|
35
35
|
var _ref = _asyncToGenerator(function* (transaction) {
|
|
36
36
|
yield queryInterface.changeColumn(db.getCollection('workflows').model.getTableName(), 'config', {
|
|
37
|
-
type:
|
|
37
|
+
type: _database().DataTypes.JSON
|
|
38
38
|
}, {
|
|
39
39
|
transaction
|
|
40
40
|
});
|
|
41
41
|
yield queryInterface.changeColumn(db.getCollection('flow_nodes').model.getTableName(), 'config', {
|
|
42
|
-
type:
|
|
42
|
+
type: _database().DataTypes.JSON
|
|
43
43
|
}, {
|
|
44
44
|
transaction
|
|
45
45
|
});
|
|
46
46
|
yield queryInterface.changeColumn(db.getCollection('executions').model.getTableName(), 'context', {
|
|
47
|
-
type:
|
|
47
|
+
type: _database().DataTypes.JSON
|
|
48
48
|
}, {
|
|
49
49
|
transaction
|
|
50
50
|
});
|
|
51
51
|
yield queryInterface.changeColumn(db.getCollection('jobs').model.getTableName(), 'result', {
|
|
52
|
-
type:
|
|
52
|
+
type: _database().DataTypes.JSON
|
|
53
53
|
}, {
|
|
54
54
|
transaction
|
|
55
55
|
});
|