# Path: src/apscheduler/converters.py
# def as_aware_datetime(value: datetime | str) -> datetime:
#     """Convert the value from a string to a timezone aware datetime."""
#     if isinstance(value, str):
#         # fromisoformat() does not handle the "Z" suffix
#         if value.upper().endswith('Z'):
#             value = value[:-1] + '+00:00'
# 
#         value = datetime.fromisoformat(value)
# 
#     return value
# 
# def as_uuid(value: UUID | str) -> UUID:
#     """Convert a string-formatted UUID to a UUID instance."""
#     if isinstance(value, str):
#         return UUID(value)
# 
#     return value
# 
# Path: src/apscheduler/enums.py
# class JobOutcome(Enum):
#     success = auto()
#     error = auto()
#     missed_start_deadline = auto()
#     cancelled = auto()
#     expired = auto()


from datetime import datetime, timezone
from functools import partial
from uuid import UUID
from attrs.converters import optional
from .converters import as_aware_datetime, as_uuid
from .enums import JobOutcome
import attrs

@attrs.define(kw_only=True, frozen=True)
class TaskUpdated(DataStoreEvent):
    task_id: str


@attrs.define(kw_only=True, frozen=True)
class TaskRemoved(DataStoreEvent):
    task_id: str


@attrs.define(kw_only=True, frozen=True)
class ScheduleAdded(DataStoreEvent):
    schedule_id: str
    next_fire_time: datetime | None = attrs.field(converter=optional(as_aware_datetime))


@attrs.define(kw_only=True, frozen=True)
class ScheduleUpdated(DataStoreEvent):
    schedule_id: str
    next_fire_time: datetime | None = attrs.field(converter=optional(as_aware_datetime))


@attrs.define(kw_only=True, frozen=True)
class ScheduleRemoved(DataStoreEvent):
    schedule_id: str


@attrs.define(kw_only=True, frozen=True)
class JobAdded(DataStoreEvent):

# Path: src/apscheduler/converters.py
# def as_aware_datetime(value: datetime | str) -> datetime:
#     """Convert the value from a string to a timezone aware datetime."""
#     if isinstance(value, str):
#         # fromisoformat() does not handle the "Z" suffix
#         if value.upper().endswith('Z'):
#             value = value[:-1] + '+00:00'
# 
#         value = datetime.fromisoformat(value)
# 
#     return value
# 
# def as_uuid(value: UUID | str) -> UUID:
#     """Convert a string-formatted UUID to a UUID instance."""
#     if isinstance(value, str):
#         return UUID(value)
# 
#     return value
# 
# Path: src/apscheduler/enums.py
# class JobOutcome(Enum):
#     success = auto()
#     error = auto()
#     missed_start_deadline = auto()
#     cancelled = auto()
#     expired = auto()


# Path: src/apscheduler/events.py
from datetime import datetime, timezone
from functools import partial
from uuid import UUID
from attrs.converters import optional
from .converters import as_aware_datetime, as_uuid
from .enums import JobOutcome
import attrs


@attrs.define(kw_only=True, frozen=True)
class TaskUpdated(DataStoreEvent):
    task_id: str


@attrs.define(kw_only=True, frozen=True)
class TaskRemoved(DataStoreEvent):
    task_id: str


@attrs.define(kw_only=True, frozen=True)
class ScheduleAdded(DataStoreEvent):
    schedule_id: str
    next_fire_time: datetime | None = attrs.field(converter=optional(as_aware_datetime))


@attrs.define(kw_only=True, frozen=True)
class ScheduleUpdated(DataStoreEvent):
    schedule_id: str
    next_fire_time: datetime | None = attrs.field(converter=optional(as_aware_datetime))


@attrs.define(kw_only=True, frozen=True)
class ScheduleRemoved(DataStoreEvent):
    schedule_id: str


@attrs.define(kw_only=True, frozen=True)
class JobAdded(DataStoreEvent):

    job_id: UUID = attrs.field(converter=as_uuid)