UNPKG

@454creative/easy-email

Version:

A framework-agnostic email service library for Node.js with observability and monitoring

128 lines (127 loc) 2.9 kB
/** * Email DTOs (Data Transfer Objects) * * Common email data structures for the easy-email library */ /** * Base email DTO with common email properties */ export declare class BaseEmailDto { /** * Email address of the recipient * @example 'recipient@example.com' */ to: string; /** * Subject line of the email * @example 'Important Notification' */ subject: string; /** * Email address of the sender (optional) * @example 'sender@example.com' */ from?: string; /** * CC recipients (optional) * @example ['cc1@example.com', 'cc2@example.com'] */ cc?: string[]; /** * BCC recipients (optional) * @example ['bcc1@example.com', 'bcc2@example.com'] */ bcc?: string[]; /** * Reply-to email address (optional) * @example 'reply@example.com' */ replyTo?: string; } /** * DTO for plain text emails */ export declare class TextEmailDto extends BaseEmailDto { /** * Text content of the email * @example 'This is the body of the email message.' */ text: string; } /** * DTO for HTML emails */ export declare class HtmlEmailDto extends BaseEmailDto { /** * HTML content of the email * @example '<h1>Hello</h1><p>This is an HTML email.</p>' */ html: string; /** * Plain text alternative (optional) * @example 'This is the plain text version' */ text?: string; } /** * DTO for templated emails */ export declare class TemplatedEmailDto extends BaseEmailDto { /** * Email template name or content * @example 'welcome-template' */ template: string; /** * Template context variables * @example { name: 'John', company: 'Acme Corp' } */ context?: Record<string, any>; /** * Template format - 'html' or 'text' * @example 'html' */ format?: 'html' | 'text'; } /** * DTO for email with attachments */ export declare class EmailWithAttachmentsDto extends BaseEmailDto { /** * Email content (HTML or text) */ content: string; /** * Content type - 'html' or 'text' * @example 'html' */ contentType: 'html' | 'text'; /** * Email attachments */ attachments?: Array<{ filename: string; content: Buffer | string; contentType?: string; contentDisposition?: string; }>; } /** * DTO for bulk email sending */ export declare class BulkEmailDto { /** * Array of email DTOs to send */ emails: Array<TextEmailDto | HtmlEmailDto | TemplatedEmailDto | EmailWithAttachmentsDto>; /** * Delay between emails in milliseconds (optional) * @example 1000 */ delayBetweenEmails?: number; /** * Maximum number of emails to send in parallel (optional) * @example 5 */ maxConcurrent?: number; }