from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field

class HelpArticleBase(BaseModel):
    slug: str
    title: str
    content: str
    last_editor: str
    category: Optional[str] = "General"
    order: Optional[int] = 0
    content_type: str = "article"
    file_url: Optional[str] = None
    file_size: Optional[int] = None
    mime_type: Optional[str] = None
    context_path: Optional[str] = None
    tags: Optional[str] = None

class HelpArticleCreate(HelpArticleBase):
    pass

class HelpArticleUpdate(BaseModel):
    slug: Optional[str] = None
    title: Optional[str] = None
    content: Optional[str] = None
    last_editor: Optional[str] = None
    category: Optional[str] = None
    order: Optional[int] = None
    content_type: Optional[str] = None
    file_url: Optional[str] = None
    file_size: Optional[int] = None
    mime_type: Optional[str] = None
    context_path: Optional[str] = None
    tags: Optional[str] = None

class HelpArticleInDB(HelpArticleBase):
    uuid: UUID
    updated_at: datetime

    class Config:
        from_attributes = True

class HelpSyncRequest(BaseModel):
    article_uuid: UUID
    client_updated_at: datetime
    client_content: str
    client_title: str
    client_slug: str
    last_editor: str
    client_category: Optional[str] = "General"
    client_order: Optional[int] = 0
    client_content_type: str = "article"
    client_file_url: Optional[str] = None
    client_file_size: Optional[int] = None
    client_mime_type: Optional[str] = None
    client_context_path: Optional[str] = None
    client_tags: Optional[str] = None

class HelpSyncResponse(BaseModel):
    status: str
    server_updated_at: Optional[datetime] = None
    server_content: Optional[str] = None
    server_title: Optional[str] = None
    server_slug: Optional[str] = None
    server_category: Optional[str] = None
    server_order: Optional[int] = None
    server_content_type: Optional[str] = None
    server_file_url: Optional[str] = None
    server_file_size: Optional[int] = None
    server_mime_type: Optional[str] = None
    server_context_path: Optional[str] = None
    server_tags: Optional[str] = None
    message: str
