@mrck-labs/vanaheim-shared 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -42,8 +42,98 @@ var FREQUENCY_MULTIPLIERS = {
42
42
  weekly: 52,
43
43
  "one-time": 1
44
44
  };
45
+ var FREQUENCY_OPTIONS = [
46
+ { value: "monthly", label: "Monthly" },
47
+ { value: "yearly", label: "Yearly" },
48
+ { value: "6-monthly", label: "Every 6 Months" },
49
+ { value: "weekly", label: "Weekly" },
50
+ { value: "one-time", label: "One Time" }
51
+ ];
45
52
  var DEFAULT_FOCUS_DURATIONS = [15, 25, 30, 45, 60, 90];
46
53
  var FOCUS_STATUS = ["active", "completed", "abandoned"];
54
+ var HEALTH_FREQUENCY_TYPES = [
55
+ "daily",
56
+ "specific_days",
57
+ "times_per_week",
58
+ "times_per_month"
59
+ ];
60
+ var HEALTH_FREQUENCY_LABELS = {
61
+ daily: "Daily",
62
+ specific_days: "Specific Days",
63
+ times_per_week: "Times per Week",
64
+ times_per_month: "Times per Month"
65
+ };
66
+ var DAY_OPTIONS = [
67
+ { value: 0, label: "Sun" },
68
+ { value: 1, label: "Mon" },
69
+ { value: 2, label: "Tue" },
70
+ { value: 3, label: "Wed" },
71
+ { value: 4, label: "Thu" },
72
+ { value: 5, label: "Fri" },
73
+ { value: 6, label: "Sat" }
74
+ ];
75
+ var PRESET_COLORS = [
76
+ "#10B981",
77
+ // Emerald
78
+ "#3B82F6",
79
+ // Blue
80
+ "#F59E0B",
81
+ // Amber
82
+ "#EF4444",
83
+ // Red
84
+ "#8B5CF6",
85
+ // Purple
86
+ "#EC4899",
87
+ // Pink
88
+ "#14B8A6",
89
+ // Teal
90
+ "#F97316",
91
+ // Orange
92
+ "#6366F1",
93
+ // Indigo
94
+ "#84CC16"
95
+ // Lime
96
+ ];
97
+ var PRESET_ICONS = [
98
+ "\u{1F4DD}",
99
+ // Writing/Notes
100
+ "\u{1F4BB}",
101
+ // Coding/Tech
102
+ "\u{1F3A8}",
103
+ // Design/Art
104
+ "\u{1F4CA}",
105
+ // Analytics/Data
106
+ "\u{1F527}",
107
+ // Tools/Settings
108
+ "\u{1F4DA}",
109
+ // Learning/Docs
110
+ "\u{1F4A1}",
111
+ // Ideas/Lightbulb
112
+ "\u{1F680}",
113
+ // Launch/Start
114
+ "\u26A1",
115
+ // Fast/Energy
116
+ "\u{1F3AF}",
117
+ // Target/Goal
118
+ "\u{1F48A}",
119
+ // Health/Medicine
120
+ "\u{1F957}",
121
+ // Food/Diet
122
+ "\u{1F4A7}",
123
+ // Water/Hydration
124
+ "\u{1F3C3}",
125
+ // Exercise/Running
126
+ "\u{1F634}",
127
+ // Sleep/Rest
128
+ "\u{1F9D8}",
129
+ // Meditation/Mindfulness
130
+ "\u{1F4AA}",
131
+ // Strength/Fitness
132
+ "\u{1F34E}",
133
+ // Health/Food
134
+ "\u{1F517}"
135
+ // Links/Connections
136
+ ];
47
137
  var LINEAR_PRIORITIES = [0, 1, 2, 3, 4];
48
138
  var LINEAR_PRIORITY_COLORS = {
49
139
  0: "#6b7280",
@@ -309,6 +399,69 @@ function calculateFocusStats(sessions) {
309
399
  };
310
400
  }
311
401
 
