Build browsable norm table with inline composition

This commit is contained in:
anor
2026-12-04 15:46:19 +10:00
parent 30955ccfc9
commit 6520ce9357
7 changed files with 403 additions and 39 deletions
+29 -1
View File
@@ -555,7 +555,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-12-04e"
APP_VERSION = "2026-12-04f"
# Audit: path → action name mapping
_AUDIT_MAP = [
@@ -2452,6 +2452,34 @@ async def public_norm_finder_catalog(request: Request):
return {"bases": await asyncio.to_thread(norm_finder.catalog)}
@app.get("/api/public/norm-finder/browse")
async def public_norm_finder_browse(request: Request, base: str = "2022", base_type: str = "ГЭСН",
path: str = "", limit: int = 20, offset: int = 0):
_check_public_finder_rate(request)
if limit > 20:
raise HTTPException(400, "Публичный каталог показывает до 20 норм за запрос")
import norm_finder
try:
return await asyncio.to_thread(norm_finder.browse, base, base_type, path, limit, offset)
except ValueError as exc:
raise HTTPException(400, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(503, str(exc)) from exc
@app.get("/api/norm-finder/browse")
async def norm_finder_browse(request: Request, base: str = "2022", base_type: str = "ГЭСН",
path: str = "", limit: int = 40, offset: int = 0):
_get_user(request)
import norm_finder
try:
return await asyncio.to_thread(norm_finder.browse, base, base_type, path, limit, offset)
except ValueError as exc:
raise HTTPException(400, str(exc)) from exc
except RuntimeError as exc:
raise HTTPException(503, str(exc)) from exc
@app.get("/api/public/norm-finder/search")
async def public_norm_finder_search(request: Request, q: str = "", base: str = "2022", limit: int = 8,
offset: int = 0):