@dgpholdings/greatoak-shared 1.2.57 → 1.2.58

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.
@@ -135,6 +135,9 @@ export type TExercise = {
135
135
  female: number;
136
136
  default: number;
137
137
  };
138
+ /** True for single-arm / single-leg exercises. The user enters weight per side,
139
+ * so the scoring engine doubles it to get total mechanical load. */
140
+ isUnilateral?: boolean;
138
141
  };
139
142
  export type TBodyPartExercises = Record<TBodyPart, TExercise[]>;
140
143
  export type TApiCreateOrUpdateExerciseReq = {
@@ -49,6 +49,8 @@ interface IFatigueExerciseData {
49
49
  muscleGroupFactor: number;
50
50
  };
51
51
  scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry";
52
+ /** P3-9: Single-arm/leg exercises. User enters weight per side; double it for total load. */
53
+ isUnilateral?: boolean;
52
54
  }
53
55
  /**
54
56
  * Calculate per-muscle fatigue scores for an exercise.
@@ -64,7 +64,7 @@ function calculateMuscleFatigue(sets, exercise, user, timingGuardrails, historic
64
64
  return {};
65
65
  const fatigueMultiplier = (_a = timingGuardrails === null || timingGuardrails === void 0 ? void 0 : timingGuardrails.fatigueMultiplier) !== null && _a !== void 0 ? _a : constants_1.FALLBACK_FATIGUE_MULTIPLIER;
66
66
  // --- Step 1–3: Compute cumulative fatigue stimulus ---
67
- const cumulativeFatigue = computeCumulativeFatigue(sets, exercise.difficultyLevel, user, fatigueMultiplier, exercise.scoringSpecialHandling);
67
+ const cumulativeFatigue = computeCumulativeFatigue(sets, exercise.difficultyLevel, user, fatigueMultiplier, exercise.scoringSpecialHandling, exercise.isUnilateral);
68
68
  // --- Step 4: Distribute to muscles ---
69
69
  const rawMuscleFatigue = distributeFatigueToMuscles(cumulativeFatigue, exercise.primaryMuscles, exercise.secondaryMuscles);
70
70
  // --- Step 5: Normalize to 0–100 ---
@@ -88,11 +88,12 @@ function calculateMuscleFatigue(sets, exercise, user, timingGuardrails, historic
88
88
  * cardio: Duration × speed factor (represents sustained effort)
89
89
  * loaded-carry: Speed factor boosted by carried weight relative to bodyweight
90
90
  */
91
- function computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling) {
91
+ function computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling, isUnilateral) {
92
92
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
93
93
  switch (set.type) {
94
94
  case "weight-reps": {
95
- const kg = (_a = set.kg) !== null && _a !== void 0 ? _a : 0;
95
+ // P3-9: User enters weight per side for unilateral exercises double for total load
96
+ const kg = ((_a = set.kg) !== null && _a !== void 0 ? _a : 0) * (isUnilateral ? 2 : 1);
96
97
  const reps = (_b = set.reps) !== null && _b !== void 0 ? _b : 0;
97
98
  return kg * reps;
98
99
  }
@@ -175,12 +176,12 @@ function computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling) {
175
176
  *
176
177
  * @returns Single number representing total fatigue stimulus
177
178
  */
178
- function computeCumulativeFatigue(sets, difficultyLevel, user, fatigueMultiplier, scoringSpecialHandling) {
179
+ function computeCumulativeFatigue(sets, difficultyLevel, user, fatigueMultiplier, scoringSpecialHandling, isUnilateral) {
179
180
  let cumulative = 0;
180
181
  for (let i = 0; i < sets.length; i++) {
181
182
  const set = sets[i];
182
183
  // Step 1: Raw volume for this set
183
- const volumeLoad = computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling);
184
+ const volumeLoad = computeVolumeLoad(set, difficultyLevel, user, scoringSpecialHandling, isUnilateral);
184
185
  // Step 2: Scale by effort and exercise fatigue multiplier
185
186
  const stimulus = volumeLoad * set.effortFraction * fatigueMultiplier;
186
187
  // Step 3: Apply diminishing returns decay
@@ -15,4 +15,4 @@ import { TRecord, TUserMetric } from "../../types";
15
15
  * @param difficultyLevel Exercise difficulty (0–4). Used for bodyweight load
16
16
  * scaling on reps-only exercises (matches fatigue pillar).
17
17
  */
18
- export declare const calculateTotalVolume: (record: TRecord[], user: TUserMetric, scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry", difficultyLevel?: number) => number;
18
+ export declare const calculateTotalVolume: (record: TRecord[], user: TUserMetric, scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry", difficultyLevel?: number, isUnilateral?: boolean) => number;
@@ -19,7 +19,7 @@ const constants_1 = require("./constants");
19
19
  * @param difficultyLevel Exercise difficulty (0–4). Used for bodyweight load
20
20
  * scaling on reps-only exercises (matches fatigue pillar).
21
21
  */
22
- const calculateTotalVolume = (record, user, scoringSpecialHandling, difficultyLevel = 2) => {
22
+ const calculateTotalVolume = (record, user, scoringSpecialHandling, difficultyLevel = 2, isUnilateral = false) => {
23
23
  if (scoringSpecialHandling === "stretch-mobility")
24
24
  return 0;
25
25
  // Bug A fix: only completed sets contribute to volume.
@@ -28,7 +28,8 @@ const calculateTotalVolume = (record, user, scoringSpecialHandling, difficultyLe
28
28
  switch (set.type) {
29
29
  case "weight-reps": {
30
30
  const reps = parseFloat(set.reps) || 0;
31
- const weight = parseFloat(set.kg) || 0;
31
+ // P3-9: User enters weight per side for unilateral exercises — double for total load
32
+ const weight = (parseFloat(set.kg) || 0) * (isUnilateral ? 2 : 1);
32
33
  return total + reps * weight;
33
34
  }
34
35
  case "reps-only": {
@@ -45,6 +45,7 @@ const calculateExerciseScoreV2 = (param) => {
45
45
  muscleGroupFactor: exercise.metabolicData.muscleGroupFactor,
46
46
  },
47
47
  scoringSpecialHandling: exercise.scoringSpecialHandling,
48
+ isUnilateral: exercise.isUnilateral,
48
49
  }, userContext, exercise.timingGuardrails, historicalContext);
49
50
  // Pillar 3: Quality Score → score
50
51
  const isStrictTimingModeScoring = record.some((r) => r.isStrictMode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgpholdings/greatoak-shared",
3
- "version": "1.2.57",
3
+ "version": "1.2.58",
4
4
  "description": "Shared TypeScript types and utilities for @dgpholdings projects",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",