IMAP and Gmail sync into a per-account SQLite store, with the mail read and composed in the browser. moved whole from src/servers/sidecar/email (14 files), src/servers/api/email, officer_db/src/email, and the Screens/Dashboard/Email tree. what changed on the way out: - credentials are encrypted. the column was plaintext jsonb holding an IMAP app password that the SMTP transport read straight out of the row; it is now AES-256-GCM under this plugin's own 'email' secret-store purpose, sealed and opened in queries.ts alone so nothing above it can hold ciphertext by accident. no plaintext fallback on read - a value that does not verify is an error. - the router derives its prefix from mountPrefix() instead of the literal '/api/email', which was only correct for a first-party publisher. - the frontend became panels.ts + layout.ts. the two panel appTypes that were null are now declared, because the platform screen used to override them by panel id and a plugin has no such hook. - account management became a modal. it was a section in the platform's Settings, which a plugin cannot contribute to, and a panel does not work either: PluginScreen renders the workspace locked, so a panel outside the default layout is unreachable. it follows Compose, which had already solved this. - 17 palette classes replaced with semantic tokens. not verified: this has never run. it was switched off in the platform on 2026-08-13 and its table was never created, so nothing has exercised sync, sending or the UI since. the first install is the first test.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
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<string, unknown>;
|
|
|
|
/**
|
|
* 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<EmailAccountSelect, 'credentials'> & { credentials: EmailCredentials };
|
|
export type EmailAccountCreate = Omit<EmailAccountInsert, 'credentials'> & { 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[];
|
|
};
|