43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
from dataclasses import dataclass
|
|
from pydantic import UUID7
|
|
from typing import Literal, TypeVar
|
|
from collections.abc import Iterator
|
|
|
|
'''
|
|
CollectionName provides the list of all allowed collections!
|
|
'''
|
|
CollectionName = Literal["system", "entity", "committee", "committee_edition", "guild"]
|
|
|
|
C = TypeVar("C", bound=str)
|
|
|
|
@dataclass(slots=True)
|
|
class Ref[C: str]:
|
|
uuid: UUID7
|
|
collection_name: C
|
|
|
|
@dataclass(slots=True)
|
|
class RefList[C: str]:
|
|
uuids: list[UUID7]
|
|
collection_name: C
|
|
|
|
def __iter__(self) -> Iterator[UUID7]:
|
|
return iter(self.uuids)
|
|
|
|
def __contains__(self, item: UUID7) -> bool:
|
|
return item in self.uuids
|
|
|
|
SystemRef = Ref[Literal["system"]]
|
|
SystemRefList = RefList[Literal["system"]]
|
|
|
|
EntityRef = Ref[Literal["entity"]]
|
|
EntityRefList = RefList[Literal["entity"]]
|
|
|
|
CommitteeRef = Ref[Literal["committee"]]
|
|
CommitteeRefList = RefList[Literal["committee"]]
|
|
|
|
CommitteeEditionRef = Ref[Literal["committee_edition"]]
|
|
CommitteeEditionRefList = RefList[Literal["committee_edition"]]
|
|
|
|
GuildRef = Ref[Literal["guild"]]
|
|
GuildRefList = RefList[Literal["guild"]]
|