- Add ia_dev submodule (projects/smart_ide on forge 4nk) - Document APIs, orchestrator, gateway, local-office, rollout - Add systemd/scripts layout; relocate setup scripts - Remove obsolete nginx/enso-only docs from this repo scope
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""Request/response schemas."""
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class CommandItem(BaseModel):
|
|
"""One command: type + params."""
|
|
type: str = Field(..., description="replaceText | insertParagraph | ...")
|
|
search: str | None = None
|
|
replace: str | None = None
|
|
text: str | None = None
|
|
position: str | None = None
|
|
|
|
|
|
class CommandsRequest(BaseModel):
|
|
"""Body for POST /documents/:id/commands."""
|
|
commands: list[CommandItem] = Field(..., min_length=1)
|
|
|
|
|
|
def commands_to_dicts(items: list[CommandItem]) -> list[dict[str, Any]]:
|
|
"""Convert to list of dicts for engine (only non-null fields)."""
|
|
out: list[dict[str, Any]] = []
|
|
for c in items:
|
|
d: dict[str, Any] = {"type": c.type}
|
|
if c.search is not None:
|
|
d["search"] = c.search
|
|
if c.replace is not None:
|
|
d["replace"] = c.replace
|
|
if c.text is not None:
|
|
d["text"] = c.text
|
|
if c.position is not None:
|
|
d["position"] = c.position
|
|
out.append(d)
|
|
return out
|