"""Pydantic schemas for the DMS plugin."""

from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel, Field


class FolderCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=255)
    parent_id: str | None = None


class FolderUpdate(BaseModel):
    name: str | None = Field(None, min_length=1, max_length=255)
    parent_id: str | None = None


class FolderResponse(BaseModel):
    id: str
    name: str
    parent_id: str | None = None
    created_by: str
    deleted_at: datetime | None = None
    path: str = ""
    children: list[dict] = []


class FileMetadataResponse(BaseModel):
    id: str
    name: str
    folder_id: str | None = None
    uploaded_by: str
    mime_type: str
    size_bytes: int
    storage_path: str
    deleted_at: datetime | None = None
    created_at: datetime | None = None
    updated_at: datetime | None = None


class FileUpdate(BaseModel):
    name: str | None = Field(None, min_length=1, max_length=255)
    folder_id: str | None = None


class ShareRequest(BaseModel):
    user_ids: list[str] = Field(default_factory=list)
    group_ids: list[str] = Field(default_factory=list)
    access_level: str = Field("read", pattern="^(read|write)$")


class ShareRemoveRequest(BaseModel):
    user_id: str | None = None
    group_id: str | None = None


class BulkMoveRequest(BaseModel):
    file_ids: list[str] = Field(..., min_length=1)
    target_folder_id: str | None = None


class BulkDeleteRequest(BaseModel):
    file_ids: list[str] = Field(..., min_length=1)


class CollaboraConfig(BaseModel):
    document: dict
    editorConfig: dict  # noqa: N815
