feat: foundations for the manager conversion (platform-v2 step 6.1)

- Backend: every HTTPException in routers/ is an error code now (260 raises, ~105 new codes,
  texts in en + el); XeniaError(detail=...) keeps the three v1-shaped answers old pages read;
  bad / unknown tokens answer auth.session_ended; test_errors refuses new HTTPExceptions.
- Manager: v2.json is the list of pages on the v2 rules: scripts/lint.mjs lints them,
  tests/v2-guards.test.mjs refuses Greek and colour literals, `strict` paths make
  set-state-in-effect an error.
- src/live/useLiveQuery.js (react-query + live events + refresh on reconnect); Signed in now
  uses it.
- Dead manager files removed (3.1k lines unreachable from main.jsx).
- Tests: backend 544 passed, manager unit 33, run-all (no Android) passed (manager's live
  bell check passed on a rerun).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 04:31:36 +02:00
co-authored by Claude Opus 5.5
parent 218a6c9c5e
commit 2dc5da446e
48 changed files with 918 additions and 3498 deletions
+11 -10
View File
@@ -1,5 +1,5 @@
from core.timeutil import utcnow, venue_day_window
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException, status, Query
from fastapi import APIRouter, BackgroundTasks, Depends, status, Query
from sqlalchemy.orm import Session
from typing import List, Optional
from datetime import datetime, timezone
@@ -12,6 +12,7 @@ from schemas.reservation import (
)
from routers.deps import get_current_user, require_manager
from models.user import User
from core.errors import XeniaError
router = APIRouter()
@@ -37,7 +38,7 @@ def create_reservation(
):
if body.table_id:
if not db.query(Table).filter(Table.id == body.table_id, Table.is_active == True).first():
raise HTTPException(status_code=400, detail="Table not found or inactive")
raise XeniaError("table.not_found", status=400)
r = Reservation(
guest_name=body.guest_name,
@@ -71,7 +72,7 @@ def list_reservations(
try:
day = datetime.fromisoformat(date).date()
except ValueError:
raise HTTPException(status_code=400, detail="Invalid date format")
raise XeniaError("validation.datetime", status=400)
# The venue's calendar day, as a UTC window (D-11; 23 h / 25 h on DST days)
start, end = venue_day_window(day)
q = q.filter(Reservation.reserved_for >= start, Reservation.reserved_for < end)
@@ -106,7 +107,7 @@ def get_reservation(
):
r = db.query(Reservation).filter(Reservation.id == reservation_id).first()
if not r:
raise HTTPException(status_code=404, detail="Reservation not found")
raise XeniaError("reservation.not_found", reservation_id=reservation_id)
return _enrich(r)
@@ -119,16 +120,16 @@ def update_reservation(
):
r = db.query(Reservation).filter(Reservation.id == reservation_id).first()
if not r:
raise HTTPException(status_code=404, detail="Reservation not found")
raise XeniaError("reservation.not_found", reservation_id=reservation_id)
updates = body.model_dump(exclude_none=True)
if "table_id" in updates and updates["table_id"] is not None:
if not db.query(Table).filter(Table.id == updates["table_id"], Table.is_active == True).first():
raise HTTPException(status_code=400, detail="Table not found or inactive")
raise XeniaError("table.not_found", status=400)
if "status" in updates and updates["status"] not in VALID_STATUSES:
raise HTTPException(status_code=400, detail=f"Invalid status: {updates['status']}")
raise XeniaError("validation.choice", field='status', value=updates['status'])
for field, value in updates.items():
setattr(r, field, value)
@@ -148,11 +149,11 @@ def update_reservation_status(
user: User = Depends(get_current_user),
):
if body.status not in VALID_STATUSES:
raise HTTPException(status_code=400, detail=f"Invalid status: {body.status}")
raise XeniaError("validation.choice", field='status', value=body.status)
r = db.query(Reservation).filter(Reservation.id == reservation_id).first()
if not r:
raise HTTPException(status_code=404, detail="Reservation not found")
raise XeniaError("reservation.not_found", reservation_id=reservation_id)
if r.online_order_cloud_id and r.status in ("requested", "pending") and body.status in ("arrived", "cancelled", "no_show"):
# an online booking (phase 3S, S.6): the same steps as the counter's, and the customer's page follows
@@ -185,6 +186,6 @@ def delete_reservation(
):
r = db.query(Reservation).filter(Reservation.id == reservation_id).first()
if not r:
raise HTTPException(status_code=404, detail="Reservation not found")
raise XeniaError("reservation.not_found", reservation_id=reservation_id)
db.delete(r)
db.commit()