# Auto-generated by sloplog codegen - DO NOT EDIT
# Source: sloplog registry

from typing import TypedDict, Literal, Union


class _ErrorPartialRequired(TypedDict):
    """Required fields for error partial"""

    type: str  # Literal["error"]
    message: str


class ErrorPartial(_ErrorPartialRequired, total=False):
    """Error details captured during event processing."""

    stack: str
    code: float


class _LogMessagePartialRequired(TypedDict):
    """Required fields for log_message partial"""

    type: str  # Literal["log_message"]
    message: str
    level: Literal["trace", "debug", "info", "warn", "error", "fatal"]


class LogMessagePartial(_LogMessagePartialRequired, total=False):
    """Lightweight log entry for ad-hoc logging. Prefer structured partials when possible."""

    data: str


class SpanPartial(TypedDict):
    """Timing span emitted by WideEvent span helpers."""

    type: str  # Literal["span"]
    name: str
    started_at: float
    ended_at: float
    duration_ms: float


class _SloplogUsageErrorPartialRequired(TypedDict):
    """Required fields for sloplog_usage_error partial"""

    type: str  # Literal["sloplog_usage_error"]
    kind: str
    message: str


class SloplogUsageErrorPartial(_SloplogUsageErrorPartialRequired, total=False):
    """Internal usage errors emitted by sloplog (e.g. partial overwrites or span misuse)."""

    partial_type: str
    span_name: str
    started_at: float
    count: float


# Union of all partial types
GeneratedPartial = Union[
    ErrorPartial, LogMessagePartial, SpanPartial, SloplogUsageErrorPartial
]


# Registry mapping partial names to their types
# Repeatable partials are typed as lists
class GeneratedRegistry(TypedDict):
    """Type-safe registry of all event partials"""

    error: list[ErrorPartial]
    log_message: list[LogMessagePartial]
    span: list[SpanPartial]
    sloplog_usage_error: list[SloplogUsageErrorPartial]


class PartialMetadata(TypedDict):
    """Metadata about a partial type"""

    repeatable: bool
    always_sample: bool


# Runtime metadata for partials
PARTIAL_METADATA: dict[str, PartialMetadata] = {
    "error": {"repeatable": True, "always_sample": True},
    "log_message": {"repeatable": True, "always_sample": False},
    "span": {"repeatable": True, "always_sample": False},
    "sloplog_usage_error": {"repeatable": True, "always_sample": False},
}

__all__ = [
    "ErrorPartial",
    "LogMessagePartial",
    "SpanPartial",
    "SloplogUsageErrorPartial",
    "GeneratedPartial",
    "GeneratedRegistry",
    "PartialMetadata",
    "PARTIAL_METADATA",
]
