@nocobase/plugin-workflow-notification 2.1.0-alpha.4 → 2.1.0-alpha.40

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.
Files changed (45) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +95 -5
  3. package/dist/client/index.js +1 -1
  4. package/dist/externalVersion.js +4 -4
  5. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  6. package/dist/node_modules/joi/lib/annotate.js +175 -0
  7. package/dist/node_modules/joi/lib/base.js +1069 -0
  8. package/dist/node_modules/joi/lib/cache.js +143 -0
  9. package/dist/node_modules/joi/lib/common.js +216 -0
  10. package/dist/node_modules/joi/lib/compile.js +283 -0
  11. package/dist/node_modules/joi/lib/errors.js +271 -0
  12. package/dist/node_modules/joi/lib/extend.js +312 -0
  13. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  14. package/dist/node_modules/joi/lib/index.js +1 -0
  15. package/dist/node_modules/joi/lib/manifest.js +476 -0
  16. package/dist/node_modules/joi/lib/messages.js +178 -0
  17. package/dist/node_modules/joi/lib/modify.js +267 -0
  18. package/dist/node_modules/joi/lib/ref.js +414 -0
  19. package/dist/node_modules/joi/lib/schemas.js +302 -0
  20. package/dist/node_modules/joi/lib/state.js +166 -0
  21. package/dist/node_modules/joi/lib/template.js +463 -0
  22. package/dist/node_modules/joi/lib/trace.js +346 -0
  23. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  24. package/dist/node_modules/joi/lib/types/any.js +174 -0
  25. package/dist/node_modules/joi/lib/types/array.js +809 -0
  26. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  27. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  28. package/dist/node_modules/joi/lib/types/date.js +233 -0
  29. package/dist/node_modules/joi/lib/types/function.js +93 -0
  30. package/dist/node_modules/joi/lib/types/keys.js +1067 -0
  31. package/dist/node_modules/joi/lib/types/link.js +168 -0
  32. package/dist/node_modules/joi/lib/types/number.js +363 -0
  33. package/dist/node_modules/joi/lib/types/object.js +22 -0
  34. package/dist/node_modules/joi/lib/types/string.js +850 -0
  35. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  36. package/dist/node_modules/joi/lib/validator.js +750 -0
  37. package/dist/node_modules/joi/lib/values.js +263 -0
  38. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  39. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  40. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  41. package/dist/node_modules/joi/package.json +1 -0
  42. package/dist/server/NotificationInstruction.d.ts +21 -1
  43. package/dist/server/NotificationInstruction.js +20 -55
  44. package/package.json +5 -3
  45. package/README.zh-CN.md +0 -9
@@ -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,22 @@ 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}) sent, waiting for response...`);
89
- const result = await notificationServer.send(sendParams);
90
- if (result.status === "success") {
91
- processor.logger.info(`notification (#${node.id}) sent successfully.`);
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);
62
+ processor.logger.info(`notification (#${node.id}) queued for delivery.`);
63
+ const result = await notificationServer.send({
64
+ ...sendParams,
65
+ transaction: processor.mainTransaction
111
66
  });
67
+ return {
68
+ status: result.status === "success" || ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED,
69
+ result
70
+ };
71
+ } catch (error) {
72
+ processor.logger.warn(`notification (#${node.id}) queue failed: ${error.message}`);
73
+ return {
74
+ status: ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.ERROR,
75
+ result: error
76
+ };
112
77
  }
113
78
  }
114
79
  async resume(node, job, processor) {
@@ -123,7 +88,7 @@ class NotificationInstruction_default extends import_plugin_workflow.Instruction
123
88
  };
124
89
  const notificationServer = this.workflow.pm.get(import_plugin_notification_manager.default);
125
90
  try {
126
- const result = await notificationServer.send(sendParams);
91
+ const result = await notificationServer.sendNow(sendParams);
127
92
  if (result.status === "success") {
128
93
  return {
129
94
  status: import_plugin_workflow.JOB_STATUS.RESOLVED,
package/package.json CHANGED
@@ -6,19 +6,21 @@
6
6
  "description": "Send notification in workflow.",
7
7
  "description.ru-RU": "Отправляет уведомления в рамках рабочего процесса.",
8
8
  "description.zh-CN": "可用于在工作流中发送各类通知。",
9
- "version": "2.1.0-alpha.4",
10
- "license": "AGPL-3.0",
9
+ "version": "2.1.0-alpha.40",
10
+ "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
13
13
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/workflow-smtp-mailer",
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": "32c682485e5f1878b9165be2e9de18000d98f935"
31
+ "gitHead": "e73f99dd0abefe847f2e50ff0fea1f41a82fd048"
30
32
  }
package/README.zh-CN.md DELETED
@@ -1,9 +0,0 @@
1
- # 工作流邮件发送节点
2
-
3
- [English](./README.md) | 中文
4
-
5
- ## 安装激活
6
-
7
- 内置插件无需手动安装激活。
8
-
9
- ## 使用方法