@trainheroic-unofficial/js 1.7.1 → 1.7.2

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/index.d.mts CHANGED
@@ -343,8 +343,10 @@ declare function toSetResults(results: ReadonlyArray<{
343
343
  * `param_2_data_N` string values plus a `param_N_made` flag.
344
344
  *
345
345
  * `mode` selects which write this is — the same endpoint serves both:
346
- * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has data
347
- * and the exercise `completed` flag is 1 when any set has logged data.
346
+ * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has reps
347
+ * entered (`param1`) and the exercise `completed` flag is 1 when any set is performed. A slot
348
+ * carrying only a weight (`param2`) with no reps is a target, not a performed set, so it stays
349
+ * un-made — matching the app, which shows no completion checkmark until reps are logged.
348
350
  * - `"prescribe"`: the values are prescribed targets, written with every `param_N_made` and
349
351
  * `completed` left at 0 so the set is not marked done. This matches what the app sends when a
350
352
  * coach edits an athlete's prescribed reps/weight.
package/dist/index.mjs CHANGED
@@ -1023,8 +1023,10 @@ function toSetResults(results) {
1023
1023
  * `param_2_data_N` string values plus a `param_N_made` flag.
1024
1024
  *
1025
1025
  * `mode` selects which write this is — the same endpoint serves both:
1026
- * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has data
1027
- * and the exercise `completed` flag is 1 when any set has logged data.
1026
+ * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has reps
1027
+ * entered (`param1`) and the exercise `completed` flag is 1 when any set is performed. A slot
1028
+ * carrying only a weight (`param2`) with no reps is a target, not a performed set, so it stays
1029
+ * un-made — matching the app, which shows no completion checkmark until reps are logged.
1028
1030
  * - `"prescribe"`: the values are prescribed targets, written with every `param_N_made` and
1029
1031
  * `completed` left at 0 so the set is not marked done. This matches what the app sends when a
1030
1032
  * coach edits an athlete's prescribed reps/weight.
@@ -1069,7 +1071,7 @@ function buildExerciseSetPayload(savedWorkoutSetExerciseId, savedWorkoutSetId, w
1069
1071
  if (target) {
1070
1072
  p1 = target.param1 !== void 0 ? String(target.param1) : "";
1071
1073
  p2 = target.param2 !== void 0 ? String(target.param2) : "";
1072
- made = performed && (p1 !== "" || p2 !== "") ? 1 : 0;
1074
+ made = performed && p1 !== "" ? 1 : 0;
1073
1075
  } else if (carryOver && coerceInt(existing?.[`param_${i}_made`]) === 1) {
1074
1076
  p1 = existingSlotData(existing, `param_1_data_${i}`);
1075
1077
  p2 = existingSlotData(existing, `param_2_data_${i}`);
@@ -1097,16 +1099,19 @@ function exerciseHasLoggedData(ex) {
1097
1099
  for (let i = 1; i <= 10; i += 1) if (coerceInt(ex[`param_${i}_made`]) === 1) return true;
1098
1100
  return false;
1099
1101
  }
1100
- /** True when a result carries at least one non-empty param value (so it produces a performed slot). */
1101
- function resultHasData(result) {
1102
- return result.sets.some((s) => s.param1 !== void 0 && String(s.param1) !== "" || s.param2 !== void 0 && String(s.param2) !== "");
1102
+ /** True when a result carries at least one set with reps entered (so it produces a performed slot).
1103
+ * A weight-only set (`param2` set, `param1` blank) is a target, not a performed result, and so does
1104
+ * not count — mirroring the `made` rule in {@link buildExerciseSetPayload}. */
1105
+ function resultHasPerformedSet(result) {
1106
+ return result.sets.some((s) => s.param1 !== void 0 && String(s.param1) !== "");
1103
1107
  }
1104
1108
  /**
1105
1109
  * Whether every exercise in a saved workout set now has logged data — either written with data in
1106
1110
  * this call (`loggedIds`) or already carrying a performed slot. Gates the set-completion PUT: a
1107
1111
  * superset/circuit stays open until the last exercise is logged, so completing it on a partial log
1108
- * does not flip its still-empty siblings to "done". An exercise written with only empty values does
1109
- * not count (it would not be marked performed), so an all-empty log never completes the set.
1112
+ * does not flip its still-empty siblings to "done". An exercise written with no reps — empty values,
1113
+ * or a weight (`param2`) with no reps (`param1`) — does not count (it would not be marked performed),
1114
+ * so a no-reps log never completes the set.
1110
1115
  */
1111
1116
  function isSetFullyLogged(exercises, loggedIds) {
1112
1117
  return exercises.every((ex) => {
@@ -1340,7 +1345,7 @@ async function writeSetResults(client, target, workouts, savedWorkoutSetId, resu
1340
1345
  }
1341
1346
  let setCompleted = false;
1342
1347
  if (mode === "log") {
1343
- if (isSetFullyLogged(exercises, new Set(results.filter(resultHasData).map((r) => r.savedWorkoutSetExerciseId)))) {
1348
+ if (isSetFullyLogged(exercises, new Set(results.filter(resultHasPerformedSet).map((r) => r.savedWorkoutSetExerciseId)))) {
1344
1349
  const setBody = {
1345
1350
  ...buildSetCompletePayload(rawSet, exercises.map((e) => coerceInt(e.id)).filter((n) => n !== null), true),
1346
1351
  ...extra
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/js",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "zod": "^4.4.3",
30
- "@trainheroic-unofficial/dto": "1.7.1"
30
+ "@trainheroic-unofficial/dto": "1.7.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^26.0.1",