from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field


# ── Sanctuary Entry ──────────────────────────────────────────────


class SanctuaryEntryCreate(BaseModel):
    """Payload for creating a new sanctuary entry (IPFS + chain anchor)."""

    entry_type: str = Field(..., max_length=64, description="document, decision, vote_result")
    reference_id: UUID = Field(..., description="ID of the referenced entity")
    title: str | None = Field(default=None, max_length=256)
    content_hash: str = Field(..., max_length=128, description="SHA-256 hash of the content")


class SanctuaryEntryOut(BaseModel):
    """Full sanctuary entry representation."""

    model_config = ConfigDict(from_attributes=True)

    id: UUID
    entry_type: str
    reference_id: UUID
    title: str | None = None
    content_hash: str
    ipfs_cid: str | None = None
    chain_tx_hash: str | None = None
    chain_block: int | None = None
    metadata_json: str | None = None
    created_at: datetime
