@nocobase/plugin-workflow 0.13.0-alpha.4 → 0.13.0-alpha.6
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/dist/client/index.js +132 -9332
- package/dist/index.js +37 -16
- package/dist/locale/en-US.js +22 -4
- package/dist/locale/es-ES.js +22 -4
- package/dist/locale/fr-FR.js +22 -4
- package/dist/locale/ja-JP.js +22 -4
- package/dist/locale/pt-BR.js +22 -4
- package/dist/locale/ru-RU.js +22 -4
- package/dist/locale/tr-TR.js +22 -4
- package/dist/locale/zh-CN.js +22 -4
- package/dist/node_modules/cron-parser/lib/parser.js +1 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/index-cjs.js +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.js +70 -55
- package/dist/server/Processor.js +42 -25
- package/dist/server/actions/executions.js +41 -14
- package/dist/server/actions/index.js +39 -34
- package/dist/server/actions/nodes.js +48 -28
- package/dist/server/actions/workflows.js +50 -20
- package/dist/server/collections/executions.js +22 -4
- package/dist/server/collections/flow_nodes.js +22 -4
- package/dist/server/collections/jobs.js +22 -4
- package/dist/server/collections/workflows.js +22 -4
- package/dist/server/constants.js +30 -6
- package/dist/server/fields/expression-field.js +29 -8
- package/dist/server/fields/index.js +24 -7
- package/dist/server/functions/index.js +22 -4
- package/dist/server/index.js +45 -39
- package/dist/server/instructions/aggregate.js +30 -13
- package/dist/server/instructions/calculation.js +30 -13
- package/dist/server/instructions/condition.js +36 -17
- package/dist/server/instructions/create.js +26 -9
- package/dist/server/instructions/delay.js +27 -10
- package/dist/server/instructions/destroy.js +24 -7
- package/dist/server/instructions/index.js +35 -12
- package/dist/server/instructions/loop.js +27 -10
- package/dist/server/instructions/manual/actions.js +31 -10
- package/dist/server/instructions/manual/collecions/jobs.js +22 -4
- package/dist/server/instructions/manual/collecions/users.js +22 -4
- package/dist/server/instructions/manual/collecions/users_jobs.js +22 -4
- package/dist/server/instructions/manual/forms/create.js +22 -4
- package/dist/server/instructions/manual/forms/index.js +36 -14
- package/dist/server/instructions/manual/forms/update.js +22 -4
- package/dist/server/instructions/manual/index.js +60 -41
- package/dist/server/instructions/parallel.js +47 -28
- package/dist/server/instructions/query.js +31 -14
- package/dist/server/instructions/request.js +39 -16
- package/dist/server/instructions/sql.js +25 -8
- package/dist/server/instructions/update.js +24 -7
- package/dist/server/migrations/20221129153547-calculation-variables.js +24 -7
- package/dist/server/migrations/20230221032941-change-request-body-type.js +28 -7
- package/dist/server/migrations/20230221071831-calculation-expression.js +24 -7
- package/dist/server/migrations/20230221121203-condition-calculation.js +62 -7
- package/dist/server/migrations/20230221162902-jsonb-to-json.js +29 -12
- package/dist/server/migrations/20230411034722-manual-multi-form.js +38 -15
- package/dist/server/migrations/20230612021134-manual-collection-block.js +26 -9
- package/dist/server/migrations/20230710115902-manual-action-values.js +24 -7
- package/dist/server/migrations/20230809113132-workflow-options.js +24 -7
- package/dist/server/triggers/collection.js +26 -9
- package/dist/server/triggers/form.js +28 -11
- package/dist/server/triggers/index.js +42 -17
- package/dist/server/triggers/schedule.js +56 -31
- package/dist/server/types/Execution.js +24 -7
- package/dist/server/types/FlowNode.js +24 -7
- package/dist/server/types/Job.js +24 -7
- package/dist/server/types/Workflow.js +24 -7
- package/dist/server/types/index.js +15 -2
- package/dist/server/utils.js +26 -4
- package/dist/swagger/index.d.ts +103 -53
- package/dist/swagger/index.js +144 -71
- package/package.json +2 -2
package/dist/server/Plugin.js
CHANGED
|
@@ -1,36 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var Plugin_exports = {};
|
|
29
|
+
__export(Plugin_exports, {
|
|
30
|
+
default: () => WorkflowPlugin
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(Plugin_exports);
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var import_lru_cache = __toESM(require("lru-cache"));
|
|
35
|
+
var import_winston = __toESM(require("winston"));
|
|
36
|
+
var import_database = require("@nocobase/database");
|
|
37
|
+
var import_server = require("@nocobase/server");
|
|
38
|
+
var import_utils = require("@nocobase/utils");
|
|
39
|
+
var import_logger = require("@nocobase/logger");
|
|
40
|
+
var import_Processor = __toESM(require("./Processor"));
|
|
41
|
+
var import_actions = __toESM(require("./actions"));
|
|
42
|
+
var import_constants = require("./constants");
|
|
43
|
+
var import_fields = __toESM(require("./fields"));
|
|
44
|
+
var import_functions = __toESM(require("./functions"));
|
|
45
|
+
var import_instructions = __toESM(require("./instructions"));
|
|
46
|
+
var import_triggers = __toESM(require("./triggers"));
|
|
47
|
+
class WorkflowPlugin extends import_server.Plugin {
|
|
48
|
+
instructions = new import_utils.Registry();
|
|
49
|
+
triggers = new import_utils.Registry();
|
|
50
|
+
functions = new import_utils.Registry();
|
|
34
51
|
executing = false;
|
|
35
52
|
pending = [];
|
|
36
53
|
events = [];
|
|
@@ -42,17 +59,17 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
42
59
|
if (this.loggerCache.has(key)) {
|
|
43
60
|
return this.loggerCache.get(key);
|
|
44
61
|
}
|
|
45
|
-
const logger
|
|
62
|
+
const logger = (0, import_logger.createLogger)({
|
|
46
63
|
transports: [
|
|
47
64
|
"console",
|
|
48
|
-
new
|
|
49
|
-
filename:
|
|
50
|
-
level:
|
|
65
|
+
new import_winston.default.transports.File({
|
|
66
|
+
filename: (0, import_logger.getLoggerFilePath)("workflows", date, `${workflowId}.log`),
|
|
67
|
+
level: (0, import_logger.getLoggerLevel)()
|
|
51
68
|
})
|
|
52
69
|
]
|
|
53
70
|
});
|
|
54
|
-
this.loggerCache.set(key, logger
|
|
55
|
-
return logger
|
|
71
|
+
this.loggerCache.set(key, logger);
|
|
72
|
+
return logger;
|
|
56
73
|
}
|
|
57
74
|
onBeforeSave = async (instance, options) => {
|
|
58
75
|
const Model = instance.constructor;
|
|
@@ -77,7 +94,7 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
77
94
|
key: instance.key,
|
|
78
95
|
current: true,
|
|
79
96
|
id: {
|
|
80
|
-
[
|
|
97
|
+
[import_database.Op.ne]: instance.id
|
|
81
98
|
}
|
|
82
99
|
},
|
|
83
100
|
transaction: options.transaction
|
|
@@ -95,12 +112,12 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
95
112
|
};
|
|
96
113
|
async load() {
|
|
97
114
|
const { db, options } = this;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.loggerCache = new
|
|
115
|
+
(0, import_fields.default)(this);
|
|
116
|
+
(0, import_actions.default)(this);
|
|
117
|
+
(0, import_triggers.default)(this, options.triggers);
|
|
118
|
+
(0, import_instructions.default)(this, options.instructions);
|
|
119
|
+
(0, import_functions.default)(this, options.functions);
|
|
120
|
+
this.loggerCache = new import_lru_cache.default({
|
|
104
121
|
max: 20,
|
|
105
122
|
updateAgeOnGet: true,
|
|
106
123
|
dispose(logger) {
|
|
@@ -125,11 +142,11 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
125
142
|
this.app.acl.allow("users_jobs", ["list", "get", "submit"], "loggedIn");
|
|
126
143
|
this.app.acl.allow("workflows", ["trigger"], "loggedIn");
|
|
127
144
|
await db.import({
|
|
128
|
-
directory:
|
|
145
|
+
directory: import_path.default.resolve(__dirname, "collections")
|
|
129
146
|
});
|
|
130
147
|
this.db.addMigrations({
|
|
131
148
|
namespace: "workflow",
|
|
132
|
-
directory:
|
|
149
|
+
directory: import_path.default.resolve(__dirname, "migrations"),
|
|
133
150
|
context: {
|
|
134
151
|
plugin: this
|
|
135
152
|
}
|
|
@@ -195,7 +212,7 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
195
212
|
this.dispatch();
|
|
196
213
|
}
|
|
197
214
|
createProcessor(execution, options = {}) {
|
|
198
|
-
return new
|
|
215
|
+
return new import_Processor.default(execution, { ...options, plugin: this });
|
|
199
216
|
}
|
|
200
217
|
prepare = async () => {
|
|
201
218
|
var _a;
|
|
@@ -224,7 +241,7 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
224
241
|
{
|
|
225
242
|
context,
|
|
226
243
|
key: workflow.key,
|
|
227
|
-
status:
|
|
244
|
+
status: import_constants.EXECUTION_STATUS.QUEUEING
|
|
228
245
|
},
|
|
229
246
|
{ transaction }
|
|
230
247
|
);
|
|
@@ -264,7 +281,7 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
264
281
|
} else {
|
|
265
282
|
const execution = await this.db.getRepository("executions").findOne({
|
|
266
283
|
filter: {
|
|
267
|
-
status:
|
|
284
|
+
status: import_constants.EXECUTION_STATUS.QUEUEING
|
|
268
285
|
},
|
|
269
286
|
appends: ["workflow"],
|
|
270
287
|
sort: "createdAt"
|
|
@@ -284,8 +301,8 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
284
301
|
}
|
|
285
302
|
async process(execution, job) {
|
|
286
303
|
var _a, _b;
|
|
287
|
-
if (execution.status ===
|
|
288
|
-
await execution.update({ status:
|
|
304
|
+
if (execution.status === import_constants.EXECUTION_STATUS.QUEUEING) {
|
|
305
|
+
await execution.update({ status: import_constants.EXECUTION_STATUS.STARTED });
|
|
289
306
|
}
|
|
290
307
|
const processor = this.createProcessor(execution);
|
|
291
308
|
this.getLogger(execution.workflowId).info(`execution (${execution.id}) ${job ? "resuming" : "starting"}...`);
|
|
@@ -302,5 +319,3 @@ class WorkflowPlugin extends server.Plugin {
|
|
|
302
319
|
}
|
|
303
320
|
}
|
|
304
321
|
}
|
|
305
|
-
|
|
306
|
-
module.exports = WorkflowPlugin;
|
package/dist/server/Processor.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var Processor_exports = {};
|
|
19
|
+
__export(Processor_exports, {
|
|
20
|
+
default: () => Processor
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(Processor_exports);
|
|
23
|
+
var import_database = require("@nocobase/database");
|
|
24
|
+
var import_evaluators = require("@nocobase/evaluators");
|
|
25
|
+
var import_utils = require("@nocobase/utils");
|
|
26
|
+
var import_constants = require("./constants");
|
|
8
27
|
class Processor {
|
|
9
28
|
constructor(execution, options) {
|
|
10
29
|
this.execution = execution;
|
|
@@ -12,13 +31,13 @@ class Processor {
|
|
|
12
31
|
this.logger = options.plugin.getLogger(execution.workflowId);
|
|
13
32
|
}
|
|
14
33
|
static StatusMap = {
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
34
|
+
[import_constants.JOB_STATUS.PENDING]: import_constants.EXECUTION_STATUS.STARTED,
|
|
35
|
+
[import_constants.JOB_STATUS.RESOLVED]: import_constants.EXECUTION_STATUS.RESOLVED,
|
|
36
|
+
[import_constants.JOB_STATUS.FAILED]: import_constants.EXECUTION_STATUS.FAILED,
|
|
37
|
+
[import_constants.JOB_STATUS.ERROR]: import_constants.EXECUTION_STATUS.ERROR,
|
|
38
|
+
[import_constants.JOB_STATUS.ABORTED]: import_constants.EXECUTION_STATUS.ABORTED,
|
|
39
|
+
[import_constants.JOB_STATUS.CANCELED]: import_constants.EXECUTION_STATUS.CANCELED,
|
|
40
|
+
[import_constants.JOB_STATUS.REJECTED]: import_constants.EXECUTION_STATUS.REJECTED
|
|
22
41
|
};
|
|
23
42
|
logger;
|
|
24
43
|
transaction;
|
|
@@ -72,7 +91,7 @@ class Processor {
|
|
|
72
91
|
}
|
|
73
92
|
async start() {
|
|
74
93
|
const { execution } = this;
|
|
75
|
-
if (execution.status !==
|
|
94
|
+
if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
|
|
76
95
|
throw new Error(`execution was ended with status ${execution.status}`);
|
|
77
96
|
}
|
|
78
97
|
await this.prepare();
|
|
@@ -80,12 +99,12 @@ class Processor {
|
|
|
80
99
|
const head = this.nodes.find((item) => !item.upstream);
|
|
81
100
|
await this.run(head, { result: execution.context });
|
|
82
101
|
} else {
|
|
83
|
-
await this.exit(
|
|
102
|
+
await this.exit(import_constants.JOB_STATUS.RESOLVED);
|
|
84
103
|
}
|
|
85
104
|
}
|
|
86
105
|
async resume(job) {
|
|
87
106
|
const { execution } = this;
|
|
88
|
-
if (execution.status !==
|
|
107
|
+
if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
|
|
89
108
|
throw new Error(`execution was ended with status ${execution.status}`);
|
|
90
109
|
}
|
|
91
110
|
await this.prepare();
|
|
@@ -113,15 +132,15 @@ class Processor {
|
|
|
113
132
|
);
|
|
114
133
|
job = {
|
|
115
134
|
result: err instanceof Error ? { message: err.message, stack: process.env.NODE_ENV === "production" ? [] : err.stack } : err,
|
|
116
|
-
status:
|
|
135
|
+
status: import_constants.JOB_STATUS.ERROR
|
|
117
136
|
};
|
|
118
137
|
if (prevJob && prevJob.nodeId === node.id) {
|
|
119
138
|
prevJob.set(job);
|
|
120
139
|
job = prevJob;
|
|
121
140
|
}
|
|
122
141
|
}
|
|
123
|
-
if (!(job instanceof
|
|
124
|
-
job.upstreamId = prevJob instanceof
|
|
142
|
+
if (!(job instanceof import_database.Model)) {
|
|
143
|
+
job.upstreamId = prevJob instanceof import_database.Model ? prevJob.get("id") : null;
|
|
125
144
|
job.nodeId = node.id;
|
|
126
145
|
}
|
|
127
146
|
const savedJob = await this.saveJob(job);
|
|
@@ -129,7 +148,7 @@ class Processor {
|
|
|
129
148
|
`execution (${this.execution.id}) run instruction [${node.type}] for node (${node.id}) finished as status: ${savedJob.status}`
|
|
130
149
|
);
|
|
131
150
|
this.logger.debug(`result of node`, { data: savedJob.result });
|
|
132
|
-
if (savedJob.status ===
|
|
151
|
+
if (savedJob.status === import_constants.JOB_STATUS.RESOLVED && node.downstream) {
|
|
133
152
|
this.logger.debug(`run next node (${node.downstreamId})`);
|
|
134
153
|
return this.run(node.downstream, savedJob);
|
|
135
154
|
}
|
|
@@ -275,13 +294,11 @@ class Processor {
|
|
|
275
294
|
};
|
|
276
295
|
}
|
|
277
296
|
getParsedValue(value, sourceNodeId, additionalScope) {
|
|
278
|
-
const template =
|
|
297
|
+
const template = (0, import_utils.parse)(value);
|
|
279
298
|
const scope = Object.assign(this.getScope(sourceNodeId), additionalScope);
|
|
280
299
|
template.parameters.forEach(({ key }) => {
|
|
281
|
-
|
|
300
|
+
(0, import_evaluators.appendArrayColumn)(scope, key);
|
|
282
301
|
});
|
|
283
302
|
return template(scope);
|
|
284
303
|
}
|
|
285
304
|
}
|
|
286
|
-
|
|
287
|
-
module.exports = Processor;
|
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var executions_exports = {};
|
|
29
|
+
__export(executions_exports, {
|
|
30
|
+
destroy: () => destroy
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(executions_exports);
|
|
33
|
+
var import_actions = __toESM(require("@nocobase/actions"));
|
|
34
|
+
var import_database = require("@nocobase/database");
|
|
35
|
+
var import_constants = require("../constants");
|
|
11
36
|
async function destroy(context, next) {
|
|
12
37
|
context.action.mergeParams({
|
|
13
38
|
filter: {
|
|
14
39
|
status: {
|
|
15
|
-
[
|
|
40
|
+
[import_database.Op.ne]: import_constants.EXECUTION_STATUS.STARTED
|
|
16
41
|
}
|
|
17
42
|
}
|
|
18
43
|
});
|
|
19
|
-
await
|
|
44
|
+
await import_actions.default.destroy(context, next);
|
|
20
45
|
}
|
|
21
|
-
|
|
22
|
-
exports
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
destroy
|
|
49
|
+
});
|
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var actions_exports = {};
|
|
29
|
+
__export(actions_exports, {
|
|
30
|
+
default: () => actions_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(actions_exports);
|
|
33
|
+
var workflows = __toESM(require("./workflows"));
|
|
34
|
+
var nodes = __toESM(require("./nodes"));
|
|
35
|
+
var executions = __toESM(require("./executions"));
|
|
29
36
|
function make(name, mod) {
|
|
30
37
|
return Object.keys(mod).reduce(
|
|
31
38
|
(result, key) => ({
|
|
@@ -37,16 +44,14 @@ function make(name, mod) {
|
|
|
37
44
|
}
|
|
38
45
|
function actions_default({ app }) {
|
|
39
46
|
app.actions({
|
|
40
|
-
...make("workflows",
|
|
47
|
+
...make("workflows", workflows),
|
|
41
48
|
...make("workflows.nodes", {
|
|
42
|
-
create:
|
|
43
|
-
destroy: nodes__namespace.destroy
|
|
49
|
+
create: nodes.create
|
|
44
50
|
}),
|
|
45
51
|
...make("flow_nodes", {
|
|
46
|
-
update:
|
|
52
|
+
update: nodes.update,
|
|
53
|
+
destroy: nodes.destroy
|
|
47
54
|
}),
|
|
48
|
-
...make("executions",
|
|
55
|
+
...make("executions", executions)
|
|
49
56
|
});
|
|
50
57
|
}
|
|
51
|
-
|
|
52
|
-
module.exports = actions_default;
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var nodes_exports = {};
|
|
19
|
+
__export(nodes_exports, {
|
|
20
|
+
create: () => create,
|
|
21
|
+
destroy: () => destroy,
|
|
22
|
+
update: () => update
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(nodes_exports);
|
|
25
|
+
var import_actions = require("@nocobase/actions");
|
|
26
|
+
var import_database = require("@nocobase/database");
|
|
6
27
|
async function create(context, next) {
|
|
7
28
|
const { db } = context;
|
|
8
|
-
const repository =
|
|
29
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
9
30
|
const { whitelist, blacklist, updateAssociationValues, values, associatedIndex: workflowId } = context.action.params;
|
|
10
31
|
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
11
32
|
const workflow = await repository.getSourceModel(transaction);
|
|
@@ -56,7 +77,7 @@ async function create(context, next) {
|
|
|
56
77
|
const [downstream] = await upstream.getBranches({
|
|
57
78
|
where: {
|
|
58
79
|
id: {
|
|
59
|
-
[
|
|
80
|
+
[import_database.Op.ne]: instance.id
|
|
60
81
|
},
|
|
61
82
|
branchIndex: instance.branchIndex
|
|
62
83
|
},
|
|
@@ -95,20 +116,18 @@ function searchBranchDownstreams(nodes, from) {
|
|
|
95
116
|
}
|
|
96
117
|
async function destroy(context, next) {
|
|
97
118
|
const { db } = context;
|
|
98
|
-
const repository =
|
|
119
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
99
120
|
const { filterByTk } = context.action.params;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
transaction
|
|
111
|
-
});
|
|
121
|
+
const fields = ["id", "upstreamId", "downstreamId", "branchIndex"];
|
|
122
|
+
const instance = await repository.findOne({
|
|
123
|
+
filterByTk,
|
|
124
|
+
fields: [...fields, "workflowId"],
|
|
125
|
+
appends: ["upstream", "downstream", "workflow"]
|
|
126
|
+
});
|
|
127
|
+
if (instance.workflow.executed) {
|
|
128
|
+
context.throw(400, "Nodes in executed workflow could not be deleted");
|
|
129
|
+
}
|
|
130
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
112
131
|
const { upstream, downstream } = instance.get();
|
|
113
132
|
if (upstream && upstream.downstreamId === instance.id) {
|
|
114
133
|
await upstream.update(
|
|
@@ -138,7 +157,6 @@ async function destroy(context, next) {
|
|
|
138
157
|
nodes.forEach((item) => {
|
|
139
158
|
nodesMap.set(item.id, item);
|
|
140
159
|
});
|
|
141
|
-
nodesMap.set(instance.id, instance);
|
|
142
160
|
nodes.forEach((item) => {
|
|
143
161
|
if (item.upstreamId) {
|
|
144
162
|
item.upstream = nodesMap.get(item.upstreamId);
|
|
@@ -147,18 +165,18 @@ async function destroy(context, next) {
|
|
|
147
165
|
item.downstream = nodesMap.get(item.downstreamId);
|
|
148
166
|
}
|
|
149
167
|
});
|
|
150
|
-
const branchNodes = searchBranchNodes(nodes, instance);
|
|
168
|
+
const branchNodes = searchBranchNodes(nodes, nodesMap.get(instance.id));
|
|
151
169
|
await repository.destroy({
|
|
152
170
|
filterByTk: [instance.id, ...branchNodes.map((item) => item.id)],
|
|
153
171
|
transaction
|
|
154
172
|
});
|
|
155
|
-
return instance;
|
|
156
173
|
});
|
|
174
|
+
context.body = instance;
|
|
157
175
|
await next();
|
|
158
176
|
}
|
|
159
177
|
async function update(context, next) {
|
|
160
178
|
const { db } = context;
|
|
161
|
-
const repository =
|
|
179
|
+
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
162
180
|
const { filterByTk, values, whitelist, blacklist, filter, updateAssociationValues } = context.action.params;
|
|
163
181
|
context.body = await db.sequelize.transaction(async (transaction) => {
|
|
164
182
|
const { workflow } = await repository.findOne({
|
|
@@ -182,7 +200,9 @@ async function update(context, next) {
|
|
|
182
200
|
});
|
|
183
201
|
await next();
|
|
184
202
|
}
|
|
185
|
-
|
|
186
|
-
exports
|
|
187
|
-
|
|
188
|
-
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
create,
|
|
206
|
+
destroy,
|
|
207
|
+
update
|
|
208
|
+
});
|