changemaker.lite/api/dist/services/email.service.d.ts

86 lines
2.7 KiB
TypeScript

interface SendEmailOptions {
to: string;
subject: string;
replyTo?: string;
html: string;
text: string;
}
interface SendEmailResult {
success: boolean;
messageId?: string;
testMode: boolean;
}
interface SendCampaignEmailOptions {
recipientEmail: string;
recipientName?: string;
recipientLevel?: string;
userEmail: string;
userName: string;
postalCode: string;
subject: string;
message: string;
campaignTitle: string;
}
declare class EmailService {
private transporter;
constructor();
private createTransporter;
/** Rebuild transporter from DB settings (with env fallback). Call after SMTP settings change. */
rebuildTransporter(): Promise<void>;
testConnection(): Promise<boolean>;
/**
* Load template from database (with caching)
*/
private loadTemplateFromDatabase;
/**
* Load template - checks database first, falls back to filesystem
* @param name Template key (e.g., "campaign-email")
* @param type File type (html or txt) - only used for filesystem fallback
*/
loadTemplate(name: string, type: 'html' | 'txt'): string;
/**
* Clear database template cache
* @param key Optional specific template key to clear. If not provided, clears all.
*/
clearDatabaseCache(key?: string): void;
escapeHtml(unsafe: string): string;
/**
* Fetch video metadata from Media API
*/
private getVideoMetadata;
processTemplate(template: string, vars: Record<string, string>, variableDefinitions?: Array<{
key: string;
type: string;
videoId?: number;
}>): Promise<string>;
/**
* Process text template (for plain text emails)
*/
processTextTemplate(template: string, vars: Record<string, string>, variableDefinitions?: Array<{
key: string;
type: string;
videoId?: number;
}>): Promise<string>;
/**
* Process subject line template
* Same as processTemplate but without HTML escaping
*/
processSubject(subject: string, vars: Record<string, string>): string;
private getFromField;
private getOrganizationName;
private getEmailTestConfig;
sendEmail(options: SendEmailOptions): Promise<SendEmailResult>;
sendCampaignEmail(options: SendCampaignEmailOptions): Promise<SendEmailResult>;
sendResponseVerification(options: {
recipientEmail: string;
campaignTitle: string;
responseType: string;
responseText: string;
submitterName: string;
verificationUrl: string;
reportUrl: string;
}): Promise<SendEmailResult>;
}
export declare const emailService: EmailService;
export {};
//# sourceMappingURL=email.service.d.ts.map