@nocobase/plugin-workflow-action-trigger 1.6.0-beta.8 → 1.6.0-beta.9
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,17 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
|
-
"@nocobase/client": "1.6.0-beta.
|
|
13
|
-
"@nocobase/plugin-workflow": "1.6.0-beta.
|
|
12
|
+
"@nocobase/client": "1.6.0-beta.9",
|
|
13
|
+
"@nocobase/plugin-workflow": "1.6.0-beta.9",
|
|
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.6.0-beta.
|
|
19
|
-
"@nocobase/server": "1.6.0-beta.
|
|
20
|
-
"@nocobase/actions": "1.6.0-beta.
|
|
21
|
-
"@nocobase/data-source-manager": "1.6.0-beta.
|
|
22
|
-
"@nocobase/plugin-workflow-test": "1.6.0-beta.
|
|
23
|
-
"@nocobase/test": "1.6.0-beta.
|
|
24
|
-
"@nocobase/utils": "1.6.0-beta.
|
|
18
|
+
"@nocobase/database": "1.6.0-beta.9",
|
|
19
|
+
"@nocobase/server": "1.6.0-beta.9",
|
|
20
|
+
"@nocobase/actions": "1.6.0-beta.9",
|
|
21
|
+
"@nocobase/data-source-manager": "1.6.0-beta.9",
|
|
22
|
+
"@nocobase/plugin-workflow-test": "1.6.0-beta.9",
|
|
23
|
+
"@nocobase/test": "1.6.0-beta.9",
|
|
24
|
+
"@nocobase/utils": "1.6.0-beta.9"
|
|
25
25
|
};
|
|
@@ -6,18 +6,12 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { Context as ActionContext, Next } from '@nocobase/actions';
|
|
9
|
+
import { Collection } from '@nocobase/database';
|
|
11
10
|
import WorkflowPlugin, { EventOptions, Trigger, WorkflowModel } from '@nocobase/plugin-workflow';
|
|
12
|
-
interface Context extends ActionContext, DefaultContext {
|
|
13
|
-
}
|
|
14
11
|
export default class extends Trigger {
|
|
15
12
|
static TYPE: string;
|
|
16
13
|
constructor(workflow: WorkflowPlugin);
|
|
17
|
-
|
|
18
|
-
* @deprecated
|
|
19
|
-
*/
|
|
20
|
-
workflowTriggerAction(context: Context, next: Next): Promise<void>;
|
|
14
|
+
getTargetCollection(collection: Collection, association: string): Collection<any, any>;
|
|
21
15
|
private collectionTriggerAction;
|
|
22
16
|
execute(workflow: WorkflowModel, values: any, options: EventOptions): Promise<void | import("@nocobase/plugin-workflow").Processor>;
|
|
23
17
|
validateContext(values: any): {
|
|
@@ -28,4 +22,3 @@ export default class extends Trigger {
|
|
|
28
22
|
data?: undefined;
|
|
29
23
|
};
|
|
30
24
|
}
|
|
31
|
-
export {};
|
|
@@ -39,11 +39,8 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
39
39
|
super(workflow);
|
|
40
40
|
const self = this;
|
|
41
41
|
async function triggerWorkflowActionMiddleware(context, next) {
|
|
42
|
-
const { resourceName, actionName } = context.action;
|
|
43
|
-
if (resourceName === "workflows" && actionName === "trigger") {
|
|
44
|
-
return self.workflowTriggerAction(context, next);
|
|
45
|
-
}
|
|
46
42
|
await next();
|
|
43
|
+
const { actionName } = context.action;
|
|
47
44
|
if (!["create", "update"].includes(actionName)) {
|
|
48
45
|
return;
|
|
49
46
|
}
|
|
@@ -51,17 +48,15 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
51
48
|
}
|
|
52
49
|
workflow.app.dataSourceManager.use(triggerWorkflowActionMiddleware);
|
|
53
50
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
getTargetCollection(collection, association) {
|
|
52
|
+
if (!association) {
|
|
53
|
+
return collection;
|
|
54
|
+
}
|
|
55
|
+
let targetCollection = collection;
|
|
56
|
+
for (const key of association.split(".")) {
|
|
57
|
+
targetCollection = collection.db.getCollection(targetCollection.getField(key).target);
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
await next();
|
|
64
|
-
return this.collectionTriggerAction(context);
|
|
59
|
+
return targetCollection;
|
|
65
60
|
}
|
|
66
61
|
async collectionTriggerAction(context) {
|
|
67
62
|
const {
|
|
@@ -74,7 +69,6 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
74
69
|
if (!collection) {
|
|
75
70
|
return;
|
|
76
71
|
}
|
|
77
|
-
const fullCollectionName = (0, import_data_source_manager.joinCollectionName)(dataSourceHeader, collection.name);
|
|
78
72
|
const { currentUser, currentRole } = context.state;
|
|
79
73
|
const { model: UserModel } = this.workflow.db.getCollection("users");
|
|
80
74
|
const userInfo = {
|
|
@@ -90,9 +84,8 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
90
84
|
const localWorkflows = /* @__PURE__ */ new Map();
|
|
91
85
|
workflows.forEach((item) => {
|
|
92
86
|
var _a;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
} else if (item.config.collection === fullCollectionName) {
|
|
87
|
+
const targetCollection = this.getTargetCollection(collection, triggersKeysMap.get(item.key));
|
|
88
|
+
if (item.config.collection === (0, import_data_source_manager.joinCollectionName)(dataSourceHeader, targetCollection.name)) {
|
|
96
89
|
if (item.config.global) {
|
|
97
90
|
if ((_a = item.config.actions) == null ? void 0 : _a.includes(actionName)) {
|
|
98
91
|
globalWorkflows.set(item.key, item);
|
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.6.0-beta.
|
|
7
|
+
"version": "1.6.0-beta.9",
|
|
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": "eb1ff948fcf7a51175626a1a56a8b8d9b90be006",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"Workflow"
|
|
27
27
|
]
|