fix(3b): delad kompletteringsväg för legacy /cook + deterministiska cooking-assumptions

- cookRecipeInputSchema utökas med actualPortionsEaten, leftoverEstimatePortions, leftoverNote
- completeCookingSession-wrapper i apps/api/src/lib/cooking.ts hanterar summavalidering,
  persistens av svar, profiluppdateringar och analytics (started+completed) för båda vägarna
- Legacy POST /v1/recipes/:id/cook använder wrappern med emitStartedEvent
- GET /v1/recipes/:id/cooking-assumptions väljer deterministiskt bland icke-valfria ingredienser
- i18n: nyckel cooked.portionsSumExceedsPlanned i samtliga 12 lokaler + server-i18n
- Nya tester för legacy /cook och cooking-assumptions med valfri första ingrediens

Refs: steg 3b-fix, granskningsrunda 2026-08-07
This commit is contained in:
Sven (AAMOS AI)
2026-08-07 05:13:35 +07:00
parent e46281b9b5
commit bbe7526ef3
18 changed files with 457 additions and 162 deletions
+6 -3
View File
@@ -122,6 +122,12 @@ export const cookRecipeInputSchema = z.object({
.regex(/^\d{4}-\d{2}-\d{2}$/)
.optional(),
mealType: z.enum(MEAL_TYPES).default("dinner"),
/** Antal portioner som faktiskt åts (steg 3c). */
actualPortionsEaten: z.number().int().min(0).max(24).optional(),
/** Uppskattade restportioner efter måltiden (steg 3c). */
leftoverEstimatePortions: z.number().int().min(0).max(24).optional(),
/** Fritextnotering om rester aldrig i analytics. */
leftoverNote: z.string().max(200).optional(),
});
export type CookRecipeInput = z.infer<typeof cookRecipeInputSchema>;
@@ -152,8 +158,5 @@ export const cookingSessionCompleteInputSchema = cookRecipeInputSchema.partial()
)
.default([]),
mealType: z.enum(MEAL_TYPES).optional(),
actualPortionsEaten: z.number().int().min(0).max(24).optional(),
leftoverEstimatePortions: z.number().int().min(0).max(24).optional(),
leftoverNote: z.string().max(200).optional(),
});
export type CookingSessionCompleteInput = z.infer<typeof cookingSessionCompleteInputSchema>;