File size: 1,412 Bytes
1f21206 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import { api } from './client'
export type DiagnosticSeverity = 'debug' | 'info' | 'warn' | 'error'
export type DiagnosticEvent = {
id: string
timestamp: string
type: string
severity: DiagnosticSeverity
summary: string
sessionId?: string
details?: unknown
}
export type DiagnosticEventInput = {
type: string
severity?: DiagnosticSeverity
summary: string
sessionId?: string
details?: unknown
}
export type DiagnosticsStatus = {
logDir: string
diagnosticsPath: string
cliDiagnosticsPath: string
runtimeErrorsPath: string
exportDir: string
retentionDays: number
maxBytes: number
totalBytes: number
eventCount: number
recentErrorCount: number
lastEventAt: string | null
}
export type DiagnosticsBundle = {
path: string
fileName: string
bytes: number
}
export const diagnosticsApi = {
getStatus: () => api.get<DiagnosticsStatus>('/api/diagnostics/status'),
getEvents: (limit = 100) => api.get<{ events: DiagnosticEvent[] }>(`/api/diagnostics/events?limit=${limit}`),
recordEvent: (event: DiagnosticEventInput) => api.post<{ ok: true }>('/api/diagnostics/events', event, { timeout: 5_000 }),
exportBundle: () => api.post<{ bundle: DiagnosticsBundle }>('/api/diagnostics/export', undefined, { timeout: 60_000 }),
openLogDir: () => api.post<{ ok: true }>('/api/diagnostics/open-log-dir'),
clear: () => api.delete<{ ok: true }>('/api/diagnostics'),
}
|