hevy-shared 1.0.942 → 1.0.944
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/API/APIClient.d.ts +5 -5
- package/built/API/APIClient.js +8 -8
- package/built/API/types.d.ts +1 -1
- package/built/hevyTrainer.d.ts +7 -3
- package/built/hevyTrainer.js +4 -4
- package/built/index.d.ts +5 -0
- package/built/index.js +3 -2
- package/package.json +1 -1
package/built/API/APIClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClientAuthToken, DeepReadonly } from '..';
|
|
2
|
-
import { RequestConfig, HTTPResponse, HTTPClient,
|
|
2
|
+
import { RequestConfig, HTTPResponse, HTTPClient, HTTPRequestCompletionCallback, HTTPErrorHandler } from './types';
|
|
3
3
|
interface HevyAPIClientConfig<UserContext> {
|
|
4
4
|
/**
|
|
5
5
|
* How long before predicted token expiry to request a new token. We request
|
|
@@ -90,7 +90,7 @@ export declare class HevyAPIClient<UserContext = never> {
|
|
|
90
90
|
private static readonly DEFAULT_TOKEN_REFRESH_THROTTLE_MS;
|
|
91
91
|
private static readonly DEFAULT_REFRESH_AUTH_TOKEN_API_ENDPOINT;
|
|
92
92
|
private readonly _config;
|
|
93
|
-
private
|
|
93
|
+
private _requestCompletionCallbacks;
|
|
94
94
|
private _errorHandlers;
|
|
95
95
|
private _authTokenFactory;
|
|
96
96
|
private _legacyAuthToken;
|
|
@@ -133,12 +133,12 @@ export declare class HevyAPIClient<UserContext = never> {
|
|
|
133
133
|
* This is a lower level API than {@link attachErrorHandler} - prefer using
|
|
134
134
|
* that one instead of this one if it's enough to suit your needs.
|
|
135
135
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
attachRequestCompletionCallback(onResult: HTTPRequestCompletionCallback): void;
|
|
137
|
+
removeRequestCompletionCallbacks(): void;
|
|
138
138
|
/**
|
|
139
139
|
* Adds a callback to be executed on receiving an HTTP error from the server.
|
|
140
140
|
* This callback will not be executed for any other type of error, such as a
|
|
141
|
-
* network error. For that and more, use {@link
|
|
141
|
+
* network error. For that and more, use {@link attachRequestCompletionCallback}.
|
|
142
142
|
*/
|
|
143
143
|
attachErrorHandler(onError: HTTPErrorHandler<{
|
|
144
144
|
willRetry: boolean;
|
package/built/API/APIClient.js
CHANGED
|
@@ -20,7 +20,7 @@ const __1 = require("..");
|
|
|
20
20
|
const types_1 = require("./types");
|
|
21
21
|
class HevyAPIClient {
|
|
22
22
|
constructor(httpClient, config) {
|
|
23
|
-
this.
|
|
23
|
+
this._requestCompletionCallbacks = [];
|
|
24
24
|
this._errorHandlers = [];
|
|
25
25
|
this._authTokenFactory = {
|
|
26
26
|
type: 'value',
|
|
@@ -146,11 +146,11 @@ class HevyAPIClient {
|
|
|
146
146
|
response,
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
this.
|
|
149
|
+
this._requestCompletionCallbacks.forEach((cb) => cb({ isSuccess: true, value: response }, request));
|
|
150
150
|
return response;
|
|
151
151
|
}
|
|
152
152
|
catch (e) {
|
|
153
|
-
this.
|
|
153
|
+
this._requestCompletionCallbacks.forEach((cb) => cb({ isSuccess: false, error: e }, request));
|
|
154
154
|
if (!(0, types_1.isHTTPError)(e))
|
|
155
155
|
throw e;
|
|
156
156
|
const { response } = e;
|
|
@@ -250,16 +250,16 @@ class HevyAPIClient {
|
|
|
250
250
|
* This is a lower level API than {@link attachErrorHandler} - prefer using
|
|
251
251
|
* that one instead of this one if it's enough to suit your needs.
|
|
252
252
|
*/
|
|
253
|
-
|
|
254
|
-
this.
|
|
253
|
+
attachRequestCompletionCallback(onResult) {
|
|
254
|
+
this._requestCompletionCallbacks.push(onResult);
|
|
255
255
|
}
|
|
256
|
-
|
|
257
|
-
this.
|
|
256
|
+
removeRequestCompletionCallbacks() {
|
|
257
|
+
this._requestCompletionCallbacks.length = 0;
|
|
258
258
|
}
|
|
259
259
|
/**
|
|
260
260
|
* Adds a callback to be executed on receiving an HTTP error from the server.
|
|
261
261
|
* This callback will not be executed for any other type of error, such as a
|
|
262
|
-
* network error. For that and more, use {@link
|
|
262
|
+
* network error. For that and more, use {@link attachRequestCompletionCallback}.
|
|
263
263
|
*/
|
|
264
264
|
attachErrorHandler(onError) {
|
|
265
265
|
this._errorHandlers.push(onError);
|
package/built/API/types.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface HTTPRequestFactory<T = unknown> {
|
|
|
23
23
|
headers: Record<string, string>;
|
|
24
24
|
try(): Promise<HTTPResponse<T>>;
|
|
25
25
|
}
|
|
26
|
-
export type
|
|
26
|
+
export type HTTPRequestCompletionCallback<T = unknown, R = unknown> = (result: Result<HTTPResponse<T>>, request: HTTPRequestFactory<R>) => void;
|
|
27
27
|
export type HTTPErrorHandler<E, T = unknown, R = unknown> = (response: HTTPResponse<T>, request: HTTPRequestFactory<R>, extraData: E) => void;
|
|
28
28
|
export interface HTTPResponse<T = unknown> {
|
|
29
29
|
status: number;
|
package/built/hevyTrainer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment } from '.';
|
|
1
|
+
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment, RestTimerLength } 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,6 +45,7 @@ export interface ProgramGenerationParams<T extends HevyTrainerLibraryExercise> {
|
|
|
45
45
|
selectedLevel: TrainingLevel;
|
|
46
46
|
selectedEquipments: GranularEquipment[];
|
|
47
47
|
selectedWorkoutDurationMinutes?: WorkoutDurationMinutes;
|
|
48
|
+
selectedRestTimerLength: RestTimerLength;
|
|
48
49
|
exerciseStore: T[];
|
|
49
50
|
focusMuscle?: SimplifiedMuscleGroup;
|
|
50
51
|
excludedExerciseIds?: Set<string>;
|
|
@@ -71,8 +72,11 @@ export type RepRanges = {
|
|
|
71
72
|
export type RestTimersPerCategory = {
|
|
72
73
|
[key in HevyTrainerExerciseCategory]: number;
|
|
73
74
|
};
|
|
75
|
+
export type CategoryPerRestTimerLength = {
|
|
76
|
+
[key in RestTimerLength]: RestTimersPerCategory;
|
|
77
|
+
};
|
|
74
78
|
export type RestTimers = {
|
|
75
|
-
[key in TrainingGoal]:
|
|
79
|
+
[key in TrainingGoal]: CategoryPerRestTimerLength;
|
|
76
80
|
};
|
|
77
81
|
export type ExercisePriorities = {
|
|
78
82
|
[key in MuscleGroup]: exerciseId[];
|
|
@@ -135,7 +139,7 @@ export interface TrainerProgram {
|
|
|
135
139
|
}
|
|
136
140
|
export declare const getTrainerSetCount: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, frequency: WeeklyTrainingFrequency) => number;
|
|
137
141
|
export declare const getTrainerRepRange: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, exerciseCategory: HevyTrainerExerciseCategory) => RepRange;
|
|
138
|
-
export declare const getTrainerRestTimerSeconds: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, exerciseCategory: HevyTrainerExerciseCategory) => number;
|
|
142
|
+
export declare const getTrainerRestTimerSeconds: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, length: RestTimerLength, exerciseCategory: HevyTrainerExerciseCategory) => number;
|
|
139
143
|
/**
|
|
140
144
|
* Normalizes the exercise category to a HevyTrainerExerciseCategory
|
|
141
145
|
* - 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, exerciseCategory) => {
|
|
207
|
-
return trainerAlgorithmSettings.rest_timers[goal][exerciseCategory];
|
|
206
|
+
const getTrainerRestTimerSeconds = (trainerAlgorithmSettings, goal, length, exerciseCategory) => {
|
|
207
|
+
return trainerAlgorithmSettings.rest_timers[goal][length][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, exerciseStore, focusMuscle, excludedExerciseIds, } = params;
|
|
501
|
+
const { trainerAlgorithmSettings, selectedDays, selectedGoal, selectedLevel, selectedEquipments, selectedWorkoutDurationMinutes, selectedRestTimerLength, 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, exercisePrescription.category),
|
|
568
|
+
restTimerSeconds: (0, exports.getTrainerRestTimerSeconds)(trainerAlgorithmSettings, selectedGoal, selectedRestTimerLength, 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,9 +640,11 @@ 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"];
|
|
643
644
|
export type TrainingGoal = Lookup<typeof trainingGoals>;
|
|
644
645
|
export type TrainingLevel = Lookup<typeof trainingLevels>;
|
|
645
646
|
export type ExerciseCategory = Lookup<typeof exerciseCategories>;
|
|
647
|
+
export type RestTimerLength = typeof restTimerLengths[number];
|
|
646
648
|
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
647
649
|
export declare const hevyTrainerProgramEquipments: readonly ["barbell", "dumbbell", "machine"];
|
|
648
650
|
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"];
|
|
@@ -1259,6 +1261,7 @@ export interface HevyTrainerProgram {
|
|
|
1259
1261
|
focus_muscle?: SimplifiedMuscleGroup;
|
|
1260
1262
|
next_workout_index: number;
|
|
1261
1263
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1264
|
+
rest_timer_length: RestTimerLength;
|
|
1262
1265
|
}
|
|
1263
1266
|
export interface PostHevyTrainerProgramRequestBody {
|
|
1264
1267
|
program: {
|
|
@@ -1271,6 +1274,7 @@ export interface PostHevyTrainerProgramRequestBody {
|
|
|
1271
1274
|
routines: RoutineUpdate[];
|
|
1272
1275
|
next_workout_index?: number;
|
|
1273
1276
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1277
|
+
rest_timer_length: RestTimerLength;
|
|
1274
1278
|
};
|
|
1275
1279
|
}
|
|
1276
1280
|
export interface UpdateHevyTrainerProgramRequestBody {
|
|
@@ -1284,6 +1288,7 @@ export interface UpdateHevyTrainerProgramRequestBody {
|
|
|
1284
1288
|
focus_muscle?: SimplifiedMuscleGroup;
|
|
1285
1289
|
next_workout_index?: number;
|
|
1286
1290
|
workout_duration_minutes?: WorkoutDurationMinutes;
|
|
1291
|
+
rest_timer_length?: RestTimerLength;
|
|
1287
1292
|
routines: {
|
|
1288
1293
|
id: string;
|
|
1289
1294
|
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.
|
|
18
|
-
exports.isOAuthScope = exports.supportedScopes = exports.isSuggestedUserSource = exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isHevyTrainerRoutine = exports.isWorkoutBiometrics = void 0;
|
|
17
|
+
exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.weeklyTrainingFrequencies = exports.isGranularEquipment = exports.granularEquipments = exports.hevyTrainerProgramEquipments = exports.restTimerLengths = 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 = exports.isHeartRateSamples = void 0;
|
|
19
19
|
const typeUtils_1 = require("./typeUtils");
|
|
20
20
|
__exportStar(require("./constants"), exports);
|
|
21
21
|
__exportStar(require("./utils"), exports);
|
|
@@ -227,6 +227,7 @@ exports.exerciseCategories = [
|
|
|
227
227
|
'compound',
|
|
228
228
|
'assistance-compound',
|
|
229
229
|
];
|
|
230
|
+
exports.restTimerLengths = ['short', 'medium', 'long'];
|
|
230
231
|
exports.hevyTrainerProgramEquipments = [
|
|
231
232
|
'barbell',
|
|
232
233
|
'dumbbell',
|