hevy-shared 1.0.1055 → 1.0.1057

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.
@@ -135,8 +135,6 @@ export type ExerciseReplacements = {
135
135
  };
136
136
  export interface WorkoutTemplate {
137
137
  exercises: ExercisePrescription[];
138
- /** @deprecated Because this is english-only and not translatable so we are not using it currently */
139
- notes?: string;
140
138
  }
141
139
  export type Templates = {
142
140
  [key in TrainerWorkoutTemplateName]: WorkoutTemplate;
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';
@@ -303,6 +302,7 @@ export interface BackofficeExistingUserResponse {
303
302
  public_api_key: string | null;
304
303
  limited_discovery: boolean;
305
304
  coach_trial_expire_date?: string;
305
+ email_consent: boolean;
306
306
  hevy_trainer_program: BackofficeTrainerProgram | null;
307
307
  }
308
308
  /**
@@ -1527,8 +1527,7 @@ type CommercialGym = {
1527
1527
  name: string;
1528
1528
  fullAddress: string;
1529
1529
  city: string;
1530
- latitude: number;
1531
- longitude: number;
1530
+ distanceM: number;
1532
1531
  };
1533
1532
  export type Gym = CommercialGym;
1534
1533
  export interface StripePrice {
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
  };
@@ -592,7 +592,6 @@ describe('generateProgram', () => {
592
592
  exercises: [
593
593
  { muscle_group: 'chest', category: 'compound', warmup_set_count: 2 },
594
594
  ],
595
- notes: 'Hit the chest hard.',
596
595
  };
597
596
  return settings;
598
597
  };
@@ -4,14 +4,7 @@ export type DeepReadonly<T> = {
4
4
  readonly [P in keyof T]: T[P] extends (...args: any[]) => any ? T[P] : DeepReadonly<T[P]>;
5
5
  };
6
6
  export declare const exhaustiveTypeCheck: (_: never) => undefined;
7
- export declare class ExhaustiveTypeException extends Error {
8
- constructor(type: never);
9
- }
10
- export declare const exhaustiveTypeException: (type: never) => ExhaustiveTypeException;
11
- export declare class AssertionError extends Error {
12
- constructor(message: string);
13
- }
14
- export declare function assert(value: {}, message?: string): asserts value;
7
+ export declare const exhaustiveTypeException: (type: never) => Error;
15
8
  export type Some<T> = {
16
9
  hasValue: true;
17
10
  value: T;
@@ -1,37 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TODO = exports.typeSafeIndex = exports.parseJSON = exports.assertNonNullish = exports.dangerousUncheckedTypeCast = exports.AssertionError = exports.exhaustiveTypeException = exports.ExhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
4
- exports.assert = assert;
3
+ exports.TODO = exports.typeSafeIndex = exports.parseJSON = exports.assertNonNullish = exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
5
4
  exports.isNonNullish = isNonNullish;
6
5
  const isInArray = (value, array) => array.includes(value);
7
6
  exports.isInArray = isInArray;
8
7
  const exhaustiveTypeCheck = (_) => void _;
9
8
  exports.exhaustiveTypeCheck = exhaustiveTypeCheck;
10
- class ExhaustiveTypeException extends Error {
11
- constructor(type) {
12
- const message = `Assertion failed: "unreachable" code reached with unknown type: ${typeof type === 'object' ? JSON.stringify(type) : String(type)}`;
13
- super(message);
14
- this.name = 'ExhaustiveTypeException';
15
- this.message = message;
16
- }
17
- }
18
- exports.ExhaustiveTypeException = ExhaustiveTypeException;
19
- const exhaustiveTypeException = (type) => new ExhaustiveTypeException(type);
9
+ const exhaustiveTypeException = (type) => new Error(`Assertion failed: "unreachable" code reached with unknown type: ${typeof type === 'object' ? JSON.stringify(type) : String(type)}`);
20
10
  exports.exhaustiveTypeException = exhaustiveTypeException;
21
- class AssertionError extends Error {
22
- constructor(message) {
23
- super(message);
24
- this.name = 'AssertionError';
25
- this.message = message;
26
- }
27
- }
28
- exports.AssertionError = AssertionError;
29
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
30
- function assert(value, message) {
31
- if (!value) {
32
- throw new AssertionError(message !== null && message !== void 0 ? message : `Assertion failed: value is ${JSON.stringify(value)}`);
33
- }
34
- }
35
11
  /**
36
12
  * Please use this instead of using the 'as' keyword directly, so it's easier
37
13
  * to screen for these ticking time bombs in the code from time to time. Or
@@ -1,4 +1,5 @@
1
- import { OwnedWorkout } from './workout';
1
+ import { OwnedWorkout, OwnedWorkoutExercise, OwnedWorkoutExerciseSet } from './workout';
2
+ import { UserWorkout, UserWorkoutExercise, UserWorkoutExerciseSet } from './userWorkout';
2
3
  export * from './workout';
3
4
  export * from './userWorkout';
4
5
  export * from './publicWorkout';
@@ -10,3 +11,7 @@ export interface WorkoutSync {
10
11
  isMore: boolean;
11
12
  updated_at?: string;
12
13
  }
14
+ export type Workout = OwnedWorkout & Partial<UserWorkout>;
15
+ export type WorkoutExercise = OwnedWorkoutExercise & Partial<UserWorkoutExercise>;
16
+ export type WorkoutExerciseSet = OwnedWorkoutExerciseSet & Partial<UserWorkoutExerciseSet>;
17
+ export declare function isOwnedWorkout(workout: OwnedWorkout | UserWorkout): workout is OwnedWorkout;
@@ -14,8 +14,14 @@ 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.isOwnedWorkout = isOwnedWorkout;
17
18
  __exportStar(require("./workout"), exports);
18
19
  __exportStar(require("./userWorkout"), exports);
19
20
  __exportStar(require("./publicWorkout"), exports);
20
21
  __exportStar(require("./normalizedWorkout"), exports);
21
22
  __exportStar(require("./postWorkoutRequest"), exports);
23
+ // Stub
24
+ function isOwnedWorkout(workout) {
25
+ void workout;
26
+ return true;
27
+ }
@@ -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,10 +39,15 @@ 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;
49
+ trainer_workout_template_id: string | undefined;
39
50
  gym: UserWorkoutGym | undefined;
40
- is_home_gym: boolean;
41
51
  }
42
52
  export interface UserWorkoutExercise {
43
53
  id: string;
@@ -57,10 +67,17 @@ export interface UserWorkoutExercise {
57
67
  superset_id: number | null;
58
68
  rest_seconds: number | null;
59
69
  notes: string;
70
+ priority: number;
60
71
  muscle_group: MuscleGroup;
61
72
  other_muscles: MuscleGroup[];
62
73
  exercise_type: ExerciseType;
74
+ equipment_category: Equipment;
75
+ url?: string;
76
+ media_type?: string;
77
+ custom_exercise_image_url?: string | null;
63
78
  thumbnail_url?: string | null;
79
+ manual_tag?: string;
80
+ aka?: string;
64
81
  /**
65
82
  * for exercises with two dumbbells
66
83
  *
@@ -86,6 +103,16 @@ export interface UserWorkoutExerciseSet {
86
103
  duration_seconds?: number | null;
87
104
  custom_metric?: number | null;
88
105
  rpe?: RPE | null;
106
+ /**
107
+ * @deprecated 1.29.17 -
108
+ * we can only set this to `best_weight`, `best_reps`, `best_duration` or
109
+ * `best_distance`. sending anything else would cause older clients to crash.
110
+ * newer clients will ignore this field and use the `prs` field instead.
111
+ */
112
+ personalRecords?: Array<{
113
+ type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
114
+ value: number;
115
+ }>;
89
116
  prs: {
90
117
  type: SetPersonalRecordType;
91
118
  value: number;
@@ -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,15 +28,30 @@ 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;
48
+ trainer_program_id: string | undefined;
30
49
  trainer_workout_template_id: string | undefined;
31
50
  gym_id: string | undefined;
32
51
  is_home_gym: boolean;
33
52
  }
34
53
  export interface TrainerWorkout extends OwnedWorkout {
35
- trainer_workout_template_id: string;
54
+ trainer_program_id: string;
36
55
  }
37
56
  export interface OwnedWorkoutExercise {
38
57
  id: string;
@@ -52,10 +71,17 @@ export interface OwnedWorkoutExercise {
52
71
  superset_id: number | null;
53
72
  rest_seconds: number | null;
54
73
  notes: string;
74
+ priority: number;
55
75
  muscle_group: MuscleGroup;
56
76
  other_muscles: MuscleGroup[];
57
77
  exercise_type: ExerciseType;
78
+ equipment_category: Equipment;
79
+ url?: string;
80
+ media_type?: string;
81
+ custom_exercise_image_url?: string | null;
58
82
  thumbnail_url?: string | null;
83
+ manual_tag?: string;
84
+ aka?: string;
59
85
  /**
60
86
  * for exercises with two dumbbells
61
87
  *
@@ -81,6 +107,16 @@ export interface OwnedWorkoutExerciseSet {
81
107
  duration_seconds?: number | null;
82
108
  custom_metric?: number | null;
83
109
  rpe?: RPE | null;
110
+ /**
111
+ * @deprecated 1.29.17 -
112
+ * we can only set this to `best_weight`, `best_reps`, `best_duration` or
113
+ * `best_distance`. sending anything else would cause older clients to crash.
114
+ * newer clients will ignore this field and use the `prs` field instead.
115
+ */
116
+ personalRecords?: Array<{
117
+ type: 'best_weight' | 'best_reps' | 'best_duration' | 'best_distance';
118
+ value: number;
119
+ }>;
84
120
  prs: {
85
121
  type: SetPersonalRecordType;
86
122
  value: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.1055",
3
+ "version": "1.0.1057",
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
- });