hevy-shared 1.0.1031 → 1.0.1033

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.
@@ -0,0 +1,108 @@
1
+ declare const VOLUME_COMPARISONS: readonly [{
2
+ readonly asset: "motorcycle";
3
+ readonly subtitleKey: "shareable.volumeCompare.motorcycle.subtitle";
4
+ readonly weightKg: 300;
5
+ }, {
6
+ readonly asset: "shark";
7
+ readonly subtitleKey: "shareable.volumeCompare.shark.subtitle";
8
+ readonly weightKg: 1000;
9
+ }, {
10
+ readonly asset: "car";
11
+ readonly subtitleKey: "shareable.volumeCompare.car.subtitle";
12
+ readonly weightKg: 1500;
13
+ }, {
14
+ readonly asset: "van";
15
+ readonly subtitleKey: "shareable.volumeCompare.van.subtitle";
16
+ readonly weightKg: 2000;
17
+ }, {
18
+ readonly asset: "pickupTruck";
19
+ readonly subtitleKey: "shareable.volumeCompare.pickupTruck.subtitle";
20
+ readonly weightKg: 3000;
21
+ }, {
22
+ readonly asset: "helicopter";
23
+ readonly subtitleKey: "shareable.volumeCompare.helicopter.subtitle";
24
+ readonly weightKg: 5000;
25
+ }, {
26
+ readonly asset: "elephant";
27
+ readonly subtitleKey: "shareable.volumeCompare.elephant.subtitle";
28
+ readonly weightKg: 6000;
29
+ }, {
30
+ readonly asset: "trex";
31
+ readonly subtitleKey: "shareable.volumeCompare.trex.subtitle";
32
+ readonly weightKg: 7000;
33
+ }, {
34
+ readonly asset: "yacht";
35
+ readonly subtitleKey: "shareable.volumeCompare.yacht.subtitle";
36
+ readonly weightKg: 8000;
37
+ }, {
38
+ readonly asset: "truck";
39
+ readonly subtitleKey: "shareable.volumeCompare.truck.subtitle";
40
+ readonly weightKg: 10000;
41
+ }, {
42
+ readonly asset: "bus";
43
+ readonly subtitleKey: "shareable.volumeCompare.bus.subtitle";
44
+ readonly weightKg: 15000;
45
+ }, {
46
+ readonly asset: "jet";
47
+ readonly subtitleKey: "shareable.volumeCompare.jet.subtitle";
48
+ readonly weightKg: 20000;
49
+ }, {
50
+ readonly asset: "airplane";
51
+ readonly subtitleKey: "shareable.volumeCompare.airplane.subtitle";
52
+ readonly weightKg: 40000;
53
+ }];
54
+ export type VolumeComparisonAssetName = typeof VOLUME_COMPARISONS[number]['asset'];
55
+ export declare const getVolumeComparison: (volumeKg: number) => {
56
+ readonly asset: "motorcycle";
57
+ readonly subtitleKey: "shareable.volumeCompare.motorcycle.subtitle";
58
+ readonly weightKg: 300;
59
+ } | {
60
+ readonly asset: "shark";
61
+ readonly subtitleKey: "shareable.volumeCompare.shark.subtitle";
62
+ readonly weightKg: 1000;
63
+ } | {
64
+ readonly asset: "car";
65
+ readonly subtitleKey: "shareable.volumeCompare.car.subtitle";
66
+ readonly weightKg: 1500;
67
+ } | {
68
+ readonly asset: "van";
69
+ readonly subtitleKey: "shareable.volumeCompare.van.subtitle";
70
+ readonly weightKg: 2000;
71
+ } | {
72
+ readonly asset: "pickupTruck";
73
+ readonly subtitleKey: "shareable.volumeCompare.pickupTruck.subtitle";
74
+ readonly weightKg: 3000;
75
+ } | {
76
+ readonly asset: "helicopter";
77
+ readonly subtitleKey: "shareable.volumeCompare.helicopter.subtitle";
78
+ readonly weightKg: 5000;
79
+ } | {
80
+ readonly asset: "elephant";
81
+ readonly subtitleKey: "shareable.volumeCompare.elephant.subtitle";
82
+ readonly weightKg: 6000;
83
+ } | {
84
+ readonly asset: "trex";
85
+ readonly subtitleKey: "shareable.volumeCompare.trex.subtitle";
86
+ readonly weightKg: 7000;
87
+ } | {
88
+ readonly asset: "yacht";
89
+ readonly subtitleKey: "shareable.volumeCompare.yacht.subtitle";
90
+ readonly weightKg: 8000;
91
+ } | {
92
+ readonly asset: "truck";
93
+ readonly subtitleKey: "shareable.volumeCompare.truck.subtitle";
94
+ readonly weightKg: 10000;
95
+ } | {
96
+ readonly asset: "bus";
97
+ readonly subtitleKey: "shareable.volumeCompare.bus.subtitle";
98
+ readonly weightKg: 15000;
99
+ } | {
100
+ readonly asset: "jet";
101
+ readonly subtitleKey: "shareable.volumeCompare.jet.subtitle";
102
+ readonly weightKg: 20000;
103
+ } | {
104
+ readonly asset: "airplane";
105
+ readonly subtitleKey: "shareable.volumeCompare.airplane.subtitle";
106
+ readonly weightKg: 40000;
107
+ } | undefined;
108
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVolumeComparison = void 0;
4
+ const VOLUME_COMPARISONS = [
5
+ {
6
+ asset: 'motorcycle',
7
+ subtitleKey: 'shareable.volumeCompare.motorcycle.subtitle',
8
+ weightKg: 300,
9
+ },
10
+ {
11
+ asset: 'shark',
12
+ subtitleKey: 'shareable.volumeCompare.shark.subtitle',
13
+ weightKg: 1000,
14
+ },
15
+ {
16
+ asset: 'car',
17
+ subtitleKey: 'shareable.volumeCompare.car.subtitle',
18
+ weightKg: 1500,
19
+ },
20
+ {
21
+ asset: 'van',
22
+ subtitleKey: 'shareable.volumeCompare.van.subtitle',
23
+ weightKg: 2000,
24
+ },
25
+ {
26
+ asset: 'pickupTruck',
27
+ subtitleKey: 'shareable.volumeCompare.pickupTruck.subtitle',
28
+ weightKg: 3000,
29
+ },
30
+ {
31
+ asset: 'helicopter',
32
+ subtitleKey: 'shareable.volumeCompare.helicopter.subtitle',
33
+ weightKg: 5000,
34
+ },
35
+ {
36
+ asset: 'elephant',
37
+ subtitleKey: 'shareable.volumeCompare.elephant.subtitle',
38
+ weightKg: 6000,
39
+ },
40
+ {
41
+ asset: 'trex',
42
+ subtitleKey: 'shareable.volumeCompare.trex.subtitle',
43
+ weightKg: 7000,
44
+ },
45
+ {
46
+ asset: 'yacht',
47
+ subtitleKey: 'shareable.volumeCompare.yacht.subtitle',
48
+ weightKg: 8000,
49
+ },
50
+ {
51
+ asset: 'truck',
52
+ subtitleKey: 'shareable.volumeCompare.truck.subtitle',
53
+ weightKg: 10000,
54
+ },
55
+ {
56
+ asset: 'bus',
57
+ subtitleKey: 'shareable.volumeCompare.bus.subtitle',
58
+ weightKg: 15000,
59
+ },
60
+ {
61
+ asset: 'jet',
62
+ subtitleKey: 'shareable.volumeCompare.jet.subtitle',
63
+ weightKg: 20000,
64
+ },
65
+ {
66
+ asset: 'airplane',
67
+ subtitleKey: 'shareable.volumeCompare.airplane.subtitle',
68
+ weightKg: 40000,
69
+ },
70
+ ];
71
+ const getVolumeComparison = (volumeKg) => {
72
+ if (volumeKg < VOLUME_COMPARISONS[0].weightKg)
73
+ return undefined;
74
+ for (let i = 1; i < VOLUME_COMPARISONS.length; i++) {
75
+ if (volumeKg < VOLUME_COMPARISONS[i].weightKg) {
76
+ return VOLUME_COMPARISONS[i - 1];
77
+ }
78
+ }
79
+ return VOLUME_COMPARISONS[VOLUME_COMPARISONS.length - 1];
80
+ };
81
+ exports.getVolumeComparison = getVolumeComparison;
package/built/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export * from './adjustEventTokens';
28
28
  export * from './hevyTrainer';
