from __future__ import annotations from typing import Any, Optional, Literal, TypedDict, Generic, TypeVar, NotRequired, cast, TYPE_CHECKING from re import Pattern from datetime import date, datetime from decimal import Decimal from teo import ObjectId, Enumerable, File, Range, OptionVariant {% if namespace.path().len() > 0 %} {% if !namespace.is_std() %} if TYPE_CHECKING: from {{ dots(namespace.path().len()) }} import {{ root_module_name }} {% endif %} {% endif %} {%- for child in namespace.namespaces().values() %} from . import {{ child.name()|snakecase }} {%- if !child.is_std() %} from .{{ child.name()|snakecase }} import {{ child.name()|pascalcase }}Namespace {% endif %} {%- endfor %} {% for e in outline.enums() %} {{ e.name() }} = Literal[{{ e.joined_enum_variant_names_for_python() }}] {% endfor %} {% for interface in outline.interfaces() %} # **{{ interface.title() }}** # # {{ interface.desc() }} class {{ interface.name() }}{% if interface.generic_names().len() > 0 %}[{{interface.joined_generic_names()}}]{% endif %}({% for t in interface.extends() %}{{ lookup.call(fix_path(t.borrow(), namespace, root_module_name.as_str()).borrow()).unwrap() }}, {% endfor %}TypedDict): {% if interface.fields().is_empty() %} pass {% endif %} {% for field in interface.fields() %} # **{{ field.title() }}** # # {{ field.desc() }} {{ field.name()|escape_python }}: {{ typed_dict_not_required(lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow()).unwrap()) }} {% endfor %} {% endfor %} {% for model in namespace.models().values() %} {%- if model.generate_entity() %} class {{ model.name() }}Model: async def find_many_objects(self, query: {{ model.name() }}FindManyArgs, /) -> list[{{ model.name() }}]: return cast(Any, None) async def find_unique_object(self, query: {{ model.name() }}FindUniqueArgs, /) -> Optional[{{ model.name() }}]: return cast(Any, None) async def find_first_object(self, query: {{ model.name() }}FindFirstArgs, /) -> Optional[{{ model.name() }}]: return cast(Any, None) async def create_object(self, input: {{ model.name() }}CreateInput, /) -> {{ model.name() }}: return cast(Any, None) async def count_objects(self, query: {{ model.name() }}CountArgs, /) -> int: return cast(Any, None) async def count_fields(self, query: {{ model.name() }}CountArgs, /) -> {{ model.name() }}CountAggregateResult: return cast(Any, None) async def aggregate(self, query: {{ model.name() }}AggregateArgs, /) -> {{ model.name() }}AggregateResult: return cast(Any, None) async def group_by(self, query: {{ model.name() }}GroupByArgs, /) -> list[{{ model.name() }}AggregateResult]: return cast(Any, None) {% if namespace.database().is_some() && namespace.database().unwrap().is_sql() %} async def sql(self, sql: str) -> list[Any]: return cast(Any, None) {% endif %} class {{ model.name() }}: def is_new(self) -> bool: return cast(Any, None) def is_modified(self) -> bool: return cast(Any, None) async def set(self, input: {{ model.name() }}UpdateInput, /) -> None: return cast(Any, None) async def update(self, input: {{ model.name() }}ScalarUpdateInput, /) -> None: return cast(Any, None) async def save(self) -> None: return cast(Any, None) async def delete(self) -> None: return cast(Any, None) async def to_teon(self) -> {{ model.name() }}Result: return cast(Any, None) {%- for field in model.fields().values() %} {{ field.name()|snakecase|escape_python }}: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }} {%- endfor %} {%- for field in model.relations().values() %} {%- if field.type().is_array() %} async def {{ field.name()|snakecase|escape_python }}(self) -> {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}: return cast(Any, None) async def set_{{ field.name()|snakecase|escape_python }}(self, new_value: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}, /) -> None: return cast(Any, None) async def add_to_{{ field.name()|snakecase|escape_python }}(self, new_value: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}, /) -> None: return cast(Any, None) async def remove_from_{{ field.name()|snakecase|escape_python }}(self, new_value: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}, /) -> None: return cast(Any, None) {%- else %} async def {{ field.name()|snakecase|escape_python }}(self) -> {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}: return cast(Any, None) async def set_{{ field.name()|snakecase|escape_python }}(self, new_value: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}, /) -> None: return cast(Any, None) {%- endif %} {%- endfor %} {%- for field in model.properties().values() %} {%- if field.getter().is_some() %} async def {{ field.name()|snakecase|escape_python }}(self) -> {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}: return cast(Any, None) {%- endif %} {%- if field.setter().is_some() %} async def set_{{ field.name()|snakecase|escape_python }}(self, new_value: {{ lookup.call(fix_path(field.type().borrow(), namespace, root_module_name).borrow())? }}, /) -> None: return cast(Any, None) {%- endif %} {%- endfor %} {%- endif %} {% endfor %} {% for path_arguments in outline.path_arguments() %} class {{ path_arguments.name() }}(TypedDict): {% for item in path_arguments.items() %} {{ item|snakecase }}: str {% endfor %} {% endfor %} {%- if !namespace.is_std() %} class {% if namespace.is_main() %}Teo{% else %}{{ namespace.name()|capitalize }}Namespace{% endif %}: {% if namespace.is_main() %} async def transaction[T](self, teo: Teo, /) -> T: return cast(Any, None) {% endif %} {%- if namespace.models().is_empty() && namespace.namespaces().is_empty() && !namespace.is_main() %} pass {% endif %} {%- for model in namespace.models().values() %} {{ model.name()|snakecase|escape_python }}: {{ model.name() }}Model {%- endfor %} {%- for child in namespace.namespaces().values() %} {%- if !child.is_std() %} {{ child.name()|snakecase|escape_python }}: {{ child.name()|pascalcase }}Namespace {%- endif %} {%- endfor %} {%- endif %}