@nocobase/plugin-workflow 0.17.0-alpha.2 → 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.js → en-US.json} +41 -94
- package/dist/locale/es-ES.json +98 -0
- package/dist/locale/fr-FR.json +98 -0
- package/dist/locale/ja-JP.json +82 -0
- package/dist/locale/pt-BR.json +98 -0
- package/dist/locale/ru-RU.json +82 -0
- package/dist/locale/tr-TR.json +82 -0
- package/dist/locale/zh-CN.json +176 -0
- 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/locale/en-US.d.ts +0 -130
- package/dist/locale/es-ES.d.ts +0 -130
- package/dist/locale/es-ES.js +0 -151
- package/dist/locale/fr-FR.d.ts +0 -130
- package/dist/locale/fr-FR.js +0 -151
- package/dist/locale/ja-JP.d.ts +0 -88
- package/dist/locale/ja-JP.js +0 -109
- package/dist/locale/pt-BR.d.ts +0 -130
- package/dist/locale/pt-BR.js +0 -151
- package/dist/locale/ru-RU.d.ts +0 -88
- package/dist/locale/ru-RU.js +0 -109
- package/dist/locale/tr-TR.d.ts +0 -88
- package/dist/locale/tr-TR.js +0 -109
- package/dist/locale/zh-CN.d.ts +0 -249
- package/dist/locale/zh-CN.js +0 -270
- 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,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
|
-
}
|