@trainheroic-unofficial/cli 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.
Files changed (2) hide show
  1. package/dist/cli.mjs +14 -9
  2. package/package.json +3 -3
package/dist/cli.mjs CHANGED
@@ -1360,8 +1360,10 @@ function toSetResults(results) {
1360
1360
  * `param_2_data_N` string values plus a `param_N_made` flag.
1361
1361
  *
1362
1362
  * `mode` selects which write this is — the same endpoint serves both:
1363
- * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has data
1364
- * and the exercise `completed` flag is 1 when any set has logged data.
1363
+ * - `"log"`: the values ARE a performed result, so `param_N_made` is 1 where the slot has reps
1364
+ * entered (`param1`) and the exercise `completed` flag is 1 when any set is performed. A slot
1365
+ * carrying only a weight (`param2`) with no reps is a target, not a performed set, so it stays
1366
+ * un-made — matching the app, which shows no completion checkmark until reps are logged.
1365
1367
  * - `"prescribe"`: the values are prescribed targets, written with every `param_N_made` and
1366
1368
  * `completed` left at 0 so the set is not marked done. This matches what the app sends when a
1367
1369
  * coach edits an athlete's prescribed reps/weight.
@@ -1406,7 +1408,7 @@ function buildExerciseSetPayload(savedWorkoutSetExerciseId, savedWorkoutSetId, w
1406
1408
  if (target) {
1407
1409
  p1 = target.param1 !== void 0 ? String(target.param1) : "";
1408
1410
  p2 = target.param2 !== void 0 ? String(target.param2) : "";
1409
- made = performed && (p1 !== "" || p2 !== "") ? 1 : 0;
1411
+ made = performed && p1 !== "" ? 1 : 0;
1410
1412
  } else if (carryOver && coerceInt(existing?.[`param_${i}_made`]) === 1) {
1411
1413
  p1 = existingSlotData(existing, `param_1_data_${i}`);
1412
1414
  p2 = existingSlotData(existing, `param_2_data_${i}`);
@@ -1434,16 +1436,19 @@ function exerciseHasLoggedData(ex) {
1434
1436
  for (let i = 1; i <= 10; i += 1) if (coerceInt(ex[`param_${i}_made`]) === 1) return true;
1435
1437
  return false;
1436
1438
  }
1437
- /** True when a result carries at least one non-empty param value (so it produces a performed slot). */
1438
- function resultHasData(result) {
1439
- return result.sets.some((s) => s.param1 !== void 0 && String(s.param1) !== "" || s.param2 !== void 0 && String(s.param2) !== "");
1439
+ /** True when a result carries at least one set with reps entered (so it produces a performed slot).
1440
+ * A weight-only set (`param2` set, `param1` blank) is a target, not a performed result, and so does
1441
+ * not count — mirroring the `made` rule in {@link buildExerciseSetPayload}. */
1442
+ function resultHasPerformedSet(result) {
1443
+ return result.sets.some((s) => s.param1 !== void 0 && String(s.param1) !== "");
1440
1444
  }
1441
1445
  /**
1442
1446
  * Whether every exercise in a saved workout set now has logged data — either written with data in
1443
1447
  * this call (`loggedIds`) or already carrying a performed slot. Gates the set-completion PUT: a
1444
1448
  * superset/circuit stays open until the last exercise is logged, so completing it on a partial log
1445
- * does not flip its still-empty siblings to "done". An exercise written with only empty values does
1446
- * not count (it would not be marked performed), so an all-empty log never completes the set.
1449
+ * does not flip its still-empty siblings to "done". An exercise written with no reps — empty values,
1450
+ * or a weight (`param2`) with no reps (`param1`) — does not count (it would not be marked performed),
1451
+ * so a no-reps log never completes the set.
1447
1452
  */
1448
1453
  function isSetFullyLogged(exercises, loggedIds) {
1449
1454
  return exercises.every((ex) => {
@@ -1677,7 +1682,7 @@ async function writeSetResults(client, target, workouts, savedWorkoutSetId, resu
1677
1682
  }
1678
1683
  let setCompleted = false;
1679
1684
  if (mode === "log") {
1680
- if (isSetFullyLogged(exercises, new Set(results.filter(resultHasData).map((r) => r.savedWorkoutSetExerciseId)))) {
1685
+ if (isSetFullyLogged(exercises, new Set(results.filter(resultHasPerformedSet).map((r) => r.savedWorkoutSetExerciseId)))) {
1681
1686
  const setBody = {
1682
1687
  ...buildSetCompletePayload(rawSet, exercises.map((e) => coerceInt(e.id)).filter((n) => n !== null), true),
1683
1688
  ...extra
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/cli",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/dto": "1.7.1",
25
- "@trainheroic-unofficial/js": "1.7.1"
24
+ "@trainheroic-unofficial/dto": "1.7.2",
25
+ "@trainheroic-unofficial/js": "1.7.2"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.0.1",