@dgpholdings/greatoak-shared 1.2.69 → 1.2.71

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.
@@ -1,6 +1,5 @@
1
1
  export declare const AI_FITNESS_GOALS: readonly ["strength", "hypertrophy", "fat_loss", "endurance", "mobility", "rehabilitation", "sport_performance", "general_fitness", "core_strength"];
2
2
  export type TAiFitnessGoal = (typeof AI_FITNESS_GOALS)[number];
3
- export declare const AI_FITNESS_GOAL_LABELS: Record<TAiFitnessGoal, string>;
4
3
  export declare const AI_EQUIPMENT_TYPES: readonly ["none", "dumbbell", "barbell", "resistance_band", "cable_machine", "standard_machine", "suspension_trainer", "pull_up_bar", "bench", "kettlebell", "niche_machine", "exercise_ball", "ez_bar", "cardio_machine", "smith_machine", "weight_plate", "jump_rope", "battle_ropes", "medicine_ball", "ab_wheel", "plyo_box", "parallel_bars"];
5
4
  export type TAiEquipmentType = (typeof AI_EQUIPMENT_TYPES)[number];
6
5
  export declare const AI_HOME_EQUIPMENT: TAiEquipmentType[];
@@ -13,7 +12,7 @@ export declare const AI_CORE_PATTERNS: TAiMovementPattern[];
13
12
  export declare const AI_WORKOUT_PLACEMENTS: readonly ["primary_compound", "secondary_compound", "accessory", "finisher", "warmup", "cooldown"];
14
13
  export type TAiWorkoutPlacement = (typeof AI_WORKOUT_PLACEMENTS)[number];
15
14
  export declare const AI_SESSION_ORDER: TAiWorkoutPlacement[];
16
- export declare const AI_DIFFICULTY_LEVELS: readonly ["beginner", "intermediate", "advanced", "expert"];
15
+ declare const AI_DIFFICULTY_LEVELS: readonly ["beginner", "intermediate", "advanced", "expert"];
17
16
  export type TAiDifficultyLevel = (typeof AI_DIFFICULTY_LEVELS)[number];
18
17
  export declare const AI_FITNESS_LEVELS: readonly ["beginner", "intermediate", "advanced"];
19
18
  export type TAiFitnessLevel = (typeof AI_FITNESS_LEVELS)[number];
@@ -28,14 +27,11 @@ export declare const AI_MET_THRESHOLDS: {
28
27
  };
29
28
  export declare const AI_BODY_AREAS: readonly ["lower back", "upper back", "shoulders", "neck", "elbows", "wrists", "hips", "hip flexors", "knees", "ankles", "hamstrings", "achilles tendon", "forearms", "groin", "calf muscles", "chest", "core"];
30
29
  export type TAiBodyArea = (typeof AI_BODY_AREAS)[number];
31
- export declare const AI_BODY_AREA_LABELS: Record<TAiBodyArea, string>;
32
30
  export declare const AI_BODY_ISSUE_TYPES: readonly ["general_soreness", "joint_pain", "old_injury", "diagnosed_condition"];
33
31
  export type TAiBodyIssueType = (typeof AI_BODY_ISSUE_TYPES)[number];
34
- export declare const AI_BODY_ISSUE_LABELS: Record<TAiBodyIssueType, string>;
35
32
  export declare const AI_POPULAR_THRESHOLD = 75;
36
33
  export declare const AI_INJURY_SEVERITY: readonly ["mild", "moderate", "severe", "acute_broken"];
37
34
  export type TAiInjurySeverity = (typeof AI_INJURY_SEVERITY)[number];
38
- export declare const AI_INJURY_SEVERITY_LABELS: Record<TAiInjurySeverity, string>;
39
35
  export declare const AI_INJURY_DURATION: readonly ["1_5_days", "1_4_weeks", "1_3_months", "3_6_months", "6_plus_months"];
40
36
  export type TAiInjuryDuration = (typeof AI_INJURY_DURATION)[number];
41
37
  export declare const AI_INJURY_DURATION_LABELS: Record<TAiInjuryDuration, string>;
