feat: [US-002] - Define TypeScript types for flowchart data

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2026-01-21 00:52:34 -03:00
parent a5a2732ba5
commit 0440d632cd
2 changed files with 75 additions and 1 deletions

View File

@ -6,7 +6,8 @@
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "eslint" "lint": "eslint",
"typecheck": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@supabase/ssr": "^0.8.0", "@supabase/ssr": "^0.8.0",

73
src/types/flowchart.ts Normal file
View File

@ -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[];
};