import type { AllergyView, DietView } from "@batch-cooking/shared"; import { prisma } from "../../db/prisma.js"; /** All reference dietary regimes, alphabetically — small, static list (see prisma/seed.ts). */ export async function getDiets(): Promise { return prisma.diet.findMany({ orderBy: { name: "asc" } }); } /** * All reference allergens, alphabetically. `Allergy` carries no `name` of * its own — it's the selectable instance of a named `Category` (see * schema.prisma) — so this resolves each allergen's display name from its * category and flattens the split away for callers. */ export async function getAllergies(): Promise { const allergies = await prisma.allergy.findMany({ include: { category: { select: { name: true, kind: true } } }, orderBy: { category: { name: "asc" } }, }); return allergies.map((allergy) => ({ id: allergy.id, name: allergy.category.name, kind: allergy.category.kind, })); }