@nocobase/plugin-workflow-action-trigger 1.6.0-beta.9 → 1.7.0-beta.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/dist/externalVersion.js
CHANGED
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
|
-
"@nocobase/client": "1.
|
|
13
|
-
"@nocobase/plugin-workflow": "1.
|
|
12
|
+
"@nocobase/client": "1.7.0-beta.1",
|
|
13
|
+
"@nocobase/plugin-workflow": "1.7.0-beta.1",
|
|
14
14
|
"react": "18.2.0",
|
|
15
15
|
"react-i18next": "11.18.6",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"sequelize": "6.35.2",
|
|
18
|
-
"@nocobase/database": "1.
|
|
19
|
-
"@nocobase/server": "1.
|
|
20
|
-
"@nocobase/actions": "1.
|
|
21
|
-
"@nocobase/
|
|
22
|
-
"@nocobase/
|
|
23
|
-
"@nocobase/test": "1.
|
|
24
|
-
"@nocobase/
|
|
18
|
+
"@nocobase/database": "1.7.0-beta.1",
|
|
19
|
+
"@nocobase/server": "1.7.0-beta.1",
|
|
20
|
+
"@nocobase/actions": "1.7.0-beta.1",
|
|
21
|
+
"@nocobase/plugin-error-handler": "1.7.0-beta.1",
|
|
22
|
+
"@nocobase/data-source-manager": "1.7.0-beta.1",
|
|
23
|
+
"@nocobase/plugin-workflow-test": "1.7.0-beta.1",
|
|
24
|
+
"@nocobase/test": "1.7.0-beta.1",
|
|
25
|
+
"@nocobase/utils": "1.7.0-beta.1"
|
|
25
26
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Form event": "Evento modulo",
|
|
3
|
+
"Event triggers when submitted a workflow bound form action.": "L'evento si attiva quando viene inviata un'azione di un modulo associato a un workflow.",
|
|
4
|
+
"Form data model": "Modello dati modulo",
|
|
5
|
+
"Use a collection to match form data.": "Utilizza una raccolta per abbinare i dati del modulo.",
|
|
6
|
+
"Associations to use": "Associazioni da utilizzare",
|
|
7
|
+
"User submitted form": "Modulo inviato dall'utente",
|
|
8
|
+
"Role of user submitted form": "Ruolo del modulo inviato dall'utente"
|
|
9
|
+
}
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
11
12
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
16
|
var __export = (target, all) => {
|
|
15
17
|
for (var name in all)
|
|
@@ -23,6 +25,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
25
|
}
|
|
24
26
|
return to;
|
|
25
27
|
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
26
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
37
|
var ActionTrigger_exports = {};
|
|
28
38
|
__export(ActionTrigger_exports, {
|
|
@@ -31,8 +41,17 @@ __export(ActionTrigger_exports, {
|
|
|
31
41
|
module.exports = __toCommonJS(ActionTrigger_exports);
|
|
32
42
|
var import_lodash = require("lodash");
|
|
33
43
|
var import_database = require("@nocobase/database");
|
|
44
|
+
var import_plugin_error_handler = __toESM(require("@nocobase/plugin-error-handler"));
|
|
34
45
|
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
35
46
|
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
47
|
+
class RequestOnActionTriggerError extends Error {
|
|
48
|
+
status = 400;
|
|
49
|
+
messages = [];
|
|
50
|
+
constructor(message) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = "RequestOnActionTriggerError";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
36
55
|
class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
37
56
|
static TYPE = "action";
|
|
38
57
|
constructor(workflow) {
|
|
@@ -47,6 +66,15 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
47
66
|
return self.collectionTriggerAction(context);
|
|
48
67
|
}
|
|
49
68
|
workflow.app.dataSourceManager.use(triggerWorkflowActionMiddleware);
|
|
69
|
+
workflow.app.pm.get(import_plugin_error_handler.default).errorHandler.register(
|
|
70
|
+
(err) => err instanceof RequestOnActionTriggerError || err.name === "RequestOnActionTriggerError",
|
|
71
|
+
async (err, ctx) => {
|
|
72
|
+
ctx.body = {
|
|
73
|
+
errors: err.messages
|
|
74
|
+
};
|
|
75
|
+
ctx.status = err.status;
|
|
76
|
+
}
|
|
77
|
+
);
|
|
50
78
|
}
|
|
51
79
|
getTargetCollection(collection, association) {
|
|
52
80
|
if (!association) {
|
|
@@ -165,7 +193,28 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
165
193
|
(workflow.sync ? syncGroup : asyncGroup).push(event);
|
|
166
194
|
}
|
|
167
195
|
for (const event of syncGroup) {
|
|
168
|
-
await this.workflow.trigger(event[0], event[1]);
|
|
196
|
+
const processor = await this.workflow.trigger(event[0], event[1], { httpContext: context });
|
|
197
|
+
if (!processor) {
|
|
198
|
+
return context.throw(500);
|
|
199
|
+
}
|
|
200
|
+
const { lastSavedJob, nodesMap } = processor;
|
|
201
|
+
const lastNode = nodesMap.get(lastSavedJob == null ? void 0 : lastSavedJob.nodeId);
|
|
202
|
+
if (processor.execution.status === import_plugin_workflow.EXECUTION_STATUS.RESOLVED) {
|
|
203
|
+
if ((lastNode == null ? void 0 : lastNode.type) === "end") {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (processor.execution.status < import_plugin_workflow.EXECUTION_STATUS.STARTED) {
|
|
209
|
+
if ((lastNode == null ? void 0 : lastNode.type) !== "end") {
|
|
210
|
+
return context.throw(500, "Workflow on your action failed, please contact the administrator");
|
|
211
|
+
}
|
|
212
|
+
const err = new RequestOnActionTriggerError("Request failed");
|
|
213
|
+
err.status = 400;
|
|
214
|
+
err.messages = context.state.messages;
|
|
215
|
+
return context.throw(err.status, err);
|
|
216
|
+
}
|
|
217
|
+
return context.throw(500, "Workflow on your action hangs, please contact the administrator");
|
|
169
218
|
}
|
|
170
219
|
for (const event of asyncGroup) {
|
|
171
220
|
this.workflow.trigger(event[0], event[1]);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流:操作后事件",
|
|
5
5
|
"description": "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.",
|
|
6
6
|
"description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.7.0-beta.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@nocobase/server": "1.x",
|
|
22
22
|
"@nocobase/test": "1.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "374a1bc60b3d55fd8b532a57c8fe0423eed1d11e",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"Workflow"
|
|
27
27
|
]
|