@nestjs-modules/mailer 1.5.1 → 1.7.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/CHANGELOG.md +319 -231
- package/LICENSE +20 -20
- package/README.md +66 -64
- package/SECURITY.md +21 -0
- package/dist/adapters/ejs.adapter.d.ts +9 -6
- package/dist/adapters/ejs.adapter.js +58 -43
- package/dist/adapters/handlebars.adapter.d.ts +10 -8
- package/dist/adapters/handlebars.adapter.js +76 -58
- package/dist/adapters/mjml.adapter.d.ts +12 -0
- package/dist/adapters/mjml.adapter.js +34 -0
- package/dist/adapters/pug.adapter.d.ts +8 -5
- package/dist/adapters/pug.adapter.js +44 -27
- package/dist/constants/mailer.constant.d.ts +2 -0
- package/dist/constants/mailer.constant.js +5 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +10 -6
- package/dist/interfaces/mailer-async-options.interface.d.ts +11 -9
- package/dist/interfaces/mailer-async-options.interface.js +2 -2
- package/dist/interfaces/mailer-options-factory.interface.d.ts +4 -4
- package/dist/interfaces/mailer-options-factory.interface.js +2 -2
- package/dist/interfaces/mailer-options.interface.d.ts +35 -35
- package/dist/interfaces/mailer-options.interface.js +2 -2
- package/dist/interfaces/mailer-send-mail-options.interface.d.ts +5 -5
- package/dist/interfaces/mailer-send-mail-options.interface.js +2 -2
- package/dist/interfaces/mailer-transport-factory.interface.d.ts +5 -0
- package/dist/{constants/mailer-options.constant.js → interfaces/mailer-transport-factory.interface.js} +2 -3
- package/dist/interfaces/send-mail-options.interface.d.ts +54 -49
- package/dist/interfaces/send-mail-options.interface.js +2 -2
- package/dist/interfaces/template-adapter-config.interface.d.ts +5 -0
- package/dist/interfaces/template-adapter-config.interface.js +2 -0
- package/dist/interfaces/template-adapter.interface.d.ts +4 -4
- package/dist/interfaces/template-adapter.interface.js +2 -2
- package/dist/mailer-core.module.d.ts +9 -9
- package/dist/mailer-core.module.js +74 -72
- package/dist/mailer-transport.factory.d.ts +8 -0
- package/dist/mailer-transport.factory.js +20 -0
- package/dist/mailer.module.d.ts +7 -7
- package/dist/mailer.module.js +29 -28
- package/dist/mailer.service.d.ts +13 -11
- package/dist/mailer.service.js +90 -83
- package/index.d.ts +0 -0
- package/index.js +5 -5
- package/package.json +102 -100
- package/yarn-error.log +6492 -0
- package/.dockerignore +0 -2
- package/Dockerfile +0 -10
- package/dist/constants/mailer-options.constant.d.ts +0 -1
- package/docker-compose.yml +0 -18
- package/jest.config.js +0 -17
package/dist/mailer.service.js
CHANGED
|
@@ -1,83 +1,90 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const previewEmail = require("preview-email");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MailerService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const previewEmail = require("preview-email");
|
|
8
|
+
const mailer_constant_1 = require("./constants/mailer.constant");
|
|
9
|
+
const mailer_transport_factory_1 = require("./mailer-transport.factory");
|
|
10
|
+
let MailerService = class MailerService {
|
|
11
|
+
constructor(mailerOptions, transportFactory) {
|
|
12
|
+
this.mailerOptions = mailerOptions;
|
|
13
|
+
this.transportFactory = transportFactory;
|
|
14
|
+
this.transporters = new Map();
|
|
15
|
+
if (!transportFactory) {
|
|
16
|
+
this.transportFactory = new mailer_transport_factory_1.MailerTransportFactory(mailerOptions);
|
|
17
|
+
}
|
|
18
|
+
if ((!mailerOptions.transport ||
|
|
19
|
+
Object.keys(mailerOptions.transport).length <= 0) &&
|
|
20
|
+
!mailerOptions.transports) {
|
|
21
|
+
throw new Error('Make sure to provide a nodemailer transport configuration object, connection url or a transport plugin instance.');
|
|
22
|
+
}
|
|
23
|
+
const templateAdapter = lodash_1.get(this.mailerOptions, 'template.adapter');
|
|
24
|
+
if (this.mailerOptions.preview) {
|
|
25
|
+
const defaults = { open: { wait: false } };
|
|
26
|
+
this.mailerOptions.preview =
|
|
27
|
+
typeof this.mailerOptions.preview === 'boolean'
|
|
28
|
+
? defaults
|
|
29
|
+
: lodash_1.defaultsDeep(this.mailerOptions.preview, defaults);
|
|
30
|
+
}
|
|
31
|
+
if (mailerOptions.transports) {
|
|
32
|
+
Object.keys(mailerOptions.transports).forEach((name) => {
|
|
33
|
+
this.transporters.set(name, this.transportFactory.createTransport(this.mailerOptions.transports[name]));
|
|
34
|
+
this.initTemplateAdapter(templateAdapter, this.transporters.get(name));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (mailerOptions.transport) {
|
|
38
|
+
this.transporter = this.transportFactory.createTransport();
|
|
39
|
+
this.initTemplateAdapter(templateAdapter, this.transporter);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
initTemplateAdapter(templateAdapter, transporter) {
|
|
43
|
+
if (templateAdapter) {
|
|
44
|
+
transporter.use('compile', (mail, callback) => {
|
|
45
|
+
if (mail.data.html) {
|
|
46
|
+
return callback();
|
|
47
|
+
}
|
|
48
|
+
return templateAdapter.compile(mail, callback, this.mailerOptions);
|
|
49
|
+
});
|
|
50
|
+
if (this.mailerOptions.preview) {
|
|
51
|
+
transporter.use('stream', (mail, callback) => {
|
|
52
|
+
return previewEmail(mail.data, this.mailerOptions.preview)
|
|
53
|
+
.then(() => callback())
|
|
54
|
+
.catch(callback);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
sendMail(sendMailOptions) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (sendMailOptions.transporterName) {
|
|
62
|
+
if (this.transporters &&
|
|
63
|
+
this.transporters.get(sendMailOptions.transporterName)) {
|
|
64
|
+
return yield this.transporters
|
|
65
|
+
.get(sendMailOptions.transporterName)
|
|
66
|
+
.sendMail(sendMailOptions);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new ReferenceError(`Transporters object doesn't have ${sendMailOptions.transporterName} key`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if (this.transporter) {
|
|
74
|
+
return yield this.transporter.sendMail(sendMailOptions);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new ReferenceError(`Transporter object undefined`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
MailerService = tslib_1.__decorate([
|
|
84
|
+
common_1.Injectable(),
|
|
85
|
+
tslib_1.__param(0, common_1.Inject(mailer_constant_1.MAILER_OPTIONS)),
|
|
86
|
+
tslib_1.__param(1, common_1.Optional()),
|
|
87
|
+
tslib_1.__param(1, common_1.Inject(mailer_constant_1.MAILER_TRANSPORT_FACTORY)),
|
|
88
|
+
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
89
|
+
], MailerService);
|
|
90
|
+
exports.MailerService = MailerService;
|
package/index.d.ts
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
|
-
exports.__esModule = true;
|
|
1
|
+
"use strict";
|
|
2
|
+
function __export(m) {
|
|
3
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
+
}
|
|
5
|
+
exports.__esModule = true;
|
|
6
6
|
__export(require("./dist"));
|
package/package.json
CHANGED
|
@@ -1,100 +1,102 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nestjs-modules/mailer",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"private": false,
|
|
5
|
-
"description": "NestJS - a mailer module (@mailer)",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"nest",
|
|
8
|
-
"nodemailer",
|
|
9
|
-
"mailer",
|
|
10
|
-
"nodejs"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://github.com/nest-modules/mailer#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/nest-modules/mailer/issues"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/nest-modules/mailer.git"
|
|
19
|
-
},
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"author": "Nest Modules TM",
|
|
22
|
-
"contributors": [
|
|
23
|
-
"Cristiam Díaz <c.diaz@udla.edu.co>",
|
|
24
|
-
"Eduardo Leal <eduardolleal@icloud.com>",
|
|
25
|
-
"Juan Echeverry <e.juandav@gmail.com>",
|
|
26
|
-
"Paweł Partyka <partyka95@icloud.com>",
|
|
27
|
-
"Yanarp"
|
|
28
|
-
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"prebuild": "rimraf dist",
|
|
31
|
-
"build": "tsc -p tsconfig.json",
|
|
32
|
-
"deploy": "sh ./publish.sh",
|
|
33
|
-
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write",
|
|
34
|
-
"major": "npm run release -- --release-as major",
|
|
35
|
-
"minor": "npm run release -- --release-as minor",
|
|
36
|
-
"patch": "npm run release -- --release-as patch",
|
|
37
|
-
"release": "standard-version",
|
|
38
|
-
"test": "jest"
|
|
39
|
-
},
|
|
40
|
-
"husky": {
|
|
41
|
-
"hooks": {
|
|
42
|
-
"pre-commit": "lint-staged",
|
|
43
|
-
"commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS"
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"lint-staged": {
|
|
47
|
-
"*.ts": [
|
|
48
|
-
"prettier --write"
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"glob": "7.
|
|
53
|
-
"inline-css": "
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"@types/
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"@commitlint/
|
|
66
|
-
"@
|
|
67
|
-
"@nestjs/
|
|
68
|
-
"@nestjs/
|
|
69
|
-
"@
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/
|
|
75
|
-
"@
|
|
76
|
-
"@typescript-eslint/
|
|
77
|
-
"
|
|
78
|
-
"husky": "
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"nodemailer": "6.
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"@
|
|
94
|
-
"@
|
|
95
|
-
"ejs": "^3.
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestjs-modules/mailer",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "NestJS - a mailer module (@mailer)",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"nest",
|
|
8
|
+
"nodemailer",
|
|
9
|
+
"mailer",
|
|
10
|
+
"nodejs"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/nest-modules/mailer#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/nest-modules/mailer/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/nest-modules/mailer.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "Nest Modules TM",
|
|
22
|
+
"contributors": [
|
|
23
|
+
"Cristiam Díaz <c.diaz@udla.edu.co>",
|
|
24
|
+
"Eduardo Leal <eduardolleal@icloud.com>",
|
|
25
|
+
"Juan Echeverry <e.juandav@gmail.com>",
|
|
26
|
+
"Paweł Partyka <partyka95@icloud.com>",
|
|
27
|
+
"Yanarp"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prebuild": "rimraf dist",
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"deploy": "sh ./publish.sh",
|
|
33
|
+
"format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write",
|
|
34
|
+
"major": "npm run release -- --release-as major",
|
|
35
|
+
"minor": "npm run release -- --release-as minor",
|
|
36
|
+
"patch": "npm run release -- --release-as patch",
|
|
37
|
+
"release": "standard-version",
|
|
38
|
+
"test": "jest"
|
|
39
|
+
},
|
|
40
|
+
"husky": {
|
|
41
|
+
"hooks": {
|
|
42
|
+
"pre-commit": "lint-staged",
|
|
43
|
+
"commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"lint-staged": {
|
|
47
|
+
"*.ts": [
|
|
48
|
+
"prettier --write"
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"glob": "7.2.0",
|
|
53
|
+
"inline-css": "3.0.0",
|
|
54
|
+
"mjml": "^4.12.0",
|
|
55
|
+
"preview-email": "3.0.4"
|
|
56
|
+
},
|
|
57
|
+
"optionalDependencies": {
|
|
58
|
+
"@types/ejs": "^3.0.3",
|
|
59
|
+
"@types/pug": "2.0.5",
|
|
60
|
+
"ejs": "^3.1.2",
|
|
61
|
+
"handlebars": "^4.7.6",
|
|
62
|
+
"pug": "^3.0.1"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@commitlint/cli": "13.2.1",
|
|
66
|
+
"@commitlint/config-angular": "13.2.0",
|
|
67
|
+
"@nestjs/common": "8.2.4",
|
|
68
|
+
"@nestjs/core": "8.2.4",
|
|
69
|
+
"@nestjs/testing": "8.2.4",
|
|
70
|
+
"@types/glob": "7.2.0",
|
|
71
|
+
"@types/inline-css": "3.0.1",
|
|
72
|
+
"@types/jest": "26.0.24",
|
|
73
|
+
"@types/lodash": "4.14.176",
|
|
74
|
+
"@types/nodemailer": "6.4.4",
|
|
75
|
+
"@types/pug": "2.0.5",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "5.8.0",
|
|
77
|
+
"@typescript-eslint/parser": "5.8.0",
|
|
78
|
+
"husky": "7.0.4",
|
|
79
|
+
"jest": "27.0.6",
|
|
80
|
+
"lint-staged": "11.2.6",
|
|
81
|
+
"nodemailer": "6.7.2",
|
|
82
|
+
"nodemailer-mock": "1.5.11",
|
|
83
|
+
"prettier": "2.3.2",
|
|
84
|
+
"reflect-metadata": "0.1.13",
|
|
85
|
+
"rimraf": "3.0.2",
|
|
86
|
+
"rxjs": "7.4.0",
|
|
87
|
+
"standard-version": "9.3.2",
|
|
88
|
+
"ts-jest": "27.1.2",
|
|
89
|
+
"ts-node": "10.2.1",
|
|
90
|
+
"typescript": "4.3.5"
|
|
91
|
+
},
|
|
92
|
+
"peerDependencies": {
|
|
93
|
+
"@nestjs/common": "^7.0.9 || ^8.0.0",
|
|
94
|
+
"@nestjs/core": "^7.0.9 || ^8.0.0",
|
|
95
|
+
"@types/ejs": "^3.0.3",
|
|
96
|
+
"@types/pug": "2.0.5",
|
|
97
|
+
"ejs": "^3.1.2",
|
|
98
|
+
"handlebars": "^4.7.6",
|
|
99
|
+
"nodemailer": "^6.4.6",
|
|
100
|
+
"pug": "^3.0.1"
|
|
101
|
+
}
|
|
102
|
+
}
|