hevy-shared 1.0.909 → 1.0.911

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.
@@ -1,4 +1,4 @@
1
- import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment } from '.';
1
+ import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment } from '.';
2
2
  export type HevyTrainerExerciseCategory = typeof hevyTrainerExerciseCategories[number];
3
3
  export type HevyTrainerRoutineName = typeof routineNames[number];
4
4
  export declare const workoutDurationOptions: readonly [40, 60, 80];
@@ -8,6 +8,7 @@ export type TrainerGymType = typeof trainerGymTypes[number];
8
8
  export declare const granularEquipmentDefaults: {
9
9
  [key in TrainerGymType]: GranularEquipment[];
10
10
  };
11
+ export declare const trainerEquipmentToGranularEquipments: (equipments: HevyTrainerProgramEquipment[]) => GranularEquipment[];
11
12
  export declare const hevyTrainerExerciseCategories: readonly ["compound", "isolation"];
12
13
  export declare const defaultDurationPerFrequency: Record<WeeklyTrainingFrequency, WorkoutDurationMinutes>;
13
14
  export declare const routineNames: readonly ["full_body_1", "full_body_2_a", "full_body_2_b", "full_body_3_a", "full_body_3_b", "full_body_3_c", "upper_1_a", "lower_1_a", "upper_1_b", "lower_1_b", "push_1", "pull_1", "legs_1", "upper_2", "lower_2", "push_2_a", "pull_2_a", "legs_2_a", "push_2_b", "pull_2_b", "legs_2_b"];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateProgram = exports.pickExerciseForPrescription = exports.getPrioritySortedExercises = exports.normalizeExerciseCategory = exports.getTrainerRestTimerSeconds = exports.getTrainerRepRange = exports.getTrainerSetCount = exports.programSplits = exports.frequencyMap = exports.routineNames = exports.defaultDurationPerFrequency = exports.hevyTrainerExerciseCategories = exports.granularEquipmentDefaults = exports.trainerGymTypes = exports.workoutDurationOptions = void 0;
3
+ exports.generateProgram = exports.pickExerciseForPrescription = exports.getPrioritySortedExercises = exports.normalizeExerciseCategory = exports.getTrainerRestTimerSeconds = exports.getTrainerRepRange = exports.getTrainerSetCount = exports.programSplits = exports.frequencyMap = exports.routineNames = exports.defaultDurationPerFrequency = exports.hevyTrainerExerciseCategories = exports.trainerEquipmentToGranularEquipments = exports.granularEquipmentDefaults = exports.trainerGymTypes = exports.workoutDurationOptions = void 0;
4
4
  const _1 = require(".");
5
5
  const MAX_BARBELL_EXERCISES_PER_ROUTINE = 2;
6
6
  exports.workoutDurationOptions = [40, 60, 80];
@@ -76,6 +76,67 @@ exports.granularEquipmentDefaults = {
76
76
  'rope',
77
77
  ],
78
78
  };
79
+ const trainerEquipmentToGranularEquipmentsMap = {
80
+ barbell: [
81
+ 'adjustable_bench',
82
+ 'barbell',
83
+ 'dip_bar',
84
+ 'ez_bar',
85
+ 'flat_bench',
86
+ 'landmine',
87
+ 'medicine_ball',
88
+ 'plate',
89
+ 'pullup_bar',
90
+ 'rings',
91
+ 'rope',
92
+ 'squat_rack',
93
+ 't_bar',
94
+ 'trap_bar',
95
+ ],
96
+ dumbbell: [
97
+ 'adjustable_bench',
98
+ 'dip_bar',
99
+ 'dumbbell',
100
+ 'flat_bench',
101
+ 'medicine_ball',
102
+ 'pullup_bar',
103
+ 'rings',
104
+ 'rope',
105
+ ],
106
+ machine: [
107
+ 'adjustable_bench',
108
+ 'air_bike',
109
+ 'battle_rope',
110
+ 'dip_bar',
111
+ 'dual_cable_machine',
112
+ 'elliptical_trainer',
113
+ 'flat_bench',
114
+ 'lat_pulldown_cable',
115
+ 'leg_press_machine',
116
+ 'medicine_ball',
117
+ 'plate',
118
+ 'plate_machines',
119
+ 'pullup_bar',
120
+ 'resistance_band',
121
+ 'rings',
122
+ 'rope',
123
+ 'rowing_machine',
124
+ 'single_cable_machine',
125
+ 'smith_machine',
126
+ 'spinning',
127
+ 'stack_machines',
128
+ 'stair_machine',
129
+ 'treadmill',
130
+ ],
131
+ };
132
+ const trainerEquipmentToGranularEquipments = (equipments) => {
133
+ const granularEquipments = [];
134
+ equipments.forEach((equipment) => {
135
+ granularEquipments.push(...trainerEquipmentToGranularEquipmentsMap[equipment]);
136
+ });
137
+ return Array.from(new Set(granularEquipments));
138
+ };
139
+ exports.trainerEquipmentToGranularEquipments = trainerEquipmentToGranularEquipments;
79
140
  exports.hevyTrainerExerciseCategories = ['compound', 'isolation'];
