# (c) Copyright 2025 Perceptic Technologies Ltd. All rights reserved.

from __future__ import annotations

from dataclasses import dataclass
from datetime import datetime
from typing import Any, Union

from perceptic_workflow.definitions.workflow_checkpoint_status import WorkflowCheckpointStatus


@dataclass(frozen=True)
class InfoEvent:
    """Generic information event with a type and payload."""

    event_id: int
    type: str
    payload: dict[str, Any]
    timestamp: datetime


@dataclass(frozen=True)
class UserInputEvent:
    """Event representing user input submitted to the workflow."""

    event_id: int
    input: dict[str, Any]
    timestamp: datetime


@dataclass(frozen=True)
class UserInputRequestEvent:
    """Event requesting user input from the client."""

    event_id: int
    requested_data: dict[str, Any]
    timestamp: datetime


@dataclass(frozen=True)
class CheckpointEvent:
    """Event representing a workflow checkpoint status update."""

    event_id: int
    checkpoint_name: str
    update_id: str
    status: WorkflowCheckpointStatus
    payload: dict[str, Any]
    timestamp: datetime


# Union type representing all WorkflowEvent variants
WorkflowEvent = Union[InfoEvent, UserInputEvent, UserInputRequestEvent, CheckpointEvent]
