hevy-shared 1.0.979 → 1.0.981
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/hevyTrainer.js +3 -3
- package/built/index.d.ts +1 -1
- package/built/tests/hevyTrainer.test.js +19 -19
- package/package.json +1 -1
package/built/hevyTrainer.js
CHANGED
|
@@ -565,7 +565,7 @@ const appendCardioExerciseSelectionTrace = (traces, params) => {
|
|
|
565
565
|
};
|
|
566
566
|
/** Inserts optional cardio before or after template exercises for one routine. */
|
|
567
567
|
const attachOptionalCardioToRoutine = ({ cardioPreference, cardioExercises, criteria, debugExerciseSelectionTrace, exerciseSelectionTraces, routine, templatePrescriptionCount, routineExercises, }) => {
|
|
568
|
-
if (
|
|
568
|
+
if (cardioPreference === 'no-cardio')
|
|
569
569
|
return;
|
|
570
570
|
const cardioExercise = cardioExercises.find((ex) => {
|
|
571
571
|
var _a, _b, _c;
|
|
@@ -581,14 +581,14 @@ const attachOptionalCardioToRoutine = ({ cardioPreference, cardioExercises, crit
|
|
|
581
581
|
exerciseTemplate: cardioExercise,
|
|
582
582
|
durationSeconds: exports.DEFAULT_TRAINER_CARDIO_ATTACHMENT_DURATION_SECONDS,
|
|
583
583
|
};
|
|
584
|
-
if (cardioPreference === '
|
|
584
|
+
if (cardioPreference === 'workout-start')
|
|
585
585
|
routineExercises.unshift(slot);
|
|
586
586
|
else
|
|
587
587
|
routineExercises.push(slot);
|
|
588
588
|
if (debugExerciseSelectionTrace) {
|
|
589
589
|
appendCardioExerciseSelectionTrace(exerciseSelectionTraces, {
|
|
590
590
|
routine,
|
|
591
|
-
prescriptionIndex: cardioPreference === '
|
|
591
|
+
prescriptionIndex: cardioPreference === 'workout-start'
|
|
592
592
|
? CARDIO_TRACE_INDEX_BEFORE_TEMPLATE
|
|
593
593
|
: templatePrescriptionCount,
|
|
594
594
|
selectedExerciseId: cardioExercise.id,
|
package/built/index.d.ts
CHANGED
|
@@ -650,7 +650,7 @@ export type TrainingGoal = Lookup<typeof trainingGoals>;
|
|
|
650
650
|
export type TrainingLevel = Lookup<typeof trainingLevels>;
|
|
651
651
|
export type ExerciseCategory = Lookup<typeof exerciseCategories>;
|
|
652
652
|
export type RestTimerLength = typeof restTimerLengths[number];
|
|
653
|
-
export type CardioPreference =
|
|
653
|
+
export type CardioPreference = 'no-cardio' | 'workout-start' | 'workout-end';
|
|
654
654
|
export type HevyTrainerProgramEquipment = Extract<Equipment, 'barbell' | 'dumbbell' | 'machine'>;
|
|
655
655
|
export declare const hevyTrainerProgramEquipments: readonly ["barbell", "dumbbell", "machine"];
|
|
656
656
|
export declare const granularEquipments: readonly ["barbell", "dumbbell", "kettlebell", "plate", "medicine_ball", "ez_bar", "landmine", "trap_bar", "pullup_bar", "dip_bar", "squat_rack", "flat_bench", "adjustable_bench", "dual_cable_machine", "single_cable_machine", "lat_pulldown_cable", "leg_press_machine", "smith_machine", "t_bar", "plate_machines", "stack_machines", "treadmill", "elliptical_trainer", "rowing_machine", "spinning", "stair_machine", "air_bike", "suspension_band", "resistance_band", "battle_rope", "rings", "jump_rope"];
|
|
@@ -608,7 +608,7 @@ describe('generateProgram', () => {
|
|
|
608
608
|
workoutDurationMinutes: 60,
|
|
609
609
|
restTimerLength: 'medium',
|
|
610
610
|
exerciseStore: [chestExercise],
|
|
611
|
-
cardioPreference:
|
|
611
|
+
cardioPreference: 'no-cardio',
|
|
612
612
|
});
|
|
613
613
|
expect(result.success).toBe(true);
|
|
614
614
|
if (!result.success)
|
|
@@ -646,7 +646,7 @@ describe('generateProgram', () => {
|
|
|
646
646
|
workoutDurationMinutes: 60,
|
|
647
647
|
restTimerLength: 'medium',
|
|
648
648
|
exerciseStore: [],
|
|
649
|
-
cardioPreference:
|
|
649
|
+
cardioPreference: 'no-cardio',
|
|
650
650
|
});
|
|
651
651
|
expect(result.success).toBe(false);
|
|
652
652
|
if (result.success)
|
|
@@ -688,7 +688,7 @@ describe('generateProgram', () => {
|
|
|
688
688
|
workoutDurationMinutes,
|
|
689
689
|
restTimerLength: 'medium',
|
|
690
690
|
exerciseStore: [makeExercise({ id: 'bench' })],
|
|
691
|
-
cardioPreference:
|
|
691
|
+
cardioPreference: 'no-cardio',
|
|
692
692
|
});
|
|
693
693
|
const routine = (result.success ? result.program : result.partialProgram)
|
|
694
694
|
.routines[0];
|
|
@@ -757,7 +757,7 @@ describe('generateProgram', () => {
|
|
|
757
757
|
makeExercise({ id: 'bench-2', priority: 2 }),
|
|
758
758
|
makeExercise({ id: 'bench-3', priority: 1 }),
|
|
759
759
|
],
|
|
760
|
-
cardioPreference:
|
|
760
|
+
cardioPreference: 'no-cardio',
|
|
761
761
|
});
|
|
762
762
|
expect(result.success).toBe(true);
|
|
763
763
|
if (!result.success)
|
|
@@ -787,7 +787,7 @@ describe('generateProgram', () => {
|
|
|
787
787
|
exerciseStore: [
|
|
788
788
|
makeExercise({ id: 'biceps-curl', muscle_group: 'biceps' }),
|
|
789
789
|
],
|
|
790
|
-
cardioPreference:
|
|
790
|
+
cardioPreference: 'no-cardio',
|
|
791
791
|
});
|
|
792
792
|
expect(result.success).toBe(true);
|
|
793
793
|
if (!result.success)
|
|
@@ -814,7 +814,7 @@ describe('generateProgram', () => {
|
|
|
814
814
|
restTimerLength: 'medium',
|
|
815
815
|
exerciseStore: [bicepsCurl],
|
|
816
816
|
focusMuscle: 'arms',
|
|
817
|
-
cardioPreference:
|
|
817
|
+
cardioPreference: 'no-cardio',
|
|
818
818
|
});
|
|
819
819
|
expect(result.success).toBe(true);
|
|
820
820
|
if (!result.success)
|
|
@@ -840,7 +840,7 @@ describe('generateProgram', () => {
|
|
|
840
840
|
restTimerLength: 'medium',
|
|
841
841
|
exerciseStore: [excluded, alt],
|
|
842
842
|
excludedExerciseIds: new Set(['excluded']),
|
|
843
|
-
cardioPreference:
|
|
843
|
+
cardioPreference: 'no-cardio',
|
|
844
844
|
});
|
|
845
845
|
expect(result.success).toBe(true);
|
|
846
846
|
if (!result.success)
|
|
@@ -860,7 +860,7 @@ describe('generateProgram', () => {
|
|
|
860
860
|
restTimerLength: 'medium',
|
|
861
861
|
exerciseStore: [chest],
|
|
862
862
|
debugExerciseSelectionTrace: true,
|
|
863
|
-
cardioPreference:
|
|
863
|
+
cardioPreference: 'no-cardio',
|
|
864
864
|
});
|
|
865
865
|
expect(result.success).toBe(true);
|
|
866
866
|
expect(result.exerciseSelectionTraces).toHaveLength(1);
|
|
@@ -894,7 +894,7 @@ describe('generateProgram', () => {
|
|
|
894
894
|
makeExercise({ id: 'bench-2' }),
|
|
895
895
|
],
|
|
896
896
|
debugExerciseSelectionTrace: true,
|
|
897
|
-
cardioPreference:
|
|
897
|
+
cardioPreference: 'no-cardio',
|
|
898
898
|
});
|
|
899
899
|
expect(result.success).toBe(true);
|
|
900
900
|
expect(result.exerciseSelectionTraces.map((t) => t.prescriptionIndex)).toEqual([0, 1]);
|
|
@@ -924,7 +924,7 @@ describe('generateProgram', () => {
|
|
|
924
924
|
}),
|
|
925
925
|
],
|
|
926
926
|
debugExerciseSelectionTrace: true,
|
|
927
|
-
cardioPreference: '
|
|
927
|
+
cardioPreference: 'workout-start',
|
|
928
928
|
});
|
|
929
929
|
expect(result.success).toBe(true);
|
|
930
930
|
if (!result.success)
|
|
@@ -966,7 +966,7 @@ describe('generateProgram', () => {
|
|
|
966
966
|
equipment_category: 'other',
|
|
967
967
|
}),
|
|
968
968
|
],
|
|
969
|
-
cardioPreference: '
|
|
969
|
+
cardioPreference: 'workout-start',
|
|
970
970
|
});
|
|
971
971
|
expect(result.success).toBe(true);
|
|
972
972
|
if (!result.success)
|
|
@@ -1011,7 +1011,7 @@ describe('generateProgram', () => {
|
|
|
1011
1011
|
equipment_category: 'other',
|
|
1012
1012
|
}),
|
|
1013
1013
|
],
|
|
1014
|
-
cardioPreference: '
|
|
1014
|
+
cardioPreference: 'workout-start',
|
|
1015
1015
|
});
|
|
1016
1016
|
expect(result.success).toBe(true);
|
|
1017
1017
|
if (!result.success)
|
|
@@ -1052,7 +1052,7 @@ describe('generateProgram', () => {
|
|
|
1052
1052
|
}),
|
|
1053
1053
|
],
|
|
1054
1054
|
excludedExerciseIds: new Set(['run-a']),
|
|
1055
|
-
cardioPreference: '
|
|
1055
|
+
cardioPreference: 'workout-start',
|
|
1056
1056
|
});
|
|
1057
1057
|
expect(result.success).toBe(true);
|
|
1058
1058
|
if (!result.success)
|
|
@@ -1091,7 +1091,7 @@ describe('generateProgram', () => {
|
|
|
1091
1091
|
}),
|
|
1092
1092
|
],
|
|
1093
1093
|
debugExerciseSelectionTrace: true,
|
|
1094
|
-
cardioPreference: '
|
|
1094
|
+
cardioPreference: 'workout-start',
|
|
1095
1095
|
});
|
|
1096
1096
|
expect(result.success).toBe(true);
|
|
1097
1097
|
if (!result.success)
|
|
@@ -1128,7 +1128,7 @@ describe('generateProgram', () => {
|
|
|
1128
1128
|
workoutDurationMinutes: 60,
|
|
1129
1129
|
restTimerLength: 'medium',
|
|
1130
1130
|
exerciseStore: exercises,
|
|
1131
|
-
cardioPreference:
|
|
1131
|
+
cardioPreference: 'no-cardio',
|
|
1132
1132
|
});
|
|
1133
1133
|
expect(result.success).toBe(false);
|
|
1134
1134
|
if (result.success)
|
|
@@ -1159,7 +1159,7 @@ describe('generateProgram', () => {
|
|
|
1159
1159
|
workoutDurationMinutes: 60,
|
|
1160
1160
|
restTimerLength: 'medium',
|
|
1161
1161
|
exerciseStore: exercises,
|
|
1162
|
-
cardioPreference:
|
|
1162
|
+
cardioPreference: 'no-cardio',
|
|
1163
1163
|
});
|
|
1164
1164
|
expect(result.success).toBe(true);
|
|
1165
1165
|
if (!result.success)
|
|
@@ -1213,7 +1213,7 @@ describe('generateProgram', () => {
|
|
|
1213
1213
|
exerciseStore: exercises,
|
|
1214
1214
|
focusMuscle: 'arms',
|
|
1215
1215
|
debugExerciseSelectionTrace: true,
|
|
1216
|
-
cardioPreference:
|
|
1216
|
+
cardioPreference: 'no-cardio',
|
|
1217
1217
|
});
|
|
1218
1218
|
const traces = result.exerciseSelectionTraces;
|
|
1219
1219
|
// Counter increments once per placed focus_muscle prescription, so the
|
|
@@ -1271,7 +1271,7 @@ describe('generateProgram', () => {
|
|
|
1271
1271
|
exerciseStore: exercises,
|
|
1272
1272
|
focusMuscle: 'legs',
|
|
1273
1273
|
debugExerciseSelectionTrace: true,
|
|
1274
|
-
cardioPreference:
|
|
1274
|
+
cardioPreference: 'no-cardio',
|
|
1275
1275
|
});
|
|
1276
1276
|
expect(result.success).toBe(true);
|
|
1277
1277
|
if (!result.success)
|
|
@@ -1311,7 +1311,7 @@ describe('generateProgram', () => {
|
|
|
1311
1311
|
exerciseStore: [candidateExercise],
|
|
1312
1312
|
focusMuscle,
|
|
1313
1313
|
debugExerciseSelectionTrace: true,
|
|
1314
|
-
cardioPreference:
|
|
1314
|
+
cardioPreference: 'no-cardio',
|
|
1315
1315
|
});
|
|
1316
1316
|
// Find the routine we targeted (it may not be first in the split).
|
|
1317
1317
|
const routine = (result.success ? result.program : result.partialProgram).routines.find((r) => r.name === routineName);
|