@trainheroic-unofficial/js 3.3.3 → 3.4.0
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 +26 -2
- package/dist/index.mjs +75 -27
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as LibrarySnapshot, r as MemoryLibraryCache, t as LibraryCache } from "./library-cache-CDABOdIN.mjs";
|
|
2
|
-
import { Advisory, AthletePrefs, AthleteProfileSummary, AthleteUser, AthleteWorkingMax, AthleteWorkoutSummary, AthleteWorkoutView, BlockSpec, CoachAthleteTraining, ExerciseHistoryDetail, ExerciseHistoryListItem, ExerciseRow, ExerciseSpec, ExerciseStats, ExerciseView, PersonalRecord, PresentedExerciseHistory, ProgramWorkout, ReadResult, ResolveResult, RosterActivityRow, SessionTemplateCreate, TeamPublishPatch, TeamVolumeReport, WorkoutDate, WorkoutHistoryExport } from "@trainheroic-unofficial/dto";
|
|
2
|
+
import { Advisory, AthletePrefs, AthleteProfileSummary, AthleteUser, AthleteWorkingMax, AthleteWorkoutNoteOutput, AthleteWorkoutSummary, AthleteWorkoutView, BlockSpec, CoachAthleteTraining, ExerciseHistoryDetail, ExerciseHistoryListItem, ExerciseRow, ExerciseSpec, ExerciseStats, ExerciseView, PersonalRecord, PresentedExerciseHistory, ProgramWorkout, ReadResult, ResolveResult, RosterActivityRow, SessionTemplateCreate, TeamPublishPatch, TeamVolumeReport, WorkoutDate, WorkoutHistoryExport } from "@trainheroic-unofficial/dto";
|
|
3
3
|
import { ZodType } from "zod";
|
|
4
4
|
export * from "@trainheroic-unofficial/dto";
|
|
5
5
|
//#region src/http-error.d.ts
|
|
@@ -146,6 +146,11 @@ declare function exerciseTitle(ex: Record<string, unknown>, fallback?: string):
|
|
|
146
146
|
* definition every consumer (presenter, find-or-create, the remove guard) reads through.
|
|
147
147
|
*/
|
|
148
148
|
declare function isPersonalSession(pw: unknown): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
|
|
151
|
+
* copy yet. Session notes, RPE, and set writes all resolve through this.
|
|
152
|
+
*/
|
|
153
|
+
declare function savedWorkoutOf(pw: unknown): Record<string, unknown> | null;
|
|
149
154
|
/**
|
|
150
155
|
* Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
|
|
151
156
|
* exact title, then prefix, then count of matched tokens, with shorter titles and
|
|
@@ -224,6 +229,11 @@ declare function fetchPersonalRecords(client: TrainHeroicClient, exerciseId: num
|
|
|
224
229
|
declare function fetchExerciseStats(client: TrainHeroicClient, exerciseId: number, userId: number, date: string): Promise<ExerciseStats>;
|
|
225
230
|
/** Scheduled + completed workouts in an inclusive YYYY-MM-DD window. */
|
|
226
231
|
declare function fetchAthleteWorkouts(client: TrainHeroicClient, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
|
|
232
|
+
/**
|
|
233
|
+
* The program-workout row with this id on this date. Throws if that id is not on the day's range;
|
|
234
|
+
* callers should take the id from `athlete_workouts`.
|
|
235
|
+
*/
|
|
236
|
+
declare function programWorkoutOnDate(client: TrainHeroicClient, date: string, programWorkoutId: number): Promise<ProgramWorkout>;
|
|
227
237
|
/** Split an inclusive `[start, end]` range into consecutive non-overlapping windows of `windowDays`. */
|
|
228
238
|
declare function dateWindows(startDate: string, endDate: string, windowDays: number): Array<{
|
|
229
239
|
start: string;
|
|
@@ -681,6 +691,20 @@ declare function logSessionForAthlete(client: TrainHeroicClient, args: {
|
|
|
681
691
|
exercises: readonly SessionExercise[];
|
|
682
692
|
}): Promise<LogSessionResult>;
|
|
683
693
|
//#endregion
|
|
694
|
+
//#region src/athlete-workout-note.d.ts
|
|
695
|
+
/**
|
|
696
|
+
* PUT /1.0/athlete/savedworkout/{id} — set the athlete's session note (the free-text box on the
|
|
697
|
+
* workout screen) and/or session RPE. The date + programWorkoutId (`athlete_workouts` `id`) locate
|
|
698
|
+
* the saved workout; GET on that path 405s, so the range read is the lookup. A notes-only body
|
|
699
|
+
* leaves rpe untouched and vice versa. Empty `notes` clears the note. Coach-visible.
|
|
700
|
+
*/
|
|
701
|
+
declare function setAthleteWorkoutNote(client: TrainHeroicClient, args: {
|
|
702
|
+
date: string;
|
|
703
|
+
programWorkoutId: number | string;
|
|
704
|
+
notes?: string | undefined;
|
|
705
|
+
rpe?: number | undefined;
|
|
706
|
+
}): Promise<AthleteWorkoutNoteOutput>;
|
|
707
|
+
//#endregion
|
|
684
708
|
//#region src/workout-export.d.ts
|
|
685
709
|
type WorkoutExportFormat = "json" | "csv" | "text";
|
|
686
710
|
/** A serialized export ready to write to a file or hand to a browser download. */
|
|
@@ -1070,4 +1094,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
|
|
|
1070
1094
|
stats(): Promise<Record<string, unknown>>;
|
|
1071
1095
|
}
|
|
1072
1096
|
//#endregion
|
|
1073
|
-
export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, BuildOptions, ClientOptions, ClientResult, CoachAthleteCalendar, CoachRosterAthlete, CreatedProgram, DEFAULT_INVITE_MESSAGE, DeletedProgram, ExerciseDefaults, ExerciseIndex, ExerciseLibrary, type ExerciseSetInput, type ExerciseSetPayload, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, LogSessionResult, LogSetTarget, LoginOptions, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MainLiftFamily, MainLiftFamilyKey, MainLiftPR, MainLiftResolution, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PROGRAM_KINDS, PersonalWorkoutCreated, ProgramKind, RequestOptions, ResolvedLift, SESSION_TEMPLATES_LIST_PATH, ScheduledAlternative, SerializedExport, SessionExercise, SetResult, type SetWriteMode, SwapExerciseResult, TeamPublishTarget, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicHttpError, type TrainHeroicHttpErrorHandler, TrainHeroicSession, WorkoutExportFormat, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, createProgram, createSessionTemplate, dateWindows, defaultBlockType, definedProps, deleteComment, deleteProgram, exerciseTitle, exerciseUnits, fetchAthleteCircuits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteProgrammingPrograms, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRecentExercises, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeAthleteSet, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveBuildProgramId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamPublishTarget, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, updateTeamPublishSettings, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
|
|
1097
|
+
export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, BuildOptions, ClientOptions, ClientResult, CoachAthleteCalendar, CoachRosterAthlete, CreatedProgram, DEFAULT_INVITE_MESSAGE, DeletedProgram, ExerciseDefaults, ExerciseIndex, ExerciseLibrary, type ExerciseSetInput, type ExerciseSetPayload, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, LogSessionResult, LogSetTarget, LoginOptions, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MainLiftFamily, MainLiftFamilyKey, MainLiftPR, MainLiftResolution, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PROGRAM_KINDS, PersonalWorkoutCreated, ProgramKind, RequestOptions, ResolvedLift, SESSION_TEMPLATES_LIST_PATH, ScheduledAlternative, SerializedExport, SessionExercise, SetResult, type SetWriteMode, SwapExerciseResult, TeamPublishTarget, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicHttpError, type TrainHeroicHttpErrorHandler, TrainHeroicSession, WorkoutExportFormat, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, createProgram, createSessionTemplate, dateWindows, defaultBlockType, definedProps, deleteComment, deleteProgram, exerciseTitle, exerciseUnits, fetchAthleteCircuits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteProgrammingPrograms, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRecentExercises, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeAthleteSet, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, programWorkoutOnDate, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveBuildProgramId, resolveLeaderboard, savedWorkoutOf, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setAthleteWorkoutNote, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamPublishTarget, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, updateTeamPublishSettings, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
|
package/dist/index.mjs
CHANGED
|
@@ -340,6 +340,15 @@ function isPersonalSession(pw) {
|
|
|
340
340
|
return isRecord(pw) && pw.personal_cal === true;
|
|
341
341
|
}
|
|
342
342
|
/**
|
|
343
|
+
* The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
|
|
344
|
+
* copy yet. Session notes, RPE, and set writes all resolve through this.
|
|
345
|
+
*/
|
|
346
|
+
function savedWorkoutOf(pw) {
|
|
347
|
+
if (!isRecord(pw)) return null;
|
|
348
|
+
const ssw = isRecord(pw.summarizedSavedWorkout) ? pw.summarizedSavedWorkout : {};
|
|
349
|
+
return isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
343
352
|
* Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
|
|
344
353
|
* exact title, then prefix, then count of matched tokens, with shorter titles and
|
|
345
354
|
* standard (non-custom) exercises preferred on ties.
|
|
@@ -507,6 +516,15 @@ function fetchExerciseStats(client, exerciseId, userId, date) {
|
|
|
507
516
|
function fetchAthleteWorkouts(client, startDate, endDate) {
|
|
508
517
|
return getArray$1(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
|
|
509
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* The program-workout row with this id on this date. Throws if that id is not on the day's range;
|
|
521
|
+
* callers should take the id from `athlete_workouts`.
|
|
522
|
+
*/
|
|
523
|
+
async function programWorkoutOnDate(client, date, programWorkoutId) {
|
|
524
|
+
const target = (await fetchAthleteWorkouts(client, date, date)).find((pw) => coerceInt(pw.id) === programWorkoutId);
|
|
525
|
+
if (target === void 0) throw new Error(`No workout with id ${programWorkoutId} on ${date}. Get the id and date from athlete_workouts.`);
|
|
526
|
+
return target;
|
|
527
|
+
}
|
|
510
528
|
/** Add `days` to a `YYYY-MM-DD` date (UTC), returning `YYYY-MM-DD`. */
|
|
511
529
|
function shiftDate(iso, days) {
|
|
512
530
|
const d = /* @__PURE__ */ new Date(`${iso}T00:00:00Z`);
|
|
@@ -702,7 +720,7 @@ function mergeAthleteWorkout(raw) {
|
|
|
702
720
|
const rec = raw;
|
|
703
721
|
const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
|
|
704
722
|
const workout = isRecord(ssw.workout) ? ssw.workout : {};
|
|
705
|
-
const saved =
|
|
723
|
+
const saved = savedWorkoutOf(rec) ?? {};
|
|
706
724
|
const prescriptionSets = (Array.isArray(workout.workoutSets) ? workout.workoutSets : []).filter(isRecord);
|
|
707
725
|
const logged = savedSets(saved);
|
|
708
726
|
const performedById = performedSlotsByExerciseId(logged);
|
|
@@ -731,6 +749,8 @@ function mergeAthleteWorkout(raw) {
|
|
|
731
749
|
program: str(rec.program_title),
|
|
732
750
|
team: str(rec.team_title),
|
|
733
751
|
instruction: str(workout.instruction),
|
|
752
|
+
notes: str(saved.notes),
|
|
753
|
+
rpe: coerceInt(saved.rpe),
|
|
734
754
|
logged: blocks.some((b) => b.exercises.some((e) => e.sets.some((s) => s.performed !== null))),
|
|
735
755
|
personal: isPersonalSession(rec),
|
|
736
756
|
blocks
|
|
@@ -778,6 +798,8 @@ function presentAthleteWorkout(raw) {
|
|
|
778
798
|
program: w.program,
|
|
779
799
|
team: w.team,
|
|
780
800
|
instruction: w.instruction,
|
|
801
|
+
notes: w.notes,
|
|
802
|
+
rpe: w.rpe,
|
|
781
803
|
logged: w.logged,
|
|
782
804
|
personal: w.personal,
|
|
783
805
|
blocks: w.blocks.map(toStringBlock)
|
|
@@ -997,7 +1019,7 @@ function presentCoachAthleteTraining(raw, athleteId, year, month) {
|
|
|
997
1019
|
completed: coerceInt(item.completed) === 1,
|
|
998
1020
|
rpe: coerceInt(item.rpe),
|
|
999
1021
|
durationMin: coerceInt(item.session_duration),
|
|
1000
|
-
notes:
|
|
1022
|
+
notes: str(item.notes),
|
|
1001
1023
|
exercises
|
|
1002
1024
|
});
|
|
1003
1025
|
}
|
|
@@ -1217,9 +1239,7 @@ function assertUniqueExerciseResults(results) {
|
|
|
1217
1239
|
function findSavedWorkoutSet(workouts, savedWorkoutSetId) {
|
|
1218
1240
|
const available = [];
|
|
1219
1241
|
for (const pw of workouts) {
|
|
1220
|
-
const
|
|
1221
|
-
const ssw = isRecord(rec.summarizedSavedWorkout) ? rec.summarizedSavedWorkout : {};
|
|
1222
|
-
const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
|
|
1242
|
+
const sw = savedWorkoutOf(pw);
|
|
1223
1243
|
if (!sw) continue;
|
|
1224
1244
|
const sets = Array.isArray(sw.workoutSets) ? sw.workoutSets : [];
|
|
1225
1245
|
for (const s of sets) {
|
|
@@ -1517,9 +1537,7 @@ async function addExercisesToWorkout(client, workoutId, exercises) {
|
|
|
1517
1537
|
* Throws on a non-ok response.
|
|
1518
1538
|
*/
|
|
1519
1539
|
async function removePersonalWorkout(client, args) {
|
|
1520
|
-
|
|
1521
|
-
if (target === void 0) throw new Error(`No workout with id ${args.programWorkoutId} on ${args.date}. Get the id and date from athlete_workouts.`);
|
|
1522
|
-
if (!isPersonalSession(target)) throw new Error(`Workout ${args.programWorkoutId} on ${args.date} is a coach-scheduled workout, not a personal session, so it can't be removed. To change logged results on a scheduled workout, use athlete_log_set.`);
|
|
1540
|
+
if (!isPersonalSession(await programWorkoutOnDate(client, args.date, args.programWorkoutId))) throw new Error(`Workout ${args.programWorkoutId} on ${args.date} is a coach-scheduled workout, not a personal session, so it can't be removed. To change logged results on a scheduled workout, use athlete_log_set.`);
|
|
1523
1541
|
const res = await client.request("DELETE", `/v5/programWorkouts/${args.programWorkoutId}`);
|
|
1524
1542
|
if (!res.ok) throw new Error(`Remove personal workout failed (HTTP ${res.status}).`);
|
|
1525
1543
|
}
|
|
@@ -1572,8 +1590,7 @@ function eachPrescribedExercise(workouts) {
|
|
|
1572
1590
|
const rows = [];
|
|
1573
1591
|
for (const pw of workouts) {
|
|
1574
1592
|
const rec = pw;
|
|
1575
|
-
const
|
|
1576
|
-
const sw = isRecord(ssw.saved_workout) ? ssw.saved_workout : null;
|
|
1593
|
+
const sw = savedWorkoutOf(rec);
|
|
1577
1594
|
if (!sw) continue;
|
|
1578
1595
|
const sets = [...Array.isArray(sw.workoutSets) ? sw.workoutSets : [], ...Array.isArray(sw.addedWorkoutSets) ? sw.addedWorkoutSets : []];
|
|
1579
1596
|
for (const s of sets) {
|
|
@@ -1743,6 +1760,53 @@ async function logSessionForAthlete(client, args) {
|
|
|
1743
1760
|
};
|
|
1744
1761
|
}
|
|
1745
1762
|
//#endregion
|
|
1763
|
+
//#region src/util.ts
|
|
1764
|
+
/**
|
|
1765
|
+
* Drop the keys whose value is `undefined`, so the result can be passed to a function or
|
|
1766
|
+
* spread into an object under `exactOptionalPropertyTypes` without the per-key
|
|
1767
|
+
* `...(x !== undefined ? { x } : {})` dance. Required keys stay required in the result type;
|
|
1768
|
+
* optional ones lose `undefined` from their value type.
|
|
1769
|
+
*
|
|
1770
|
+
* Example:
|
|
1771
|
+
* definedProps({ metric, teamId: maybeId, date }) // omits teamId/date if they're undefined
|
|
1772
|
+
*/
|
|
1773
|
+
function definedProps(obj) {
|
|
1774
|
+
const result = {};
|
|
1775
|
+
for (const [key, value] of Object.entries(obj)) if (value !== void 0) result[key] = value;
|
|
1776
|
+
return result;
|
|
1777
|
+
}
|
|
1778
|
+
//#endregion
|
|
1779
|
+
//#region src/athlete-workout-note.ts
|
|
1780
|
+
/**
|
|
1781
|
+
* PUT /1.0/athlete/savedworkout/{id} — set the athlete's session note (the free-text box on the
|
|
1782
|
+
* workout screen) and/or session RPE. The date + programWorkoutId (`athlete_workouts` `id`) locate
|
|
1783
|
+
* the saved workout; GET on that path 405s, so the range read is the lookup. A notes-only body
|
|
1784
|
+
* leaves rpe untouched and vice versa. Empty `notes` clears the note. Coach-visible.
|
|
1785
|
+
*/
|
|
1786
|
+
async function setAthleteWorkoutNote(client, args) {
|
|
1787
|
+
if (args.notes === void 0 && args.rpe === void 0) throw new Error("Provide notes and/or rpe.");
|
|
1788
|
+
const programWorkoutId = coerceInt(args.programWorkoutId);
|
|
1789
|
+
if (programWorkoutId === null) throw new Error(`Invalid programWorkoutId ${String(args.programWorkoutId)}.`);
|
|
1790
|
+
const saved = savedWorkoutOf(await programWorkoutOnDate(client, args.date, programWorkoutId));
|
|
1791
|
+
const savedWorkoutId = saved !== null ? coerceInt(saved.id) : null;
|
|
1792
|
+
if (savedWorkoutId === null) throw new Error(`Workout ${programWorkoutId} on ${args.date} has no saved workout to attach a note to.`);
|
|
1793
|
+
const body = definedProps({
|
|
1794
|
+
id: savedWorkoutId,
|
|
1795
|
+
notes: args.notes,
|
|
1796
|
+
rpe: args.rpe
|
|
1797
|
+
});
|
|
1798
|
+
const res = await client.request("PUT", `/1.0/athlete/savedworkout/${savedWorkoutId}`, { body });
|
|
1799
|
+
if (!res.ok) throw new Error(`Set workout note failed (HTTP ${res.status}).`);
|
|
1800
|
+
const data = isRecord(res.data) ? res.data : {};
|
|
1801
|
+
return {
|
|
1802
|
+
programWorkoutId,
|
|
1803
|
+
savedWorkoutId,
|
|
1804
|
+
date: args.date,
|
|
1805
|
+
notes: typeof data.notes === "string" ? data.notes : args.notes ?? "",
|
|
1806
|
+
rpe: coerceInt(data.rpe) ?? (args.rpe !== void 0 ? args.rpe : null)
|
|
1807
|
+
};
|
|
1808
|
+
}
|
|
1809
|
+
//#endregion
|
|
1746
1810
|
//#region src/workout-export.ts
|
|
1747
1811
|
const DEFAULT_FILENAME_BASE = "trainheroic-workout-history";
|
|
1748
1812
|
/** Pretty-printed JSON of the structured workouts, exactly as `presentAthleteWorkoutsExport` yields. */
|
|
@@ -1869,22 +1933,6 @@ function serializeWorkoutHistory(workouts, format, opts = {}) {
|
|
|
1869
1933
|
};
|
|
1870
1934
|
}
|
|
1871
1935
|
//#endregion
|
|
1872
|
-
//#region src/util.ts
|
|
1873
|
-
/**
|
|
1874
|
-
* Drop the keys whose value is `undefined`, so the result can be passed to a function or
|
|
1875
|
-
* spread into an object under `exactOptionalPropertyTypes` without the per-key
|
|
1876
|
-
* `...(x !== undefined ? { x } : {})` dance. Required keys stay required in the result type;
|
|
1877
|
-
* optional ones lose `undefined` from their value type.
|
|
1878
|
-
*
|
|
1879
|
-
* Example:
|
|
1880
|
-
* definedProps({ metric, teamId: maybeId, date }) // omits teamId/date if they're undefined
|
|
1881
|
-
*/
|
|
1882
|
-
function definedProps(obj) {
|
|
1883
|
-
const result = {};
|
|
1884
|
-
for (const [key, value] of Object.entries(obj)) if (value !== void 0) result[key] = value;
|
|
1885
|
-
return result;
|
|
1886
|
-
}
|
|
1887
|
-
//#endregion
|
|
1888
1936
|
//#region src/workout-encode.ts
|
|
1889
1937
|
const LEADERBOARD_TYPE = {
|
|
1890
1938
|
completion: 0,
|
|
@@ -3187,4 +3235,4 @@ var ExerciseLibrary = class {
|
|
|
3187
3235
|
}
|
|
3188
3236
|
};
|
|
3189
3237
|
//#endregion
|
|
3190
|
-
export { ANALYTICS_METRIC_KEYS, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, DEFAULT_INVITE_MESSAGE, ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PROGRAM_KINDS, SESSION_TEMPLATES_LIST_PATH, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicHttpError, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, createProgram, createSessionTemplate, dateWindows, defaultBlockType, definedProps, deleteComment, deleteProgram, exerciseTitle, exerciseUnits, fetchAthleteCircuits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteProgrammingPrograms, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRecentExercises, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeAthleteSet, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveBuildProgramId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamPublishTarget, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, updateTeamPublishSettings, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
|
|
3238
|
+
export { ANALYTICS_METRIC_KEYS, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, DEFAULT_INVITE_MESSAGE, ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, MAIN_LIFT_FAMILIES, MAX_PARAM_SLOTS, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PROGRAM_KINDS, SESSION_TEMPLATES_LIST_PATH, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicHttpError, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, createProgram, createSessionTemplate, dateWindows, defaultBlockType, definedProps, deleteComment, deleteProgram, exerciseTitle, exerciseUnits, fetchAthleteCircuits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteProgrammingPrograms, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, fetchCoachAthleteCalendarSummary, fetchCoachAthleteWorkouts, fetchCoachRoster, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchRecentExercises, fetchRosterActivity, fetchRosterMainLiftPRs, fetchStreams, fetchTeamAthleteIds, fetchWorkingMaxes, findSavedWorkoutSet, inviteAthletes, isPersonalSession, isRecord, logAdHocSession, logAthleteSet, logForAthlete, logSessionForAthlete, loginTrainHeroic, makeExercise, mapPool, mergeWorkoutsById, prescribeAthleteSet, prescribeForAthlete, presentAthleteWorkout, presentAthleteWorkoutExport, presentAthleteWorkouts, presentAthleteWorkoutsExport, presentCoachAthleteTraining, presentExercise, presentExerciseHistory, presentLogTargets, programWorkoutOnDate, publishSession, queryAnalytics, rankSearch, readLive, readSession, removePersonalWorkout, removeSession, repsList, resolveAthleteMainLifts, resolveAthleteUserId, resolveBuildProgramId, resolveLeaderboard, savedWorkoutOf, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setAthleteWorkoutNote, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamPublishTarget, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, updateTeamPublishSettings, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
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": "3.
|
|
30
|
+
"@trainheroic-unofficial/dto": "3.4.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "^26.
|
|
33
|
+
"@types/node": "^26.3.0",
|
|
34
34
|
"tsdown": "^0.22.14",
|
|
35
|
-
"vitest": "^4.1.
|
|
35
|
+
"vitest": "^4.1.11"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsdown",
|