Menu
Public repository / 0216cf0f6008aae88a648a82e9b3a462a6688302
AkurAI-Mail / src/framework/reader.js
Latest change 0216cf0f6008aae88a648a82e9b3a462a6688302 - OLI-248: reader view-model on framework ESM (wave 3 slice), tests red-first by Ólafur Búi Ólafsson
// Message reader view-model on plain ESM (AkurAI-Framework island logic, no build step).
/** @type {Record<string, string>} */
const SIGNAL_LABELS = { replyNeeded: "Reply needed", followUpDue: "Follow-up due", priority: "Priority", deadlineDetected: "Deadline detected" };
/** @type {Record<string, string>} */
const PROVENANCE_LABELS = { deterministic: "Computed", model: "Model", "user-corrected": "Your correction" };
const DISPLAY_SIGNAL_TYPES = ["replyNeeded", "followUpDue", "priority", "deadlineDetected"];
const BYTES_PER_KB = 1024;
/** @param {string} type */
export const signalTypeLabel = (type) => SIGNAL_LABELS[type] ?? type;
/** @param {string} provenance */
export const provenanceLabel = (provenance) => PROVENANCE_LABELS[provenance] ?? provenance;
/** @param {Record<string, any>|undefined} convSignal @returns {[string, any][]} */
export const displaySignals = (convSignal) => (convSignal ? Object.entries(convSignal).filter(([key]) => DISPLAY_SIGNAL_TYPES.includes(key)) : []);
/** @param {{name: string}[]|undefined} folders */
export const moveTargets = (folders) => (folders ?? []).filter((folder) => folder.name !== "Trash");
/** @param {number} bytes */
export const attachmentSizeLabel = (bytes) => `${Math.ceil(bytes / BYTES_PER_KB)} KB`;