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
+6 -5
View File
@@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends, HTTPException, status, Query
from fastapi import APIRouter, Depends, status, Query
from sqlalchemy.orm import Session
from typing import List, Optional
@@ -9,6 +9,7 @@ from models.user import User
from schemas.customers import CustomerCreate, CustomerUpdate, CustomerOut, AssignCustomerRequest
from core.access.deps import require_any
from routers.deps import require_manager, get_current_user
from core.errors import XeniaError
router = APIRouter()
@@ -81,7 +82,7 @@ def lookup_customer(phone: str = Query(..., max_length=40), db: Session = Depend
def get_customer(customer_id: int, db: Session = Depends(get_db), user: User = Depends(require_manager)):
c = db.query(Customer).filter(Customer.id == customer_id).first()
if not c:
raise HTTPException(status_code=404, detail="Customer not found")
raise XeniaError("customer.not_found")
return _customer_out(c, db)
@@ -89,7 +90,7 @@ def get_customer(customer_id: int, db: Session = Depends(get_db), user: User = D
def update_customer(customer_id: int, body: CustomerUpdate, db: Session = Depends(get_db), user: User = Depends(require_manager)):
c = db.query(Customer).filter(Customer.id == customer_id).first()
if not c:
raise HTTPException(status_code=404, detail="Customer not found")
raise XeniaError("customer.not_found")
for field, value in body.model_dump(exclude_none=True).items():
setattr(c, field, value)
db.commit()
@@ -101,7 +102,7 @@ def update_customer(customer_id: int, body: CustomerUpdate, db: Session = Depend
def delete_customer(customer_id: int, db: Session = Depends(get_db), user: User = Depends(require_manager)):
c = db.query(Customer).filter(Customer.id == customer_id).first()
if not c:
raise HTTPException(status_code=404, detail="Customer not found")
raise XeniaError("customer.not_found")
c.is_active = False
db.commit()
@@ -110,7 +111,7 @@ def delete_customer(customer_id: int, db: Session = Depends(get_db), user: User
def customer_orders(customer_id: int, db: Session = Depends(get_db), user: User = Depends(require_manager)):
c = db.query(Customer).filter(Customer.id == customer_id).first()
if not c:
raise HTTPException(status_code=404, detail="Customer not found")
raise XeniaError("customer.not_found")
from models.table import Table
orders = db.query(Order).filter(Order.customer_id == customer_id).order_by(Order.opened_at.desc()).all()
tables_map = {t.id: (t.label or f"T{t.number}") for t in db.query(Table).all()}