@trainheroic-unofficial/cli 3.2.0 → 3.3.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/cli.mjs +351 -4
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -32,7 +32,8 @@ z.looseObject({
|
|
|
32
32
|
roles: z.array(z.string()).optional(),
|
|
33
33
|
org_id: intLikeOrNull$1.optional()
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
/** `/v5/athleteProfile/summary` — lifetime training totals. Needs `use_metric` in the query. */
|
|
36
|
+
const athleteProfileSummarySchema = z.looseObject({
|
|
36
37
|
reps_sum: z.number().optional(),
|
|
37
38
|
volume_sum: z.number().optional(),
|
|
38
39
|
sessions_count: z.number().optional(),
|
|
@@ -40,7 +41,8 @@ z.looseObject({
|
|
|
40
41
|
last_logged_date: z.string().optional(),
|
|
41
42
|
duration_hours: z.number().optional()
|
|
42
43
|
});
|
|
43
|
-
|
|
44
|
+
/** `/v5/users/{id}` — the detailed athlete profile (only the fields we surface). */
|
|
45
|
+
const athleteUserSchema = z.looseObject({
|
|
44
46
|
id: intLike$1,
|
|
45
47
|
email: z.string().optional(),
|
|
46
48
|
name_first: z.string().optional(),
|
|
@@ -110,7 +112,8 @@ const liftPRSchema = z.looseObject({
|
|
|
110
112
|
isMetric: z.boolean().optional(),
|
|
111
113
|
description: z.string().optional()
|
|
112
114
|
});
|
|
113
|
-
|
|
115
|
+
/** `/v5/exercises/{id}/history` — the per-exercise PRs + session history. */
|
|
116
|
+
const exerciseHistoryDetailSchema = z.looseObject({
|
|
114
117
|
liftPRs: z.array(liftPRSchema).optional(),
|
|
115
118
|
singleParamPRs: z.array(z.unknown()).optional(),
|
|
116
119
|
history: z.array(historyEntrySchema).optional()
|
|
@@ -147,7 +150,7 @@ const programWorkoutSchema = z.looseObject({
|
|
|
147
150
|
team_title: z.string().optional(),
|
|
148
151
|
summarizedSavedWorkout: z.unknown().optional()
|
|
149
152
|
});
|
|
150
|
-
z.array(programWorkoutSchema);
|
|
153
|
+
const programWorkoutListSchema = z.array(programWorkoutSchema);
|
|
151
154
|
/** A `YYYY-MM-DD` date argument. The single definition reused across athlete tool inputs. */
|
|
152
155
|
const dateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u, "expected YYYY-MM-DD");
|
|
153
156
|
z.object({
|
|
@@ -263,8 +266,161 @@ const athleteSessionRemoveArgsSchema = z.object({
|
|
|
263
266
|
programWorkoutId: idArgSchema,
|
|
264
267
|
date: dateString
|
|
265
268
|
});
|
|
269
|
+
const presentedNullNumber = z.number().nullable();
|
|
270
|
+
const presentedNullString = z.string().nullable();
|
|
271
|
+
/** Flattened exercise within a presented workout: prescriptions, logged results, units. */
|
|
272
|
+
const athleteWorkoutExerciseSchema = z.object({
|
|
273
|
+
exerciseId: presentedNullNumber,
|
|
274
|
+
title: z.string(),
|
|
275
|
+
instruction: presentedNullString,
|
|
276
|
+
units: z.array(presentedNullString),
|
|
277
|
+
prescribed: z.array(z.string()),
|
|
278
|
+
performed: z.array(z.string())
|
|
279
|
+
});
|
|
280
|
+
const athleteWorkoutBlockSchema = z.object({
|
|
281
|
+
order: z.number(),
|
|
282
|
+
title: presentedNullString,
|
|
283
|
+
instruction: presentedNullString,
|
|
284
|
+
isTest: z.boolean(),
|
|
285
|
+
exercises: z.array(athleteWorkoutExerciseSchema)
|
|
286
|
+
});
|
|
287
|
+
const athleteWorkoutViewSchema = z.object({
|
|
288
|
+
id: presentedNullNumber,
|
|
289
|
+
date: z.string(),
|
|
290
|
+
title: z.string(),
|
|
291
|
+
program: presentedNullString,
|
|
292
|
+
team: presentedNullString,
|
|
293
|
+
instruction: presentedNullString,
|
|
294
|
+
logged: z.boolean(),
|
|
295
|
+
personal: z.boolean(),
|
|
296
|
+
blocks: z.array(athleteWorkoutBlockSchema)
|
|
297
|
+
});
|
|
298
|
+
const athleteWorkoutSummarySchema = z.object({
|
|
299
|
+
id: presentedNullNumber,
|
|
300
|
+
date: z.string(),
|
|
301
|
+
title: z.string(),
|
|
302
|
+
program: presentedNullString,
|
|
303
|
+
team: presentedNullString,
|
|
304
|
+
logged: z.boolean(),
|
|
305
|
+
personal: z.boolean(),
|
|
306
|
+
exerciseCount: z.number().int().nonnegative(),
|
|
307
|
+
performedCount: z.number().int().nonnegative()
|
|
308
|
+
});
|
|
309
|
+
z.union([
|
|
310
|
+
z.array(athleteWorkoutSummarySchema),
|
|
311
|
+
z.array(athleteWorkoutViewSchema),
|
|
312
|
+
programWorkoutListSchema
|
|
313
|
+
]);
|
|
314
|
+
z.looseObject({
|
|
315
|
+
summary: athleteProfileSummarySchema,
|
|
316
|
+
user: athleteUserSchema
|
|
317
|
+
});
|
|
318
|
+
z.array(z.object({
|
|
319
|
+
id: z.union([z.number(), z.string()]),
|
|
320
|
+
title: z.string(),
|
|
321
|
+
isCircuit: z.boolean(),
|
|
322
|
+
units: z.array(presentedNullString)
|
|
323
|
+
}));
|
|
324
|
+
const coachAthleteExerciseSchema = z.object({
|
|
325
|
+
exerciseId: presentedNullNumber,
|
|
326
|
+
title: z.string(),
|
|
327
|
+
summary: presentedNullString,
|
|
328
|
+
completed: z.boolean()
|
|
329
|
+
});
|
|
330
|
+
const coachAthleteSessionSchema = z.object({
|
|
331
|
+
workoutId: presentedNullNumber,
|
|
332
|
+
savedWorkoutId: presentedNullNumber,
|
|
333
|
+
title: z.string(),
|
|
334
|
+
logged: z.boolean(),
|
|
335
|
+
completed: z.boolean(),
|
|
336
|
+
rpe: presentedNullNumber,
|
|
337
|
+
durationMin: presentedNullNumber,
|
|
338
|
+
notes: presentedNullString,
|
|
339
|
+
exercises: z.array(coachAthleteExerciseSchema)
|
|
340
|
+
});
|
|
341
|
+
z.object({
|
|
342
|
+
athleteId: presentedNullNumber,
|
|
343
|
+
athleteName: presentedNullString,
|
|
344
|
+
year: z.number().int(),
|
|
345
|
+
month: z.number().int(),
|
|
346
|
+
sessions: z.array(coachAthleteSessionSchema)
|
|
347
|
+
});
|
|
348
|
+
const rosterActivityRowSchema = z.object({
|
|
349
|
+
athleteId: z.number(),
|
|
350
|
+
sessionsCount: presentedNullNumber,
|
|
351
|
+
firstLoggedDate: presentedNullString,
|
|
352
|
+
lastLoggedDate: presentedNullString,
|
|
353
|
+
totalReps: presentedNullNumber,
|
|
354
|
+
totalVolume: presentedNullNumber
|
|
355
|
+
});
|
|
356
|
+
const teamVolumeAthleteSchema = z.object({
|
|
357
|
+
athleteId: z.number(),
|
|
358
|
+
name: presentedNullString,
|
|
359
|
+
sessions: z.number(),
|
|
360
|
+
reps: z.number(),
|
|
361
|
+
volume: z.number(),
|
|
362
|
+
firstLoggedDate: presentedNullString,
|
|
363
|
+
lastLoggedDate: presentedNullString
|
|
364
|
+
});
|
|
365
|
+
z.object({
|
|
366
|
+
window: z.object({
|
|
367
|
+
start: z.string(),
|
|
368
|
+
end: z.string()
|
|
369
|
+
}),
|
|
370
|
+
athletes: z.array(teamVolumeAthleteSchema),
|
|
371
|
+
totals: z.object({
|
|
372
|
+
athletes: z.number(),
|
|
373
|
+
sessions: z.number(),
|
|
374
|
+
reps: z.number(),
|
|
375
|
+
volume: z.number()
|
|
376
|
+
})
|
|
377
|
+
});
|
|
378
|
+
z.array(rosterActivityRowSchema);
|
|
379
|
+
const presentedExerciseSessionSchema = z.object({
|
|
380
|
+
date: z.string(),
|
|
381
|
+
abr: presentedNullString,
|
|
382
|
+
estimated1RM: presentedNullNumber,
|
|
383
|
+
sets: z.array(z.object({
|
|
384
|
+
setNumber: z.number(),
|
|
385
|
+
value: presentedNullString
|
|
386
|
+
}))
|
|
387
|
+
});
|
|
388
|
+
const presentedExerciseHistorySchema = z.object({
|
|
389
|
+
liftPRs: z.array(z.object({
|
|
390
|
+
description: presentedNullString,
|
|
391
|
+
reps: presentedNullNumber,
|
|
392
|
+
weight: presentedNullNumber,
|
|
393
|
+
units: presentedNullString,
|
|
394
|
+
date: presentedNullString
|
|
395
|
+
})),
|
|
396
|
+
sessions: z.array(presentedExerciseSessionSchema)
|
|
397
|
+
});
|
|
398
|
+
z.union([presentedExerciseHistorySchema, exerciseHistoryDetailSchema]);
|
|
266
399
|
//#endregion
|
|
267
400
|
//#region ../dto/src/exercise.ts
|
|
401
|
+
/**
|
|
402
|
+
* A row presented for display. The raw param-type codes are dropped and the fixed
|
|
403
|
+
* measurement units are surfaced positionally in `units`, ordered by entry slot
|
|
404
|
+
* (param 1, then param 2). Positional, not semantic: param 2 is not always the load
|
|
405
|
+
* — some exercises reverse the slots — so the units are not labelled by role.
|
|
406
|
+
*/
|
|
407
|
+
const exerciseViewSchema = z.object({
|
|
408
|
+
id: z.number(),
|
|
409
|
+
title: z.string(),
|
|
410
|
+
can_edit: z.number(),
|
|
411
|
+
user_id: z.number().nullable(),
|
|
412
|
+
use_count: z.number(),
|
|
413
|
+
units: z.array(z.string().nullable())
|
|
414
|
+
});
|
|
415
|
+
z.looseObject({
|
|
416
|
+
id: idSchema,
|
|
417
|
+
title: z.string(),
|
|
418
|
+
units: z.array(z.string().nullable())
|
|
419
|
+
});
|
|
420
|
+
z.object({
|
|
421
|
+
match: exerciseViewSchema.nullable(),
|
|
422
|
+
candidates: z.array(exerciseViewSchema)
|
|
423
|
+
});
|
|
268
424
|
/** Body for creating a custom exercise; extra fields the API accepts are preserved. */
|
|
269
425
|
const exerciseCreateSchema = z.looseObject({
|
|
270
426
|
title: z.string().min(1),
|
|
@@ -324,6 +480,197 @@ const teamPublishPatchSchema = z.object({
|
|
|
324
480
|
pub_timezone: z.string().optional()
|
|
325
481
|
}).refine((v) => v.pub_enabled !== void 0 || v.pub_days !== void 0 || v.pub_time !== void 0 || v.pub_timezone !== void 0, { message: "Provide at least one pub_* field" });
|
|
326
482
|
//#endregion
|
|
483
|
+
//#region ../dto/src/tool-output.ts
|
|
484
|
+
const nullableNumber = z.number().nullable();
|
|
485
|
+
const nullableString = z.string().nullable();
|
|
486
|
+
const truncationMarkerSchema = z.looseObject({
|
|
487
|
+
field: z.string().optional(),
|
|
488
|
+
returned: z.number().int().nonnegative().optional(),
|
|
489
|
+
total: z.number().int().nonnegative(),
|
|
490
|
+
omitted: z.number().int().nonnegative(),
|
|
491
|
+
hint: z.string()
|
|
492
|
+
});
|
|
493
|
+
/** Dedicated budget-fallback envelope. Never the natural tool shape. */
|
|
494
|
+
const truncatedOutputSchema = z.looseObject({
|
|
495
|
+
preview: z.string().optional(),
|
|
496
|
+
items: z.array(z.json()).optional(),
|
|
497
|
+
__truncated: truncationMarkerSchema
|
|
498
|
+
});
|
|
499
|
+
/**
|
|
500
|
+
* Add the shared size-budget fallback to a tool's natural result shape.
|
|
501
|
+
* Truncation is a dedicated `{ items|preview, __truncated }` envelope, so it cannot
|
|
502
|
+
* validate as the natural object and drop the marker.
|
|
503
|
+
*/
|
|
504
|
+
function toolOutputSchema(schema) {
|
|
505
|
+
return z.union([truncatedOutputSchema, schema]);
|
|
506
|
+
}
|
|
507
|
+
toolOutputSchema(z.json());
|
|
508
|
+
const logSetTargetOutputSchema = z.object({
|
|
509
|
+
date: z.string(),
|
|
510
|
+
workoutTitle: z.string(),
|
|
511
|
+
program: nullableString,
|
|
512
|
+
programId: nullableNumber,
|
|
513
|
+
team: nullableString,
|
|
514
|
+
teamId: nullableNumber,
|
|
515
|
+
savedWorkoutSetId: z.number(),
|
|
516
|
+
setTitle: nullableString,
|
|
517
|
+
exercises: z.array(z.object({
|
|
518
|
+
savedWorkoutSetExerciseId: z.number(),
|
|
519
|
+
title: z.string(),
|
|
520
|
+
units: z.array(nullableString),
|
|
521
|
+
prescribed: z.array(z.string()),
|
|
522
|
+
performed: z.array(z.string())
|
|
523
|
+
}))
|
|
524
|
+
});
|
|
525
|
+
z.union([z.array(logSetTargetOutputSchema), programWorkoutListSchema]);
|
|
526
|
+
z.object({
|
|
527
|
+
draft: z.literal(true),
|
|
528
|
+
note: z.string(),
|
|
529
|
+
would_POST: z.string(),
|
|
530
|
+
payload: z.json()
|
|
531
|
+
});
|
|
532
|
+
z.looseObject({
|
|
533
|
+
status: z.enum(["sent", "logged"]),
|
|
534
|
+
reference: z.string().optional(),
|
|
535
|
+
note: z.string()
|
|
536
|
+
});
|
|
537
|
+
z.looseObject({ removed: z.union([z.boolean(), z.number()]) });
|
|
538
|
+
z.object({
|
|
539
|
+
removed: z.literal(true),
|
|
540
|
+
programWorkoutId: z.number(),
|
|
541
|
+
date: z.string()
|
|
542
|
+
});
|
|
543
|
+
z.object({
|
|
544
|
+
invited: z.literal(true),
|
|
545
|
+
teamId: z.number(),
|
|
546
|
+
result: z.json().optional()
|
|
547
|
+
});
|
|
548
|
+
z.object({
|
|
549
|
+
savedWorkoutSetId: z.number(),
|
|
550
|
+
exercisesLogged: z.number().int().nonnegative(),
|
|
551
|
+
setCompleted: z.boolean()
|
|
552
|
+
});
|
|
553
|
+
z.object({
|
|
554
|
+
savedWorkoutSetId: z.number(),
|
|
555
|
+
exercisesPrescribed: z.number().int().nonnegative()
|
|
556
|
+
});
|
|
557
|
+
z.object({
|
|
558
|
+
savedWorkoutSetExerciseId: z.number(),
|
|
559
|
+
athleteId: nullableNumber,
|
|
560
|
+
newExerciseId: z.number(),
|
|
561
|
+
newExerciseTitle: nullableString,
|
|
562
|
+
originalTeamExerciseId: nullableNumber
|
|
563
|
+
});
|
|
564
|
+
const sessionLogSetOutputSchema = z.object({
|
|
565
|
+
savedWorkoutSetId: z.number(),
|
|
566
|
+
exercisesLogged: z.number().int().nonnegative()
|
|
567
|
+
});
|
|
568
|
+
z.object({
|
|
569
|
+
date: z.string(),
|
|
570
|
+
created: z.boolean(),
|
|
571
|
+
sets: z.array(sessionLogSetOutputSchema),
|
|
572
|
+
scheduledAlternatives: z.array(z.object({
|
|
573
|
+
exerciseId: z.number(),
|
|
574
|
+
title: z.string(),
|
|
575
|
+
program: nullableString,
|
|
576
|
+
workoutTitle: z.string(),
|
|
577
|
+
savedWorkoutSetId: z.number(),
|
|
578
|
+
savedWorkoutSetExerciseId: z.number()
|
|
579
|
+
})).optional()
|
|
580
|
+
});
|
|
581
|
+
z.object({
|
|
582
|
+
programWorkoutId: z.number(),
|
|
583
|
+
workoutId: z.number(),
|
|
584
|
+
savedWorkoutId: z.number(),
|
|
585
|
+
groupId: z.number(),
|
|
586
|
+
date: z.string()
|
|
587
|
+
});
|
|
588
|
+
const workoutReadExerciseOutputSchema = z.object({
|
|
589
|
+
order: z.number(),
|
|
590
|
+
title: z.string(),
|
|
591
|
+
reps: z.array(z.string()),
|
|
592
|
+
primaryUnit: nullableString,
|
|
593
|
+
load: z.array(z.string()),
|
|
594
|
+
loadUnit: nullableString,
|
|
595
|
+
instruction: z.string()
|
|
596
|
+
});
|
|
597
|
+
const workoutReadBlockOutputSchema = z.object({
|
|
598
|
+
order: z.number(),
|
|
599
|
+
title: z.string(),
|
|
600
|
+
instruction: z.string(),
|
|
601
|
+
leaderboard: nullableString,
|
|
602
|
+
exercises: z.array(workoutReadExerciseOutputSchema)
|
|
603
|
+
});
|
|
604
|
+
const workoutReadOutputSchema = z.object({
|
|
605
|
+
pwId: z.number(),
|
|
606
|
+
date: z.string(),
|
|
607
|
+
published: z.json().optional(),
|
|
608
|
+
instruction: z.string(),
|
|
609
|
+
blocks: z.array(workoutReadBlockOutputSchema)
|
|
610
|
+
});
|
|
611
|
+
z.object({
|
|
612
|
+
pwId: z.number(),
|
|
613
|
+
workoutId: z.number(),
|
|
614
|
+
programId: z.number(),
|
|
615
|
+
published: z.literal(false),
|
|
616
|
+
advisories: z.object({
|
|
617
|
+
notes: z.array(z.string()),
|
|
618
|
+
warnings: z.array(z.string())
|
|
619
|
+
}),
|
|
620
|
+
readback: workoutReadOutputSchema.nullable(),
|
|
621
|
+
note: z.string()
|
|
622
|
+
});
|
|
623
|
+
z.object({
|
|
624
|
+
published: z.number(),
|
|
625
|
+
readback: workoutReadOutputSchema,
|
|
626
|
+
note: z.string()
|
|
627
|
+
});
|
|
628
|
+
z.object({
|
|
629
|
+
sent: z.literal(true),
|
|
630
|
+
comment: z.json()
|
|
631
|
+
});
|
|
632
|
+
z.object({
|
|
633
|
+
deleted: z.literal(true),
|
|
634
|
+
response: z.json().optional()
|
|
635
|
+
});
|
|
636
|
+
z.object({ deleted: z.number() });
|
|
637
|
+
z.object({ forgotten: z.number() });
|
|
638
|
+
z.looseObject({ id: z.union([z.number(), z.string()]) });
|
|
639
|
+
const mainLiftPrOutputSchema = z.object({
|
|
640
|
+
family: z.enum([
|
|
641
|
+
"cleanjerk",
|
|
642
|
+
"snatch",
|
|
643
|
+
"deadlift",
|
|
644
|
+
"squat",
|
|
645
|
+
"bench",
|
|
646
|
+
"overhead"
|
|
647
|
+
]),
|
|
648
|
+
label: z.string(),
|
|
649
|
+
exerciseId: nullableNumber,
|
|
650
|
+
title: nullableString,
|
|
651
|
+
weight: nullableNumber,
|
|
652
|
+
reps: nullableNumber,
|
|
653
|
+
units: nullableString,
|
|
654
|
+
date: nullableString
|
|
655
|
+
});
|
|
656
|
+
z.object({
|
|
657
|
+
athleteId: z.number(),
|
|
658
|
+
athleteName: nullableString,
|
|
659
|
+
prs: z.array(mainLiftPrOutputSchema)
|
|
660
|
+
});
|
|
661
|
+
z.object({
|
|
662
|
+
containerId: z.number(),
|
|
663
|
+
programId: z.number(),
|
|
664
|
+
title: z.string(),
|
|
665
|
+
kind: z.enum(["calendar", "fixed"]),
|
|
666
|
+
requestedName: z.string(),
|
|
667
|
+
nameApplied: z.boolean()
|
|
668
|
+
});
|
|
669
|
+
z.object({
|
|
670
|
+
programId: z.number(),
|
|
671
|
+
containerId: nullableNumber
|
|
672
|
+
});
|
|
673
|
+
//#endregion
|
|
327
674
|
//#region ../dto/src/workout.ts
|
|
328
675
|
/** A single exercise prescription inside a block. */
|
|
329
676
|
const exerciseSpecSchema = z.object({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^4.4.3",
|
|
24
|
-
"@trainheroic-unofficial/dto": "3.
|
|
25
|
-
"@trainheroic-unofficial/js": "3.
|
|
24
|
+
"@trainheroic-unofficial/dto": "3.3.0",
|
|
25
|
+
"@trainheroic-unofficial/js": "3.3.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^26.2.0",
|
|
29
29
|
"tsdown": "^0.22.14",
|
|
30
|
-
"tsx": "^4.23.
|
|
30
|
+
"tsx": "^4.23.12",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vitest": "^4.1.10"
|
|
33
33
|
},
|