import { Payload } from 'payload' import type { CollectionConfig, RichTextField } from 'payload' import { Transporter } from 'nodemailer' export interface EmailObject { to: string | string[] cc?: string | string[] bcc?: string | string[] from?: string replyTo?: string subject: string html: string text?: string variables?: Record } export type EmailWrapperHook = (email: EmailObject) => EmailObject | Promise export interface MailingPluginConfig { collections?: { templates?: string | Partial emails?: string | Partial } defaultFrom?: string transport?: Transporter | MailingTransportConfig queue?: string retryAttempts?: number retryDelay?: number emailWrapper?: EmailWrapperHook richTextEditor?: RichTextField['editor'] onReady?: (payload: any) => Promise initOrder?: 'before' | 'after' } export interface MailingTransportConfig { host: string port: number secure?: boolean auth?: { user: string pass: string } } export interface EmailTemplate { id: string name: string slug: string subject: string content: any // Lexical editor state createdAt: string updatedAt: string } export interface QueuedEmail { id: string template?: string to: string[] cc?: string[] bcc?: string[] from?: string replyTo?: string subject: string html: string text?: string variables?: Record scheduledAt?: string sentAt?: string status: 'pending' | 'processing' | 'sent' | 'failed' attempts: number lastAttemptAt?: string error?: string priority?: number createdAt: string updatedAt: string } export interface SendEmailOptions { templateSlug?: string to: string | string[] cc?: string | string[] bcc?: string | string[] from?: string replyTo?: string subject?: string html?: string text?: string variables?: Record scheduledAt?: Date priority?: number } export interface MailingService { sendEmail(options: SendEmailOptions): Promise scheduleEmail(options: SendEmailOptions): Promise processEmails(): Promise retryFailedEmails(): Promise } export interface MailingContext { payload: Payload config: MailingPluginConfig service: MailingService }