hevy-shared 1.0.655 → 1.0.657

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
@@ -444,6 +444,7 @@ export interface UserHevyProSubcription {
444
444
  managing_store: UserHevyProSubcriptionStore;
445
445
  type: 'monthly' | 'yearly' | 'lifetime' | 'custom';
446
446
  expires_date?: string;
447
+ grace_period_expires_date?: string | null;
447
448
  /**
448
449
  * Set if the user has paused/cancelled their subscription
449
450
  */
@@ -1,4 +1,4 @@
1
- import { MuscleGroup, SetType, SimplifiedMuscleGroup } from '.';
1
+ import { MuscleGroup, SetType } from '.';
2
2
  interface SetCountableSet {
3
3
  indicator: SetType;
4
4
  }
@@ -7,13 +7,18 @@ interface SetCountableExercise {
7
7
  other_muscles: MuscleGroup[];
8
8
  sets: SetCountableSet[];
9
9
  }
10
- export interface SetCountableWorkoutOrRoutine {
10
+ interface SetCountableWorkoutOrRoutine {
11
11
  exercises: SetCountableExercise[];
12
12
  }
13
- export declare const calculateSetContributionsForSimplifiedMuscleGroups: ({ muscle_group, other_muscles, }: {
14
- muscle_group: MuscleGroup;
15
- other_muscles: MuscleGroup[];
16
- }) => {
13
+ export declare const getSetContributionsForMuscleGroups: (muscle_group: MuscleGroup, other_muscles: MuscleGroup[]) => {
14
+ core: number;
15
+ shoulders: number;
16
+ arms: number;
17
+ legs: number;
18
+ back: number;
19
+ chest: number;
20
+ };
21
+ export declare const calculateSimplifiedMuscleSplit: (workoutsOrRoutines: SetCountableWorkoutOrRoutine[], shouldIncludeWarmupSets: boolean) => {
17
22
  core: number;
18
23
  shoulders: number;
19
24
  arms: number;
@@ -21,16 +26,5 @@ export declare const calculateSetContributionsForSimplifiedMuscleGroups: ({ musc
21
26
  back: number;
22
27
  chest: number;
23
28
  };
24
- export declare const calculateSimplifiedMuscleSplit: ({ workoutsOrRoutines, includeWarmupSets, }: {
25
- workoutsOrRoutines: SetCountableWorkoutOrRoutine[];
26
- includeWarmupSets: boolean;
27
- }) => Record<SimplifiedMuscleGroup, number>;
28
- export declare const calculateSetContributionsForMuscleGroups: ({ muscleGroup, otherMuscles, }: {
29
- muscleGroup: MuscleGroup;
30
- otherMuscles: MuscleGroup[];
31
- }) => Record<MuscleGroup, number>;
32
- export declare const calculateSetCountPerMuscleGroups: ({ workoutsOrRoutines, includeWarmupSets, }: {
33
- workoutsOrRoutines: SetCountableWorkoutOrRoutine[];
34
- includeWarmupSets: boolean;
35
- }) => Record<MuscleGroup, number>;
29
+ export declare const getSetCountPerMuscleGroups: (workout: SetCountableWorkoutOrRoutine, shouldIncludeWarmupSets: boolean) => Partial<{ [key in MuscleGroup]: number; }>;
36
30
  export {};
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateSetCountPerMuscleGroups = exports.calculateSetContributionsForMuscleGroups = exports.calculateSimplifiedMuscleSplit = exports.calculateSetContributionsForSimplifiedMuscleGroups = void 0;
6
+ exports.getSetCountPerMuscleGroups = exports.calculateSimplifiedMuscleSplit = exports.getSetContributionsForMuscleGroups = void 0;
7
7
  const intersection_1 = __importDefault(require("lodash/intersection"));
8
8
  const _1 = require(".");
9
- const calculateSetContributionsForSimplifiedMuscleGroups = ({ muscle_group, other_muscles, }) => {
9
+ const getSetContributionsForMuscleGroups = (muscle_group, other_muscles) => {
10
10
  const getContribution = (mg) => {
11
11
  if (mg.includes(muscle_group)) {
12
12
  return 1;
@@ -28,8 +28,8 @@ const calculateSetContributionsForSimplifiedMuscleGroups = ({ muscle_group, othe
28
28
  chest: getContribution(_1.chestMuscles),
29
29
  };
30
30
  };
31
- exports.calculateSetContributionsForSimplifiedMuscleGroups = calculateSetContributionsForSimplifiedMuscleGroups;
32
- const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets, }) => {
31
+ exports.getSetContributionsForMuscleGroups = getSetContributionsForMuscleGroups;
32
+ const calculateSimplifiedMuscleSplit = (workoutsOrRoutines, shouldIncludeWarmupSets) => {
33
33
  const totals = {
34
34
  core: 0,
35
35
  shoulders: 0,
@@ -40,14 +40,11 @@ const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets,
40
40
  };
41
41
  for (const workoutOrRoutine of workoutsOrRoutines) {
42
42
  for (const exercise of workoutOrRoutine.exercises) {
43
- const trimmedSets = includeWarmupSets
43
+ const trimmedSets = shouldIncludeWarmupSets
44
44
  ? exercise.sets
45
45
  : exercise.sets.filter((s) => s.indicator !== 'warmup');
46
46
  const setCount = trimmedSets.length;
47
- const contributions = (0, exports.calculateSetContributionsForSimplifiedMuscleGroups)({
48
- muscle_group: exercise.muscle_group,
49
- other_muscles: exercise.other_muscles,
50
- });
47
+ const contributions = (0, exports.getSetContributionsForMuscleGroups)(exercise.muscle_group, exercise.other_muscles);
51
48
  totals.core += contributions.core * setCount;
52
49
  totals.shoulders += contributions.shoulders * setCount;
53
50
  totals.arms += contributions.arms * setCount;
@@ -59,42 +56,16 @@ const calculateSimplifiedMuscleSplit = ({ workoutsOrRoutines, includeWarmupSets,
59
56
  return totals;
60
57
  };
61
58
  exports.calculateSimplifiedMuscleSplit = calculateSimplifiedMuscleSplit;
62
- const calculateSetContributionsForMuscleGroups = ({ muscleGroup, otherMuscles, }) => {
63
- const getContribution = (mg) => {
64
- if (mg === muscleGroup) {
65
- return 1;
66
- }
67
- else if (otherMuscles.includes(mg)) {
68
- return 0.5;
69
- }
70
- return 0;
71
- };
72
- return _1.muscleGroups.reduce((acc, mg) => {
73
- acc[mg] = getContribution(mg);
74
- return acc;
75
- }, {});
76
- };
77
- exports.calculateSetContributionsForMuscleGroups = calculateSetContributionsForMuscleGroups;
78
- const calculateSetCountPerMuscleGroups = ({ workoutsOrRoutines, includeWarmupSets, }) => {
79
- const totals = _1.muscleGroups.reduce((acc, muscleGroup) => {
80
- acc[muscleGroup] = 0;
59
+ const getSetCountPerMuscleGroups = (workout, shouldIncludeWarmupSets) => {
60
+ return workout.exercises.reduce((acc, e) => {
61
+ const trimmedSets = shouldIncludeWarmupSets
62
+ ? e.sets
63
+ : e.sets.filter((s) => s.indicator !== 'warmup');
64
+ acc[e.muscle_group] = (acc[e.muscle_group] || 0) + trimmedSets.length;
65
+ e.other_muscles.forEach((muscle) => {
66
+ acc[muscle] = (acc[muscle] || 0) + trimmedSets.length / 2;
67
+ });
81
68
  return acc;
82
69
  }, {});
83
- for (const workoutOrRoutine of workoutsOrRoutines) {
84
- for (const exercise of workoutOrRoutine.exercises) {
85
- const trimmedSets = includeWarmupSets
86
- ? exercise.sets
87
- : exercise.sets.filter((s) => s.indicator !== 'warmup');
88
- const setCount = trimmedSets.length;
89
- const contributions = (0, exports.calculateSetContributionsForMuscleGroups)({
90
- muscleGroup: exercise.muscle_group,
91
- otherMuscles: exercise.other_muscles,
92
- });
93
- for (const muscleGroup of _1.muscleGroups) {
94
- totals[muscleGroup] += contributions[muscleGroup] * setCount;
95
- }
96
- }
97
- }
98
- return totals;
99
70
  };
100
- exports.calculateSetCountPerMuscleGroups = calculateSetCountPerMuscleGroups;
71
+ exports.getSetCountPerMuscleGroups = getSetCountPerMuscleGroups;
@@ -134,7 +134,7 @@ export type MobilePushDataType = NotificationMobilePushDataType | DataOnlyMobile
134
134
  * These types will have an alert/title, and will only be delivered if the user has given the notification
135
135
  * permission to the App
136
136
  */
137
- export type NotificationMobilePushDataType = NotificationType | 'chat-update' | 'coach-program-finishes-next-week' | 'coach-program-starts-today' | 'coach-logged-your-workout' | 'coach-logged-your-measurements' | 'monthly-report';
137
+ export type NotificationMobilePushDataType = NotificationType | 'chat-update' | 'coach-program-finishes-next-week' | 'coach-program-starts-today' | 'coach-logged-your-workout' | 'coach-logged-your-measurements' | 'monthly-report' | 'grace-period-status';
138
138
  /**
139
139
  * These types CAN NOT have an alert/title, but may be delivered even if the user has not given the notification
140
140
  * permission and even if Hevy isn't running, although these should be treated as best effort
@@ -195,4 +195,8 @@ export interface MonthlyReportMobilePushData extends BaseMobilePushData {
195
195
  type: 'monthly-report';
196
196
  deeplink: string;
197
197
  }
198
- export type MobilePushData = ChatUpdateMobilePushData | SyncCustomExercisesAndCoachCustomizationsMobilePushData | SyncWorkoutsMobilePushData | SyncRoutineFoldersMobilePushData | SyncRoutinesMobilePushData | ProStatusChangedPushMobilePushData | HevyProSubscriptionRenewedMobilePushData | CoachProgramChangedMobilePushData | CoachDataChangedMobilePushData | ContactOnHevyMobilePushData | CoachClientInviteMobilePushData | AcceptFollowRequestMobilePushData | FollowRequestMobilePushData | FollowMobilePushData | WorkoutLikeMobilePushData | WorkoutCommentLikeMobilePushData | WorkoutCommentMentionMobilePushData | WorkoutCommentDiscussionMobilePushData | WorkoutCommentReplyMobilePushData | WorkoutCommentMobilePushData | WorkoutMentionMobilePushData | WorkoutCompleteMobilePushData | CoachProgramFinishesNextWeekMobilePushData | CoachProgramStartsTodayMobilePushData | CoachLoggedYourWorkoutMobilePushData | CoachLoggedYourMeasurementsMobilePushData | MonthlyReportMobilePushData;
198
+ export interface GracePeriodStatusMobilePushData extends BaseMobilePushData {
199
+ type: 'grace-period-status';
200
+ deeplink: string;
201
+ }
202
+ export type MobilePushData = ChatUpdateMobilePushData | SyncCustomExercisesAndCoachCustomizationsMobilePushData | SyncWorkoutsMobilePushData | SyncRoutineFoldersMobilePushData | SyncRoutinesMobilePushData | ProStatusChangedPushMobilePushData | HevyProSubscriptionRenewedMobilePushData | CoachProgramChangedMobilePushData | CoachDataChangedMobilePushData | ContactOnHevyMobilePushData | CoachClientInviteMobilePushData | AcceptFollowRequestMobilePushData | FollowRequestMobilePushData | FollowMobilePushData | WorkoutLikeMobilePushData | WorkoutCommentLikeMobilePushData | WorkoutCommentMentionMobilePushData | WorkoutCommentDiscussionMobilePushData | WorkoutCommentReplyMobilePushData | WorkoutCommentMobilePushData | WorkoutMentionMobilePushData | WorkoutCompleteMobilePushData | CoachProgramFinishesNextWeekMobilePushData | CoachProgramStartsTodayMobilePushData | CoachLoggedYourWorkoutMobilePushData | CoachLoggedYourMeasurementsMobilePushData | MonthlyReportMobilePushData | GracePeriodStatusMobilePushData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.655",
3
+ "version": "1.0.657",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,153 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const muscleSplits_1 = require("../muscleSplits");
4
- class SetCountableWorkoutOrRoutineBuilder {
5
- constructor() {
6
- this.exercises = [];
7
- }
8
- addExercise(muscle_group, other_muscles, sets) {
9
- this.exercises.push({
10
- muscle_group,
11
- other_muscles,
12
- sets: sets.map((indicator) => ({ indicator })),
13
- });
14
- return this;
15
- }
16
- build() {
17
- return {
18
- exercises: this.exercises,
19
- };
20
- }
21
- }
22
- describe('muscleSplits', () => {
23
- describe('calculateSetContributionsForSimplifiedMuscleGroups', () => {
24
- it('should return 1 for the main muscle group', () => {
25
- const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
26
- muscle_group: 'chest',
27
- other_muscles: [],
28
- });
29
- expect(contributions.chest).toBe(1);
30
- expect(contributions.back).toBe(0);
31
- expect(contributions.shoulders).toBe(0);
32
- expect(contributions.arms).toBe(0);
33
- expect(contributions.legs).toBe(0);
34
- expect(contributions.core).toBe(0);
35
- });
36
- it('should return 0.5 for other muscle groups', () => {
37
- const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
38
- muscle_group: 'shoulders',
39
- other_muscles: ['triceps'],
40
- });
41
- expect(contributions.shoulders).toBe(1);
42
- expect(contributions.arms).toBe(0.5);
43
- });
44
- it('should return 1/6 for full body exercises', () => {
45
- const contributions = (0, muscleSplits_1.calculateSetContributionsForSimplifiedMuscleGroups)({
46
- muscle_group: 'full_body',
47
- other_muscles: [],
48
- });
49
- const expected = 1 / 6;
50
- expect(contributions.chest).toBe(expected);
51
- expect(contributions.back).toBe(expected);
52
- expect(contributions.shoulders).toBe(expected);
53
- expect(contributions.arms).toBe(expected);
54
- expect(contributions.legs).toBe(expected);
55
- expect(contributions.core).toBe(expected);
56
- });
57
- });
58
- describe('calculateSimplifiedMuscleSplit', () => {
59
- it('should calculate the split correctly', () => {
60
- const workout = new SetCountableWorkoutOrRoutineBuilder()
61
- .addExercise('chest', ['triceps'], ['normal', 'normal', 'normal'])
62
- .addExercise('lats', ['biceps'], ['normal', 'normal'])
63
- .build();
64
- const split = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
65
- workoutsOrRoutines: [workout],
66
- includeWarmupSets: false,
67
- });
68
- expect(split.chest).toBe(3);
69
- expect(split.arms).toBe(3 * 0.5 + 2 * 0.5); // 1.5 from chest day, 1 from back day
70
- expect(split.back).toBe(2);
71
- });
72
- it('should handle warmup sets', () => {
73
- const workout = new SetCountableWorkoutOrRoutineBuilder()
74
- .addExercise('chest', ['triceps'], ['warmup', 'normal', 'normal', 'failure'])
75
- .build();
76
- const splitWithWarmup = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
77
- workoutsOrRoutines: [workout],
78
- includeWarmupSets: true,
79
- });
80
- expect(splitWithWarmup.chest).toBe(4);
81
- expect(splitWithWarmup.arms).toBe(4 * 0.5);
82
- const splitWithoutWarmup = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
83
- workoutsOrRoutines: [workout],
84
- includeWarmupSets: false,
85
- });
86
- expect(splitWithoutWarmup.chest).toBe(3);
87
- expect(splitWithoutWarmup.arms).toBe(3 * 0.5);
88
- });
89
- it('should count a set as 1 for a simplified group even if primary and other muscles are in the same group', () => {
90
- const workout = new SetCountableWorkoutOrRoutineBuilder()
91
- .addExercise('quadriceps', ['hamstrings', 'glutes'], // also in legs
92
- ['normal'])
93
- .build();
94
- const split = (0, muscleSplits_1.calculateSimplifiedMuscleSplit)({
95
- workoutsOrRoutines: [workout],
96
- includeWarmupSets: false,
97
- });
98
- expect(split.legs).toBe(1);
99
- expect(split.chest).toBe(0);
100
- expect(split.back).toBe(0);
101
- expect(split.shoulders).toBe(0);
102
- expect(split.arms).toBe(0);
103
- expect(split.core).toBe(0);
104
- });
105
- });
106
- describe('calculateSetContributionsForMuscleGroups', () => {
107
- it('should return 1 for the main muscle group and 0.5 for others', () => {
108
- const contributions = (0, muscleSplits_1.calculateSetContributionsForMuscleGroups)({
109
- muscleGroup: 'chest',
110
- otherMuscles: ['shoulders', 'triceps'],
111
- });
112
- expect(contributions.chest).toBe(1);
113
- expect(contributions.shoulders).toBe(0.5);
114
- expect(contributions.triceps).toBe(0.5);
115
- expect(contributions.lats).toBe(0);
116
- });
117
- });
118
- describe('calculateSetCountPerMuscleGroups', () => {
119
- it('should calculate the set count per muscle group', () => {
120
- const workout = new SetCountableWorkoutOrRoutineBuilder()
121
- .addExercise('chest', ['shoulders', 'triceps'], ['normal', 'normal', 'normal'])
122
- .addExercise('lats', ['biceps'], ['normal', 'normal'])
123
- .build();
124
- const counts = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
125
- workoutsOrRoutines: [workout],
126
- includeWarmupSets: false,
127
- });
128
- expect(counts.chest).toBe(3);
129
- expect(counts.shoulders).toBe(3 * 0.5);
130
- expect(counts.triceps).toBe(3 * 0.5);
131
- expect(counts.lats).toBe(2);
132
- expect(counts.biceps).toBe(2 * 0.5);
133
- expect(counts.abdominals).toBe(0);
134
- });
135
- it('should handle warmup sets correctly', () => {
136
- const workout = new SetCountableWorkoutOrRoutineBuilder()
137
- .addExercise('chest', ['shoulders', 'triceps'], ['warmup', 'normal', 'normal'])
138
- .build();
139
- const countsWithWarmup = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
140
- workoutsOrRoutines: [workout],
141
- includeWarmupSets: true,
142
- });
143
- expect(countsWithWarmup.chest).toBe(3);
144
- expect(countsWithWarmup.shoulders).toBe(3 * 0.5);
145
- const countsWithoutWarmup = (0, muscleSplits_1.calculateSetCountPerMuscleGroups)({
146
- workoutsOrRoutines: [workout],
147
- includeWarmupSets: false,
148
- });
149
- expect(countsWithoutWarmup.chest).toBe(2);
150
- expect(countsWithoutWarmup.shoulders).toBe(2 * 0.5);
151
- });
152
- });
153
- });