@nocobase/plugin-workflow-mailer 2.0.0-alpha.50 → 2.0.0-alpha.52

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.
@@ -11,8 +11,9 @@ module.exports = {
11
11
  "@ant-design/icons": "5.6.1",
12
12
  "@formily/antd-v5": "1.2.3",
13
13
  "react": "18.2.0",
14
- "@nocobase/client": "2.0.0-alpha.50",
15
- "@nocobase/plugin-workflow": "2.0.0-alpha.50",
14
+ "@nocobase/client": "2.0.0-alpha.52",
15
+ "@nocobase/plugin-workflow": "2.0.0-alpha.52",
16
16
  "react-i18next": "11.18.6",
17
- "@nocobase/server": "2.0.0-alpha.50"
17
+ "lodash": "4.17.21",
18
+ "@nocobase/server": "2.0.0-alpha.52"
18
19
  };
@@ -1 +1 @@
1
- {"name":"nodemailer","version":"6.9.13","description":"Easy as cake e-mail sending from your Node.js applications","main":"lib/nodemailer.js","scripts":{"test":"node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js","test:coverage":"c8 node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js","lint":"eslint .","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-ses":"3.529.1","bunyan":"1.8.15","c8":"9.1.0","eslint":"8.57.0","eslint-config-nodemailer":"1.2.0","eslint-config-prettier":"9.1.0","libbase64":"1.3.0","libmime":"5.3.4","libqp":"2.1.0","nodemailer-ntlm-auth":"1.0.4","proxy":"1.0.2","proxy-test-server":"1.0.0","smtp-server":"3.13.3"},"engines":{"node":">=6.0.0"},"_lastModified":"2025-12-02T12:52:00.284Z"}
1
+ {"name":"nodemailer","version":"6.9.13","description":"Easy as cake e-mail sending from your Node.js applications","main":"lib/nodemailer.js","scripts":{"test":"node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js","test:coverage":"c8 node --test --test-concurrency=1 test/**/*.test.js test/**/*-test.js","lint":"eslint .","update":"rm -rf node_modules/ package-lock.json && ncu -u && npm install"},"repository":{"type":"git","url":"https://github.com/nodemailer/nodemailer.git"},"keywords":["Nodemailer"],"author":"Andris Reinman","license":"MIT-0","bugs":{"url":"https://github.com/nodemailer/nodemailer/issues"},"homepage":"https://nodemailer.com/","devDependencies":{"@aws-sdk/client-ses":"3.529.1","bunyan":"1.8.15","c8":"9.1.0","eslint":"8.57.0","eslint-config-nodemailer":"1.2.0","eslint-config-prettier":"9.1.0","libbase64":"1.3.0","libmime":"5.3.4","libqp":"2.1.0","nodemailer-ntlm-auth":"1.0.4","proxy":"1.0.2","proxy-test-server":"1.0.0","smtp-server":"3.13.3"},"engines":{"node":">=6.0.0"},"_lastModified":"2025-12-09T10:21:21.340Z"}
@@ -7,7 +7,13 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import { FlowNodeModel, Instruction, Processor } from '@nocobase/plugin-workflow';
10
- export default class extends Instruction {
10
+ export default class MailerInstruction extends Instruction {
11
+ private static transporterMap;
12
+ private static configMap;
13
+ private getTransporterKey;
14
+ private isConfigChanged;
15
+ private createNewTransporter;
16
+ private getTransporter;
11
17
  run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
12
18
  status: 1 | -1;
13
19
  result: any;
@@ -36,13 +36,46 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
37
  var MailerInstruction_exports = {};
38
38
  __export(MailerInstruction_exports, {
39
- default: () => MailerInstruction_default
39
+ default: () => MailerInstruction
40
40
  });
41
41
  module.exports = __toCommonJS(MailerInstruction_exports);
42
42
  var import_util = require("util");
43
43
  var import_nodemailer = __toESM(require("nodemailer"));
44
44
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
45
- class MailerInstruction_default extends import_plugin_workflow.Instruction {
45
+ var import_get = __toESM(require("lodash/get"));
46
+ class MailerInstruction extends import_plugin_workflow.Instruction {
47
+ static transporterMap = /* @__PURE__ */ new Map();
48
+ static configMap = /* @__PURE__ */ new Map();
49
+ getTransporterKey(provider) {
50
+ const { host, port, auth } = provider;
51
+ return `${host}:${port}:${auth == null ? void 0 : auth.user}`;
52
+ }
53
+ isConfigChanged(oldConfig, newConfig) {
54
+ const fields = ["host", "port", "secure", "auth.user", "auth.pass"];
55
+ return fields.some((key) => (0, import_get.default)(oldConfig, key) !== (0, import_get.default)(newConfig, key));
56
+ }
57
+ createNewTransporter(key, config) {
58
+ const transporter = import_nodemailer.default.createTransport(config);
59
+ MailerInstruction.transporterMap.set(key, transporter);
60
+ MailerInstruction.configMap.set(key, config);
61
+ return transporter;
62
+ }
63
+ getTransporter(provider) {
64
+ const key = this.getTransporterKey(provider);
65
+ const newConfig = provider;
66
+ const oldConfig = MailerInstruction.configMap.get(key);
67
+ if (!oldConfig) {
68
+ return this.createNewTransporter(key, newConfig);
69
+ }
70
+ if (this.isConfigChanged(oldConfig, newConfig)) {
71
+ const oldTransporter = MailerInstruction.transporterMap.get(key);
72
+ if (oldTransporter) {
73
+ oldTransporter.close();
74
+ }
75
+ return this.createNewTransporter(key, newConfig);
76
+ }
77
+ return MailerInstruction.transporterMap.get(key);
78
+ }
46
79
  async run(node, prevJob, processor) {
47
80
  const {
48
81
  provider,
@@ -58,7 +91,7 @@ class MailerInstruction_default extends import_plugin_workflow.Instruction {
58
91
  } = processor.getParsedValue(node.config, node.id);
59
92
  const { workflow } = processor.execution;
60
93
  const sync = this.workflow.isWorkflowSync(workflow);
61
- const transporter = import_nodemailer.default.createTransport(provider);
94
+ const transporter = this.getTransporter(provider);
62
95
  const send = (0, import_util.promisify)(transporter.sendMail.bind(transporter));
63
96
  const payload = {
64
97
  ...options,
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Send email in workflow.",
7
7
  "description.ru-RU": "Отправляет электронное письмо в рамках рабочего процесса.",
8
8
  "description.zh-CN": "可用于在工作流中发送电子邮件。",
9
- "version": "2.0.0-alpha.50",
9
+ "version": "2.0.0-alpha.52",
10
10
  "license": "AGPL-3.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow-smtp-mailer",
@@ -24,7 +24,7 @@
24
24
  "@nocobase/server": "2.x",
25
25
  "@nocobase/test": "2.x"
26
26
  },
27
- "gitHead": "a6eb64abf3632e116ad0b295a7f410270a1059d1",
27
+ "gitHead": "b32992d8baeb4ca6616d839ca2f9c023d49476a9",
28
28
  "keywords": [
29
29
  "NocoBase",
30
30
  "Workflow",