feat(api): add POST/GET /v1/files with auth, error envelope, and request-id middleware
Why: - Wires the ADR-0008 error envelope, per-request correlation id, and the /v1/files routes into the app. Changes: - Extend AppResources/lifespan with the ingestion CapacityLimiter and ObjectStorage adapter. Impact: - /v1 now exposes routes for the first time.
This commit is contained in:
50
src/api/schemas/files.py
Normal file
50
src/api/schemas/files.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""Public request/response models for `/v1/files` (ADR-0008).
|
||||
|
||||
Separate from the SQLAlchemy ORM models and the `application/files` domain
|
||||
dataclasses (ADR-0015): this is the shape callers see.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from src.application.files.models import UploadResult
|
||||
from src.application.files.status import FileStatusResult
|
||||
|
||||
|
||||
class FileUploadResponse(BaseModel):
|
||||
file_id: uuid.UUID
|
||||
ingestion_job_id: uuid.UUID
|
||||
status: str
|
||||
chunks_indexed: int
|
||||
|
||||
@classmethod
|
||||
def from_result(cls, result: UploadResult) -> "FileUploadResponse":
|
||||
return cls(
|
||||
file_id=result.file_id,
|
||||
ingestion_job_id=result.ingestion_job_id,
|
||||
status=result.status,
|
||||
chunks_indexed=result.chunks_indexed,
|
||||
)
|
||||
|
||||
|
||||
class FileStatusResponse(BaseModel):
|
||||
file_id: uuid.UUID
|
||||
source_filename: str
|
||||
domain: str
|
||||
status: str
|
||||
ingestion_job_id: uuid.UUID | None
|
||||
ingestion_status: str | None
|
||||
chunks_indexed: int
|
||||
|
||||
@classmethod
|
||||
def from_result(cls, result: FileStatusResult) -> "FileStatusResponse":
|
||||
return cls(
|
||||
file_id=result.file_id,
|
||||
source_filename=result.source_filename,
|
||||
domain=result.domain,
|
||||
status=result.status,
|
||||
ingestion_job_id=result.ingestion_job_id,
|
||||
ingestion_status=result.ingestion_status,
|
||||
chunks_indexed=result.chunks_indexed,
|
||||
)
|
||||
Reference in New Issue
Block a user