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:
lucianoandClaude Opus 4.7 committed 2026-04-29 23:18:47 +02:00
1 parent 2c11b73703
commit bda96a3550
15 files changed
+1288 -44

No files matched your search

+260 -1
View File
@@ -15,7 +15,9 @@ export interface SeedIngredient {
| 'panetteria'
| 'frutta-secca'
| 'erbe'
| 'salumi';
| 'salumi'
| 'legumi'
| 'cereali';
defaultUnit: 'g' | 'ml' | 'pz' | 'cucchiaio' | 'cucchiaino';
kcalPer100g: number;
proteinPer100g: number;
@@ -23,6 +25,8 @@ export interface SeedIngredient {
netCarbPer100g: number;
exclusionGroups: string[];
priceAvgEur?: number;
// PRD §5.1 — settimana di Fase 2 dalla quale è disponibile (1+).
phase2Week?: number;
}
export const SEED_INGREDIENTS: SeedIngredient[] = [
@@ -398,4 +402,259 @@ export const SEED_INGREDIENTS: SeedIngredient[] = [
exclusionGroups: [],
priceAvgEur: 5.0,
},
// VERDURA — extra
{
name: 'Broccoli',
category: 'verdura',
defaultUnit: 'g',
kcalPer100g: 34,
proteinPer100g: 2.8,
fatPer100g: 0.4,
netCarbPer100g: 4.0,
exclusionGroups: [],
priceAvgEur: 2.0,
},
{
name: 'Funghi champignon',
category: 'verdura',
defaultUnit: 'g',
kcalPer100g: 22,
proteinPer100g: 3.1,
fatPer100g: 0.3,
netCarbPer100g: 2.3,
exclusionGroups: [],
priceAvgEur: 4.5,
},
{
name: 'Spinaci surgelati',
category: 'verdura',
defaultUnit: 'g',
kcalPer100g: 23,
proteinPer100g: 3.0,
fatPer100g: 0.4,
netCarbPer100g: 1.5,
exclusionGroups: [],
priceAvgEur: 1.5,
},
{
name: 'Melanzane',
category: 'verdura',
defaultUnit: 'g',
kcalPer100g: 25,
proteinPer100g: 1.0,
fatPer100g: 0.2,
netCarbPer100g: 3.0,
exclusionGroups: [],
priceAvgEur: 2.0,
},
{
name: 'Peperoni',
category: 'verdura',
defaultUnit: 'g',
kcalPer100g: 31,
proteinPer100g: 1.0,
fatPer100g: 0.3,
netCarbPer100g: 4.6,
exclusionGroups: [],
priceAvgEur: 2.8,
},
// CARNE & PESCE — extra
{
name: 'Petto di tacchino',
category: 'carne',
defaultUnit: 'g',
kcalPer100g: 135,
proteinPer100g: 30,
fatPer100g: 1.0,
netCarbPer100g: 0,
exclusionGroups: [],
priceAvgEur: 12.0,
},
{
name: 'Gamberi',
category: 'pesce',
defaultUnit: 'g',
kcalPer100g: 99,
proteinPer100g: 24,
fatPer100g: 0.3,
netCarbPer100g: 0.2,
exclusionGroups: ['fish'],
priceAvgEur: 18.0,
},
{
name: 'Sgombro',
category: 'pesce',
defaultUnit: 'g',
kcalPer100g: 205,
proteinPer100g: 19,
fatPer100g: 14,
netCarbPer100g: 0,
exclusionGroups: ['fish'],
priceAvgEur: 12.0,
},
{
name: 'Prosciutto crudo',
category: 'salumi',
defaultUnit: 'g',
kcalPer100g: 270,
proteinPer100g: 27,
fatPer100g: 18,
netCarbPer100g: 0,
exclusionGroups: ['pork'],
priceAvgEur: 32.0,
},
{
name: 'Bresaola',
category: 'salumi',
defaultUnit: 'g',
kcalPer100g: 151,
proteinPer100g: 33,
fatPer100g: 2.0,
netCarbPer100g: 0,
exclusionGroups: ['beef'],
priceAvgEur: 38.0,
},
// LATTICINI — extra
{
name: 'Mozzarella di bufala',
category: 'latticini',
defaultUnit: 'g',
kcalPer100g: 288,
proteinPer100g: 17,
fatPer100g: 24,
netCarbPer100g: 0.4,
exclusionGroups: ['lactose'],
priceAvgEur: 14.0,
},
{
name: 'Stracchino',
category: 'latticini',
defaultUnit: 'g',
kcalPer100g: 298,
proteinPer100g: 18,
fatPer100g: 25,
netCarbPer100g: 1.0,
exclusionGroups: ['lactose'],
priceAvgEur: 12.0,
},
{
name: 'Mascarpone',
category: 'latticini',
defaultUnit: 'g',
kcalPer100g: 429,
proteinPer100g: 4.8,
fatPer100g: 44,
netCarbPer100g: 4.8,
exclusionGroups: ['lactose'],
priceAvgEur: 8.0,
},
// CONDIMENTI / SEMI — extra
{
name: 'Aceto balsamico',
category: 'condimenti',
defaultUnit: 'cucchiaio',
kcalPer100g: 88,
proteinPer100g: 0.5,
fatPer100g: 0,
netCarbPer100g: 17,
exclusionGroups: [],
priceAvgEur: 8.0,
},
{
name: 'Semi di chia',
category: 'frutta-secca',
defaultUnit: 'g',
kcalPer100g: 486,
proteinPer100g: 17,
fatPer100g: 31,
netCarbPer100g: 1.4,
exclusionGroups: [],
priceAvgEur: 18.0,
},
{
name: 'Cocco rapè non zuccherato',
category: 'frutta-secca',
defaultUnit: 'g',
kcalPer100g: 660,
proteinPer100g: 7,
fatPer100g: 64,
netCarbPer100g: 7,
exclusionGroups: [],
priceAvgEur: 10.0,
},
// FRUTTA — phase2-introduced
{
name: 'Frutti di bosco misti',
category: 'frutta',
defaultUnit: 'g',
kcalPer100g: 47,
proteinPer100g: 0.9,
fatPer100g: 0.3,
netCarbPer100g: 7,
exclusionGroups: [],
priceAvgEur: 8.0,
phase2Week: 1, // disponibile da subito anche in fase 2 (low-carb)
},
{
name: 'Mela',
category: 'frutta',
defaultUnit: 'pz',
kcalPer100g: 52,
proteinPer100g: 0.3,
fatPer100g: 0.2,
netCarbPer100g: 11,
exclusionGroups: [],
priceAvgEur: 2.5,
phase2Week: 5, // si reintroduce dalla 5ª settimana di fase 2
},
{
name: 'Pera',
category: 'frutta',
defaultUnit: 'pz',
kcalPer100g: 57,
proteinPer100g: 0.4,
fatPer100g: 0.1,
netCarbPer100g: 12,
exclusionGroups: [],
priceAvgEur: 2.8,
phase2Week: 6,
},
// LEGUMI — phase2-introduced
{
name: 'Lenticchie cotte',
category: 'legumi',
defaultUnit: 'g',
kcalPer100g: 116,
proteinPer100g: 9,
fatPer100g: 0.4,
netCarbPer100g: 12,
exclusionGroups: [],
priceAvgEur: 2.5,
phase2Week: 3,
},
{
name: 'Ceci cotti',
category: 'legumi',
defaultUnit: 'g',
kcalPer100g: 164,
proteinPer100g: 9,
fatPer100g: 2.6,
netCarbPer100g: 17,
exclusionGroups: [],
priceAvgEur: 2.5,
phase2Week: 4,
},
// CEREALI — phase2-introduced (avanzato)
{
name: 'Quinoa cotta',
category: 'cereali',
defaultUnit: 'g',
kcalPer100g: 120,
proteinPer100g: 4.4,
fatPer100g: 1.9,
netCarbPer100g: 18,
exclusionGroups: [],
priceAvgEur: 6.0,
phase2Week: 7,
},
];