@dgpholdings/greatoak-shared 1.2.28 → 1.2.29
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/dist/types/TApiExercise.d.ts +1 -0
- package/dist/types/commonTypes.d.ts +6 -2
- package/dist/utils/scoring/calculateCalories.d.ts +1 -1
- package/dist/utils/scoring/calculateCalories.js +25 -9
- package/dist/utils/scoring/calculateMuscleFatiue.d.ts +1 -0
- package/dist/utils/scoring/calculateMuscleFatiue.js +42 -22
- package/dist/utils/scoring/calculateQualityScore.d.ts +3 -2
- package/dist/utils/scoring/calculateQualityScore.js +5 -6
- package/dist/utils/scoring/calculateTotalVolume.d.ts +10 -6
- package/dist/utils/scoring/calculateTotalVolume.js +34 -13
- package/dist/utils/scoring/constants.d.ts +20 -0
- package/dist/utils/scoring/constants.js +21 -1
- package/dist/utils/scoring/index.js +1 -0
- package/dist/utils/scoring/parseRecords.d.ts +3 -2
- package/dist/utils/scoring/parseRecords.js +8 -4
- package/dist/utils/scoring/types.d.ts +6 -4
- package/package.json +1 -1
|
@@ -121,6 +121,7 @@ export type TExercise = {
|
|
|
121
121
|
importantTipsHtml: string;
|
|
122
122
|
popularityIndex: number;
|
|
123
123
|
isFavorite?: boolean;
|
|
124
|
+
scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry";
|
|
124
125
|
};
|
|
125
126
|
export type TBodyPartExercises = Record<TBodyPart, TExercise[]>;
|
|
126
127
|
export type TApiCreateOrUpdateExerciseReq = {
|
|
@@ -21,13 +21,15 @@ export type TRecord = {
|
|
|
21
21
|
rir?: string;
|
|
22
22
|
} | {
|
|
23
23
|
type: "cardio-machine";
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
speed?: string;
|
|
25
|
+
inclinePercentage?: string;
|
|
26
|
+
resistanceLevel?: string;
|
|
26
27
|
durationMmSs: string;
|
|
27
28
|
distance?: string;
|
|
28
29
|
} | {
|
|
29
30
|
type: "cardio-free";
|
|
30
31
|
distance: string;
|
|
32
|
+
auxWeightKg?: string;
|
|
31
33
|
durationMmSs: string;
|
|
32
34
|
});
|
|
33
35
|
export type TRecordDuration = Extract<TRecord, {
|
|
@@ -53,6 +55,8 @@ export type TExerciseConfig = {
|
|
|
53
55
|
enableSetNote?: boolean;
|
|
54
56
|
enableExerciseNote?: boolean;
|
|
55
57
|
enableTimeIntervalMode?: boolean;
|
|
58
|
+
enableInclinePercentage?: boolean;
|
|
59
|
+
enableResistanceLevel?: boolean;
|
|
56
60
|
};
|
|
57
61
|
export type TTemplateExercise = {
|
|
58
62
|
exerciseId: string;
|
|
@@ -63,5 +63,5 @@ interface IMetabolicData {
|
|
|
63
63
|
* // → 6.4 (for 3 light bench press sets)
|
|
64
64
|
* // → 142.3 (for a 20-min treadmill run)
|
|
65
65
|
*/
|
|
66
|
-
export declare function calculateCalories(sets: IParsedSet[], metabolicData: IMetabolicData, user: IUserContext, difficultyLevel: number): number;
|
|
66
|
+
export declare function calculateCalories(sets: IParsedSet[], metabolicData: IMetabolicData, user: IUserContext, difficultyLevel: number, scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry"): number;
|
|
67
67
|
export {};
|
|
@@ -46,16 +46,21 @@ const helpers_1 = require("./helpers");
|
|
|
46
46
|
* // → 6.4 (for 3 light bench press sets)
|
|
47
47
|
* // → 142.3 (for a 20-min treadmill run)
|
|
48
48
|
*/
|
|
49
|
-
function calculateCalories(sets, metabolicData, user, difficultyLevel) {
|
|
49
|
+
function calculateCalories(sets, metabolicData, user, difficultyLevel, scoringSpecialHandling) {
|
|
50
50
|
if (sets.length === 0)
|
|
51
51
|
return 0;
|
|
52
|
+
// Stretch/mobility: no meaningful work calories — only passive rest MET applies
|
|
53
|
+
if (scoringSpecialHandling === "stretch-mobility") {
|
|
54
|
+
const totalRestSecs = sets.reduce((sum, s) => { var _a; return sum + ((_a = s.restDurationSecs) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
55
|
+
return Math.round(constants_1.REST_MET * user.weightKg * (totalRestSecs / 3600) * 10) / 10;
|
|
56
|
+
}
|
|
52
57
|
// Normalize metRange so [0] = min, [1] = max (sample data has them reversed)
|
|
53
58
|
const [metMin, metMax] = normalizeMetRange(metabolicData.metRange, metabolicData.baseMET);
|
|
54
59
|
let totalWorkCalories = 0;
|
|
55
60
|
let totalRestCalories = 0;
|
|
56
61
|
for (const set of sets) {
|
|
57
62
|
// 1. Calculate effective MET for this set
|
|
58
|
-
const effectiveMET = calculateEffectiveMET(set, metabolicData, metMin, metMax, user, difficultyLevel);
|
|
63
|
+
const effectiveMET = calculateEffectiveMET(set, metabolicData, metMin, metMax, user, difficultyLevel, scoringSpecialHandling);
|
|
59
64
|
// 2. Work calories: MET × weight × time
|
|
60
65
|
const workHours = set.activeDurationSecs / 3600;
|
|
61
66
|
totalWorkCalories += effectiveMET * user.weightKg * workHours;
|
|
@@ -85,12 +90,19 @@ function calculateCalories(sets, metabolicData, user, difficultyLevel) {
|
|
|
85
90
|
* The effort fraction (from RPE/RIR) determines WHERE in the MET range
|
|
86
91
|
* this set falls. Low effort → closer to metMin, high effort → closer to metMax.
|
|
87
92
|
*/
|
|
88
|
-
function calculateEffectiveMET(set, metabolicData, metMin, metMax, user, difficultyLevel) {
|
|
89
|
-
var _a, _b, _c, _d;
|
|
93
|
+
function calculateEffectiveMET(set, metabolicData, metMin, metMax, user, difficultyLevel, scoringSpecialHandling) {
|
|
94
|
+
var _a, _b, _c, _d, _e;
|
|
90
95
|
// Start with effort-scaled MET
|
|
91
96
|
// effortFraction is 0.5–1.3 (from helpers), we normalize to 0–1 for interpolation
|
|
92
97
|
const effortNormalized = (0, helpers_1.clamp)((set.effortFraction - 0.5) / 0.8, 0, 1);
|
|
93
98
|
let met = metMin + (metMax - metMin) * effortNormalized;
|
|
99
|
+
// Continuous-duration (battle ropes, high knees, jump rope): these behave like
|
|
100
|
+
// cardio metabolically — bypass the static-hold duration formula entirely
|
|
101
|
+
if (scoringSpecialHandling === "continuous-duration") {
|
|
102
|
+
met = metMin + (metMax - metMin) * effortNormalized;
|
|
103
|
+
met *= metabolicData.compoundMultiplier;
|
|
104
|
+
return (0, helpers_1.clamp)(met, 1, 25);
|
|
105
|
+
}
|
|
94
106
|
// Apply type-specific intensity scaling
|
|
95
107
|
switch (set.type) {
|
|
96
108
|
case "weight-reps":
|
|
@@ -103,11 +115,17 @@ function calculateEffectiveMET(set, metabolicData, metMin, metMax, user, difficu
|
|
|
103
115
|
met *= getDurationMultiplier((_c = set.durationSecs) !== null && _c !== void 0 ? _c : 0, (_d = set.auxWeightKg) !== null && _d !== void 0 ? _d : 0, user.weightKg, metabolicData);
|
|
104
116
|
break;
|
|
105
117
|
case "cardio-machine":
|
|
106
|
-
// For cardio, we override the effort-based MET with speed-based MET
|
|
107
118
|
met = getCardioMachineMET(set, metabolicData, metMin, metMax, effortNormalized);
|
|
108
119
|
break;
|
|
109
120
|
case "cardio-free":
|
|
110
121
|
met = getCardioFreeMET(set, metabolicData, metMin, metMax, effortNormalized);
|
|
122
|
+
// Loaded carry: scale MET up by the weight being carried relative to bodyweight
|
|
123
|
+
if (scoringSpecialHandling === "loaded-carry") {
|
|
124
|
+
const auxWeightKg = (_e = set.auxWeightKg) !== null && _e !== void 0 ? _e : 0;
|
|
125
|
+
if (auxWeightKg > 0) {
|
|
126
|
+
met *= 1 + (auxWeightKg / user.weightKg) * constants_1.LOADED_CARRY_WEIGHT_MET_SCALE;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
111
129
|
break;
|
|
112
130
|
}
|
|
113
131
|
// Apply compound multiplier (multi-joint exercises have higher energy cost)
|
|
@@ -190,11 +208,9 @@ function getDurationMultiplier(durationSecs, auxWeightKg, userWeightKg, metaboli
|
|
|
190
208
|
* If paceFactors are available, we interpolate from the pace table instead.
|
|
191
209
|
*/
|
|
192
210
|
function getCardioMachineMET(set, metabolicData, metMin, metMax, effortNormalized) {
|
|
193
|
-
var _a
|
|
194
|
-
const speedMin = (_a = set.speedMin) !== null && _a !== void 0 ? _a : 0;
|
|
195
|
-
const speedMax = (_b = set.speedMax) !== null && _b !== void 0 ? _b : 0;
|
|
211
|
+
var _a;
|
|
196
212
|
// Average speed from the set data
|
|
197
|
-
const avgSpeed = (
|
|
213
|
+
const avgSpeed = (_a = set.speed) !== null && _a !== void 0 ? _a : 0;
|
|
198
214
|
if (avgSpeed > 0) {
|
|
199
215
|
// If we have pace factors, use them for more accurate MET lookup
|
|
200
216
|
if (metabolicData.paceFactors) {
|
|
@@ -48,6 +48,7 @@ interface IFatigueExerciseData {
|
|
|
48
48
|
compoundMultiplier: number;
|
|
49
49
|
muscleGroupFactor: number;
|
|
50
50
|
};
|
|
51
|
+
scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry";
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Calculate per-muscle fatigue scores for an exercise.
|
|
@@ -59,9 +59,12 @@ function calculateMuscleFatigue(sets, exercise, user, timingGuardrails) {
|
|
|
59
59
|
var _a;
|
|
60
60
|
if (sets.length === 0)
|
|
61
61
|
return {};
|
|
62
|
+
// Stretching/mobility produces zero mechanical fatigue — skip entirely
|
|
63
|
+
if (exercise.scoringSpecialHandling === "stretch-mobility")
|
|
64
|
+
return {};
|
|
62
65
|
const fatigueMultiplier = (_a = timingGuardrails === null || timingGuardrails === void 0 ? void 0 : timingGuardrails.fatigueMultiplier) !== null && _a !== void 0 ? _a : constants_1.FALLBACK_FATIGUE_MULTIPLIER;
|
|
63
66
|
// --- Step 1–3: Compute cumulative fatigue stimulus ---
|
|
64
|
-
const cumulativeFatigue = computeCumulativeFatigue(sets, exercise.difficultyLevel, user, fatigueMultiplier);
|
|
67
|
+
const cumulativeFatigue = computeCumulativeFatigue(sets, exercise.difficultyLevel, user, fatigueMultiplier, exercise.scoringSpecialHandling);
|
|
65
68
|
// --- Step 4: Distribute to muscles ---
|
|
66
69
|
const rawMuscleFatigue = distributeFatigueToMuscles(cumulativeFatigue, exercise.primaryMuscles, exercise.secondaryMuscles);
|
|
67
70
|
// --- Step 5: Normalize to 0–100 ---
|
|
@@ -77,13 +80,16 @@ function calculateMuscleFatigue(sets, exercise, user, timingGuardrails) {
|
|
|
77
80
|
* Volume load represents the mechanical work experienced by the muscles.
|
|
78
81
|
* Different exercise types produce volume in fundamentally different ways:
|
|
79
82
|
*
|
|
80
|
-
* weight-reps:
|
|
81
|
-
* reps-only:
|
|
82
|
-
*
|
|
83
|
-
*
|
|
83
|
+
* weight-reps: Force (kg) × repetitions
|
|
84
|
+
* reps-only: Effective load (BW fraction + aux) × repetitions
|
|
85
|
+
* plyometric: Same + PLYOMETRIC_LOAD_MULTIPLIER for impact/neuromotor demand
|
|
86
|
+
* duration: Time under tension × difficulty scaling × aux boost
|
|
87
|
+
* continuous-duration: Routed through cardio path with dampener (no static hold)
|
|
88
|
+
* cardio: Duration × speed factor (represents sustained effort)
|
|
89
|
+
* loaded-carry: Speed factor boosted by carried weight relative to bodyweight
|
|
84
90
|
*/
|
|
85
|
-
function computeVolumeLoad(set, difficultyLevel, user) {
|
|
86
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
91
|
+
function computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling) {
|
|
92
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
87
93
|
switch (set.type) {
|
|
88
94
|
case "weight-reps": {
|
|
89
95
|
const kg = (_a = set.kg) !== null && _a !== void 0 ? _a : 0;
|
|
@@ -97,11 +103,22 @@ function computeVolumeLoad(set, difficultyLevel, user) {
|
|
|
97
103
|
// difficulty 0 → 0%, difficulty 2 → ~33%, difficulty 4 → 65%
|
|
98
104
|
const bodyweightLoad = (difficultyLevel / 4) * constants_1.BW_FRACTION_SCALE * user.weightKg;
|
|
99
105
|
const totalLoad = bodyweightLoad + auxWeightKg;
|
|
100
|
-
|
|
106
|
+
const baseVolume = totalLoad * reps;
|
|
107
|
+
// Plyometric: impact forces and neuromotor demand exceed simple BW × reps
|
|
108
|
+
if (scoringSpecialHandling === "plyometric") {
|
|
109
|
+
return baseVolume * constants_1.PLYOMETRIC_LOAD_MULTIPLIER;
|
|
110
|
+
}
|
|
111
|
+
return baseVolume;
|
|
101
112
|
}
|
|
102
113
|
case "duration": {
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
// Continuous-movement duration (battle ropes, high knees, jump rope):
|
|
115
|
+
// these are not static holds — route through cardio path with dampener
|
|
116
|
+
if (scoringSpecialHandling === "continuous-duration") {
|
|
117
|
+
const durationSecs = (_e = set.durationSecs) !== null && _e !== void 0 ? _e : set.activeDurationSecs;
|
|
118
|
+
return durationSecs * constants_1.CONTINUOUS_DURATION_INTENSITY_FACTOR * constants_1.CARDIO_MUSCLE_FATIGUE_DAMPENER;
|
|
119
|
+
}
|
|
120
|
+
const durationSecs = (_f = set.durationSecs) !== null && _f !== void 0 ? _f : set.activeDurationSecs;
|
|
121
|
+
const auxWeightKg = (_g = set.auxWeightKg) !== null && _g !== void 0 ? _g : 0;
|
|
105
122
|
// Duration exercises: time under tension is the primary driver
|
|
106
123
|
// Scale by (difficultyLevel + 1) so even difficulty-0 produces some fatigue
|
|
107
124
|
// Aux weight adds load (holding a plate during plank, etc.)
|
|
@@ -109,13 +126,11 @@ function computeVolumeLoad(set, difficultyLevel, user) {
|
|
|
109
126
|
return durationSecs * (difficultyLevel + 1) * auxBoost;
|
|
110
127
|
}
|
|
111
128
|
case "cardio-machine": {
|
|
112
|
-
const durationSecs = (
|
|
113
|
-
const
|
|
114
|
-
const speedMax = (_j = set.speedMax) !== null && _j !== void 0 ? _j : 0;
|
|
115
|
-
const avgSpeed = (speedMin + speedMax) / 2;
|
|
129
|
+
const durationSecs = (_h = set.cardioDurationSecs) !== null && _h !== void 0 ? _h : set.activeDurationSecs;
|
|
130
|
+
const speed = (_j = set.speed) !== null && _j !== void 0 ? _j : 0;
|
|
116
131
|
// Speed factor: faster pace = more muscle engagement per second
|
|
117
132
|
// Normalize against expected speed range (3–20 km/h)
|
|
118
|
-
const speedFactor =
|
|
133
|
+
const speedFactor = speed > 0 ? (0, helpers_1.clamp)(speed / constants_1.CARDIO_SPEED_RANGE.max, 0.1, 1.5) : 0.3; // fallback: light effort
|
|
119
134
|
// Cardio dampener: running fatigues muscles less than lifting
|
|
120
135
|
// A 30-min jog ≠ 30 min of squats for muscle fatigue
|
|
121
136
|
return durationSecs * speedFactor * constants_1.CARDIO_MUSCLE_FATIGUE_DAMPENER;
|
|
@@ -123,16 +138,21 @@ function computeVolumeLoad(set, difficultyLevel, user) {
|
|
|
123
138
|
case "cardio-free": {
|
|
124
139
|
const durationSecs = (_k = set.cardioDurationSecs) !== null && _k !== void 0 ? _k : set.activeDurationSecs;
|
|
125
140
|
const distance = (_l = set.distance) !== null && _l !== void 0 ? _l : 0;
|
|
126
|
-
let
|
|
141
|
+
let speedFactor;
|
|
127
142
|
if (distance > 0 && durationSecs > 0) {
|
|
128
143
|
const speedKmh = distance / (durationSecs / 3600);
|
|
129
|
-
|
|
130
|
-
baseVolume = durationSecs * speedFactor;
|
|
144
|
+
speedFactor = (0, helpers_1.clamp)(speedKmh / constants_1.CARDIO_SPEED_RANGE.max, 0.1, 1.5);
|
|
131
145
|
}
|
|
132
146
|
else {
|
|
133
|
-
|
|
147
|
+
speedFactor = 0.3;
|
|
134
148
|
}
|
|
135
|
-
|
|
149
|
+
// Loaded carry: the weight being carried increases muscle stress beyond pace alone
|
|
150
|
+
if (scoringSpecialHandling === "loaded-carry") {
|
|
151
|
+
const auxWeightKg = (_m = set.auxWeightKg) !== null && _m !== void 0 ? _m : 0;
|
|
152
|
+
const weightBoost = 1 + (auxWeightKg / user.weightKg) * 0.4;
|
|
153
|
+
return durationSecs * speedFactor * weightBoost * constants_1.CARDIO_MUSCLE_FATIGUE_DAMPENER;
|
|
154
|
+
}
|
|
155
|
+
return durationSecs * speedFactor * constants_1.CARDIO_MUSCLE_FATIGUE_DAMPENER;
|
|
136
156
|
}
|
|
137
157
|
default:
|
|
138
158
|
return 0;
|
|
@@ -155,12 +175,12 @@ function computeVolumeLoad(set, difficultyLevel, user) {
|
|
|
155
175
|
*
|
|
156
176
|
* @returns Single number representing total fatigue stimulus
|
|
157
177
|
*/
|
|
158
|
-
function computeCumulativeFatigue(sets, difficultyLevel, user, fatigueMultiplier) {
|
|
178
|
+
function computeCumulativeFatigue(sets, difficultyLevel, user, fatigueMultiplier, scoringSpecialHandling) {
|
|
159
179
|
let cumulative = 0;
|
|
160
180
|
for (let i = 0; i < sets.length; i++) {
|
|
161
181
|
const set = sets[i];
|
|
162
182
|
// Step 1: Raw volume for this set
|
|
163
|
-
const volumeLoad = computeVolumeLoad(set, difficultyLevel, user);
|
|
183
|
+
const volumeLoad = computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling);
|
|
164
184
|
// Step 2: Scale by effort and exercise fatigue multiplier
|
|
165
185
|
const stimulus = volumeLoad * set.effortFraction * fatigueMultiplier;
|
|
166
186
|
// Step 3: Apply diminishing returns decay
|
|
@@ -44,8 +44,9 @@ interface IRawRecord {
|
|
|
44
44
|
reps?: string;
|
|
45
45
|
durationMmSs?: string;
|
|
46
46
|
auxWeightKg?: string;
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
speed?: string;
|
|
48
|
+
inclinePercentage?: string;
|
|
49
|
+
resistanceLevel?: string;
|
|
49
50
|
distance?: string;
|
|
50
51
|
restDurationSecs?: number;
|
|
51
52
|
}
|
|
@@ -137,7 +137,7 @@ function calculateConsistency(parsedSets) {
|
|
|
137
137
|
* Extract the consistency metric for a set based on its type.
|
|
138
138
|
*/
|
|
139
139
|
function extractConsistencyMetric(set) {
|
|
140
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
140
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
141
141
|
switch (set.type) {
|
|
142
142
|
case "weight-reps": {
|
|
143
143
|
// Volume per set: weight × reps
|
|
@@ -155,14 +155,13 @@ function extractConsistencyMetric(set) {
|
|
|
155
155
|
}
|
|
156
156
|
case "cardio-machine": {
|
|
157
157
|
// Average speed
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
return (speedMin + speedMax) / 2;
|
|
158
|
+
const speed = (_e = set.speed) !== null && _e !== void 0 ? _e : 0;
|
|
159
|
+
return speed;
|
|
161
160
|
}
|
|
162
161
|
case "cardio-free": {
|
|
163
162
|
// Effective speed (km/h)
|
|
164
|
-
const distance = (
|
|
165
|
-
const durationSecs = (
|
|
163
|
+
const distance = (_f = set.distance) !== null && _f !== void 0 ? _f : 0;
|
|
164
|
+
const durationSecs = (_g = set.cardioDurationSecs) !== null && _g !== void 0 ? _g : set.activeDurationSecs;
|
|
166
165
|
if (durationSecs > 0 && distance > 0) {
|
|
167
166
|
return distance / (durationSecs / 3600);
|
|
168
167
|
}
|
|
@@ -2,10 +2,14 @@ import { TRecord, TUserMetric } from "../../types";
|
|
|
2
2
|
/**
|
|
3
3
|
* Calculates total volume for a set of records.
|
|
4
4
|
*
|
|
5
|
-
* - weight-reps:
|
|
6
|
-
* - reps-only:
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
5
|
+
* - weight-reps: reps * weight
|
|
6
|
+
* - reps-only: reps * (auxWeight || 30% of bodyweight)
|
|
7
|
+
* plyometric: × 1.5 multiplier for impact/explosive demand
|
|
8
|
+
* - duration: durationSecs * 10 * (1 + auxWeight/100)
|
|
9
|
+
* continuous-duration: durationSecs only (no static-hold multiplier)
|
|
10
|
+
* stretch-mobility: 0 (no training volume)
|
|
11
|
+
* - cardio-machine: distance (m) * (1 + speed/20) * inclineBoost * resistanceBoost
|
|
12
|
+
* - cardio-free: distance (m) * (1 + speed/20)
|
|
13
|
+
* loaded-carry: × carried weight boost
|
|
10
14
|
*/
|
|
11
|
-
export declare const calculateTotalVolume: (record: TRecord[], user: TUserMetric) => number;
|
|
15
|
+
export declare const calculateTotalVolume: (record: TRecord[], user: TUserMetric, scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry") => number;
|
|
@@ -5,18 +5,25 @@ const time_util_1 = require("../time.util");
|
|
|
5
5
|
/**
|
|
6
6
|
* Calculates total volume for a set of records.
|
|
7
7
|
*
|
|
8
|
-
* - weight-reps:
|
|
9
|
-
* - reps-only:
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
8
|
+
* - weight-reps: reps * weight
|
|
9
|
+
* - reps-only: reps * (auxWeight || 30% of bodyweight)
|
|
10
|
+
* plyometric: × 1.5 multiplier for impact/explosive demand
|
|
11
|
+
* - duration: durationSecs * 10 * (1 + auxWeight/100)
|
|
12
|
+
* continuous-duration: durationSecs only (no static-hold multiplier)
|
|
13
|
+
* stretch-mobility: 0 (no training volume)
|
|
14
|
+
* - cardio-machine: distance (m) * (1 + speed/20) * inclineBoost * resistanceBoost
|
|
15
|
+
* - cardio-free: distance (m) * (1 + speed/20)
|
|
16
|
+
* loaded-carry: × carried weight boost
|
|
13
17
|
*/
|
|
14
|
-
const calculateTotalVolume = (record, user) => {
|
|
18
|
+
const calculateTotalVolume = (record, user, scoringSpecialHandling) => {
|
|
19
|
+
// Stretching/mobility produces no training volume
|
|
20
|
+
if (scoringSpecialHandling === "stretch-mobility")
|
|
21
|
+
return 0;
|
|
15
22
|
return record.reduce((total, set) => {
|
|
16
23
|
const weight = parseFloat(set.type === "weight-reps"
|
|
17
24
|
? set.kg
|
|
18
|
-
: set.type === "duration" || set.type === "reps-only"
|
|
19
|
-
? set.auxWeightKg
|
|
25
|
+
: set.type === "duration" || set.type === "reps-only" || set.type === "cardio-free"
|
|
26
|
+
? set.auxWeightKg || "0"
|
|
20
27
|
: "0") || 0;
|
|
21
28
|
const reps = parseFloat(set.type === "weight-reps" || set.type === "reps-only" ? set.reps : "0") || 0;
|
|
22
29
|
const duration = set.type === "duration" ||
|
|
@@ -30,21 +37,35 @@ const calculateTotalVolume = (record, user) => {
|
|
|
30
37
|
else if (set.type === "reps-only") {
|
|
31
38
|
const bodyweight = user.weightKg || 70;
|
|
32
39
|
const effectiveWeight = weight > 0 ? weight : bodyweight * 0.3;
|
|
33
|
-
|
|
40
|
+
const baseVolume = reps * effectiveWeight;
|
|
41
|
+
return total + (scoringSpecialHandling === "plyometric" ? baseVolume * 1.5 : baseVolume);
|
|
34
42
|
}
|
|
35
43
|
else if (set.type === "duration") {
|
|
44
|
+
// Continuous-duration: no static-hold multiplier — just time elapsed
|
|
45
|
+
if (scoringSpecialHandling === "continuous-duration") {
|
|
46
|
+
return total + duration;
|
|
47
|
+
}
|
|
36
48
|
const weightFactor = weight > 0 ? 1 + weight / 100 : 1;
|
|
37
49
|
return total + duration * 10 * weightFactor;
|
|
38
50
|
}
|
|
39
51
|
else if (set.type === "cardio-machine") {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
52
|
+
const speed = parseFloat(set.speed || "10");
|
|
53
|
+
const inclineBoost = set.inclinePercentage
|
|
54
|
+
? 1 + parseFloat(set.inclinePercentage) * 0.02
|
|
55
|
+
: 1;
|
|
56
|
+
const resistanceBoost = set.resistanceLevel
|
|
57
|
+
? 1 + parseFloat(set.resistanceLevel) * 0.05
|
|
58
|
+
: 1;
|
|
59
|
+
const distance = parseFloat(set.distance || "0") || (speed * duration) / 3600;
|
|
60
|
+
return total + distance * 1000 * (1 + speed / 20) * inclineBoost * resistanceBoost;
|
|
43
61
|
}
|
|
44
62
|
else if (set.type === "cardio-free") {
|
|
45
63
|
const distance = parseFloat(set.distance) || 0;
|
|
46
64
|
const speed = distance / (duration / 3600);
|
|
47
|
-
|
|
65
|
+
const carryBoost = scoringSpecialHandling === "loaded-carry" && weight > 0
|
|
66
|
+
? 1 + weight / (user.weightKg || 70) * 0.5
|
|
67
|
+
: 1;
|
|
68
|
+
return total + distance * 1000 * (1 + speed / 20) * carryBoost;
|
|
48
69
|
}
|
|
49
70
|
return total;
|
|
50
71
|
}, 0);
|
|
@@ -133,6 +133,26 @@ export declare const SET_FATIGUE_DECAY_RATE = 0.15;
|
|
|
133
133
|
* "volume" of strength work would.
|
|
134
134
|
*/
|
|
135
135
|
export declare const CARDIO_MUSCLE_FATIGUE_DAMPENER = 0.3;
|
|
136
|
+
/**
|
|
137
|
+
* Load multiplier for plyometric / explosive reps-only exercises.
|
|
138
|
+
* Accounts for impact forces (3–5× BW) and neuromotor demand that
|
|
139
|
+
* simple BW × reps volume underestimates.
|
|
140
|
+
* Applied to volume load before fatigue distribution.
|
|
141
|
+
*/
|
|
142
|
+
export declare const PLYOMETRIC_LOAD_MULTIPLIER = 1.5;
|
|
143
|
+
/**
|
|
144
|
+
* Intensity factor for continuous-movement duration exercises
|
|
145
|
+
* (battle ropes, high knees, jump rope) when no speed/distance is available.
|
|
146
|
+
* Represents moderate continuous effort — higher than isometric holds but
|
|
147
|
+
* routed through the cardio dampener like other cardio types.
|
|
148
|
+
*/
|
|
149
|
+
export declare const CONTINUOUS_DURATION_INTENSITY_FACTOR = 0.5;
|
|
150
|
+
/**
|
|
151
|
+
* MET scale factor for loaded-carry exercises (farmer's walk, overhead carry).
|
|
152
|
+
* For every 100% of bodyweight carried, MET is boosted by this fraction.
|
|
153
|
+
* e.g. carrying 50% BW → MET × (1 + 0.5 × 0.5) = MET × 1.25
|
|
154
|
+
*/
|
|
155
|
+
export declare const LOADED_CARRY_WEIGHT_MET_SCALE = 0.5;
|
|
136
156
|
/**
|
|
137
157
|
* Reference max scaling by difficulty level.
|
|
138
158
|
* Maps difficultyLevel (0–4) → expected max weight as a fraction of bodyweight.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* FACTOR_* = multipliers used in formulas
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.REST_NO_DATA_SCORE = exports.REST_OUTSIDE_SCORE = exports.REST_ACCEPTABLE_BASE = exports.REST_OPTIMAL_SCORE = exports.EFFORT_NO_DATA_SCORE = exports.EFFORT_MIN_SCORE = exports.EFFORT_DISTANCE_PENALTY = exports.OPTIMAL_RPE_RANGE = exports.OPTIMAL_RIR_RANGE = exports.PROGRESSIVE_OVERLOAD_FLOOR = exports.CONSISTENCY_MIN_SCORE = exports.CONSISTENCY_CV_PENALTY = exports.QUALITY_WEIGHTS = exports.REFERENCE_MAX_EFFORT = exports.REFERENCE_MAX_REPS = exports.REFERENCE_MAX_SETS = exports.DIFFICULTY_TO_WEIGHT_FRACTION = exports.CARDIO_MUSCLE_FATIGUE_DAMPENER = exports.SET_FATIGUE_DECAY_RATE = exports.SECONDARY_MUSCLE_ALLOCATION = exports.PRIMARY_MUSCLE_ALLOCATION = exports.CARDIO_SPEED_RANGE = exports.BW_FRACTION_SCALE = exports.DURATION_CATEGORY_THRESHOLDS = exports.DEFAULT_DURATION_FACTORS = exports.WEIGHT_CATEGORY_THRESHOLDS = exports.DEFAULT_WEIGHT_FACTORS = exports.REST_MET = exports.EFFORT_FRACTION_RANGE = exports.EFFORT_FRACTION_BASE = exports.EFFORT_CURVE_EXPONENT = exports.DEFAULT_EFFORT_FRACTION = exports.ABSOLUTE_WORK_MAX = exports.ABSOLUTE_WORK_MIN = exports.ABSOLUTE_REST_MAX = exports.ABSOLUTE_REST_MIN = exports.FALLBACK_STRESS_REST_BONUS = exports.FALLBACK_FATIGUE_MULTIPLIER = exports.FALLBACK_REST_SECS = exports.FALLBACK_SET_DURATION_SECS = exports.FALLBACK_SECS_PER_REP = exports.DEFAULT_USER_AGE = exports.DEFAULT_USER_HEIGHT_CM = exports.DEFAULT_USER_WEIGHT_KG = void 0;
|
|
19
|
+
exports.REST_NO_DATA_SCORE = exports.REST_OUTSIDE_SCORE = exports.REST_ACCEPTABLE_BASE = exports.REST_OPTIMAL_SCORE = exports.EFFORT_NO_DATA_SCORE = exports.EFFORT_MIN_SCORE = exports.EFFORT_DISTANCE_PENALTY = exports.OPTIMAL_RPE_RANGE = exports.OPTIMAL_RIR_RANGE = exports.PROGRESSIVE_OVERLOAD_FLOOR = exports.CONSISTENCY_MIN_SCORE = exports.CONSISTENCY_CV_PENALTY = exports.QUALITY_WEIGHTS = exports.REFERENCE_MAX_EFFORT = exports.REFERENCE_MAX_REPS = exports.REFERENCE_MAX_SETS = exports.DIFFICULTY_TO_WEIGHT_FRACTION = exports.LOADED_CARRY_WEIGHT_MET_SCALE = exports.CONTINUOUS_DURATION_INTENSITY_FACTOR = exports.PLYOMETRIC_LOAD_MULTIPLIER = exports.CARDIO_MUSCLE_FATIGUE_DAMPENER = exports.SET_FATIGUE_DECAY_RATE = exports.SECONDARY_MUSCLE_ALLOCATION = exports.PRIMARY_MUSCLE_ALLOCATION = exports.CARDIO_SPEED_RANGE = exports.BW_FRACTION_SCALE = exports.DURATION_CATEGORY_THRESHOLDS = exports.DEFAULT_DURATION_FACTORS = exports.WEIGHT_CATEGORY_THRESHOLDS = exports.DEFAULT_WEIGHT_FACTORS = exports.REST_MET = exports.EFFORT_FRACTION_RANGE = exports.EFFORT_FRACTION_BASE = exports.EFFORT_CURVE_EXPONENT = exports.DEFAULT_EFFORT_FRACTION = exports.ABSOLUTE_WORK_MAX = exports.ABSOLUTE_WORK_MIN = exports.ABSOLUTE_REST_MAX = exports.ABSOLUTE_REST_MIN = exports.FALLBACK_STRESS_REST_BONUS = exports.FALLBACK_FATIGUE_MULTIPLIER = exports.FALLBACK_REST_SECS = exports.FALLBACK_SET_DURATION_SECS = exports.FALLBACK_SECS_PER_REP = exports.DEFAULT_USER_AGE = exports.DEFAULT_USER_HEIGHT_CM = exports.DEFAULT_USER_WEIGHT_KG = void 0;
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
21
|
// User Defaults (when TUserMetric has missing fields)
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
@@ -165,6 +165,26 @@ exports.SET_FATIGUE_DECAY_RATE = 0.15;
|
|
|
165
165
|
* "volume" of strength work would.
|
|
166
166
|
*/
|
|
167
167
|
exports.CARDIO_MUSCLE_FATIGUE_DAMPENER = 0.3;
|
|
168
|
+
/**
|
|
169
|
+
* Load multiplier for plyometric / explosive reps-only exercises.
|
|
170
|
+
* Accounts for impact forces (3–5× BW) and neuromotor demand that
|
|
171
|
+
* simple BW × reps volume underestimates.
|
|
172
|
+
* Applied to volume load before fatigue distribution.
|
|
173
|
+
*/
|
|
174
|
+
exports.PLYOMETRIC_LOAD_MULTIPLIER = 1.5;
|
|
175
|
+
/**
|
|
176
|
+
* Intensity factor for continuous-movement duration exercises
|
|
177
|
+
* (battle ropes, high knees, jump rope) when no speed/distance is available.
|
|
178
|
+
* Represents moderate continuous effort — higher than isometric holds but
|
|
179
|
+
* routed through the cardio dampener like other cardio types.
|
|
180
|
+
*/
|
|
181
|
+
exports.CONTINUOUS_DURATION_INTENSITY_FACTOR = 0.5;
|
|
182
|
+
/**
|
|
183
|
+
* MET scale factor for loaded-carry exercises (farmer's walk, overhead carry).
|
|
184
|
+
* For every 100% of bodyweight carried, MET is boosted by this fraction.
|
|
185
|
+
* e.g. carrying 50% BW → MET × (1 + 0.5 × 0.5) = MET × 1.25
|
|
186
|
+
*/
|
|
187
|
+
exports.LOADED_CARRY_WEIGHT_MET_SCALE = 0.5;
|
|
168
188
|
/**
|
|
169
189
|
* Reference max scaling by difficulty level.
|
|
170
190
|
* Maps difficultyLevel (0–4) → expected max weight as a fraction of bodyweight.
|
|
@@ -38,6 +38,7 @@ const calculateExerciseScoreV2 = (param) => {
|
|
|
38
38
|
compoundMultiplier: exercise.metabolicData.compoundMultiplier,
|
|
39
39
|
muscleGroupFactor: exercise.metabolicData.muscleGroupFactor,
|
|
40
40
|
},
|
|
41
|
+
scoringSpecialHandling: exercise.scoringSpecialHandling,
|
|
41
42
|
}, userContext, exercise.timingGuardrails);
|
|
42
43
|
// Pillar 3: Quality Score → score
|
|
43
44
|
const { score } = (0, calculateQualityScore_1.calculateQualityScore)(parsedSets, record, exercise.timingGuardrails);
|
|
@@ -143,8 +143,9 @@ function parseDuration(record, effortFraction, restDurationSecs, guardrails) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
function parseCardioMachine(record, effortFraction, restDurationSecs) {
|
|
146
|
-
const
|
|
147
|
-
const
|
|
146
|
+
const speed = (0, helpers_1.safeParseFloat)(record.speed);
|
|
147
|
+
const inclinePercentage = (0, helpers_1.safeParseFloat)(record.inclinePercentage);
|
|
148
|
+
const resistanceLevel = (0, helpers_1.safeParseFloat)(record.resistanceLevel);
|
|
148
149
|
const distance = (0, helpers_1.safeParseFloat)(record.distance);
|
|
149
150
|
const cardioDurationSecs = (0, helpers_1.parseDurationMmSs)(record.durationMmSs);
|
|
150
151
|
// Need at least duration or distance to be meaningful
|
|
@@ -156,14 +157,16 @@ function parseCardioMachine(record, effortFraction, restDurationSecs) {
|
|
|
156
157
|
activeDurationSecs,
|
|
157
158
|
restDurationSecs,
|
|
158
159
|
effortFraction,
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
speed,
|
|
161
|
+
inclinePercentage,
|
|
162
|
+
resistanceLevel,
|
|
161
163
|
distance,
|
|
162
164
|
cardioDurationSecs,
|
|
163
165
|
};
|
|
164
166
|
}
|
|
165
167
|
function parseCardioFree(record, effortFraction, restDurationSecs) {
|
|
166
168
|
const distance = (0, helpers_1.safeParseFloat)(record.distance);
|
|
169
|
+
const auxWeightKg = (0, helpers_1.safeParseFloat)(record.auxWeightKg);
|
|
167
170
|
const cardioDurationSecs = (0, helpers_1.parseDurationMmSs)(record.durationMmSs);
|
|
168
171
|
if (cardioDurationSecs === 0 && distance === 0)
|
|
169
172
|
return null;
|
|
@@ -174,6 +177,7 @@ function parseCardioFree(record, effortFraction, restDurationSecs) {
|
|
|
174
177
|
restDurationSecs,
|
|
175
178
|
effortFraction,
|
|
176
179
|
distance,
|
|
180
|
+
auxWeightKg,
|
|
177
181
|
cardioDurationSecs,
|
|
178
182
|
};
|
|
179
183
|
}
|
|
@@ -63,10 +63,12 @@ export interface IParsedSet {
|
|
|
63
63
|
auxWeightKg?: number;
|
|
64
64
|
/** duration: hold time in seconds */
|
|
65
65
|
durationSecs?: number;
|
|
66
|
-
/** cardio-machine:
|
|
67
|
-
|
|
68
|
-
/** cardio-machine:
|
|
69
|
-
|
|
66
|
+
/** cardio-machine: speed */
|
|
67
|
+
speed?: number;
|
|
68
|
+
/** cardio-machine: incline percentage (Treadmill) */
|
|
69
|
+
inclinePercentage?: number;
|
|
70
|
+
/** cardio-machine: resistance level (Elliptical, Cycling) */
|
|
71
|
+
resistanceLevel?: number;
|
|
70
72
|
/** cardio-machine / cardio-free: distance (km) */
|
|
71
73
|
distance?: number;
|
|
72
74
|
/** cardio-free / cardio-machine: session duration in seconds */
|