402
+ // src/utils/health.ts
403
+ function parseFrequencyConfig(config) {
404
+ if (!config) return null;
405
+ try {
406
+ return JSON.parse(config);
407
+ } catch {
408
+ return null;
409
+ }
410
+ }
411
+ function stringifyFrequencyConfig(config) {
412
+ if (!config) return null;
413
+ return JSON.stringify(config);
414
+ }
415
+ function getFrequencyDescription(habit) {
416
+ const config = parseFrequencyConfig(habit.frequencyConfig);
417
+ switch (habit.frequencyType) {
418
+ case "daily":
419
+ return "Every day";
420
+ case "specific_days": {
421
+ if (!config?.days) return "Specific days";
422
+ const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
423
+ return config.days.map((d) => dayNames[d]).join(", ");
424
+ }
425
+ case "times_per_week":
426
+ return `${config?.target || 1}x per week`;
427
+ case "times_per_month":
428
+ return `${config?.target || 1}x per month`;
429
+ default:
430
+ return "Unknown";
431
+ }
432
+ }
433
+ function shouldDoOnDate(habit, date) {
434
+ const dayOfWeek = date.getDay();
435
+ switch (habit.frequencyType) {
436
+ case "daily":
437
+ return true;
438
+ case "specific_days": {
439
+ const config = parseFrequencyConfig(habit.frequencyConfig);
440
+ return config?.days?.includes(dayOfWeek) ?? false;
441
+ }
442
+ case "times_per_week":
443
+ case "times_per_month":
444
+ return true;
445
+ default:
446
+ return true;
447
+ }
448
+ }
449
+ function shouldDoToday(habit) {
450
+ return shouldDoOnDate(habit, /* @__PURE__ */ new Date());
451
+ }
452
+ function calculateWeeklyProgress(habit, weekCompletionCount) {
453
+ const config = parseFrequencyConfig(habit.frequencyConfig);
454
+ const target = config?.target ?? 1;
455
+ const completed = weekCompletionCount;
456
+ return {
457
+ habit,
458
+ target,
459
+ completed,
460
+ remaining: Math.max(0, target - completed),
461
+ isComplete: completed >= target
462
+ };
463
+ }
464
+
312
465
  // src/query/index.ts
313
466
  var queryKeys = {
314
467
  // -------------------------------------------------------------------------
@@ -535,6 +688,94 @@ var queryKeys = {
535
688
  all: ["linear"],
536
689
  issues: (filters) => [...queryKeys.linear.all, "issues", filters],
537
690
  projects: () => [...queryKeys.linear.all, "projects"]
691
+ },
692
+ // -------------------------------------------------------------------------
693
+ // Nutrition Module
694
+ // -------------------------------------------------------------------------
695
+ ingredients: {
696
+ all: ["ingredients"],
697
+ lists: () => [...queryKeys.ingredients.all, "list"],
698
+ list: (filters) => [...queryKeys.ingredients.lists(), filters],
699
+ detail: (id) => [...queryKeys.ingredients.all, "detail", id]
700
+ },
701
+ recipes: {
702
+ all: ["recipes"],
703
+ lists: () => [...queryKeys.recipes.all, "list"],
704
+ list: (filters) => [...queryKeys.recipes.lists(), filters],
705
+ detail: (id) => [...queryKeys.recipes.all, "detail", id]
706
+ },
707
+ foodLogs: {
708
+ all: ["foodLogs"],
709
+ lists: () => [...queryKeys.foodLogs.all, "list"],
710
+ list: (filters) => [...queryKeys.foodLogs.lists(), filters],
711
+ forDate: (date) => [...queryKeys.foodLogs.all, "date", date]
712
+ },
713
+ nutritionGoals: {
714
+ all: ["nutritionGoals"],
715
+ active: () => [...queryKeys.nutritionGoals.all, "active"]
716
+ },
717
+ nutritionStats: {
718
+ all: ["nutritionStats"],
719
+ forDate: (date) => [...queryKeys.nutritionStats.all, date]
720
+ },
721
+ // -------------------------------------------------------------------------
722
+ // Planning Module - Daily Plans
723
+ // -------------------------------------------------------------------------
724
+ dailyPlans: {
725
+ all: ["dailyPlans"],
726
+ forDate: (date) => [...queryKeys.dailyPlans.all, date],
727
+ forRange: (startDate, endDate) => [...queryKeys.dailyPlans.all, "range", startDate, endDate]
728
+ },
729
+ // -------------------------------------------------------------------------
730
+ // Planning Module - Meal Plans
731
+ // -------------------------------------------------------------------------
732
+ mealPlans: {
733
+ all: ["mealPlans"],
734
+ lists: () => [...queryKeys.mealPlans.all, "list"],
735
+ forDate: (date) => [...queryKeys.mealPlans.all, "date", date],
736
+ forRange: (startDate, endDate) => [...queryKeys.mealPlans.all, "range", startDate, endDate],
737
+ detail: (id) => [...queryKeys.mealPlans.all, "detail", id]
738
+ },
739
+ // -------------------------------------------------------------------------
740
+ // Planning Module - Prep Sessions
741
+ // -------------------------------------------------------------------------
742
+ prepSessions: {
743
+ all: ["prepSessions"],
744
+ lists: () => [...queryKeys.prepSessions.all, "list"],
745
+ forDate: (date) => [...queryKeys.prepSessions.all, "date", date],
746
+ forRange: (startDate, endDate) => [...queryKeys.prepSessions.all, "range", startDate, endDate],
747
+ detail: (id) => [...queryKeys.prepSessions.all, "detail", id]
748
+ },
749
+ // -------------------------------------------------------------------------
750
+ // Planning Module - Grocery List
751
+ // -------------------------------------------------------------------------
752
+ groceryList: {
753
+ all: ["groceryList"],
754
+ forWeek: (weekStart, weekEnd) => [...queryKeys.groceryList.all, weekStart, weekEnd]
755
+ },
756
+ // -------------------------------------------------------------------------
757
+ // Planning Module - Weekly Plans
758
+ // -------------------------------------------------------------------------
759
+ weeklyPlans: {
760
+ all: ["weeklyPlans"],
761
+ forWeek: (weekStart) => [...queryKeys.weeklyPlans.all, weekStart],
762
+ forRange: (startWeek, endWeek) => [...queryKeys.weeklyPlans.all, "range", startWeek, endWeek]
763
+ },
764
+ // -------------------------------------------------------------------------
765
+ // Planning Module - Notes
766
+ // -------------------------------------------------------------------------
767
+ noteFolders: {
768
+ all: ["noteFolders"],
769
+ list: () => [...queryKeys.noteFolders.all, "list"],
770
+ detail: (id) => [...queryKeys.noteFolders.all, "detail", id]
771
+ },
772
+ notes: {
773
+ all: ["notes"],
774
+ lists: () => [...queryKeys.notes.all, "list"],
775
+ list: (filters) => [...queryKeys.notes.lists(), filters],
776
+ detail: (id) => [...queryKeys.notes.all, "detail", id],
777
+ pinned: () => [...queryKeys.notes.all, "pinned"],
778
+ recent: () => [...queryKeys.notes.all, "recent"]
538
779
  }
539
780
  };
