import uuid from datetime import datetime from pydantic import BaseModel, ConfigDict from app.models.enums import ChangeProposalOrigin, ChangeProposalStatus class ProposalOperation(BaseModel): op: str # create | update | delete entity_type: str # person | name | event | relationship | source | citation entity_id: uuid.UUID | None = None payload: dict = {} class ChangeProposalCreate(BaseModel): summary: str rationale: str | None = None origin: ChangeProposalOrigin = ChangeProposalOrigin.contributor operations: list[ProposalOperation] class ProposalReview(BaseModel): note: str | None = None # Optional edited operations to apply instead of the original (approve-with-edits). operations: list[ProposalOperation] | None = None class ChangeProposalRead(BaseModel): model_config = ConfigDict(from_attributes=True) id: uuid.UUID tree_id: uuid.UUID status: ChangeProposalStatus origin: ChangeProposalOrigin created_by_user_id: uuid.UUID | None summary: str rationale: str | None operations: list reviewed_by_user_id: uuid.UUID | None reviewed_at: datetime | None review_note: str | None apply_error: str | None created_at: datetime