type ThumbnailDoc = { id: string; thumbnailKey?: string; thumbnailGeneratedAt?: string; }; /** * Builds the URL for a document thumbnail image, or returns null when the document * has no thumbnail yet. When `thumbnailGeneratedAt` is present it is appended as a * `?v=…` query param so the browser / proxy cache is invalidated whenever the file * is replaced (the backend regenerates thumbnails at the same S3 key on replace). */ export function thumbnailUrl(doc: ThumbnailDoc): string | null { if (!doc.thumbnailKey) return null; const base = `/api/documents/${doc.id}/thumbnail`; if (!doc.thumbnailGeneratedAt) return base; return `${base}?v=${encodeURIComponent(doc.thumbnailGeneratedAt)}`; }