import type { File } from "@prisma/client"; /** * TASK-0101 — the FileRecord wire shape (docs/api/files.md §File object). * The raw object `key` is NEVER part of the record (spec §Security): only * signed URLs leave the server. */ export interface FileRecord { id: string; workspaceId: string; blockId: string | null; pageId: string | null; name: string; size: number; mimeType: string; status: string; metadata: Record; thumbnailKey: string | null; thumbnailUrl: string | null; scanReport: Record | null; uploadedBy: string; version: number; createdAt: string; updatedAt: string; } export function toFileRecord(file: File, version: number): FileRecord { return { id: file.id, workspaceId: file.workspaceId, blockId: file.blockId, pageId: file.pageId, name: file.name, size: file.size, mimeType: file.mimeType, status: file.status, metadata: (file.metadata as Record) ?? {}, thumbnailKey: file.thumbnailKey, thumbnailUrl: file.thumbnailUrl, scanReport: (file.scanReport as Record | null) ?? null, uploadedBy: file.uploadedBy, version, createdAt: file.createdAt.toISOString(), updatedAt: file.updatedAt.toISOString(), }; }