|
5 | 5 | from dishka import FromDishka |
6 | 6 | from dishka.integrations.fastapi import DishkaRoute, inject |
7 | 7 | from fastapi import APIRouter, Depends, Header, HTTPException, Path, Query, Request |
8 | | -from pydantic import TypeAdapter |
9 | 8 |
|
10 | 9 | from app.api.dependencies import admin_user, current_user |
11 | 10 | from app.core.tracing import EventAttributes, add_span_attributes |
12 | 11 | from app.core.utils import get_client_ip |
13 | 12 | from app.domain.enums.events import EventType |
14 | 13 | from app.domain.enums.execution import ExecutionStatus |
15 | 14 | from app.domain.enums.user import UserRole |
16 | | -from app.domain.events.typed import BaseEvent, EventMetadata |
| 15 | +from app.domain.events.typed import BaseEvent, DomainEvent, EventMetadata |
17 | 16 | from app.domain.exceptions import DomainError |
18 | | -from app.schemas_pydantic.events import EventResponse |
19 | 17 | from app.schemas_pydantic.execution import ( |
20 | 18 | CancelExecutionRequest, |
21 | 19 | CancelResponse, |
|
36 | 34 | from app.services.kafka_event_service import KafkaEventService |
37 | 35 | from app.settings import Settings |
38 | 36 |
|
39 | | -_event_list_adapter: TypeAdapter[list[EventResponse]] = TypeAdapter(list[EventResponse]) |
40 | | - |
41 | 37 | router = APIRouter(route_class=DishkaRoute, tags=["execution"]) |
42 | 38 |
|
43 | 39 |
|
@@ -234,18 +230,18 @@ async def retry_execution( |
234 | 230 | return ExecutionResponse.model_validate(new_result) |
235 | 231 |
|
236 | 232 |
|
237 | | -@router.get("/executions/{execution_id}/events", response_model=list[EventResponse]) |
| 233 | +@router.get("/executions/{execution_id}/events", response_model=list[DomainEvent]) |
238 | 234 | async def get_execution_events( |
239 | 235 | execution: Annotated[ExecutionInDB, Depends(get_execution_with_access)], |
240 | 236 | event_service: FromDishka[EventService], |
241 | 237 | event_types: list[EventType] | None = Query(None, description="Event types to filter"), |
242 | 238 | limit: int = Query(100, ge=1, le=1000), |
243 | | -) -> list[EventResponse]: |
| 239 | +) -> list[DomainEvent]: |
244 | 240 | """Get all events for an execution.""" |
245 | 241 | events = await event_service.get_events_by_aggregate( |
246 | 242 | aggregate_id=execution.execution_id, event_types=event_types, limit=limit |
247 | 243 | ) |
248 | | - return _event_list_adapter.validate_python([e.model_dump() for e in events]) |
| 244 | + return events |
249 | 245 |
|
250 | 246 |
|
251 | 247 | @router.get("/user/executions", response_model=ExecutionListResponse) |
|
0 commit comments