29
29
  export * from './translations';
30
30
  export * from './exerciseLocaleUtils';
31
+ export * from './getVolumeComparison';
31
32
  export type WeightUnit = 'kg' | 'lbs';
32
33
  export declare const isWeightUnit: (x: string) => x is WeightUnit;
33
34
  export type DistanceUnit = 'kilometers' | 'miles';
@@ -1407,7 +1408,10 @@ export type CommercialGym = {
1407
1408
  city: string;
1408
1409
  distanceM: number;
1409
1410
  };
1410
- export type Gym = CommercialGym;
1411
+ export type HomeGym = {
1412
+ type: 'home';
1413
+ };
1414
+ export type Gym = CommercialGym | HomeGym;
1411
1415
  export interface StripePrice {
1412
1416
  product_id: string;
1413
1417
  billing_period: 'month' | 'year' | 'pay-once';
package/built/index.js CHANGED
@@ -40,6 +40,7 @@ __exportStar(require("./adjustEventTokens"), exports);
40
40
  __exportStar(require("./hevyTrainer"), exports);
41
41
  __exportStar(require("./translations"), exports);
42
42
  __exportStar(require("./exerciseLocaleUtils"), exports);
43
+ __exportStar(require("./getVolumeComparison"), exports);
43
44
  const isWeightUnit = (x) => {
44
45
  return x === 'kg' || x === 'lbs';
45
46
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getVolumeComparison_1 = require("../getVolumeComparison");
4
+ describe('getVolumeComparison', () => {
5
+ it('returns undefined when volume is below the minimum threshold (300kg)', () => {
6
+ expect((0, getVolumeComparison_1.getVolumeComparison)(0)).toBeUndefined();
7
+ expect((0, getVolumeComparison_1.getVolumeComparison)(100)).toBeUndefined();
8
+ expect((0, getVolumeComparison_1.getVolumeComparison)(299)).toBeUndefined();
9
+ });
10
+ it('returns motorcycle at exactly 300kg', () => {
11
+ var _a;
12
+ expect((_a = (0, getVolumeComparison_1.getVolumeComparison)(300)) === null || _a === void 0 ? void 0 : _a.asset).toBe('motorcycle');
13
+ });
14
+ it('returns the correct asset at each exact threshold', () => {
15
+ var _a;
16
+ const cases = [
17
+ [310, 'motorcycle'],
18
+ [1010, 'shark'],
19
+ [1510, 'car'],
20
+ [2010, 'van'],
21
+ [3010, 'pickupTruck'],
22
+ [5010, 'helicopter'],
23
+ [6010, 'elephant'],
24
+ [7010, 'trex'],
25
+ [8010, 'yacht'],
26
+ [10010, 'truck'],
27
+ [15010, 'bus'],
28
+ [20010, 'jet'],
29
+ [40010, 'airplane'],
30
+ ];
31
+ for (const [kg, asset] of cases) {
32
+ expect((_a = (0, getVolumeComparison_1.getVolumeComparison)(kg)) === null || _a === void 0 ? void 0 : _a.asset).toBe(asset);
33
+ }
34
+ });
35
+ it('returns the last threshold reached when volume is between two thresholds', () => {
36
+ var _a, _b, _c, _d;
37
+ expect((_a = (0, getVolumeComparison_1.getVolumeComparison)(500)) === null || _a === void 0 ? void 0 : _a.asset).toBe('motorcycle');
38
+ expect((_b = (0, getVolumeComparison_1.getVolumeComparison)(1200)) === null || _b === void 0 ? void 0 : _b.asset).toBe('shark');
39
+ expect((_c = (0, getVolumeComparison_1.getVolumeComparison)(2500)) === null || _c === void 0 ? void 0 : _c.asset).toBe('van');
40
+ expect((_d = (0, getVolumeComparison_1.getVolumeComparison)(12000)) === null || _d === void 0 ? void 0 : _d.asset).toBe('truck');
41
+ });
42
+ it('returns airplane for volume above the maximum threshold', () => {
43
+ var _a, _b;
44
+ expect((_a = (0, getVolumeComparison_1.getVolumeComparison)(40001)) === null || _a === void 0 ? void 0 : _a.asset).toBe('airplane');
45
+ expect((_b = (0, getVolumeComparison_1.getVolumeComparison)(1000000)) === null || _b === void 0 ? void 0 : _b.asset).toBe('airplane');
46
+ });
47
+ it('returns the correct subtitleKey and weightKg for each result', () => {
48
+ const motorcycle = (0, getVolumeComparison_1.getVolumeComparison)(300);
49
+ expect(motorcycle === null || motorcycle === void 0 ? void 0 : motorcycle.subtitleKey).toBe('shareable.volumeCompare.motorcycle.subtitle');
50
+ expect(motorcycle === null || motorcycle === void 0 ? void 0 : motorcycle.weightKg).toBe(300);
51
+ const airplane = (0, getVolumeComparison_1.getVolumeComparison)(40000);
52
+ expect(airplane === null || airplane === void 0 ? void 0 : airplane.subtitleKey).toBe('shareable.volumeCompare.airplane.subtitle');
53
+ expect(airplane === null || airplane === void 0 ? void 0 : airplane.weightKg).toBe(40000);
54
+ });
55
+ });
@@ -40,7 +40,6 @@ 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_workout: boolean;
44
43
  }
45
44
  export interface PostWorkoutRequestExercise {
46
45
  title: string;
@@ -47,7 +47,6 @@ export interface OwnedWorkout {
47
47
  is_biometrics_public: boolean;
48
48
  trainer_program_id: string | undefined;
49
49
  gym_id: string | undefined;
50
- is_home_workout: boolean;
51
50
  }
52
51
  export interface TrainerWorkout extends OwnedWorkout {
53
52
  trainer_program_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.1031",
3
+ "version": "1.0.1033",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",