hevy-shared 1.0.705 → 1.0.707
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/built/adjustEventTokens.d.ts +1 -0
- package/built/hevyTrainer.d.ts +126 -0
- package/built/hevyTrainer.js +245 -0
- package/built/index.d.ts +8 -3
- package/built/index.js +12 -3
- package/built/typeUtils.d.ts +5 -0
- package/built/typeUtils.js +7 -1
- package/built/utils.d.ts +5 -0
- package/built/utils.js +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, Equipment, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise } from '.';
|
|
2
|
+
export type HevyTrainerExerciseCategory = typeof hevyTrainerExerciseCategories[number];
|
|
3
|
+
export type HevyTrainerRoutineName = typeof routineNames[number];
|
|
4
|
+
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
5
|
+
export declare const hevyTrainerExerciseCategories: readonly ["compound", "isolation"];
|
|
6
|
+
export declare const routineNames: readonly ["full_body_1", "full_body_2_a", "full_body_2_b", "full_body_3_a", "full_body_3_b", "full_body_3_c", "upper_1_a", "lower_1_a", "upper_1_b", "lower_1_b", "push_1", "pull_1", "legs_1", "upper_2", "lower_2", "push_2_a", "pull_2_a", "legs_2_a", "push_2_b", "pull_2_b", "legs_2_b"];
|
|
7
|
+
export type exerciseId = string;
|
|
8
|
+
export declare const frequencyMap: Record<WeeklyTrainingFrequency, string>;
|
|
9
|
+
export declare const programSplits: Record<WeeklyTrainingFrequency, HevyTrainerRoutineName[]>;
|
|
10
|
+
export type SetsPerGoal = {
|
|
11
|
+
[key in TrainingGoal]: number;
|
|
12
|
+
};
|
|
13
|
+
export type Sets = {
|
|
14
|
+
[key in string]: SetsPerGoal;
|
|
15
|
+
};
|
|
16
|
+
export interface RepRange {
|
|
17
|
+
rep_range_start: number;
|
|
18
|
+
rep_range_end: number;
|
|
19
|
+
}
|
|
20
|
+
export type RepRangesPerCategory = {
|
|
21
|
+
[key in HevyTrainerExerciseCategory]: RepRange;
|
|
22
|
+
};
|
|
23
|
+
export type RepRanges = {
|
|
24
|
+
[key in TrainingGoal]: RepRangesPerCategory;
|
|
25
|
+
};
|
|
26
|
+
export type RestTimersPerCategory = {
|
|
27
|
+
[key in HevyTrainerExerciseCategory]: number;
|
|
28
|
+
};
|
|
29
|
+
export type RestTimers = {
|
|
30
|
+
[key in TrainingGoal]: RestTimersPerCategory;
|
|
31
|
+
};
|
|
32
|
+
export type ExercisePriorities = {
|
|
33
|
+
[key in MuscleGroup]: exerciseId[];
|
|
34
|
+
};
|
|
35
|
+
export type ExerciseNotes = {
|
|
36
|
+
[key in exerciseId]: string;
|
|
37
|
+
};
|
|
38
|
+
export interface ExercisePrescription {
|
|
39
|
+
muscle_group: MuscleGroup | 'focus_muscle';
|
|
40
|
+
category: HevyTrainerExerciseCategory;
|
|
41
|
+
warmup_set_count?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface WorkoutTemplate {
|
|
44
|
+
exercises: ExercisePrescription[];
|
|
45
|
+
notes?: string;
|
|
46
|
+
}
|
|
47
|
+
export type Templates = {
|
|
48
|
+
[key in HevyTrainerRoutineName]: WorkoutTemplate;
|
|
49
|
+
};
|
|
50
|
+
export interface TrainerPreset {
|
|
51
|
+
id?: number;
|
|
52
|
+
username: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
is_default?: boolean;
|
|
55
|
+
updated_at?: string;
|
|
56
|
+
settings: TrainerPresetSettings;
|
|
57
|
+
workout_tab_ai_insight_prompt?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TrainerPresetSettings {
|
|
60
|
+
sets: Sets;
|
|
61
|
+
rep_ranges: RepRanges;
|
|
62
|
+
rest_timers: RestTimers;
|
|
63
|
+
templates: Templates;
|
|
64
|
+
exercise_priorities: ExercisePriorities;
|
|
65
|
+
exercise_notes: ExerciseNotes;
|
|
66
|
+
}
|
|
67
|
+
export interface TrainerProgramExercise {
|
|
68
|
+
exerciseTemplate: HevyTrainerLibraryExercise;
|
|
69
|
+
muscleGroup: MuscleGroup | 'focus_muscle';
|
|
70
|
+
category: HevyTrainerExerciseCategory;
|
|
71
|
+
sets: number;
|
|
72
|
+
warmupSetCount?: number;
|
|
73
|
+
repRangeStart: number;
|
|
74
|
+
repRangeEnd: number;
|
|
75
|
+
restTimerSeconds: number;
|
|
76
|
+
notes?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface TrainerProgramRoutine {
|
|
79
|
+
name: HevyTrainerRoutineName;
|
|
80
|
+
exercises: TrainerProgramExercise[];
|
|
81
|
+
notes?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface TrainerProgram {
|
|
84
|
+
name: WeeklyTrainingFrequency;
|
|
85
|
+
routines: TrainerProgramRoutine[];
|
|
86
|
+
}
|
|
87
|
+
export type HevyTrainerLibraryExercise = Pick<LibraryExercise, 'id' | 'title' | 'priority' | 'muscle_group' | 'other_muscles' | 'exercise_type' | 'equipment_category' | 'category' | 'level' | 'goal'>;
|
|
88
|
+
export interface ExercisePrescriptionError {
|
|
89
|
+
type: 'exercise_not_found';
|
|
90
|
+
prescription: ExercisePrescription;
|
|
91
|
+
muscleGroup: MuscleGroup;
|
|
92
|
+
context: {
|
|
93
|
+
goal: TrainingGoal;
|
|
94
|
+
level: TrainingLevel;
|
|
95
|
+
equipments: HevyTrainerProgramEquipment[];
|
|
96
|
+
focusMuscle?: SimplifiedMuscleGroup;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export interface TrainerProgramExerciseResult {
|
|
100
|
+
success: true;
|
|
101
|
+
exercise: TrainerProgramExercise;
|
|
102
|
+
}
|
|
103
|
+
export interface TrainerProgramExerciseError {
|
|
104
|
+
success: false;
|
|
105
|
+
error: ExercisePrescriptionError;
|
|
106
|
+
}
|
|
107
|
+
export type TrainerProgramExerciseAttempt = TrainerProgramExerciseResult | TrainerProgramExerciseError;
|
|
108
|
+
export interface TrainerProgramResult {
|
|
109
|
+
success: true;
|
|
110
|
+
program: TrainerProgram;
|
|
111
|
+
}
|
|
112
|
+
export interface TrainerProgramError {
|
|
113
|
+
success: false;
|
|
114
|
+
errors: ExercisePrescriptionError[];
|
|
115
|
+
partialProgram?: TrainerProgram;
|
|
116
|
+
}
|
|
117
|
+
export type TrainerProgramAttempt = TrainerProgramResult | TrainerProgramError;
|
|
118
|
+
export declare const generateProgram: ({ trainerPreset, selectedDays, selectedGoal, selectedLevel, selectedEquipments, exerciseStore, focusMuscle, }: {
|
|
119
|
+
trainerPreset: TrainerPreset;
|
|
120
|
+
selectedDays: WeeklyTrainingFrequency;
|
|
121
|
+
selectedGoal: TrainingGoal;
|
|
122
|
+
selectedLevel: TrainingLevel;
|
|
123
|
+
selectedEquipments: HevyTrainerProgramEquipment[];
|
|
124
|
+
exerciseStore: HevyTrainerLibraryExercise[];
|
|
125
|
+
focusMuscle?: SimplifiedMuscleGroup;
|
|
126
|
+
}) => TrainerProgramAttempt;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateProgram = exports.programSplits = exports.frequencyMap = exports.routineNames = exports.hevyTrainerExerciseCategories = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
exports.hevyTrainerExerciseCategories = ['compound', 'isolation'];
|
|
6
|
+
exports.routineNames = [
|
|
7
|
+
// Full body 1x
|
|
8
|
+
'full_body_1',
|
|
9
|
+
// Full body 2x
|
|
10
|
+
'full_body_2_a',
|
|
11
|
+
'full_body_2_b',
|
|
12
|
+
// Full body 3x
|
|
13
|
+
'full_body_3_a',
|
|
14
|
+
'full_body_3_b',
|
|
15
|
+
'full_body_3_c',
|
|
16
|
+
// Upper body x4 per week
|
|
17
|
+
'upper_1_a',
|
|
18
|
+
'lower_1_a',
|
|
19
|
+
'upper_1_b',
|
|
20
|
+
'lower_1_b',
|
|
21
|
+
// Push Pull Legs Upper Lower 5x per week
|
|
22
|
+
'push_1',
|
|
23
|
+
'pull_1',
|
|
24
|
+
'legs_1',
|
|
25
|
+
'upper_2',
|
|
26
|
+
'lower_2',
|
|
27
|
+
// Push Pull Legs x6 per week
|
|
28
|
+
'push_2_a',
|
|
29
|
+
'pull_2_a',
|
|
30
|
+
'legs_2_a',
|
|
31
|
+
'push_2_b',
|
|
32
|
+
'pull_2_b',
|
|
33
|
+
'legs_2_b',
|
|
34
|
+
];
|
|
35
|
+
exports.frequencyMap = {
|
|
36
|
+
1: 'one_day',
|
|
37
|
+
2: 'two_days',
|
|
38
|
+
3: 'three_days',
|
|
39
|
+
4: 'four_days',
|
|
40
|
+
5: 'five_days',
|
|
41
|
+
6: 'six_days',
|
|
42
|
+
};
|
|
43
|
+
exports.programSplits = {
|
|
44
|
+
1: ['full_body_1'],
|
|
45
|
+
2: ['full_body_2_a', 'full_body_2_b'],
|
|
46
|
+
3: ['full_body_3_a', 'full_body_3_b', 'full_body_3_c'],
|
|
47
|
+
4: ['upper_1_a', 'lower_1_a', 'upper_1_b', 'lower_1_b'],
|
|
48
|
+
5: ['push_1', 'pull_1', 'legs_1', 'upper_2', 'lower_2'],
|
|
49
|
+
6: ['push_2_a', 'pull_2_a', 'legs_2_a', 'push_2_b', 'pull_2_b', 'legs_2_b'],
|
|
50
|
+
};
|
|
51
|
+
const isolationExerciseAlternatives = {
|
|
52
|
+
chest: ['B74A95BB', '392887AA', '39C99849'],
|
|
53
|
+
triceps: ['6575F52D', 'CD6DC8E5'],
|
|
54
|
+
quadriceps: ['32HKJ34K', 'A733CC5B', '9694DA61'],
|
|
55
|
+
hamstrings: ['F6948F17', '487B3755', 'CDA23948'],
|
|
56
|
+
glutes: [],
|
|
57
|
+
lats: [],
|
|
58
|
+
lower_back: [],
|
|
59
|
+
upper_back: [],
|
|
60
|
+
shoulders: [],
|
|
61
|
+
biceps: [],
|
|
62
|
+
adductors: [],
|
|
63
|
+
abductors: [],
|
|
64
|
+
calves: [],
|
|
65
|
+
forearms: [],
|
|
66
|
+
abdominals: [],
|
|
67
|
+
other: [],
|
|
68
|
+
cardio: [],
|
|
69
|
+
traps: [],
|
|
70
|
+
neck: [],
|
|
71
|
+
full_body: [],
|
|
72
|
+
};
|
|
73
|
+
const getMuscleGroup = ({ muscleGroupPrescription, programFocusMuscleExerciseCount, focusMuscle, }) => {
|
|
74
|
+
if (muscleGroupPrescription === 'focus_muscle') {
|
|
75
|
+
if (!!focusMuscle) {
|
|
76
|
+
const n = _1.simplifiedMuscleGroupToMuscleGroups[focusMuscle].length;
|
|
77
|
+
return _1.simplifiedMuscleGroupToMuscleGroups[focusMuscle][programFocusMuscleExerciseCount % n];
|
|
78
|
+
}
|
|
79
|
+
// User has not selected a focus muscle, so we skip this extra exercise for the focus muscle
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
return muscleGroupPrescription;
|
|
83
|
+
};
|
|
84
|
+
const isExerciseMatch = ({ exercisePrescription, exercise, equipments, routineBarbellExerciseCount, level, goal, }) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
return ((exercise.category === exercisePrescription.category ||
|
|
87
|
+
(exercise.category === 'assistance-compound' && // Airtable also has `assistance-compound` as another category
|
|
88
|
+
exercisePrescription.category === 'compound')) && // but we are not differentiating between them and using `compound` instead
|
|
89
|
+
((_a = exercise.level) === null || _a === void 0 ? void 0 : _a.includes(level)) &&
|
|
90
|
+
((_b = exercise.goal) === null || _b === void 0 ? void 0 : _b.includes(goal)) &&
|
|
91
|
+
(equipments.includes(exercise.equipment_category) ||
|
|
92
|
+
exercise.equipment_category === 'none' ||
|
|
93
|
+
exercise.equipment_category === 'other') &&
|
|
94
|
+
// Up to 2 barbell exercises per routine, unless there is only one equipment category selected
|
|
95
|
+
(exercise.equipment_category !== 'barbell' ||
|
|
96
|
+
routineBarbellExerciseCount < 2 ||
|
|
97
|
+
equipments.length === 1));
|
|
98
|
+
};
|
|
99
|
+
const isAlternativeIsolationExerciseMatch = ({ exercise, exercisePrescription, equipments, level, muscleGroup, }) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return (exercisePrescription.category === 'isolation' &&
|
|
102
|
+
isolationExerciseAlternatives[muscleGroup].includes(exercise.id) &&
|
|
103
|
+
(equipments.includes(exercise.equipment_category) ||
|
|
104
|
+
exercise.equipment_category === 'none' ||
|
|
105
|
+
exercise.equipment_category === 'other') &&
|
|
106
|
+
((_a = exercise.level) === null || _a === void 0 ? void 0 : _a.includes(level)));
|
|
107
|
+
};
|
|
108
|
+
const generateProgram = ({ trainerPreset, selectedDays, selectedGoal, selectedLevel, selectedEquipments, exerciseStore, focusMuscle, }) => {
|
|
109
|
+
var _a;
|
|
110
|
+
const routines = exports.programSplits[selectedDays];
|
|
111
|
+
const program = {
|
|
112
|
+
name: selectedDays,
|
|
113
|
+
routines: [],
|
|
114
|
+
};
|
|
115
|
+
// Have a map of muscle group to exercises sorted by exercise priority
|
|
116
|
+
const sortedExercises = Object.entries(trainerPreset.settings.exercise_priorities).reduce((acc, [muscleGroup, exercises]) => {
|
|
117
|
+
acc[muscleGroup] = exercises.map((exercise) => exerciseStore.find((e) => e.id === exercise));
|
|
118
|
+
return acc;
|
|
119
|
+
}, {});
|
|
120
|
+
// Then add remaining exercises to the map
|
|
121
|
+
Object.keys(sortedExercises).forEach((muscleGroup) => {
|
|
122
|
+
const remainingExercises = exerciseStore
|
|
123
|
+
.filter((e) => e.muscle_group === muscleGroup &&
|
|
124
|
+
!sortedExercises[muscleGroup].includes(e))
|
|
125
|
+
.sort((a, b) => b.priority - a.priority);
|
|
126
|
+
sortedExercises[muscleGroup].push(...remainingExercises);
|
|
127
|
+
});
|
|
128
|
+
const programUsedExercises = new Set();
|
|
129
|
+
let programFocusMuscleExerciseCount = 0;
|
|
130
|
+
const allErrors = [];
|
|
131
|
+
for (const routine of routines) {
|
|
132
|
+
const routineTemplate = trainerPreset.settings.templates[routine];
|
|
133
|
+
let routineBarbellExerciseCount = 0;
|
|
134
|
+
const routineUsedExercises = new Set();
|
|
135
|
+
const routineExercises = [];
|
|
136
|
+
for (const exercisePrescription of routineTemplate.exercises) {
|
|
137
|
+
const muscleGroup = getMuscleGroup({
|
|
138
|
+
muscleGroupPrescription: exercisePrescription.muscle_group,
|
|
139
|
+
programFocusMuscleExerciseCount,
|
|
140
|
+
focusMuscle,
|
|
141
|
+
});
|
|
142
|
+
// If the muscle group is not found, skip the exercise
|
|
143
|
+
if (!muscleGroup) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// First pass: Try to find an exact match for the exercise that is not used in the program
|
|
147
|
+
let exercise = sortedExercises[muscleGroup].find((e) => isExerciseMatch({
|
|
148
|
+
exercisePrescription,
|
|
149
|
+
exercise: e,
|
|
150
|
+
equipments: selectedEquipments,
|
|
151
|
+
routineBarbellExerciseCount,
|
|
152
|
+
level: selectedLevel,
|
|
153
|
+
goal: selectedGoal,
|
|
154
|
+
}) && !programUsedExercises.has(e.title));
|
|
155
|
+
if (exercise === undefined) {
|
|
156
|
+
// Second pass
|
|
157
|
+
// By allowing the same exercise to be assigned in the same program more than once
|
|
158
|
+
const extendedMatchingExercise = sortedExercises[muscleGroup].find((e) => isExerciseMatch({
|
|
159
|
+
exercisePrescription,
|
|
160
|
+
exercise: e,
|
|
161
|
+
equipments: selectedEquipments,
|
|
162
|
+
routineBarbellExerciseCount,
|
|
163
|
+
level: selectedLevel,
|
|
164
|
+
goal: selectedGoal,
|
|
165
|
+
}) && !routineUsedExercises.has(e.title));
|
|
166
|
+
exercise = extendedMatchingExercise;
|
|
167
|
+
}
|
|
168
|
+
if (exercise === undefined) {
|
|
169
|
+
// Third pass
|
|
170
|
+
// Check if isolation exercise alternatives are available and not used in the program
|
|
171
|
+
const alternativeIsolationExercise = sortedExercises[muscleGroup].find((e) => isAlternativeIsolationExerciseMatch({
|
|
172
|
+
exercise: e,
|
|
173
|
+
exercisePrescription,
|
|
174
|
+
equipments: selectedEquipments,
|
|
175
|
+
level: selectedLevel,
|
|
176
|
+
muscleGroup,
|
|
177
|
+
}) && !programUsedExercises.has(e.title));
|
|
178
|
+
exercise = alternativeIsolationExercise;
|
|
179
|
+
}
|
|
180
|
+
if (exercise === undefined) {
|
|
181
|
+
// Fourth pass
|
|
182
|
+
// Check if isolation exercise alternatives are available and not used in the workout
|
|
183
|
+
const extendedIsolationExercise = sortedExercises[muscleGroup].find((e) => isAlternativeIsolationExerciseMatch({
|
|
184
|
+
exercise: e,
|
|
185
|
+
exercisePrescription,
|
|
186
|
+
equipments: selectedEquipments,
|
|
187
|
+
level: selectedLevel,
|
|
188
|
+
muscleGroup,
|
|
189
|
+
}) && !routineUsedExercises.has(e.title));
|
|
190
|
+
exercise = extendedIsolationExercise;
|
|
191
|
+
}
|
|
192
|
+
if (!!exercise) {
|
|
193
|
+
programUsedExercises.add(exercise.title);
|
|
194
|
+
routineUsedExercises.add(exercise.title);
|
|
195
|
+
if (exercise.equipment_category === 'barbell')
|
|
196
|
+
routineBarbellExerciseCount++;
|
|
197
|
+
if (exercisePrescription.muscle_group === 'focus_muscle')
|
|
198
|
+
programFocusMuscleExerciseCount++;
|
|
199
|
+
routineExercises.push({
|
|
200
|
+
exerciseTemplate: exercise,
|
|
201
|
+
muscleGroup: exercisePrescription.muscle_group,
|
|
202
|
+
category: exercisePrescription.category,
|
|
203
|
+
sets: trainerPreset.settings.sets[exports.frequencyMap[selectedDays]][selectedGoal],
|
|
204
|
+
warmupSetCount: exercisePrescription.warmup_set_count,
|
|
205
|
+
repRangeStart: trainerPreset.settings.rep_ranges[selectedGoal][exercisePrescription.category].rep_range_start,
|
|
206
|
+
repRangeEnd: trainerPreset.settings.rep_ranges[selectedGoal][exercisePrescription.category].rep_range_end,
|
|
207
|
+
restTimerSeconds: trainerPreset.settings.rest_timers[selectedGoal][exercisePrescription.category],
|
|
208
|
+
notes: (_a = trainerPreset.settings.exercise_notes[exercise.id]) !== null && _a !== void 0 ? _a : '',
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
// Collect error instead of throwing
|
|
213
|
+
allErrors.push({
|
|
214
|
+
type: 'exercise_not_found',
|
|
215
|
+
prescription: exercisePrescription,
|
|
216
|
+
muscleGroup,
|
|
217
|
+
context: {
|
|
218
|
+
goal: selectedGoal,
|
|
219
|
+
level: selectedLevel,
|
|
220
|
+
equipments: selectedEquipments,
|
|
221
|
+
focusMuscle,
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
program.routines.push({
|
|
227
|
+
name: routine,
|
|
228
|
+
notes: routineTemplate.notes,
|
|
229
|
+
exercises: routineExercises,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
// Return result based on whether there were errors
|
|
233
|
+
if (allErrors.length > 0) {
|
|
234
|
+
return {
|
|
235
|
+
success: false,
|
|
236
|
+
errors: allErrors,
|
|
237
|
+
partialProgram: program.routines.length > 0 ? program : undefined,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
success: true,
|
|
242
|
+
program,
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
exports.generateProgram = generateProgram;
|
package/built/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './typeUtils';
|
|
|
18
18
|
export * from './async';
|
|
19
19
|
export * from './adminPermissions';
|
|
20
20
|
export * from './adjustEventTokens';
|
|
21
|
+
export * from './hevyTrainer';
|
|
21
22
|
export declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "pt", "tr", "zh_CN", "zh_TW", "ru", "ja", "ko"];
|
|
22
23
|
export type Language = Lookup<typeof supportedLanguages>;
|
|
23
24
|
export declare const isLanguage: (x: string) => x is Language;
|
|
@@ -73,6 +74,7 @@ export interface AccountResponse {
|
|
|
73
74
|
is_coached: boolean;
|
|
74
75
|
birthday?: string;
|
|
75
76
|
sex?: Sex;
|
|
77
|
+
height_cm?: number;
|
|
76
78
|
}
|
|
77
79
|
export interface UserAccountResponse {
|
|
78
80
|
id: string;
|
|
@@ -107,6 +109,7 @@ export interface UserAccountResponse {
|
|
|
107
109
|
sex?: Sex;
|
|
108
110
|
email_consent: boolean;
|
|
109
111
|
email_verified: boolean;
|
|
112
|
+
height_cm?: number;
|
|
110
113
|
}
|
|
111
114
|
export interface CoachAppPushTarget {
|
|
112
115
|
type: 'android' | 'ios';
|
|
@@ -161,6 +164,7 @@ export interface AccountUpdate {
|
|
|
161
164
|
accepted_terms_and_conditions?: boolean;
|
|
162
165
|
sex?: Sex;
|
|
163
166
|
birthday?: string;
|
|
167
|
+
height_cm?: number;
|
|
164
168
|
}
|
|
165
169
|
export interface AppleSignUpRequest {
|
|
166
170
|
email?: string;
|
|
@@ -556,18 +560,19 @@ export declare const coreMuscles: readonly ["abdominals"];
|
|
|
556
560
|
export declare const shoulderMuscles: readonly ["shoulders"];
|
|
557
561
|
export declare const armMuscles: readonly ["biceps", "triceps", "forearms"];
|
|
558
562
|
export declare const legMuscles: readonly ["quadriceps", "hamstrings", "calves", "glutes", "abductors", "adductors"];
|
|
559
|
-
export declare const backMuscles: readonly ["lats", "
|
|
563
|
+
export declare const backMuscles: readonly ["lats", "upper_back", "traps", "lower_back"];
|
|
560
564
|
export declare const chestMuscles: readonly ["chest"];
|
|
561
565
|
export declare const miscellaneousMuscles: readonly ["cardio", "neck", "full_body", "other"];
|
|
562
566
|
export declare const simplifiedMuscleGroups: readonly ["core", "shoulders", "arms", "legs", "back", "chest"];
|
|
563
567
|
export type SimplifiedMuscleGroup = Lookup<typeof simplifiedMuscleGroups>;
|
|
564
568
|
export declare const isSimplifiedMuscleGroup: (x: string) => x is SimplifiedMuscleGroup;
|
|
565
|
-
export declare const muscleGroups: readonly ["abdominals", "shoulders", "biceps", "triceps", "forearms", "quadriceps", "hamstrings", "calves", "glutes", "abductors", "adductors", "lats", "
|
|
569
|
+
export declare const muscleGroups: readonly ["abdominals", "shoulders", "biceps", "triceps", "forearms", "quadriceps", "hamstrings", "calves", "glutes", "abductors", "adductors", "lats", "upper_back", "traps", "lower_back", "chest", "cardio", "neck", "full_body", "other"];
|
|
566
570
|
export type MuscleGroup = Lookup<typeof muscleGroups>;
|
|
567
571
|
export declare const isMuscleGroup: (x: string) => x is MuscleGroup;
|
|
568
|
-
export declare const muscleGroupFilters: readonly ["all_muscles", "abdominals", "shoulders", "biceps", "triceps", "forearms", "quadriceps", "hamstrings", "calves", "glutes", "abductors", "adductors", "lats", "
|
|
572
|
+
export declare const muscleGroupFilters: readonly ["all_muscles", "abdominals", "shoulders", "biceps", "triceps", "forearms", "quadriceps", "hamstrings", "calves", "glutes", "abductors", "adductors", "lats", "upper_back", "traps", "lower_back", "chest", "cardio", "neck", "full_body", "other"];
|
|
569
573
|
export type MuscleGroupFilter = Lookup<typeof muscleGroupFilters>;
|
|
570
574
|
export declare const isMuscleGroupFilter: (x: string) => x is MuscleGroupFilter;
|
|
575
|
+
export declare const simplifiedMuscleGroupToMuscleGroups: Record<SimplifiedMuscleGroup, readonly MuscleGroup[]>;
|
|
571
576
|
/**
|
|
572
577
|
* Equipment
|
|
573
578
|
*/
|
package/built/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = void 0;
|
|
17
|
+
exports.isWorkoutBiometrics = exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.hevyTrainerProgramEquipments = exports.exerciseCategories = exports.trainingLevels = exports.trainingGoals = exports.isCustomExerciseType = exports.customExericseTypes = exports.isExerciseType = exports.exerciseTypes = exports.isExerciseRepType = exports.exerciseRepTypes = exports.isEquipmentFilter = exports.equipmentFilters = exports.isEquipment = exports.equipments = exports.simplifiedMuscleGroupToMuscleGroups = exports.isMuscleGroupFilter = exports.muscleGroupFilters = exports.isMuscleGroup = exports.muscleGroups = exports.isSimplifiedMuscleGroup = exports.simplifiedMuscleGroups = exports.miscellaneousMuscles = exports.chestMuscles = exports.backMuscles = exports.legMuscles = exports.armMuscles = exports.shoulderMuscles = exports.coreMuscles = exports.DefaultClientConfiguration = exports.isCoachRole = exports.isErrorResponse = exports.isLivePRVolumeOption = exports.isTimerVolumeOption = exports.isWeekday = exports.orderedWeekdays = exports.isBodyMeasurementUnit = exports.isDistanceUnitShort = exports.isDistanceUnit = exports.isWeightUnit = exports.isLanguage = exports.supportedLanguages = void 0;
|
|
18
|
+
exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = void 0;
|
|
19
19
|
const typeUtils_1 = require("./typeUtils");
|
|
20
20
|
__exportStar(require("./constants"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
@@ -36,6 +36,7 @@ __exportStar(require("./typeUtils"), exports);
|
|
|
36
36
|
__exportStar(require("./async"), exports);
|
|
37
37
|
__exportStar(require("./adminPermissions"), exports);
|
|
38
38
|
__exportStar(require("./adjustEventTokens"), exports);
|
|
39
|
+
__exportStar(require("./hevyTrainer"), exports);
|
|
39
40
|
exports.supportedLanguages = [
|
|
40
41
|
'en',
|
|
41
42
|
'es',
|
|
@@ -119,9 +120,9 @@ exports.legMuscles = [
|
|
|
119
120
|
];
|
|
120
121
|
exports.backMuscles = [
|
|
121
122
|
'lats',
|
|
123
|
+
'upper_back',
|
|
122
124
|
'traps',
|
|
123
125
|
'lower_back',
|
|
124
|
-
'upper_back',
|
|
125
126
|
];
|
|
126
127
|
exports.chestMuscles = ['chest'];
|
|
127
128
|
exports.miscellaneousMuscles = [
|
|
@@ -154,6 +155,14 @@ exports.isMuscleGroup = isMuscleGroup;
|
|
|
154
155
|
exports.muscleGroupFilters = ['all_muscles', ...exports.muscleGroups];
|
|
155
156
|
const isMuscleGroupFilter = (x) => (0, typeUtils_1.isInArray)(x, exports.muscleGroupFilters);
|
|
156
157
|
exports.isMuscleGroupFilter = isMuscleGroupFilter;
|
|
158
|
+
exports.simplifiedMuscleGroupToMuscleGroups = {
|
|
159
|
+
chest: exports.chestMuscles,
|
|
160
|
+
shoulders: exports.shoulderMuscles,
|
|
161
|
+
back: exports.backMuscles,
|
|
162
|
+
arms: exports.armMuscles,
|
|
163
|
+
legs: exports.legMuscles,
|
|
164
|
+
core: exports.coreMuscles,
|
|
165
|
+
};
|
|
157
166
|
/**
|
|
158
167
|
* Equipment
|
|
159
168
|
*/
|
package/built/typeUtils.d.ts
CHANGED
|
@@ -30,3 +30,8 @@ export type Some<T> = {
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare const dangerousUncheckedTypeCast: <T = void, U extends T = T>(value: unknown) => U;
|
|
33
|
+
/**
|
|
34
|
+
* Same as `array[index]`, but adds `undefined` to the return type. Maybe some
|
|
35
|
+
* fine day we will enable `noUncheckedIndexedAccess` in all our projects. 🤞
|
|
36
|
+
*/
|
|
37
|
+
export declare const typeSafeIndex: <T>(array: T[], index: number) => T | undefined;
|
package/built/typeUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
|
|
3
|
+
exports.typeSafeIndex = exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
|
|
4
4
|
const isInArray = (value, array) => array.includes(value);
|
|
5
5
|
exports.isInArray = isInArray;
|
|
6
6
|
const exhaustiveTypeCheck = (_) => void _;
|
|
@@ -30,3 +30,9 @@ exports.exhaustiveTypeException = exhaustiveTypeException;
|
|
|
30
30
|
*/
|
|
31
31
|
const dangerousUncheckedTypeCast = (value) => value;
|
|
32
32
|
exports.dangerousUncheckedTypeCast = dangerousUncheckedTypeCast;
|
|
33
|
+
/**
|
|
34
|
+
* Same as `array[index]`, but adds `undefined` to the return type. Maybe some
|
|
35
|
+
* fine day we will enable `noUncheckedIndexedAccess` in all our projects. 🤞
|
|
36
|
+
*/
|
|
37
|
+
const typeSafeIndex = (array, index) => array[index];
|
|
38
|
+
exports.typeSafeIndex = typeSafeIndex;
|
package/built/utils.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ export declare const roundToTwoDecimal: (value: number) => number;
|
|
|
14
14
|
export declare const roundToOneDecimal: (value: number) => number;
|
|
15
15
|
export declare const roundToWholeNumber: (value: number) => number;
|
|
16
16
|
export declare const isValidUsername: (username: string) => boolean;
|
|
17
|
+
export declare const secondsToClockParts: (totalSeconds: number) => {
|
|
18
|
+
hours: number;
|
|
19
|
+
minutes: number;
|
|
20
|
+
seconds: number;
|
|
21
|
+
};
|
|
17
22
|
/**
|
|
18
23
|
* 01:25
|
|
19
24
|
* 02:25:36
|
package/built/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
3
|
+
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.secondsToClockParts = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Doesn't matter what you throw in the function it'll
|
|
6
6
|
* always return a number. Non number values will return
|
|
@@ -47,6 +47,13 @@ const isValidUsername = (username) => {
|
|
|
47
47
|
return re.test(username);
|
|
48
48
|
};
|
|
49
49
|
exports.isValidUsername = isValidUsername;
|
|
50
|
+
const secondsToClockParts = (totalSeconds) => {
|
|
51
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
52
|
+
const minutes = Math.floor((totalSeconds - hours * 3600) / 60);
|
|
53
|
+
const seconds = totalSeconds - hours * 3600 - minutes * 60;
|
|
54
|
+
return { hours, minutes, seconds };
|
|
55
|
+
};
|
|
56
|
+
exports.secondsToClockParts = secondsToClockParts;
|
|
50
57
|
/**
|
|
51
58
|
* 01:25
|
|
52
59
|
* 02:25:36
|