hevy-shared 1.0.559 → 1.0.561

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 CHANGED
@@ -465,10 +465,9 @@ export interface UserPreferences {
465
465
  live_pr_volume?: LivePRVolumeOption;
466
466
  inline_set_timer_enabled?: boolean;
467
467
  default_workout_visibility_public?: boolean;
468
- /** Only updateable by the backend within a special API */
469
- volume_includes_warmup_sets?: boolean;
468
+ default_workout_biometrics_visibility_public?: boolean;
470
469
  }
471
- export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username' | 'volume_includes_warmup_sets'>;
470
+ export type UpdateUserPreferencesRequest = Omit<UserPreferences, 'username'>;
472
471
  export type FollowingStatus = 'not-following' | 'following' | 'requested';
473
472
  export type FollowingStatusMap = {
474
473
  [id: string]: Omit<FollowingStatus, 'not-following'>;
@@ -775,16 +774,13 @@ export interface Workout {
775
774
  * why we added estimated_volume_kg
776
775
  */
777
776
  estimated_volume_kg: number;
778
- /**
779
- * Whether to include warmup sets in various calculations.
780
- * https://github.com/hevyapp/hevy-shared/pull/312
781
- */
782
- include_warmup_sets: boolean;
783
777
  is_private: boolean;
784
778
  /**
785
779
  * If applicable, the user ID of the coach who logged this workout
786
780
  */
787
781
  logged_by_coach_id?: string;
782
+ biometrics?: WorkoutBiometrics;
783
+ is_biometrics_public: boolean;
788
784
  }
789
785
  export interface CustomExerciseImage {
790
786
  type: 'image';
@@ -861,6 +857,18 @@ export interface PostWorkoutRequestWorkout {
861
857
  wearos_watch: boolean;
862
858
  workout_id: string;
863
859
  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;
864
872
  }
865
873
  export interface PostWorkoutRequestExercise {
866
874
  title: string;
@@ -892,7 +900,7 @@ export interface PostWorkoutRequestSet {
892
900
  * update the corresponding values of the workout in the database, and those
893
901
  * that are undefined will not be changed.
894
902
  */
895
- export type UpdateWorkoutRequestWorkout = Partial<Pick<PostWorkoutRequestWorkout, 'title' | 'description' | 'media' | 'exercises' | 'is_private'>> & {
903
+ export type UpdateWorkoutRequestWorkout = Partial<Pick<PostWorkoutRequestWorkout, 'title' | 'description' | 'media' | 'exercises' | 'is_private' | 'is_biometrics_public'>> & {
896
904
  start_and_end_time?: Required<Pick<PostWorkoutRequestWorkout, 'start_time' | 'end_time'>>;
897
905
  };
898
906
  /** Routines */
@@ -1326,18 +1334,6 @@ export interface WarmupCalculatorData {
1326
1334
  dumbbellRoundingSettingLbs: number;
1327
1335
  warmupSets: WarmupSet[];
1328
1336
  }
1329
- export interface RecalculateSetPRProgress {
1330
- numWorkoutsProcessed: number;
1331
- numWorkoutsTotal: number;
1332
- }
1333
- export type RecalculateSetPRStatusResponse = {
1334
- type: 'ready';
1335
- } | {
1336
- type: 'busy';
1337
- progress: RecalculateSetPRProgress;
1338
- } | {
1339
- type: 'error';
1340
- };
1341
1337
  export interface ExerciseTemplateUnit {
1342
1338
  id: number;
1343
1339
  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.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;
17
+ exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isWorkoutBiometrics = exports.isHeartRateSamples = 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,6 +212,30 @@ 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;
215
239
  exports.measurementsList = [
216
240
  'weight_kg',
217
241
  'fat_percent',
@@ -1,4 +1,4 @@
1
- import { ExerciseType, RPE, SetType, ShareToPlatform, WorkoutMedia, WorkoutVisibility } from '.';
1
+ import { ExerciseType, RPE, SetType, ShareToPlatform, WorkoutBiometrics, 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.
@@ -33,6 +33,7 @@ export interface NormalizedWorkout {
33
33
  [key in ShareToPlatform]: boolean;
34
34
  };
35
35
  clientId: string;
36
+ biometrics?: WorkoutBiometrics;
36
37
  }
37
38
  export interface NormalizedSet {
38
39
  index: number;
@@ -4,10 +4,7 @@ const workoutVolume_1 = require("../workoutVolume");
4
4
  describe('workoutVolume', () => {
5
5
  describe('estimatedWorkoutVolumeKg', () => {
6
6
  it('calculates the correct workout volume', () => {
7
- const emptyWorkout = {
8
- exercises: [],
9
- include_warmup_sets: true,
10
- };
7
+ const emptyWorkout = { exercises: [] };
11
8
  const weightRepsWorkout = {
12
9
  exercises: [
13
10
  {
@@ -17,7 +14,6 @@ describe('workoutVolume', () => {
17
14
  hundred_percent_bodyweight_exercise: false,
18
15
  sets: [
19
16
  {
20
- indicator: 'normal',
21
17
  weight_kg: 100,
22
18
  reps: 10,
23
19
  distance_meters: 0,
@@ -25,7 +21,6 @@ describe('workoutVolume', () => {
25
21
  ],
26
22
  },
27
23
  ],
28
- include_warmup_sets: true,
29
24
  };
30
25
  const pullUpWorkout = {
31
26
  exercises: [
@@ -36,7 +31,6 @@ describe('workoutVolume', () => {
36
31
  hundred_percent_bodyweight_exercise: true,
37
32
  sets: [
38
33
  {
39
- indicator: 'normal',
40
34
  weight_kg: 0,
41
35
  reps: 10,
42
36
  distance_meters: 0,
@@ -44,7 +38,6 @@ describe('workoutVolume', () => {
44
38
  ],
45
39
  },
46
40
  ],
47
- include_warmup_sets: true,
48
41
  };
49
42
  const assistedPullUpWorkout = {
50
43
  exercises: [
@@ -55,7 +48,6 @@ describe('workoutVolume', () => {
55
48
  hundred_percent_bodyweight_exercise: true,
56
49
  sets: [
57
50
  {
58
- indicator: 'normal',
59
51
  weight_kg: 10,
60
52
  reps: 10,
61
53
  distance_meters: 0,
@@ -63,7 +55,6 @@ describe('workoutVolume', () => {
63
55
  ],
64
56
  },
65
57
  ],
66
- include_warmup_sets: true,
67
58
  };
68
59
  const weightedPullUpWorkout = {
69
60
  exercises: [
@@ -74,7 +65,6 @@ describe('workoutVolume', () => {
74
65
  hundred_percent_bodyweight_exercise: true,
75
66
  sets: [
76
67
  {
77
- indicator: 'normal',
78
68
  weight_kg: 10,
79
69
  reps: 10,
80
70
  distance_meters: 0,
@@ -82,7 +72,6 @@ describe('workoutVolume', () => {
82
72
  ],
83
73
  },
84
74
  ],
85
- include_warmup_sets: true,
86
75
  };
87
76
  const shortDistanceWeightWorkout = {
88
77
  exercises: [
@@ -93,7 +82,6 @@ describe('workoutVolume', () => {
93
82
  hundred_percent_bodyweight_exercise: false,
94
83
  sets: [
95
84
  {
96
- indicator: 'normal',
97
85
  weight_kg: 100,
98
86
  reps: 0,
99
87
  distance_meters: 10,
@@ -101,7 +89,6 @@ describe('workoutVolume', () => {
101
89
  ],
102
90
  },
103
91
  ],
104
- include_warmup_sets: true,
105
92
  };
106
93
  expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
107
94
  bodyweightKg: 100,
@@ -137,49 +124,8 @@ describe('workoutVolume', () => {
137
124
  ...weightedPullUpWorkout.exercises,
138
125
  ...shortDistanceWeightWorkout.exercises,
139
126
  ],
140
- include_warmup_sets: true,
141
127
  },
142
128
  })).toBe(5000);
143
129
  });
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
- });
184
130
  });
185
131
  });
@@ -1,4 +1,4 @@
1
- import { BodyMeasurement, ExerciseType, BaseExerciseTemplate, WorkoutExerciseSet } from '.';
1
+ import { BodyMeasurement, ExerciseType, BaseExerciseTemplate } from '.';
2
2
  export declare const isVolumeDoublingSupportableForExerciseTemplate: (exerciseTemplate: Pick<BaseExerciseTemplate, "equipment_category" | "exercise_type">) => boolean;
3
3
  export interface VolumeCalculableWorkout {
4
4
  exercises: {
@@ -6,9 +6,13 @@ export interface VolumeCalculableWorkout {
6
6
  exercise_template_id: string;
7
7
  volume_doubling_enabled: boolean;
8
8
  hundred_percent_bodyweight_exercise: boolean;
9
- sets: Pick<WorkoutExerciseSet, 'indicator' | 'weight_kg' | 'reps' | 'distance_meters' | 'duration_seconds'>[];
9
+ sets: {
10
+ weight_kg?: number | null;
11
+ reps?: number | null;
12
+ distance_meters?: number | null;
13
+ duration_seconds?: number | null;
14
+ }[];
10
15
  }[];
11
- include_warmup_sets: boolean;
12
16
  }
13
17
  export interface TimestampedVolumeCalculableWorkout extends VolumeCalculableWorkout {
14
18
  start_time: number;
@@ -98,9 +98,7 @@ 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
102
- .filter((s) => workout.include_warmup_sets || s.indicator !== 'warmup')
103
- .map((s) => {
101
+ return e.sets.map((s) => {
104
102
  var _a, _b, _c;
105
103
  return {
106
104
  type: e.exercise_type || 'weight_reps',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.559",
3
+ "version": "1.0.561",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",