@restorecommerce/mailer 0.1.10 → 0.1.16
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 +63 -0
- package/LICENSE +2 -2
- package/lib/index.d.ts +14 -0
- package/lib/index.js +44 -0
- package/package.json +33 -16
- package/src/index.ts +38 -0
- package/tsconfig.json +25 -0
- package/coverage/coverage.json +0 -1
- package/coverage/lcov.info +0 -33
- package/index.js +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.1.16](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.15...@restorecommerce/mailer@0.1.16) (2022-02-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @restorecommerce/mailer
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.15](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.14...@restorecommerce/mailer@0.1.15) (2021-08-23)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **version:** up version to be in sync in package-lock ([b8f22c1](https://github.com/restorecommerce/libs/commit/b8f22c1268ee2af4beff7d88bda30f197896e3d2))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [0.1.14](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.13...@restorecommerce/mailer@0.1.14) (2021-08-03)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* up pkg locks ([8ed92d6](https://github.com/restorecommerce/libs/commit/8ed92d613b9a095e4b5066056ac566e5dbcf1472))
|
|
31
|
+
* updated githead ([2904d30](https://github.com/restorecommerce/libs/commit/2904d30e5773dc8a87c01a08ff6481f99d692354))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## [0.1.13](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.12...@restorecommerce/mailer@0.1.13) (2021-08-03)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* **koa-health-check:** added missing .eslintrc.js ([45af632](https://github.com/restorecommerce/libs/commit/45af632955d2dd448e7a27f4e8c4b971412cd004))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## [0.1.12](https://github.com/restorecommerce/mailer/compare/@restorecommerce/mailer@0.1.11...@restorecommerce/mailer@0.1.12) (2021-05-25)
|
|
49
|
+
|
|
50
|
+
**Note:** Version bump only for package @restorecommerce/mailer
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## 0.1.11 (2021-05-24)
|
|
57
|
+
|
|
58
|
+
**Note:** Version bump only for package @restorecommerce/mailer
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
1
64
|
### 0.1.10 (April 15th, 2021)
|
|
2
65
|
|
|
3
66
|
Upgrade deps.
|
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) n-fuse GmbH and other contributors.
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
4
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
16
16
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
17
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
SOFTWARE.
|
|
19
|
+
SOFTWARE.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class Mailer {
|
|
2
|
+
/**
|
|
3
|
+
@param {Object} opts nodemailer transport options
|
|
4
|
+
@param {Object} htmlToTextOptions for nodemailer html to text module
|
|
5
|
+
*/
|
|
6
|
+
transport: any;
|
|
7
|
+
constructor(opts: any, htmlToTextOptions: any);
|
|
8
|
+
/**
|
|
9
|
+
@param {Object} mail nodemailer mail
|
|
10
|
+
@returns Promise
|
|
11
|
+
*/
|
|
12
|
+
send(mail: any): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
export default Mailer;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const nodemailer_html_to_text_1 = require("nodemailer-html-to-text");
|
|
16
|
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
17
|
+
const nodemailer_stub_transport_1 = __importDefault(require("nodemailer-stub-transport"));
|
|
18
|
+
const winston_1 = __importDefault(require("winston"));
|
|
19
|
+
class Mailer {
|
|
20
|
+
constructor(opts, htmlToTextOptions) {
|
|
21
|
+
const defaultOpts = {
|
|
22
|
+
logger: winston_1.default,
|
|
23
|
+
pool: true
|
|
24
|
+
};
|
|
25
|
+
const htmlToTextOpts = htmlToTextOptions || {};
|
|
26
|
+
if (process.env.NODE_ENV === 'test') {
|
|
27
|
+
this.transport = nodemailer_1.default.createTransport((0, nodemailer_stub_transport_1.default)());
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.transport = nodemailer_1.default.createTransport(opts, defaultOpts);
|
|
31
|
+
}
|
|
32
|
+
this.transport.use('compile', (0, nodemailer_html_to_text_1.htmlToText)(htmlToTextOpts));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
@param {Object} mail nodemailer mail
|
|
36
|
+
@returns Promise
|
|
37
|
+
*/
|
|
38
|
+
send(mail) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return this.transport.sendMail(mail);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = Mailer;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restorecommerce/mailer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Multi transport mailer based on nodemailer",
|
|
5
|
-
"main": "index",
|
|
6
|
-
"
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"author": "n-fuse GmbH",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/restorecommerce/
|
|
10
|
+
"url": "https://github.com/restorecommerce/libs.git"
|
|
10
11
|
},
|
|
11
12
|
"license": "MIT",
|
|
12
13
|
"keywords": [
|
|
@@ -14,30 +15,46 @@
|
|
|
14
15
|
"commerce"
|
|
15
16
|
],
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"nodemailer": "^6.
|
|
18
|
-
"nodemailer-html-to-text": "^3.
|
|
18
|
+
"nodemailer": "^6.7.2",
|
|
19
|
+
"nodemailer-html-to-text": "^3.2.0",
|
|
19
20
|
"nodemailer-mandrill-transport": "^1.2.0",
|
|
20
21
|
"nodemailer-stub-transport": "^1.1.0",
|
|
21
22
|
"nodemailer-wellknown": "^0.2.3",
|
|
22
|
-
"winston": "^3.
|
|
23
|
+
"winston": "^3.5.1"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@
|
|
26
|
+
"@types/mocha": "^9.1.0",
|
|
27
|
+
"@types/node": "^17.0.16",
|
|
28
|
+
"@types/nodemailer": "^6.4.4",
|
|
29
|
+
"@types/nodemailer-html-to-text": "^3.1.0",
|
|
30
|
+
"@types/nodemailer-stub-transport": "^1.1.5",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^5.11.0",
|
|
32
|
+
"@typescript-eslint/eslint-plugin-tslint": "^5.11.0",
|
|
33
|
+
"@typescript-eslint/parser": "^5.11.0",
|
|
26
34
|
"assert": "^2.0.0",
|
|
27
35
|
"co-mocha": "^1.2.2",
|
|
28
|
-
"coveralls": "^3.1.
|
|
36
|
+
"coveralls": "^3.1.1",
|
|
37
|
+
"eslint": "^8.8.0",
|
|
38
|
+
"eslint-plugin-prefer-arrow-functions": "^3.1.4",
|
|
29
39
|
"is-generator": "^1.0.3",
|
|
30
|
-
"mocha": "^
|
|
40
|
+
"mocha": "^9.2.0",
|
|
41
|
+
"npm-run-all": "^4.1.5",
|
|
31
42
|
"nyc": "^15.1.0",
|
|
32
|
-
"should": "^13.2.
|
|
43
|
+
"should": "^13.2.3",
|
|
44
|
+
"typescript": "^4.5.5"
|
|
33
45
|
},
|
|
34
46
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
47
|
+
"lint": "eslint src --ext .ts ",
|
|
48
|
+
"pretest": "npm run build",
|
|
49
|
+
"test": "nyc mocha ./test/* --exit",
|
|
50
|
+
"build:tsc": "tsc --strict",
|
|
51
|
+
"build:clean": "rimraf lib",
|
|
52
|
+
"build": "npm-run-all lint build:clean build:tsc",
|
|
53
|
+
"lcov-report": "nyc report --reporter=lcov",
|
|
54
|
+
"coveralls": "nyc --reporter text --reporter lcov npm test"
|
|
39
55
|
},
|
|
40
56
|
"engines": {
|
|
41
57
|
"node": ">= 10.0.0"
|
|
42
|
-
}
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "e97bbfe2fe8166dfe1cd47ae60bce54347a4f1c9"
|
|
43
60
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { htmlToText } from 'nodemailer-html-to-text';
|
|
2
|
+
import nodemailer from 'nodemailer';
|
|
3
|
+
import stubTransport from 'nodemailer-stub-transport';
|
|
4
|
+
import winston from 'winston';
|
|
5
|
+
|
|
6
|
+
class Mailer {
|
|
7
|
+
/**
|
|
8
|
+
@param {Object} opts nodemailer transport options
|
|
9
|
+
@param {Object} htmlToTextOptions for nodemailer html to text module
|
|
10
|
+
*/
|
|
11
|
+
transport: any;
|
|
12
|
+
|
|
13
|
+
constructor(opts: any, htmlToTextOptions: any) {
|
|
14
|
+
const defaultOpts = {
|
|
15
|
+
logger: winston,
|
|
16
|
+
pool: true
|
|
17
|
+
} as any;
|
|
18
|
+
|
|
19
|
+
const htmlToTextOpts = htmlToTextOptions || {};
|
|
20
|
+
|
|
21
|
+
if (process.env.NODE_ENV === 'test') {
|
|
22
|
+
this.transport = nodemailer.createTransport(stubTransport());
|
|
23
|
+
} else {
|
|
24
|
+
this.transport = nodemailer.createTransport(opts, defaultOpts);
|
|
25
|
+
}
|
|
26
|
+
this.transport.use('compile', htmlToText(htmlToTextOpts));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
@param {Object} mail nodemailer mail
|
|
31
|
+
@returns Promise
|
|
32
|
+
*/
|
|
33
|
+
async send(mail: any) {
|
|
34
|
+
return this.transport.sendMail(mail);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default Mailer;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES6",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"outDir": "lib",
|
|
13
|
+
"typeRoots": [
|
|
14
|
+
"node_modules/@types"
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"src/**/*.ts"
|
|
19
|
+
],
|
|
20
|
+
"exclude": [
|
|
21
|
+
"node_modules",
|
|
22
|
+
"lib",
|
|
23
|
+
"doc"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/coverage/coverage.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"/Restore/mailer/index.js":{"path":"/Restore/mailer/index.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":2,"8":2,"9":2,"10":2,"11":2,"12":1,"13":1,"14":2,"15":2,"16":2,"17":2,"18":1},"b":{"1":[1,1]},"f":{"1":2,"2":2},"fnMap":{"1":{"name":"(anonymous_1)","line":13,"loc":{"start":{"line":13,"column":13},"end":{"line":13,"column":39}}},"2":{"name":"(anonymous_2)","line":38,"loc":{"start":{"line":38,"column":6},"end":{"line":38,"column":13}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":36}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":28}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":65}},"4":{"start":{"line":4,"column":0},"end":{"line":4,"column":41}},"5":{"start":{"line":5,"column":0},"end":{"line":5,"column":59}},"6":{"start":{"line":7,"column":0},"end":{"line":7,"column":35}},"7":{"start":{"line":14,"column":4},"end":{"line":17,"column":6}},"8":{"start":{"line":18,"column":4},"end":{"line":20,"column":6}},"9":{"start":{"line":22,"column":4},"end":{"line":22,"column":84}},"10":{"start":{"line":23,"column":4},"end":{"line":23,"column":18}},"11":{"start":{"line":24,"column":4},"end":{"line":28,"column":5}},"12":{"start":{"line":25,"column":6},"end":{"line":25,"column":62}},"13":{"start":{"line":27,"column":6},"end":{"line":27,"column":61}},"14":{"start":{"line":29,"column":4},"end":{"line":29,"column":57}},"15":{"start":{"line":30,"column":4},"end":{"line":30,"column":48}},"16":{"start":{"line":31,"column":4},"end":{"line":31,"column":31}},"17":{"start":{"line":39,"column":4},"end":{"line":39,"column":46}},"18":{"start":{"line":43,"column":0},"end":{"line":43,"column":24}}},"branchMap":{"1":{"line":24,"type":"if","locations":[{"start":{"line":24,"column":4},"end":{"line":24,"column":4}},{"start":{"line":24,"column":4},"end":{"line":24,"column":4}}]}}}}
|
package/coverage/lcov.info
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
TN:
|
|
2
|
-
SF:/Restore/mailer/index.js
|
|
3
|
-
FN:13,(anonymous_1)
|
|
4
|
-
FN:38,(anonymous_2)
|
|
5
|
-
FNF:2
|
|
6
|
-
FNH:2
|
|
7
|
-
FNDA:2,(anonymous_1)
|
|
8
|
-
FNDA:2,(anonymous_2)
|
|
9
|
-
DA:1,1
|
|
10
|
-
DA:2,1
|
|
11
|
-
DA:3,1
|
|
12
|
-
DA:4,1
|
|
13
|
-
DA:5,1
|
|
14
|
-
DA:7,1
|
|
15
|
-
DA:14,2
|
|
16
|
-
DA:18,2
|
|
17
|
-
DA:22,2
|
|
18
|
-
DA:23,2
|
|
19
|
-
DA:24,2
|
|
20
|
-
DA:25,1
|
|
21
|
-
DA:27,1
|
|
22
|
-
DA:29,2
|
|
23
|
-
DA:30,2
|
|
24
|
-
DA:31,2
|
|
25
|
-
DA:39,2
|
|
26
|
-
DA:43,1
|
|
27
|
-
LF:18
|
|
28
|
-
LH:18
|
|
29
|
-
BRDA:24,1,0,1
|
|
30
|
-
BRDA:24,1,1,1
|
|
31
|
-
BRF:2
|
|
32
|
-
BRH:2
|
|
33
|
-
end_of_record
|
package/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const htmlToText = require('nodemailer-html-to-text').htmlToText;
|
|
2
|
-
const nodemailer = require('nodemailer');
|
|
3
|
-
const stubTransport = require('nodemailer-stub-transport');
|
|
4
|
-
|
|
5
|
-
const winston = require('winston');
|
|
6
|
-
|
|
7
|
-
class Mailer {
|
|
8
|
-
/**
|
|
9
|
-
@param {Object} opts nodemailer transport options
|
|
10
|
-
@param {Object} htmlToTextOptions for nodemailer html to text module
|
|
11
|
-
*/
|
|
12
|
-
constructor(opts, htmlToTextOptions) {
|
|
13
|
-
const defaultOpts = {
|
|
14
|
-
logger: winston,
|
|
15
|
-
pool: true
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const htmlToTextOpts = htmlToTextOptions || {};
|
|
19
|
-
|
|
20
|
-
let transport;
|
|
21
|
-
if (process.env.NODE_ENV === 'test') {
|
|
22
|
-
transport = nodemailer.createTransport(stubTransport());
|
|
23
|
-
} else {
|
|
24
|
-
transport = nodemailer.createTransport(opts, defaultOpts);
|
|
25
|
-
}
|
|
26
|
-
transport.use('compile', htmlToText(htmlToTextOpts));
|
|
27
|
-
this.transport = transport;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
@param {Object} mail nodemailer mail
|
|
32
|
-
@returns Promise
|
|
33
|
-
*/
|
|
34
|
-
async send(mail) {
|
|
35
|
-
return this.transport.sendMail(mail);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = Mailer;
|