@restorecommerce/mailer 0.1.14 → 0.1.18

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 CHANGED
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.1.18](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.17...@restorecommerce/mailer@0.1.18) (2022-02-15)
7
+
8
+ **Note:** Version bump only for package @restorecommerce/mailer
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.17](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.16...@restorecommerce/mailer@0.1.17) (2022-02-14)
15
+
16
+ **Note:** Version bump only for package @restorecommerce/mailer
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.1.16](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.15...@restorecommerce/mailer@0.1.16) (2022-02-14)
23
+
24
+ **Note:** Version bump only for package @restorecommerce/mailer
25
+
26
+
27
+
28
+
29
+
30
+ ## [0.1.15](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.14...@restorecommerce/mailer@0.1.15) (2021-08-23)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **version:** up version to be in sync in package-lock ([b8f22c1](https://github.com/restorecommerce/libs/commit/b8f22c1268ee2af4beff7d88bda30f197896e3d2))
36
+
37
+
38
+
39
+
40
+
6
41
  ## [0.1.14](https://github.com/restorecommerce/libs/compare/@restorecommerce/mailer@0.1.13...@restorecommerce/mailer@0.1.14) (2021-08-03)
7
42
 
8
43
 
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) Invend GmbH and other contributors.
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,9 +1,10 @@
1
1
  {
2
2
  "name": "@restorecommerce/mailer",
3
- "version": "0.1.14",
3
+ "version": "0.1.18",
4
4
  "description": "Multi transport mailer based on nodemailer",
5
- "main": "index",
6
- "author": "Invend GmbH",
5
+ "main": "./lib/index.js",
6
+ "typings": "./lib/index.d.ts",
7
+ "author": "n-fuse GmbH",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "https://github.com/restorecommerce/libs.git"
@@ -14,32 +15,46 @@
14
15
  "commerce"
15
16
  ],
16
17
  "dependencies": {
17
- "nodemailer": "^6.6.0",
18
+ "nodemailer": "^6.7.2",
18
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.3.3"
23
+ "winston": "^3.5.1"
23
24
  },
24
25
  "devDependencies": {
25
- "@restorecommerce/eslint-config-restorecommerce": "^0.1.5",
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.0",
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": "^8.4.0",
40
+ "mocha": "^9.2.0",
41
+ "npm-run-all": "^4.1.5",
31
42
  "nyc": "^15.1.0",
32
- "should": "^13.2.1"
43
+ "should": "^13.2.3",
44
+ "typescript": "^4.5.5"
33
45
  },
34
46
  "scripts": {
35
- "test": "nyc mocha",
36
- "lint": "eslint *.json *.js",
37
- "mocha": "mocha ./test/*",
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",
38
53
  "lcov-report": "nyc report --reporter=lcov",
39
- "coveralls": "nyc report --reporter=text-lcov | coveralls"
54
+ "coveralls": "nyc --reporter text --reporter lcov npm test"
40
55
  },
41
56
  "engines": {
42
57
  "node": ">= 10.0.0"
43
58
  },
44
- "gitHead": "d4ac2692c0d2552b209cd49a73afc754ccf6cdf3"
59
+ "gitHead": "a3e82fe9170e6bd988d722af28d212e0ec87d8b4"
45
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/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;