/ src / features / dreamnode / types / dreamnode.ts
dreamnode.ts
  1  /**
  2   * DreamNode Types - Core data structures for InterBrain spatial visualization
  3   *
  4   * Based on Git-native architecture where each DreamNode is a Git repository
  5   * with explicit file path arrays stored in UDD (Universal Dream Description) files.
  6   */
  7  
  8  /**
  9   * Enhanced supermodule entry with historical tracking
 10   * Tracks which commit of the parent first included this as a dependency
 11   */
 12  export interface SupermoduleEntry {
 13    /** Radicle ID of the parent DreamNode */
 14    radicleId: string;
 15    /** Display title of the parent DreamNode */
 16    title: string;
 17    /** Commit hash in the parent repo when this was added as submodule */
 18    atCommit: string;
 19    /** Timestamp when this relationship was recorded */
 20    addedAt: number;
 21  }
 22  
 23  /**
 24   * Universal Dream Description (UDD) file structure
 25   * Stored as single .udd file in each DreamNode Git repository
 26   * Simplified schema optimized for performance and graph traversal
 27   */
 28  export interface UDDFile {
 29    /** Unique identifier - constant, never changes after creation */
 30    uuid: string;
 31  
 32    /** Display name/title of the DreamNode */
 33    title: string;
 34  
 35    /** Type of DreamNode - determines color coding and relationships */
 36    type: 'dream' | 'dreamer';
 37  
 38    /** Single file reference path for DreamTalk symbol (relative to repo root) */
 39    dreamTalk: string;
 40  
 41    /** Array of UUIDs for vertical holonic relationships - children */
 42    submodules: string[];
 43  
 44    /**
 45     * Supermodule relationships - parents that include this DreamNode as a submodule
 46     * Can be either legacy format (string UUIDs) or enhanced format (SupermoduleEntry[])
 47     * New entries should use SupermoduleEntry format for historical tracking
 48     */
 49    supermodules: (string | SupermoduleEntry)[];
 50  
 51    /** Optional contact email (for dreamer-type nodes) */
 52    email?: string;
 53  
 54    /** Optional contact phone number (for dreamer-type nodes) */
 55    phone?: string;
 56  
 57    /** Optional Radicle ID (RID) of this DreamNode's repository */
 58    radicleId?: string;
 59  
 60    /** Optional Radicle DID for peer identity (for dreamer-type nodes only) */
 61    did?: string;
 62  
 63    /** Optional GitHub repository URL for fallback sharing */
 64    githubRepoUrl?: string;
 65  
 66    /** Optional GitHub Pages URL for public DreamSong broadcast */
 67    githubPagesUrl?: string;
 68  }
 69  
 70  /**
 71   * Runtime DreamNode data structure for React components
 72   * Derived from UDD file + resolved file paths
 73   */
 74  export interface DreamNode {
 75    /** Unique identifier */
 76    id: string;
 77    
 78    /** Type determines visual styling */
 79    type: 'dream' | 'dreamer';
 80    
 81    /** Display name */
 82    name: string;
 83    
 84    /** Current position in 3D space */
 85    position: [number, number, number];
 86    
 87    /** Resolved media files for DreamTalk display */
 88    dreamTalkMedia: MediaFile[];
 89    
 90    /** Resolved canvas content for DreamSong display */
 91    dreamSongContent: CanvasFile[];
 92    
 93    /** Connected DreamNode IDs */
 94    liminalWebConnections: string[];
 95    
 96    /** Repository information */
 97    repoPath: string;
 98    
 99    /** Whether this node has unsaved changes */
100    hasUnsavedChanges: boolean;
101    
102    /** Git status information for visual indicators */
103    gitStatus?: GitStatus;
104  
105    /** Optional contact email (for dreamer-type nodes) */
106    email?: string;
107  
108    /** Optional contact phone number (for dreamer-type nodes) */
109    phone?: string;
110  
111    /** Optional Radicle ID (RID) of this DreamNode's repository */
112    radicleId?: string;
113  
114    /** Optional Radicle DID for peer identity (for dreamer-type nodes only) */
115    did?: string;
116  
117    /** Optional GitHub repository URL for fallback sharing */
118    githubRepoUrl?: string;
119  
120    /** Optional GitHub Pages URL for public DreamSong broadcast */
121    githubPagesUrl?: string;
122  }
123  
124  /**
125   * Media file with resolved content for DreamTalk symbols
126   */
127  export interface MediaFile {
128    /** File path relative to repo root */
129    path: string;
130    
131    /** Absolute file system path */
132    absolutePath: string;
133    
134    /** MIME type */
135    type: string;
136    
137    /** File contents as data URL or file path */
138    data: string;
139    
140    /** File size in bytes */
141    size: number;
142  }
143  
144  /**
145   * Obsidian canvas file for DreamSong content
146   */
147  export interface CanvasFile {
148    /** File path relative to repo root */
149    path: string;
150    
151    /** Absolute file system path */
152    absolutePath: string;
153    
154    /** Parsed canvas JSON content */
155    content: ObsidianCanvasData;
156  }
157  
158  /**
159   * Obsidian canvas file structure
160   * Based on Obsidian's native .canvas format
161   */
162  export interface ObsidianCanvasData {
163    nodes: CanvasNode[];
164    edges: CanvasEdge[];
165  }
166  
167  export interface CanvasNode {
168    id: string;
169    type: 'text' | 'file' | 'link' | 'group';
170    x: number;
171    y: number;
172    width: number;
173    height: number;
174    text?: string;
175    file?: string;
176    url?: string;
177    color?: string;
178  }
179  
180  export interface CanvasEdge {
181    id: string;
182    fromNode: string;
183    fromSide: 'top' | 'right' | 'bottom' | 'left';
184    toNode: string;
185    toSide: 'top' | 'right' | 'bottom' | 'left';
186    color?: string;
187    label?: string;
188  }
189  
190  /**
191   * Layout information for spatial positioning
192   */
193  export interface SpatialLayout {
194    /** Layout algorithm being used */
195    type: 'fibonacci-sphere' | 'honeycomb' | 'constellation' | 'focused';
196    
197    /** Center point of the layout */
198    center: [number, number, number];
199    
200    /** Scale factor for the layout */
201    scale: number;
202    
203    /** Additional layout-specific parameters */
204    params?: Record<string, unknown>;
205  }
206  
207  /**
208   * Git status information for visual indicators
209   */
210  export interface GitStatus {
211    /** Whether there are uncommitted changes (staged or unstaged) */
212    hasUncommittedChanges: boolean;
213    
214    /** Whether there are stashed changes */
215    hasStashedChanges: boolean;
216    
217    /** Whether there are unpushed commits (ahead of remote) */
218    hasUnpushedChanges: boolean;
219    
220    /** Last time git status was checked */
221    lastChecked: number;
222    
223    /** Optional detailed status information */
224    details?: {
225      staged?: number;
226      unstaged?: number;
227      untracked?: number;
228      stashCount?: number;
229      aheadCount?: number;
230      commitHash?: string;
231    };
232  }
233  
234  /**
235   * Visual state for LOD (Level of Detail) system
236   */
237  export interface VisualState {
238    /** Current level of detail */
239    lod: 'star' | 'node' | 'detailed';
240    
241    /** Scale factor based on distance from camera */
242    scale: number;
243    
244    /** Whether this node should billboard (always face camera) */
245    billboard: boolean;
246    
247    /** Distance from camera */
248    distanceFromCamera: number;
249    
250    /** Whether mouse is hovering over this node */
251    isHovered: boolean;
252    
253    /** Whether this node is currently selected */
254    isSelected: boolean;
255  }