@nestjs-modules/mailer 1.9.1 → 1.11.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 +1 -1
- package/CHANGELOG.md +25 -0
- package/README.md +2 -0
- package/dist/adapters/ejs.adapter.js +10 -10
- package/dist/adapters/handlebars.adapter.js +13 -11
- package/dist/adapters/pug.adapter.js +7 -9
- package/dist/interfaces/template-adapter-config.interface.d.ts +2 -2
- package/dist/mailer-core.module.js +2 -1
- package/dist/mailer-transport.factory.js +2 -1
- package/dist/mailer.module.js +2 -1
- package/dist/mailer.service.js +2 -1
- package/package.json +41 -44
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v20.10.0
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
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
|
+
## [1.11.0](https://github.com/nest-modules/mailer/compare/v1.10.3...v1.11.0) (2024-02-24)
|
|
6
|
+
|
|
7
|
+
### [1.10.3](https://github.com/nest-modules/mailer/compare/v1.10.2...v1.10.3) (2023-12-20)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add tslib ([36f3aca](https://github.com/nest-modules/mailer/commit/36f3aca0ffac5943fa1dcd927cce7200dbcdb8df))
|
|
13
|
+
|
|
14
|
+
### [1.10.2](https://github.com/nest-modules/mailer/compare/v1.10.0...v1.10.2) (2023-12-20)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* allows you to handle peer dependencies greater than or equal to ([9885780](https://github.com/nest-modules/mailer/commit/988578099fe9975ca96c3e245bfc1b709d9be28a))
|
|
20
|
+
|
|
21
|
+
### [1.10.1](https://github.com/nest-modules/mailer/compare/v1.10.0...v1.10.1) (2023-12-20)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* allows you to handle peer dependencies greater than or equal to ([9885780](https://github.com/nest-modules/mailer/commit/988578099fe9975ca96c3e245bfc1b709d9be28a))
|
|
27
|
+
|
|
28
|
+
## [1.10.0](https://github.com/nest-modules/mailer/compare/v1.9.1...v1.10.0) (2023-12-20)
|
|
29
|
+
|
|
5
30
|
### [1.9.1](https://github.com/nest-modules/mailer/compare/v1.9.0...v1.9.1) (2023-07-20)
|
|
6
31
|
|
|
7
32
|
|
package/README.md
CHANGED
|
@@ -60,6 +60,8 @@ you can find all the documentation [here](https://nest-modules.github.io/mailer/
|
|
|
60
60
|
* [Juan Echeverry](https://github.com/juandav)
|
|
61
61
|
* [Pat McGowan](https://github.com/p-mcgowan)
|
|
62
62
|
* [Paweł Partyka](https://github.com/partyka95)
|
|
63
|
+
* [Wasutan Kitijerapat](https://github.com/kitimark)
|
|
64
|
+
* [Alexandre Titeux](https://github.com/GFoniX)
|
|
63
65
|
|
|
64
66
|
### License
|
|
65
67
|
|
|
@@ -5,12 +5,12 @@ 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
|
|
8
|
+
const css_inline_1 = require("css-inline");
|
|
9
9
|
class EjsAdapter {
|
|
10
10
|
constructor(config) {
|
|
11
11
|
this.precompiledTemplates = {};
|
|
12
12
|
this.config = {
|
|
13
|
-
inlineCssOptions: {
|
|
13
|
+
inlineCssOptions: {},
|
|
14
14
|
inlineCssEnabled: true,
|
|
15
15
|
};
|
|
16
16
|
Object.assign(this.config, config);
|
|
@@ -24,7 +24,9 @@ class EjsAdapter {
|
|
|
24
24
|
? path.dirname(template)
|
|
25
25
|
: path.join(templateBaseDir, path.dirname(template));
|
|
26
26
|
const templatePath = path.join(templateDir, templateName + templateExt);
|
|
27
|
-
templateName = path
|
|
27
|
+
templateName = path
|
|
28
|
+
.relative(templateBaseDir, templatePath)
|
|
29
|
+
.replace(templateExt, '');
|
|
28
30
|
if (!this.precompiledTemplates[templateName]) {
|
|
29
31
|
try {
|
|
30
32
|
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
@@ -37,17 +39,15 @@ class EjsAdapter {
|
|
|
37
39
|
const rendered = this.precompiledTemplates[templateName](context);
|
|
38
40
|
const render = (html) => {
|
|
39
41
|
if (this.config.inlineCssEnabled) {
|
|
40
|
-
|
|
41
|
-
.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})
|
|
45
|
-
.catch(callback);
|
|
42
|
+
try {
|
|
43
|
+
mail.data.html = (0, css_inline_1.inline)(html, this.config.inlineCssOptions);
|
|
44
|
+
}
|
|
45
|
+
catch (e) { }
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
mail.data.html = html;
|
|
49
|
-
return callback();
|
|
50
49
|
}
|
|
50
|
+
return callback();
|
|
51
51
|
};
|
|
52
52
|
if (typeof rendered === 'string') {
|
|
53
53
|
render(rendered);
|
|
@@ -4,14 +4,14 @@ exports.HandlebarsAdapter = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const handlebars = require("handlebars");
|
|
7
|
-
const
|
|
7
|
+
const css_inline_1 = require("css-inline");
|
|
8
8
|
const glob = require("glob");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
10
10
|
class HandlebarsAdapter {
|
|
11
11
|
constructor(helpers, config) {
|
|
12
12
|
this.precompiledTemplates = {};
|
|
13
13
|
this.config = {
|
|
14
|
-
inlineCssOptions: {
|
|
14
|
+
inlineCssOptions: {},
|
|
15
15
|
inlineCssEnabled: true,
|
|
16
16
|
};
|
|
17
17
|
handlebars.registerHelper('concat', (...args) => {
|
|
@@ -30,7 +30,9 @@ class HandlebarsAdapter {
|
|
|
30
30
|
? path.dirname(template)
|
|
31
31
|
: path.join(templateBaseDir, path.dirname(template));
|
|
32
32
|
const templatePath = path.join(templateDir, templateName + templateExt);
|
|
33
|
-
templateName = path
|
|
33
|
+
templateName = path
|
|
34
|
+
.relative(templateBaseDir, templatePath)
|
|
35
|
+
.replace(templateExt, '');
|
|
34
36
|
if (!this.precompiledTemplates[templateName]) {
|
|
35
37
|
try {
|
|
36
38
|
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
@@ -53,7 +55,9 @@ class HandlebarsAdapter {
|
|
|
53
55
|
data: {},
|
|
54
56
|
});
|
|
55
57
|
if (runtimeOptions.partials) {
|
|
56
|
-
const partialPath = path
|
|
58
|
+
const partialPath = path
|
|
59
|
+
.join(runtimeOptions.partials.dir, '**', '*.hbs')
|
|
60
|
+
.replace(/\\/g, '/');
|
|
57
61
|
const files = glob.sync(partialPath);
|
|
58
62
|
files.forEach((file) => {
|
|
59
63
|
const { templateName, templatePath } = precompile(file, () => { }, runtimeOptions.partials);
|
|
@@ -63,17 +67,15 @@ class HandlebarsAdapter {
|
|
|
63
67
|
}
|
|
64
68
|
const rendered = this.precompiledTemplates[templateName](mail.data.context, Object.assign(Object.assign({}, runtimeOptions), { partials: this.precompiledTemplates }));
|
|
65
69
|
if (this.config.inlineCssEnabled) {
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})
|
|
71
|
-
.catch(callback);
|
|
70
|
+
try {
|
|
71
|
+
mail.data.html = (0, css_inline_1.inline)(rendered, this.config.inlineCssOptions);
|
|
72
|
+
}
|
|
73
|
+
catch (e) { }
|
|
72
74
|
}
|
|
73
75
|
else {
|
|
74
76
|
mail.data.html = rendered;
|
|
75
|
-
return callback();
|
|
76
77
|
}
|
|
78
|
+
return callback();
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
exports.HandlebarsAdapter = HandlebarsAdapter;
|
|
@@ -4,11 +4,11 @@ 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
|
|
7
|
+
const css_inline_1 = require("css-inline");
|
|
8
8
|
class PugAdapter {
|
|
9
9
|
constructor(config) {
|
|
10
10
|
this.config = {
|
|
11
|
-
inlineCssOptions: {
|
|
11
|
+
inlineCssOptions: {},
|
|
12
12
|
inlineCssEnabled: true,
|
|
13
13
|
};
|
|
14
14
|
Object.assign(this.config, config);
|
|
@@ -27,17 +27,15 @@ class PugAdapter {
|
|
|
27
27
|
return callback(err);
|
|
28
28
|
}
|
|
29
29
|
if (this.config.inlineCssEnabled) {
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
35
|
-
.catch(callback);
|
|
30
|
+
try {
|
|
31
|
+
mail.data.html = (0, css_inline_1.inline)(body, this.config.inlineCssOptions);
|
|
32
|
+
}
|
|
33
|
+
catch (e) { }
|
|
36
34
|
}
|
|
37
35
|
else {
|
|
38
36
|
mail.data.html = body;
|
|
39
|
-
return callback();
|
|
40
37
|
}
|
|
38
|
+
return callback();
|
|
41
39
|
});
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -6,7 +6,7 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const mailer_constant_1 = require("./constants/mailer.constant");
|
|
8
8
|
const mailer_service_1 = require("./mailer.service");
|
|
9
|
-
let MailerCoreModule =
|
|
9
|
+
let MailerCoreModule = MailerCoreModule_1 = class MailerCoreModule {
|
|
10
10
|
static forRoot(options) {
|
|
11
11
|
const MailerOptionsProvider = {
|
|
12
12
|
provide: mailer_constant_1.MAILER_OPTIONS,
|
|
@@ -67,6 +67,7 @@ let MailerCoreModule = exports.MailerCoreModule = MailerCoreModule_1 = class Mai
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
+
exports.MailerCoreModule = MailerCoreModule;
|
|
70
71
|
exports.MailerCoreModule = MailerCoreModule = MailerCoreModule_1 = tslib_1.__decorate([
|
|
71
72
|
(0, common_1.Global)(),
|
|
72
73
|
(0, common_1.Module)({})
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const nodemailer_1 = require("nodemailer");
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const mailer_constant_1 = require("./constants/mailer.constant");
|
|
8
|
-
let MailerTransportFactory =
|
|
8
|
+
let MailerTransportFactory = class MailerTransportFactory {
|
|
9
9
|
constructor(options) {
|
|
10
10
|
this.options = options;
|
|
11
11
|
}
|
|
@@ -13,6 +13,7 @@ let MailerTransportFactory = exports.MailerTransportFactory = class MailerTransp
|
|
|
13
13
|
return (0, nodemailer_1.createTransport)(opts || this.options.transport, this.options.defaults);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
+
exports.MailerTransportFactory = MailerTransportFactory;
|
|
16
17
|
exports.MailerTransportFactory = MailerTransportFactory = tslib_1.__decorate([
|
|
17
18
|
tslib_1.__param(0, (0, common_1.Inject)(mailer_constant_1.MAILER_OPTIONS)),
|
|
18
19
|
tslib_1.__metadata("design:paramtypes", [Object])
|
package/dist/mailer.module.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.MailerModule = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const common_1 = require("@nestjs/common");
|
|
7
7
|
const mailer_core_module_1 = require("./mailer-core.module");
|
|
8
|
-
let MailerModule =
|
|
8
|
+
let MailerModule = MailerModule_1 = class MailerModule {
|
|
9
9
|
static forRoot(options) {
|
|
10
10
|
return {
|
|
11
11
|
module: MailerModule_1,
|
|
@@ -23,6 +23,7 @@ let MailerModule = exports.MailerModule = MailerModule_1 = class MailerModule {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
+
exports.MailerModule = MailerModule;
|
|
26
27
|
exports.MailerModule = MailerModule = MailerModule_1 = tslib_1.__decorate([
|
|
27
28
|
(0, common_1.Module)({})
|
|
28
29
|
], MailerModule);
|
package/dist/mailer.service.js
CHANGED
|
@@ -7,7 +7,7 @@ const common_1 = require("@nestjs/common");
|
|
|
7
7
|
const previewEmail = require("preview-email");
|
|
8
8
|
const mailer_constant_1 = require("./constants/mailer.constant");
|
|
9
9
|
const mailer_transport_factory_1 = require("./mailer-transport.factory");
|
|
10
|
-
let MailerService =
|
|
10
|
+
let MailerService = class MailerService {
|
|
11
11
|
initTemplateAdapter(templateAdapter, transporter) {
|
|
12
12
|
if (templateAdapter) {
|
|
13
13
|
transporter.use('compile', (mail, callback) => {
|
|
@@ -85,6 +85,7 @@ let MailerService = exports.MailerService = class MailerService {
|
|
|
85
85
|
return transporterName;
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
+
exports.MailerService = MailerService;
|
|
88
89
|
exports.MailerService = MailerService = tslib_1.__decorate([
|
|
89
90
|
(0, common_1.Injectable)(),
|
|
90
91
|
tslib_1.__param(0, (0, common_1.Inject)(mailer_constant_1.MAILER_OPTIONS)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs-modules/mailer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "NestJS - a mailer module (@mailer)",
|
|
6
6
|
"keywords": [
|
|
@@ -52,58 +52,55 @@
|
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"mjml": "
|
|
55
|
+
"@css-inline/css-inline": "0.13.0",
|
|
56
|
+
"glob": "10.3.10",
|
|
57
|
+
"mjml": "4.15.3",
|
|
58
58
|
"preview-email": "3.0.19"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@types/ejs": "^3.1.
|
|
62
|
-
"@types/pug": "2.0.
|
|
61
|
+
"@types/ejs": "^3.1.5",
|
|
62
|
+
"@types/pug": "^2.0.10",
|
|
63
63
|
"ejs": "^3.1.9",
|
|
64
|
-
"handlebars": "^4.7.
|
|
64
|
+
"handlebars": "^4.7.8",
|
|
65
65
|
"pug": "^3.0.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "
|
|
69
|
-
"@commitlint/config-angular": "
|
|
70
|
-
"@nestjs/common": "
|
|
71
|
-
"@nestjs/core": "
|
|
72
|
-
"@nestjs/testing": "
|
|
73
|
-
"@types/glob": "
|
|
74
|
-
"@types/
|
|
75
|
-
"@types/
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/
|
|
78
|
-
"@
|
|
79
|
-
"@typescript-eslint/
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"nodemailer": "
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"rxjs": "^7.8.1",
|
|
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",
|
|
73
|
+
"@types/glob": "8.1.0",
|
|
74
|
+
"@types/jest": "29.5.12",
|
|
75
|
+
"@types/lodash": "4.14.202",
|
|
76
|
+
"@types/nodemailer": "6.4.14",
|
|
77
|
+
"@types/pug": "2.0.10",
|
|
78
|
+
"@typescript-eslint/eslint-plugin": "7.0.2",
|
|
79
|
+
"@typescript-eslint/parser": "7.0.2",
|
|
80
|
+
"husky": "9.0.11",
|
|
81
|
+
"jest": "29.7.0",
|
|
82
|
+
"lint-staged": "15.2.2",
|
|
83
|
+
"nodemailer": "6.9.10",
|
|
84
|
+
"nodemailer-mock": "2.0.4",
|
|
85
|
+
"prettier": "3.2.5",
|
|
86
|
+
"reflect-metadata": "0.2.1",
|
|
87
|
+
"rimraf": "5.0.5",
|
|
88
|
+
"rxjs": "7.8.1",
|
|
90
89
|
"standard-version": "9.5.0",
|
|
91
|
-
"ts-jest": "
|
|
92
|
-
"ts-node": "10.9.
|
|
93
|
-
"
|
|
94
|
-
"
|
|
90
|
+
"ts-jest": "29.1.2",
|
|
91
|
+
"ts-node": "10.9.2",
|
|
92
|
+
"tslib": "2.6.2",
|
|
93
|
+
"typescript": "5.3.3",
|
|
94
|
+
"yarn-audit-fix": "10.0.7"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@nestjs/common": "
|
|
98
|
-
"@nestjs/core": "
|
|
99
|
-
"@types/ejs": "
|
|
100
|
-
"@types/pug": "2.0.6",
|
|
101
|
-
"ejs": "
|
|
102
|
-
"handlebars": "
|
|
103
|
-
"nodemailer": "
|
|
104
|
-
"pug": "
|
|
105
|
-
},
|
|
106
|
-
"resolutions": {
|
|
107
|
-
"vm2": "isolated-vm"
|
|
97
|
+
"@nestjs/common": ">=7.0.9",
|
|
98
|
+
"@nestjs/core": ">=7.0.9",
|
|
99
|
+
"@types/ejs": ">=3.0.3",
|
|
100
|
+
"@types/pug": ">=2.0.6",
|
|
101
|
+
"ejs": ">=3.1.2",
|
|
102
|
+
"handlebars": ">=4.7.6",
|
|
103
|
+
"nodemailer": ">=6.4.6",
|
|
104
|
+
"pug": ">=3.0.1"
|
|
108
105
|
}
|
|
109
106
|
}
|