Neah/types/email.ts
2025-04-30 21:42:42 +02:00

78 lines
1.6 KiB
TypeScript

/**
* Standardized Email Interfaces
*
* This file contains the core interfaces for email data structures
* used throughout the application. All components should use these
* interfaces for consistency.
*/
export interface EmailAddress {
name: string;
address: string;
}
export interface EmailAttachment {
filename: string;
contentType: string;
content?: string;
size?: number;
contentId?: string;
}
export interface EmailContent {
text: string;
html?: string;
isHtml: boolean;
direction: 'ltr' | 'rtl';
}
export interface EmailFlags {
seen: boolean;
flagged: boolean;
answered: boolean;
deleted: boolean;
draft: boolean;
}
export interface EmailMessage {
id: string;
subject: string;
from: string;
to: string;
cc?: string;
bcc?: string;
date: string;
flags: string[];
content: EmailContent;
attachments?: Array<{
filename: string;
contentType: string;
encoding?: string;
content?: string;
}>;
// For debugging and transition
_originalFormat?: any;
}
// This represents the legacy email format that might come from API
export interface LegacyEmailMessage {
id: string;
subject: string;
from: string;
to: string;
cc?: string;
bcc?: string;
date: string;
flags?: string[] | Record<string, boolean>;
content?: string | EmailContent;
html?: string; // Some APIs provide HTML directly
text?: string; // Some APIs provide text directly
plainText?: string; // Alternative to text
formattedContent?: string; // Legacy property
attachments?: Array<{
filename?: string;
name?: string;
contentType?: string;
content?: string;
}>;
}