@trainheroic-unofficial/dto 1.0.0 → 1.1.1
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/README.md +4 -4
- package/dist/index.d.mts +75 -1
- package/dist/index.mjs +29 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @trainheroic-unofficial/dto
|
|
2
2
|
|
|
3
3
|
Domain DTOs and zod schemas for the TrainHeroic API. This package is the single source of
|
|
4
|
-
truth for request and response shapes
|
|
5
|
-
their types from here
|
|
4
|
+
truth for request and response shapes. The SDK, the MCP tool layer, and the CLI all import
|
|
5
|
+
their types from here.
|
|
6
6
|
|
|
7
7
|
Part of the [trainheroic-unofficial](../../README.md) workspace.
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ import { workoutSpecSchema, type WorkoutSpec } from "@trainheroic-unofficial/dto
|
|
|
32
32
|
const spec: WorkoutSpec = workoutSpecSchema.parse(input);
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
It imports no `node:*` and touches no filesystem, so it runs
|
|
35
|
+
It imports no `node:*` and touches no filesystem, so it runs in Node, browsers, and
|
|
36
36
|
Cloudflare workerd.
|
|
37
37
|
|
|
38
38
|
## What's inside
|
|
@@ -57,7 +57,7 @@ re-exported through `index.ts`. The central pieces:
|
|
|
57
57
|
warnings the encoder emits (for example, a prescription whose unit does not match the
|
|
58
58
|
exercise's parameter type).
|
|
59
59
|
- The `responses` module holds the tolerant schemas the SDK uses to sanity-check an API
|
|
60
|
-
response before trusting it
|
|
60
|
+
response before trusting it; these schemas accept unknown fields.
|
|
61
61
|
|
|
62
62
|
## Develop
|
|
63
63
|
|
package/dist/index.d.mts
CHANGED
|
@@ -220,6 +220,14 @@ declare const athleteWorkoutRangeArgsSchema: z.ZodObject<{
|
|
|
220
220
|
endDate: z.ZodString;
|
|
221
221
|
}, z.core.$strip>;
|
|
222
222
|
type AthleteWorkoutRangeArgs = z.infer<typeof athleteWorkoutRangeArgsSchema>;
|
|
223
|
+
/**
|
|
224
|
+
* One entered set: the value of each parameter slot (param 1 / param 2 — e.g. reps / weight).
|
|
225
|
+
* Shared by every logging write so the per-set shape is defined once.
|
|
226
|
+
*/
|
|
227
|
+
declare const loggedSetSchema: z.ZodObject<{
|
|
228
|
+
param1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
229
|
+
param2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
230
|
+
}, z.core.$strip>;
|
|
223
231
|
/**
|
|
224
232
|
* Args for the set-logging write. `date` (the workout's day) locates the saved
|
|
225
233
|
* workout via the range endpoint; `savedWorkoutSetId` picks the set to complete; `results`
|
|
@@ -254,6 +262,41 @@ declare const coachLogSetArgsSchema: z.ZodObject<{
|
|
|
254
262
|
athleteId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
255
263
|
}, z.core.$strip>;
|
|
256
264
|
type CoachLogSetArgs = z.infer<typeof coachLogSetArgsSchema>;
|
|
265
|
+
/**
|
|
266
|
+
* Args for logging a whole session by exercise (rather than by saved-workout-set id). Each
|
|
267
|
+
* exercise carries its entered sets and an optional 1-based `order`. The athlete path creates
|
|
268
|
+
* or reuses a personal session for the date and logs against it; the coach path resolves each
|
|
269
|
+
* exercise to a set already prescribed on that date and logs against that.
|
|
270
|
+
*/
|
|
271
|
+
declare const logSessionArgsSchema: z.ZodObject<{
|
|
272
|
+
date: z.ZodString;
|
|
273
|
+
exercises: z.ZodArray<z.ZodObject<{
|
|
274
|
+
exerciseId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
275
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
276
|
+
sets: z.ZodArray<z.ZodObject<{
|
|
277
|
+
param1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
278
|
+
param2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
279
|
+
}, z.core.$strip>>;
|
|
280
|
+
}, z.core.$strip>>;
|
|
281
|
+
}, z.core.$strip>;
|
|
282
|
+
type LogSessionArgs = z.infer<typeof logSessionArgsSchema>;
|
|
283
|
+
/**
|
|
284
|
+
* Args for the coach variant of {@link logSessionArgsSchema}: the same shape plus the roster
|
|
285
|
+
* `athleteId` whose session is being logged on their behalf.
|
|
286
|
+
*/
|
|
287
|
+
declare const coachLogSessionArgsSchema: z.ZodObject<{
|
|
288
|
+
date: z.ZodString;
|
|
289
|
+
exercises: z.ZodArray<z.ZodObject<{
|
|
290
|
+
exerciseId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
291
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
sets: z.ZodArray<z.ZodObject<{
|
|
293
|
+
param1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
294
|
+
param2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
295
|
+
}, z.core.$strip>>;
|
|
296
|
+
}, z.core.$strip>>;
|
|
297
|
+
athleteId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
type CoachLogSessionArgs = z.infer<typeof coachLogSessionArgsSchema>;
|
|
257
300
|
/** A flattened exercise within a presented workout: prescriptions, logged results, units. */
|
|
258
301
|
type AthleteWorkoutExercise = {
|
|
259
302
|
exerciseId: number | null;
|
|
@@ -359,6 +402,37 @@ type RosterActivityRow = {
|
|
|
359
402
|
totalReps: number | null;
|
|
360
403
|
totalVolume: number | null;
|
|
361
404
|
};
|
|
405
|
+
/**
|
|
406
|
+
* One athlete's logged volume over a date window, aggregated from the `training-summary-athlete`
|
|
407
|
+
* analytics report (which returns one row per logged session). `volume` is in pounds.
|
|
408
|
+
*/
|
|
409
|
+
type TeamVolumeAthlete = {
|
|
410
|
+
athleteId: number;
|
|
411
|
+
name: string | null;
|
|
412
|
+
sessions: number;
|
|
413
|
+
reps: number;
|
|
414
|
+
volume: number;
|
|
415
|
+
firstLoggedDate: string | null;
|
|
416
|
+
lastLoggedDate: string | null;
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* A coach's team-wide training volume over an inclusive `YYYY-MM-DD` window: per-athlete rows
|
|
420
|
+
* (only athletes who logged in range appear) plus the rolled-up team totals. The windowed
|
|
421
|
+
* counterpart to the all-time {@link RosterActivityRow} snapshot.
|
|
422
|
+
*/
|
|
423
|
+
type TeamVolumeReport = {
|
|
424
|
+
window: {
|
|
425
|
+
start: string;
|
|
426
|
+
end: string;
|
|
427
|
+
};
|
|
428
|
+
athletes: TeamVolumeAthlete[];
|
|
429
|
+
totals: {
|
|
430
|
+
athletes: number;
|
|
431
|
+
sessions: number;
|
|
432
|
+
reps: number;
|
|
433
|
+
volume: number;
|
|
434
|
+
};
|
|
435
|
+
};
|
|
362
436
|
/** One performed session in a presented exercise history. */
|
|
363
437
|
type PresentedExerciseSession = {
|
|
364
438
|
date: string;
|
|
@@ -578,4 +652,4 @@ type ReadResult = {
|
|
|
578
652
|
blocks: ReadBlock[];
|
|
579
653
|
};
|
|
580
654
|
//#endregion
|
|
581
|
-
export { Advisory, AthletePrefs, AthleteProfileSummary, AthleteUser, AthleteWorkingMax, AthleteWorkoutBlock, AthleteWorkoutExercise, AthleteWorkoutRangeArgs, AthleteWorkoutSummary, AthleteWorkoutView, BlockSpec, CoachAthleteExercise, CoachAthleteSession, CoachAthleteTraining, CoachLogSetArgs, CommentDraft, ExerciseCreate, ExerciseHistoryDetail, ExerciseHistoryListItem, ExerciseRow, ExerciseSpec, ExerciseStats, ExerciseView, Id, LeaderboardSpec, LogSetArgs, PersonalRecord, PresentedExerciseHistory, PresentedExerciseSession, ProgramWorkout, ReadBlock, ReadExercise, ReadResult, ResolveResult, RosterActivityRow, UserSimple, WorkoutDate, WorkoutSpec, athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, coachLogSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSetArgsSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, repMaxSchema, sessionCreateResponseSchema, userSimpleSchema, workoutSpecSchema };
|
|
655
|
+
export { Advisory, AthletePrefs, AthleteProfileSummary, AthleteUser, AthleteWorkingMax, AthleteWorkoutBlock, AthleteWorkoutExercise, AthleteWorkoutRangeArgs, AthleteWorkoutSummary, AthleteWorkoutView, BlockSpec, CoachAthleteExercise, CoachAthleteSession, CoachAthleteTraining, CoachLogSessionArgs, CoachLogSetArgs, CommentDraft, ExerciseCreate, ExerciseHistoryDetail, ExerciseHistoryListItem, ExerciseRow, ExerciseSpec, ExerciseStats, ExerciseView, Id, LeaderboardSpec, LogSessionArgs, LogSetArgs, PersonalRecord, PresentedExerciseHistory, PresentedExerciseSession, ProgramWorkout, ReadBlock, ReadExercise, ReadResult, ResolveResult, RosterActivityRow, TeamVolumeAthlete, TeamVolumeReport, UserSimple, WorkoutDate, WorkoutSpec, athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSessionArgsSchema, logSetArgsSchema, loggedSetSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, repMaxSchema, sessionCreateResponseSchema, userSimpleSchema, workoutSpecSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -156,6 +156,14 @@ const athleteWorkoutRangeArgsSchema = z.object({
|
|
|
156
156
|
endDate: dateString
|
|
157
157
|
});
|
|
158
158
|
/**
|
|
159
|
+
* One entered set: the value of each parameter slot (param 1 / param 2 — e.g. reps / weight).
|
|
160
|
+
* Shared by every logging write so the per-set shape is defined once.
|
|
161
|
+
*/
|
|
162
|
+
const loggedSetSchema = z.object({
|
|
163
|
+
param1: z.union([z.number(), z.string()]).optional(),
|
|
164
|
+
param2: z.union([z.number(), z.string()]).optional()
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
159
167
|
* Args for the set-logging write. `date` (the workout's day) locates the saved
|
|
160
168
|
* workout via the range endpoint; `savedWorkoutSetId` picks the set to complete; `results`
|
|
161
169
|
* gives, per exercise in it, the entered value of each set (param 1 / param 2 by entry slot).
|
|
@@ -165,10 +173,7 @@ const logSetArgsSchema = z.object({
|
|
|
165
173
|
savedWorkoutSetId: idArgSchema,
|
|
166
174
|
results: z.array(z.object({
|
|
167
175
|
savedWorkoutSetExerciseId: idArgSchema,
|
|
168
|
-
sets: z.array(
|
|
169
|
-
param1: z.union([z.number(), z.string()]).optional(),
|
|
170
|
-
param2: z.union([z.number(), z.string()]).optional()
|
|
171
|
-
})).min(1)
|
|
176
|
+
sets: z.array(loggedSetSchema).min(1)
|
|
172
177
|
})).min(1)
|
|
173
178
|
});
|
|
174
179
|
/**
|
|
@@ -176,6 +181,25 @@ const logSetArgsSchema = z.object({
|
|
|
176
181
|
* roster `athleteId` whose set is being logged on their behalf.
|
|
177
182
|
*/
|
|
178
183
|
const coachLogSetArgsSchema = logSetArgsSchema.extend({ athleteId: idArgSchema });
|
|
184
|
+
/**
|
|
185
|
+
* Args for logging a whole session by exercise (rather than by saved-workout-set id). Each
|
|
186
|
+
* exercise carries its entered sets and an optional 1-based `order`. The athlete path creates
|
|
187
|
+
* or reuses a personal session for the date and logs against it; the coach path resolves each
|
|
188
|
+
* exercise to a set already prescribed on that date and logs against that.
|
|
189
|
+
*/
|
|
190
|
+
const logSessionArgsSchema = z.object({
|
|
191
|
+
date: dateString,
|
|
192
|
+
exercises: z.array(z.object({
|
|
193
|
+
exerciseId: idArgSchema,
|
|
194
|
+
order: z.number().int().positive().optional(),
|
|
195
|
+
sets: z.array(loggedSetSchema).min(1)
|
|
196
|
+
})).min(1)
|
|
197
|
+
});
|
|
198
|
+
/**
|
|
199
|
+
* Args for the coach variant of {@link logSessionArgsSchema}: the same shape plus the roster
|
|
200
|
+
* `athleteId` whose session is being logged on their behalf.
|
|
201
|
+
*/
|
|
202
|
+
const coachLogSessionArgsSchema = logSessionArgsSchema.extend({ athleteId: idArgSchema });
|
|
179
203
|
//#endregion
|
|
180
204
|
//#region src/exercise.ts
|
|
181
205
|
/** Body for creating a custom exercise; extra fields the API accepts are preserved. */
|
|
@@ -278,4 +302,4 @@ function parseWorkoutDate(s) {
|
|
|
278
302
|
];
|
|
279
303
|
}
|
|
280
304
|
//#endregion
|
|
281
|
-
export { athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, coachLogSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSetArgsSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, repMaxSchema, sessionCreateResponseSchema, userSimpleSchema, workoutSpecSchema };
|
|
305
|
+
export { athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, coachLogSessionArgsSchema, coachLogSetArgsSchema, commentDraftSchema, dateString, exerciseCreateSchema, exerciseHistoryDetailSchema, exerciseHistoryListItemSchema, exerciseHistoryListSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, exerciseStatsSchema, historyEntrySchema, historySetSchema, idArgSchema, idSchema, leaderboardSpecSchema, liftPRSchema, logSessionArgsSchema, logSetArgsSchema, loggedSetSchema, parseWorkoutDate, personalRecordListSchema, personalRecordSchema, programWorkoutListSchema, programWorkoutResponseSchema, programWorkoutSchema, programsEditResponseSchema, repMaxSchema, sessionCreateResponseSchema, userSimpleSchema, workoutSpecSchema };
|