@nocobase/plugin-workflow-notification 2.1.0-alpha.14 → 2.1.0-alpha.15
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
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@ant-design/icons": "5.6.1",
|
|
13
|
-
"@nocobase/plugin-workflow": "2.1.0-alpha.
|
|
14
|
-
"@nocobase/plugin-notification-manager": "2.1.0-alpha.
|
|
15
|
-
"@nocobase/client": "2.1.0-alpha.
|
|
13
|
+
"@nocobase/plugin-workflow": "2.1.0-alpha.15",
|
|
14
|
+
"@nocobase/plugin-notification-manager": "2.1.0-alpha.15",
|
|
15
|
+
"@nocobase/client": "2.1.0-alpha.15",
|
|
16
16
|
"react-i18next": "11.18.6",
|
|
17
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
17
|
+
"@nocobase/server": "2.1.0-alpha.15"
|
|
18
18
|
};
|
|
@@ -10,7 +10,19 @@ import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow
|
|
|
10
10
|
export default class extends Instruction {
|
|
11
11
|
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
|
|
12
12
|
status: 1 | -1;
|
|
13
|
-
result:
|
|
13
|
+
result: {
|
|
14
|
+
status: "success";
|
|
15
|
+
triggerFrom: string;
|
|
16
|
+
channelName: string;
|
|
17
|
+
receivers: import("@nocobase/plugin-notification-manager").ReceiversOptions;
|
|
18
|
+
queued: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
status: "failure";
|
|
21
|
+
reason: string;
|
|
22
|
+
triggerFrom: string;
|
|
23
|
+
channelName: string;
|
|
24
|
+
receivers: import("@nocobase/plugin-notification-manager").ReceiversOptions;
|
|
25
|
+
};
|
|
14
26
|
} | {
|
|
15
27
|
status: 1 | -2;
|
|
16
28
|
result: any;
|
|
@@ -53,62 +53,22 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
|
|
|
53
53
|
data: scope
|
|
54
54
|
};
|
|
55
55
|
const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
|
|
56
|
-
const { workflow } = processor.execution;
|
|
57
|
-
const sync = this.workflow.isWorkflowSync(workflow);
|
|
58
|
-
if (sync) {
|
|
59
|
-
try {
|
|
60
|
-
const result = await notificationServer.send(sendParams);
|
|
61
|
-
if (result.status === "success") {
|
|
62
|
-
return {
|
|
63
|
-
status: import_plugin_workflow.JOB_STATUS.RESOLVED,
|
|
64
|
-
result
|
|
65
|
-
};
|
|
66
|
-
} else {
|
|
67
|
-
return {
|
|
68
|
-
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
|
|
69
|
-
result
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return {
|
|
74
|
-
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
|
|
75
|
-
result: error
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const { id } = processor.saveJob({
|
|
80
|
-
status: import_plugin_workflow.JOB_STATUS.PENDING,
|
|
81
|
-
nodeId: node.id,
|
|
82
|
-
nodeKey: node.key,
|
|
83
|
-
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
84
|
-
});
|
|
85
|
-
await processor.exit();
|
|
86
|
-
const jobDone = { status: import_plugin_workflow.JOB_STATUS.PENDING };
|
|
87
56
|
try {
|
|
88
|
-
processor.logger.info(`notification (#${node.id})
|
|
89
|
-
const result = await notificationServer.send(
|
|
90
|
-
|
|
91
|
-
processor.
|
|
92
|
-
jobDone.status = import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
93
|
-
jobDone.result = result;
|
|
94
|
-
} else {
|
|
95
|
-
processor.logger.info(`notification (#${node.id}) sent failed.`);
|
|
96
|
-
jobDone.status = ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
|
|
97
|
-
jobDone.result = result;
|
|
98
|
-
}
|
|
99
|
-
} catch (error) {
|
|
100
|
-
processor.logger.warn(`notification (#${node.id}) sent failed: ${error.message}`);
|
|
101
|
-
jobDone.status = ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
|
|
102
|
-
jobDone.result = error;
|
|
103
|
-
} finally {
|
|
104
|
-
const job = await this.workflow.app.db.getRepository("jobs").findOne({
|
|
105
|
-
filterByTk: id
|
|
106
|
-
});
|
|
107
|
-
job.set(jobDone);
|
|
108
|
-
processor.logger.debug(`notification (#${node.id}) sending ended, resume workflow...`);
|
|
109
|
-
setImmediate(() => {
|
|
110
|
-
this.workflow.resume(job);
|
|
57
|
+
processor.logger.info(`notification (#${node.id}) queued for delivery.`);
|
|
58
|
+
const result = await notificationServer.send({
|
|
59
|
+
...sendParams,
|
|
60
|
+
transaction: processor.mainTransaction
|
|
111
61
|
});
|
|
62
|
+
return {
|
|
63
|
+
status: result.status === "success" || ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
|
|
64
|
+
result
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
processor.logger.warn(`notification (#${node.id}) queue failed: ${error.message}`);
|
|
68
|
+
return {
|
|
69
|
+
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
|
|
70
|
+
result: error
|
|
71
|
+
};
|
|
112
72
|
}
|
|
113
73
|
}
|
|
114
74
|
async resume(node, job, processor) {
|
|
@@ -123,7 +83,7 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
|
|
|
123
83
|
};
|
|
124
84
|
const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
|
|
125
85
|
try {
|
|
126
|
-
const result = await notificationServer.
|
|
86
|
+
const result = await notificationServer.sendNow(sendParams);
|
|
127
87
|
if (result.status === "success") {
|
|
128
88
|
return {
|
|
129
89
|
status: import_plugin_workflow.JOB_STATUS.RESOLVED,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Send notification in workflow.",
|
|
7
7
|
"description.ru-RU": "Отправляет уведомления в рамках рабочего процесса.",
|
|
8
8
|
"description.zh-CN": "可用于在工作流中发送各类通知。",
|
|
9
|
-
"version": "2.1.0-alpha.
|
|
9
|
+
"version": "2.1.0-alpha.15",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"keywords": [
|
|
28
28
|
"Workflow"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e"
|
|
31
31
|
}
|