@@ -61,8 +57,8 @@ export interface TAiUserProfile {
61
57
  onboardingCompletedAt: string;
62
58
  onboardingVersion: string;
63
59
  }
64
- export declare const AI_SLEEP_QUALITY_OPTIONS: readonly ["good", "disturbed", "poor"];
65
- export type TAiSleepQuality = (typeof AI_SLEEP_QUALITY_OPTIONS)[number];
66
- export declare const AI_SLEEP_QUALITY_LABELS: Record<TAiSleepQuality, string>;
60
+ export declare const AI_ENERGY_LEVEL_OPTIONS: readonly ["fresh", "normal", "tired", "exhausted"];
61
+ export type TAiEnergyLevel = (typeof AI_ENERGY_LEVEL_OPTIONS)[number];
67
62
  export declare const AI_INTENT_CHIPS: readonly ["leg-day", "upper-body", "full-body", "push-day", "pull-day", "cardio-focused", "back-and-biceps", "chest-and-triceps", "legs-and-glutes", "core-and-abs", "mobility-and-flexibility", "Surprise me"];
68
63
  export type TAiIntentChip = (typeof AI_INTENT_CHIPS)[number];
64
+ export {};
@@ -7,8 +7,7 @@
7
7
  // Verified against 701 active exercises from exercises-v2_3_PURE.json
