hevy-shared 1.0.1051 → 1.0.1053
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/geography.d.ts +1 -0
- package/built/geography.js +15 -0
- package/built/index.d.ts +4 -15
- package/built/index.js +1 -0
- package/built/tests/geography.test.d.ts +1 -0
- package/built/tests/geography.test.js +25 -0
- package/built/typeUtils.d.ts +8 -1
- package/built/typeUtils.js +26 -2
- package/built/workout/index.d.ts +1 -6
- package/built/workout/index.js +0 -6
- package/built/workout/publicWorkout.d.ts +1 -3
- package/built/workout/userWorkout.d.ts +1 -29
- package/built/workout/workout.d.ts +1 -36
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const distanceMBetween: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
package/built/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export * from './hevyTrainer';
|
|
|
29
29
|
export * from './translations';
|
|
30
30
|
export * from './exerciseLocaleUtils';
|
|
31
31
|
export * from './getVolumeComparison';
|
|
32
|
+
export * from './geography';
|
|
32
33
|
export type WeightUnit = 'kg' | 'lbs';
|
|
33
34
|
export declare const isWeightUnit: (x: string) => x is WeightUnit;
|
|
34
35
|
export type DistanceUnit = 'kilometers' | 'miles';
|
|
@@ -302,21 +303,8 @@ export interface BackofficeExistingUserResponse {
|
|
|
302
303
|
public_api_key: string | null;
|
|
303
304
|
limited_discovery: boolean;
|
|
304
305
|
coach_trial_expire_date?: string;
|
|
305
|
-
hevy_trainer_program:
|
|
306
|
+
hevy_trainer_program: TrainerProgramV3 | null;
|
|
306
307
|
}
|
|
307
|
-
/**
|
|
308
|
-
* A user has at most one active Hevy Trainer program, on either the v2 schema
|
|
309
|
-
* (program → routines) or the v3 schema (program → templates). The backoffice
|
|
310
|
-
* receives whichever exists as a discriminated union keyed by `schema_version`
|
|
311
|
-
* so the front-end can render each shape.
|
|
312
|
-
*/
|
|
313
|
-
export type BackofficeTrainerProgram = {
|
|
314
|
-
schema_version: 'v2';
|
|
315
|
-
program: HevyTrainerProgram;
|
|
316
|
-
} | {
|
|
317
|
-
schema_version: 'v3';
|
|
318
|
-
program: TrainerProgramV3;
|
|
319
|
-
};
|
|
320
308
|
export interface BackofficeDeletedUserResponse {
|
|
321
309
|
state: 'deleted-account';
|
|
322
310
|
id: string;
|
|
@@ -1526,7 +1514,8 @@ type CommercialGym = {
|
|
|
1526
1514
|
name: string;
|
|
1527
1515
|
fullAddress: string;
|
|
1528
1516
|
city: string;
|
|
1529
|
-
|
|
1517
|
+
latitude: number;
|
|
1518
|
+
longitude: number;
|
|
1530
1519
|
};
|
|
1531
1520
|
export type Gym = CommercialGym;
|
|
1532
1521
|
export interface StripePrice {
|
package/built/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __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);
|
|
44
45
|
const isWeightUnit = (x) => {
|
|
45
46
|
return x === 'kg' || x === 'lbs';
|
|
46
47
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
});
|
package/built/typeUtils.d.ts
CHANGED
|
@@ -4,7 +4,14 @@ 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
|
|
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;
|
|
8
15
|
export type Some<T> = {
|
|
9
16
|
hasValue: true;
|
|
10
17
|
value: T;
|
package/built/typeUtils.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TODO = exports.typeSafeIndex = exports.parseJSON = exports.assertNonNullish = exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
|
|
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;
|
|
4
5
|
exports.isNonNullish = isNonNullish;
|
|
5
6
|
const isInArray = (value, array) => array.includes(value);
|
|
6
7
|
exports.isInArray = isInArray;
|
|
7
8
|
const exhaustiveTypeCheck = (_) => void _;
|
|
8
9
|
exports.exhaustiveTypeCheck = exhaustiveTypeCheck;
|
|
9
|
-
|
|
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);
|
|
10
20
|
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
|
+
}
|
|
11
35
|
/**
|
|
12
36
|
* Please use this instead of using the 'as' keyword directly, so it's easier
|
|
13
37
|
* to screen for these ticking time bombs in the code from time to time. Or
|
package/built/workout/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OwnedWorkout
|
|
2
|
-
import { UserWorkout, UserWorkoutExercise, UserWorkoutExerciseSet } from './userWorkout';
|
|
1
|
+
import { OwnedWorkout } from './workout';
|
|
3
2
|
export * from './workout';
|
|
4
3
|
export * from './userWorkout';
|
|
5
4
|
export * from './publicWorkout';
|
|
@@ -11,7 +10,3 @@ export interface WorkoutSync {
|
|
|
11
10
|
isMore: boolean;
|
|
12
11
|
updated_at?: string;
|
|
13
12
|
}
|
|
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;
|
package/built/workout/index.js
CHANGED
|
@@ -14,14 +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.isOwnedWorkout = isOwnedWorkout;
|
|
18
17
|
__exportStar(require("./workout"), exports);
|
|
19
18
|
__exportStar(require("./userWorkout"), exports);
|
|
20
19
|
__exportStar(require("./publicWorkout"), exports);
|
|
21
20
|
__exportStar(require("./normalizedWorkout"), exports);
|
|
22
21
|
__exportStar(require("./postWorkoutRequest"), exports);
|
|
23
|
-
// Stub
|
|
24
|
-
function isOwnedWorkout(workout) {
|
|
25
|
-
void workout;
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DistanceUnit,
|
|
1
|
+
import { DistanceUnit, 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,11 +39,9 @@ export interface PublicWorkoutExercise {
|
|
|
39
39
|
superset_id: number | null;
|
|
40
40
|
rest_seconds: number | null;
|
|
41
41
|
notes: string;
|
|
42
|
-
priority: number;
|
|
43
42
|
muscle_group: MuscleGroup;
|
|
44
43
|
other_muscles: MuscleGroup[];
|
|
45
44
|
exercise_type: ExerciseType;
|
|
46
|
-
equipment_category: Equipment;
|
|
47
45
|
url?: string;
|
|
48
46
|
media_type?: string;
|
|
49
47
|
custom_exercise_image_url?: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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,13 +6,9 @@ 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[];
|
|
11
9
|
preview_workout_likes: PreviewWorkoutLike[];
|
|
12
10
|
comment_count: number;
|
|
13
11
|
comments: WorkoutComment[];
|
|
14
|
-
/** @deprecated 1.28.13 */
|
|
15
|
-
image_urls?: string[];
|
|
16
12
|
media: WorkoutMedia[];
|
|
17
13
|
is_liked_by_user: boolean;
|
|
18
14
|
start_time: number;
|
|
@@ -25,7 +21,6 @@ export interface UserWorkout {
|
|
|
25
21
|
apple_watch: boolean;
|
|
26
22
|
wearos_watch: boolean;
|
|
27
23
|
verified: boolean;
|
|
28
|
-
created_at: string;
|
|
29
24
|
updated_at: string;
|
|
30
25
|
nth_workout: number;
|
|
31
26
|
/**
|
|
@@ -39,14 +34,8 @@ export interface UserWorkout {
|
|
|
39
34
|
*/
|
|
40
35
|
include_warmup_sets: boolean;
|
|
41
36
|
is_private: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* If applicable, the user ID of the coach who logged this workout
|
|
44
|
-
*/
|
|
45
|
-
logged_by_coach_id?: string;
|
|
46
37
|
biometrics?: WorkoutBiometrics;
|
|
47
38
|
is_biometrics_public: boolean;
|
|
48
|
-
trainer_program_id: string | undefined;
|
|
49
|
-
trainer_workout_template_id: string | undefined;
|
|
50
39
|
gym: UserWorkoutGym | undefined;
|
|
51
40
|
}
|
|
52
41
|
export interface UserWorkoutExercise {
|
|
@@ -67,17 +56,10 @@ export interface UserWorkoutExercise {
|
|
|
67
56
|
superset_id: number | null;
|
|
68
57
|
rest_seconds: number | null;
|
|
69
58
|
notes: string;
|
|
70
|
-
priority: number;
|
|
71
59
|
muscle_group: MuscleGroup;
|
|
72
60
|
other_muscles: MuscleGroup[];
|
|
73
61
|
exercise_type: ExerciseType;
|
|
74
|
-
equipment_category: Equipment;
|
|
75
|
-
url?: string;
|
|
76
|
-
media_type?: string;
|
|
77
|
-
custom_exercise_image_url?: string | null;
|
|
78
62
|
thumbnail_url?: string | null;
|
|
79
|
-
manual_tag?: string;
|
|
80
|
-
aka?: string;
|
|
81
63
|
/**
|
|
82
64
|
* for exercises with two dumbbells
|
|
83
65
|
*
|
|
@@ -103,16 +85,6 @@ export interface UserWorkoutExerciseSet {
|
|
|
103
85
|
duration_seconds?: number | null;
|
|
104
86
|
custom_metric?: number | null;
|
|
105
87
|
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
|
-
}>;
|
|
116
88
|
prs: {
|
|
117
89
|
type: SetPersonalRecordType;
|
|
118
90
|
value: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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,13 +6,9 @@ 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[];
|
|
11
9
|
preview_workout_likes: PreviewWorkoutLike[];
|
|
12
10
|
comment_count: number;
|
|
13
11
|
comments: WorkoutComment[];
|
|
14
|
-
/** @deprecated 1.28.13 */
|
|
15
|
-
image_urls?: string[];
|
|
16
12
|
media: WorkoutMedia[];
|
|
17
13
|
is_liked_by_user: boolean;
|
|
18
14
|
start_time: number;
|
|
@@ -28,21 +24,7 @@ export interface OwnedWorkout {
|
|
|
28
24
|
created_at: string;
|
|
29
25
|
updated_at: string;
|
|
30
26
|
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;
|
|
41
27
|
is_private: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* If applicable, the user ID of the coach who logged this workout
|
|
44
|
-
*/
|
|
45
|
-
logged_by_coach_id?: string;
|
|
46
28
|
biometrics?: WorkoutBiometrics;
|
|
47
29
|
is_biometrics_public: boolean;
|
|
48
30
|
trainer_program_id: string | undefined;
|
|
@@ -71,17 +53,10 @@ export interface OwnedWorkoutExercise {
|
|
|
71
53
|
superset_id: number | null;
|
|
72
54
|
rest_seconds: number | null;
|
|
73
55
|
notes: string;
|
|
74
|
-
priority: number;
|
|
75
56
|
muscle_group: MuscleGroup;
|
|
76
57
|
other_muscles: MuscleGroup[];
|
|
77
58
|
exercise_type: ExerciseType;
|
|
78
|
-
equipment_category: Equipment;
|
|
79
|
-
url?: string;
|
|
80
|
-
media_type?: string;
|
|
81
|
-
custom_exercise_image_url?: string | null;
|
|
82
59
|
thumbnail_url?: string | null;
|
|
83
|
-
manual_tag?: string;
|
|
84
|
-
aka?: string;
|
|
85
60
|
/**
|
|
86
61
|
* for exercises with two dumbbells
|
|
87
62
|
*
|
|
@@ -107,16 +82,6 @@ export interface OwnedWorkoutExerciseSet {
|
|
|
107
82
|
duration_seconds?: number | null;
|
|
108
83
|
custom_metric?: number | null;
|
|
109
84
|
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
|
-
}>;
|
|
120
85
|
prs: {
|
|
121
86
|
type: SetPersonalRecordType;
|
|
122
87
|
value: number;
|