hevy-shared 1.0.562 → 1.0.564
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/index.d.ts +26 -17
- package/built/index.js +1 -25
- package/built/normalizedWorkoutUtils.d.ts +1 -3
- package/built/tests/testUtils.js +0 -1
- package/built/tests/workoutVolume.test.js +55 -1
- package/built/workoutVolume.d.ts +3 -7
- package/built/workoutVolume.js +3 -1
- package/package.json +1 -1
package/built/index.d.ts
CHANGED
|
@@ -465,9 +465,10 @@ export interface UserPreferences {
|
|
|
465
465
|
live_pr_volume?: LivePRVolumeOption;
|
|
466
466
|
inline_set_timer_enabled?: boolean;
|
|
467
467
|
default_workout_visibility_public?: boolean;
|
|
468
|
-
|
|
468
|
+
/** Only updateable by the backend within a special API */
|
|
469
|
+
volume_includes_warmup_sets?: boolean;
|
|
469
470
|
}
|
|
470
|
-
export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username'>;
|
|
471
|
+
export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username' | 'volume_includes_warmup_sets'>;
|
|
471
472
|
export type FollowingStatus = 'not-following' | 'following' | 'requested';
|
|
472
473
|
export type FollowingStatusMap = {
|
|
473
474
|
[id: string]: Omit<FollowingStatus, 'not-following'>;
|
|
@@ -506,6 +507,10 @@ export interface RoutineMetadata {
|
|
|
506
507
|
short_id: string;
|
|
507
508
|
title: string;
|
|
508
509
|
}
|
|
510
|
+
export type PreviewMutualUser = {
|
|
511
|
+
username: string;
|
|
512
|
+
profile_pic: string | null;
|
|
513
|
+
};
|
|
509
514
|
export interface UserProfile {
|
|
510
515
|
username: string;
|
|
511
516
|
verified: boolean;
|
|
@@ -523,6 +528,7 @@ export interface UserProfile {
|
|
|
523
528
|
following_count: number;
|
|
524
529
|
routines: RoutineMetadata[];
|
|
525
530
|
weekly_workout_durations: WeeklyWorkoutDuration[];
|
|
531
|
+
mutual_followers: PreviewMutualUser[];
|
|
526
532
|
}
|
|
527
533
|
export interface PublicUserProfile {
|
|
528
534
|
private_profile: boolean;
|
|
@@ -774,13 +780,16 @@ export interface Workout {
|
|
|
774
780
|
* why we added estimated_volume_kg
|
|
775
781
|
*/
|
|
776
782
|
estimated_volume_kg: number;
|
|
783
|
+
/**
|
|
784
|
+
* Whether to include warmup sets in various calculations.
|
|
785
|
+
* https://github.com/hevyapp/hevy-shared/pull/312
|
|
786
|
+
*/
|
|
787
|
+
include_warmup_sets: boolean;
|
|
777
788
|
is_private: boolean;
|
|
778
789
|
/**
|
|
779
790
|
* If applicable, the user ID of the coach who logged this workout
|
|
780
791
|
*/
|
|
781
792
|
logged_by_coach_id?: string;
|
|
782
|
-
biometrics?: WorkoutBiometrics;
|
|
783
|
-
is_biometrics_public: boolean;
|
|
784
793
|
}
|
|
785
794
|
export interface CustomExerciseImage {
|
|
786
795
|
type: 'image';
|
|
@@ -857,18 +866,6 @@ export interface PostWorkoutRequestWorkout {
|
|
|
857
866
|
wearos_watch: boolean;
|
|
858
867
|
workout_id: string;
|
|
859
868
|
is_private: boolean;
|
|
860
|
-
biometrics?: WorkoutBiometrics;
|
|
861
|
-
is_biometrics_public: boolean;
|
|
862
|
-
}
|
|
863
|
-
export declare const isHeartRateSamples: (x: any) => x is HeartRateSample[];
|
|
864
|
-
export declare const isWorkoutBiometrics: (x: any) => x is WorkoutBiometrics;
|
|
865
|
-
export interface WorkoutBiometrics {
|
|
866
|
-
total_calories?: number;
|
|
867
|
-
heart_rate_samples?: HeartRateSample[];
|
|
868
|
-
}
|
|
869
|
-
export interface HeartRateSample {
|
|
870
|
-
timestamp_ms: number;
|
|
871
|
-
bpm: number;
|
|
872
869
|
}
|
|
873
870
|
export interface PostWorkoutRequestExercise {
|
|
874
871
|
title: string;
|
|
@@ -900,7 +897,7 @@ export interface PostWorkoutRequestSet {
|
|
|
900
897
|
* update the corresponding values of the workout in the database, and those
|
|
901
898
|
* that are undefined will not be changed.
|
|
902
899
|
*/
|
|
903
|
-
export type UpdateWorkoutRequestWorkout = Partial<Pick<PostWorkoutRequestWorkout, 'title' | 'description' | 'media' | 'exercises' | 'is_private'
|
|
900
|
+
export type UpdateWorkoutRequestWorkout = Partial<Pick<PostWorkoutRequestWorkout, 'title' | 'description' | 'media' | 'exercises' | 'is_private'>> & {
|
|
904
901
|
start_and_end_time?: Required<Pick<PostWorkoutRequestWorkout, 'start_time' | 'end_time'>>;
|
|
905
902
|
};
|
|
906
903
|
/** Routines */
|
|
@@ -1334,6 +1331,18 @@ export interface WarmupCalculatorData {
|
|
|
1334
1331
|
dumbbellRoundingSettingLbs: number;
|
|
1335
1332
|
warmupSets: WarmupSet[];
|
|
1336
1333
|
}
|
|
1334
|
+
export interface RecalculateSetPRProgress {
|
|
1335
|
+
numWorkoutsProcessed: number;
|
|
1336
|
+
numWorkoutsTotal: number;
|
|
1337
|
+
}
|
|
1338
|
+
export type RecalculateSetPRStatusResponse = {
|
|
1339
|
+
type: 'ready';
|
|
1340
|
+
} | {
|
|
1341
|
+
type: 'busy';
|
|
1342
|
+
progress: RecalculateSetPRProgress;
|
|
1343
|
+
} | {
|
|
1344
|
+
type: 'error';
|
|
1345
|
+
};
|
|
1337
1346
|
export interface ExerciseTemplateUnit {
|
|
1338
1347
|
id: number;
|
|
1339
1348
|
exercise_template_id: string;
|
package/built/index.js
CHANGED
|
@@ -14,7 +14,7 @@ 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.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.
|
|
17
|
+
exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.supportedInstructionsLanguages = exports.isCustomExerciseType = exports.customExericseTypes = exports.isExerciseType = exports.exerciseTypes = exports.isExerciseRepType = exports.exerciseRepTypes = exports.isEquipmentFilter = exports.equipmentFilters = exports.isEquipment = exports.equipments = exports.isMuscleGroupFilter = exports.muscleGroupFilters = exports.isMuscleGroup = exports.muscleGroups = 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
18
|
const typeUtils_1 = require("./typeUtils");
|
|
19
19
|
__exportStar(require("./constants"), exports);
|
|
20
20
|
__exportStar(require("./utils"), exports);
|
|
@@ -212,30 +212,6 @@ const isPublicWorkout = (x) => {
|
|
|
212
212
|
return x.type === 'public';
|
|
213
213
|
};
|
|
214
214
|
exports.isPublicWorkout = isPublicWorkout;
|
|
215
|
-
const isHeartRateSamples = (x) => {
|
|
216
|
-
if (!x)
|
|
217
|
-
return false;
|
|
218
|
-
if (Array.isArray(x)) {
|
|
219
|
-
for (const sample of x) {
|
|
220
|
-
if (typeof sample.timestamp_ms !== 'number' ||
|
|
221
|
-
typeof sample.bpm !== 'number') {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return true;
|
|
227
|
-
};
|
|
228
|
-
exports.isHeartRateSamples = isHeartRateSamples;
|
|
229
|
-
const isWorkoutBiometrics = (x) => {
|
|
230
|
-
if (!x)
|
|
231
|
-
return false;
|
|
232
|
-
const maybeCalories = x.total_calories;
|
|
233
|
-
const maybeHeartRateSamples = x.heart_rate_samples;
|
|
234
|
-
const caloriesAreValid = !maybeCalories || (typeof maybeCalories === 'number' && maybeCalories >= 0);
|
|
235
|
-
return ((caloriesAreValid && !maybeHeartRateSamples) ||
|
|
236
|
-
(0, exports.isHeartRateSamples)(maybeHeartRateSamples));
|
|
237
|
-
};
|
|
238
|
-
exports.isWorkoutBiometrics = isWorkoutBiometrics;
|
|
239
215
|
exports.measurementsList = [
|
|
240
216
|
'weight_kg',
|
|
241
217
|
'fat_percent',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExerciseType, RPE, SetType, ShareToPlatform,
|
|
1
|
+
import { ExerciseType, RPE, SetType, ShareToPlatform, WorkoutMedia, WorkoutVisibility } from '.';
|
|
2
2
|
/**
|
|
3
3
|
* Events are used to determine the start time, end time and duration of a
|
|
4
4
|
* `NormalizedWorkout`, in a way that can be persisted to disk.
|
|
@@ -29,12 +29,10 @@ export interface NormalizedWorkout {
|
|
|
29
29
|
appleWatch: boolean;
|
|
30
30
|
wearosWatch: boolean;
|
|
31
31
|
workoutVisibility: WorkoutVisibility;
|
|
32
|
-
isWorkoutBiometricsPublic: boolean;
|
|
33
32
|
shareTo: {
|
|
34
33
|
[key in ShareToPlatform]: boolean;
|
|
35
34
|
};
|
|
36
35
|
clientId: string;
|
|
37
|
-
biometrics?: WorkoutBiometrics;
|
|
38
36
|
}
|
|
39
37
|
export interface NormalizedSet {
|
|
40
38
|
index: number;
|
package/built/tests/testUtils.js
CHANGED
|
@@ -4,7 +4,10 @@ const workoutVolume_1 = require("../workoutVolume");
|
|
|
4
4
|
describe('workoutVolume', () => {
|
|
5
5
|
describe('estimatedWorkoutVolumeKg', () => {
|
|
6
6
|
it('calculates the correct workout volume', () => {
|
|
7
|
-
const emptyWorkout = {
|
|
7
|
+
const emptyWorkout = {
|
|
8
|
+
exercises: [],
|
|
9
|
+
include_warmup_sets: true,
|
|
10
|
+
};
|
|
8
11
|
const weightRepsWorkout = {
|
|
9
12
|
exercises: [
|
|
10
13
|
{
|
|
@@ -14,6 +17,7 @@ describe('workoutVolume', () => {
|
|
|
14
17
|
hundred_percent_bodyweight_exercise: false,
|
|
15
18
|
sets: [
|
|
16
19
|
{
|
|
20
|
+
indicator: 'normal',
|
|
17
21
|
weight_kg: 100,
|
|
18
22
|
reps: 10,
|
|
19
23
|
distance_meters: 0,
|
|
@@ -21,6 +25,7 @@ describe('workoutVolume', () => {
|
|
|
21
25
|
],
|
|
22
26
|
},
|
|
23
27
|
],
|
|
28
|
+
include_warmup_sets: true,
|
|
24
29
|
};
|
|
25
30
|
const pullUpWorkout = {
|
|
26
31
|
exercises: [
|
|
@@ -31,6 +36,7 @@ describe('workoutVolume', () => {
|
|
|
31
36
|
hundred_percent_bodyweight_exercise: true,
|
|
32
37
|
sets: [
|
|
33
38
|
{
|
|
39
|
+
indicator: 'normal',
|
|
34
40
|
weight_kg: 0,
|
|
35
41
|
reps: 10,
|
|
36
42
|
distance_meters: 0,
|
|
@@ -38,6 +44,7 @@ describe('workoutVolume', () => {
|
|
|
38
44
|
],
|
|
39
45
|
},
|
|
40
46
|
],
|
|
47
|
+
include_warmup_sets: true,
|
|
41
48
|
};
|
|
42
49
|
const assistedPullUpWorkout = {
|
|
43
50
|
exercises: [
|
|
@@ -48,6 +55,7 @@ describe('workoutVolume', () => {
|
|
|
48
55
|
hundred_percent_bodyweight_exercise: true,
|
|
49
56
|
sets: [
|
|
50
57
|
{
|
|
58
|
+
indicator: 'normal',
|
|
51
59
|
weight_kg: 10,
|
|
52
60
|
reps: 10,
|
|
53
61
|
distance_meters: 0,
|
|
@@ -55,6 +63,7 @@ describe('workoutVolume', () => {
|
|
|
55
63
|
],
|
|
56
64
|
},
|
|
57
65
|
],
|
|
66
|
+
include_warmup_sets: true,
|
|
58
67
|
};
|
|
59
68
|
const weightedPullUpWorkout = {
|
|
60
69
|
exercises: [
|
|
@@ -65,6 +74,7 @@ describe('workoutVolume', () => {
|
|
|
65
74
|
hundred_percent_bodyweight_exercise: true,
|
|
66
75
|
sets: [
|
|
67
76
|
{
|
|
77
|
+
indicator: 'normal',
|
|
68
78
|
weight_kg: 10,
|
|
69
79
|
reps: 10,
|
|
70
80
|
distance_meters: 0,
|
|
@@ -72,6 +82,7 @@ describe('workoutVolume', () => {
|
|
|
72
82
|
],
|
|
73
83
|
},
|
|
74
84
|
],
|
|
85
|
+
include_warmup_sets: true,
|
|
75
86
|
};
|
|
76
87
|
const shortDistanceWeightWorkout = {
|
|
77
88
|
exercises: [
|
|
@@ -82,6 +93,7 @@ describe('workoutVolume', () => {
|
|
|
82
93
|
hundred_percent_bodyweight_exercise: false,
|
|
83
94
|
sets: [
|
|
84
95
|
{
|
|
96
|
+
indicator: 'normal',
|
|
85
97
|
weight_kg: 100,
|
|
86
98
|
reps: 0,
|
|
87
99
|
distance_meters: 10,
|
|
@@ -89,6 +101,7 @@ describe('workoutVolume', () => {
|
|
|
89
101
|
],
|
|
90
102
|
},
|
|
91
103
|
],
|
|
104
|
+
include_warmup_sets: true,
|
|
92
105
|
};
|
|
93
106
|
expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
|
|
94
107
|
bodyweightKg: 100,
|
|
@@ -124,8 +137,49 @@ describe('workoutVolume', () => {
|
|
|
124
137
|
...weightedPullUpWorkout.exercises,
|
|
125
138
|
...shortDistanceWeightWorkout.exercises,
|
|
126
139
|
],
|
|
140
|
+
include_warmup_sets: true,
|
|
127
141
|
},
|
|
128
142
|
})).toBe(5000);
|
|
129
143
|
});
|
|
144
|
+
it('takes warmup sets into account only if `include_warmup_sets` === `true`', () => {
|
|
145
|
+
const workoutWithWarmupSets = {
|
|
146
|
+
exercises: [
|
|
147
|
+
{
|
|
148
|
+
exercise_type: 'weight_reps',
|
|
149
|
+
exercise_template_id: 'asd',
|
|
150
|
+
volume_doubling_enabled: false,
|
|
151
|
+
hundred_percent_bodyweight_exercise: false,
|
|
152
|
+
sets: [
|
|
153
|
+
{
|
|
154
|
+
indicator: 'warmup',
|
|
155
|
+
weight_kg: 100,
|
|
156
|
+
reps: 10,
|
|
157
|
+
distance_meters: 0,
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
indicator: 'normal',
|
|
161
|
+
weight_kg: 100,
|
|
162
|
+
reps: 10,
|
|
163
|
+
distance_meters: 0,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
indicator: 'normal',
|
|
167
|
+
weight_kg: 100,
|
|
168
|
+
reps: 10,
|
|
169
|
+
distance_meters: 0,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
|
|
176
|
+
bodyweightKg: 100,
|
|
177
|
+
workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: false }),
|
|
178
|
+
})).toBe(2000);
|
|
179
|
+
expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
|
|
180
|
+
bodyweightKg: 100,
|
|
181
|
+
workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: true }),
|
|
182
|
+
})).toBe(3000);
|
|
183
|
+
});
|
|
130
184
|
});
|
|
131
185
|
});
|
package/built/workoutVolume.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BodyMeasurement, ExerciseType, BaseExerciseTemplate } from '.';
|
|
1
|
+
import { BodyMeasurement, ExerciseType, BaseExerciseTemplate, WorkoutExerciseSet } from '.';
|
|
2
2
|
export declare const isVolumeDoublingSupportableForExerciseTemplate: (exerciseTemplate: Pick<BaseExerciseTemplate, "equipment_category" | "exercise_type">) => boolean;
|
|
3
3
|
export interface VolumeCalculableWorkout {
|
|
4
4
|
exercises: {
|
|
@@ -6,13 +6,9 @@ export interface VolumeCalculableWorkout {
|
|
|
6
6
|
exercise_template_id: string;
|
|
7
7
|
volume_doubling_enabled: boolean;
|
|
8
8
|
hundred_percent_bodyweight_exercise: boolean;
|
|
9
|
-
sets:
|
|
10
|
-
weight_kg?: number | null;
|
|
11
|
-
reps?: number | null;
|
|
12
|
-
distance_meters?: number | null;
|
|
13
|
-
duration_seconds?: number | null;
|
|
14
|
-
}[];
|
|
9
|
+
sets: Pick<WorkoutExerciseSet, 'indicator' | 'weight_kg' | 'reps' | 'distance_meters' | 'duration_seconds'>[];
|
|
15
10
|
}[];
|
|
11
|
+
include_warmup_sets: boolean;
|
|
16
12
|
}
|
|
17
13
|
export interface TimestampedVolumeCalculableWorkout extends VolumeCalculableWorkout {
|
|
18
14
|
start_time: number;
|
package/built/workoutVolume.js
CHANGED
|
@@ -98,7 +98,9 @@ const setVolumeKg = (set, bodyweightKg) => {
|
|
|
98
98
|
exports.setVolumeKg = setVolumeKg;
|
|
99
99
|
const workoutToWorkoutVolumeSets = (workout) => {
|
|
100
100
|
const unflatSets = workout.exercises.map((e) => {
|
|
101
|
-
return e.sets
|
|
101
|
+
return e.sets
|
|
102
|
+
.filter((s) => workout.include_warmup_sets || s.indicator !== 'warmup')
|
|
103
|
+
.map((s) => {
|
|
102
104
|
var _a, _b, _c;
|
|
103
105
|
return {
|
|
104
106
|
type: e.exercise_type || 'weight_reps',
|