-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Milestone
Description
Parent Epic
Part of #362 (Connection Graph Model - Port-Based Architecture)
Summary
Implement a connection store with CRUD operations and validation logic for port-based connections.
Acceptance Criteria
- Create
src/lib/stores/connection.svelte.ts -
addConnection(a_port_id, b_port_id, props)method -
updateConnection(id, updates)method -
removeConnection(id)method -
getConnection(id)method -
getConnectionsForPort(port_id)method -
getConnectionsForDevice(device_id)method - Validation: port can only have one connection (error)
- Validation: incompatible port types (warning)
- Validation: same connection class required
- Undo/redo support via raw operations
- Dirty state tracking
Validation Rules
- Single connection per port: Most ports allow only one connection. Error if already connected.
- Type compatibility: Warning if connecting mismatched types (e.g., RJ45 to SFP).
- Class match: Network ports only connect to network ports, power to power.
- Self-connection: Cannot connect a port to itself.
- Duplicate: Cannot create duplicate connection between same ports.
API
interface ConnectionStore {
// Getters
connections: Connection[];
getConnection(id: string): Connection | undefined;
getConnectionsForPort(portId: string): Connection[];
getConnectionsForDevice(deviceId: string): Connection[];
// CRUD
addConnection(input: CreateConnectionInput): { connection: Connection } | { errors: string[] };
updateConnection(id: string, updates: Partial<Connection>): { success: true } | { errors: string[] };
removeConnection(id: string): Connection | undefined;
removeConnectionsForDevice(deviceId: string): number;
// Raw operations (for undo/redo)
addConnectionRaw(connection: Connection): void;
updateConnectionRaw(id: string, updates: Partial<Connection>): void;
removeConnectionRaw(id: string): void;
// Validation
validateConnection(input: CreateConnectionInput): ValidationResult;
}Test Requirements
-
addConnectioncreates valid connection - Double-connecting a port raises error
- Type mismatch raises warning
- Self-connection raises error
- Duplicate connection raises error
-
removeConnectionsForDeviceremoves all connections for device - Undo/redo works for connection operations
- Dirty state updates on changes
Related
- Parent Epic: feat: Connection Graph Model - Phase 1: Port-Based Architecture #362
- Depends on: feat: PlacedPort schema and port instantiation #363 (PlacedPort), feat: Connection model refactor (port-ID based) #365 (Connection)
- Similar to: Cable store from PR feat: cable data model and schema (#261) #355 (refactored)