@nocobase/plugin-workflow-notification 2.1.0-beta.9 → 2.2.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/client/index.js +1 -1
- package/dist/externalVersion.js +4 -4
- package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
- package/dist/node_modules/joi/lib/annotate.js +175 -0
- package/dist/node_modules/joi/lib/base.js +1069 -0
- package/dist/node_modules/joi/lib/cache.js +143 -0
- package/dist/node_modules/joi/lib/common.js +216 -0
- package/dist/node_modules/joi/lib/compile.js +283 -0
- package/dist/node_modules/joi/lib/errors.js +271 -0
- package/dist/node_modules/joi/lib/extend.js +312 -0
- package/dist/node_modules/joi/lib/index.d.ts +2365 -0
- package/dist/node_modules/joi/lib/index.js +1 -0
- package/dist/node_modules/joi/lib/manifest.js +476 -0
- package/dist/node_modules/joi/lib/messages.js +178 -0
- package/dist/node_modules/joi/lib/modify.js +267 -0
- package/dist/node_modules/joi/lib/ref.js +414 -0
- package/dist/node_modules/joi/lib/schemas.js +302 -0
- package/dist/node_modules/joi/lib/state.js +166 -0
- package/dist/node_modules/joi/lib/template.js +463 -0
- package/dist/node_modules/joi/lib/trace.js +346 -0
- package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
- package/dist/node_modules/joi/lib/types/any.js +174 -0
- package/dist/node_modules/joi/lib/types/array.js +809 -0
- package/dist/node_modules/joi/lib/types/binary.js +100 -0
- package/dist/node_modules/joi/lib/types/boolean.js +150 -0
- package/dist/node_modules/joi/lib/types/date.js +233 -0
- package/dist/node_modules/joi/lib/types/function.js +93 -0
- package/dist/node_modules/joi/lib/types/keys.js +1067 -0
- package/dist/node_modules/joi/lib/types/link.js +168 -0
- package/dist/node_modules/joi/lib/types/number.js +363 -0
- package/dist/node_modules/joi/lib/types/object.js +22 -0
- package/dist/node_modules/joi/lib/types/string.js +850 -0
- package/dist/node_modules/joi/lib/types/symbol.js +102 -0
- package/dist/node_modules/joi/lib/validator.js +750 -0
- package/dist/node_modules/joi/lib/values.js +263 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
- package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
- package/dist/node_modules/joi/package.json +1 -0
- package/dist/server/NotificationInstruction.d.ts +21 -1
- package/dist/server/NotificationInstruction.js +16 -54
- package/package.json +4 -2
|
@@ -39,9 +39,14 @@ __export(NotificationInstruction_exports, {
|
|
|
39
39
|
default: () => NotificationInstruction_default
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(NotificationInstruction_exports);
|
|
42
|
+
var import_joi = __toESM(require("joi"));
|
|
42
43
|
var import_plugin_notification_manager = __toESM(require("@nocobase/plugin-notification-manager"));
|
|
43
44
|
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
44
45
|
class NotificationInstruction_default extends import_plugin_workflow.Instruction {
|
|
46
|
+
configSchema = import_joi.default.object({
|
|
47
|
+
channelName: import_joi.default.string(),
|
|
48
|
+
ignoreFail: import_joi.default.boolean().default(false)
|
|
49
|
+
});
|
|
45
50
|
async run(node, prevJob, processor) {
|
|
46
51
|
const { ignoreFail, ...config } = node.config;
|
|
47
52
|
const options = processor.getParsedValue(config, node.id);
|
|
@@ -53,62 +58,19 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
|
|
|
53
58
|
data: scope
|
|
54
59
|
};
|
|
55
60
|
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
61
|
try {
|
|
88
|
-
processor.logger.info(`notification (#${node.id})
|
|
62
|
+
processor.logger.info(`notification (#${node.id}) queued for delivery.`);
|
|
89
63
|
const result = await notificationServer.send(sendParams);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
}
|
|
64
|
+
return {
|
|
65
|
+
status: result.status === "success" || ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
|
|
66
|
+
result
|
|
67
|
+
};
|
|
99
68
|
} catch (error) {
|
|
100
|
-
processor.logger.warn(`notification (#${node.id})
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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);
|
|
111
|
-
});
|
|
69
|
+
processor.logger.warn(`notification (#${node.id}) queue failed: ${error.message}`);
|
|
70
|
+
return {
|
|
71
|
+
status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
|
|
72
|
+
result: error
|
|
73
|
+
};
|
|
112
74
|
}
|
|
113
75
|
}
|
|
114
76
|
async resume(node, job, processor) {
|
|
@@ -123,7 +85,7 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
|
|
|
123
85
|
};
|
|
124
86
|
const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
|
|
125
87
|
try {
|
|
126
|
-
const result = await notificationServer.
|
|
88
|
+
const result = await notificationServer.sendNow(sendParams);
|
|
127
89
|
if (result.status === "success") {
|
|
128
90
|
return {
|
|
129
91
|
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.
|
|
9
|
+
"version": "2.2.0-beta.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow-smtp-mailer",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"antd": "5.x",
|
|
17
|
+
"joi": "^17.13.3",
|
|
17
18
|
"react": "18.x"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
21
|
"@nocobase/client": "2.x",
|
|
21
22
|
"@nocobase/database": "2.x",
|
|
23
|
+
"@nocobase/plugin-notification-manager": "2.x",
|
|
22
24
|
"@nocobase/plugin-workflow": ">=0.17.0-alpha.3",
|
|
23
25
|
"@nocobase/server": "2.x",
|
|
24
26
|
"@nocobase/test": "2.x"
|
|
@@ -26,5 +28,5 @@
|
|
|
26
28
|
"keywords": [
|
|
27
29
|
"Workflow"
|
|
28
30
|
],
|
|
29
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "f82fa9d0c3aa8e00e53dd94e404a312483b4866b"
|
|
30
32
|
}
|