feat: add metadata refresh job to re-download metadata for linked series

Adds a new job type that refreshes metadata from external providers for
all series already linked via approved external_metadata_links. Tracks
and displays per-field diffs (series and book level), respects locked
fields, and provides a detailed change report in the job detail page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 09:09:10 +01:00
parent 818bd82e0f
commit 163dc3698c
17 changed files with 1170 additions and 56 deletions

View File

@@ -803,6 +803,49 @@ export async function startMetadataBatch(libraryId: string) {
});
}
export async function startMetadataRefresh(libraryId: string) {
return apiFetch<{ id: string; status: string }>("/metadata/refresh", {
method: "POST",
body: JSON.stringify({ library_id: libraryId }),
});
}
export type RefreshFieldDiff = {
field: string;
old?: unknown;
new?: unknown;
};
export type RefreshBookDiff = {
book_id: string;
title: string;
volume: number | null;
changes: RefreshFieldDiff[];
};
export type RefreshSeriesResult = {
series_name: string;
provider: string;
status: string; // "updated" | "unchanged" | "error"
series_changes: RefreshFieldDiff[];
book_changes: RefreshBookDiff[];
error?: string;
};
export type MetadataRefreshReportDto = {
job_id: string;
status: string;
total_links: number;
refreshed: number;
unchanged: number;
errors: number;
changes: RefreshSeriesResult[];
};
export async function getMetadataRefreshReport(jobId: string) {
return apiFetch<MetadataRefreshReportDto>(`/metadata/refresh/${jobId}/report`);
}
export async function getMetadataBatchReport(jobId: string) {
return apiFetch<MetadataBatchReportDto>(`/metadata/batch/${jobId}/report`);
}