hevy-shared 1.0.948 → 1.0.949
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 +3 -7
- package/built/hevyTrainer.js +4 -4
- package/built/index.d.ts +0 -5
- package/built/index.js +2 -3
- package/built/utils.d.ts +4 -0
- package/built/utils.js +26 -1
- package/package.json +1 -1
package/built/hevyTrainer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment
|
|
1
|
+
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment } from '.';
|
|
2
2
|
export type HevyTrainerExerciseCategory = typeof hevyTrainerExerciseCategories[number];
|
|
3
3
|
export type HevyTrainerRoutineName = typeof routineNames[number];
|
|
4
4
|
export declare const workoutDurationOptions: readonly [40, 60, 80];
|
|
@@ -45,7 +45,6 @@ export interface ProgramGenerationParams<T extends HevyTrainerLibraryExercise> {
|
|
|
45
45
|
selectedLevel: TrainingLevel;
|
|
46
46
|
selectedEquipments: GranularEquipment[];
|
|
47
47
|
selectedWorkoutDurationMinutes?: WorkoutDurationMinutes;
|
|
48
|
-
selectedRestTimerLength: RestTimerLength;
|
|
49
48
|
exerciseStore: T[];
|
|
50
49
|
focusMuscle?: SimplifiedMuscleGroup;
|
|
51
50
|
excludedExerciseIds?: Set<string>;
|
|
@@ -72,11 +71,8 @@ export type RepRanges = {
|
|
|
72
71
|
export type RestTimersPerCategory = {
|
|
73
72
|
[key in HevyTrainerExerciseCategory]: number;
|
|
74
73
|
};
|
|
75
|
-
export type CategoryPerRestTimerLength = {
|
|
76
|
-
[key in RestTimerLength]: RestTimersPerCategory;
|
|
77
|
-
};
|
|
78
74
|
export type RestTimers = {
|
|
79
|
-
[key in TrainingGoal]:
|
|
75
|
+
[key in TrainingGoal]: RestTimersPerCategory;
|
|
80
76
|
};
|
|
81
77
|
export type ExercisePriorities = {
|
|
82
78
|
[key in MuscleGroup]: exerciseId[];
|
|
@@ -139,7 +135,7 @@ export interface TrainerProgram {
|
|
|
139
135
|
}
|
|
140
136
|
export declare const getTrainerSetCount: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, frequency: WeeklyTrainingFrequency) => number;
|
|
141
137
|
export declare const getTrainerRepRange: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, exerciseCategory: HevyTrainerExerciseCategory) => RepRange;
|
|
142
|
-
export declare const getTrainerRestTimerSeconds: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal,
|
|
138
|
+
export declare const getTrainerRestTimerSeconds: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, exerciseCategory: HevyTrainerExerciseCategory) => number;
|
|
143
139
|
/**
|
|
144
140
|
* Normalizes the exercise category to a HevyTrainerExerciseCategory
|
|
145
141
|
* - Treat custom exercises and exercises with no category as `compound`
|
package/built/hevyTrainer.js
CHANGED
|
@@ -203,8 +203,8 @@ const getTrainerRepRange = (trainerAlgorithmSettings, goal, exerciseCategory) =>
|
|
|
203
203
|
return trainerAlgorithmSettings.rep_ranges[goal][exerciseCategory];
|
|
204
204
|
};
|
|
205
205
|
exports.getTrainerRepRange = getTrainerRepRange;
|
|
206
|
-
const getTrainerRestTimerSeconds = (trainerAlgorithmSettings, goal,
|
|
207
|
-
return trainerAlgorithmSettings.rest_timers[goal][
|
|
206
|
+
const getTrainerRestTimerSeconds = (trainerAlgorithmSettings, goal, exerciseCategory) => {
|
|
207
|
+
return trainerAlgorithmSettings.rest_timers[goal][exerciseCategory];
|
|
208
208
|
};
|
|
209
209
|
exports.getTrainerRestTimerSeconds = getTrainerRestTimerSeconds;
|
|
210
210
|
/**
|
|
@@ -498,7 +498,7 @@ exports.pickExerciseForPrescription = pickExerciseForPrescription;
|
|
|
498
498
|
*/
|
|
499
499
|
const generateProgram = (params) => {
|
|
500
500
|
var _a;
|
|
501
|
-
const { trainerAlgorithmSettings, selectedDays, selectedGoal, selectedLevel, selectedEquipments, selectedWorkoutDurationMinutes,
|
|
501
|
+
const { trainerAlgorithmSettings, selectedDays, selectedGoal, selectedLevel, selectedEquipments, selectedWorkoutDurationMinutes, exerciseStore, focusMuscle, excludedExerciseIds, } = params;
|
|
502
502
|
const routines = exports.programSplits[selectedDays];
|
|
503
503
|
const program = {
|
|
504
504
|
name: selectedDays,
|
|
@@ -565,7 +565,7 @@ const generateProgram = (params) => {
|
|
|
565
565
|
sets: (0, exports.getTrainerSetCount)(trainerAlgorithmSettings, selectedGoal, selectedDays),
|
|
566
566
|
repRangeStart: repRange.rep_range_start,
|
|
567
567
|
repRangeEnd: repRange.rep_range_end,
|
|
568
|
-
restTimerSeconds: (0, exports.getTrainerRestTimerSeconds)(trainerAlgorithmSettings, selectedGoal,
|
|
568
|
+
restTimerSeconds: (0, exports.getTrainerRestTimerSeconds)(trainerAlgorithmSettings, selectedGoal, exercisePrescription.category),
|
|
569
569
|
warmupSetCount: exercisePrescription.warmup_set_count,
|
|
570
570
|
notes: (_a = trainerAlgorithmSettings.exercise_notes[exercise.id]) !== null && _a !== void 0 ? _a : '',
|
|
571
571
|
});
|
package/built/index.d.ts
CHANGED
|
@@ -640,11 +640,9 @@ export declare const isCustomExerciseType: (x: any) => x is CustomExerciseType;
|
|
|
640
640
|
export declare const trainingGoals: readonly ["strength", "build_muscle", "fat_loss"];
|
|
641
641
|
export declare const trainingLevels: readonly ["beginner", "intermediate", "advanced"];
|
|
642
642
|
export declare const exerciseCategories: readonly ["isolation", "compound", "assistance-compound"];
|
|
643
|
-
export declare const restTimerLengths: readonly ["short", "medium", "long"];
|
|
644
643
|
export type TrainingGoal = Lookup<typeof trainingGoals>;
|
|
645
644
|
export type TrainingLevel = Lookup<typeof trainingLevels>;
|
|
646
645
|
export type ExerciseCategory = Lookup<typeof exerciseCategories>;
|
|
647
|
-
export type RestTimerLength = typeof restTimerLengths[number];
|
|
648
646
|
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
649
647
|
export declare const hevyTrainerProgramEquipments: readonly ["barbell", "dumbbell", "machine"];
|
|
650
648
|
export declare const granularEquipments: readonly ["barbell", "dumbbell", "kettlebell", "plate", "medicine_ball", "ez_bar", "landmine", "trap_bar", "pullup_bar", "dip_bar", "squat_rack", "flat_bench", "adjustable_bench", "dual_cable_machine", "single_cable_machine", "lat_pulldown_cable", "leg_press_machine", "smith_machine", "t_bar", "plate_machines", "stack_machines", "treadmill", "elliptical_trainer", "rowing_machine", "spinning", "stair_machine", "air_bike", "suspension_band", "resistance_band", "battle_rope", "rings", "jump_rope"];
|
|
@@ -1261,7 +1259,6 @@ export interface HevyTrainerProgram {
|
|
|
1261
1259
|
focus_muscle?: SimplifiedMuscleGroup;
|
|
1262
1260
|
next_workout_index: number;
|
|
1263
1261
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1264
|
-
rest_timer_length: RestTimerLength;
|
|
1265
1262
|
}
|
|
1266
1263
|
export interface PostHevyTrainerProgramRequestBody {
|
|
1267
1264
|
program: {
|
|
@@ -1274,7 +1271,6 @@ export interface PostHevyTrainerProgramRequestBody {
|
|
|
1274
1271
|
routines: RoutineUpdate[];
|
|
1275
1272
|
next_workout_index?: number;
|
|
1276
1273
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1277
|
-
rest_timer_length: RestTimerLength;
|
|
1278
1274
|
};
|
|
1279
1275
|
}
|
|
1280
1276
|
export interface UpdateHevyTrainerProgramRequestBody {
|
|
@@ -1288,7 +1284,6 @@ export interface UpdateHevyTrainerProgramRequestBody {
|
|
|
1288
1284
|
focus_muscle?: SimplifiedMuscleGroup;
|
|
1289
1285
|
next_workout_index?: number;
|
|
1290
1286
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1291
|
-
rest_timer_length?: RestTimerLength;
|
|
1292
1287
|
routines: {
|
|
1293
1288
|
id: string;
|
|
1294
1289
|
title: string;
|
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.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.isGranularEquipment = exports.granularEquipments = exports.hevyTrainerProgramEquipments = exports.
|
|
18
|
-
exports.isOAuthScope = exports.supportedScopes = exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isHevyTrainerRoutine = exports.isWorkoutBiometrics =
|
|
17
|
+
exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.isGranularEquipment = exports.granularEquipments = 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.parseClientAuthTokenResponse = exports.isCoachRole = exports.isErrorResponse = exports.isLivePRVolumeOption = exports.isTimerVolumeOption = exports.isWeekday = exports.orderedWeekdays = exports.isBodyMeasurementUnit = exports.isDistanceUnitShort = exports.isDistanceUnit = exports.isWeightUnit = void 0;
|
|
18
|
+
exports.isOAuthScope = exports.supportedScopes = exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isHevyTrainerRoutine = exports.isWorkoutBiometrics = void 0;
|
|
19
19
|
const typeUtils_1 = require("./typeUtils");
|
|
20
20
|
__exportStar(require("./constants"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
@@ -227,7 +227,6 @@ exports.exerciseCategories = [
|
|
|
227
227
|
'compound',
|
|
228
228
|
'assistance-compound',
|
|
229
229
|
];
|
|
230
|
-
exports.restTimerLengths = ['short', 'medium', 'long'];
|
|
231
230
|
exports.hevyTrainerProgramEquipments = [
|
|
232
231
|
'barbell',
|
|
233
232
|
'dumbbell',
|
package/built/utils.d.ts
CHANGED
|
@@ -287,4 +287,8 @@ interface getSetValueParams {
|
|
|
287
287
|
}
|
|
288
288
|
export declare const formatSetValue: ({ exerciseType, set, units, lokalizedLabels, }: getSetValueParams) => string;
|
|
289
289
|
export declare const rawInstructionsToIndexedSteps: (rawInstructions: string) => ExerciseInstructionsStep[];
|
|
290
|
+
export declare const roundToKnownValue: (value: number, knownValues: number[]) => number | undefined;
|
|
291
|
+
export declare const indexByNearestValue: <T>(value: number, map: {
|
|
292
|
+
[key: number]: T;
|
|
293
|
+
}) => T | undefined;
|
|
290
294
|
export {};
|
package/built/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.calculateCurrentWeekStreak = 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.ESTIMATED_REST_TIMER_DURATION = exports.ESTIMATED_SET_DURATION = exports.UserFacingIndicatorToSetIndicator = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.toFragmentedJSON = 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;
|
|
7
|
-
exports.rawInstructionsToIndexedSteps = exports.formatSetValue = exports.exerciseWeight = exports.distance = exports.weekdayNumberMap = exports.startOfWeek = void 0;
|
|
7
|
+
exports.indexByNearestValue = exports.roundToKnownValue = exports.rawInstructionsToIndexedSteps = exports.formatSetValue = exports.exerciseWeight = exports.distance = exports.weekdayNumberMap = exports.startOfWeek = void 0;
|
|
8
8
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
9
|
const _1 = require(".");
|
|
10
10
|
/**
|
|
@@ -903,3 +903,28 @@ const rawInstructionsToIndexedSteps = (rawInstructions) => {
|
|
|
903
903
|
return instructionsByStep;
|
|
904
904
|
};
|
|
905
905
|
exports.rawInstructionsToIndexedSteps = rawInstructionsToIndexedSteps;
|
|
906
|
+
const roundToKnownValue = (value, knownValues) => {
|
|
907
|
+
if (knownValues.length === 0)
|
|
908
|
+
return undefined;
|
|
909
|
+
const boundingValues = knownValues.reduce(([lower, upper], v) => {
|
|
910
|
+
return [
|
|
911
|
+
v > lower && v <= value ? v : lower,
|
|
912
|
+
v < upper && v >= value ? v : upper,
|
|
913
|
+
];
|
|
914
|
+
}, [-Infinity, Infinity]);
|
|
915
|
+
if (boundingValues[0] === -Infinity && boundingValues[1] === Infinity)
|
|
916
|
+
return undefined;
|
|
917
|
+
if (boundingValues[0] === -Infinity)
|
|
918
|
+
return boundingValues[1];
|
|
919
|
+
if (boundingValues[1] === Infinity)
|
|
920
|
+
return boundingValues[0];
|
|
921
|
+
return value - boundingValues[0] < boundingValues[1] - value
|
|
922
|
+
? boundingValues[0]
|
|
923
|
+
: boundingValues[1];
|
|
924
|
+
};
|
|
925
|
+
exports.roundToKnownValue = roundToKnownValue;
|
|
926
|
+
const indexByNearestValue = (value, map) => {
|
|
927
|
+
const index = (0, exports.roundToKnownValue)(value, Object.keys(map).map((e) => Number(e)));
|
|
928
|
+
return index ? map[index] : undefined;
|
|
929
|
+
};
|
|
930
|
+
exports.indexByNearestValue = indexByNearestValue;
|