acupedia-api/app/features/content/domain.py

92 lines
2.0 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
from typing import Any
from uuid import UUID
@dataclass(frozen=True, slots=True)
class DefinitionSetRecord:
id: UUID
code: str
attribute_prefix_code: str
content_kind: str | None
@dataclass(frozen=True, slots=True)
class PresentationRecord:
id: UUID
attribute_definition_set_id: UUID
client_type: str
version_no: int
presentation_mode: str
collection_renderer: str | None
collection_item_renderer: str | None
detail_renderer: str
@dataclass(frozen=True, slots=True)
class AttributePresentationRecord:
presentation_contract_id: UUID
attribute_definition_id: UUID
attribute_definition_set_id: UUID
attribute_key: str
empty_behavior: str
empty_text: str | None
metadata_json: dict[str, Any]
@dataclass(frozen=True, slots=True)
class AttributeDefinitionRecord:
id: UUID
attribute_key: str
attribute_label: str
data_type: str | None
definition_kind: str
is_root: bool
is_searchable: bool
is_filterable: bool
is_multivalue: bool
allowed_values: list[Any] | None
sort_order: int
@property
def local_code(self) -> str:
return self.attribute_key.rsplit(".", 1)[-1]
@dataclass(frozen=True, slots=True)
class ModuleSearchDefinitionRecord:
id: UUID
template_code: str
template_name: str
attribute_key: str
attribute_label: str
data_type: str | None
definition_kind: str
is_root: bool
is_searchable: bool
is_filterable: bool
is_multivalue: bool
allowed_values: list[Any] | None
sort_order: int
visibility: str
@property
def local_code(self) -> str:
return self.attribute_key.rsplit(".", 1)[-1]
@dataclass(frozen=True, slots=True)
class ContentReferenceLookup:
module_code: str
template_code: str
source_key: str
@dataclass(frozen=True, slots=True)
class ResolvedContentReference:
lookup: ContentReferenceLookup
content_id: UUID