"""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="Dataset",
            description="A dataset containing records",
            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="format",
                    type=FieldType.ENUM,
                    enum_values=["csv", "json", "parquet", "xml"],
                    default="json",
                ),
                FieldSpec(
                    name="schema_definition",
                    type=FieldType.JSON,
                ),
                FieldSpec(
                    name="record_count",
                    type=FieldType.INTEGER,
                    default=0,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="records",
                    target_model="Record",
                    type="one_to_many",
                    back_populates="dataset",
                ),
            ],
            timestamps=True,
            soft_delete=True,
        ),
        ModelSpec(
            name="Record",
            description="A data record within a dataset",
            fields=[
                FieldSpec(
                    name="key",
                    type=FieldType.STRING,
                    max_length=255,
                    required=True,
                ),
                FieldSpec(
                    name="data",
                    type=FieldType.JSON,
                    required=True,
                ),
                FieldSpec(
                    name="status",
                    type=FieldType.ENUM,
                    enum_values=["pending", "validated", "rejected"],
                    default="pending",
                ),
                FieldSpec(
                    name="ingested_at",
                    type=FieldType.DATETIME,
                ),
                FieldSpec(
                    name="dataset_id",
                    type=FieldType.FOREIGN_KEY,
                    references="Dataset",
                    required=True,
                ),
            ],
            relationships=[
                RelationshipSpec(
                    name="dataset",
                    target_model="Dataset",
                    type="many_to_one",
                    back_populates="records",
                ),
            ],
            timestamps=True,
        ),
    ],
)
