@trainheroic-unofficial/js 1.7.1 → 1.7.3

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
@@ -301,6 +301,30 @@ declare function presentCoachAthleteTraining(raw: readonly unknown[], athleteId:
301
301
  /** Flatten `/v5/exercises/{id}/history` into PRs + a session time-series. */
302
302
  declare function presentExerciseHistory(detail: ExerciseHistoryDetail): PresentedExerciseHistory;
303
303
  //#endregion
304
+ //#region src/exercise-set-payload.d.ts
305
+ type SetWriteMode = "log" | "prescribe";
306
+ type ExerciseSetInput = {
307
+ param1?: number | string;
308
+ param2?: number | string;
309
+ slot?: number;
310
+ };
311
+ type ExerciseSetPayload = Record<string, unknown> & {
312
+ id: number;
313
+ saved_workout_set_id: number;
314
+ workout_set_exercise_id: number;
315
+ completed: 0 | 1;
316
+ };
317
+ /**
318
+ * Build the typed body for `PUT /1.0/{role}/savedworkoutsetexercise/{id}`.
319
+ *
320
+ * A log marks only slots carrying reps as performed. The exercise completes only when every active
321
+ * slot is performed; active slots are prescribed values, prior performed values, or slots targeted
322
+ * by this write. Untargeted performed slots carry over, while untouched prescription values are
323
+ * blanked so TrainHeroic cannot fabricate performed results from them. A prescription replaces the
324
+ * full payload and never marks slots or the exercise complete.
325
+ */
326
+ declare function buildExerciseSetPayload(savedWorkoutSetExerciseId: number, savedWorkoutSetId: number, workoutSetExerciseId: number, results: readonly ExerciseSetInput[], mode: SetWriteMode, existing?: Record<string, unknown>): ExerciseSetPayload;
327
+ //#endregion
304
328
  //#region src/athlete-set-write.d.ts
305
329
  /**
306
330
  * One set of entered values for a single exercise within a saved workout set.
@@ -316,12 +340,6 @@ type SetResult = {
316
340
  slot?: number;
317
341
  }>;
318
342
  };
319
- /**
320
- * Which write a set-write is: `"log"` records a performed result (and marks the set done),
321
- * `"prescribe"` sets prescribed targets without marking it done. Threaded through
322
- * {@link buildExerciseSetPayload} and the set-write helper so the two contracts share one path.
323
- */
324
- type SetWriteMode = "log" | "prescribe";
325
343
  /**
326
344
  * Coerce the loosely-typed `results` from a validated log/prescribe args object into the SDK's
327
345
  * {@link SetResult}[]. The dto schemas validate ids as a number or a numeric string and leave
@@ -337,38 +355,6 @@ declare function toSetResults(results: ReadonlyArray<{
337
355
  slot?: number | undefined;
338
356
  }>;
339
357
  }>): SetResult[];
340
- /**
341
- * Build the body for `PUT /1.0/{role}/savedworkoutsetexercise/{id}`. The body uses snake_case
342
- * keys matching the live API response shape. Each set slot (1-10) carries `param_1_data_N` /
343
- * `param_2_data_N` string values plus a `param_N_made` flag.
344
- *
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.
348
- * - `"prescribe"`: the values are prescribed targets, written with every `param_N_made` and
349
- * `completed` left at 0 so the set is not marked done. This matches what the app sends when a
350
- * coach edits an athlete's prescribed reps/weight.
351
- *
352
- * Each set fills a 1-based slot: its explicit `slot`, or its sequential position in `results`
353
- * when `slot` is omitted. A `log` carrying the live exercise record in `existing` keeps the slots
354
- * it does not write that were ALREADY performed (`param_N_made === 1`), so logging a second part of
355
- * a set does not wipe the earlier-logged sets. A slot holding only un-logged prescription pre-fill
356
- * (`param_N_made === 0`) is left blank rather than carried over: marking the set completed makes
357
- * the server flag every data-bearing slot performed, so preserving that pre-fill would fabricate
358
- * sets the athlete never did. The prescription is unaffected (it lives in the separate `workout`
359
- * copy, not this saved copy). A `prescribe` ignores `existing` and replaces the whole prescription.
360
- *
361
- * Only `savedWorkoutSetExerciseId`, `savedWorkoutSetId`, and `workoutSetExerciseId` are
362
- * required from the live exercise record; everything else is derived from `results` and the
363
- * preserved slots of `existing`.
364
- *
365
- * Exported for unit testing — callers should use `logAthleteSet` / `prescribeForAthlete` instead.
366
- */
367
- declare function buildExerciseSetPayload(savedWorkoutSetExerciseId: number, savedWorkoutSetId: number, workoutSetExerciseId: number, results: readonly {
368
- param1?: number | string;
369
- param2?: number | string;
370
- slot?: number;
371
- }[], mode: SetWriteMode, existing?: Record<string, unknown>): Record<string, unknown>;
372
358
  /**
373
359
  * Locate the target saved workout set across all program workouts on the given day.
374
360
  * Returns the `savedWorkoutId`, the matching set's `workoutSetExercises` array so callers
@@ -892,4 +878,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
892
878
  stats(): Promise<Record<string, unknown>>;
893
879
  }
894
880
  //#endregion
895
- export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BuildOptions, ClientResult, CoachRosterAthlete, DEFAULT_INVITE_MESSAGE, ExerciseIndex, ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, LogSessionResult, LogSetTarget, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MainLiftFamily, MainLiftFamilyKey, MainLiftPR, MainLiftResolution, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PersonalWorkoutCreated, RequestOptions, ResolvedLift, ScheduledAlternative, SerializedExport, SessionExercise, SetResult, SetWriteMode, SwapExerciseResult, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicSession, WorkoutExportFormat, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, definedProps, deleteComment, exerciseTitle, exerciseUnits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
881
+ export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BuildOptions, ClientResult, CoachRosterAthlete, DEFAULT_INVITE_MESSAGE, ExerciseIndex, ExerciseLibrary, type ExerciseSetInput, type ExerciseSetPayload, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, LogSessionResult, LogSetTarget, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MainLiftFamily, MainLiftFamilyKey, MainLiftPR, MainLiftResolution, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PersonalWorkoutCreated, RequestOptions, ResolvedLift, ScheduledAlternative, SerializedExport, SessionExercise, SetResult, type SetWriteMode, SwapExerciseResult, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicSession, WorkoutExportFormat, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, definedProps, deleteComment, exerciseTitle, exerciseUnits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
package/dist/index.mjs CHANGED
@@ -993,6 +993,75 @@ function presentExerciseHistory(detail) {
993
993
  };
994
994
  }
995
995
  //#endregion
996
+ //#region src/exercise-set-payload.ts
997
+ function slotData(exercise, key) {
998
+ const value = exercise?.[key];
999
+ return value === void 0 || value === null ? "" : String(value);
1000
+ }
1001
+ function slotIsActive(exercise, slot, targeted = false) {
1002
+ return targeted || slotData(exercise, `param_1_data_${slot}`) !== "" || slotData(exercise, `param_2_data_${slot}`) !== "" || coerceInt(exercise?.[`param_${slot}_made`]) === 1;
1003
+ }
1004
+ /** True when an existing saved-copy exercise has at least one active slot and all are performed. */
1005
+ function exerciseIsFullyLogged(exercise) {
1006
+ let anyActive = false;
1007
+ for (let slot = 1; slot <= 10; slot += 1) {
1008
+ if (!slotIsActive(exercise, slot)) continue;
1009
+ anyActive = true;
1010
+ if (coerceInt(exercise[`param_${slot}_made`]) !== 1) return false;
1011
+ }
1012
+ return anyActive;
1013
+ }
1014
+ /**
1015
+ * Build the typed body for `PUT /1.0/{role}/savedworkoutsetexercise/{id}`.
1016
+ *
1017
+ * A log marks only slots carrying reps as performed. The exercise completes only when every active
1018
+ * slot is performed; active slots are prescribed values, prior performed values, or slots targeted
1019
+ * by this write. Untargeted performed slots carry over, while untouched prescription values are
1020
+ * blanked so TrainHeroic cannot fabricate performed results from them. A prescription replaces the
1021
+ * full payload and never marks slots or the exercise complete.
1022
+ */
1023
+ function buildExerciseSetPayload(savedWorkoutSetExerciseId, savedWorkoutSetId, workoutSetExerciseId, results, mode, existing) {
1024
+ if (results.length > 10) throw new Error(`At most 10 sets are supported per exercise; got ${results.length}.`);
1025
+ const bySlot = /* @__PURE__ */ new Map();
1026
+ results.forEach((set, index) => {
1027
+ const slot = set.slot ?? index + 1;
1028
+ if (slot < 1 || slot > 10) throw new Error(`Set slot ${slot} is out of range; slots are 1–10.`);
1029
+ if (bySlot.has(slot)) throw new Error(`Two sets target slot ${slot}; each slot can be written once.`);
1030
+ bySlot.set(slot, set);
1031
+ });
1032
+ const logging = mode === "log";
1033
+ const body = {
1034
+ id: savedWorkoutSetExerciseId,
1035
+ saved_workout_set_id: savedWorkoutSetId,
1036
+ workout_set_exercise_id: workoutSetExerciseId,
1037
+ completed: 0
1038
+ };
1039
+ let anyMade = false;
1040
+ let allActiveSlotsMade = true;
1041
+ for (let slot = 1; slot <= 10; slot += 1) {
1042
+ const target = bySlot.get(slot);
1043
+ let param1 = "";
1044
+ let param2 = "";
1045
+ let made = 0;
1046
+ if (target) {
1047
+ param1 = target.param1 === void 0 ? "" : String(target.param1);
1048
+ param2 = target.param2 === void 0 ? "" : String(target.param2);
1049
+ made = logging && param1 !== "" ? 1 : 0;
1050
+ } else if (logging && coerceInt(existing?.[`param_${slot}_made`]) === 1) {
1051
+ param1 = slotData(existing, `param_1_data_${slot}`);
1052
+ param2 = slotData(existing, `param_2_data_${slot}`);
1053
+ made = 1;
1054
+ }
1055
+ anyMade ||= made === 1;
1056
+ if (slotIsActive(existing, slot, target !== void 0) && made !== 1) allActiveSlotsMade = false;
1057
+ body[`param_${slot}_made`] = made;
1058
+ body[`param_1_data_${slot}`] = param1;
1059
+ body[`param_2_data_${slot}`] = param2;
1060
+ }
1061
+ body.completed = logging && anyMade && allActiveSlotsMade ? 1 : 0;
1062
+ return body;
1063
+ }
1064
+ //#endregion
996
1065
  //#region src/athlete-set-write.ts
997
1066
  /**
998
1067
  * Coerce the loosely-typed `results` from a validated log/prescribe args object into the SDK's
@@ -1018,102 +1087,25 @@ function toSetResults(results) {
1018
1087
  });
1019
1088
  }
1020
1089
  /**
1021
- * Build the body for `PUT /1.0/{role}/savedworkoutsetexercise/{id}`. The body uses snake_case
1022
- * keys matching the live API response shape. Each set slot (1-10) carries `param_1_data_N` /
1023
- * `param_2_data_N` string values plus a `param_N_made` flag.
1024
- *
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.
1028
- * - `"prescribe"`: the values are prescribed targets, written with every `param_N_made` and
1029
- * `completed` left at 0 so the set is not marked done. This matches what the app sends when a
1030
- * coach edits an athlete's prescribed reps/weight.
1031
- *
1032
- * Each set fills a 1-based slot: its explicit `slot`, or its sequential position in `results`
1033
- * when `slot` is omitted. A `log` carrying the live exercise record in `existing` keeps the slots
1034
- * it does not write that were ALREADY performed (`param_N_made === 1`), so logging a second part of
1035
- * a set does not wipe the earlier-logged sets. A slot holding only un-logged prescription pre-fill
1036
- * (`param_N_made === 0`) is left blank rather than carried over: marking the set completed makes
1037
- * the server flag every data-bearing slot performed, so preserving that pre-fill would fabricate
1038
- * sets the athlete never did. The prescription is unaffected (it lives in the separate `workout`
1039
- * copy, not this saved copy). A `prescribe` ignores `existing` and replaces the whole prescription.
1040
- *
1041
- * Only `savedWorkoutSetExerciseId`, `savedWorkoutSetId`, and `workoutSetExerciseId` are
1042
- * required from the live exercise record; everything else is derived from `results` and the
1043
- * preserved slots of `existing`.
1044
- *
1045
- * Exported for unit testing — callers should use `logAthleteSet` / `prescribeForAthlete` instead.
1046
- */
1047
- function buildExerciseSetPayload(savedWorkoutSetExerciseId, savedWorkoutSetId, workoutSetExerciseId, results, mode, existing) {
1048
- if (results.length > 10) throw new Error(`At most 10 sets are supported per exercise; got ${results.length}.`);
1049
- const bySlot = /* @__PURE__ */ new Map();
1050
- results.forEach((set, i) => {
1051
- const slot = set.slot ?? i + 1;
1052
- if (slot < 1 || slot > 10) throw new Error(`Set slot ${slot} is out of range; slots are 1–10.`);
1053
- if (bySlot.has(slot)) throw new Error(`Two sets target slot ${slot}; each slot can be written once.`);
1054
- bySlot.set(slot, set);
1055
- });
1056
- const performed = mode === "log";
1057
- const carryOver = performed && existing !== void 0;
1058
- const body = {
1059
- id: savedWorkoutSetExerciseId,
1060
- saved_workout_set_id: savedWorkoutSetId,
1061
- workout_set_exercise_id: workoutSetExerciseId
1062
- };
1063
- let anyMade = false;
1064
- for (let i = 1; i <= 10; i += 1) {
1065
- const target = bySlot.get(i);
1066
- let p1;
1067
- let p2;
1068
- let made;
1069
- if (target) {
1070
- p1 = target.param1 !== void 0 ? String(target.param1) : "";
1071
- p2 = target.param2 !== void 0 ? String(target.param2) : "";
1072
- made = performed && (p1 !== "" || p2 !== "") ? 1 : 0;
1073
- } else if (carryOver && coerceInt(existing?.[`param_${i}_made`]) === 1) {
1074
- p1 = existingSlotData(existing, `param_1_data_${i}`);
1075
- p2 = existingSlotData(existing, `param_2_data_${i}`);
1076
- made = 1;
1077
- } else {
1078
- p1 = "";
1079
- p2 = "";
1080
- made = 0;
1081
- }
1082
- if (made === 1) anyMade = true;
1083
- body[`param_${i}_made`] = made;
1084
- body[`param_1_data_${i}`] = p1;
1085
- body[`param_2_data_${i}`] = p2;
1086
- }
1087
- body.completed = performed && anyMade ? 1 : 0;
1088
- return body;
1089
- }
1090
- /** Read a saved-copy slot value (`param_1_data_N` / `param_2_data_N`) as the string the body uses. */
1091
- function existingSlotData(existing, key) {
1092
- const v = existing?.[key];
1093
- return v === void 0 || v === null ? "" : String(v);
1094
- }
1095
- /** True when a saved-copy exercise already carries a performed slot (any `param_N_made` === 1). */
1096
- function exerciseHasLoggedData(ex) {
1097
- for (let i = 1; i <= 10; i += 1) if (coerceInt(ex[`param_${i}_made`]) === 1) return true;
1098
- return false;
1099
- }
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) !== "");
1103
- }
1104
- /**
1105
- * Whether every exercise in a saved workout set now has logged data — either written with data in
1106
- * this call (`loggedIds`) or already carrying a performed slot. Gates the set-completion PUT: a
1107
- * 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.
1090
+ * Whether every exercise in a saved workout set is fully logged — either completed by its projected
1091
+ * payload in this call (`projectedCompletion`) or already carrying made flags for every active slot.
1092
+ * This gates the set-completion PUT so a partial exercise cannot close a superset/circuit and cause
1093
+ * TrainHeroic to backfill its omitted slots or untouched siblings.
1110
1094
  */
