import type * as EmailSchema from './schema'; export type EmailAccountSelect = typeof EmailSchema.emailAccounts.$inferSelect; export type EmailAccountInsert = typeof EmailSchema.emailAccounts.$inferInsert; /** What an account's secret actually holds — a password, or an OAuth pair, depending on `authType`. */ export type EmailCredentials = Record; /** * An account as every caller sees it: `credentials` decrypted and parsed. * * The stored row and the used row are different types on purpose. `EmailAccountSelect` has a ciphertext * string in that field, and nothing outside `queries.ts` should be able to hold one by accident. */ export type EmailAccount = Omit & { credentials: EmailCredentials }; export type EmailAccountCreate = Omit & { credentials: EmailCredentials }; export type EmailSummary = { id: string; from: string; to: string; subject: string; date: string; snippet: string; attachmentCount?: number; read?: boolean; fromDomain?: string; labels?: string[]; // Conversation grouping: total messages in the thread, and how many are unread (folder view only). threadCount?: number; threadUnread?: number; }; export type EmailMessage = EmailSummary & { cc?: string; html?: string; text?: string; attachments: Array<{ filename: string; size: number; contentType: string }>; }; // A full conversation: every non-deleted message in the thread, oldest first. export type EmailThread = { id: string; // the representative message id used to open the thread subject: string; messages: EmailMessage[]; };