first commit - MVE Incrementables Parser microservice with FastAPI, JWT, Celery, Redis
This commit is contained in:
81
app/schemas.py
Normal file
81
app/schemas.py
Normal file
@@ -0,0 +1,81 @@
|
||||
"""Pydantic schemas for request/response validation."""
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# Authentication Schemas
|
||||
class LoginRequest(BaseModel):
|
||||
"""Login request schema."""
|
||||
username: str = Field(..., min_length=1)
|
||||
password: str = Field(..., min_length=1)
|
||||
|
||||
|
||||
class LoginResponse(BaseModel):
|
||||
"""Login response schema."""
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
expires_in: int
|
||||
|
||||
|
||||
# Health Check Schema
|
||||
class HealthResponse(BaseModel):
|
||||
"""Health check response."""
|
||||
status: str = "ok"
|
||||
service: str
|
||||
version: str
|
||||
|
||||
|
||||
# Incrementables Schemas
|
||||
class DocumentInfo(BaseModel):
|
||||
"""PDF document metadata."""
|
||||
filename: str
|
||||
pages: int
|
||||
sha256: str
|
||||
|
||||
|
||||
class IncrementablesData(BaseModel):
|
||||
"""Parsed incrementables data."""
|
||||
currency: str
|
||||
fletes: float
|
||||
seguros: Optional[float] = None
|
||||
almacenaje_consolidacion: float
|
||||
regalias: Optional[float] = None
|
||||
|
||||
|
||||
class ExtractionInfo(BaseModel):
|
||||
"""Information about the extraction process."""
|
||||
method: str # "text", "ocr" (future)
|
||||
anchors_found: List[str]
|
||||
warnings: List[str] = []
|
||||
|
||||
|
||||
class ParseResponse(BaseModel):
|
||||
"""Parse endpoint response."""
|
||||
correlation_id: str
|
||||
document: DocumentInfo
|
||||
incrementables: IncrementablesData
|
||||
extraction: ExtractionInfo
|
||||
|
||||
|
||||
# Async/Queue schemas
|
||||
class ParseAsyncResponse(BaseModel):
|
||||
"""Async parse endpoint response."""
|
||||
task_id: str
|
||||
correlation_id: str
|
||||
status: str = "queued"
|
||||
message: str = "Task queued for processing"
|
||||
|
||||
|
||||
class TaskStatusResponse(BaseModel):
|
||||
"""Task status response."""
|
||||
task_id: str
|
||||
status: str # pending, started, completed, failed
|
||||
result: Optional[dict] = None
|
||||
error: Optional[str] = None
|
||||
|
||||
|
||||
class ErrorResponse(BaseModel):
|
||||
"""Error response schema."""
|
||||
detail: str
|
||||
correlation_id: Optional[str] = None
|
||||
Reference in New Issue
Block a user