from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class DocumentBase(BaseModel):
    account_id: int | None = None
    supplier_id: int | None = None
    doc_type: str = Field(..., max_length=60)
    name: str = Field(..., min_length=1, max_length=255)
    file_key: str | None = Field(None, max_length=512)
    file_url: str | None = Field(None, max_length=1024)
    content_type: str | None = Field(None, max_length=120)
    size_bytes: int | None = Field(None, ge=0)


class DocumentCreate(DocumentBase):
    pass


class DocumentUpdate(BaseModel):
    doc_type: str | None = Field(None, max_length=60)
    name: str | None = Field(None, min_length=1, max_length=255)
    file_key: str | None = Field(None, max_length=512)
    file_url: str | None = Field(None, max_length=1024)
    content_type: str | None = Field(None, max_length=120)
    size_bytes: int | None = Field(None, ge=0)


class DocumentResponse(DocumentBase):
    model_config = ConfigDict(from_attributes=True)

    id: int
    uploaded_by: str | None = None
    tenant_id: int
    company_id: int
    created_at: datetime
    updated_at: datetime
