@8ms/helpers 2.1.0 → 2.1.2
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/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../_class";
|
|
2
2
|
import { AwsConfig } from "../server";
|
|
3
|
-
import
|
|
3
|
+
import { SendEmailCommandInput, SendRawEmailCommandInput, SESClient } from "@aws-sdk/client-ses";
|
|
4
4
|
export declare class AwsSesNamespace extends BaseNamespace {
|
|
5
5
|
client: SESClient;
|
|
6
6
|
config: AwsConfig;
|
|
7
7
|
ensureInit: () => Promise<void>;
|
|
8
|
-
send: (input: SendEmailCommandInput) => Promise<any>;
|
|
8
|
+
send: (input: SendEmailCommandInput | SendRawEmailCommandInput) => Promise<any>;
|
|
9
9
|
}
|
|
@@ -51,14 +51,28 @@ class AwsSesNamespace extends _class_1.BaseNamespace {
|
|
|
51
51
|
};
|
|
52
52
|
this.send = async (input) => {
|
|
53
53
|
await this.ensureInit();
|
|
54
|
-
const { SendEmailCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ses")));
|
|
55
54
|
let response;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
// For a simple message
|
|
56
|
+
if (input?.Message?.Body?.Html?.Data) {
|
|
57
|
+
try {
|
|
58
|
+
const { SendEmailCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ses")));
|
|
59
|
+
const command = new SendEmailCommand(input);
|
|
60
|
+
response = await this.client.send(command);
|
|
61
|
+
}
|
|
62
|
+
catch (exception) {
|
|
63
|
+
response = exception;
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
// For a message with attachments
|
|
67
|
+
else {
|
|
68
|
+
try {
|
|
69
|
+
const { SendRawEmailCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ses")));
|
|
70
|
+
const command = new SendRawEmailCommand(input);
|
|
71
|
+
response = await this.client.send(command);
|
|
72
|
+
}
|
|
73
|
+
catch (exception) {
|
|
74
|
+
response = exception;
|
|
75
|
+
}
|
|
62
76
|
}
|
|
63
77
|
return response;
|
|
64
78
|
};
|