fix: resolve 7 frontend-backend API inconsistencies and add comprehensive documentation

- Fixed LoginResponse: added expires_in field
- Renamed format to file_format across FileInfo interface
- Updated ProcessRequest: replaced confidence_threshold with detect_layout
- Modified ProcessResponse: added message and total_files, removed task_id
- Removed non-existent getTaskStatus API call
- Fixed getOCRResult parameter from taskId to fileId
- Commented out translation config APIs pending backend implementation

Documentation:
- Added API_REFERENCE.md: Complete API endpoint inventory
- Added API_FIX_SUMMARY.md: Detailed before/after comparison of all fixes
- Added FRONTEND_API.md: Frontend integration documentation
- Added FRONTEND_QUICK_START.md: Quick start guide
- Added FRONTEND_UPGRADE_SUMMARY.md: Upgrade summary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-11-13 08:54:37 +08:00
parent fed112656f
commit 9cf36d8e21
7 changed files with 2865 additions and 34 deletions

View File

@@ -6,7 +6,6 @@ import type {
UploadResponse,
ProcessRequest,
ProcessResponse,
TaskStatus,
BatchStatus,
OCRResult,
ExportRequest,
@@ -151,18 +150,11 @@ class ApiClient {
}
/**
* Get task status
* Get OCR result by file ID
* Note: Backend uses file-level tracking, not task-level
*/
async getTaskStatus(taskId: string): Promise<TaskStatus> {
const response = await this.client.get<TaskStatus>(`/ocr/status/${taskId}`)
return response.data
}
/**
* Get OCR result
*/
async getOCRResult(taskId: string): Promise<OCRResult> {
const response = await this.client.get<OCRResult>(`/ocr/result/${taskId}`)
async getOCRResult(fileId: number): Promise<OCRResult> {
const response = await this.client.get<OCRResult>(`/ocr/result/${fileId}`)
return response.data
}
@@ -251,28 +243,26 @@ class ApiClient {
}
/**
* Get translation configs (STUB - Not yet implemented)
* This is a placeholder for future translation functionality
* @throws Will throw error with status 501 (Not Implemented)
* Get translation configs (NOT IMPLEMENTED)
* This endpoint does not exist on backend - configs will be part of Phase 5
* @deprecated Backend endpoint does not exist - will return 404
*/
async getTranslationConfigs(): Promise<TranslationConfig[]> {
// This endpoint is expected to return 501 Not Implemented until Phase 5
const response = await this.client.get<TranslationConfig[]>('/translate/configs')
return response.data
}
// async getTranslationConfigs(): Promise<TranslationConfig[]> {
// const response = await this.client.get<TranslationConfig[]>('/translate/configs')
// return response.data
// }
/**
* Create translation config (STUB - Not yet implemented)
* This is a placeholder for future translation functionality
* @throws Will throw error with status 501 (Not Implemented)
* Create translation config (NOT IMPLEMENTED)
* This endpoint does not exist on backend - configs will be part of Phase 5
* @deprecated Backend endpoint does not exist - will return 404
*/
async createTranslationConfig(
config: Omit<TranslationConfig, 'id' | 'created_at'>
): Promise<TranslationConfig> {
// This endpoint is expected to return 501 Not Implemented until Phase 5
const response = await this.client.post<TranslationConfig>('/translate/configs', config)
return response.data
}
// async createTranslationConfig(
// config: Omit<TranslationConfig, 'id' | 'created_at'>
// ): Promise<TranslationConfig> {
// const response = await this.client.post<TranslationConfig>('/translate/configs', config)
// return response.data
// }
}
// Export singleton instance

View File

@@ -12,6 +12,7 @@ export interface LoginRequest {
export interface LoginResponse {
access_token: string
token_type: string
expires_in: number // Token expiration time in seconds
}
export interface User {
@@ -29,7 +30,7 @@ export interface FileInfo {
id: number
filename: string
file_size: number
format: string
file_format: string // Changed from 'format' to match backend
status: 'pending' | 'processing' | 'completed' | 'failed'
}
@@ -37,13 +38,15 @@ export interface FileInfo {
export interface ProcessRequest {
batch_id: number
lang?: string
confidence_threshold?: number
detect_layout?: boolean // Changed from confidence_threshold to match backend
}
export interface ProcessResponse {
task_id: string
message: string // Added to match backend
batch_id: number
total_files: number // Added to match backend
status: string
// Removed task_id - backend uses batch-level tracking instead
}
export interface TaskStatus {
@@ -132,7 +135,7 @@ export interface ExportRule {
export interface CSSTemplate {
name: string
description: string
filename: string
// filename is not returned by backend - use name as identifier
}
// Translation (FUTURE FEATURE)