Skip to content

base

base

DomoWorkflow_Tile dataclass

DomoWorkflow_Tile(
    id: str,
    tile_type: str,
    index: int,
    x: float = 0.0,
    y: float = 0.0,
    title: str | None = None,
    dimensions: dict | None = None,
    data: dict = dict(),
    raw: dict = dict(),
)

Base class for all workflow designElement tiles.

from_dict classmethod

from_dict(
    obj: dict[str, Any], index: int = 0
) -> DomoWorkflow_Tile

Dispatch to the registered subclass by type field.

Source code in src/crew_dcs/classes/DomoWorkflow/tile/base.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@classmethod
def from_dict(cls, obj: dict[str, Any], index: int = 0) -> DomoWorkflow_Tile:
    """Dispatch to the registered subclass by `type` field."""
    tile_type = obj.get("type", "EMPTY")

    if cls is DomoWorkflow_Tile:
        target_cls = _TILE_TYPE_REGISTRY.get(tile_type, DomoWorkflow_Tile_Unknown)
        return target_cls.from_dict(obj, index=index)

    data = obj.get("data") or {}
    position = obj.get("position") or {}

    instance = cls(
        id=obj.get("id", ""),
        tile_type=tile_type,
        index=index,
        x=position.get("x", 0.0),
        y=position.get("y", 0.0),
        title=data.get("title"),
        dimensions=data.get("dimensions"),
        data=data,
        raw=obj,
    )
    instance._extract_fields(data)
    return instance

to_dict

to_dict() -> dict[str, Any]

Serialize back to the designElement wire shape.

Source code in src/crew_dcs/classes/DomoWorkflow/tile/base.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def to_dict(self) -> dict[str, Any]:
    """Serialize back to the designElement wire shape."""
    data = dict(self.data)
    data["title"] = self.title
    data.pop("position", None)  # position lives at top-level, not inside data
    data["dimensions"] = self.dimensions or {"width": 200, "height": 60}
    out: dict[str, Any] = {
        "id": self.id,
        "type": self.tile_type,
        "position": {"x": self.x, "y": self.y},
        "data": data,
    }
    # Preserve cosmetic top-level fields from the original wire payload
    for key in ("style", "index"):
        if key in self.raw:
            out[key] = self.raw[key]
    return out

DomoWorkflow_Tile_Unknown dataclass

DomoWorkflow_Tile_Unknown(
    id: str,
    tile_type: str,
    index: int,
    x: float = 0.0,
    y: float = 0.0,
    title: str | None = None,
    dimensions: dict | None = None,
    data: dict = dict(),
    raw: dict = dict(),
)

Bases: DomoWorkflow_Tile

Fallback for tile types not yet registered.

register_tile_type

register_tile_type(tile_type: str)

Decorator that registers a DomoWorkflow_Tile subclass for a tile type string.

Source code in src/crew_dcs/classes/DomoWorkflow/tile/base.py
20
21
22
23
24
25
26
27
def register_tile_type(tile_type: str):
    """Decorator that registers a DomoWorkflow_Tile subclass for a tile type string."""

    def decorator(cls: type[DomoWorkflow_Tile]) -> type[DomoWorkflow_Tile]:
        _TILE_TYPE_REGISTRY[tile_type] = cls
        return cls

    return decorator