"""Prism specification for {{ project_name }}.

Starter spec — edit these models and run `prisme generate` to create the full stack.
"""

from prisme import (
    FieldSpec,
    FieldType,
    FilterOperator,
    ModelSpec,
    RelationshipSpec,
    StackSpec,
)

spec = StackSpec(
    name="{{ project_name_snake }}",
    version="1.0.0",
    description="{{ description }}",
    models=[
        ModelSpec(
            name="Organization",
            description="A top-level organization",
            fields=[
                FieldSpec(
                    name="name",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="description",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="status",
                    type=FieldType.ENUM,
                    enum_values=["active", "suspended", "archived"],
                    default="active",
                ),
                FieldSpec(
                    name="founded_date",
                    type=FieldType.DATE,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="projects",
                    target_model="Project",
                    type="one_to_many",
                    back_populates="organization",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
        ModelSpec(
            name="Project",
            description="A project within an organization",
            fields=[
                FieldSpec(
                    name="name",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="description",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="budget",
                    type=FieldType.DECIMAL,
                    precision=12,
                    scale=2,
                ),
                FieldSpec(
                    name="is_active",
                    type=FieldType.BOOLEAN,
                    default=True,
                ),
                FieldSpec(
                    name="organization_id",
                    type=FieldType.FOREIGN_KEY,
                    references="Organization",
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="organization",
                    target_model="Organization",
                    type="many_to_one",
                    back_populates="projects",
                ),
                RelationshipSpec(
                    name="documents",
                    target_model="Document",
                    type="one_to_many",
                    back_populates="project",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
        ModelSpec(
            name="Document",
            description="A document attached to a project",
            fields=[
                FieldSpec(
                    name="title",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="content",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="doc_type",
                    type=FieldType.ENUM,
                    enum_values=["proposal", "report", "contract", "memo"],
                    default="memo",
                ),
                FieldSpec(
                    name="version",
                    type=FieldType.STRING,
                    max_length=20,
                    default="1.0",
                ),
                FieldSpec(
                    name="project_id",
                    type=FieldType.FOREIGN_KEY,
                    references="Project",
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="project",
                    target_model="Project",
                    type="many_to_one",
                    back_populates="documents",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
    ],
)
