@trainheroic-unofficial/js 2.0.1 → 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),
@@ -822,6 +865,14 @@ declare function resolveLeaderboard(block: BlockSpec): Leaderboard;
822
865
  declare function repsList(ex: ExerciseSpec): string[];
823
866
  /** Build one saveWorkoutSetExercises payload entry with all ten param slots filled. */
824
867
  declare function makeExercise(ex: ExerciseSpec, workoutSetId: number, order: number, key: string): Record<string, unknown>;
868
+ /** Block `type` values the coach calendar accepts (verified in workout-creation.md). */
869
+ declare const BLOCK_TYPE_CONDITIONING = 1;
870
+ declare const BLOCK_TYPE_HYPERTROPHY = 2;
871
+ /**
872
+ * Default block type: text-only (empty exercises) blocks are Conditioning / Circuit (type 1);
873
+ * structured exercise blocks default to Hypertrophy (type 2). An explicit `type` always wins.
874
+ */
875
+ declare function defaultBlockType(block: BlockSpec): number;
825
876
  declare function buildBlockPayload(blocks: readonly BlockSpec[], workoutId: number): Array<Record<string, unknown>>;
826
877
  /** Flag spec params the API will silently override to the exercise's fixed units. */
827
878
  declare function unitAdvisory(blockTitle: string, ex: ExerciseSpec, defaults: {
@@ -846,6 +897,12 @@ type BuildOptions = {
846
897
  /** Optional session-level note ("Coach Instructions"), set after the blocks save. */
847
898
  instruction?: string;
848
899
  };
900
+ /**
901
+ * Coach calendar writes (`createWorkoutForDay`, timeline create, `copyProgramWorkout`) 500/401
902
+ * on personal calendars (Coach Plan / `personal_cal`). Shared by `buildSession` and
903
+ * `copySession` so the hint stays in one place.
904
+ */
905
+ declare function calendarWriteError(method: string, path: string, status: number, detail: string): Error;
849
906
  declare function buildSession(client: TrainHeroicClient, opts: BuildOptions): Promise<{
850
907
  pwId: number;
851
908
  workoutId: number;
@@ -899,4 +956,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
899
956
  stats(): Promise<Record<string, unknown>>;
900
957
  }
901
958
  //#endregion
902
- export { ANALYTICS_METRIC_KEYS, AddedExercise, AnalyticsMetric, AnalyticsQueryArgs, ApiBase, AthleteMainLiftPRs, 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, 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 };
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 };