540
781
 
@@ -695,6 +936,17 @@ function formatTimeHHMM(date) {
695
936
  const d = typeof date === "string" ? new Date(date) : date;
696
937
  return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
697
938
  }
939
+ function formatTimeShort(date) {
940
+ const d = typeof date === "string" ? new Date(date) : date;
941
+ return d.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
942
+ }
943
+ function formatDateDisplay(date) {
944
+ return date.toLocaleDateString("en-US", {
945
+ weekday: "long",
946
+ month: "short",
947
+ day: "numeric"
948
+ });
949
+ }
698
950
  function formatTimeWithSeconds(date) {
699
951
  const d = typeof date === "string" ? new Date(date) : date;
700
952
  return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
@@ -827,14 +1079,20 @@ export {
827
1079
  CURRENCIES,
828
1080
  CURRENCY_NAMES,
829
1081
  CURRENCY_SYMBOLS,
1082
+ DAY_OPTIONS,
830
1083
  DEFAULT_FOCUS_DURATIONS,
831
1084
  FOCUS_STATUS,
832
1085
  FREQUENCIES,
833
1086
  FREQUENCY_LABELS,
834
1087
  FREQUENCY_MULTIPLIERS,
1088
+ FREQUENCY_OPTIONS,
1089
+ HEALTH_FREQUENCY_LABELS,
1090
+ HEALTH_FREQUENCY_TYPES,
835
1091
  LINEAR_PRIORITIES,
836
1092
  LINEAR_PRIORITY_COLORS,
837
1093
  LINEAR_PRIORITY_LABELS,
1094
+ PRESET_COLORS,
1095
+ PRESET_ICONS,
838
1096
  SETTING_KEYS,
839
1097
  activeSessionAtom,
840
1098
  addDays,
@@ -844,9 +1102,11 @@ export {
844
1102
  calculateMonthlyIncome,
845
1103
  calculateMonthlySavings,
846
1104
  calculateSavingsRate,
1105
+ calculateWeeklyProgress,
847
1106
  elapsedSecondsAtom,
848
1107
  formatCurrency,
849
1108
  formatDate,
1109
+ formatDateDisplay,
850
1110
  formatDateHeader,
851
1111
  formatDateLocalized,
852
1112
  formatDateLong,
@@ -863,6 +1123,7 @@ export {
863
1123
  formatTime,
864
1124
  formatTimeHHMM,
865
1125
  formatTimeLocalized,
1126
+ formatTimeShort,
866
1127
  formatTimeWithSeconds,
867
1128
  formatTotalTime,
868
1129
  formatWeekRange,
@@ -872,6 +1133,7 @@ export {
872
1133
  generateRandomColor,
873
1134
  generateShortId,
874
1135
  getEndOfDayISO,
1136
+ getFrequencyDescription,
875
1137
  getNextWeek,
876
1138
  getPreviousWeek,
877
1139
  getRepoName,
@@ -895,11 +1157,15 @@ export {
895
1157
  isValidISODate,
896
1158
  isValidUrl,
897
1159
  normalizeToMidnight,
1160
+ parseFrequencyConfig,
898
1161
  parseLocalDate,
899
1162
  progressAtom,
900
1163
  progressPercentAtom,
901
1164
  queryKeys,
902
1165
  remainingSecondsAtom,
1166
+ shouldDoOnDate,
1167
+ shouldDoToday,
1168
+ stringifyFrequencyConfig,
903
1169
  subtractDays,
904
1170
  targetSecondsAtom,
905
1171
  timerStatusAtom,