Comparing version 4.0.7 to 4.0.8
/// <reference types="node" /> | ||
import * as AWSSESv2 from '@aws-sdk/client-sesv2'; | ||
import * as AWSSES 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: AWSSESv2.SESv2Client; | ||
protected ses: AWSSES.SESv2Client; | ||
logger: Logger; | ||
@@ -17,3 +17,3 @@ constructor(options?: { | ||
}); | ||
getTemplate(templateName: string): Promise<AWSSESv2.EmailTemplateContent>; | ||
getTemplate(templateName: string): Promise<AWSSES.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<AWSSESv2.SendEmailCommandOutput>; | ||
sendTemplatedEmail(emailData: TemplatedEmailData, sesParams: SESParams): Promise<AWSSES.SendEmailCommandOutput>; | ||
/** | ||
@@ -33,3 +33,3 @@ * Send an email through AWS Simple Email Service. | ||
*/ | ||
sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSESv2.SendEmailResponse | NodemailerSentMessageInfo>; | ||
sendEmail(emailData: EmailData, sesParams: SESParams): Promise<AWSSES.SendEmailResponse | NodemailerSentMessageInfo>; | ||
private searchForCustomSESConfigByTeamId; | ||
@@ -36,0 +36,0 @@ private sendEmailWithSES; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const client_ses_1 = require("@aws-sdk/client-ses"); | ||
const AWSSESv2 = __importStar(require("@aws-sdk/client-sesv2")); | ||
const AWSSES = __importStar(require("@aws-sdk/client-sesv2")); | ||
const nodemailer_1 = require("nodemailer"); | ||
@@ -39,3 +39,3 @@ const dynamoDB_1 = require("./dynamoDB"); | ||
this.logger = new logger_1.Logger(); | ||
this.ses = new AWSSESv2.SESv2Client({ region: options.region }); | ||
this.ses = new AWSSES.SESv2Client({ region: options.region }); | ||
this.logger.level = options.debug ? 'DEBUG' : 'INFO'; | ||
@@ -47,3 +47,3 @@ } | ||
async getTemplate(templateName) { | ||
const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const { TemplateContent } = await this.ses.send(command); | ||
@@ -55,3 +55,3 @@ return TemplateContent; | ||
try { | ||
const command = new AWSSESv2.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSES.GetEmailTemplateCommand({ TemplateName: templateName }); | ||
await this.ses.send(command); | ||
@@ -72,13 +72,13 @@ } | ||
if (isNew) | ||
command = new AWSSESv2.CreateEmailTemplateCommand(template); | ||
command = new AWSSES.CreateEmailTemplateCommand(template); | ||
else | ||
command = new AWSSESv2.UpdateEmailTemplateCommand(template); | ||
command = new AWSSES.UpdateEmailTemplateCommand(template); | ||
await this.ses.send(command); | ||
} | ||
async deleteTemplate(templateName) { | ||
const command = new AWSSESv2.DeleteEmailTemplateCommand({ TemplateName: templateName }); | ||
const command = new AWSSES.DeleteEmailTemplateCommand({ TemplateName: templateName }); | ||
await this.ses.send(command); | ||
} | ||
async testTemplate(templateName, data) { | ||
const command = new AWSSESv2.TestRenderEmailTemplateCommand({ | ||
const command = new AWSSES.TestRenderEmailTemplateCommand({ | ||
TemplateName: templateName, | ||
@@ -97,3 +97,3 @@ TemplateData: JSON.stringify(data) | ||
async sendTemplatedEmail(emailData, sesParams) { | ||
const command = new AWSSESv2.SendEmailCommand({ | ||
const command = new AWSSES.SendEmailCommand({ | ||
Destination: this.prepareEmailDestination(emailData), | ||
@@ -115,3 +115,3 @@ Content: { | ||
else | ||
ses = new AWSSESv2.SESv2Client({ region: sesParams.region }); | ||
ses = new AWSSES.SESv2Client({ region: sesParams.region }); | ||
this.logger.debug('SES send templated email'); | ||
@@ -145,3 +145,3 @@ return await ses.send(command); | ||
async sendEmailWithSES(emailData, sesParams) { | ||
const command = new AWSSESv2.SendEmailCommand({ | ||
const command = new AWSSES.SendEmailCommand({ | ||
Destination: this.prepareEmailDestination(emailData), | ||
@@ -157,3 +157,3 @@ Content: { Simple: this.prepareEmailMessage(emailData) }, | ||
else | ||
ses = new AWSSESv2.SESv2Client({ region: sesParams.region }); | ||
ses = new AWSSES.SESv2Client({ region: sesParams.region }); | ||
this.logger.debug('SES send email'); | ||
@@ -179,3 +179,3 @@ return await ses.send(command); | ||
// note: Nodemailer doesn't support SESv2 as of August 2023 | ||
const ses = new client_ses_1.SESClient({ region: sesParams.region }); | ||
const ses = new client_ses_1.SES({ region: sesParams.region }); | ||
this.logger.debug('SES send email (Nodemailer)'); | ||
@@ -182,0 +182,0 @@ return await (0, nodemailer_1.createTransport)({ SES: ses }).sendMail(mailOptions); |
{ | ||
"name": "idea-aws", | ||
"version": "4.0.7", | ||
"version": "4.0.8", | ||
"description": "AWS wrappers to use in IDEA's back-ends", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
134055