@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.
Binary file
@@ -1,9 +1,9 @@
1
1
  import { BaseNamespace } from "../../_class";
2
2
  import { AwsConfig } from "../server";
3
- import type { SendEmailCommandInput, SESClient } from "@aws-sdk/client-ses";
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
- const command = new SendEmailCommand(input);
57
- try {
58
- response = await this.client.send(command);
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
- catch (exception) {
61
- response = exception;
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
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@8ms/helpers",
3
3
  "license": "UNLICENSED",
4
- "version": "2.1.0",
4
+ "version": "2.1.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/8millionstories-organisation/8ms-helpers-ts.git"