57 lines
1.1 KiB
Python
57 lines
1.1 KiB
Python
from enum import Enum
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.common import ErrorPayload
|
|
|
|
|
|
class FileSnapshot(BaseModel):
|
|
path: str = Field(min_length=1)
|
|
content: str
|
|
content_hash: str = Field(min_length=1)
|
|
|
|
|
|
class IndexSnapshotRequest(BaseModel):
|
|
project_id: str = Field(min_length=1)
|
|
files: list[FileSnapshot]
|
|
|
|
|
|
class ChangeOp(str, Enum):
|
|
UPSERT = "upsert"
|
|
DELETE = "delete"
|
|
|
|
|
|
class ChangedFile(BaseModel):
|
|
op: ChangeOp
|
|
path: str = Field(min_length=1)
|
|
content: Optional[str] = None
|
|
content_hash: Optional[str] = None
|
|
|
|
|
|
class IndexChangesRequest(BaseModel):
|
|
project_id: str = Field(min_length=1)
|
|
changed_files: list[ChangedFile]
|
|
|
|
|
|
class IndexJobQueuedResponse(BaseModel):
|
|
index_job_id: str
|
|
status: str
|
|
|
|
|
|
class IndexJobStatus(str, Enum):
|
|
QUEUED = "queued"
|
|
RUNNING = "running"
|
|
DONE = "done"
|
|
ERROR = "error"
|
|
|
|
|
|
class IndexJobResponse(BaseModel):
|
|
index_job_id: str
|
|
status: IndexJobStatus
|
|
indexed_files: int = 0
|
|
failed_files: int = 0
|
|
cache_hit_files: int = 0
|
|
cache_miss_files: int = 0
|
|
error: Optional[ErrorPayload] = None
|