@8ms/helpers 1.0.19 → 1.0.22

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.
@@ -49,5 +49,6 @@ declare class SimpleEmail extends BaseClass {
49
49
  SesLib: any;
50
50
  client: any;
51
51
  }): Promise<ApiResponseType>;
52
+ private _filterRecipients;
52
53
  }
53
54
  export default SimpleEmail;
@@ -142,22 +142,17 @@ var SimpleEmail = /** @class */ (function (_super) {
142
142
  SimpleEmail.prototype.send = function (_a) {
143
143
  var SesLib = _a.SesLib, client = _a.client;
144
144
  return __awaiter(this, void 0, void 0, function () {
145
- var SendEmailCommand, response, clean, params, command, apiResponse, error_1;
145
+ var SendEmailCommand, response, params, command, apiResponse, error_1;
146
146
  return __generator(this, function (_b) {
147
147
  switch (_b.label) {
148
148
  case 0:
149
149
  SendEmailCommand = SesLib.SendEmailCommand;
150
150
  response = __assign({}, api_1.ApiPlaceholder);
151
- clean = {
152
- bcc: (0, uniq_1.default)(this.bcc.filter(function (value) { return value !== undefined && value !== null; })),
153
- cc: (0, uniq_1.default)(this.cc.filter(function (value) { return value !== undefined && value !== null; })),
154
- to: (0, uniq_1.default)(this.to.filter(function (value) { return value !== undefined && value !== null; })),
155
- };
156
151
  params = {
157
152
  Destination: {
158
- BccAddresses: clean.bcc,
159
- CcAddresses: clean.cc,
160
- ToAddresses: clean.to,
153
+ BccAddresses: this._filterRecipients({ field: 'bcc' }),
154
+ CcAddresses: this._filterRecipients({ field: 'cc' }),
155
+ ToAddresses: this._filterRecipients({ field: 'to' }),
161
156
  },
162
157
  Message: {
163
158
  Body: {
@@ -204,6 +199,19 @@ var SimpleEmail = /** @class */ (function (_super) {
204
199
  });
205
200
  });
206
201
  };
202
+ SimpleEmail.prototype._filterRecipients = function (_a) {
203
+ var field = _a.field;
204
+ // Remove all undefined and null values
205
+ var response = this[field].filter(function (recipient) { return undefined !== recipient && null !== recipient; });
206
+ // Clean all the values
207
+ response = response.map(function (recipient) { return recipient.toLowerCase()
208
+ .trim(); });
209
+ // Remove all empty values
210
+ response = response.filter(function (recipient) { return '' !== recipient; });
211
+ // Return only unique values
212
+ response = (0, uniq_1.default)(response);
213
+ return response;
214
+ };
207
215
  return SimpleEmail;
208
216
  }(Class_1.BaseClass));
209
217
  exports.default = SimpleEmail;
@@ -14,7 +14,7 @@ var getClient = function (_a) {
14
14
  if (!global.awsSesClient) {
15
15
  var SESClient = SesLib.SESClient;
16
16
  var formattedConfig = (0, getConfig_1.default)({ config: config, isAthenaExpress: false });
17
- global.sesClient = new SESClient(formattedConfig);
17
+ global.awsSesClient = new SESClient(formattedConfig);
18
18
  }
19
19
  sesClient = global.awsSesClient;
20
20
  return sesClient;
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
- "version": "1.0.19",
3
+ "version": "1.0.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"
@@ -15,7 +15,7 @@
15
15
  "jest": "jest --watch"
16
16
  },
17
17
  "dependencies": {
18
- "axios": "0.26.0",
18
+ "axios": "0.26.1",
19
19
  "date-fns": "2.28.0",
20
20
  "lodash": "4.17.21"
21
21
  },
@@ -24,12 +24,12 @@
24
24
  "@babel/preset-flow": "7.16.7",
25
25
  "@babel/preset-typescript": "7.16.7",
26
26
  "@types/jest": "27.4.1",
27
- "@types/lodash": "4.14.178",
28
- "@types/node": "17.0.20",
27
+ "@types/lodash": "4.14.180",
28
+ "@types/node": "17.0.21",
29
29
  "babel-jest": "27.5.1",
30
30
  "jest": "27.5.1",
31
- "ts-node": "10.5.0",
31
+ "ts-node": "10.7.0",
32
32
  "tslib": "2.3.1",
33
- "typescript": "4.5.5"
33
+ "typescript": "4.6.2"
34
34
  }
35
35
  }