fix(metadata): persist auto-fetch library overrides

Ensure the settings UI saves inherit toggles immediately and guards eligible-count previews against stale async responses. Align library override DTO validation with the shared partial override contract, and record manual library runs even when nothing queues.
This commit is contained in:
neon
2026-06-23 04:48:30 +00:00
parent 303f7f2d6a
commit 484ad0b9be
15 changed files with 1027 additions and 36 deletions
+13 -2
View File
@@ -26,11 +26,21 @@ export interface BookMetadataFetchConfig {
conditions: BookMetadataFetchConditions;
}
export interface BookMetadataFetchConditionsOverride {
scoreThreshold?: Partial<BookMetadataFetchScoreCondition>;
missingFields?: Partial<BookMetadataFetchMissingFieldsCondition>;
neverFetched?: Partial<BookMetadataFetchNeverFetchedCondition>;
}
// Stored per-library. null = inherit everything from global.
// Deep-merged by getEffectiveConfig: top-level keys first, then each conditions key individually.
export type BookMetadataFetchConfigOverride = Partial<BookMetadataFetchConfig> | null;
export type BookMetadataFetchConfigOverride =
| (Partial<Omit<BookMetadataFetchConfig, "conditions">> & {
conditions?: BookMetadataFetchConditionsOverride;
})
| null;
// 'done' is not a queue status — rows are deleted on success to prevent unbounded growth.
// 'done' is not a queue status - rows are deleted on success to prevent unbounded growth.
export type BookMetadataFetchQueueStatus = "queued" | "processing" | "failed";
export type BookMetadataFetchReason = "event_import" | "manual_trigger" | "manual_retry";
@@ -53,6 +63,7 @@ export interface BookMetadataFetchStatusEvent extends BookMetadataFetchStatus {
// Library-level config response: effective config merged with per-library run history.
export interface BookMetadataFetchLibraryConfig extends BookMetadataFetchConfig {
override: BookMetadataFetchConfigOverride;
lastRunAt: string | null;
lastQueuedCount: number | null;
}