feat: [US-002] - Define TypeScript types for flowchart data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
a5a2732ba5
commit
0440d632cd
@@ -0,0 +1,73 @@
|
||||
// Position type for node coordinates
|
||||
export type Position = {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
// DialogueNode type: represents character speech/dialogue
|
||||
export type DialogueNode = {
|
||||
id: string;
|
||||
type: 'dialogue';
|
||||
position: Position;
|
||||
data: {
|
||||
speaker?: string;
|
||||
text: string;
|
||||
};
|
||||
};
|
||||
|
||||
// Choice option type for ChoiceNode
|
||||
export type ChoiceOption = {
|
||||
id: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
// ChoiceNode type: represents branching decisions
|
||||
export type ChoiceNode = {
|
||||
id: string;
|
||||
type: 'choice';
|
||||
position: Position;
|
||||
data: {
|
||||
prompt: string;
|
||||
options: ChoiceOption[];
|
||||
};
|
||||
};
|
||||
|
||||
// VariableNode type: represents variable operations
|
||||
export type VariableNode = {
|
||||
id: string;
|
||||
type: 'variable';
|
||||
position: Position;
|
||||
data: {
|
||||
variableName: string;
|
||||
operation: 'set' | 'add' | 'subtract';
|
||||
value: number;
|
||||
};
|
||||
};
|
||||
|
||||
// Union type for all node types
|
||||
export type FlowchartNode = DialogueNode | ChoiceNode | VariableNode;
|
||||
|
||||
// Condition type for conditional edges
|
||||
export type Condition = {
|
||||
variableName: string;
|
||||
operator: '>' | '<' | '==' | '>=' | '<=' | '!=';
|
||||
value: number;
|
||||
};
|
||||
|
||||
// FlowchartEdge type: represents connections between nodes
|
||||
export type FlowchartEdge = {
|
||||
id: string;
|
||||
source: string;
|
||||
sourceHandle?: string;
|
||||
target: string;
|
||||
targetHandle?: string;
|
||||
data?: {
|
||||
condition?: Condition;
|
||||
};
|
||||
};
|
||||
|
||||
// FlowchartData type: represents the complete flowchart structure
|
||||
export type FlowchartData = {
|
||||
nodes: FlowchartNode[];
|
||||
edges: FlowchartEdge[];
|
||||
};
|
||||
Reference in New Issue
Block a user