# generated by datamodel-codegen:
#   filename:  core/signal_definition.json
#   timestamp: 2026-02-23T01:56:40+00:00

from __future__ import annotations

from typing import Annotated

from adcp.types.base import AdCPBaseModel
from pydantic import ConfigDict, Field, RootModel

from ..enums import signal_value_type


class Range(AdCPBaseModel):
    max: Annotated[float, Field(description='Maximum value')]
    min: Annotated[float, Field(description='Minimum value')]
    unit: Annotated[
        str | None, Field(description="Unit of measurement (e.g., 'score', 'dollars', 'years')")
    ] = None


class Tag(RootModel[str]):
    root: Annotated[str, Field(pattern='^[a-z0-9_-]+$')]


class SignalDefinition(AdCPBaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    allowed_values: Annotated[
        list[str] | None,
        Field(
            description='For categorical signals, the valid values users can be assigned',
            min_length=1,
        ),
    ] = None
    description: Annotated[
        str | None,
        Field(
            description="Detailed description of what this signal represents and how it's derived",
            max_length=2000,
        ),
    ] = None
    id: Annotated[
        str,
        Field(
            description="Signal identifier within this data provider's catalog",
            pattern='^[a-zA-Z0-9_-]+$',
        ),
    ]
    name: Annotated[
        str, Field(description='Human-readable signal name', max_length=255, min_length=1)
    ]
    range: Annotated[
        Range | None, Field(description='For numeric signals, the valid value range')
    ] = None
    tags: Annotated[
        list[Tag] | None,
        Field(description='Tags for grouping and filtering signals within the catalog'),
    ] = None
    value_type: Annotated[
        signal_value_type.SignalValueType,
        Field(description="The data type of this signal's values"),
    ]
