from datetime import datetime
from typing import TypeVar, Union, Literal, Any
from uuid import uuid4

T = TypeVar("T")
R = TypeVar("R")

UuidId = Union[str, uuid4]
SerialId = Union[int]

Id = Union[UuidId, SerialId]

Iterable = Union[list[T], set[T], tuple[T]]

IntFilterOperator = Literal[
    "equal",
    "notEqual",
    "greater",
    "greaterOrEqual",
    "less",
    "lessOrEqual",
    "isNull",
    "isNotNull",
]
StringFilterOperator = Literal[
    "equal",
    "notEqual",
    "contains",
    "notContains",
    "startsWith",
    "endsWith",
    "isNull",
    "isNotNull",
]
BoolFilterOperator = Literal[
    "equal",
    "notEqual",
    "isNull",
    "isNotNull",
]
DateFilterOperator = Literal[
    "equal",
    "notEqual",
    "greater",
    "greaterOrEqual",
    "less",
    "lessOrEqual",
    "isNull",
    "isNotNull",
]
FilterOperator = Union[
    IntFilterOperator, StringFilterOperator, BoolFilterOperator, DateFilterOperator
]

Attribute = Union[str, property]

AttributeCondition = Union[
    dict[IntFilterOperator, int],
    dict[StringFilterOperator, str],
    dict[BoolFilterOperator, bool],
    dict[DateFilterOperator, datetime],
]
AttributeFilter = dict[
    Attribute, Union[list[Union[AttributeCondition, Any]], AttributeCondition, Any]
]
AttributeFilters = Union[
    list[AttributeFilter],
    AttributeFilter,
]

AttributeSort = dict[Attribute, Literal["asc", "desc"]]
AttributeSorts = Union[
    list[AttributeSort],
    AttributeSort,
]
