@8ms/helpers 1.20.0 → 1.22.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,13 +89,12 @@ class SimpleEmail extends BaseClass_1.default {
90
89
  },
91
90
  Source: this.from,
92
91
  };
92
+ const command = new SendEmailCommand(params);
93
93
  try {
94
- const command = new SendEmailCommand(params);
95
- const apiResponse = await global.awsSesClient.send(command);
96
- response = (0, isResponse200_1.default)({ apiResponse });
94
+ response = await global.awsSesClient.send(command);
97
95
  }
98
- catch (error) {
99
- response = false;
96
+ catch (exception) {
97
+ response = exception;
100
98
  }
101
99
  return response;
102
100
  }
@@ -107,7 +105,7 @@ class SimpleEmail extends BaseClass_1.default {
107
105
  response = response.map(recipient => recipient.toLowerCase()
108
106
  .trim());
109
107
  // Remove all empty values
110
- response = response.filter(recipient => '' !== recipient);
108
+ response = response.filter(recipient => "" !== recipient);
111
109
  // Return only unique values
112
110
  response = (0, uniq_1.default)(response);
113
111
  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.22.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"