feat: catalogo+30, varianti, sostituti, reintroduzione Fase 2, free meal Fase 3 (PRD §5.1)
Quattro completamenti del PRD §5.1: catalogo, varianti/sostituti, fase 2,
free meal.
Catalogo ricette 16 → 46
- seed-recipes.ts: +30 ricette italiane keto bilanciate
(8 colazione · 8 pranzo · 6 spuntino · 8 cena)
- seed-ingredients.ts: 33 → 55 ingredienti
(verdura/carne/pesce/latticini/condimenti + categorie nuove `legumi` e
`cereali` per Fase 2)
- seed.ts: ora fa upsert anche degli ingredienti pre-esistenti per
propagare campi nuovi (es. phase2Week)
Varianti + sostituti
- Recipe.variants Json (array { name, description, kcalDelta? })
- RecipeIngredient.substitutes String[]
- /recipes/[id]: nuova sezione "Varianti suggerite" + riga "Sostituzioni:"
sotto ogni ingrediente quando presenti
Reintroduzione progressiva Fase 2
- Ingredient.phase2Week (settimana minima di reintroduzione, NULL=sempre)
- User.phase2StartedAt: settato automaticamente quando si passa a TRANSITION
- @ketopath/shared/planner/phase-progression: currentPhase2Week,
isRecipeAllowedForPhaseWeek, weeksSince
- plan.routes filtra fuori le ricette con ingredienti non ancora reintrodotti
- POST /me/profile/phase per avanzare di fase (idempotente sul timestamp)
- 12 unit test su phase-progression
- Esempi seed: lenticchie phase2Week=3, ceci=4, mela=5, pera=6, quinoa=7
Free Meal pianificato Fase 3
- MealSlot.isFreeMeal Boolean (default false)
- POST /me/meal-plans/slots/:id/free-meal toggle, valido solo in MAINTENANCE
- @ketopath/shared/planner/phase-progression: freeMealKcalAdjustment
(compensazione clamp -200/+50 kcal per pasto sui rimanenti)
- /plan: bottone ☆ in ogni SlotCard quando phase=MAINTENANCE; lo slot
marcato come pasto libero rende "Pasto libero pianificato" + ~750 kcal
stimate; macro tracker ne tiene conto
Indicatori di fase nel piano
- /plan ora include currentPhase + phase2Week dalla API
- Header del piano: "Settimana N di Fase 2" o "Mantenimento — Fase 3"
i18n: namespaces Plan + Recipe arricchiti
Schema migration 20260429XXXXXX_add_meal_plan_extras.
66/66 unit test verdi (12 nuovi). Smoke verificato live: API ritorna
correctly i campi nuovi, UI rende badge fase, bottoni ☆/↻, free-meal slot.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2c11b73703
commit
bda96a3550
15 files changed
+1288
-44
No files matched your search
@@ -86,6 +86,9 @@ model User {
|
||||
// PRD §14.3 — consenso esplicito al disclaimer medico. NULL finché l'utente
|
||||
// non lo accetta; bloccante per le pagine di profilo/tracking.
|
||||
disclaimerAcceptedAt DateTime? @map("disclaimer_accepted_at")
|
||||
// PRD §5.1 — momento in cui l'utente è entrato nella fase 2 (TRANSITION).
|
||||
// Serve a calcolare la "settimana di fase" per la reintroduzione progressiva.
|
||||
phase2StartedAt DateTime? @map("phase2_started_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@ -282,6 +285,9 @@ model Ingredient {
|
||||
netCarbPer100g Float @map("net_carb_per_100g")
|
||||
exclusionGroups String[] @default([]) @map("exclusion_groups")
|
||||
priceAvgEur Float? @map("price_avg_eur")
|
||||
// PRD §5.1 — settimana di Fase 2 dalla quale l'ingrediente diventa
|
||||
// disponibile (1=da subito, 5=quinta settimana, ecc.). NULL = sempre.
|
||||
phase2Week Int? @map("phase2_week")
|
||||
|
||||
recipeIngredients RecipeIngredient[]
|
||||
|
||||
@@ -304,6 +310,9 @@ model Recipe {
|
||||
phases Int[] @default([1, 2, 3])
|
||||
servings Int @default(1)
|
||||
notesChef String? @map("notes_chef")
|
||||
// PRD §5.1 — varianti della ricetta (es. "versione vegetariana"). Array
|
||||
// JSON di { name, description, kcalDelta? }. Schema applicativo zod-validato.
|
||||
variants Json @default("[]")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@ -316,11 +325,14 @@ model Recipe {
|
||||
}
|
||||
|
||||
model RecipeIngredient {
|
||||
id String @id @default(cuid())
|
||||
recipeId String @map("recipe_id")
|
||||
ingredientId String @map("ingredient_id")
|
||||
id String @id @default(cuid())
|
||||
recipeId String @map("recipe_id")
|
||||
ingredientId String @map("ingredient_id")
|
||||
quantity Float
|
||||
unit String
|
||||
// PRD §5.1 — suggerimenti di sostituzione per quell'ingrediente in questa
|
||||
// ricetta. Stringhe libere ("ricotta intera", "tofu strapazzato"…).
|
||||
substitutes String[] @default([])
|
||||
|
||||
recipe Recipe @relation(fields: [recipeId], references: [id], onDelete: Cascade)
|
||||
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
|
||||
@@ -372,12 +384,16 @@ model DeviceToken {
|
||||
}
|
||||
|
||||
model MealSlot {
|
||||
id String @id @default(cuid())
|
||||
planId String @map("plan_id")
|
||||
dayOfWeek Int @map("day_of_week")
|
||||
meal MealCategory
|
||||
recipeId String? @map("recipe_id")
|
||||
status String @default("pending")
|
||||
id String @id @default(cuid())
|
||||
planId String @map("plan_id")
|
||||
dayOfWeek Int @map("day_of_week")
|
||||
meal MealCategory
|
||||
recipeId String? @map("recipe_id")
|
||||
status String @default("pending")
|
||||
// PRD §5.1 — "pasto libero" pianificato in Fase 3. Quando true, lo slot
|
||||
// è un placeholder (no ricetta KetoPath, kcal stimate ~750) e il piano
|
||||
// adatta gli altri pasti della settimana.
|
||||
isFreeMeal Boolean @default(false) @map("is_free_meal")
|
||||
|
||||
plan MealPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
selected Recipe? @relation("SelectedRecipe", fields: [recipeId], references: [id])
|
||||
|
||||
Reference in new issue
Block a user