import type { BookFile } from '../types' export function fetchBookFiles(bookId: number): Promise { return fetch(`/api/books/${bookId}/files`).then(r => r.json()) } export function fetchUnmatchedFiles(): Promise { return fetch('/api/files?unmatched=true').then(r => r.json()) } export function assignFile(id: number, bookId: number | null, editionId: number | null): Promise { return fetch(`/api/files/${id}`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ bookId, editionId }), }).then(r => r.json()) } export function deleteFile(id: number): Promise { return fetch(`/api/files/${id}`, { method: 'DELETE' }).then(() => undefined) } export function triggerScan(): Promise { return fetch('/api/scan', { method: 'POST' }).then(() => undefined) }