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
+15 -15
View File
@@ -40,7 +40,7 @@ from core.access.queries import holders_filter
from core.errors import XeniaError
from core.timeutil import utcnow
import json
from fastapi import APIRouter, Depends, HTTPException, Query, Request
from fastapi import APIRouter, Depends, Query, Request
from datetime import datetime, timezone
from sqlalchemy.orm import Session, joinedload
from pydantic import BaseModel
@@ -367,11 +367,11 @@ def update_order_kds_status(
kitchen screen with a prep zone only that zone's items change (3.2c), and the order's
status then follows all its items."""
if body.status not in VALID_KDS_STATUSES:
raise HTTPException(status_code=400, detail=f"Invalid status '{body.status}'")
raise XeniaError("validation.choice", field='status', value=body.status)
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
zone_id = _device_zone_id(request, db)
if body.status != order.kds_status and zone_id is None:
@@ -410,14 +410,14 @@ def update_item_kds_status(
user: User = Depends(get_current_user),
):
if body.status not in VALID_KDS_STATUSES:
raise HTTPException(status_code=400, detail=f"Invalid status '{body.status}'")
raise XeniaError("validation.choice", field='status', value=body.status)
item = db.query(OrderItem).filter(
OrderItem.id == item_id,
OrderItem.order_id == order_id,
).first()
if not item:
raise HTTPException(status_code=404, detail="Item not found")
raise XeniaError("order.item_not_found")
item.kds_status = body.status
@@ -451,11 +451,11 @@ def update_order_type(
user: User = Depends(get_current_user),
):
if body.order_type not in VALID_ORDER_TYPES:
raise HTTPException(status_code=400, detail=f"Invalid order_type '{body.order_type}'")
raise XeniaError("validation.choice", field='order_type', value=body.order_type)
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
order.order_type = body.order_type
db.commit()
@@ -477,7 +477,7 @@ def mark_items_served(
"""Mark a list of items as served (kds_status=served). Works on active and paid items."""
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
updated = []
ids_set = set(body.item_ids)
@@ -507,7 +507,7 @@ def mark_all_items_served(
"""Mark all non-pending items in an order as served."""
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
updated = []
for item in order.items:
@@ -591,7 +591,7 @@ def decline_order(
"""Mark all active items on an order as declined."""
order = db.query(Order).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
zone_id = _device_zone_id(request, db) # a zone screen declines only its own items (3.2c)
for item in order.items:
@@ -628,7 +628,7 @@ def decline_item(
OrderItem.order_id == order_id,
).first()
if not item:
raise HTTPException(status_code=404, detail="Item not found")
raise XeniaError("order.item_not_found")
item.kds_status = "declined"
item.decline_note = body.decline_note
@@ -717,7 +717,7 @@ def kds_notify_order_complete(
joinedload(Order.waiters),
).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
waiter_ids = _waiter_ids_for_order(order)
if not waiter_ids:
@@ -758,7 +758,7 @@ def kds_notify_items_ready(
joinedload(Order.waiters),
).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
waiter_ids = _waiter_ids_for_order(order)
if not waiter_ids:
@@ -793,7 +793,7 @@ def kds_call_waiter_order(
joinedload(Order.waiters),
).filter(Order.id == order_id).first()
if not order:
raise HTTPException(status_code=404, detail="Order not found")
raise XeniaError("order.not_found", order_id=order_id)
waiter_ids = _waiter_ids_for_order(order)
if not waiter_ids:
@@ -824,7 +824,7 @@ def kds_call_waiter_general(
):
"""Call one or more on-shift waiters to the prep zone."""
if not body.waiter_ids:
raise HTTPException(status_code=400, detail="waiter_ids must not be empty")
raise XeniaError("validation.missing", field='waiter_ids')
zone = _sender(request, db, body.kds_zone)
msg_body = f"Κλήση από {zone}"