/** * One-off validation, run by hand: checks that `catalog-en-keys.ts` has an * entry for every diet/allergen/ingredient currently in * `reference-seed-data.ts`, and that the resulting English keys are unique * within each table. Not part of the app or the seed itself — just a * pre-flight check while building/editing the dictionary by hand. */ import { ALLERGENS, DIETS, INGREDIENT_GROUPS } from "../src/db/reference-seed-data.js"; import { getEnglishKey } from "../src/db/catalog-en-keys.js"; function check(label: string, names: string[]) { const keys = new Map(); const missing: string[] = []; const duplicates: string[] = []; for (const name of names) { let key: string; try { key = getEnglishKey(name); } catch { missing.push(name); continue; } const existing = keys.get(key); if (existing !== undefined && existing !== name) { duplicates.push(`"${existing}" and "${name}" both map to "${key}"`); } keys.set(key, name); } console.log(`${label}: ${names.length} names, ${keys.size} unique keys`); if (missing.length > 0) { console.log(` MISSING (${missing.length}):`, missing); } if (duplicates.length > 0) { console.log(` DUPLICATES (${duplicates.length}):`, duplicates); } } check("Diets", DIETS); check("Allergens", ALLERGENS.map((a) => a.name)); check( "Ingredients", INGREDIENT_GROUPS.flatMap((g) => g.items.map((i) => i.name)), );