"""Pydantic schemas for plugin API responses."""

from __future__ import annotations

from pydantic import BaseModel, Field


class PluginInfo(BaseModel):
    """Plugin status information returned in list endpoint."""

    name: str
    display_name: str
    version: str
    status: str = Field(description="discovered | installed | active | inactive")
    installed: bool = False
    active: bool = False
    description: str = ""
    dependencies: list[str] = Field(default_factory=list)
    events: list[str] = Field(default_factory=list)
    migrations: list[str] = Field(default_factory=list)
    permissions: list[str] = Field(default_factory=list)


class PluginListResponse(BaseModel):
    """Response for GET /api/v1/plugins."""

    plugins: list[PluginInfo]
    total: int


class PluginActionResponse(BaseModel):
    """Response for install/activate/deactivate/uninstall actions."""

    name: str
    display_name: str
    version: str
    status: str
    installed: bool = False
    active: bool = False
    dropped_tables: list[str] = Field(
        default_factory=list, description="Tables dropped (uninstall with remove_data=true)"
    )
    message: str = ""


class PluginUninstallResponse(PluginActionResponse):
    """Response for DELETE /api/v1/plugins/{name}."""

    pass


class ManifestFieldDoc(BaseModel):
    """Documentation for a single manifest field."""

    type: str
    required: str
    description: str


class ManifestSchemaResponse(BaseModel):
    """Response for GET /api/v1/plugins/manifest."""

    fields: dict[str, ManifestFieldDoc]
    example: dict
