diff --git a/packages/storage/src/models.ts b/packages/storage/src/models.ts new file mode 100644 index 0000000..eb2c3d5 --- /dev/null +++ b/packages/storage/src/models.ts @@ -0,0 +1,120 @@ +/** + * TypeScript models for GlowTrack data structures + * + * Based on the data model specification for mood and habit tracking + * with wellbeing grid visualization. + */ + +/** + * Color blind accessibility modes supported by the application + */ +export type ColorBlindMode = 'none' | 'protanopia' | 'deuteranopia' | 'tritanopia'; + +/** + * Type of habit entry - positive contributes to wellbeing, negative detracts + */ +export type HabitType = 'positive' | 'negative'; + +/** + * Settings for PNG export functionality + */ +export interface ExportSettings { + /** Scale factor for PNG export (1.0 = screen resolution) */ + pngScale: number; + /** Whether to include legend in exported PNG */ + includeLegend: boolean; +} + +/** + * Configuration settings for the wellbeing grid + */ +export interface GridSettings { + /** Start date for the grid view (ISO date YYYY-MM-DD) */ + startDate: string; + /** End date for the grid view (ISO date YYYY-MM-DD) */ + endDate: string; + /** Theme palette identifier */ + theme: string; + /** Color blind accessibility mode */ + colorBlindMode: ColorBlindMode; + /** Export configuration */ + export: ExportSettings; +} + +/** + * Mood state for a specific day + */ +export interface Mood { + /** Hue value (0-360 degrees) */ + hue: number; + /** Intensity level (0-1) */ + intensity: number; + /** Optional note about the mood */ + note?: string; +} + +/** + * Definition of a habit that can be tracked + */ +export interface HabitDefinition { + /** Unique identifier for the habit */ + id: string; + /** Type of habit (positive or negative) */ + type: HabitType; + /** Display label for the habit */ + label: string; + /** Optional icon identifier for UI glyphs */ + icon?: string; + /** Default weight for new entries of this habit */ + defaultWeight: number; + /** Whether this habit is archived (no longer actively tracked) */ + archived: boolean; +} + +/** + * A single habit entry for a specific day + */ +export interface HabitEntry { + /** Unique identifier for this entry */ + id: string; + /** Type of habit entry */ + type: HabitType; + /** Reference to the habit definition */ + habitId: string; + /** Display label (may differ from habit definition) */ + label: string; + /** Weight of this entry (always positive, type determines sign for net score) */ + weight: number; + /** When this entry was created */ + timestamp: string; +} + +/** + * Data for a single day tile in the wellbeing grid + */ +export interface DayTile { + /** Date for this tile (ISO date YYYY-MM-DD) */ + date: string; + /** Mood state for this day */ + mood: Mood; + /** Habit entries for this day */ + entries: HabitEntry[]; + /** Derived net score: sum(positive weights) - sum(negative weights) */ + netScore: number; +} + +/** + * Complete wellbeing grid data structure + */ +export interface WellbeingGrid { + /** Stable unique identifier for this grid */ + id: string; + /** When this grid was created (ISO datetime) */ + createdAt: string; + /** When this grid was last updated (ISO datetime) */ + updatedAt: string; + /** Grid configuration settings */ + settings: GridSettings; + /** Day tiles that make up the grid */ + days: DayTile[]; +} diff --git a/specs/001-glowtrack-a-mood/tasks.md b/specs/001-glowtrack-a-mood/tasks.md index 2bd8ccf..c776ac9 100644 --- a/specs/001-glowtrack-a-mood/tasks.md +++ b/specs/001-glowtrack-a-mood/tasks.md @@ -111,7 +111,7 @@ Integration scenarios from quickstart.md → e2e smoke tests [P] ## Phase 3.3: Core Implementation (only after tests are failing) From data-model.md → model creation tasks [P] -- [ ] T016 [P] Define TypeScript models +- [X] T016 [P] Define TypeScript models - Create /home/jawz/Development/Projects/GlowTrack/packages/storage/src/models.ts - Export interfaces: WellbeingGrid, GridSettings, ExportSettings, DayTile, Mood, HabitEntry, HabitDefinition - Dependencies: T009-T015 (tests exist), T003