All checks were successful
Build and Deploy Log Center / build-and-deploy (push) Successful in 1m31s
95 lines
2.5 KiB
TypeScript
95 lines
2.5 KiB
TypeScript
import axios from 'axios';
|
|
|
|
const API_BASE = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8002';
|
|
|
|
const api = axios.create({
|
|
baseURL: API_BASE,
|
|
timeout: 10000,
|
|
});
|
|
|
|
// Types
|
|
export interface ErrorLog {
|
|
id: number;
|
|
project_id: string;
|
|
environment: string;
|
|
level: string;
|
|
error_type: string;
|
|
error_message: string;
|
|
file_path: string;
|
|
line_number: number;
|
|
stack_trace: string;
|
|
context: Record<string, any>;
|
|
version?: string;
|
|
commit_hash?: string;
|
|
timestamp: string;
|
|
fingerprint: string;
|
|
status: string;
|
|
retry_count: number;
|
|
}
|
|
|
|
export interface DashboardStats {
|
|
total_bugs: number;
|
|
today_bugs: number;
|
|
fix_rate: number;
|
|
status_distribution: Record<string, number>;
|
|
}
|
|
|
|
export interface PaginatedResponse<T> {
|
|
items: T[];
|
|
total: number;
|
|
page: number;
|
|
page_size: number;
|
|
total_pages: number;
|
|
}
|
|
|
|
export interface RepairReport {
|
|
id: number;
|
|
error_log_id: number;
|
|
project_id: string;
|
|
status: string;
|
|
ai_analysis: string;
|
|
fix_plan: string;
|
|
code_diff: string;
|
|
modified_files: string[];
|
|
test_output: string;
|
|
test_passed: boolean;
|
|
created_at: string;
|
|
repair_round: number;
|
|
failure_reason: string | null;
|
|
}
|
|
|
|
// API Functions
|
|
export const getStats = () => api.get<DashboardStats>('/api/v1/dashboard/stats');
|
|
|
|
export const getBugs = (params: {
|
|
page?: number;
|
|
page_size?: number;
|
|
status?: string;
|
|
project_id?: string;
|
|
}) => api.get<PaginatedResponse<ErrorLog>>('/api/v1/bugs', { params });
|
|
|
|
export const getBugDetail = (id: number) => api.get<ErrorLog>(`/api/v1/bugs/${id}`);
|
|
|
|
export const getProjects = () => api.get<{ projects: string[] }>('/api/v1/projects');
|
|
|
|
export const updateTaskStatus = (taskId: number, status: string, message?: string) =>
|
|
api.put(`/api/v1/tasks/${taskId}/status`, { status, message });
|
|
|
|
export const triggerRepair = (bugId: number) =>
|
|
updateTaskStatus(bugId, 'PENDING_FIX', 'Triggered from UI');
|
|
|
|
export const getRepairReports = (params: {
|
|
page?: number;
|
|
page_size?: number;
|
|
project_id?: string;
|
|
}) => api.get<PaginatedResponse<RepairReport>>('/api/v1/repair/reports', { params });
|
|
|
|
export const getRepairReportDetail = (id: number) => api.get<RepairReport>(`/api/v1/repair/reports/${id}`);
|
|
|
|
export const getRepairReportsByBug = (errorLogId: number) =>
|
|
api.get<PaginatedResponse<RepairReport>>('/api/v1/repair/reports', {
|
|
params: { error_log_id: errorLogId, page_size: 100 }
|
|
});
|
|
|
|
export default api;
|