types.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Shared TypeScript types matching the Go server's API contracts.
  2. export interface RouterEvent {
  3. id: string
  4. router_id: string
  5. hostname?: string
  6. event_type: string
  7. timestamp: string
  8. payload: Record<string, unknown>
  9. received_at: string
  10. connection: string
  11. }
  12. export interface RouterInfo {
  13. id: string
  14. last_seen: string
  15. online: boolean
  16. queued_commands: number
  17. }
  18. export interface CommandRecord {
  19. id: string
  20. router_id: string
  21. command: string
  22. args: Record<string, string> | null
  23. issued_by: string
  24. status: 'pending' | 'queued' | 'delivered' | 'completed' | 'timeout' | 'publish_failed'
  25. result?: { success: boolean; output: string; error: string }
  26. ts: string
  27. }
  28. export interface Alert {
  29. id: number
  30. router_id: string
  31. kind: string
  32. message: string
  33. created_at: string
  34. acknowledged_at?: string
  35. }
  36. export interface MetricsBucket {
  37. ts: string
  38. events_total: number
  39. commands_total: number
  40. commands_ok: number
  41. commands_fail: number
  42. events_by_type: Record<string, number>
  43. }
  44. export interface MetricsResponse {
  45. summary: {
  46. events_last_5min: number
  47. events_this_min: number
  48. commands_this_min: number
  49. }
  50. buckets: MetricsBucket[]
  51. since: string
  52. }
  53. export interface HealthResponse {
  54. status: string
  55. routers: number
  56. routers_online: number
  57. redpanda: string[]
  58. version: string
  59. }
  60. export interface LoginResponse {
  61. token: string
  62. role: string
  63. expires: string
  64. }
  65. export interface MeResponse {
  66. user_id: number
  67. username: string
  68. role: 'system_admin' | 'project_admin' | 'user'
  69. expires: number
  70. }