truthound-dashboard 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. truthound_dashboard/__init__.py +11 -0
  2. truthound_dashboard/__main__.py +6 -0
  3. truthound_dashboard/api/__init__.py +15 -0
  4. truthound_dashboard/api/deps.py +153 -0
  5. truthound_dashboard/api/drift.py +179 -0
  6. truthound_dashboard/api/error_handlers.py +287 -0
  7. truthound_dashboard/api/health.py +78 -0
  8. truthound_dashboard/api/history.py +62 -0
  9. truthound_dashboard/api/middleware.py +626 -0
  10. truthound_dashboard/api/notifications.py +561 -0
  11. truthound_dashboard/api/profile.py +52 -0
  12. truthound_dashboard/api/router.py +83 -0
  13. truthound_dashboard/api/rules.py +277 -0
  14. truthound_dashboard/api/schedules.py +329 -0
  15. truthound_dashboard/api/schemas.py +136 -0
  16. truthound_dashboard/api/sources.py +229 -0
  17. truthound_dashboard/api/validations.py +125 -0
  18. truthound_dashboard/cli.py +226 -0
  19. truthound_dashboard/config.py +132 -0
  20. truthound_dashboard/core/__init__.py +264 -0
  21. truthound_dashboard/core/base.py +185 -0
  22. truthound_dashboard/core/cache.py +479 -0
  23. truthound_dashboard/core/connections.py +331 -0
  24. truthound_dashboard/core/encryption.py +409 -0
  25. truthound_dashboard/core/exceptions.py +627 -0
  26. truthound_dashboard/core/logging.py +488 -0
  27. truthound_dashboard/core/maintenance.py +542 -0
  28. truthound_dashboard/core/notifications/__init__.py +56 -0
  29. truthound_dashboard/core/notifications/base.py +390 -0
  30. truthound_dashboard/core/notifications/channels.py +557 -0
  31. truthound_dashboard/core/notifications/dispatcher.py +453 -0
  32. truthound_dashboard/core/notifications/events.py +155 -0
  33. truthound_dashboard/core/notifications/service.py +744 -0
  34. truthound_dashboard/core/sampling.py +626 -0
  35. truthound_dashboard/core/scheduler.py +311 -0
  36. truthound_dashboard/core/services.py +1531 -0
  37. truthound_dashboard/core/truthound_adapter.py +659 -0
  38. truthound_dashboard/db/__init__.py +67 -0
  39. truthound_dashboard/db/base.py +108 -0
  40. truthound_dashboard/db/database.py +196 -0
  41. truthound_dashboard/db/models.py +732 -0
  42. truthound_dashboard/db/repository.py +237 -0
  43. truthound_dashboard/main.py +309 -0
  44. truthound_dashboard/schemas/__init__.py +150 -0
  45. truthound_dashboard/schemas/base.py +96 -0
  46. truthound_dashboard/schemas/drift.py +118 -0
  47. truthound_dashboard/schemas/history.py +74 -0
  48. truthound_dashboard/schemas/profile.py +91 -0
  49. truthound_dashboard/schemas/rule.py +199 -0
  50. truthound_dashboard/schemas/schedule.py +88 -0
  51. truthound_dashboard/schemas/schema.py +121 -0
  52. truthound_dashboard/schemas/source.py +138 -0
  53. truthound_dashboard/schemas/validation.py +192 -0
  54. truthound_dashboard/static/assets/index-BqJMyAHX.js +110 -0
  55. truthound_dashboard/static/assets/index-DMDxHCTs.js +465 -0
  56. truthound_dashboard/static/assets/index-Dm2D11TK.css +1 -0
  57. truthound_dashboard/static/index.html +15 -0
  58. truthound_dashboard/static/mockServiceWorker.js +349 -0
  59. truthound_dashboard-1.0.0.dist-info/METADATA +218 -0
  60. truthound_dashboard-1.0.0.dist-info/RECORD +62 -0
  61. truthound_dashboard-1.0.0.dist-info/WHEEL +4 -0
  62. truthound_dashboard-1.0.0.dist-info/entry_points.txt +5 -0
