mirror of
https://github.com/OFFIS-ESC/constellation-analyzer
synced 2026-01-27 07:43:41 +00:00
158 lines
4.9 KiB
TypeScript
158 lines
4.9 KiB
TypeScript
import { Node, Edge } from '@xyflow/react';
|
|
|
|
// Node/Actor Types
|
|
export interface ActorData extends Record<string, unknown> {
|
|
label: string;
|
|
type: string;
|
|
description?: string;
|
|
labels?: string[]; // Array of LabelConfig IDs
|
|
citations?: string[]; // Array of bibliography reference IDs
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
export type Actor = Node<ActorData>;
|
|
|
|
// Edge/Relation Types
|
|
export type EdgeDirectionality = 'directed' | 'bidirectional' | 'undirected';
|
|
|
|
export interface RelationData extends Record<string, unknown> {
|
|
label?: string;
|
|
type: string;
|
|
directionality?: EdgeDirectionality;
|
|
strength?: number;
|
|
labels?: string[]; // Array of LabelConfig IDs
|
|
citations?: string[]; // Array of bibliography reference IDs
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
export type Relation = Edge<RelationData>;
|
|
|
|
// Node Shape Types
|
|
export type NodeShape =
|
|
| 'rectangle'
|
|
| 'circle'
|
|
| 'roundedRectangle'
|
|
| 'ellipse'
|
|
| 'pill';
|
|
|
|
// Node Type Configuration
|
|
export interface NodeTypeConfig {
|
|
id: string;
|
|
label: string;
|
|
color: string;
|
|
shape: NodeShape;
|
|
icon?: string;
|
|
description?: string;
|
|
}
|
|
|
|
// Edge Type Configuration
|
|
export interface EdgeTypeConfig {
|
|
id: string;
|
|
label: string;
|
|
color: string;
|
|
style?: 'solid' | 'dashed' | 'dotted';
|
|
description?: string;
|
|
defaultDirectionality?: EdgeDirectionality;
|
|
}
|
|
|
|
// Label Configuration
|
|
export type LabelScope = 'actors' | 'relations' | 'both';
|
|
|
|
export interface LabelConfig {
|
|
id: string;
|
|
name: string;
|
|
color: string;
|
|
appliesTo: LabelScope;
|
|
description?: string;
|
|
}
|
|
|
|
// Tangible Configuration
|
|
export type TangibleMode = 'filter' | 'state' | 'stateDial';
|
|
|
|
export interface TangibleConfig {
|
|
id: string; // Internal unique identifier (auto-generated from name)
|
|
name: string;
|
|
mode: TangibleMode;
|
|
description?: string;
|
|
hardwareId?: string; // Hardware token/device ID (editable, must be unique if present)
|
|
filterLabels?: string[]; // For filter mode: array of LabelConfig IDs
|
|
stateId?: string; // For state/stateDial mode: ConstellationState ID
|
|
}
|
|
|
|
// Group Types
|
|
export interface GroupData extends Record<string, unknown> {
|
|
label: string;
|
|
description?: string;
|
|
color: string;
|
|
actorIds: string[];
|
|
minimized?: boolean;
|
|
metadata?: Record<string, unknown>;
|
|
}
|
|
|
|
export type Group = Node<GroupData>;
|
|
|
|
// Graph State
|
|
export interface GraphState {
|
|
nodes: Actor[];
|
|
edges: Relation[];
|
|
groups: Group[];
|
|
nodeTypes: NodeTypeConfig[];
|
|
edgeTypes: EdgeTypeConfig[];
|
|
labels: LabelConfig[];
|
|
tangibles: TangibleConfig[];
|
|
}
|
|
|
|
// Editor Settings
|
|
export interface EditorSettings {
|
|
snapToGrid: boolean;
|
|
showGrid: boolean;
|
|
gridSize: number;
|
|
panOnDrag: boolean;
|
|
zoomOnScroll: boolean;
|
|
}
|
|
|
|
// Store Actions
|
|
export interface GraphActions {
|
|
addNode: (node: Actor) => void;
|
|
updateNode: (id: string, updates: Partial<Actor>) => void;
|
|
deleteNode: (id: string) => void;
|
|
addEdge: (edge: Relation) => void;
|
|
updateEdge: (id: string, data: Partial<RelationData>) => void;
|
|
deleteEdge: (id: string) => void;
|
|
addNodeType: (nodeType: NodeTypeConfig) => void;
|
|
updateNodeType: (id: string, updates: Partial<Omit<NodeTypeConfig, 'id'>>) => void;
|
|
deleteNodeType: (id: string) => void;
|
|
addEdgeType: (edgeType: EdgeTypeConfig) => void;
|
|
updateEdgeType: (id: string, updates: Partial<Omit<EdgeTypeConfig, 'id'>>) => void;
|
|
deleteEdgeType: (id: string) => void;
|
|
addLabel: (label: LabelConfig) => void;
|
|
updateLabel: (id: string, updates: Partial<Omit<LabelConfig, 'id'>>) => void;
|
|
deleteLabel: (id: string) => void;
|
|
addTangible: (tangible: TangibleConfig) => void;
|
|
updateTangible: (id: string, updates: Partial<Omit<TangibleConfig, 'id'>>) => void;
|
|
deleteTangible: (id: string) => void;
|
|
setTangibles: (tangibles: TangibleConfig[]) => void;
|
|
addGroup: (group: Group) => void;
|
|
updateGroup: (id: string, updates: Partial<GroupData>) => void;
|
|
deleteGroup: (id: string, ungroupActors?: boolean) => void;
|
|
addActorToGroup: (actorId: string, groupId: string) => void;
|
|
removeActorFromGroup: (actorId: string, groupId: string) => void;
|
|
toggleGroupMinimized: (groupId: string) => void;
|
|
clearGraph: () => void;
|
|
setNodes: (nodes: Actor[]) => void;
|
|
setEdges: (edges: Relation[]) => void;
|
|
setGroups: (groups: Group[]) => void;
|
|
setNodeTypes: (nodeTypes: NodeTypeConfig[]) => void;
|
|
setEdgeTypes: (edgeTypes: EdgeTypeConfig[]) => void;
|
|
setLabels: (labels: LabelConfig[]) => void;
|
|
// NOTE: exportToFile and importFromFile have been removed
|
|
// Import/export is now handled by the workspace-level system (workspaceStore)
|
|
loadGraphState: (data: { nodes: Actor[]; edges: Relation[]; groups?: Group[]; nodeTypes: NodeTypeConfig[]; edgeTypes: EdgeTypeConfig[]; labels?: LabelConfig[]; tangibles?: TangibleConfig[] }) => void;
|
|
}
|
|
|
|
export interface EditorActions {
|
|
updateSettings: (settings: Partial<EditorSettings>) => void;
|
|
}
|
|
|
|
// Re-export workspace types
|
|
export type { WorkspaceSettings } from '../stores/workspace/types';
|