@trainheroic-unofficial/js 2.0.2 → 2.1.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 CHANGED
@@ -211,20 +211,6 @@ declare function fetchAthleteWorkoutsChunked(client: TrainHeroicClient, startDat
211
211
  concurrency?: number;
212
212
  onProgress?: (done: number, total: number) => void;
213
213
  }): Promise<ProgramWorkout[]>;
214
- /**
215
- * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
216
- * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
217
- * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
218
- * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
219
- */
220
- declare function fetchCoachAthleteWorkouts(client: TrainHeroicClient, athleteId: number, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
221
- /**
222
- * A coach's month view of a roster athlete's logged sessions
223
- * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
224
- * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
225
- * `userId` in each row is the roster athlete, not the calling coach.
226
- */
227
- declare function fetchCoachAthleteCalendarSummary(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<unknown[]>;
228
214
  declare function fetchLeaderboard(client: TrainHeroicClient, workoutId: number, opts?: {
229
215
  page?: number;
230
216
  pageSize?: number;
@@ -317,6 +303,50 @@ declare function presentCoachAthleteTraining(raw: readonly unknown[], athleteId:
317
303
  /** Flatten `/v5/exercises/{id}/history` into PRs + a session time-series. */
318
304
  declare function presentExerciseHistory(detail: ExerciseHistoryDetail): PresentedExerciseHistory;
319
305
  //#endregion
306
+ //#region src/coach-athlete-calendar.d.ts
307
+ /**
308
+ * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
309
+ * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
310
+ * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
311
+ * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
312
+ */
313
+ declare function fetchCoachAthleteWorkouts(client: TrainHeroicClient, athleteId: number, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
314
+ /**
315
+ * A coach's month view of a roster athlete's logged sessions
316
+ * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
317
+ * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
318
+ * `userId` in each row is the roster athlete, not the calling coach.
319
+ */
320
+ declare function fetchCoachAthleteCalendarSummary(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<unknown[]>;
321
+ /** A roster athlete's coach-writable calendar (from `GET /v5/calendars/athletes/{id}`). */
322
+ type CoachAthleteCalendar = {
323
+ programId: number;
324
+ title: string;
325
+ /** Program type: 5 = individual athlete calendar, 4 = coach own calendar (observed). */
326
+ type: number | null;
327
+ groupId: number | null;
328
+ };
329
+ /**
330
+ * Resolve a roster athlete's coach-writable calendar program id
331
+ * (`GET /v5/calendars/athletes/{athleteId}?year=&month=`).
332
+ *
333
+ * Year and month are required by the API (HTTP 400 without them); the returned `programId` is
334
+ * stable for the athlete, so any month works. This is the calendar the coach web app writes
335
+ * with `createWorkoutForDay` when you open an athlete from My Athletes → calendar — distinct
336
+ * from athlete-created `personal_cal` ad-hoc sessions.
337
+ */
338
+ declare function fetchCoachAthleteCalendar(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<CoachAthleteCalendar>;
339
+ /**
340
+ * Resolve the calendar program id for `workout_build` / `coach workout build`: either an
341
+ * explicit team/group `programId`, or a roster `athleteId` (+ date) via
342
+ * `fetchCoachAthleteCalendar`. Exactly one of programId / athleteId is required.
343
+ */
344
+ declare function resolveBuildProgramId(client: TrainHeroicClient, args: {
345
+ programId?: number;
346
+ athleteId?: number;
347
+ date?: string;
348
+ }): Promise<number>;
349
+ //#endregion
320
350
  //#region src/exercise-set-payload.d.ts
321
351
  type SetWriteMode = "log" | "prescribe";
322
352
  type ExerciseSetInput = {
@@ -734,6 +764,19 @@ declare function inviteAthletes(client: TrainHeroicClient, args: {
734
764
  invited: string[];
735
765
  result: unknown;
736
766
  }>;
767
+ /**
768
+ * Update a team's title and/or reassign its calendar (`PUT /v5/teams/{teamId}`).
769
+ *
770
+ * The live API accepts `group_program` to point the team at an existing parent program /
771
+ * calendar (e.g. another team's `group_program` from `list_teams`), but rejects a body that
772
+ * has only `group_program` (HTTP 400 "Invalid parameters"). When `title` is omitted we read
773
+ * the current title first so callers can re-link without renaming.
774
+ */
775
+ declare function updateTeam(client: TrainHeroicClient, args: {
776
+ teamId: number;
777
+ title?: string;
778
+ groupProgram?: number;
779
+ }): Promise<unknown>;
737
780
  /**
738
781
  * Copy/repeat a session to a target date on a program (`POST /2.0/coach/calendar/copyProgramWorkout`).
739
782
  * The API wants the target date as a structured object (with weekday and an isToday flag),
@@ -913,4 +956,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
913
956
  stats(): Promise<Record<string, unknown>>;
914
957
  }
915
958
  //#endregion
916
- export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, BuildOptions, ClientOptions, 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, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, defaultBlockType, 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 };
959
+ export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, BLOCK_TYPE_CONDITIONING, BLOCK_TYPE_HYPERTROPHY, BuildOptions, ClientOptions, ClientResult, CoachAthleteCalendar, 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, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, defaultBlockType, definedProps, deleteComment, exerciseTitle, exerciseUnits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, 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, resolveBuildProgramId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
package/dist/index.mjs CHANGED
@@ -356,7 +356,7 @@ async function getJson(client, path, label) {
356
356
  if (!res.ok) throw new Error(`${label} failed (HTTP ${res.status}).`);
357
357
  return res.data;
358
358
  }
359
- async function getArray(client, path, label) {
359
+ async function getArray$1(client, path, label) {
360
360
  const res = await client.request("GET", path);
361
361
  if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
362
362
  return res.data;
@@ -439,10 +439,10 @@ function fetchAthletePrefs(client) {
439
439
  return getJson(client, "/1.0/athlete/prefs", "athlete prefs");
440
440
  }
441
441
  function fetchWorkingMaxes(client) {
442
- return getArray(client, "/2.0/athlete/workingMax", "athlete working maxes");
442
+ return getArray$1(client, "/2.0/athlete/workingMax", "athlete working maxes");
443
443
  }
444
444
  function fetchExerciseHistoryList(client) {
445
- return getArray(client, "/v5/users/exercises/history", "athlete exercise history list");
445
+ return getArray$1(client, "/v5/users/exercises/history", "athlete exercise history list");
446
446
  }
447
447
  /** Free-text search over the athlete's logged exercises (FTS replacement via rankSearch). */
448
448
  async function searchExerciseHistory(client, query, limit = 20) {
@@ -452,7 +452,7 @@ function fetchExerciseHistoryDetail(client, exerciseId, userId) {
452
452
  return getJson(client, `/v5/exercises/${exerciseId}/history?userId=${userId}`, "athlete exercise history");
453
453
  }
454
454
  function fetchPersonalRecords(client, exerciseId) {
455
- return getArray(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
455
+ return getArray$1(client, `/v5/exercises/${exerciseId}/personalRecords`, "athlete personal records");
456
456
  }
457
457
  /** Last performance + PR for an exercise. `date` (YYYY-MM-DD) is required by the API. */
458
458
  function fetchExerciseStats(client, exerciseId, userId, date) {
@@ -460,7 +460,7 @@ function fetchExerciseStats(client, exerciseId, userId, date) {
460
460
  }
461
461
  /** Scheduled + completed workouts in an inclusive YYYY-MM-DD window. */
462
462
  function fetchAthleteWorkouts(client, startDate, endDate) {
463
- return getArray(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
463
+ return getArray$1(client, `/3.0/athlete/programworkout/range?startDate=${startDate}&endDate=${endDate}`, "athlete workouts");
464
464
  }
465
465
  /** Add `days` to a `YYYY-MM-DD` date (UTC), returning `YYYY-MM-DD`. */
466
466
  function shiftDate(iso, days) {
@@ -522,24 +522,6 @@ async function fetchAthleteWorkoutsChunked(client, startDate, endDate, opts = {}
522
522
  return page;
523
523
  }));
524
524
  }
525
- /**
526
- * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
527
- * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
528
- * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
529
- * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
530
- */
531
- function fetchCoachAthleteWorkouts(client, athleteId, startDate, endDate) {
532
- return getArray(client, `/3.0/coach/athlete/programworkout/range/${athleteId}?startDate=${startDate}&endDate=${endDate}`, "coach athlete workouts");
533
- }
534
- /**
535
- * A coach's month view of a roster athlete's logged sessions
536
- * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
537
- * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
538
- * `userId` in each row is the roster athlete, not the calling coach.
539
- */
540
- function fetchCoachAthleteCalendarSummary(client, athleteId, year, month) {
541
- return getArray(client, `/2.0/coach/athlete/calendar/summary/${athleteId}/${year}/${month}/7`, "coach athlete calendar summary");
542
- }
543
525
  function fetchLeaderboard(client, workoutId, opts = {}) {
544
526
  const qs = new URLSearchParams();
545
527
  if (opts.page !== void 0) qs.set("page", String(opts.page));
@@ -1004,6 +986,70 @@ function presentExerciseHistory(detail) {
1004
986
  };
1005
987
  }
1006
988
  //#endregion
989
+ //#region src/coach-athlete-calendar.ts
990
+ async function getArray(client, path, label) {
991
+ const res = await client.request("GET", path);
992
+ if (!res.ok || !Array.isArray(res.data)) throw new Error(`${label} failed (HTTP ${res.status}).`);
993
+ return res.data;
994
+ }
995
+ /**
996
+ * A coach's view of a roster athlete's scheduled + completed workouts in an inclusive
997
+ * YYYY-MM-DD window (`/3.0/coach/athlete/programworkout/range/{athleteId}`). Returns the same
998
+ * `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
999
+ * `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
1000
+ */
1001
+ function fetchCoachAthleteWorkouts(client, athleteId, startDate, endDate) {
1002
+ return getArray(client, `/3.0/coach/athlete/programworkout/range/${athleteId}?startDate=${startDate}&endDate=${endDate}`, "coach athlete workouts");
1003
+ }
1004
+ /**
1005
+ * A coach's month view of a roster athlete's logged sessions
1006
+ * (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
1007
+ * ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
1008
+ * `userId` in each row is the roster athlete, not the calling coach.
1009
+ */
1010
+ function fetchCoachAthleteCalendarSummary(client, athleteId, year, month) {
1011
+ return getArray(client, `/2.0/coach/athlete/calendar/summary/${athleteId}/${year}/${month}/7`, "coach athlete calendar summary");
1012
+ }
1013
+ /**
1014
+ * Resolve a roster athlete's coach-writable calendar program id
1015
+ * (`GET /v5/calendars/athletes/{athleteId}?year=&month=`).
1016
+ *
1017
+ * Year and month are required by the API (HTTP 400 without them); the returned `programId` is
1018
+ * stable for the athlete, so any month works. This is the calendar the coach web app writes
1019
+ * with `createWorkoutForDay` when you open an athlete from My Athletes → calendar — distinct
1020
+ * from athlete-created `personal_cal` ad-hoc sessions.
1021
+ */
1022
+ async function fetchCoachAthleteCalendar(client, athleteId, year, month) {
1023
+ const path = `/v5/calendars/athletes/${athleteId}?year=${year}&month=${month}`;
1024
+ const res = await client.request("GET", path);
1025
+ if (!res.ok) {
1026
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
1027
+ throw new Error(`GET ${path} failed (HTTP ${res.status}): ${detail}`);
1028
+ }
1029
+ if (!isRecord(res.data)) throw new Error("Unexpected athlete calendar response.");
1030
+ const programId = coerceInt(res.data.id);
1031
+ if (programId === null || programId <= 0) throw new Error(`Athlete calendar for ${athleteId} did not include a program id.`);
1032
+ return {
1033
+ programId,
1034
+ title: str(res.data.title) ?? "",
1035
+ type: coerceInt(res.data.type),
1036
+ groupId: coerceInt(res.data.group_id)
1037
+ };
1038
+ }
1039
+ /**
1040
+ * Resolve the calendar program id for `workout_build` / `coach workout build`: either an
1041
+ * explicit team/group `programId`, or a roster `athleteId` (+ date) via
1042
+ * `fetchCoachAthleteCalendar`. Exactly one of programId / athleteId is required.
1043
+ */
1044
+ async function resolveBuildProgramId(client, args) {
1045
+ if (args.programId !== void 0 && args.athleteId !== void 0) throw new Error("Pass programId or athleteId, not both.");
1046
+ if (args.programId !== void 0) return args.programId;
1047
+ if (args.athleteId === void 0) throw new Error("Provide programId (team calendar) or athleteId (athlete calendar).");
1048
+ if (args.date === void 0) throw new Error("athleteId requires date (YYYY-M-D) to resolve the athlete calendar.");
1049
+ const [y, m] = parseWorkoutDate(args.date);
1050
+ return (await fetchCoachAthleteCalendar(client, args.athleteId, y, m)).programId;
1051
+ }
1052
+ //#endregion
1007
1053
  //#region src/exercise-set-payload.ts
1008
1054
  function slotData(exercise, key) {
1009
1055
  const value = exercise?.[key];
@@ -2008,7 +2054,7 @@ async function collectAdvisories(blocks, index) {
2008
2054
  function calendarWriteError(method, path, status, detail) {
2009
2055
  const base = `${method} ${path} failed (HTTP ${status}): ${detail}`;
2010
2056
  if (!(path.includes("/createWorkoutForDay/") || path.includes("/createWorkoutForTimelineDay/") || path.includes("/copyProgramWorkout")) || status !== 500 && status !== 401) return new Error(base);
2011
- return /* @__PURE__ */ new Error(`${base}. This often means the program is another athlete's Coach Plan / personal calendar (personal_cal), which the coach calendar write endpoints do not support — workout_build and session_copy work on team/group programs (and the coach's own personal calendar), but there is currently no coach-facing tool to create sessions on another athlete's personal calendar.`);
2057
+ return /* @__PURE__ */ new Error(`${base}. This often means the programId is not a coach-writable calendar — use a team/group programId (list_teams → group_program) or resolve a roster athlete's calendar via GET /v5/calendars/athletes/{athleteId}?year=&month= (workout_build athleteId). Athlete-created personal_cal ad-hoc sessions are a different surface.`);
2012
2058
  }
2013
2059
  async function req(client, method, path, body) {
2014
2060
  const res = await client.request(method, path, body === void 0 ? void 0 : { body });
@@ -2198,6 +2244,36 @@ async function inviteAthletes(client, args) {
2198
2244
  };
2199
2245
  }
2200
2246
  /**
2247
+ * Update a team's title and/or reassign its calendar (`PUT /v5/teams/{teamId}`).
2248
+ *
2249
+ * The live API accepts `group_program` to point the team at an existing parent program /
2250
+ * calendar (e.g. another team's `group_program` from `list_teams`), but rejects a body that
2251
+ * has only `group_program` (HTTP 400 "Invalid parameters"). When `title` is omitted we read
2252
+ * the current title first so callers can re-link without renaming.
2253
+ */
2254
+ async function updateTeam(client, args) {
2255
+ if (args.title === void 0 && args.groupProgram === void 0) throw new Error("Provide title and/or groupProgram.");
2256
+ let title = args.title;
2257
+ if (title === void 0) {
2258
+ const existing = await client.request("GET", `/v5/teams/${args.teamId}`);
2259
+ if (!existing.ok) {
2260
+ const detail = typeof existing.data === "string" ? existing.data : JSON.stringify(existing.data);
2261
+ throw new Error(`GET /v5/teams/${args.teamId} failed (HTTP ${existing.status}): ${detail}`);
2262
+ }
2263
+ const rec = existing.data && typeof existing.data === "object" ? existing.data : null;
2264
+ title = typeof rec?.title === "string" ? rec.title : "";
2265
+ if (title.trim() === "") throw new Error(`Could not read current title for team ${args.teamId}; pass title explicitly.`);
2266
+ }
2267
+ const body = { title };
2268
+ if (args.groupProgram !== void 0) body.group_program = args.groupProgram;
2269
+ const res = await client.request("PUT", `/v5/teams/${args.teamId}`, { body });
2270
+ if (!res.ok) {
2271
+ const detail = typeof res.data === "string" ? res.data : JSON.stringify(res.data);
2272
+ throw new Error(`PUT /v5/teams/${args.teamId} failed (HTTP ${res.status}): ${detail}`);
2273
+ }
2274
+ return res.data;
2275
+ }
2276
+ /**
2201
2277
  * Copy/repeat a session to a target date on a program (`POST /2.0/coach/calendar/copyProgramWorkout`).
2202
2278
  * The API wants the target date as a structured object (with weekday and an isToday flag),
2203
2279
  * which is computed here from `toDate` (YYYY-M-D). Creates a new (unpublished) session.
@@ -2903,4 +2979,4 @@ var ExerciseLibrary = class {
2903
2979
  }
2904
2980
  };
2905
2981
  //#endregion
2906
- 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, TrainHeroicAuthError, TrainHeroicClient, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, defaultBlockType, 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 };
2982
+ 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, TrainHeroicAuthError, TrainHeroicClient, addExercisesToWorkout, analyticsMetricCatalog, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseSetPayload, buildSearchText, buildSession, buildSetCompletePayload, calendarWriteError, checkResponse, chunk, classifyMainLift, coerceInt, coerceNum, collectAdvisories, copySession, createPersonalWorkout, dateWindows, defaultBlockType, definedProps, deleteComment, exerciseTitle, exerciseUnits, fetchAthleteMainLiftPRs, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchAthleteWorkoutsChunked, fetchCoachAthleteCalendar, 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, resolveBuildProgramId, resolveLeaderboard, searchExerciseHistory, selectWorkouts, selectWorkoutsByProgram, sendComment, serializeWorkoutHistory, setSessionInstruction, sortRosterByRecency, str, summarizeAthleteWorkouts, swapAthleteExercise, teamVolume, toSetResults, unitAdvisory, unitLabel, unwrapEnvelope, updateTeam, withUnits, workoutsToCsv, workoutsToJson, workoutsToText };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/js",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
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": "2.0.2"
30
+ "@trainheroic-unofficial/dto": "2.1.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^26.1.2",