@nocobase/plugin-workflow-action-trigger 0.21.0-alpha.6 → 0.21.0-alpha.7
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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"@formily/react": "2.3.0",
|
|
3
|
-
"@nocobase/client": "0.21.0-alpha.
|
|
4
|
-
"@nocobase/plugin-workflow": "0.21.0-alpha.
|
|
3
|
+
"@nocobase/client": "0.21.0-alpha.7",
|
|
4
|
+
"@nocobase/plugin-workflow": "0.21.0-alpha.7",
|
|
5
5
|
"react-i18next": "11.18.6",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"sequelize": "6.35.2",
|
|
8
|
-
"@nocobase/database": "0.21.0-alpha.
|
|
9
|
-
"@nocobase/server": "0.21.0-alpha.
|
|
10
|
-
"@nocobase/actions": "0.21.0-alpha.
|
|
11
|
-
"@nocobase/data-source-manager": "0.21.0-alpha.
|
|
12
|
-
"@nocobase/plugin-workflow-test": "0.21.0-alpha.
|
|
13
|
-
"@nocobase/test": "0.21.0-alpha.
|
|
14
|
-
"@nocobase/utils": "0.21.0-alpha.
|
|
8
|
+
"@nocobase/database": "0.21.0-alpha.7",
|
|
9
|
+
"@nocobase/server": "0.21.0-alpha.7",
|
|
10
|
+
"@nocobase/actions": "0.21.0-alpha.7",
|
|
11
|
+
"@nocobase/data-source-manager": "0.21.0-alpha.7",
|
|
12
|
+
"@nocobase/plugin-workflow-test": "0.21.0-alpha.7",
|
|
13
|
+
"@nocobase/test": "0.21.0-alpha.7",
|
|
14
|
+
"@nocobase/utils": "0.21.0-alpha.7"
|
|
15
15
|
};
|
|
@@ -57,7 +57,8 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
57
57
|
params: { triggerWorkflows = "", values }
|
|
58
58
|
} = context.action;
|
|
59
59
|
const dataSourceHeader = context.get("x-data-source") || "main";
|
|
60
|
-
const
|
|
60
|
+
const collection = context.app.dataSourceManager.dataSources.get(dataSourceHeader).collectionManager.getCollection(resourceName);
|
|
61
|
+
const fullCollectionName = (0, import_data_source_manager.joinCollectionName)(dataSourceHeader, collection.name);
|
|
61
62
|
const { currentUser, currentRole } = context.state;
|
|
62
63
|
const { model: UserModel } = this.workflow.db.getCollection("users");
|
|
63
64
|
const userInfo = {
|
|
@@ -98,8 +99,8 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
|
|
|
98
99
|
const syncGroup = [];
|
|
99
100
|
const asyncGroup = [];
|
|
100
101
|
for (const workflow of triggeringLocalWorkflows.concat(...globalWorkflows.values())) {
|
|
101
|
-
const {
|
|
102
|
-
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
102
|
+
const { appends = [] } = workflow.config;
|
|
103
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
|
|
103
104
|
const dataPath = triggersKeysMap.get(workflow.key);
|
|
104
105
|
const event = [workflow];
|
|
105
106
|
if (context.action.resourceName !== "workflows") {
|
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": "0.21.0-alpha.
|
|
7
|
+
"version": "0.21.0-alpha.7",
|
|
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": "0.x",
|
|
22
22
|
"@nocobase/test": "0.x"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "b1be3993f8aa81173d01bc390aa8e4c5adcc0e2d",
|
|
25
25
|
"keywords": [
|
|
26
26
|
"Workflow"
|
|
27
27
|
]
|
|
@@ -54,7 +54,10 @@ export default class extends Trigger {
|
|
|
54
54
|
params: { triggerWorkflows = '', values },
|
|
55
55
|
} = context.action;
|
|
56
56
|
const dataSourceHeader = context.get('x-data-source') || 'main';
|
|
57
|
-
const
|
|
57
|
+
const collection = context.app.dataSourceManager.dataSources
|
|
58
|
+
.get(dataSourceHeader)
|
|
59
|
+
.collectionManager.getCollection(resourceName);
|
|
60
|
+
const fullCollectionName = joinCollectionName(dataSourceHeader, collection.name);
|
|
58
61
|
const { currentUser, currentRole } = context.state;
|
|
59
62
|
const { model: UserModel } = this.workflow.db.getCollection('users');
|
|
60
63
|
const userInfo = {
|
|
@@ -95,8 +98,8 @@ export default class extends Trigger {
|
|
|
95
98
|
const syncGroup = [];
|
|
96
99
|
const asyncGroup = [];
|
|
97
100
|
for (const workflow of triggeringLocalWorkflows.concat(...globalWorkflows.values())) {
|
|
98
|
-
const {
|
|
99
|
-
const [dataSourceName, collectionName] = parseCollectionName(collection);
|
|
101
|
+
const { appends = [] } = workflow.config;
|
|
102
|
+
const [dataSourceName, collectionName] = parseCollectionName(workflow.config.collection);
|
|
100
103
|
const dataPath = triggersKeysMap.get(workflow.key);
|
|
101
104
|
const event = [workflow];
|
|
102
105
|
if (context.action.resourceName !== 'workflows') {
|
|
@@ -10,7 +10,7 @@ describe('workflow > action-trigger', () => {
|
|
|
10
10
|
let db: Database;
|
|
11
11
|
let agent;
|
|
12
12
|
let PostRepo;
|
|
13
|
-
let
|
|
13
|
+
let CategoryRepo;
|
|
14
14
|
let WorkflowModel;
|
|
15
15
|
let UserRepo;
|
|
16
16
|
let users;
|
|
@@ -25,7 +25,7 @@ describe('workflow > action-trigger', () => {
|
|
|
25
25
|
db = app.db;
|
|
26
26
|
WorkflowModel = db.getCollection('workflows').model;
|
|
27
27
|
PostRepo = db.getCollection('posts').repository;
|
|
28
|
-
|
|
28
|
+
CategoryRepo = db.getCollection('categories').repository;
|
|
29
29
|
UserRepo = db.getCollection('users').repository;
|
|
30
30
|
|
|
31
31
|
users = await UserRepo.create({
|
|
@@ -461,6 +461,33 @@ describe('workflow > action-trigger', () => {
|
|
|
461
461
|
});
|
|
462
462
|
});
|
|
463
463
|
|
|
464
|
+
describe('associations actions', () => {
|
|
465
|
+
it('trigger on associated data', async () => {
|
|
466
|
+
const workflow = await WorkflowModel.create({
|
|
467
|
+
enabled: true,
|
|
468
|
+
type: 'action',
|
|
469
|
+
config: {
|
|
470
|
+
collection: 'posts',
|
|
471
|
+
},
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
const c1 = await CategoryRepo.create({ values: { title: 'c1' } });
|
|
475
|
+
|
|
476
|
+
const res1 = await userAgents[0].resource('categories.posts', c1.id).create({
|
|
477
|
+
values: { title: 'p1' },
|
|
478
|
+
triggerWorkflows: `${workflow.key}`,
|
|
479
|
+
});
|
|
480
|
+
expect(res1.status).toBe(200);
|
|
481
|
+
|
|
482
|
+
await sleep(500);
|
|
483
|
+
|
|
484
|
+
const e1s = await workflow.getExecutions();
|
|
485
|
+
expect(e1s.length).toBe(1);
|
|
486
|
+
expect(e1s[0].status).toBe(EXECUTION_STATUS.RESOLVED);
|
|
487
|
+
expect(e1s[0].context.data).toMatchObject({ title: 'p1', categoryId: c1.id });
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
|
|
464
491
|
describe('workflow key', () => {
|
|
465
492
|
it('revision', async () => {
|
|
466
493
|
const w1 = await WorkflowModel.create({
|