@@ -0,0 +1,78 @@
1
+ """Health check endpoint.
2
+
3
+ This module provides health and readiness endpoints for
4
+ monitoring and orchestration systems.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from datetime import datetime
10
+ from typing import Any
11
+
12
+ from fastapi import APIRouter
13
+
14
+ from truthound_dashboard import __version__
15
+ from truthound_dashboard.schemas import BaseSchema
16
+
17
+ router = APIRouter()
18
+
19
+
20
+ class HealthResponse(BaseSchema):
21
+ """Health check response schema."""
22
+
23
+ status: str
24
+ version: str
25
+ timestamp: str
26
+ checks: dict[str, Any] | None = None
27
+
28
+
29
+ @router.get(
30
+ "/health",
31
+ response_model=HealthResponse,
32
+ summary="Health check",
33
+ description="Check if the server is healthy and responding",
34
+ )
35
+ async def health_check() -> HealthResponse:
36
+ """Check server health.
37
+
38
+ Returns basic health information including version and timestamp.
39
+ """
40
+ return HealthResponse(
41
+ status="ok",
42
+ version=__version__,
43
+ timestamp=datetime.utcnow().isoformat(),
44
+ )
45
+
46
+
47
+ @router.get(
48
+ "/ready",
49
+ response_model=HealthResponse,
50
+ summary="Readiness check",
51
+ description="Check if the server is ready to accept requests",
52
+ )
53
+ async def readiness_check() -> HealthResponse:
54
+ """Check server readiness.
55
+
56
+ Performs deeper health checks including database connectivity.
57
+ """
58
+ checks: dict[str, Any] = {}
59
+
60
+ # Check database
61
+ try:
62
+ from truthound_dashboard.db import get_session
63
+
64
+ async with get_session() as session:
65
+ await session.execute("SELECT 1")
66
+ checks["database"] = {"status": "ok"}
67
+ except Exception as e:
68
+ checks["database"] = {"status": "error", "message": str(e)}
69
+
70
+ # Determine overall status
71
+ all_ok = all(c.get("status") == "ok" for c in checks.values())
72
+
73
+ return HealthResponse(
74
+ status="ok" if all_ok else "degraded",
75
+ version=__version__,
76
+ timestamp=datetime.utcnow().isoformat(),
77
+ checks=checks,
78
+ )
@@ -0,0 +1,62 @@
1
+ """Validation history API endpoints.
2
+
3
+ Provides endpoints for validation history and trend analysis.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Annotated, Literal
9
+
10
+ from fastapi import APIRouter, Depends, HTTPException, Query
11
+
12
+ from truthound_dashboard.core import HistoryService
13
+
14
+ from .deps import SessionDep
15
+
16
+ router = APIRouter()
17
+
18
+
19
+ async def get_history_service(session: SessionDep) -> HistoryService:
20
+ """Get history service dependency."""
21
+ return HistoryService(session)
22
+
23
+
24
+ HistoryServiceDep = Annotated[HistoryService, Depends(get_history_service)]
25
+
26
+
27
+ @router.get(
28
+ "/sources/{source_id}/history",
29
+ response_model=dict,
30
+ summary="Get validation history",
31
+ description="Get validation history with trend analysis for a source.",
32
+ )
33
+ async def get_validation_history(
34
+ source_id: str,
35
+ service: HistoryServiceDep,
36
+ period: Literal["7d", "30d", "90d"] = Query("30d", description="Time period"),
37
+ granularity: Literal["hourly", "daily", "weekly"] = Query(
38
+ "daily", description="Aggregation granularity"
39
+ ),
40
+ ) -> dict:
41
+ """Get validation history with trend data.
42
+
43
+ Args:
44
+ source_id: Source ID.
45
+ service: History service.
46
+ period: Time period to analyze (7d, 30d, 90d).
47
+ granularity: Aggregation granularity (hourly, daily, weekly).
48
+
49
+ Returns:
50
+ Dictionary with summary, trend, failure_frequency, and recent_validations.
51
+ """
52
+ try:
53
+ data = await service.get_history(
54
+ source_id,
55
+ period=period,
56
+ granularity=granularity,
57
+ )
58
+ return {"success": True, "data": data}
59
+ except ValueError as e:
60
+ raise HTTPException(status_code=404, detail=str(e))
61
+ except Exception as e:
62
+ raise HTTPException(status_code=500, detail=str(e))