mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Scoped codemod over surfsense_backend/app (excluding routes/, Wave E): renames search_space_id -> workspace_id, search_space -> workspace, SearchSpace -> Workspace across services, utils, tasks, agents, gateway, event_bus, notifications, podcasts, automations, observability params, and prompt .md files. Also flips the camelCase payload key searchSpaceId -> workspaceId (no backend reader; hard cutover). Preserved carve-outs (verbatim): Celery task names "delete_search_space_background" and "ai_sort_search_space" (wire names), and the OTel/metric key "search_space.id" (dashboards depend on it). Enum values 'SEARCH_SPACE' and SearchSourceConnector untouched.
38 lines
1 KiB
Python
38 lines
1 KiB
Python
"""The ``Event`` value object — the only shape that crosses the bus.
|
|
|
|
An immutable fact: something named happened, with this payload, in this space,
|
|
at this time. JSON round-trippable so a subscriber can queue it to a worker.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
from datetime import UTC, datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
def _new_event_id() -> str:
|
|
return uuid.uuid4().hex
|
|
|
|
|
|
def _now() -> datetime:
|
|
return datetime.now(UTC)
|
|
|
|
|
|
class Event(BaseModel):
|
|
"""A published domain fact.
|
|
|
|
``event_type`` is a dotted namespace (``document.indexed``, etc). ``payload`` is
|
|
JSON-serializable. ``workspace_id`` scopes delivery. ``event_id`` and
|
|
``occurred_at`` are engine-stamped.
|
|
"""
|
|
|
|
model_config = ConfigDict(frozen=True)
|
|
|
|
event_type: str
|
|
payload: dict[str, Any] = Field(default_factory=dict)
|
|
workspace_id: int
|
|
event_id: str = Field(default_factory=_new_event_id)
|
|
occurred_at: datetime = Field(default_factory=_now)
|