@nestjs-modules/mailer 1.4.2 → 1.6.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/.dockerignore +2 -2
- package/CHANGELOG.md +277 -196
- package/Dockerfile +10 -10
- package/LICENSE +20 -20
- package/README.md +66 -59
- package/dist/adapters/ejs.adapter.d.ts +9 -6
- package/dist/adapters/ejs.adapter.js +55 -35
- package/dist/adapters/handlebars.adapter.d.ts +10 -8
- package/dist/adapters/handlebars.adapter.js +70 -58
- package/dist/adapters/pug.adapter.d.ts +8 -5
- package/dist/adapters/pug.adapter.js +41 -27
- package/dist/constants/mailer.constant.d.ts +2 -0
- package/dist/constants/mailer.constant.js +5 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +10 -10
- package/dist/interfaces/mailer-async-options.interface.d.ts +9 -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 +51 -48
- 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 +73 -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/docker-compose.yml +18 -18
- package/index.d.ts +0 -0
- package/index.js +5 -5
- package/jest.config.js +17 -17
- package/package.json +100 -93
- package/dist/constants/mailer-options.constant.d.ts +0 -1
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/docker-compose.yml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
version: "3"
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
docusaurus:
|
|
5
|
-
build: .
|
|
6
|
-
ports:
|
|
7
|
-
- 3000:3000
|
|
8
|
-
- 35729:35729
|
|
9
|
-
volumes:
|
|
10
|
-
- ./docs:/app/docs
|
|
11
|
-
- ./website/blog:/app/website/blog
|
|
12
|
-
- ./website/core:/app/website/core
|
|
13
|
-
- ./website/i18n:/app/website/i18n
|
|
14
|
-
- ./website/pages:/app/website/pages
|
|
15
|
-
- ./website/static:/app/website/static
|
|
16
|
-
- ./website/sidebars.json:/app/website/sidebars.json
|
|
17
|
-
- ./website/siteConfig.js:/app/website/siteConfig.js
|
|
18
|
-
working_dir: /app/website
|
|
1
|
+
version: "3"
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
docusaurus:
|
|
5
|
+
build: .
|
|
6
|
+
ports:
|
|
7
|
+
- 3000:3000
|
|
8
|
+
- 35729:35729
|
|
9
|
+
volumes:
|
|
10
|
+
- ./docs:/app/docs
|
|
11
|
+
- ./website/blog:/app/website/blog
|
|
12
|
+
- ./website/core:/app/website/core
|
|
13
|
+
- ./website/i18n:/app/website/i18n
|
|
14
|
+
- ./website/pages:/app/website/pages
|
|
15
|
+
- ./website/static:/app/website/static
|
|
16
|
+
- ./website/sidebars.json:/app/website/sidebars.json
|
|
17
|
+
- ./website/siteConfig.js:/app/website/siteConfig.js
|
|
18
|
+
working_dir: /app/website
|
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/jest.config.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require('ts-node/register');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
'moduleFileExtensions': [
|
|
5
|
-
'js',
|
|
6
|
-
'json',
|
|
7
|
-
'ts',
|
|
8
|
-
],
|
|
9
|
-
'rootDir': 'lib',
|
|
10
|
-
'testRegex': '/lib/.*\\.spec\\.(ts|js)$',
|
|
11
|
-
'globals': {
|
|
12
|
-
'ts-jest': {
|
|
13
|
-
'tsConfig': 'tsconfig.json'
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
'preset': 'ts-jest',
|
|
17
|
-
};
|
|
1
|
+
require('ts-node/register');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
'moduleFileExtensions': [
|
|
5
|
+
'js',
|
|
6
|
+
'json',
|
|
7
|
+
'ts',
|
|
8
|
+
],
|
|
9
|
+
'rootDir': 'lib',
|
|
10
|
+
'testRegex': '/lib/.*\\.spec\\.(ts|js)$',
|
|
11
|
+
'globals': {
|
|
12
|
+
'ts-jest': {
|
|
13
|
+
'tsConfig': 'tsconfig.json'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
'preset': 'ts-jest',
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,93 +1,100 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nestjs-modules/mailer",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
"@types/
|
|
58
|
-
"@types/
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"typescript": "
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nestjs-modules/mailer",
|
|
3
|
+
"version": "1.6.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.1.6",
|
|
53
|
+
"inline-css": "3.0.0",
|
|
54
|
+
"preview-email": "3.0.4"
|
|
55
|
+
},
|
|
56
|
+
"optionalDependencies": {
|
|
57
|
+
"@types/ejs": "^3.0.3",
|
|
58
|
+
"@types/pug": "2.0.4",
|
|
59
|
+
"ejs": "^3.1.2",
|
|
60
|
+
"handlebars": "^4.7.6",
|
|
61
|
+
"pug": "^3.0.1"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/cli": "12.1.1",
|
|
65
|
+
"@commitlint/config-angular": "12.1.1",
|
|
66
|
+
"@nestjs/common": "7.6.15",
|
|
67
|
+
"@nestjs/core": "7.6.15",
|
|
68
|
+
"@nestjs/testing": "7.6.15",
|
|
69
|
+
"@types/glob": "7.1.3",
|
|
70
|
+
"@types/inline-css": "0.0.33",
|
|
71
|
+
"@types/jest": "26.0.22",
|
|
72
|
+
"@types/lodash": "4.14.168",
|
|
73
|
+
"@types/nodemailer": "6.4.1",
|
|
74
|
+
"@types/pug": "2.0.4",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "4.22.0",
|
|
76
|
+
"@typescript-eslint/parser": "4.22.0",
|
|
77
|
+
"husky": "6.0.0",
|
|
78
|
+
"lint-staged": "10.5.4",
|
|
79
|
+
"jest": "26.6.3",
|
|
80
|
+
"nodemailer": "6.5.0",
|
|
81
|
+
"nodemailer-mock": "1.5.8",
|
|
82
|
+
"prettier": "2.2.1",
|
|
83
|
+
"reflect-metadata": "0.1.13",
|
|
84
|
+
"rimraf": "3.0.2",
|
|
85
|
+
"standard-version": "9.2.0",
|
|
86
|
+
"ts-jest": "26.5.4",
|
|
87
|
+
"ts-node": "9.1.1",
|
|
88
|
+
"typescript": "4.2.4"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@nestjs/common": "^7.0.9",
|
|
92
|
+
"@nestjs/core": "^7.0.9",
|
|
93
|
+
"@types/ejs": "^3.0.3",
|
|
94
|
+
"@types/pug": "2.0.4",
|
|
95
|
+
"ejs": "^3.1.2",
|
|
96
|
+
"handlebars": "^4.7.6",
|
|
97
|
+
"nodemailer": "^6.4.6",
|
|
98
|
+
"pug": "^2.0.4 || ^3.0.0"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const MAILER_OPTIONS = "MAILER_OPTIONS";
|