Repository Public
1import { qs } from './api.ts';2import type { FileItem, PreviewSource } from './types.ts';34/** Preview source for a file of the signed-in owner (optionally one of its versions). */5export function ownerSource(f: Pick<FileItem, 'id' | 'name' | 'size' | 'kind' | 'scan'>, versionId?: string): PreviewSource {6 const base = `/api/v1/files/${f.id}`;7 return {8 id: versionId ? `${f.id}:${versionId}` : f.id, name: f.name, size: f.size, kind: f.kind, canDownload: true,9 contentUrl: (o = {}) => `${base}/content${qs({ v: versionId, download: o.download ? 1 : undefined, as: o.text ? 'text' : undefined, infected: o.download && f.scan === 'infected' ? 'ack' : undefined })}`,10 previewUrl: (kind) => `${base}/preview/${kind}${qs({ v: versionId })}`,11 };12}13