hevy-shared 1.0.1038 → 1.0.1040

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
@@ -29,7 +29,6 @@ export * from './hevyTrainer';
29
29
  export * from './translations';
30
30
  export * from './exerciseLocaleUtils';
31
31
  export * from './getVolumeComparison';
32
- export * from './geography';
33
32
  export type WeightUnit = 'kg' | 'lbs';
34
33
  export declare const isWeightUnit: (x: string) => x is WeightUnit;
35
34
  export type DistanceUnit = 'kilometers' | 'miles';
@@ -1401,19 +1400,15 @@ export interface UserMetadataResponse {
1401
1400
  export interface NetworkInfoRequest {
1402
1401
  networkType: NetworkType;
1403
1402
  }
1404
- export type CommercialGym = {
1403
+ type CommercialGym = {
1405
1404
  type: 'commercial';
1406
1405
  id: string;
1407
1406
  name: string;
1408
1407
  fullAddress: string;
1409
1408
  city: string;
1410
- latitude: number;
1411
- longitude: number;
1409
+ distanceM: number;
1412
1410
  };
1413
- export type HomeGym = {
1414
- type: 'home';
1415
- };
1416
- export type Gym = CommercialGym | HomeGym;
1411
+ export type Gym = CommercialGym;
1417
1412
  export interface StripePrice {
1418
1413
  product_id: string;
1419
1414
  billing_period: 'month' | 'year' | 'pay-once';
package/built/index.js CHANGED
@@ -41,7 +41,6 @@ __exportStar(require("./hevyTrainer"), exports);
41
41
  __exportStar(require("./translations"), exports);
42
42
  __exportStar(require("./exerciseLocaleUtils"), exports);
43
43
  __exportStar(require("./getVolumeComparison"), exports);
44
- __exportStar(require("./geography"), exports);
45
44
  const isWeightUnit = (x) => {
46
45
  return x === 'kg' || x === 'lbs';
47
46
  };
@@ -162,6 +162,7 @@ class WorkoutBuilder {
162
162
  },
163
163
  clientId: '',
164
164
  gymId: undefined,
165
+ isHomeGym: false,
165
166
  });
166
167
  this._exercises = [];
167
168
  }
@@ -11,7 +11,7 @@ export interface WorkoutSync {
11
11
  isMore: boolean;
12
12
  updated_at?: string;
13
13
  }
14
- export type Workout = OwnedWorkout | UserWorkout;
15
- export type WorkoutExercise = OwnedWorkoutExercise | UserWorkoutExercise;
16
- export type WorkoutExerciseSet = OwnedWorkoutExerciseSet | UserWorkoutExerciseSet;
14
+ export type Workout = OwnedWorkout & Partial<UserWorkout>;
15
+ export type WorkoutExercise = OwnedWorkoutExercise & Partial<UserWorkoutExercise>;
16
+ export type WorkoutExerciseSet = OwnedWorkoutExerciseSet & Partial<UserWorkoutExerciseSet>;
17
17
  export declare function isOwnedWorkout(workout: OwnedWorkout | UserWorkout): workout is OwnedWorkout;
@@ -20,7 +20,8 @@ __exportStar(require("./userWorkout"), exports);
20
20
  __exportStar(require("./publicWorkout"), exports);
21
21
  __exportStar(require("./normalizedWorkout"), exports);
22
22
  __exportStar(require("./postWorkoutRequest"), exports);
23
- // Placeholder, will be done better but this works for now
23
+ // Stub
24
24
  function isOwnedWorkout(workout) {
25
- return 'gymId' in workout;
25
+ void workout;
26
+ return true;
26
27
  }
@@ -37,6 +37,7 @@ export interface NormalizedWorkout {
37
37
  biometrics?: WorkoutBiometrics;
38
38
  trainerProgramId: string | undefined;
39
39
  gymId: string | undefined;
40
+ isHomeGym: boolean;
40
41
  }
