@trainheroic-unofficial/dto 0.2.0 → 0.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 CHANGED
@@ -1,5 +1,289 @@
1
1
  import { z } from "zod";
2
2
 
3
+ //#region src/athlete.d.ts
4
+ /** `/user/simple` — the identity + tenant key (numeric `id`) for any logged-in account. */
5
+ declare const userSimpleSchema: z.ZodObject<{
6
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
7
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
+ org_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
9
+ }, z.core.$loose>;
10
+ type UserSimple = z.infer<typeof userSimpleSchema>;
11
+ /** `/v5/athleteProfile/summary` — lifetime training totals. Needs `use_metric` in the query. */
12
+ declare const athleteProfileSummarySchema: z.ZodObject<{
13
+ reps_sum: z.ZodOptional<z.ZodNumber>;
14
+ volume_sum: z.ZodOptional<z.ZodNumber>;
15
+ sessions_count: z.ZodOptional<z.ZodNumber>;
16
+ first_logged_date: z.ZodOptional<z.ZodString>;
17
+ last_logged_date: z.ZodOptional<z.ZodString>;
18
+ duration_hours: z.ZodOptional<z.ZodNumber>;
19
+ }, z.core.$loose>;
20
+ type AthleteProfileSummary = z.infer<typeof athleteProfileSummarySchema>;
21
+ /** `/v5/users/{id}` — the detailed athlete profile (only the fields we surface). */
22
+ declare const athleteUserSchema: z.ZodObject<{
23
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
24
+ email: z.ZodOptional<z.ZodString>;
25
+ name_first: z.ZodOptional<z.ZodString>;
26
+ name_last: z.ZodOptional<z.ZodString>;
27
+ username: z.ZodOptional<z.ZodString>;
28
+ gender: z.ZodOptional<z.ZodString>;
29
+ date_of_birth: z.ZodOptional<z.ZodString>;
30
+ use_metric: z.ZodOptional<z.ZodBoolean>;
31
+ }, z.core.$loose>;
32
+ type AthleteUser = z.infer<typeof athleteUserSchema>;
33
+ /** `/1.0/athlete/prefs` — notification + display preference flags. */
34
+ declare const athletePrefsSchema: z.ZodObject<{
35
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
36
+ }, z.core.$loose>;
37
+ type AthletePrefs = z.infer<typeof athletePrefsSchema>;
38
+ /** One item of `/2.0/athlete/workingMax` — the athlete's working max for an exercise. */
39
+ declare const athleteWorkingMaxSchema: z.ZodObject<{
40
+ exercise_id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
41
+ title: z.ZodOptional<z.ZodString>;
42
+ param_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
43
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
44
+ type_suffix: z.ZodOptional<z.ZodString>;
45
+ working_max_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
46
+ }, z.core.$loose>;
47
+ declare const athleteWorkingMaxListSchema: z.ZodArray<z.ZodObject<{
48
+ exercise_id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
49
+ title: z.ZodOptional<z.ZodString>;
50
+ param_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
51
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
52
+ type_suffix: z.ZodOptional<z.ZodString>;
53
+ working_max_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
54
+ }, z.core.$loose>>;
55
+ type AthleteWorkingMax = z.infer<typeof athleteWorkingMaxSchema>;
56
+ /** One item of `/v5/users/exercises/history` — an exercise the athlete has logged. */
57
+ declare const exerciseHistoryListItemSchema: z.ZodObject<{
58
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
59
+ title: z.ZodString;
60
+ isCircuit: z.ZodOptional<z.ZodBoolean>;
61
+ prescription: z.ZodOptional<z.ZodString>;
62
+ param1Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
63
+ param2Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
64
+ }, z.core.$loose>;
65
+ declare const exerciseHistoryListSchema: z.ZodArray<z.ZodObject<{
66
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
67
+ title: z.ZodString;
68
+ isCircuit: z.ZodOptional<z.ZodBoolean>;
69
+ prescription: z.ZodOptional<z.ZodString>;
70
+ param1Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
71
+ param2Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
72
+ }, z.core.$loose>>;
73
+ type ExerciseHistoryListItem = z.infer<typeof exerciseHistoryListItemSchema>;
74
+ /** A single completed set inside a history entry (`/v5/exercises/{id}/history`). */
75
+ declare const historySetSchema: z.ZodObject<{
76
+ setNumber: z.ZodNumber;
77
+ formattedValue: z.ZodOptional<z.ZodString>;
78
+ rawValue1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
79
+ rawValue2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
80
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
81
+ }, z.core.$loose>;
82
+ /** A best rep-max derived for a history entry. */
83
+ declare const repMaxSchema: z.ZodObject<{
84
+ reps: z.ZodNumber;
85
+ weight: z.ZodNumber;
86
+ }, z.core.$loose>;
87
+ /** One performed session of an exercise (`/v5/exercises/{id}/history` → `history[]`). */
88
+ declare const historyEntrySchema: z.ZodObject<{
89
+ dateCompleted: z.ZodString;
90
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ isLift: z.ZodOptional<z.ZodBoolean>;
92
+ param1Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
93
+ param2Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
94
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
95
+ teamId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
96
+ programWorkoutId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
97
+ abr: z.ZodOptional<z.ZodString>;
98
+ bestEstimated1RM: z.ZodOptional<z.ZodNumber>;
99
+ repMaxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
+ reps: z.ZodNumber;
101
+ weight: z.ZodNumber;
102
+ }, z.core.$loose>>>;
103
+ sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
104
+ setNumber: z.ZodNumber;
105
+ formattedValue: z.ZodOptional<z.ZodString>;
106
+ rawValue1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
107
+ rawValue2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
108
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
109
+ }, z.core.$loose>>>;
110
+ }, z.core.$loose>;
111
+ /** A lifetime PR row from `/v5/exercises/{id}/history` → `liftPRs[]`. */
112
+ declare const liftPRSchema: z.ZodObject<{
113
+ weight: z.ZodOptional<z.ZodNumber>;
114
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
115
+ setNumber: z.ZodOptional<z.ZodNumber>;
116
+ dateCompleted: z.ZodOptional<z.ZodString>;
117
+ reps: z.ZodOptional<z.ZodNumber>;
118
+ units: z.ZodOptional<z.ZodString>;
119
+ isMetric: z.ZodOptional<z.ZodBoolean>;
120
+ description: z.ZodOptional<z.ZodString>;
121
+ }, z.core.$loose>;
122
+ /** `/v5/exercises/{id}/history` — the per-exercise PRs + session history. */
123
+ declare const exerciseHistoryDetailSchema: z.ZodObject<{
124
+ liftPRs: z.ZodOptional<z.ZodArray<z.ZodObject<{
125
+ weight: z.ZodOptional<z.ZodNumber>;
126
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
127
+ setNumber: z.ZodOptional<z.ZodNumber>;
128
+ dateCompleted: z.ZodOptional<z.ZodString>;
129
+ reps: z.ZodOptional<z.ZodNumber>;
130
+ units: z.ZodOptional<z.ZodString>;
131
+ isMetric: z.ZodOptional<z.ZodBoolean>;
132
+ description: z.ZodOptional<z.ZodString>;
133
+ }, z.core.$loose>>>;
134
+ singleParamPRs: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
135
+ history: z.ZodOptional<z.ZodArray<z.ZodObject<{
136
+ dateCompleted: z.ZodString;
137
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
138
+ isLift: z.ZodOptional<z.ZodBoolean>;
139
+ param1Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
140
+ param2Type: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
141
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
142
+ teamId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
143
+ programWorkoutId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
144
+ abr: z.ZodOptional<z.ZodString>;
145
+ bestEstimated1RM: z.ZodOptional<z.ZodNumber>;
146
+ repMaxes: z.ZodOptional<z.ZodArray<z.ZodObject<{
147
+ reps: z.ZodNumber;
148
+ weight: z.ZodNumber;
149
+ }, z.core.$loose>>>;
150
+ sets: z.ZodOptional<z.ZodArray<z.ZodObject<{
151
+ setNumber: z.ZodNumber;
152
+ formattedValue: z.ZodOptional<z.ZodString>;
153
+ rawValue1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
154
+ rawValue2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
155
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
156
+ }, z.core.$loose>>>;
157
+ }, z.core.$loose>>>;
158
+ }, z.core.$loose>;
159
+ type ExerciseHistoryDetail = z.infer<typeof exerciseHistoryDetailSchema>;
160
+ /** One item of `/v5/exercises/{id}/personalRecords` — a standards-filtered PR. */
161
+ declare const personalRecordSchema: z.ZodObject<{
162
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
163
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
164
+ setNumber: z.ZodOptional<z.ZodNumber>;
165
+ reps: z.ZodOptional<z.ZodNumber>;
166
+ weight: z.ZodOptional<z.ZodNumber>;
167
+ scaledWeight: z.ZodOptional<z.ZodNumber>;
168
+ units: z.ZodOptional<z.ZodString>;
169
+ isMetric: z.ZodOptional<z.ZodBoolean>;
170
+ }, z.core.$loose>;
171
+ declare const personalRecordListSchema: z.ZodArray<z.ZodObject<{
172
+ id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
173
+ savedWorkoutSetExerciseId: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
174
+ setNumber: z.ZodOptional<z.ZodNumber>;
175
+ reps: z.ZodOptional<z.ZodNumber>;
176
+ weight: z.ZodOptional<z.ZodNumber>;
177
+ scaledWeight: z.ZodOptional<z.ZodNumber>;
178
+ units: z.ZodOptional<z.ZodString>;
179
+ isMetric: z.ZodOptional<z.ZodBoolean>;
180
+ }, z.core.$loose>>;
181
+ type PersonalRecord = z.infer<typeof personalRecordSchema>;
182
+ /** `/v5/exercises/{id}/stats` — last performance + PR for an exercise. Needs `date` in the query. */
183
+ declare const exerciseStatsSchema: z.ZodObject<{
184
+ isLift: z.ZodOptional<z.ZodBoolean>;
185
+ lastPerformance: z.ZodOptional<z.ZodUnknown>;
186
+ personalRecord: z.ZodOptional<z.ZodUnknown>;
187
+ }, z.core.$loose>;
188
+ type ExerciseStats = z.infer<typeof exerciseStatsSchema>;
189
+ /**
190
+ * One item of `/3.0/athlete/programworkout/range` — a scheduled/completed workout. The deep
191
+ * `summarizedSavedWorkout` tree is left loose: the presenter in `js` flattens it, so dto only
192
+ * pins the top-level fields the warehouse and presenter key off.
193
+ */
194
+ declare const programWorkoutSchema: z.ZodObject<{
195
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
196
+ date: z.ZodOptional<z.ZodString>;
197
+ workout_title: z.ZodOptional<z.ZodString>;
198
+ program_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
199
+ program_title: z.ZodOptional<z.ZodString>;
200
+ team_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
201
+ team_title: z.ZodOptional<z.ZodString>;
202
+ summarizedSavedWorkout: z.ZodOptional<z.ZodUnknown>;
203
+ }, z.core.$loose>;
204
+ declare const programWorkoutListSchema: z.ZodArray<z.ZodObject<{
205
+ id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
206
+ date: z.ZodOptional<z.ZodString>;
207
+ workout_title: z.ZodOptional<z.ZodString>;
208
+ program_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
209
+ program_title: z.ZodOptional<z.ZodString>;
210
+ team_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodNull]>>;
211
+ team_title: z.ZodOptional<z.ZodString>;
212
+ summarizedSavedWorkout: z.ZodOptional<z.ZodUnknown>;
213
+ }, z.core.$loose>>;
214
+ type ProgramWorkout = z.infer<typeof programWorkoutSchema>;
215
+ /** A `YYYY-MM-DD` date argument. The single definition reused across athlete tool inputs. */
216
+ declare const dateString: z.ZodString;
217
+ /** Args for the workout-range read: an inclusive `YYYY-MM-DD` window. */
218
+ declare const athleteWorkoutRangeArgsSchema: z.ZodObject<{
219
+ startDate: z.ZodString;
220
+ endDate: z.ZodString;
221
+ }, z.core.$strip>;
222
+ type AthleteWorkoutRangeArgs = z.infer<typeof athleteWorkoutRangeArgsSchema>;
223
+ /**
224
+ * Args for the set-logging write. `date` (the workout's day) locates the saved
225
+ * workout via the range endpoint; `savedWorkoutSetId` picks the set to complete; `results`
226
+ * gives, per exercise in it, the entered value of each set (param 1 / param 2 by entry slot).
227
+ */
228
+ declare const logSetArgsSchema: z.ZodObject<{
229
+ date: z.ZodString;
230
+ savedWorkoutSetId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
231
+ results: z.ZodArray<z.ZodObject<{
232
+ savedWorkoutSetExerciseId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
233
+ sets: z.ZodArray<z.ZodObject<{
234
+ param1: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
235
+ param2: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
236
+ }, z.core.$strip>>;
237
+ }, z.core.$strip>>;
238
+ }, z.core.$strip>;
239
+ type LogSetArgs = z.infer<typeof logSetArgsSchema>;
240
+ /** A flattened exercise within a presented workout: prescriptions per set + positional units. */
241
+ type AthleteWorkoutExercise = {
242
+ exerciseId: number | null;
243
+ title: string;
244
+ instruction: string | null;
245
+ units: Array<string | null>; /** Per-set prescriptions, e.g. ["5 @ 225 lb", "3 @ 245 lb"] or ["AMRAP"]. */
246
+ prescribed: string[];
247
+ };
248
+ /** A block (workout set) within a presented workout. */
249
+ type AthleteWorkoutBlock = {
250
+ order: number;
251
+ title: string | null;
252
+ instruction: string | null;
253
+ isTest: boolean;
254
+ exercises: AthleteWorkoutExercise[];
255
+ };
256
+ /** A scheduled/completed workout flattened for reading. */
257
+ type AthleteWorkoutView = {
258
+ id: number | null;
259
+ date: string;
260
+ title: string;
261
+ program: string | null;
262
+ team: string | null;
263
+ instruction: string | null;
264
+ blocks: AthleteWorkoutBlock[];
265
+ };
266
+ /** One performed session in a presented exercise history. */
267
+ type PresentedExerciseSession = {
268
+ date: string;
269
+ abr: string | null;
270
+ estimated1RM: number | null;
271
+ sets: Array<{
272
+ setNumber: number;
273
+ value: string | null;
274
+ }>;
275
+ };
276
+ /** A presented per-exercise history: PRs plus the session time-series. */
277
+ type PresentedExerciseHistory = {
278
+ liftPRs: Array<{
279
+ description: string | null;
280
+ reps: number | null;
281
+ weight: number | null;
282
+ date: string | null;
283
+ }>;
284
+ sessions: PresentedExerciseSession[];
285
+ };
286
+ //#endregion
3
287
  //#region src/common.d.ts
