hevy-shared 1.0.770 → 1.0.772
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/hevyTrainer.d.ts +4 -0
- package/built/hevyTrainer.js +12 -2
- package/built/utils.d.ts +9 -0
- package/built/utils.js +17 -1
- package/package.json +1 -1
package/built/hevyTrainer.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export type HevyTrainerExerciseCategory = typeof hevyTrainerExerciseCategories[n
|
|
|
3
3
|
export type HevyTrainerRoutineName = typeof routineNames[number];
|
|
4
4
|
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
5
5
|
export declare const hevyTrainerExerciseCategories: readonly ["compound", "isolation"];
|
|
6
|
+
export type WorkoutDurationMinutes = typeof workoutDurationOptions[number];
|
|
7
|
+
export declare const workoutDurationOptions: readonly [40, 60, 80];
|
|
6
8
|
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
9
|
export type exerciseId = string;
|
|
8
10
|
export interface ExerciseSelectionCriteria {
|
|
@@ -29,6 +31,7 @@ export interface ProgramGenerationParams<T extends HevyTrainerLibraryExercise> {
|
|
|
29
31
|
selectedGoal: TrainingGoal;
|
|
30
32
|
selectedLevel: TrainingLevel;
|
|
31
33
|
selectedEquipments: HevyTrainerProgramEquipment[];
|
|
34
|
+
selectedWorkoutDurationMinutes?: WorkoutDurationMinutes;
|
|
32
35
|
exerciseStore: T[];
|
|
33
36
|
focusMuscle?: SimplifiedMuscleGroup;
|
|
34
37
|
excludedExerciseIds?: Set<string>;
|
|
@@ -68,6 +71,7 @@ export interface ExercisePrescription {
|
|
|
68
71
|
muscle_group: MuscleGroup | 'focus_muscle';
|
|
69
72
|
category: HevyTrainerExerciseCategory;
|
|
70
73
|
warmup_set_count?: number;
|
|
74
|
+
min_workout_duration_limit?: WorkoutDurationMinutes;
|
|
71
75
|
}
|
|
72
76
|
export interface WorkoutTemplate {
|
|
73
77
|
exercises: ExercisePrescription[];
|
package/built/hevyTrainer.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateProgram = exports.pickExerciseForPrescription = exports.getPrioritySortedExercises = exports.getTrainerRestTimerSeconds = exports.getTrainerRepRange = exports.getTrainerSetCount = exports.programSplits = exports.frequencyMap = exports.routineNames = exports.hevyTrainerExerciseCategories = void 0;
|
|
3
|
+
exports.generateProgram = exports.pickExerciseForPrescription = exports.getPrioritySortedExercises = exports.getTrainerRestTimerSeconds = exports.getTrainerRepRange = exports.getTrainerSetCount = exports.programSplits = exports.frequencyMap = exports.routineNames = exports.workoutDurationOptions = exports.hevyTrainerExerciseCategories = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const MAX_BARBELL_EXERCISES_PER_ROUTINE = 2;
|
|
6
6
|
exports.hevyTrainerExerciseCategories = ['compound', 'isolation'];
|
|
7
|
+
exports.workoutDurationOptions = [40, 60, 80];
|
|
7
8
|
exports.routineNames = [
|
|
8
9
|
// Full body 1x
|
|
9
10
|
'full_body_1',
|
|
@@ -253,7 +254,7 @@ exports.pickExerciseForPrescription = pickExerciseForPrescription;
|
|
|
253
254
|
*/
|
|
254
255
|
const generateProgram = (params) => {
|
|
255
256
|
var _a;
|
|
256
|
-
const { trainerAlgorithmSettings, selectedDays, selectedGoal, selectedLevel, selectedEquipments, exerciseStore, focusMuscle, excludedExerciseIds, } = params;
|
|
257
|
+
const { trainerAlgorithmSettings, selectedDays, selectedGoal, selectedLevel, selectedEquipments, selectedWorkoutDurationMinutes, exerciseStore, focusMuscle, excludedExerciseIds, } = params;
|
|
257
258
|
const routines = exports.programSplits[selectedDays];
|
|
258
259
|
const program = {
|
|
259
260
|
name: selectedDays,
|
|
@@ -278,6 +279,15 @@ const generateProgram = (params) => {
|
|
|
278
279
|
if (!muscleGroup) {
|
|
279
280
|
continue;
|
|
280
281
|
}
|
|
282
|
+
// If the exercise does not meet the min workout duration limit, skip the exercise
|
|
283
|
+
const execiseDoesNotMeetMinWorkoutDurationLimit = selectedWorkoutDurationMinutes &&
|
|
284
|
+
exercisePrescription.min_workout_duration_limit
|
|
285
|
+
? exercisePrescription.min_workout_duration_limit >
|
|
286
|
+
selectedWorkoutDurationMinutes
|
|
287
|
+
: false;
|
|
288
|
+
if (execiseDoesNotMeetMinWorkoutDurationLimit) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
281
291
|
const exercise = (0, exports.pickExerciseForPrescription)({
|
|
282
292
|
sortedExercises,
|
|
283
293
|
criteria: {
|
package/built/utils.d.ts
CHANGED
|
@@ -175,6 +175,15 @@ export interface TotalSetCountWorkout {
|
|
|
175
175
|
*/
|
|
176
176
|
export declare const userExerciseSetWeight: (set: UserExerciseSet, exerciseStore: BaseExerciseTemplate[], hundredPercentBodyweightExercise: boolean) => number;
|
|
177
177
|
export declare const workoutSetCount: (w: TotalSetCountWorkout) => number;
|
|
178
|
+
interface GetEstimatedExercisesDuration {
|
|
179
|
+
exercises: {
|
|
180
|
+
rest_seconds: number | null;
|
|
181
|
+
sets: {
|
|
182
|
+
duration_seconds?: number | null;
|
|
183
|
+
}[];
|
|
184
|
+
}[];
|
|
185
|
+
}
|
|
186
|
+
export declare const getEstimatedExercisesDurationSeconds: ({ exercises, }: GetEstimatedExercisesDuration) => number;
|
|
178
187
|
export declare const oneRepMaxPercentageMap: {
|
|
179
188
|
[s: number]: number;
|
|
180
189
|
};
|
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.secondsToClockParts = 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.getEstimatedExercisesDurationSeconds = 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
|
|
@@ -444,6 +444,22 @@ const workoutSetCount = (w) => {
|
|
|
444
444
|
}, 0);
|
|
445
445
|
};
|
|
446
446
|
exports.workoutSetCount = workoutSetCount;
|
|
447
|
+
const ESTIMATED_SET_DURATION = 45;
|
|
448
|
+
const ESTIMATED_REST_TIMER_DURATION = 90;
|
|
449
|
+
const getEstimatedExercisesDurationSeconds = ({ exercises, }) => {
|
|
450
|
+
const totalSeconds = exercises.reduce((exercisesTotal, exercise) => {
|
|
451
|
+
var _a;
|
|
452
|
+
const restPerSet = (_a = exercise.rest_seconds) !== null && _a !== void 0 ? _a : ESTIMATED_REST_TIMER_DURATION;
|
|
453
|
+
const exerciseTotal = exercise.sets.reduce((setTotal, set) => {
|
|
454
|
+
var _a;
|
|
455
|
+
const duration = (_a = set.duration_seconds) !== null && _a !== void 0 ? _a : ESTIMATED_SET_DURATION;
|
|
456
|
+
return setTotal + duration + restPerSet;
|
|
457
|
+
}, 0);
|
|
458
|
+
return exercisesTotal + exerciseTotal;
|
|
459
|
+
}, 0);
|
|
460
|
+
return totalSeconds;
|
|
461
|
+
};
|
|
462
|
+
exports.getEstimatedExercisesDurationSeconds = getEstimatedExercisesDurationSeconds;
|
|
447
463
|
exports.oneRepMaxPercentageMap = {
|
|
448
464
|
1: 1.0,
|
|
449
465
|
2: 0.97,
|