41
42
  export interface NormalizedSet {
42
43
  index: number;
@@ -40,6 +40,7 @@ export interface PostWorkoutRequestWorkout {
40
40
  is_biometrics_public: boolean;
41
41
  trainer_program_id: string | undefined;
42
42
  gym_id: string | undefined;
43
+ is_home_gym: boolean;
43
44
  }
44
45
  export interface PostWorkoutRequestExercise {
45
46
  title: string;
@@ -1,4 +1,4 @@
1
- import { DistanceUnit, ExerciseType, MuscleGroup, RPE, SetPersonalRecordType, SetType, WeightUnit } from '..';
1
+ import { DistanceUnit, Equipment, ExerciseType, MuscleGroup, RPE, SetPersonalRecordType, SetType, WeightUnit } from '..';
2
2
  export declare const isPublicWorkout: (x: any) => x is PublicWorkout;
3
3
  export interface PublicWorkout {
4
4
  type: 'public';
@@ -39,9 +39,11 @@ export interface PublicWorkoutExercise {
39
39
  superset_id: number | null;
40
40
  rest_seconds: number | null;
41
41
  notes: string;
42
+ priority: number;
42
43
  muscle_group: MuscleGroup;
43
44
  other_muscles: MuscleGroup[];
44
45
  exercise_type: ExerciseType;
46
+ equipment_category: Equipment;
45
47
  url?: string;
46
48
  media_type?: string;
47
49
  custom_exercise_image_url?: string | null;
@@ -1,4 +1,4 @@
1
- import { ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
1
+ import { Equipment, ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
2
2
  export interface UserWorkout {
3
3
  id: string;
4
4
  short_id: string | null;
@@ -6,9 +6,13 @@ export interface UserWorkout {
6
6
  name: string;
7
7
  description?: string;
8
8
  like_count: number;
9
+ /** @deprecated 2.3.4 */
10
+ like_images: string[];
9
11
  preview_workout_likes: PreviewWorkoutLike[];
10
12
  comment_count: number;
11
13
  comments: WorkoutComment[];
14
+ /** @deprecated 1.28.13 */
15
+ image_urls?: string[];
12
16
  media: WorkoutMedia[];
13
17
  is_liked_by_user: boolean;
14
18
  start_time: number;
@@ -21,6 +25,7 @@ export interface UserWorkout {
21
25
  apple_watch: boolean;
22
26
  wearos_watch: boolean;
23
27
  verified: boolean;
28
+ created_at: string;
24
29
  updated_at: string;
25
30
  nth_workout: number;
26
31
  /**
@@ -34,8 +39,13 @@ export interface UserWorkout {
34
39
  */
35
40
  include_warmup_sets: boolean;
36
41
  is_private: boolean;
42
+ /**
43
+ * If applicable, the user ID of the coach who logged this workout
44
+ */
45
+ logged_by_coach_id?: string;
37
46
  biometrics?: WorkoutBiometrics;
38
47
  is_biometrics_public: boolean;
48
+ trainer_program_id: string | undefined;
39
49
  gym: UserWorkoutGym | undefined;
40
50
  }
41
51
  export interface UserWorkoutExercise {
@@ -56,10 +66,17 @@ export interface UserWorkoutExercise {
56
66
  superset_id: number | null;
57
67
  rest_seconds: number | null;
58
68
  notes: string;
69
+ priority: number;
59
70
  muscle_group: MuscleGroup;
60
71
  other_muscles: MuscleGroup[];
61
72
  exercise_type: ExerciseType;
73
+ equipment_category: Equipment;
74
+ url?: string;
75
+ media_type?: string;
76
+ custom_exercise_image_url?: string | null;
62
77
  thumbnail_url?: string | null;
78
+ manual_tag?: string;
79
+ aka?: string;
63
80
  /**
64
81
  * for exercises with two dumbbells
65
82
  *
@@ -85,6 +102,16 @@ export interface UserWorkoutExerciseSet {
85
102
  duration_seconds?: number | null;
86
103
  custom_metric?: number | null;
87
104
  rpe?: RPE | null;
105
+ /**
106
+ * @deprecated 1.29.17 -
107
+ * we can only set this to `best_weight`, `best_reps`, `best_duration` or
108
+ * `best_distance`. sending anything else would cause older clients to crash.
109
+ * newer clients will ignore this field and use the `prs` field instead.
110
+ */
111
+ personalRecords?: Array<{
112
+ type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
113
+ value: number;
114
+ }>;
88
115
  prs: {
89
116
  type: SetPersonalRecordType;
90
117
  value: number;
@@ -96,8 +123,5 @@ type CommercialGym = {
96
123
  name: string;
97
124
  city: string;
98
125
  };
99
- type HomeGym = {
100
- type: 'home';
101
- };
102
- export type UserWorkoutGym = CommercialGym | HomeGym;
126
+ export type UserWorkoutGym = CommercialGym;
103
127
  export {};
@@ -1,4 +1,4 @@
1
- import { ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
1
+ import { Equipment, ExerciseType, MuscleGroup, PreviewWorkoutLike, RPE, SetPersonalRecordType, SetType, WorkoutBiometrics, WorkoutComment, WorkoutMedia } from '..';
2
2
  export interface OwnedWorkout {
3
3
  id: string;
4
4
  short_id: string | null;
@@ -6,9 +6,13 @@ export interface OwnedWorkout {
6
6
  name: string;
7
7
  description?: string;
8
8
  like_count: number;
9
+ /** @deprecated 2.3.4 */
10
+ like_images: string[];
9
11
  preview_workout_likes: PreviewWorkoutLike[];
10
12
  comment_count: number;
11
13
  comments: WorkoutComment[];
14
+ /** @deprecated 1.28.13 */
15
+ image_urls?: string[];
12
16
  media: WorkoutMedia[];
13
17
  is_liked_by_user: boolean;
14
18
  start_time: number;
@@ -24,11 +28,26 @@ export interface OwnedWorkout {
24
28
  created_at: string;
25
29
  updated_at: string;
26
30
  nth_workout: number;
31
+ /**
32
+ * See https://github.com/hevyapp/hevy-backend/pull/193 to understand
33
+ * why we added estimated_volume_kg
34
+ */
35
+ estimated_volume_kg: number;
36
+ /**
37
+ * Whether to include warmup sets in various calculations.
38
+ * https://github.com/hevyapp/hevy-shared/pull/312
39
+ */
40
+ include_warmup_sets: boolean;
27
41
  is_private: boolean;
42
+ /**
43
+ * If applicable, the user ID of the coach who logged this workout
44
+ */
45
+ logged_by_coach_id?: string;
28
46
  biometrics?: WorkoutBiometrics;
29
47
  is_biometrics_public: boolean;
30
48
  trainer_program_id: string | undefined;
31
49
  gym_id: string | undefined;
50
+ is_home_gym: boolean;
32
51
  }
33
52
  export interface TrainerWorkout extends OwnedWorkout {
34
53
  trainer_program_id: string;
@@ -51,10 +70,17 @@ export interface OwnedWorkoutExercise {
51
70
  superset_id: number | null;
52
71
  rest_seconds: number | null;
53
72
  notes: string;
73
+ priority: number;
54
74
  muscle_group: MuscleGroup;
55
75
  other_muscles: MuscleGroup[];
56
76
  exercise_type: ExerciseType;
77
+ equipment_category: Equipment;
78
+ url?: string;
79
+ media_type?: string;
80
+ custom_exercise_image_url?: string | null;
57
81
  thumbnail_url?: string | null;
82
+ manual_tag?: string;
83
+ aka?: string;
58
84
  /**
59
85
  * for exercises with two dumbbells
60
86
  *
@@ -80,6 +106,16 @@ export interface OwnedWorkoutExerciseSet {
80
106
  duration_seconds?: number | null;
81
107
  custom_metric?: number | null;
82
108
  rpe?: RPE | null;
109
+ /**
110
+ * @deprecated 1.29.17 -
111
+ * we can only set this to `best_weight`, `best_reps`, `best_duration` or
112
+ * `best_distance`. sending anything else would cause older clients to crash.
113
+ * newer clients will ignore this field and use the `prs` field instead.
114
+ */
115
+ personalRecords?: Array<{
116
+ type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
117
+ value: number;
118
+ }>;
83
119
  prs: {
84
120
  type: SetPersonalRecordType;
85
121
  value: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.1038",
3
+ "version": "1.0.1040",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",
@@ -1 +0,0 @@
1
- export declare const distanceMBetween: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.distanceMBetween = void 0;
4
- const haversineDistance = (lat1, lon1, lat2, lon2) => {
5
- const R = 6371;
6
- const dLat = ((lat2 - lat1) * Math.PI) / 180;
7
- const dLon = ((lon2 - lon1) * Math.PI) / 180;
8
- const a = Math.sin(dLat / 2) ** 2 +
9
- Math.cos((lat1 * Math.PI) / 180) *
10
- Math.cos((lat2 * Math.PI) / 180) *
11
- Math.sin(dLon / 2) ** 2;
12
- return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
13
- };
14
- const distanceMBetween = (lat1, lon1, lat2, lon2) => Math.round(haversineDistance(lat1, lon1, lat2, lon2) * 1000);
15
- exports.distanceMBetween = distanceMBetween;
@@ -1 +0,0 @@
1
- export {};
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const geography_1 = require("../geography");
13
- describe('Geography utils', () => {
14
- describe('distanceMBetween', () => {
15
- it('Calculates the distance between two sets of coordinates', () => __awaiter(void 0, void 0, void 0, function* () {
16
- expect((0, geography_1.distanceMBetween)(51.001, 52, 51, 52)).toBe(111);
17
- expect((0, geography_1.distanceMBetween)(51.002, 52, 51, 52)).toBe(222);
18
- expect((0, geography_1.distanceMBetween)(50.999, 52, 51, 52)).toBe(111);
19
- expect((0, geography_1.distanceMBetween)(51.01, 52, 51, 52)).toBe(1112);
20
- expect((0, geography_1.distanceMBetween)(51.04, 52, 51, 52)).toBe(4448);
21
- expect((0, geography_1.distanceMBetween)(51.035, 52.035, 51, 52)).toBe(4598);
22
- expect((0, geography_1.distanceMBetween)(50.965, 51.965, 51, 52)).toBe(4599);
23
- }));
24
- });
25
- });