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

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

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

spec = StackSpec(
    name="{{ project_name_snake }}",
    version="1.0.0",
    description="{{ description }}",
    models=[
        ModelSpec(
            name="Category",
            description="A category for grouping items",
            fields=[
                FieldSpec(
                    name="name",
                    type=FieldType.STRING,
                    max_length=100,
                    required=True,
                ),
                FieldSpec(
                    name="description",
                    type=FieldType.TEXT,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="items",
                    target_model="Item",
                    type="one_to_many",
                    back_populates="category",
                ),
            ],
            timestamps=True,
        ),
        ModelSpec(
            name="Item",
            description="An item belonging to a category",
            fields=[
                FieldSpec(
                    name="name",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                ),
                FieldSpec(
                    name="description",
                    type=FieldType.TEXT,
                ),
                FieldSpec(
                    name="quantity",
                    type=FieldType.INTEGER,
                    default=0,
                ),
                FieldSpec(
                    name="is_active",
                    type=FieldType.BOOLEAN,
                    default=True,
                ),
                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="items",
                ),
            ],
            timestamps=True,
        ),
    ],
)
