Comparing version 4.0.6 to 4.0.7
/// <reference types="node" /> | ||
import * as AWSSES from '@aws-sdk/client-sesv2'; | ||
import * as AWSSESv2 from '@aws-sdk/client-sesv2'; | ||
import { SentMessageInfo as NodemailerSentMessageInfo } from 'nodemailer'; | ||
@@ -10,3 +10,3 @@ import { Headers } from 'nodemailer/lib/mailer'; | ||
export declare class SES { | ||
protected ses: AWSSES.SESv2Client; | ||
protected ses: AWSSESv2.SESv2Client; | ||
logger: Logger; | ||
@@ -17,3 +17,3 @@ constructor(options?: { | ||
}); | ||
getTemplate(templateName: string): Promise<AWSSES.EmailTemplateContent>; | ||
getTemplate(templateName: string): Promise<AWSSESv2.EmailTemplateContent>; | ||
setTemplate(templateName: string, subject: string, content: string, isHTML?: boolean): Promise<void>; | ||
@@ -27,3 +27,3 @@ deleteTemplate(templateName: string): Promise<void>; | ||
*/ | ||
sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSES.SendEmailCommandOutput>; | ||
sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSESv2.SendEmailCommandOutput>; | ||
/** | ||
@@ -33,3 +33,3 @@ * Send an email through AWS Simple Email Service. | ||
*/ | ||
sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSES.SendEmailResponse | NodemailerSentMessageInfo>; | ||
sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSESv2.SendEmailResponse | NodemailerSentMessageInfo>; | ||
private searchForCustomSESConfigByTeamId; | ||
@@ -36,0 +36,0 @@ private sendEmailWithSES; |
@@ -27,3 +27,4 @@ "use strict"; | ||
exports.SES = void 0; | ||
const AWSSES = __importStar(require("@aws-sdk/client-sesv2")); | ||
const client_ses_1 = require("@aws-sdk/client-ses"); | ||
const AWSSESv2 = __importStar(require("@aws-sdk/client-sesv2")); | ||
const nodemailer_1 = require("nodemailer"); | ||
@@ -38,3 +39,3 @@ const dynamoDB_1 = require("./dynamoDB"); | ||
this.logger = new logger_1.Logger(); | ||
this.ses = new AWSSES.SESv2Client({ region: options.region }); | ||
this.ses = new AWSSESv2.SESv2Client({ region: options.region }); | ||
this.logger.level = options.debug ? 'DEBUG' : 'INFO'; | ||
@@ -46,3 +47,3 @@ } | ||
async getTemplate(templateName) { | ||
const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const { TemplateContent } = await this.ses.send(command); | ||
@@ -54,3 +55,3 @@ return TemplateContent; | ||
try { | ||
const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
await this.ses.send(command); | ||
@@ -71,13 +72,13 @@ } | ||
if (isNew) | ||
command = new AWSSES.CreateEmailTemplateCommand(template); | ||
command = new AWSSESv2.CreateEmailTemplateCommand(template); | ||
else | ||
command = new AWSSES.UpdateEmailTemplateCommand(template); | ||
command = new AWSSESv2.UpdateEmailTemplateCommand(template); | ||
await this.ses.send(command); | ||
} | ||
async deleteTemplate(templateName) { | ||
const command = new AWSSES.DeleteEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSESv2.DeleteEmailTemplateCommand({ TemplateName: templateName }); | ||
await this.ses.send(command); | ||
} | ||
async testTemplate(templateName, data) { | ||
const command = new AWSSES.TestRenderEmailTemplateCommand({ | ||
const command = new AWSSESv2.TestRenderEmailTemplateCommand({ | ||
TemplateName: templateName, | ||
@@ -96,3 +97,3 @@ TemplateData: JSON.stringify(data) | ||
async sendTemplatedEmail(emailData, sesParams) { | ||
const command = new AWSSES.SendEmailCommand({ | ||
const command = new AWSSESv2.SendEmailCommand({ | ||
Destination: this.prepareEmailDestination(emailData), | ||
@@ -114,3 +115,3 @@ Content: { | ||
else | ||
ses = new AWSSES.SESv2Client({ region: sesParams.region }); | ||
ses = new AWSSESv2.SESv2Client({ region: sesParams.region }); | ||
this.logger.debug('SES send templated email'); | ||
@@ -144,3 +145,3 @@ return await ses.send(command); | ||
async sendEmailWithSES(emailData, sesParams) { | ||
const command = new AWSSES.SendEmailCommand({ | ||
const command = new AWSSESv2.SendEmailCommand({ | ||
Destination: this.prepareEmailDestination(emailData), | ||
@@ -156,3 +157,3 @@ Content: { Simple: this.prepareEmailMessage(emailData) }, | ||
else | ||
ses = new AWSSES.SESv2Client({ region: sesParams.region }); | ||
ses = new AWSSESv2.SESv2Client({ region: sesParams.region }); | ||
this.logger.debug('SES send email'); | ||
@@ -177,7 +178,4 @@ return await ses.send(command); | ||
mailOptions.attachments = emailData.attachments; | ||
let ses; | ||
if (this.ses.config.region === sesParams.region) | ||
ses = this.ses; | ||
else | ||
ses = new AWSSES.SESv2Client({ region: sesParams.region }); | ||
// note: Nodemailer doesn't support SESv2 as of August 2023 | ||
const ses = new client_ses_1.SESClient({ region: sesParams.region }); | ||
this.logger.debug('SES send email (Nodemailer)'); | ||
@@ -184,0 +182,0 @@ return await (0, nodemailer_1.createTransport)({ SES: ses }).sendMail(mailOptions); |
{ | ||
"name": "idea-aws", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"description": "AWS wrappers to use in IDEA's back-ends", | ||
@@ -55,2 +55,3 @@ "main": "dist/index.js", | ||
"@aws-sdk/client-secrets-manager": "^3.389.0", | ||
"@aws-sdk/client-ses": "^3.398.0", | ||
"@aws-sdk/client-sesv2": "^3.388.0", | ||
@@ -57,0 +58,0 @@ "@aws-sdk/client-sns": "^3.388.0", |
134095
26
3409