from __future__ import annotations
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import xml.etree.ElementTree as ET


@dataclass
class FieldDef:
    name: str
    type: str
    size: Optional[int] = None
    source: Optional[str] = None


@dataclass
class NodeDef:
    tool_id: int
    plugin: str
    config: Optional[ET.Element]
    output_schema: List[FieldDef] = field(default_factory=list)
    position: tuple = (0, 0)


@dataclass
class ConnectionDef:
    origin_id: int
    origin_anchor: str
    dest_id: int
    dest_anchor: str
    name: Optional[str] = None
    wireless: bool = False


@dataclass
class WorkflowGraph:
    nodes: Dict[int, NodeDef]
    connections: List[ConnectionDef]
    properties: Optional[ET.Element]
