@trainheroic-unofficial/js 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +26 -1
- package/dist/index.mjs +40 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -231,6 +231,31 @@ declare function logAthleteSet(client: TrainHeroicClient, args: {
|
|
|
231
231
|
savedWorkoutSetId: number;
|
|
232
232
|
exercisesLogged: number;
|
|
233
233
|
}>;
|
|
234
|
+
type PersonalWorkoutCreated = {
|
|
235
|
+
programWorkoutId: number;
|
|
236
|
+
workoutId: number;
|
|
237
|
+
savedWorkoutId: number;
|
|
238
|
+
groupId: number;
|
|
239
|
+
date: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* POST /v5/programWorkouts/personal — create a personal workout session for a given date.
|
|
243
|
+
* Returns the key ids: workoutId (needed for addExercisesToWorkout), programWorkoutId,
|
|
244
|
+
* savedWorkoutId, and groupId.
|
|
245
|
+
*/
|
|
246
|
+
declare function createPersonalWorkout(client: TrainHeroicClient, date: string): Promise<PersonalWorkoutCreated>;
|
|
247
|
+
/** One exercise item for addExercisesToWorkout. */
|
|
248
|
+
type AddedExercise = {
|
|
249
|
+
exerciseId: number;
|
|
250
|
+
order: number;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* PUT /v5/personalCalendar/workouts/{workoutId}/addExercises — add exercises to a personal
|
|
254
|
+
* workout. Returns saved workout set objects: each top-level `id` is a savedWorkoutSetId
|
|
255
|
+
* and `savedWorkoutSetExercises[].id` is a savedWorkoutSetExerciseId, both needed by
|
|
256
|
+
* logAthleteSet.
|
|
257
|
+
*/
|
|
258
|
+
declare function addExercisesToWorkout(client: TrainHeroicClient, workoutId: number, exercises: AddedExercise[]): Promise<unknown>;
|
|
234
259
|
/** Flatten `/v5/exercises/{id}/history` into PRs + a session time-series. */
|
|
235
260
|
declare function presentExerciseHistory(detail: ExerciseHistoryDetail): PresentedExerciseHistory;
|
|
236
261
|
//#endregion
|
|
@@ -323,4 +348,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
|
|
|
323
348
|
stats(): Promise<Record<string, unknown>>;
|
|
324
349
|
}
|
|
325
350
|
//#endregion
|
|
326
|
-
export { ApiBase, BuildOptions, ClientResult, ExerciseIndex, ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, RequestOptions, SetResult, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicSession, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseLogPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, coerceInt, coerceNum, collectAdvisories, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, findSavedWorkoutSet, isRecord, logAthleteSet, loginTrainHeroic, makeExercise, mapPool, presentAthleteWorkout, presentAthleteWorkouts, presentExercise, presentExerciseHistory, publishSession, rankSearch, readLive, readSession, removeSession, repsList, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, sendComment, setSessionInstruction, unitAdvisory, unitLabel, unwrapEnvelope, withUnits };
|
|
351
|
+
export { AddedExercise, ApiBase, BuildOptions, ClientResult, ExerciseIndex, ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, Leaderboard, LibraryCache, LibrarySnapshot, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, PersonalWorkoutCreated, RequestOptions, SetResult, TrainHeroicAuthError, TrainHeroicClient, TrainHeroicSession, addExercisesToWorkout, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseLogPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, coerceInt, coerceNum, collectAdvisories, createPersonalWorkout, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, findSavedWorkoutSet, isRecord, logAthleteSet, loginTrainHeroic, makeExercise, mapPool, presentAthleteWorkout, presentAthleteWorkouts, presentExercise, presentExerciseHistory, publishSession, rankSearch, readLive, readSession, removeSession, repsList, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, sendComment, setSessionInstruction, unitAdvisory, unitLabel, unwrapEnvelope, withUnits };
|
package/dist/index.mjs
CHANGED
|
@@ -554,6 +554,45 @@ async function logAthleteSet(client, args) {
|
|
|
554
554
|
exercisesLogged
|
|
555
555
|
};
|
|
556
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* POST /v5/programWorkouts/personal — create a personal workout session for a given date.
|
|
559
|
+
* Returns the key ids: workoutId (needed for addExercisesToWorkout), programWorkoutId,
|
|
560
|
+
* savedWorkoutId, and groupId.
|
|
561
|
+
*/
|
|
562
|
+
async function createPersonalWorkout(client, date) {
|
|
563
|
+
const res = await client.request("POST", "/v5/programWorkouts/personal", { body: { date } });
|
|
564
|
+
if (!res.ok) throw new Error(`Create personal workout failed (HTTP ${res.status}).`);
|
|
565
|
+
if (!isRecord(res.data)) throw new Error("Unexpected response from /v5/programWorkouts/personal.");
|
|
566
|
+
const pw = isRecord(res.data.programWorkout) ? res.data.programWorkout : null;
|
|
567
|
+
const sw = isRecord(res.data.savedWorkout) ? res.data.savedWorkout : null;
|
|
568
|
+
if (!pw || !sw) throw new Error("Missing programWorkout or savedWorkout in response.");
|
|
569
|
+
const programWorkoutId = coerceInt(pw.id);
|
|
570
|
+
const workoutId = coerceInt(pw.workoutId);
|
|
571
|
+
const savedWorkoutId = coerceInt(sw.id);
|
|
572
|
+
const groupId = coerceInt(sw.group_id);
|
|
573
|
+
if (!programWorkoutId || !workoutId || !savedWorkoutId || !groupId) throw new Error("Could not parse required ids from personal workout response.");
|
|
574
|
+
return {
|
|
575
|
+
programWorkoutId,
|
|
576
|
+
workoutId,
|
|
577
|
+
savedWorkoutId,
|
|
578
|
+
groupId,
|
|
579
|
+
date: typeof pw.date === "string" ? pw.date : date
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* PUT /v5/personalCalendar/workouts/{workoutId}/addExercises — add exercises to a personal
|
|
584
|
+
* workout. Returns saved workout set objects: each top-level `id` is a savedWorkoutSetId
|
|
585
|
+
* and `savedWorkoutSetExercises[].id` is a savedWorkoutSetExerciseId, both needed by
|
|
586
|
+
* logAthleteSet.
|
|
587
|
+
*/
|
|
588
|
+
async function addExercisesToWorkout(client, workoutId, exercises) {
|
|
589
|
+
const res = await client.request("PUT", `/v5/personalCalendar/workouts/${workoutId}/addExercises`, { body: {
|
|
590
|
+
exercises,
|
|
591
|
+
circuits: []
|
|
592
|
+
} });
|
|
593
|
+
if (!res.ok) throw new Error(`Add exercises to workout failed (HTTP ${res.status}).`);
|
|
594
|
+
return res.data;
|
|
595
|
+
}
|
|
557
596
|
/** Flatten `/v5/exercises/{id}/history` into PRs + a session time-series. */
|
|
558
597
|
function presentExerciseHistory(detail) {
|
|
559
598
|
return {
|
|
@@ -1141,4 +1180,4 @@ var ExerciseLibrary = class {
|
|
|
1141
1180
|
}
|
|
1142
1181
|
};
|
|
1143
1182
|
//#endregion
|
|
1144
|
-
export { ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, TrainHeroicAuthError, TrainHeroicClient, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseLogPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, coerceInt, coerceNum, collectAdvisories, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, findSavedWorkoutSet, isRecord, logAthleteSet, loginTrainHeroic, makeExercise, mapPool, presentAthleteWorkout, presentAthleteWorkouts, presentExercise, presentExerciseHistory, publishSession, rankSearch, readLive, readSession, removeSession, repsList, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, sendComment, setSessionInstruction, unitAdvisory, unitLabel, unwrapEnvelope, withUnits };
|
|
1183
|
+
export { ExerciseLibrary, LEADERBOARD_LABEL, LEADERBOARD_TYPE, MemoryLibraryCache, PARAM_NONE, PARAM_PCT_MAX, PARAM_REPS, PARAM_RPE, PARAM_UNIT, PARAM_WEIGHT, TrainHeroicAuthError, TrainHeroicClient, addExercisesToWorkout, asExerciseList, buildBlockPayload, buildCommentPayload, buildExerciseLogPayload, buildSearchText, buildSession, buildSetCompletePayload, checkResponse, chunk, coerceInt, coerceNum, collectAdvisories, createPersonalWorkout, deleteComment, exerciseUnits, fetchAthletePrefs, fetchAthleteProfileSummary, fetchAthleteUser, fetchAthleteWorkouts, fetchExerciseHistoryDetail, fetchExerciseHistoryList, fetchExerciseStats, fetchLeaderboard, fetchPersonalRecords, fetchStreams, fetchWorkingMaxes, findSavedWorkoutSet, isRecord, logAthleteSet, loginTrainHeroic, makeExercise, mapPool, presentAthleteWorkout, presentAthleteWorkouts, presentExercise, presentExerciseHistory, publishSession, rankSearch, readLive, readSession, removeSession, repsList, resolveAthleteUserId, resolveLeaderboard, searchExerciseHistory, sendComment, setSessionInstruction, unitAdvisory, unitLabel, unwrapEnvelope, withUnits };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/js",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
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": "0.4.
|
|
30
|
+
"@trainheroic-unofficial/dto": "0.4.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^26.0.0",
|