@vroskus/library-email 1.0.28 → 1.0.30

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/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ declare class EmailService<C extends Config> {
18
18
  #private;
19
19
  from: string;
20
20
  transporter: $Transporter | null;
21
- constructor({ email, from, host, password, port, username, }: C);
21
+ constructor({ debug, email, from, host, password, port, username, }: C);
22
22
  sendMail({ attachments, bcc, content, replyTo, subject, to, }: {
23
23
  attachments?: SendMailOptions['attachments'];
24
24
  bcc?: Array<string> | string;
package/dist/index.js CHANGED
@@ -13,16 +13,23 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
17
+ if (kind === "m") throw new TypeError("Private method is not writable");
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
20
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
+ };
16
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
24
  };
19
- var _EmailService_instances, _EmailService_setupTransporter;
25
+ var _EmailService_instances, _EmailService_debug, _EmailService_setupTransporter;
20
26
  Object.defineProperty(exports, "__esModule", { value: true });
21
27
  const nodemailer_1 = __importDefault(require("nodemailer"));
22
28
  const html_to_text_1 = require("html-to-text");
23
29
  class EmailService {
24
- constructor({ email, from, host, password, port, username, }) {
30
+ constructor({ debug, email, from, host, password, port, username, }) {
25
31
  _EmailService_instances.add(this);
32
+ _EmailService_debug.set(this, void 0);
26
33
  this.from = `"${from}" <${email}>`;
27
34
  this.transporter = null;
28
35
  __classPrivateFieldGet(this, _EmailService_instances, "m", _EmailService_setupTransporter).call(this, {
@@ -31,6 +38,7 @@ class EmailService {
31
38
  port: port || '25',
32
39
  username,
33
40
  });
41
+ __classPrivateFieldSet(this, _EmailService_debug, debug, "f");
34
42
  }
35
43
  sendMail(_a) {
36
44
  return __awaiter(this, arguments, void 0, function* ({ attachments, bcc, content, replyTo, subject, to, }) {
@@ -46,17 +54,19 @@ class EmailService {
46
54
  };
47
55
  if (this.transporter !== null) {
48
56
  const info = yield this.transporter.sendMail(params);
49
- console.log('info', info);
57
+ if (__classPrivateFieldGet(this, _EmailService_debug, "f")) {
58
+ console.info('EmailService:', info);
59
+ }
50
60
  return info.messageId;
51
61
  }
52
62
  throw new Error('Transporter not initialised');
53
63
  });
54
64
  }
55
65
  }
56
- _EmailService_instances = new WeakSet(), _EmailService_setupTransporter = function _EmailService_setupTransporter({ host, password, port, username, }) {
66
+ _EmailService_debug = new WeakMap(), _EmailService_instances = new WeakSet(), _EmailService_setupTransporter = function _EmailService_setupTransporter({ host, password, port, username, }) {
57
67
  this.transporter = {
58
68
  sendMail: (_a) => __awaiter(this, [_a], void 0, function* ({ bcc, html, subject, text, to, }) {
59
- console.log('\x1b[33m', 'EmailService.sendEmail', '\x1b[0m\x1b[90m', to, bcc, subject, JSON.stringify(html), JSON.stringify(text));
69
+ console.info('\x1b[33m', 'EmailService.sendEmail', '\x1b[0m\x1b[90m', to, bcc, subject, JSON.stringify(html), JSON.stringify(text));
60
70
  return {
61
71
  accepted: typeof to === 'string' ? [to] : to,
62
72
  messageId: '0',
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type $Config = {
2
+ debug?: boolean;
2
3
  email: string;
3
4
  from: string;
4
5
  host: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vroskus/library-email",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "Email",
5
5
  "author": "Vilius Roškus <vilius@regattas.eu>",
6
6
  "license": "MIT",