Recherche de fiches par nom peu fiable : sans ISBN, les providers étaient interrogés avec des titres bruts peu discriminants. - extraction de hints locaux (titre/auteur/année/isbn du fichier et du nom de fichier) persistés dans books.local_metadata_json - nouveau use-case ScoreMetadataMatch : tri des résultats par score de correspondance avant sélection du meilleur candidat - providers (google-books, open-library, bnf, local) durcis et nourris par les hints ; colonne + index local_metadata_json avec migrations idempotentes (création et rebuild legacy) - web : nettoyage de la description de la fiche livre (cleanBookDescription, white-space pre-line) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
897 B
TypeScript
22 lines
897 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { MetadataProvider } from "./metadata.types.js";
|
|
import { ResolveProviderChain } from "./use-cases/resolve-provider-chain.js";
|
|
|
|
const provider = (id: MetadataProvider["id"]): MetadataProvider => ({
|
|
id,
|
|
lookup: async () => null,
|
|
searchByMetadata: async () => []
|
|
});
|
|
|
|
describe("ResolveProviderChain", () => {
|
|
it("keeps local active and orders enabled remote providers by priority", () => {
|
|
const chain = new ResolveProviderChain([provider("googlebooks"), provider("local"), provider("bnf")]).resolve([
|
|
{ provider: "local", enabled: false, priority: 99, apiKey: null },
|
|
{ provider: "googlebooks", enabled: true, priority: 2, apiKey: null },
|
|
{ provider: "bnf", enabled: true, priority: 1, apiKey: null }
|
|
]);
|
|
|
|
expect(chain.map((entry) => entry.provider.id)).toEqual(["bnf", "googlebooks", "local"]);
|
|
});
|
|
});
|