1111
- function isSetFullyLogged(exercises, loggedIds) {
1095
+ function isSetFullyLogged(exercises, projectedCompletion) {
1112
1096
  return exercises.every((ex) => {
1113
1097
  const id = coerceInt(ex.id);
1114
- return id !== null && loggedIds.has(id) || exerciseHasLoggedData(ex);
1098
+ if (id !== null && projectedCompletion.has(id)) return projectedCompletion.get(id) === true;
1099
+ return exerciseIsFullyLogged(ex);
1115
1100
  });
1116
1101
  }
1102
+ function assertUniqueExerciseResults(results) {
1103
+ const seen = /* @__PURE__ */ new Set();
1104
+ for (const result of results) {
1105
+ if (seen.has(result.savedWorkoutSetExerciseId)) throw new Error(`savedWorkoutSetExerciseId ${result.savedWorkoutSetExerciseId} appears more than once; combine its sets into one result.`);
1106
+ seen.add(result.savedWorkoutSetExerciseId);
1107
+ }
1108
+ }
1117
1109
  /**
1118
1110
  * Locate the target saved workout set across all program workouts on the given day.
1119
1111
  * Returns the `savedWorkoutId`, the matching set's `workoutSetExercises` array so callers
@@ -1313,9 +1305,11 @@ async function swapAthleteExercise(client, args) {
1313
1305
  */
1314
1306
  async function writeSetResults(client, target, workouts, savedWorkoutSetId, results, mode) {
1315
1307
  const { exercises, rawSet } = findSavedWorkoutSet(workouts, savedWorkoutSetId);
1308
+ assertUniqueExerciseResults(results);
1316
1309
  const suffix = target.role === "coach" ? `/${target.athleteId}` : "";
1317
1310
  const extra = target.role === "coach" ? { athleteId: target.athleteId } : {};
1318
1311
  let exercisesWritten = 0;
1312
+ const projectedCompletion = /* @__PURE__ */ new Map();
1319
1313
  for (const result of results) {
1320
1314
  const ex = exercises.find((e) => coerceInt(e.id) === result.savedWorkoutSetExerciseId);
1321
1315
  if (!ex) {
@@ -1336,11 +1330,12 @@ async function writeSetResults(client, target, workouts, savedWorkoutSetId, resu
1336
1330
  const readOnly = target.role === "coach" && (res.status === 401 || res.status === 403) ? ` Athlete ${target.athleteId} appears to be read-only for changes — TrainHeroic's seeded demo/sample athletes return ${res.status} here; writes only persist for real (invited) athletes.` : "";
1337
1331
  throw new Error(`Failed to write exercise ${result.savedWorkoutSetExerciseId} (HTTP ${res.status}).${readOnly}`);
1338
1332
  }
1333
+ projectedCompletion.set(result.savedWorkoutSetExerciseId, body.completed === 1);
1339
1334
  exercisesWritten += 1;
1340
1335
  }
1341
1336
  let setCompleted = false;
1342
1337
  if (mode === "log") {
1343
- if (isSetFullyLogged(exercises, new Set(results.filter(resultHasData).map((r) => r.savedWorkoutSetExerciseId)))) {
1338
+ if (isSetFullyLogged(exercises, projectedCompletion)) {
1344
1339
  const setBody = {
1345
1340
  ...buildSetCompletePayload(rawSet, exercises.map((e) => coerceInt(e.id)).filter((n) => n !== null), true),
1346
1341
  ...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.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,12 +27,12 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "zod": "^4.4.3",
30
- "@trainheroic-unofficial/dto": "1.7.1"
30
+ "@trainheroic-unofficial/dto": "1.7.3"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^26.0.1",
33
+ "@types/node": "^26.1.0",
34
34
  "tsdown": "^0.22.3",
35
- "vitest": "^4.1.9"
35
+ "vitest": "^4.1.10"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsdown",