idea-aws 4.0.6 → 4.0.7

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/dist/src/ses.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import * as AWSSES from '@aws-sdk/client-sesv2';
2
+ import * as AWSSESv2 from '@aws-sdk/client-sesv2';
3
3
  import { SentMessageInfo as NodemailerSentMessageInfo } from 'nodemailer';
4
4
  import { Headers } from 'nodemailer/lib/mailer';
5
5
  import { Logger } from './logger';
@@ -7,13 +7,13 @@ import { Logger } from './logger';
7
7
  * A wrapper for AWS Simple Email Service.
8
8
  */
9
9
  export declare class SES {
10
- protected ses: AWSSES.SESv2Client;
10
+ protected ses: AWSSESv2.SESv2Client;
11
11
  logger: Logger;
12
12
  constructor(options?: {
13
13
  region?: string;
14
14
  debug: boolean;
15
15
  });
16
- getTemplate(templateName: string): Promise<AWSSES.EmailTemplateContent>;
16
+ getTemplate(templateName: string): Promise<AWSSESv2.EmailTemplateContent>;
17
17
  setTemplate(templateName: string, subject: string, content: string, isHTML?: boolean): Promise<void>;
18
18
  deleteTemplate(templateName: string): Promise<void>;
19
19
  testTemplate(templateName: string, data: {
@@ -22,12 +22,12 @@ export declare class SES {
22
22
  /**
23
23
  * Send a templated email through AWS Simple Email Service.
24
24
  */
25
- sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSES.SendEmailCommandOutput>;
25
+ sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSESv2.SendEmailCommandOutput>;
26
26
  /**
27
27
  * Send an email through AWS Simple Email Service.
28
28
  * It supports IDEA's teams custom configuration.
29
29
  */
30
- sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSES.SendEmailResponse | NodemailerSentMessageInfo>;
30
+ sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSESv2.SendEmailResponse | NodemailerSentMessageInfo>;
31
31
  private searchForCustomSESConfigByTeamId;
32
32
  private sendEmailWithSES;
33
33
  private sendEmailWithNodemailer;
package/dist/src/ses.js CHANGED
@@ -24,7 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.SES = void 0;
27
- const AWSSES = __importStar(require("@aws-sdk/client-sesv2"));
27
+ const client_ses_1 = require("@aws-sdk/client-ses");
28
+ const AWSSESv2 = __importStar(require("@aws-sdk/client-sesv2"));
28
29
  const nodemailer_1 = require("nodemailer");
29
30
  const dynamoDB_1 = require("./dynamoDB");
30
31
  const logger_1 = require("./logger");
@@ -34,21 +35,21 @@ const logger_1 = require("./logger");
34
35
  class SES {
35
36
  constructor(options = { debug: true }) {
36
37
  this.logger = new logger_1.Logger();
37
- this.ses = new AWSSES.SESv2Client({ region: options.region });
38
+ this.ses = new AWSSESv2.SESv2Client({ region: options.region });
38
39
  this.logger.level = options.debug ? 'DEBUG' : 'INFO';
39
40
  }
40
41
  //
41
42
  // CONFIG
42
43
  //
43
44
  async getTemplate(templateName) {
44
- const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
45
+ const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName });
45
46
  const { TemplateContent } = await this.ses.send(command);
46
47
  return TemplateContent;
47
48
  }
48
49
  async setTemplate(templateName, subject, content, isHTML) {
49
50
  let isNew = false;
50
51
  try {
51
- const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName });
52
+ const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName });
52
53
  await this.ses.send(command);
53
54
  }
54
55
  catch (notFound) {
@@ -64,17 +65,17 @@ class SES {
64
65
  template.TemplateContent.Text = content;
65
66
  let command;
66
67
  if (isNew)
67
- command = new AWSSES.CreateEmailTemplateCommand(template);
68
+ command = new AWSSESv2.CreateEmailTemplateCommand(template);
68
69
  else
69
- command = new AWSSES.UpdateEmailTemplateCommand(template);
70
+ command = new AWSSESv2.UpdateEmailTemplateCommand(template);
70
71
  await this.ses.send(command);
71
72
  }
72
73
  async deleteTemplate(templateName) {
73
- const command = new AWSSES.DeleteEmailTemplateCommand({ TemplateName: templateName });
74
+ const command = new AWSSESv2.DeleteEmailTemplateCommand({ TemplateName: templateName });
74
75
  await this.ses.send(command);
75
76
  }
76
77
  async testTemplate(templateName, data) {
77
- const command = new AWSSES.TestRenderEmailTemplateCommand({
78
+ const command = new AWSSESv2.TestRenderEmailTemplateCommand({
78
79
  TemplateName: templateName,
79
80
  TemplateData: JSON.stringify(data)
80
81
  });
@@ -88,7 +89,7 @@ class SES {
88
89
  * Send a templated email through AWS Simple Email Service.
89
90
  */
90
91
  async sendTemplatedEmail(emailData, sesParams) {
91
- const command = new AWSSES.SendEmailCommand({
92
+ const command = new AWSSESv2.SendEmailCommand({
92
93
  Destination: this.prepareEmailDestination(emailData),
93
94
  Content: {
94
95
  Template: {
@@ -105,7 +106,7 @@ class SES {
105
106
  if (this.ses.config.region === sesParams.region)
106
107
  ses = this.ses;
107
108
  else
108
- ses = new AWSSES.SESv2Client({ region: sesParams.region });
109
+ ses = new AWSSESv2.SESv2Client({ region: sesParams.region });
109
110
  this.logger.debug('SES send templated email');
110
111
  return await ses.send(command);
111
112
  }
@@ -134,7 +135,7 @@ class SES {
134
135
  }
135
136
  }
136
137
  async sendEmailWithSES(emailData, sesParams) {
137
- const command = new AWSSES.SendEmailCommand({
138
+ const command = new AWSSESv2.SendEmailCommand({
138
139
  Destination: this.prepareEmailDestination(emailData),
139
140
  Content: { Simple: this.prepareEmailMessage(emailData) },
140
141
  ReplyToAddresses: emailData.replyToAddresses,
@@ -145,7 +146,7 @@ class SES {
145
146
  if (this.ses.config.region === sesParams.region)
146
147
  ses = this.ses;
147
148
  else
148
- ses = new AWSSES.SESv2Client({ region: sesParams.region });
149
+ ses = new AWSSESv2.SESv2Client({ region: sesParams.region });
149
150
  this.logger.debug('SES send email');
150
151
  return await ses.send(command);
151
152
  }
@@ -165,11 +166,8 @@ class SES {
165
166
  if (emailData.text)
166
167
  mailOptions.text = emailData.text;
167
168
  mailOptions.attachments = emailData.attachments;
168
- let ses;
169
- if (this.ses.config.region === sesParams.region)
170
- ses = this.ses;
171
- else
172
- ses = new AWSSES.SESv2Client({ region: sesParams.region });
169
+ // note: Nodemailer doesn't support SESv2 as of August 2023
170
+ const ses = new client_ses_1.SESClient({ region: sesParams.region });
173
171
  this.logger.debug('SES send email (Nodemailer)');
174
172
  return await (0, nodemailer_1.createTransport)({ SES: ses }).sendMail(mailOptions);
175
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "AWS wrappers to use in IDEA's back-ends",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -52,6 +52,7 @@
52
52
  "@aws-sdk/client-lambda": "^3.388.0",
53
53
  "@aws-sdk/client-s3": "^3.388.0",
54
54
  "@aws-sdk/client-secrets-manager": "^3.389.0",
55
+ "@aws-sdk/client-ses": "^3.398.0",
55
56
  "@aws-sdk/client-sesv2": "^3.388.0",
56
57
  "@aws-sdk/client-sns": "^3.388.0",
57
58
  "@aws-sdk/client-translate": "^3.388.0",