11/// <reference types="node" />
22
3- import * as aws from "@aws-sdk/client-sesv2" ;
43import { EventEmitter } from "node:events" ;
54
65import { Transport , TransportOptions } from "../.." ;
@@ -12,25 +11,66 @@ import MailMessage = require("../mailer/mail-message");
1211import MimeNode = require( "../mime-node" ) ;
1312
1413declare namespace SESTransport {
14+ /**
15+ * Minimal structural shape of SESv2 SendEmail input.
16+ * This is intentionally structural so @types/nodemailer does not require
17+ * installing @aws-sdk/client-sesv2.
18+ *
19+ * If you want the full, exact type, install @aws-sdk/client-sesv2 in your
20+ * app and use its types directly in your own code.
21+ */
22+ interface SendEmailRequestLike {
23+ FromEmailAddress ?: string ;
24+ Destination ?: {
25+ ToAddresses ?: string [ ] ;
26+ CcAddresses ?: string [ ] ;
27+ BccAddresses ?: string [ ] ;
28+ } ;
29+ ReplyToAddresses ?: string [ ] ;
30+ Content ?: unknown ;
31+ EmailTags ?: Array < { Name ?: string ; Value ?: string } > ;
32+ ConfigurationSetName ?: string ;
33+ ListManagementOptions ?: unknown ;
34+ FeedbackForwardingEmailAddress ?: string ;
35+ // Allow extra fields without forcing the SDK type package
36+ [ key : string ] : unknown ;
37+ }
38+
39+ /** Structural type matching SESv2Client from @aws-sdk/client-sesv2 */
40+ interface SESv2ClientLike {
41+ send ( command : unknown , options ?: unknown ) : Promise < { MessageId ?: string } > ;
42+ config ?: {
43+ region ?: string | ( ( ) => Promise < string > ) ;
44+ } ;
45+ }
46+
47+ /**
48+ * Constructor type for SendEmailCommand from @aws-sdk/client-sesv2.
49+ * The real type is: new(input: SendEmailCommandInput) => SendEmailCommand
50+ * Contravariance prevents typing this more strictly without pulling in aws-sdk as a dependency.
51+ */
52+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53+ type SendEmailCommandConstructorLike = new ( input : any ) => unknown ;
54+
1555 interface MailOptions extends Mail . Options {
16- /** list of keys that SendRawEmail method can take */
56+ /** Options passed to AWS SESv2 SendEmailCommand */
1757 ses ?: MailSesOptions | undefined ;
1858 }
1959
2060 // Keep it as an interface for backward-compatibility
2161 // eslint-disable-next-line @typescript-eslint/no-empty-interface
22- interface MailSesOptions extends Partial < aws . SendEmailRequest > { }
62+ interface MailSesOptions extends Partial < SendEmailRequestLike > { }
2363
2464 interface Options extends MailOptions , TransportOptions {
25- /** is an option that expects an instantiated aws.SES object */
65+ /** An object containing an instantiated SESv2Client and the SendEmailCommand class */
2666 SES : {
27- sesClient : aws . SESv2Client ;
28- SendEmailCommand : typeof aws . SendEmailCommand ;
67+ sesClient : SESv2ClientLike ;
68+ SendEmailCommand : SendEmailCommandConstructorLike ;
2969 } ;
3070 }
3171
3272 interface SentMessageInfo {
33- /** an envelope object {from:‘ address’ , to:[‘ address’ ]} */
73+ /** an envelope object {from:' address' , to:[' address' ]} */
3474 envelope : MimeNode . Envelope ;
3575 /** the Message-ID header value. This value is derived from the response of SES API, so it differs from the Message-ID values used in logging. */
3676 messageId : string ;
0 commit comments