"""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="Category",
            description="A category for organizing pages and posts",
            fields=[
                FieldSpec(
                    name="name",
                    type=FieldType.STRING,
                    max_length=100,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="slug",
                    type=FieldType.STRING,
                    max_length=100,
                    unique=True,
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="pages",
                    target_model="Page",
                    type="one_to_many",
                    back_populates="category",
                ),
                RelationshipSpec(
                    name="posts",
                    target_model="Post",
                    type="one_to_many",
                    back_populates="category",
                ),
            ],
            timestamps=True,
        ),
        ModelSpec(
            name="Page",
            description="A static page on the website",
            fields=[
                FieldSpec(
                    name="title",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="slug",
                    type=FieldType.STRING,
                    max_length=255,
                    unique=True,
                    required=True,
                ),
                FieldSpec(
                    name="content",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="is_published",
                    type=FieldType.BOOLEAN,
                    default=False,
                ),
                FieldSpec(
                    name="sort_order",
                    type=FieldType.INTEGER,
                    default=0,
                ),
                FieldSpec(
                    name="category_id",
                    type=FieldType.FOREIGN_KEY,
                    references="Category",
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="category",
                    target_model="Category",
                    type="many_to_one",
                    back_populates="pages",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
        ModelSpec(
            name="Post",
            description="A blog post",
            fields=[
                FieldSpec(
                    name="title",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                    searchable=True,
                    filter_operators=[FilterOperator.EQ, FilterOperator.CONTAINS],
                ),
                FieldSpec(
                    name="slug",
                    type=FieldType.STRING,
                    max_length=255,
                    unique=True,
                    required=True,
                ),
                FieldSpec(
                    name="content",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="is_published",
                    type=FieldType.BOOLEAN,
                    default=False,
                ),
                FieldSpec(
                    name="published_at",
                    type=FieldType.DATETIME,
                ),
                FieldSpec(
                    name="category_id",
                    type=FieldType.FOREIGN_KEY,
                    references="Category",
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="category",
                    target_model="Category",
                    type="many_to_one",
                    back_populates="posts",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
    ],
)