4
288
  /** An entity id as it arrives over the wire — a number or a numeric string. */
5
289
  declare const idSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
@@ -22,10 +306,14 @@ type ExerciseRow = {
22
306
  user_id: number | null;
23
307
  use_count: number;
24
308
  };
25
- /** A row annotated with human-readable unit labels for display. */
26
- type ExerciseView = ExerciseRow & {
27
- param_1_unit: string | null;
28
- param_2_unit: string | null;
309
+ /**
310
+ * A row presented for display. The raw param-type codes are dropped and the fixed
311
+ * measurement units are surfaced positionally in `units`, ordered by entry slot
312
+ * (param 1, then param 2). Positional, not semantic: param 2 is not always the load
313
+ * — some exercises reverse the slots — so the units are not labelled by role.
314
+ */
315
+ type ExerciseView = Omit<ExerciseRow, "param_1_type" | "param_2_type"> & {
316
+ units: Array<string | null>;
29
317
  };
30
318
  /** The outcome of resolving a name: a single match (or null) plus ranked candidates. */
31
319
  type ResolveResult = {
@@ -194,4 +482,4 @@ type ReadResult = {
194
482
  blocks: ReadBlock[];
195
483
  };
196
484
  //#endregion
197
- export { Advisory, BlockSpec, CommentDraft, ExerciseCreate, ExerciseRow, ExerciseSpec, ExerciseView, Id, LeaderboardSpec, ReadBlock, ReadExercise, ReadResult, ResolveResult, WorkoutDate, WorkoutSpec, blockSpecSchema, commentDraftSchema, exerciseCreateSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, idArgSchema, idSchema, leaderboardSpecSchema, parseWorkoutDate, programWorkoutResponseSchema, programsEditResponseSchema, sessionCreateResponseSchema, workoutSpecSchema };
485
+ export { Advisory, AthletePrefs, AthleteProfileSummary, AthleteUser, AthleteWorkingMax, AthleteWorkoutBlock, AthleteWorkoutExercise, AthleteWorkoutRangeArgs, AthleteWorkoutView, BlockSpec, CommentDraft, ExerciseCreate, ExerciseHistoryDetail, ExerciseHistoryListItem, ExerciseRow, ExerciseSpec, ExerciseStats, ExerciseView, Id, LeaderboardSpec, LogSetArgs, PersonalRecord, PresentedExerciseHistory, PresentedExerciseSession, ProgramWorkout, ReadBlock, ReadExercise, ReadResult, ResolveResult, UserSimple, WorkoutDate, WorkoutSpec, athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, 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 };
package/dist/index.mjs CHANGED
@@ -9,6 +9,169 @@ const idSchema = z.union([z.string(), z.number()]);
9
9
  */
10
10
  const idArgSchema = z.union([z.number().int(), z.string().regex(/^\d+$/u)]);
11
11
  //#endregion
12
+ //#region src/athlete.ts
13
+ const intLike$1 = z.union([z.number(), z.string()]);
14
+ const intLikeOrNull$1 = z.union([
15
+ z.number(),
16
+ z.string(),
17
+ z.null()
18
+ ]);
19
+ const numLikeOrNull = z.union([
20
+ z.number(),
21
+ z.string(),
22
+ z.null()
23
+ ]);
24
+ /** `/user/simple` — the identity + tenant key (numeric `id`) for any logged-in account. */
25
+ const userSimpleSchema = z.looseObject({
26
+ id: intLike$1,
27
+ roles: z.array(z.string()).optional(),
28
+ org_id: intLikeOrNull$1.optional()
29
+ });
30
+ /** `/v5/athleteProfile/summary` — lifetime training totals. Needs `use_metric` in the query. */
31
+ const athleteProfileSummarySchema = z.looseObject({
32
+ reps_sum: z.number().optional(),
33
+ volume_sum: z.number().optional(),
34
+ sessions_count: z.number().optional(),
35
+ first_logged_date: z.string().optional(),
36
+ last_logged_date: z.string().optional(),
37
+ duration_hours: z.number().optional()
38
+ });
39
+ /** `/v5/users/{id}` — the detailed athlete profile (only the fields we surface). */
40
+ const athleteUserSchema = z.looseObject({
41
+ id: intLike$1,
42
+ email: z.string().optional(),
43
+ name_first: z.string().optional(),
44
+ name_last: z.string().optional(),
45
+ username: z.string().optional(),
46
+ gender: z.string().optional(),
47
+ date_of_birth: z.string().optional(),
48
+ use_metric: z.boolean().optional()
49
+ });
50
+ /** `/1.0/athlete/prefs` — notification + display preference flags. */
51
+ const athletePrefsSchema = z.looseObject({ id: intLike$1 });
52
+ /** One item of `/2.0/athlete/workingMax` — the athlete's working max for an exercise. */
53
+ const athleteWorkingMaxSchema = z.looseObject({
54
+ exercise_id: intLike$1,
55
+ title: z.string().optional(),
56
+ param_type: intLikeOrNull$1.optional(),
57
+ value: numLikeOrNull.optional(),
58
+ type_suffix: z.string().optional(),
59
+ working_max_id: intLikeOrNull$1.optional()
60
+ });
61
+ const athleteWorkingMaxListSchema = z.array(athleteWorkingMaxSchema);
62
+ /** One item of `/v5/users/exercises/history` — an exercise the athlete has logged. */
63
+ const exerciseHistoryListItemSchema = z.looseObject({
64
+ id: intLike$1,
65
+ title: z.string(),
66
+ isCircuit: z.boolean().optional(),
67
+ prescription: z.string().optional(),
68
+ param1Type: intLikeOrNull$1.optional(),
69
+ param2Type: intLikeOrNull$1.optional()
70
+ });
71
+ const exerciseHistoryListSchema = z.array(exerciseHistoryListItemSchema);
72
+ /** A single completed set inside a history entry (`/v5/exercises/{id}/history`). */
73
+ const historySetSchema = z.looseObject({
74
+ setNumber: z.number(),
75
+ formattedValue: z.string().optional(),
76
+ rawValue1: numLikeOrNull.optional(),
77
+ rawValue2: numLikeOrNull.optional(),
78
+ savedWorkoutSetExerciseId: intLike$1.optional()
79
+ });
80
+ /** A best rep-max derived for a history entry. */
81
+ const repMaxSchema = z.looseObject({
82
+ reps: z.number(),
83
+ weight: z.number()
84
+ });
85
+ /** One performed session of an exercise (`/v5/exercises/{id}/history` → `history[]`). */
86
+ const historyEntrySchema = z.looseObject({
87
+ dateCompleted: z.string(),
88
+ notes: z.string().nullable().optional(),
89
+ isLift: z.boolean().optional(),
90
+ param1Type: intLikeOrNull$1.optional(),
91
+ param2Type: intLikeOrNull$1.optional(),
92
+ savedWorkoutSetExerciseId: intLike$1.optional(),
93
+ teamId: intLikeOrNull$1.optional(),
94
+ programWorkoutId: intLikeOrNull$1.optional(),
95
+ abr: z.string().optional(),
96
+ bestEstimated1RM: z.number().optional(),
97
+ repMaxes: z.array(repMaxSchema).optional(),
98
+ sets: z.array(historySetSchema).optional()
99
+ });
100
+ /** A lifetime PR row from `/v5/exercises/{id}/history` → `liftPRs[]`. */
101
+ const liftPRSchema = z.looseObject({
102
+ weight: z.number().optional(),
103
+ savedWorkoutSetExerciseId: intLike$1.optional(),
104
+ setNumber: z.number().optional(),
105
+ dateCompleted: z.string().optional(),
106
+ reps: z.number().optional(),
107
+ units: z.string().optional(),
108
+ isMetric: z.boolean().optional(),
109
+ description: z.string().optional()
110
+ });
111
+ /** `/v5/exercises/{id}/history` — the per-exercise PRs + session history. */
112
+ const exerciseHistoryDetailSchema = z.looseObject({
113
+ liftPRs: z.array(liftPRSchema).optional(),
114
+ singleParamPRs: z.array(z.unknown()).optional(),
115
+ history: z.array(historyEntrySchema).optional()
116
+ });
117
+ /** One item of `/v5/exercises/{id}/personalRecords` — a standards-filtered PR. */
118
+ const personalRecordSchema = z.looseObject({
119
+ id: intLike$1.optional(),
120
+ savedWorkoutSetExerciseId: intLike$1.optional(),
121
+ setNumber: z.number().optional(),
122
+ reps: z.number().optional(),
123
+ weight: z.number().optional(),
124
+ scaledWeight: z.number().optional(),
125
+ units: z.string().optional(),
126
+ isMetric: z.boolean().optional()
127
+ });
128
+ const personalRecordListSchema = z.array(personalRecordSchema);
129
+ /** `/v5/exercises/{id}/stats` — last performance + PR for an exercise. Needs `date` in the query. */
130
+ const exerciseStatsSchema = z.looseObject({
131
+ isLift: z.boolean().optional(),
132
+ lastPerformance: z.unknown().optional(),
133
+ personalRecord: z.unknown().optional()
134
+ });
135
+ /**
136
+ * One item of `/3.0/athlete/programworkout/range` — a scheduled/completed workout. The deep
137
+ * `summarizedSavedWorkout` tree is left loose: the presenter in `js` flattens it, so dto only
138
+ * pins the top-level fields the warehouse and presenter key off.
139
+ */
140
+ const programWorkoutSchema = z.looseObject({
141
+ id: intLike$1,
142
+ date: z.string().optional(),
143
+ workout_title: z.string().optional(),
144
+ program_id: intLikeOrNull$1.optional(),
145
+ program_title: z.string().optional(),
146
+ team_id: intLikeOrNull$1.optional(),
147
+ team_title: z.string().optional(),
148
+ summarizedSavedWorkout: z.unknown().optional()
149
+ });
150
+ const programWorkoutListSchema = z.array(programWorkoutSchema);
151
+ /** A `YYYY-MM-DD` date argument. The single definition reused across athlete tool inputs. */
152
+ const dateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u, "expected YYYY-MM-DD");
153
+ /** Args for the workout-range read: an inclusive `YYYY-MM-DD` window. */
154
+ const athleteWorkoutRangeArgsSchema = z.object({
155
+ startDate: dateString,
156
+ endDate: dateString
157
+ });
158
+ /**
159
+ * Args for the set-logging write. `date` (the workout's day) locates the saved
160
+ * workout via the range endpoint; `savedWorkoutSetId` picks the set to complete; `results`
161
+ * gives, per exercise in it, the entered value of each set (param 1 / param 2 by entry slot).
162
+ */
163
+ const logSetArgsSchema = z.object({
164
+ date: dateString,
165
+ savedWorkoutSetId: idArgSchema,
166
+ results: z.array(z.object({
167
+ savedWorkoutSetExerciseId: idArgSchema,
168
+ sets: z.array(z.object({
169
+ param1: z.union([z.number(), z.string()]).optional(),
170
+ param2: z.union([z.number(), z.string()]).optional()
171
+ })).min(1)
172
+ })).min(1)
173
+ });
174
+ //#endregion
12
175
  //#region src/exercise.ts
13
176
  /** Body for creating a custom exercise; extra fields the API accepts are preserved. */
14
177
  const exerciseCreateSchema = z.looseObject({
@@ -110,4 +273,4 @@ function parseWorkoutDate(s) {
110
273
  ];
111
274
  }
112
275
  //#endregion
113
- export { blockSpecSchema, commentDraftSchema, exerciseCreateSchema, exerciseLibraryResponseSchema, exerciseResponseSchema, exerciseSpecSchema, idArgSchema, idSchema, leaderboardSpecSchema, parseWorkoutDate, programWorkoutResponseSchema, programsEditResponseSchema, sessionCreateResponseSchema, workoutSpecSchema };
276
+ export { athletePrefsSchema, athleteProfileSummarySchema, athleteUserSchema, athleteWorkingMaxListSchema, athleteWorkingMaxSchema, athleteWorkoutRangeArgsSchema, blockSpecSchema, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/dto",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",