80
141
  // These are the values that Philip decided for the default duration per frequency
81
142
  exports.defaultDurationPerFrequency = {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hevyTrainer_1 = require("../hevyTrainer");
4
+ const sortGranular = (arr) => [...arr].sort();
5
+ describe('trainerEquipmentToGranularEquipments', () => {
6
+ it('returns empty array when no equipments are provided', () => {
7
+ expect((0, hevyTrainer_1.trainerEquipmentToGranularEquipments)([])).toEqual([]);
8
+ });
9
+ it('returns expected granular equipments for barbell only', () => {
10
+ const result = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(['barbell']);
11
+ expect(sortGranular(result)).toEqual(sortGranular([
12
+ 'adjustable_bench',
13
+ 'barbell',
14
+ 'dip_bar',
15
+ 'ez_bar',
16
+ 'flat_bench',
17
+ 'landmine',
18
+ 'medicine_ball',
19
+ 'plate',
20
+ 'pullup_bar',
21
+ 'rings',
22
+ 'rope',
23
+ 'squat_rack',
24
+ 't_bar',
25
+ 'trap_bar',
26
+ ]));
27
+ });
28
+ it('returns expected granular equipments for dumbbell only', () => {
29
+ const result = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(['dumbbell']);
30
+ expect(sortGranular(result)).toEqual(sortGranular([
31
+ 'adjustable_bench',
32
+ 'dip_bar',
33
+ 'dumbbell',
34
+ 'flat_bench',
35
+ 'medicine_ball',
36
+ 'pullup_bar',
37
+ 'rings',
38
+ 'rope',
39
+ ]));
40
+ });
41
+ it('returns expected granular equipments for machine only', () => {
42
+ const result = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(['machine']);
43
+ expect(sortGranular(result)).toEqual(sortGranular([
44
+ 'adjustable_bench',
45
+ 'air_bike',
46
+ 'battle_rope',
47
+ 'dip_bar',
48
+ 'dual_cable_machine',
49
+ 'elliptical_trainer',
50
+ 'flat_bench',
51
+ 'lat_pulldown_cable',
52
+ 'leg_press_machine',
53
+ 'medicine_ball',
54
+ 'plate',
55
+ 'plate_machines',
56
+ 'pullup_bar',
57
+ 'resistance_band',
58
+ 'rings',
59
+ 'rope',
60
+ 'rowing_machine',
61
+ 'single_cable_machine',
62
+ 'smith_machine',
63
+ 'spinning',
64
+ 'stack_machines',
65
+ 'stair_machine',
66
+ 'treadmill',
67
+ ]));
68
+ });
69
+ it('returns deduped union for multiple equipments', () => {
70
+ const equipments = ['barbell', 'dumbbell'];
71
+ const result = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(equipments);
72
+ const barbellOnly = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(['barbell']);
73
+ const dumbbellOnly = (0, hevyTrainer_1.trainerEquipmentToGranularEquipments)(['dumbbell']);
74
+ const combined = sortGranular(Array.from(new Set([...barbellOnly, ...dumbbellOnly])));
75
+ expect(sortGranular(result)).toEqual(combined);
76
+ });
77
+ });
78
+ const __1 = require("..");
79
+ describe('hevyTrainer gym types and defaults', () => {
80
+ it('defines granular equipment defaults for every trainer gym type', () => {
81
+ __1.trainerGymTypes.forEach((gymType) => {
82
+ const defaults = __1.granularEquipmentDefaults[gymType];
83
+ expect(Array.isArray(defaults)).toBe(true);
84
+ expect(defaults.length).toBeGreaterThan(0);
85
+ });
86
+ });
87
+ it('granular equipment defaults only contain granular equipment values', () => {
88
+ Object.keys(__1.granularEquipmentDefaults).forEach((gymType) => {
89
+ const defaults = __1.granularEquipmentDefaults[gymType];
90
+ defaults.forEach((equipment) => {
91
+ // Type assertion ensures the mapping stays within the GranularEquipment union.
92
+ const typed = equipment;
93
+ expect(typeof typed).toBe('string');
94
+ });
95
+ });
96
+ });
97
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.909",
3
+ "version": "1.0.911",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",