[INT-TYPE-006] Complete ApiError interface with all backend fields

This commit is contained in:
senke 2025-12-25 22:37:36 +01:00
parent 2b81d5156d
commit 8a484833ec
4 changed files with 39 additions and 22 deletions

View file

@ -355,7 +355,8 @@
"description": "L'interface ApiError frontend est incomplète par rapport aux erreurs retournées par le backend.",
"priority": "P1",
"priority_rank": 9,
"status": "todo",
"status": "completed",
"completed_at": "2025-01-27T13:45:00Z",
"estimated_hours": 1.5,
"side": "frontend_only",
"files_to_modify": [
@ -1090,13 +1091,13 @@
},
"progress_tracking": {
"total_tasks": 32,
"completed": 8,
"completed": 9,
"in_progress": 0,
"todo": 24,
"todo": 23,
"blocked": 0,
"completion_percentage": 25,
"last_updated": "2025-01-27T13:30:00Z",
"completion_percentage": 28,
"last_updated": "2025-01-27T13:45:00Z",
"estimated_completion_date": null,
"estimated_hours_remaining": 36
"estimated_hours_remaining": 34.5
}
}

View file

@ -182,18 +182,22 @@ export type AuditLog = z.infer<typeof auditLogSchema>;
/**
* ApiError schema
* INT-TYPE-006: Aligned with backend error format (handlers/error_response.go)
* Backend ErrorDetail: { field, message }
*/
export const apiErrorSchema = z.object({
code: z.number().int(),
code: z.number().int(), // ErrorCode (1000-9999) or HTTP status code
message: z.string(),
// INT-TYPE-006: details matches backend ErrorDetail[] structure
details: z.array(z.object({
field: z.string(),
message: z.string(),
field: z.string(), // Field name from ErrorDetail.Field
message: z.string(), // Error message from ErrorDetail.Message
value: z.string().optional(), // Optional value that failed validation
})).optional(),
request_id: z.string().optional(),
timestamp: isoDateSchema,
context: z.record(z.any()).optional(),
retry_after: z.number().int().positive().optional(),
request_id: z.string().optional(), // Request ID for tracking
timestamp: isoDateSchema, // ISO8601 timestamp
context: z.record(z.any()).optional(), // Additional context (user_id, etc.)
retry_after: z.number().int().positive().optional(), // Seconds before retry (for 429)
});
export type ApiError = z.infer<typeof apiErrorSchema>;

View file

@ -251,18 +251,20 @@ export interface ApiResponse<T> {
}
// Types pour les erreurs API
// Aligné avec FRONTEND_INTEGRATION.md
// INT-TYPE-006: ApiError interface aligned with backend error format (handlers/error_response.go)
// Backend format: { error: { code, message, details, request_id, timestamp, context } }
export interface ApiError {
code: number; // Code numérique (1000, 2000, etc.) ou code HTTP (429, 503, 502)
message: string;
// INT-TYPE-006: details array matches backend ErrorDetail[] structure
details?: Array<{
field: string;
message: string;
value?: string; // FE-TYPE-005: Added to match backend ValidationError DTO
field: string; // Field name (from ErrorDetail.Field)
message: string; // Error message (from ErrorDetail.Message)
value?: string; // Optional value that failed validation
}>;
request_id?: string;
timestamp: string;
context?: Record<string, any>;
request_id?: string; // Request ID for tracking (from X-Request-ID header)
timestamp: string; // ISO8601 timestamp
context?: Record<string, any>; // Additional context (user_id, etc.)
retry_after?: number; // Nombre de secondes avant de pouvoir réessayer (pour 429)
}

View file

@ -97,10 +97,20 @@ export interface LibraryItem {
is_favorite: boolean;
}
// INT-TYPE-006: ApiError interface aligned with backend error format
// Backend format: { error: { code, message, details, request_id, timestamp, context } }
export interface ApiError {
code: number; // Code numérique (1000, 2000, etc.) ou code HTTP (429, 503, 502)
message: string;
code?: string;
details?: Record<string, unknown>;
details?: Array<{
field: string;
message: string;
value?: string; // Optional value that failed validation
}>;
request_id?: string;
timestamp: string;
context?: Record<string, any>; // Additional context (user_id, etc.)
retry_after?: number; // Nombre de secondes avant de pouvoir réessayer (pour 429)
}
export interface PaginatedResponse<T> {