import type { AttachmentView } from '@/components/files/Attachments' /** * Formt die Datenbankzeilen für die Oberfläche um. * * Zwei Dinge passieren hier, beide mit Absicht: `thumbKey` wird zu einem * Wahrheitswert — der Pfad auf der Platte geht den Browser nichts an —, und * `createdAt` wird zu einer Zeichenkette, weil ein `Date` die Grenze zur * Client-Komponente nicht sauber überquert. */ export function toAttachmentViews( rows: { id: string originalName: string mimeType: string sizeBytes: number scanStatus: string scanMessage: string | null thumbKey: string | null blurhash: string | null width: number | null height: number | null createdAt: Date }[], ): AttachmentView[] { return rows.map((row) => ({ id: row.id, originalName: row.originalName, mimeType: row.mimeType, sizeBytes: row.sizeBytes, scanStatus: row.scanStatus, scanMessage: row.scanMessage, blurhash: row.blurhash, width: row.width, height: row.height, hasThumb: row.thumbKey !== null, createdAt: row.createdAt.toISOString(), })) }