@8ms/helpers 1.20.0 → 1.21.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.
@@ -1,4 +1,4 @@
1
- import BaseClass from '../../class/BaseClass';
1
+ import BaseClass from "../../class/BaseClass";
2
2
  type Constructor = {
3
3
  bcc?: string[];
4
4
  cc?: string[];
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const uniq_1 = __importDefault(require("lodash/uniq"));
7
7
  const BaseClass_1 = __importDefault(require("../../class/BaseClass"));
8
- const isResponse200_1 = __importDefault(require("../isResponse200"));
9
8
  /**
10
9
  * Class to build and send an AWS SES email.
11
10
  */
@@ -36,41 +35,41 @@ class SimpleEmail extends BaseClass_1.default {
36
35
  return this;
37
36
  }
38
37
  setFrom({ from }) {
39
- return this._setValue({ input: from, fields: 'from' });
38
+ return this._setValue({ input: from, fields: "from" });
40
39
  }
41
40
  setHtml({ html }) {
42
- return this._setValue({ input: html, fields: 'html' });
41
+ return this._setValue({ input: html, fields: "html" });
43
42
  }
44
43
  setSubject({ subject }) {
45
- return this._setValue({ input: subject, fields: 'subject' });
44
+ return this._setValue({ input: subject, fields: "subject" });
46
45
  }
47
46
  pushBcc({ recipient }) {
48
- return this._push({ input: recipient, fields: 'bcc' });
47
+ return this._push({ input: recipient, fields: "bcc" });
49
48
  }
50
49
  pushCc({ recipient }) {
51
- return this._push({ input: recipient, fields: 'cc' });
50
+ return this._push({ input: recipient, fields: "cc" });
52
51
  }
53
52
  pushTo({ recipient }) {
54
- return this._push({ input: recipient, fields: 'to' });
53
+ return this._push({ input: recipient, fields: "to" });
55
54
  }
56
55
  setBcc({ recipient }) {
57
- return this._setArray({ input: recipient, fields: 'bcc' });
56
+ return this._setArray({ input: recipient, fields: "bcc" });
58
57
  }
59
58
  setCc({ recipient }) {
60
- return this._setArray({ input: recipient, fields: 'cc' });
59
+ return this._setArray({ input: recipient, fields: "cc" });
61
60
  }
62
61
  setTo({ recipient }) {
63
- return this._setArray({ input: recipient, fields: 'to' });
62
+ return this._setArray({ input: recipient, fields: "to" });
64
63
  }
65
64
  async send() {
66
- const { SendEmailCommand } = require('@aws-sdk/client-ses');
65
+ const { SendEmailCommand } = require("@aws-sdk/client-ses");
67
66
  let response;
68
67
  // https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ses-examples-sending-email.html
69
68
  const params = {
70
69
  Destination: {
71
- BccAddresses: this._filterRecipients({ field: 'bcc' }),
72
- CcAddresses: this._filterRecipients({ field: 'cc' }),
73
- ToAddresses: this._filterRecipients({ field: 'to' }),
70
+ BccAddresses: this._filterRecipients({ field: "bcc" }),
71
+ CcAddresses: this._filterRecipients({ field: "cc" }),
72
+ ToAddresses: this._filterRecipients({ field: "to" }),
74
73
  },
75
74
  Message: {
76
75
  Body: {
@@ -90,15 +89,9 @@ class SimpleEmail extends BaseClass_1.default {
90
89
  },
91
90
  Source: this.from,
92
91
  };
93
- try {
94
- const command = new SendEmailCommand(params);
95
- const apiResponse = await global.awsSesClient.send(command);
96
- response = (0, isResponse200_1.default)({ apiResponse });
97
- }
98
- catch (error) {
99
- response = false;
100
- }
101
- return response;
92
+ const command = new SendEmailCommand(params);
93
+ const apiResponse = await global.awsSesClient.send(command);
94
+ return apiResponse;
102
95
  }
103
96
  _filterRecipients({ field }) {
104
97
  // Remove all undefined and null values
@@ -107,7 +100,7 @@ class SimpleEmail extends BaseClass_1.default {
107
100
  response = response.map(recipient => recipient.toLowerCase()
108
101
  .trim());
109
102
  // Remove all empty values
110
- response = response.filter(recipient => '' !== recipient);
103
+ response = response.filter(recipient => "" !== recipient);
111
104
  // Return only unique values
112
105
  response = (0, uniq_1.default)(response);
113
106
  return response;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "1.20.0",
4
+ "version": "1.21.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"