2026-02-25 08:29:53 +02:00
|
|
|
from pydantic import BaseModel, Field, field_validator
|
2026-02-24 22:20:08 +02:00
|
|
|
|
|
|
|
|
from app.db import DocumentType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectorDocument(BaseModel):
|
2026-02-25 01:40:30 +02:00
|
|
|
"""Canonical data transfer object produced by connector adapters and consumed by the indexing pipeline."""
|
2026-02-26 13:00:31 -08:00
|
|
|
|
2026-02-24 22:20:08 +02:00
|
|
|
title: str
|
|
|
|
|
source_markdown: str
|
|
|
|
|
unique_id: str
|
|
|
|
|
document_type: DocumentType
|
refactor(backend): rename search_space -> workspace across app bulk (Phase 2 Wave D)
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.
2026-06-26 18:30:47 +02:00
|
|
|
workspace_id: int = Field(gt=0)
|
2026-02-24 22:20:08 +02:00
|
|
|
should_use_code_chunker: bool = False
|
|
|
|
|
metadata: dict = {}
|
2026-02-25 19:56:59 +02:00
|
|
|
connector_id: int | None = None
|
2026-02-25 08:29:53 +02:00
|
|
|
created_by_id: str
|
2026-04-08 17:48:50 +05:30
|
|
|
folder_id: int | None = None
|
2026-02-24 22:20:08 +02:00
|
|
|
|
2026-02-25 08:29:53 +02:00
|
|
|
@field_validator("title", "source_markdown", "unique_id", "created_by_id")
|
2026-02-24 22:20:08 +02:00
|
|
|
@classmethod
|
|
|
|
|
def not_empty(cls, v: str, info) -> str:
|
|
|
|
|
if not v.strip():
|
|
|
|
|
raise ValueError(f"{info.field_name} must not be empty or whitespace")
|
|
|
|
|
return v
|