Carry over the lab 2 solution

Bring the application, own tests, Dockerfile, toolchain, compose
stack, migrations, secret generator, restart hook, evidence scripts and
CI job from the lab 2 solution commit 8cddb09 unchanged, merge the lab
2 Makefile targets into the lab 3 skeleton Makefile without touching
its targets, and append the lab 2 solution variables to the skeleton
.env.example. The package version follows the contract version 1.3.0.

This is the starting point of the lab 3 cycle: lint, own tests and the
offline skeleton check pass before any lab 3 change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-28 11:26:15 +03:00
co-authored by Claude Opus 5.5
parent 0ec2f9dae3
commit 416ce4f9db
111 changed files with 7066 additions and 1 deletions
@@ -0,0 +1,72 @@
from collections.abc import Callable
from datetime import datetime
from typing import Annotated, Self
from uuid import UUID
from pydantic import BaseModel, ConfigDict, Field
from messenger.messaging.application.queries import Page
from messenger.messaging.domain.models import Chat, Message
STRICT = ConfigDict(extra="forbid", strict=True)
class CreateChatRequest(BaseModel):
model_config = STRICT
title: str
member_ids: list[Annotated[UUID, Field(strict=False)]]
class CreateMessageRequest(BaseModel):
model_config = STRICT
text: str
class PageQuery(BaseModel):
limit: int = Field(default=50, ge=1, le=100)
cursor: str | None = None
class ChatOut(BaseModel):
id: UUID
title: str
member_ids: tuple[UUID, ...]
created_at: datetime
@classmethod
def of(cls, chat: Chat) -> ChatOut:
return cls(
id=chat.id,
title=chat.title.value,
member_ids=chat.member_ids,
created_at=chat.created_at,
)
class MessageOut(BaseModel):
id: UUID
chat_id: UUID
sender_id: UUID
text: str
created_at: datetime
@classmethod
def of(cls, message: Message) -> MessageOut:
return cls(
id=message.id,
chat_id=message.chat_id,
sender_id=message.sender_id,
text=message.text.value,
created_at=message.created_at,
)
class PageOut[ItemT](BaseModel):
items: list[ItemT]
next_cursor: str | None
@classmethod
def of[SourceT](cls, page: Page[SourceT], view: Callable[[SourceT], ItemT]) -> Self:
return cls(items=[view(item) for item in page.items], next_cursor=page.next_cursor)