@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.
- package/aws/ses/SimpleEmail.d.ts +1 -1
- package/aws/ses/SimpleEmail.js +17 -24
- package/package.json +1 -1
package/aws/ses/SimpleEmail.d.ts
CHANGED
package/aws/ses/SimpleEmail.js
CHANGED
|
@@ -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:
|
|
38
|
+
return this._setValue({ input: from, fields: "from" });
|
|
40
39
|
}
|
|
41
40
|
setHtml({ html }) {
|
|
42
|
-
return this._setValue({ input: html, fields:
|
|
41
|
+
return this._setValue({ input: html, fields: "html" });
|
|
43
42
|
}
|
|
44
43
|
setSubject({ subject }) {
|
|
45
|
-
return this._setValue({ input: subject, fields:
|
|
44
|
+
return this._setValue({ input: subject, fields: "subject" });
|
|
46
45
|
}
|
|
47
46
|
pushBcc({ recipient }) {
|
|
48
|
-
return this._push({ input: recipient, fields:
|
|
47
|
+
return this._push({ input: recipient, fields: "bcc" });
|
|
49
48
|
}
|
|
50
49
|
pushCc({ recipient }) {
|
|
51
|
-
return this._push({ input: recipient, fields:
|
|
50
|
+
return this._push({ input: recipient, fields: "cc" });
|
|
52
51
|
}
|
|
53
52
|
pushTo({ recipient }) {
|
|
54
|
-
return this._push({ input: recipient, fields:
|
|
53
|
+
return this._push({ input: recipient, fields: "to" });
|
|
55
54
|
}
|
|
56
55
|
setBcc({ recipient }) {
|
|
57
|
-
return this._setArray({ input: recipient, fields:
|
|
56
|
+
return this._setArray({ input: recipient, fields: "bcc" });
|
|
58
57
|
}
|
|
59
58
|
setCc({ recipient }) {
|
|
60
|
-
return this._setArray({ input: recipient, fields:
|
|
59
|
+
return this._setArray({ input: recipient, fields: "cc" });
|
|
61
60
|
}
|
|
62
61
|
setTo({ recipient }) {
|
|
63
|
-
return this._setArray({ input: recipient, fields:
|
|
62
|
+
return this._setArray({ input: recipient, fields: "to" });
|
|
64
63
|
}
|
|
65
64
|
async send() {
|
|
66
|
-
const { SendEmailCommand } = require(
|
|
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:
|
|
72
|
-
CcAddresses: this._filterRecipients({ field:
|
|
73
|
-
ToAddresses: this._filterRecipients({ field:
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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 =>
|
|
103
|
+
response = response.filter(recipient => "" !== recipient);
|
|
111
104
|
// Return only unique values
|
|
112
105
|
response = (0, uniq_1.default)(response);
|
|
113
106
|
return response;
|