8
8
  // Do not add values here without also ensuring they exist in the data.
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.AI_INTENT_CHIPS = exports.AI_SLEEP_QUALITY_LABELS = exports.AI_SLEEP_QUALITY_OPTIONS = exports.AI_INJURY_DURATION_LABELS = exports.AI_INJURY_DURATION = exports.AI_INJURY_SEVERITY_LABELS = exports.AI_INJURY_SEVERITY = exports.AI_POPULAR_THRESHOLD = exports.AI_BODY_ISSUE_LABELS = exports.AI_BODY_ISSUE_TYPES = exports.AI_BODY_AREA_LABELS = exports.AI_BODY_AREAS = exports.AI_MET_THRESHOLDS = exports.AI_SLEEP_TO_MAX_CNS = exports.AI_INTENSITY_LEVELS = exports.AI_DIFFICULTY_FILTER = exports.AI_FITNESS_LEVELS = exports.AI_DIFFICULTY_LEVELS = exports.AI_SESSION_ORDER = exports.AI_WORKOUT_PLACEMENTS = exports.AI_CORE_PATTERNS = exports.AI_LEG_PATTERNS = exports.AI_PULL_PATTERNS = exports.AI_PUSH_PATTERNS = exports.AI_MOVEMENT_PATTERNS = exports.AI_HOME_EQUIPMENT = exports.AI_EQUIPMENT_TYPES = exports.AI_FITNESS_GOAL_LABELS = exports.AI_FITNESS_GOALS = void 0;
11
- // ── FITNESS GOALS ────────────────────────────────────────────────────────────
10
+ exports.AI_INTENT_CHIPS = exports.AI_ENERGY_LEVEL_OPTIONS = exports.AI_INJURY_DURATION_LABELS = exports.AI_INJURY_DURATION = exports.AI_INJURY_SEVERITY = exports.AI_POPULAR_THRESHOLD = exports.AI_BODY_ISSUE_TYPES = exports.AI_BODY_AREAS = exports.AI_MET_THRESHOLDS = exports.AI_SLEEP_TO_MAX_CNS = exports.AI_INTENSITY_LEVELS = exports.AI_DIFFICULTY_FILTER = exports.AI_FITNESS_LEVELS = exports.AI_SESSION_ORDER = exports.AI_WORKOUT_PLACEMENTS = exports.AI_CORE_PATTERNS = exports.AI_LEG_PATTERNS = exports.AI_PULL_PATTERNS = exports.AI_PUSH_PATTERNS = exports.AI_MOVEMENT_PATTERNS = exports.AI_HOME_EQUIPMENT = exports.AI_EQUIPMENT_TYPES = exports.AI_FITNESS_GOALS = void 0;
12
11
  exports.AI_FITNESS_GOALS = [
13
12
  "strength",
14
13
  "hypertrophy",
@@ -20,18 +19,6 @@ exports.AI_FITNESS_GOALS = [
20
19
  "general_fitness",
21
20
  "core_strength",
22
21
  ];
23
- exports.AI_FITNESS_GOAL_LABELS = {
24
- strength: "Get stronger",
25
- hypertrophy: "Build muscle",
26
- fat_loss: "Lose fat",
27
- endurance: "Improve endurance",
28
- mobility: "Improve flexibility & mobility",
29
- rehabilitation: "Recover from injury",
30
- sport_performance: "Sport performance",
31
- general_fitness: "General fitness",
32
- core_strength: "Build core strength",
33
- };
34
- // ── EQUIPMENT TYPES ──────────────────────────────────────────────────────────
35
22
  exports.AI_EQUIPMENT_TYPES = [
36
23
  "none",
37
24
  "dumbbell",
@@ -66,7 +53,6 @@ exports.AI_HOME_EQUIPMENT = [
66
53
  "exercise_ball",
67
54
  "jump_rope",
68
55
  ];
69
- // ── MOVEMENT PATTERNS ────────────────────────────────────────────────────────
70
56
  exports.AI_MOVEMENT_PATTERNS = [
71
57
  "push_horizontal",
72
58
  "push_vertical",
@@ -101,7 +87,6 @@ exports.AI_CORE_PATTERNS = [
101
87
  "core_stability",
102
88
  "rotation",
103
89
  ];
104
- // ── WORKOUT PLACEMENT ────────────────────────────────────────────────────────
105
90
  exports.AI_WORKOUT_PLACEMENTS = [
106
91
  "primary_compound",
107
92
  "secondary_compound",
@@ -118,8 +103,7 @@ exports.AI_SESSION_ORDER = [
118
103
  "finisher",
119
104
  "cooldown",
120
105
  ];
121
- // ── DIFFICULTY LEVELS ────────────────────────────────────────────────────────
122
- exports.AI_DIFFICULTY_LEVELS = [
106
+ const AI_DIFFICULTY_LEVELS = [
123
107
  "beginner",
124
108
  "intermediate",
125
109
  "advanced",
@@ -135,20 +119,17 @@ exports.AI_DIFFICULTY_FILTER = {
135
119
  intermediate: ["beginner", "intermediate"],
136
120
  advanced: ["beginner", "intermediate", "advanced", "expert"],
137
121
  };
138
- // ── INTENSITY LEVELS ─────────────────────────────────────────────────────────
139
122
  exports.AI_INTENSITY_LEVELS = ["low", "moderate", "high"];
140
123
  exports.AI_SLEEP_TO_MAX_CNS = {
141
124
  good: "high",
142
125
  disturbed: "moderate",
143
126
  poor: "low",
144
127
  };
145
- // ── MET VALUES ───────────────────────────────────────────────────────────────
146
128
  exports.AI_MET_THRESHOLDS = {
147
129
  low: 3,
148
130
  moderate: 6,
149
131
  high: 6,
150
132
  };
151
- // ── BODY AREAS ───────────────────────────────────────────────────────────────
152
133
  exports.AI_BODY_AREAS = [
153
134
  "lower back",
154
135
  "upper back",
@@ -168,54 +149,19 @@ exports.AI_BODY_AREAS = [
168
149
  "chest",
169
150
  "core",
170
151
  ];
171
- exports.AI_BODY_AREA_LABELS = {
172
- "lower back": "Lower back",
173
- "upper back": "Upper back",
174
- shoulders: "Shoulder",
175
- neck: "Neck",
176
- elbows: "Elbow",
177
- wrists: "Wrist",
178
- hips: "Hip",
179
- "hip flexors": "Hip flexor",
180
- knees: "Knee",
181
- ankles: "Ankle",
182
- hamstrings: "Hamstring",
183
- "achilles tendon": "Achilles / calf",
184
- forearms: "Forearm",
185
- groin: "Groin",
186
- "calf muscles": "Calf",
187
- chest: "Chest",
188
- core: "Core / abdomen",
189
- };
190
- // ── BODY ISSUE TYPES ─────────────────────────────────────────────────────────
191
152
  exports.AI_BODY_ISSUE_TYPES = [
192
153
  "general_soreness",
193
154
  "joint_pain",
194
155
  "old_injury",
195
156
  "diagnosed_condition",
196
157
  ];
197
- exports.AI_BODY_ISSUE_LABELS = {
198
- general_soreness: "General soreness or tightness",
199
- joint_pain: "Joint pain or clicking",
200
- old_injury: "Old / healed injury (just to note)",
201
- diagnosed_condition: "Doctor-diagnosed condition",
202
- };
203
- // ── POPULARITY ───────────────────────────────────────────────────────────────
204
158
  exports.AI_POPULAR_THRESHOLD = 75;
205
- // ── INJURY SEVERITY / INTENSITY ────────────────────────────────────────────────
206
159
  exports.AI_INJURY_SEVERITY = [
207
160
  "mild",
208
161
  "moderate",
209
162
  "severe",
210
163
  "acute_broken",
211
164
  ];
212
- exports.AI_INJURY_SEVERITY_LABELS = {
213
- mild: "Mild (Discomfort / Tightness)",
214
- moderate: "Moderate (Painful but manageable)",
215
- severe: "Severe (Sharp pain / Limited mobility)",
216
- acute_broken: "Acute / Broken (Recent trauma or surgery)",
217
- };
218
- // ── INJURY DURATION / AGE ────────────────────────────────────────────────────
219
165
  exports.AI_INJURY_DURATION = [
220
166
  "1_5_days",
221
167
  "1_4_weeks",
@@ -230,14 +176,12 @@ exports.AI_INJURY_DURATION_LABELS = {
230
176
  "3_6_months": "3-6 months",
231
177
  "6_plus_months": "6+ months (Chronic / Permanent)",
232
178
  };
233
- // ── SLEEP QUALITY ────────────────────────────────────────────────────────────
234
- exports.AI_SLEEP_QUALITY_OPTIONS = ["good", "disturbed", "poor"];
235
- exports.AI_SLEEP_QUALITY_LABELS = {
236
- good: "Slept well",
237
- disturbed: "Lightly disturbed",
238
- poor: "Poor sleep",
239
- };
240
- // ── USER INTENT CHIPS ────────────────────────────────────────────────────────
179
+ exports.AI_ENERGY_LEVEL_OPTIONS = [
180
+ "fresh",
181
+ "normal",
182
+ "tired",
183
+ "exhausted",
184
+ ];
241
185
  exports.AI_INTENT_CHIPS = [
242
186
  "leg-day",
243
187
  "upper-body",
@@ -1,15 +1,15 @@
1
- import { TAiIntentChip, TAiSleepQuality, TAiUserInjury } from "../constants/AiExerciseVocabulary";
1
+ import { TAiEnergyLevel, TAiUserInjury } from "../constants/AiExerciseVocabulary";
2
2
  import { TTemplate } from "./TApiTemplateData";
3
3
  export type TApiAiQuickStartWorkoutReq = {
4
4
  /**
5
5
  * What the user wants to focus on today.
6
- * e.g., "Leg day", "Upper body", "Surprise me"
6
+ * e.g., "Leg day", "Upper body", "I want 80% back 20% bicep" or "אני רוצה ליבה חזקה"
7
7
  */
8
- intentChip: TAiIntentChip;
8
+ intentText: string;
9
9
  /**
10
- * How the user slept last night. Used by the AI to modulate volume and intensity.
10
+ * How the user feels right now. Used by the AI to modulate volume and intensity.
11
11
  */
12
- sleepQuality: TAiSleepQuality;
12
+ energyLevel: TAiEnergyLevel;
13
13
  /**
14
14
  * Optional: How much time the user has for the workout.
15
15
  * Helps the AI determine the number of exercises and sets.
@@ -39,13 +39,16 @@ export type TAiEnrichedContext = {
39
39
  age: number;
40
40
  gender: string;
41
41
  fitnessLevel: string;
42
- sleepQuality: string;
42
+ energyLevel: string;
43
43
  fatigueMap: Record<string, any>;
44
44
  activeInjuries: TAiUserInjury[];
45
45
  avoidedAreas: string[];
46
46
  yesterdaysExercises: string[];
47
47
  };
48
48
  };
49
+ /**
50
+ * @deprecated This api will be deprecated since Sync api is being replaced with async polling-api which uses TApiJobStatusRes.
51
+ */
49
52
  export type TApiAiQuickStartWorkoutRes = {
50
53
  status: 200;
51
54
  state: "success";
@@ -66,3 +69,72 @@ export type TApiAiQuickStartWorkoutRes = {
66
69
  state: "failed" | "unauthorized";
67
70
  message: string;
68
71
  };
72
+ /**
73
+ * Job Status: Where is this job in the pipeline?
74
+ * - pending: Just created, waiting in queue
75
+ * - processing: Worker picked it up, working on it
76
+ * - success: Done! Plan is ready
77
+ * - failed: Something went wrong
78
+ */
79
+ export type TJobState = "pending" | "processing" | "success" | "failed" | "timeout";
80
+ /**
81
+ * Job Record: Stored in DynamoDB
82
+ * This is what we write to the database when a job is created
83
+ */
84
+ export interface TQuickStartJob {
85
+ jobId: string;
86
+ userId: string;
87
+ state: TJobState;
88
+ requestPayload: TApiAiQuickStartWorkoutReq;
89
+ plan?: Extract<TTemplate, {
90
+ type: "ai-generated";
91
+ }>;
92
+ enrichedContext?: TAiEnrichedContext;
93
+ errorMessage?: string;
94
+ createdAt: string;
95
+ startedAt?: string;
96
+ completedAt?: string;
97
+ ttl: number;
98
+ }
99
+ /**
100
+ * API Response for Job Creation
101
+ * What we return when someone calls POST /plans/quickstart/jobs-initiate
102
+ */
103
+ export type TApiCreateJobReq = TApiAiQuickStartWorkoutReq;
104
+ export type TApiCreateJobRes = {
105
+ jobId: string;
106
+ state: "pending";
107
+ message: string;
108
+ status: 200;
109
+ } | {
110
+ status: 500;
111
+ message: string;
112
+ };
113
+ export type TApiJobStatusReq = {
114
+ jobId: string;
115
+ };
116
+ export type TApiJobStatusRes = {
117
+ jobId: string;
118
+ state: TJobState;
119
+ plan?: Extract<TTemplate, {
120
+ type: "ai-generated";
121
+ }>;
122
+ enrichedContext?: TAiEnrichedContext;
123
+ errorMessage?: string;
124
+ createdAt: string;
125
+ completedAt?: string;
126
+ status: 200;
127
+ } | {
128
+ status: 500;
129
+ message: string;
130
+ };
131
+ /**
132
+ * Async Quick Start Architecture
133
+ *
134
+ * Flow:
135
+ * 1. Client → POST /plans/quickstart/jobs → TApiCreateJobRes { jobId }
136
+ * 2. SQS worker processes job in background
137
+ * 3. Client → GET /plans/quickstart/jobs/{jobId} → TApiJobStatusRes { plan? }
138
+ *
139
+ * This replaces the deprecated sync endpoint to avoid API Gateway 29s timeout.
140
+ */
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Async Quick Start Architecture
5
+ *
6
+ * Flow:
7
+ * 1. Client → POST /plans/quickstart/jobs → TApiCreateJobRes { jobId }
8
+ * 2. SQS worker processes job in background
9
+ * 3. Client → GET /plans/quickstart/jobs/{jobId} → TApiJobStatusRes { plan? }
10
+ *
11
+ * This replaces the deprecated sync endpoint to avoid API Gateway 29s timeout.
12
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgpholdings/greatoak-shared",
3
- "version": "1.2.69",
3
+ "version": "1.2.71",
4
4
  "description": "Shared TypeScript types and utilities for @dgpholdings projects",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",