@nocobase/plugin-workflow 0.17.0-alpha.3 → 0.17.0-alpha.4
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/WorkflowPane.d.ts +2 -0
- package/dist/client/components/index.d.ts +5 -0
- package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
- package/dist/client/index.d.ts +14 -6
- package/dist/client/index.js +136 -186
- package/dist/client/nodes/calculation.d.ts +8 -62
- package/dist/client/nodes/condition.d.ts +9 -9
- package/dist/client/nodes/create.d.ts +3 -5
- package/dist/client/nodes/destroy.d.ts +3 -4
- package/dist/client/nodes/index.d.ts +2 -6
- package/dist/client/nodes/query.d.ts +3 -5
- package/dist/client/nodes/update.d.ts +4 -4
- package/dist/client/triggers/collection.d.ts +3 -4
- package/dist/client/triggers/index.d.ts +2 -11
- package/dist/client/triggers/schedule/index.d.ts +3 -4
- package/dist/client/utils.d.ts +1 -0
- package/dist/externalVersion.js +11 -13
- package/dist/locale/en-US.json +1 -32
- package/dist/locale/es-ES.json +1 -32
- package/dist/locale/fr-FR.json +1 -32
- package/dist/locale/ja-JP.json +0 -5
- package/dist/locale/pt-BR.json +1 -32
- package/dist/locale/ru-RU.json +0 -5
- package/dist/locale/tr-TR.json +0 -5
- package/dist/locale/zh-CN.json +42 -114
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +12 -2
- package/dist/server/Plugin.js +31 -7
- package/dist/server/Processor.d.ts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/instructions/CalculationInstruction.d.ts +15 -0
- package/dist/server/instructions/{calculation.js → CalculationInstruction.js} +13 -6
- package/dist/server/instructions/ConditionInstruction.d.ts +19 -0
- package/dist/server/instructions/{condition.js → ConditionInstruction.js} +11 -7
- package/dist/server/instructions/CreateInstruction.d.ts +10 -0
- package/dist/server/instructions/{create.js → CreateInstruction.js} +13 -6
- package/dist/server/instructions/DestroyInstruction.d.ts +10 -0
- package/dist/server/instructions/{destroy.js → DestroyInstruction.js} +13 -6
- package/dist/server/instructions/{update.d.ts → QueryInstruction.d.ts} +5 -4
- package/dist/server/instructions/{query.js → QueryInstruction.js} +13 -6
- package/dist/server/instructions/{aggregate.d.ts → UpdateInstruction.d.ts} +5 -4
- package/dist/server/instructions/{update.js → UpdateInstruction.js} +13 -6
- package/dist/server/instructions/index.d.ts +10 -14
- package/dist/server/instructions/index.js +9 -39
- package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +4 -0
- package/dist/server/migrations/20231122143143-split-to-plugins.js +87 -0
- package/dist/server/triggers/{collection.d.ts → CollectionTrigger.d.ts} +1 -1
- package/dist/server/triggers/{collection.js → CollectionTrigger.js} +15 -5
- package/dist/server/triggers/{schedule.d.ts → ScheduleTrigger.d.ts} +2 -1
- package/dist/server/triggers/{schedule.js → ScheduleTrigger.js} +5 -5
- package/dist/server/triggers/index.d.ts +2 -6
- package/dist/server/triggers/index.js +1 -21
- package/package.json +3 -2
- package/dist/client/WorkflowProvider.d.ts +0 -5
- package/dist/client/components/Duration.d.ts +0 -5
- package/dist/client/components/DynamicExpression.d.ts +0 -6
- package/dist/client/components/NullRender.d.ts +0 -1
- package/dist/client/interfaces/expression.d.ts +0 -3
- package/dist/client/nodes/aggregate.d.ts +0 -196
- package/dist/client/nodes/delay.d.ts +0 -35
- package/dist/client/nodes/loop.d.ts +0 -33
- package/dist/client/nodes/manual/AssigneesSelect.d.ts +0 -6
- package/dist/client/nodes/manual/DetailsBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/ModeConfig.d.ts +0 -5
- package/dist/client/nodes/manual/SchemaConfig.d.ts +0 -49
- package/dist/client/nodes/manual/WorkflowTodo.d.ts +0 -5
- package/dist/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/forms/create.d.ts +0 -3
- package/dist/client/nodes/manual/forms/custom.d.ts +0 -5
- package/dist/client/nodes/manual/forms/update.d.ts +0 -3
- package/dist/client/nodes/manual/index.d.ts +0 -86
- package/dist/client/nodes/manual/utils.d.ts +0 -2
- package/dist/client/nodes/parallel.d.ts +0 -32
- package/dist/client/nodes/request.d.ts +0 -183
- package/dist/client/nodes/sql.d.ts +0 -35
- package/dist/client/triggers/form.d.ts +0 -52
- package/dist/server/fields/expression-field.d.ts +0 -7
- package/dist/server/fields/expression-field.js +0 -32
- package/dist/server/fields/index.d.ts +0 -1
- package/dist/server/fields/index.js +0 -28
- package/dist/server/instructions/aggregate.js +0 -54
- package/dist/server/instructions/calculation.d.ts +0 -3
- package/dist/server/instructions/condition.d.ts +0 -6
- package/dist/server/instructions/create.d.ts +0 -8
- package/dist/server/instructions/delay.d.ts +0 -15
- package/dist/server/instructions/delay.js +0 -104
- package/dist/server/instructions/destroy.d.ts +0 -8
- package/dist/server/instructions/loop.d.ts +0 -15
- package/dist/server/instructions/loop.js +0 -94
- package/dist/server/instructions/manual/actions.d.ts +0 -2
- package/dist/server/instructions/manual/actions.js +0 -94
- package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
- package/dist/server/instructions/manual/collecions/jobs.js +0 -39
- package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
- package/dist/server/instructions/manual/collecions/users.js +0 -37
- package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
- package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
- package/dist/server/instructions/manual/forms/create.d.ts +0 -5
- package/dist/server/instructions/manual/forms/create.js +0 -41
- package/dist/server/instructions/manual/forms/index.d.ts +0 -6
- package/dist/server/instructions/manual/forms/index.js +0 -38
- package/dist/server/instructions/manual/forms/update.d.ts +0 -6
- package/dist/server/instructions/manual/forms/update.js +0 -41
- package/dist/server/instructions/manual/index.d.ts +0 -29
- package/dist/server/instructions/manual/index.js +0 -179
- package/dist/server/instructions/parallel.d.ts +0 -12
- package/dist/server/instructions/parallel.js +0 -124
- package/dist/server/instructions/query.d.ts +0 -9
- package/dist/server/instructions/request.d.ts +0 -18
- package/dist/server/instructions/request.js +0 -92
- package/dist/server/instructions/sql.d.ts +0 -12
- package/dist/server/instructions/sql.js +0 -43
- package/dist/server/triggers/form.d.ts +0 -11
- package/dist/server/triggers/form.js +0 -116
|
@@ -1,92 +0,0 @@
|
|
|
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 request_exports = {};
|
|
29
|
-
__export(request_exports, {
|
|
30
|
-
default: () => request_default
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(request_exports);
|
|
33
|
-
var import_axios = __toESM(require("axios"));
|
|
34
|
-
var import_constants = require("../constants");
|
|
35
|
-
async function request(config) {
|
|
36
|
-
const { url, method = "POST", data, timeout = 5e3 } = config;
|
|
37
|
-
const headers = (config.headers ?? []).reduce((result, header) => {
|
|
38
|
-
if (header.name.toLowerCase() === "content-type") {
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
return Object.assign(result, { [header.name]: header.value });
|
|
42
|
-
}, {});
|
|
43
|
-
const params = (config.params ?? []).reduce(
|
|
44
|
-
(result, param) => Object.assign(result, { [param.name]: param.value }),
|
|
45
|
-
{}
|
|
46
|
-
);
|
|
47
|
-
headers["Content-Type"] = "application/json";
|
|
48
|
-
return import_axios.default.request({
|
|
49
|
-
url,
|
|
50
|
-
method,
|
|
51
|
-
headers,
|
|
52
|
-
params,
|
|
53
|
-
data,
|
|
54
|
-
timeout
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
class request_default {
|
|
58
|
-
constructor(plugin) {
|
|
59
|
-
this.plugin = plugin;
|
|
60
|
-
}
|
|
61
|
-
async run(node, prevJob, processor) {
|
|
62
|
-
const job = await processor.saveJob({
|
|
63
|
-
status: import_constants.JOB_STATUS.PENDING,
|
|
64
|
-
nodeId: node.id,
|
|
65
|
-
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
66
|
-
});
|
|
67
|
-
const config = processor.getParsedValue(node.config, node.id);
|
|
68
|
-
request(config).then((response) => {
|
|
69
|
-
job.set({
|
|
70
|
-
status: import_constants.JOB_STATUS.RESOLVED,
|
|
71
|
-
result: response.data
|
|
72
|
-
});
|
|
73
|
-
}).catch((error) => {
|
|
74
|
-
job.set({
|
|
75
|
-
status: import_constants.JOB_STATUS.FAILED,
|
|
76
|
-
result: error.isAxiosError ? error.toJSON() : error.message
|
|
77
|
-
});
|
|
78
|
-
}).finally(() => {
|
|
79
|
-
processor.logger.info(`request (#${node.id}) response received, status: ${job.get("status")}`);
|
|
80
|
-
this.plugin.resume(job);
|
|
81
|
-
});
|
|
82
|
-
processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
|
|
83
|
-
return processor.exit();
|
|
84
|
-
}
|
|
85
|
-
async resume(node, job, processor) {
|
|
86
|
-
const { ignoreFail } = node.config;
|
|
87
|
-
if (ignoreFail) {
|
|
88
|
-
job.set("status", import_constants.JOB_STATUS.RESOLVED);
|
|
89
|
-
}
|
|
90
|
-
return job;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,43 +0,0 @@
|
|
|
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 sql_exports = {};
|
|
19
|
-
__export(sql_exports, {
|
|
20
|
-
default: () => sql_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(sql_exports);
|
|
23
|
-
var import__ = require("..");
|
|
24
|
-
var sql_default = {
|
|
25
|
-
async run(node, input, processor) {
|
|
26
|
-
const { sequelize } = node.constructor.database;
|
|
27
|
-
const sql = processor.getParsedValue(node.config.sql ?? "", node.id).trim();
|
|
28
|
-
if (!sql) {
|
|
29
|
-
return {
|
|
30
|
-
status: import__.JOB_STATUS.RESOLVED
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const result = await sequelize.query(sql, {
|
|
34
|
-
transaction: processor.transaction
|
|
35
|
-
// plain: true,
|
|
36
|
-
// model: db.getCollection(node.config.collection).model
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
result,
|
|
40
|
-
status: import__.JOB_STATUS.RESOLVED
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Trigger } from '.';
|
|
2
|
-
import Plugin from '..';
|
|
3
|
-
import { WorkflowModel } from '../types';
|
|
4
|
-
export default class FormTrigger extends Trigger {
|
|
5
|
-
constructor(plugin: Plugin);
|
|
6
|
-
triggerAction(context: any, next: any): Promise<any>;
|
|
7
|
-
middleware: (context: any, next: any) => Promise<any>;
|
|
8
|
-
private trigger;
|
|
9
|
-
on(workflow: WorkflowModel): void;
|
|
10
|
-
off(workflow: WorkflowModel): void;
|
|
11
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
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 form_exports = {};
|
|
19
|
-
__export(form_exports, {
|
|
20
|
-
default: () => FormTrigger
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(form_exports);
|
|
23
|
-
var import_lodash = require("lodash");
|
|
24
|
-
var import__ = require(".");
|
|
25
|
-
var import_database = require("@nocobase/database");
|
|
26
|
-
var import_utils = require("../utils");
|
|
27
|
-
class FormTrigger extends import__.Trigger {
|
|
28
|
-
constructor(plugin) {
|
|
29
|
-
super(plugin);
|
|
30
|
-
plugin.app.resourcer.use(this.middleware);
|
|
31
|
-
}
|
|
32
|
-
async triggerAction(context, next) {
|
|
33
|
-
const { triggerWorkflows } = context.action.params;
|
|
34
|
-
if (!triggerWorkflows) {
|
|
35
|
-
return context.throw(400);
|
|
36
|
-
}
|
|
37
|
-
context.status = 202;
|
|
38
|
-
await next();
|
|
39
|
-
this.trigger(context);
|
|
40
|
-
}
|
|
41
|
-
middleware = async (context, next) => {
|
|
42
|
-
const {
|
|
43
|
-
resourceName,
|
|
44
|
-
actionName,
|
|
45
|
-
params: { triggerWorkflows }
|
|
46
|
-
} = context.action;
|
|
47
|
-
if (resourceName === "workflows" && actionName === "trigger") {
|
|
48
|
-
return this.triggerAction(context, next);
|
|
49
|
-
}
|
|
50
|
-
await next();
|
|
51
|
-
if (!triggerWorkflows) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
if (!["create", "update"].includes(actionName)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this.trigger(context);
|
|
58
|
-
};
|
|
59
|
-
async trigger(context) {
|
|
60
|
-
const { triggerWorkflows = "", values } = context.action.params;
|
|
61
|
-
const { currentUser } = context.state;
|
|
62
|
-
const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
|
|
63
|
-
const workflowRepo = this.plugin.db.getRepository("workflows");
|
|
64
|
-
const workflows = await workflowRepo.find({
|
|
65
|
-
filter: {
|
|
66
|
-
key: triggers.map((trigger) => trigger[0]),
|
|
67
|
-
current: true,
|
|
68
|
-
type: "form",
|
|
69
|
-
enabled: true
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
workflows.forEach((workflow) => {
|
|
73
|
-
var _a;
|
|
74
|
-
const trigger = triggers.find((trigger2) => trigger2[0] == workflow.key);
|
|
75
|
-
if ((_a = context.body) == null ? void 0 : _a.data) {
|
|
76
|
-
const { data } = context.body;
|
|
77
|
-
(Array.isArray(data) ? data : [data]).forEach(async (row) => {
|
|
78
|
-
let payload = row;
|
|
79
|
-
if (trigger[1]) {
|
|
80
|
-
const paths = trigger[1].split(".");
|
|
81
|
-
for await (const field of paths) {
|
|
82
|
-
if (payload.get(field)) {
|
|
83
|
-
payload = payload.get(field);
|
|
84
|
-
} else {
|
|
85
|
-
const association = (0, import_database.modelAssociationByKey)(payload, field);
|
|
86
|
-
payload = await payload[association.accessors.get]();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const { collection, appends = [] } = workflow.config;
|
|
91
|
-
const model = payload.constructor;
|
|
92
|
-
if (collection !== model.collection.name) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (appends.length) {
|
|
96
|
-
payload = await model.collection.repository.findOne({
|
|
97
|
-
filterByTk: payload.get(model.primaryKeyAttribute),
|
|
98
|
-
appends
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
this.plugin.trigger(workflow, { data: (0, import_utils.toJSON)(payload), user: (0, import_utils.toJSON)(currentUser) });
|
|
102
|
-
});
|
|
103
|
-
} else {
|
|
104
|
-
const data = trigger[1] ? (0, import_lodash.get)(values, trigger[1]) : values;
|
|
105
|
-
this.plugin.trigger(workflow, {
|
|
106
|
-
data,
|
|
107
|
-
user: currentUser
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
on(workflow) {
|
|
113
|
-
}
|
|
114
|
-
off(workflow) {
|
|
115
|
-
}
|
|
116
|
-
}
|