3c: partial consumption + undo for cooking sessions
- Append-only undo via correction transactions tied to cookingSessionId. - POST /v1/cooking-sessions/:id/undo with 24h UTC window (409 + i18n after expiry). - Complete undo scope: meals removed, meal boxes discarded, recipe_cooks deleted, cookCount decremented; activation milestones left intact. - Deterministic assumption-profile rollback via lastSessionAnswers.sessionId; profile deleted when observationCount reaches 0. - New status 'undone' as TEXT validated against COOKING_SESSION_STATUSES. - Analytics event cooking_session_undone + domain events MEAL_BOX_DISCARDED, MEAL_REMOVED, COOKING_SESSION_UNDONE. - Partial consumption uses actualPortionsEaten/plannedPortions factor. - i18n coverage for cooked.undoWindowExpired across all 12 locales + server. - Invariant tests: computeBalance(transactions) === item.quantity after complete, undo, and undo + new complete; transaction count increases on undo. - Migration 0014_expand_event_types.sql adds new enum values. - Updated FAS3-COOKING-SESSIONS-AUDIT.md with chosen semantics.
This commit is contained in:
@@ -42,6 +42,13 @@ export interface EventPayloadMap {
|
||||
WEEK_PLAN_UPDATED: { weekPlanId: string; reason?: string | null };
|
||||
MEAL_BOX_CREATED: { mealBoxId: string; portions: number };
|
||||
MEAL_BOX_CONSUMED: { mealBoxId: string; portions: number };
|
||||
MEAL_BOX_DISCARDED: { mealBoxId: string; portions: number; source: string };
|
||||
MEAL_REMOVED: { mealId: string; recipeId: string; source: string };
|
||||
COOKING_SESSION_UNDONE: {
|
||||
cookingSessionId: string;
|
||||
recipeId: string;
|
||||
reversedTransactions: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** Kontroll i kompileringstid att kartan täcker alla EventType. */
|
||||
|
||||
Reference in New Issue
Block a user