@nestjs-modules/mailer 1.11.0 → 2.0.0

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/.nvmrc CHANGED
@@ -1 +1 @@
1
- v20.10.0
1
+ v20.12.2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.0.0](https://github.com/nest-modules/mailer/compare/v1.11.2...v2.0.0) (2024-04-27)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **mailer.service:** The usage of in has been refactored. This could potentially alter the way configurations are merged in the application. Update your configurations if necessary to accommodate this change.
11
+
12
+ ### Features
13
+
14
+ * **mailer.service:** refactor usage of defaultsDeep ([3506885](https://github.com/nest-modules/mailer/commit/350688518e72d1fa347a11c2b1ed84988dbcc55a))
15
+
16
+ ### [1.11.2](https://github.com/nest-modules/mailer/compare/v1.11.0...v1.11.2) (2024-02-27)
17
+
18
+ ### [1.11.1](https://github.com/nest-modules/mailer/compare/v1.11.0...v1.11.1) (2024-02-27)
19
+
5
20
  ## [1.11.0](https://github.com/nest-modules/mailer/compare/v1.10.3...v1.11.0) (2024-02-24)
6
21
 
7
22
  ### [1.10.3](https://github.com/nest-modules/mailer/compare/v1.10.2...v1.10.3) (2023-12-20)
package/README.md CHANGED
@@ -34,6 +34,8 @@ npm install --save handlebars
34
34
  npm install --save pug
35
35
  #or
36
36
  npm install --save ejs
37
+ #or
38
+ npm install --save mjml
37
39
  ```
38
40
 
39
41
  #### with yarn
@@ -43,6 +45,8 @@ yarn add handlebars
43
45
  yarn add pug
44
46
  #or
45
47
  yarn add ejs
48
+ #or
49
+ yarn add mjml
46
50
  ```
47
51
 
48
52
  ### Documentation
@@ -5,7 +5,7 @@ const ejs_1 = require("ejs");
5
5
  const lodash_1 = require("lodash");
6
6
  const fs = require("fs");
7
7
  const path = require("path");
8
- const css_inline_1 = require("css-inline");
8
+ const css_inline_1 = require("@css-inline/css-inline");
9
9
  class EjsAdapter {
10
10
  constructor(config) {
11
11
  this.precompiledTemplates = {};
@@ -42,7 +42,9 @@ class EjsAdapter {
42
42
  try {
43
43
  mail.data.html = (0, css_inline_1.inline)(html, this.config.inlineCssOptions);
44
44
  }
45
- catch (e) { }
45
+ catch (e) {
46
+ callback(e);
47
+ }
46
48
  }
47
49
  else {
48
50
  mail.data.html = html;
@@ -4,7 +4,7 @@ exports.HandlebarsAdapter = void 0;
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
  const handlebars = require("handlebars");
7
- const css_inline_1 = require("css-inline");
7
+ const css_inline_1 = require("@css-inline/css-inline");
8
8
  const glob = require("glob");
9
9
  const lodash_1 = require("lodash");
10
10
  class HandlebarsAdapter {
@@ -70,7 +70,9 @@ class HandlebarsAdapter {
70
70
  try {
71
71
  mail.data.html = (0, css_inline_1.inline)(rendered, this.config.inlineCssOptions);
72
72
  }
73
- catch (e) { }
73
+ catch (e) {
74
+ callback(e);
75
+ }
74
76
  }
75
77
  else {
76
78
  mail.data.html = rendered;
@@ -4,7 +4,7 @@ exports.PugAdapter = void 0;
4
4
  const path = require("path");
5
5
  const lodash_1 = require("lodash");
6
6
  const pug_1 = require("pug");
7
- const css_inline_1 = require("css-inline");
7
+ const css_inline_1 = require("@css-inline/css-inline");
8
8
  class PugAdapter {
9
9
  constructor(config) {
10
10
  this.config = {
@@ -30,7 +30,9 @@ class PugAdapter {
30
30
  try {
31
31
  mail.data.html = (0, css_inline_1.inline)(body, this.config.inlineCssOptions);
32
32
  }
33
- catch (e) { }
33
+ catch (e) {
34
+ callback(e);
35
+ }
34
36
  }
35
37
  else {
36
38
  mail.data.html = body;
@@ -1,5 +1,5 @@
1
- import { InlineOptions } from 'css-inline';
1
+ import { Options } from '@css-inline/css-inline';
2
2
  export interface TemplateAdapterConfig {
3
- inlineCssOptions?: InlineOptions;
3
+ inlineCssOptions?: Options;
4
4
  inlineCssEnabled?: boolean;
5
5
  }
@@ -10,7 +10,9 @@ export declare class MailerService {
10
10
  private transporters;
11
11
  private templateAdapter;
12
12
  private initTemplateAdapter;
13
+ private readonly mailerLogger;
13
14
  constructor(mailerOptions: MailerOptions, transportFactory: IMailerTransportFactory);
15
+ private verifyTransporter;
14
16
  sendMail(sendMailOptions: ISendMailOptions): Promise<SentMessageInfo>;
15
17
  addTransporter(transporterName: string, config: string | smtpTransport | smtpTransport.Options): string;
16
18
  }
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var MailerService_1;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.MailerService = void 0;
4
5
  const tslib_1 = require("tslib");
@@ -7,7 +8,7 @@ const common_1 = require("@nestjs/common");
7
8
  const previewEmail = require("preview-email");
8
9
  const mailer_constant_1 = require("./constants/mailer.constant");
9
10
  const mailer_transport_factory_1 = require("./mailer-transport.factory");
10
- let MailerService = class MailerService {
11
+ let MailerService = MailerService_1 = class MailerService {
11
12
  initTemplateAdapter(templateAdapter, transporter) {
12
13
  if (templateAdapter) {
13
14
  transporter.use('compile', (mail, callback) => {
@@ -29,6 +30,7 @@ let MailerService = class MailerService {
29
30
  this.mailerOptions = mailerOptions;
30
31
  this.transportFactory = transportFactory;
31
32
  this.transporters = new Map();
33
+ this.mailerLogger = new common_1.Logger(MailerService_1.name);
32
34
  if (!transportFactory) {
33
35
  this.transportFactory = new mailer_transport_factory_1.MailerTransportFactory(mailerOptions);
34
36
  }
@@ -47,15 +49,24 @@ let MailerService = class MailerService {
47
49
  }
48
50
  if (mailerOptions.transports) {
49
51
  Object.keys(mailerOptions.transports).forEach((name) => {
50
- this.transporters.set(name, this.transportFactory.createTransport(this.mailerOptions.transports[name]));
51
- this.initTemplateAdapter(this.templateAdapter, this.transporters.get(name));
52
+ const transporter = this.transportFactory.createTransport(this.mailerOptions.transports[name]);
53
+ this.transporters.set(name, transporter);
54
+ this.verifyTransporter(transporter, name);
55
+ this.initTemplateAdapter(this.templateAdapter, transporter);
52
56
  });
53
57
  }
54
58
  if (mailerOptions.transport) {
55
59
  this.transporter = this.transportFactory.createTransport();
60
+ this.verifyTransporter(this.transporter);
56
61
  this.initTemplateAdapter(this.templateAdapter, this.transporter);
57
62
  }
58
63
  }
64
+ verifyTransporter(transporter, name) {
65
+ const transporterName = name ? ` '${name}'` : '';
66
+ transporter.verify()
67
+ .then(() => this.mailerLogger.error(`Transporter${transporterName} is ready`))
68
+ .catch((error) => this.mailerLogger.error(`Error occurred while verifying the transporter${transporterName}}: ${error.message}`));
69
+ }
59
70
  sendMail(sendMailOptions) {
60
71
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
72
  if (sendMailOptions.transporterName) {
@@ -86,7 +97,7 @@ let MailerService = class MailerService {
86
97
  }
87
98
  };
88
99
  exports.MailerService = MailerService;
89
- exports.MailerService = MailerService = tslib_1.__decorate([
100
+ exports.MailerService = MailerService = MailerService_1 = tslib_1.__decorate([
90
101
  (0, common_1.Injectable)(),
91
102
  tslib_1.__param(0, (0, common_1.Inject)(mailer_constant_1.MAILER_OPTIONS)),
92
103
  tslib_1.__param(1, (0, common_1.Optional)()),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-modules/mailer",
3
- "version": "1.11.0",
3
+ "version": "2.0.0",
4
4
  "private": false,
5
5
  "description": "NestJS - a mailer module (@mailer)",
6
6
  "keywords": [
@@ -24,7 +24,9 @@
24
24
  "Eduardo Leal <eduardolleal@icloud.com>",
25
25
  "Juan Echeverry <e.juandav@gmail.com>",
26
26
  "Paweł Partyka <partyka95@icloud.com>",
27
- "Yanarp"
27
+ "Alexandre TITEUX <alexandretiteux@gmail.com>",
28
+ "Yanarp",
29
+ "Joao vitor FREZYN <00001097715413SP@al.educacao.sp.gov.br>"
28
30
  ],
29
31
  "scripts": {
30
32
  "prebuild": "rimraf dist",
@@ -52,45 +54,47 @@
52
54
  ]
53
55
  },
54
56
  "dependencies": {
55
- "@css-inline/css-inline": "0.13.0",
56
- "glob": "10.3.10",
57
- "mjml": "4.15.3",
58
- "preview-email": "3.0.19"
57
+ "@css-inline/css-inline": "0.14.1",
58
+ "glob": "10.3.12"
59
59
  },
60
60
  "optionalDependencies": {
61
61
  "@types/ejs": "^3.1.5",
62
62
  "@types/pug": "^2.0.10",
63
- "ejs": "^3.1.9",
63
+ "@types/mjml": "^4.7.4",
64
+ "ejs": "^3.1.10",
64
65
  "handlebars": "^4.7.8",
65
- "pug": "^3.0.2"
66
+ "mjml": "^4.15.3",
67
+ "pug": "^3.0.2",
68
+ "liquidjs": "^10.11.1"
66
69
  },
67
70
  "devDependencies": {
68
- "@commitlint/cli": "18.6.1",
69
- "@commitlint/config-angular": "18.6.1",
70
- "@nestjs/common": "10.3.3",
71
- "@nestjs/core": "10.3.3",
72
- "@nestjs/testing": "10.3.3",
71
+ "@commitlint/cli": "19.3.0",
72
+ "@commitlint/config-angular": "19.3.0",
73
+ "@nestjs/common": "10.3.8",
74
+ "@nestjs/core": "10.3.8",
75
+ "@nestjs/testing": "10.3.8",
73
76
  "@types/glob": "8.1.0",
74
77
  "@types/jest": "29.5.12",
75
- "@types/lodash": "4.14.202",
78
+ "@types/lodash": "4.17.0",
76
79
  "@types/nodemailer": "6.4.14",
77
80
  "@types/pug": "2.0.10",
78
- "@typescript-eslint/eslint-plugin": "7.0.2",
79
- "@typescript-eslint/parser": "7.0.2",
81
+ "@typescript-eslint/eslint-plugin": "7.7.1",
82
+ "@typescript-eslint/parser": "7.7.1",
80
83
  "husky": "9.0.11",
81
84
  "jest": "29.7.0",
82
85
  "lint-staged": "15.2.2",
83
- "nodemailer": "6.9.10",
84
- "nodemailer-mock": "2.0.4",
86
+ "nodemailer": "6.9.13",
87
+ "nodemailer-mock": "2.0.6",
85
88
  "prettier": "3.2.5",
86
- "reflect-metadata": "0.2.1",
89
+ "preview-email": "3.0.19",
90
+ "reflect-metadata": "0.2.2",
87
91
  "rimraf": "5.0.5",
88
92
  "rxjs": "7.8.1",
89
93
  "standard-version": "9.5.0",
90
94
  "ts-jest": "29.1.2",
91
95
  "ts-node": "10.9.2",
92
96
  "tslib": "2.6.2",
93
- "typescript": "5.3.3",
97
+ "typescript": "5.4.5",
94
98
  "yarn-audit-fix": "10.0.7"
95
99
  },
96
100
  "peerDependencies": {
@@ -98,9 +102,12 @@
98
102
  "@nestjs/core": ">=7.0.9",
99
103
  "@types/ejs": ">=3.0.3",
100
104
  "@types/pug": ">=2.0.6",
105
+ "@types/mjml": ">=4.7.4",
106
+ "nodemailer": ">=6.4.6",
101
107
  "ejs": ">=3.1.2",
102
108
  "handlebars": ">=4.7.6",
103
- "nodemailer": ">=6.4.6",
104
- "pug": ">=3.0.1"
109
+ "mjml": ">=4.15.3",
110
+ "pug": ">=3.0.1",
111
+ "liquidjs": ">=10.8.2"
105
112
  }
106
113
  }