"""
Pydantic models for data store file and folder listing API responses.

This module defines data structures for browsing files and folders within
store connectors on the Airia platform.
"""

from typing import List, Optional

from pydantic import BaseModel, Field


class IngestionProcessingStatus(BaseModel):
    """Status information for file ingestion processing.

    Contains details about how a file is being processed during ingestion,
    including processing mode, status, and any errors encountered.

    Attributes:
        table_document_processing_mode: Mode used for processing table documents
        user_errors: List of user-facing error messages
        system_errors: List of system error messages
        status: Current processing status
    """

    table_document_processing_mode: Optional[str] = Field(
        None, alias="tableDocumentProcessingMode"
    )
    user_errors: Optional[List[str]] = Field(None, alias="userErrors")
    system_errors: Optional[List[str]] = Field(None, alias="systemErrors")
    status: Optional[str] = None


class FileOrFolder(BaseModel):
    """Individual file or folder entry in a store connector.

    Represents a single item (file or folder) within the data store,
    including metadata, status, and nested content counts for folders.

    Attributes:
        id: Unique identifier for the file or folder
        name: Name of the file or folder
        type: Type of the item (e.g., 'file' or 'folder')
        size: Size in bytes (for files)
        mime_type: MIME type (for files)
        file_count: Number of files (for folders)
        folder_count: Number of subfolders (for folders)
        file_last_updated_at: Timestamp of last update (ISO format)
        status: Current status of the file or folder
        ingestion_processing_statuses: List of ingestion processing status information
        additional_metadata_json: Additional metadata as JSON string
    """

    id: Optional[str] = None
    name: Optional[str] = None
    type: Optional[str] = None
    size: Optional[int] = None
    mime_type: Optional[str] = Field(None, alias="mimeType")
    file_count: Optional[int] = Field(None, alias="fileCount")
    folder_count: Optional[int] = Field(None, alias="folderCount")
    file_last_updated_at: Optional[str] = Field(None, alias="fileLastUpdatedAt")
    status: Optional[str] = None
    ingestion_processing_statuses: Optional[List[IngestionProcessingStatus]] = Field(
        None, alias="ingestionProcessingStatuses"
    )
    additional_metadata_json: Optional[str] = Field(
        None, alias="additionalMetadataJson"
    )


class GetFilesAndFoldersResponse(BaseModel):
    """Response model for getting files and folders from a store connector.

    Contains a list of files and folders along with pagination information.

    Attributes:
        files_and_folders: List of file and folder objects
        total_count: Total number of items available (may be greater than items returned)
    """

    files_and_folders: Optional[List[FileOrFolder]] = Field(
        None, alias="filesAndFolders"
    )
    total_count: Optional[int] = Field(None, alias="totalCount")
