@trainheroic-unofficial/cli 3.0.1 → 3.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/README.md
CHANGED
|
@@ -84,7 +84,7 @@ trainheroic coach workout build --program 988 --date 2026-6-22 --file day.json -
|
|
|
84
84
|
validation path on bad input.
|
|
85
85
|
- Actions that touch an athlete or delete data require an explicit `--yes`:
|
|
86
86
|
`coach workout publish`, `coach workout remove`, `coach exercise forget`,
|
|
87
|
-
`coach message send`, `coach message delete`, `athlete log-set`, and
|
|
87
|
+
`coach message send`, `coach message delete`, `athlete log-set`, `athlete prescribe-set`, and
|
|
88
88
|
`coach workout build --publish`. (`coach workout build` alone creates a draft; `--publish`
|
|
89
89
|
makes it visible to athletes, which is why that combination needs `--yes`.)
|
|
90
90
|
- JSON input can be passed inline, with `--file <path>`, or piped on stdin. Inputs are
|
package/dist/cli.mjs
CHANGED
|
@@ -211,20 +211,18 @@ const logSetArgsSchema = z.object({
|
|
|
211
211
|
*/
|
|
212
212
|
const coachLogSetArgsSchema = logSetArgsSchema.extend({ athleteId: idArgSchema });
|
|
213
213
|
/**
|
|
214
|
-
* Args for the
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* positional and sequential by definition: it deliberately omits the log path's `slot` field (a
|
|
219
|
-
* sparse, slot-targeted prescription has no meaning here) by building its results off
|
|
220
|
-
* {@link loggedSetSchema} rather than {@link loggedSetWithSlotSchema}.
|
|
214
|
+
* Args for changing the logged-in athlete's prescribed targets without marking the set performed.
|
|
215
|
+
* The write replaces the exercise's whole prescription, so its sets are positional and sequential
|
|
216
|
+
* by definition: it deliberately omits the log path's `slot` field because a sparse prescription
|
|
217
|
+
* has no meaning here.
|
|
221
218
|
*/
|
|
222
|
-
const
|
|
219
|
+
const athletePrescribeSetArgsSchema = z.object({
|
|
223
220
|
date: dateString,
|
|
224
221
|
savedWorkoutSetId: idArgSchema,
|
|
225
|
-
athleteId: idArgSchema,
|
|
226
222
|
results: prescribedExerciseResultsSchema
|
|
227
223
|
});
|
|
224
|
+
/** Coach variant of {@link athletePrescribeSetArgsSchema}, with the roster athlete to update. */
|
|
225
|
+
const coachPrescribeSetArgsSchema = athletePrescribeSetArgsSchema.extend({ athleteId: idArgSchema });
|
|
228
226
|
/**
|
|
229
227
|
* Args for the coach per-athlete exercise swap: replace the exercise prescribed in one of a
|
|
230
228
|
* roster athlete's saved-workout slots with a different exercise, the API equivalent of the
|
|
@@ -1662,6 +1660,21 @@ async function logAthleteSet(client, args) {
|
|
|
1662
1660
|
};
|
|
1663
1661
|
}
|
|
1664
1662
|
/**
|
|
1663
|
+
* Set the logged-in athlete's prescribed reps/weight for one saved workout set WITHOUT marking it
|
|
1664
|
+
* performed. This is the athlete-side equivalent of editing target values in the app: it writes
|
|
1665
|
+
* `param_N_data_M` with every made/completed flag cleared and skips the set-completion PUT.
|
|
1666
|
+
*
|
|
1667
|
+
* The write replaces the selected exercise's whole prescription, so callers must pass every set
|
|
1668
|
+
* they want to keep. An omitted param is cleared rather than preserved.
|
|
1669
|
+
*/
|
|
1670
|
+
async function prescribeAthleteSet(client, args) {
|
|
1671
|
+
const r = await writeSetResults(client, { role: "athlete" }, await fetchAthleteWorkouts(client, args.date, args.date), args.savedWorkoutSetId, args.results, "prescribe");
|
|
1672
|
+
return {
|
|
1673
|
+
savedWorkoutSetId: r.savedWorkoutSetId,
|
|
1674
|
+
exercisesPrescribed: r.exercisesWritten
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1665
1678
|
* Coach "Log for Athlete": record set results for a roster athlete on their behalf, via the
|
|
1666
1679
|
* coach surface — `PUT /1.0/coach/savedworkoutsetexercise/{id}/{athleteId}` (the data write)
|
|
1667
1680
|
* then `PUT /1.0/coach/savedworkoutset/{id}/{athleteId}` (mark complete). Same two-step
|
|
@@ -1746,9 +1759,10 @@ async function swapAthleteExercise(client, args) {
|
|
|
1746
1759
|
};
|
|
1747
1760
|
}
|
|
1748
1761
|
/**
|
|
1749
|
-
* Shared set-write behind {@link logAthleteSet}, {@link
|
|
1750
|
-
* {@link prescribeForAthlete}. `target` selects the surface: `athlete`
|
|
1751
|
-
* `coach` writes `/1.0/coach/...{athleteId}` and stamps `athleteId` into
|
|
1762
|
+
* Shared set-write behind {@link logAthleteSet}, {@link prescribeAthleteSet},
|
|
1763
|
+
* {@link logForAthlete}, and {@link prescribeForAthlete}. `target` selects the surface: `athlete`
|
|
1764
|
+
* writes `/1.0/athlete/...`; `coach` writes `/1.0/coach/...{athleteId}` and stamps `athleteId` into
|
|
1765
|
+
* each body.
|
|
1752
1766
|
*
|
|
1753
1767
|
* Step 1 PUTs each exercise's per-set values to its own endpoint (the only path that actually
|
|
1754
1768
|
* stores reps and weight). `mode` decides what those values mean: `"log"` records them as a
|
|
@@ -3522,6 +3536,7 @@ Athlete — the logged-in user's own training (a coach account works too):
|
|
|
3522
3536
|
athlete leaderboard <workoutId> [--page N] [--page-size N] [--gender N]
|
|
3523
3537
|
athlete export [--out dir] [--start Y-M-D] [--end Y-M-D] [--full]
|
|
3524
3538
|
athlete log-set --date Y-M-D --set <savedWorkoutSetId> <resultsJson>|--file f --yes (logs to a PRESCRIBED workout on that date; ids from 'athlete log-targets'; each set fills the next position, add "slot":K to target the K-th; a partial log records only what you send)
|
|
3539
|
+
athlete prescribe-set --date Y-M-D --set <savedWorkoutSetId> <resultsJson>|--file f --yes (sets your PLANNED reps/weight without logging completion; replaces the selected exercise's whole prescription, so pass every set/value to keep)
|
|
3525
3540
|
athlete log-session --date Y-M-D <exercisesJson>|--file f --yes (log OFF-PLAN work with no prescription — creates/reuses a personal session for the date, then logs it; exerciseIds from 'athlete exercises')
|
|
3526
3541
|
athlete session-remove --id <programWorkoutId> --date Y-M-D --yes (delete a stray PERSONAL session; the id is the session 'id' from 'athlete workouts')
|
|
3527
3542
|
athlete swap-exercise --set-exercise <savedWorkoutSetExerciseId> --exercise <exerciseId> --yes (substitute one prescribed exercise in a COACH-SCHEDULED slot for a different one — your copy only; slot id from 'athlete log-targets', exerciseId from 'athlete exercises')
|
|
@@ -3869,6 +3884,29 @@ async function cmdAthleteLogSet(client, a) {
|
|
|
3869
3884
|
results: toSetResults(args.results)
|
|
3870
3885
|
}));
|
|
3871
3886
|
}
|
|
3887
|
+
const ATHLETE_PRESCRIBE_SET_USAGE = "athlete prescribe-set --date Y-M-D --set <id> <resultsJson> --yes";
|
|
3888
|
+
async function cmdAthletePrescribeSet(client, a) {
|
|
3889
|
+
const { values, positionals } = parse(a, {
|
|
3890
|
+
date: { type: "string" },
|
|
3891
|
+
set: { type: "string" },
|
|
3892
|
+
file: { type: "string" },
|
|
3893
|
+
yes: { type: "boolean" }
|
|
3894
|
+
});
|
|
3895
|
+
const date = isoDate(need(values.date, ATHLETE_PRESCRIBE_SET_USAGE), "--date");
|
|
3896
|
+
const savedWorkoutSetId = toInt(need(values.set, ATHLETE_PRESCRIBE_SET_USAGE), "--set");
|
|
3897
|
+
const results = await jsonInput(positionals[0], values.file);
|
|
3898
|
+
const args = validate(athletePrescribeSetArgsSchema, {
|
|
3899
|
+
date,
|
|
3900
|
+
savedWorkoutSetId,
|
|
3901
|
+
results
|
|
3902
|
+
}, "athlete prescribe-set args");
|
|
3903
|
+
if (values.yes !== true) fail(`changing the prescribed values for set ${savedWorkoutSetId} requires --yes.`);
|
|
3904
|
+
return out(await prescribeAthleteSet(client, {
|
|
3905
|
+
date: args.date,
|
|
3906
|
+
savedWorkoutSetId,
|
|
3907
|
+
results: toSetResults(args.results)
|
|
3908
|
+
}));
|
|
3909
|
+
}
|
|
3872
3910
|
const LOG_SESSION_USAGE = "athlete log-session --date Y-M-D <exercisesJson>|--file f --yes";
|
|
3873
3911
|
/** Map validated logSession exercises to the SDK's SessionExercise[] (ids coerced, slots trimmed). */
|
|
3874
3912
|
function toSessionExercises(exercises) {
|
|
@@ -4053,10 +4091,11 @@ async function cmdAthlete(client, rest) {
|
|
|
4053
4091
|
case "export": return cmdAthleteExport(client, a);
|
|
4054
4092
|
case "log-targets": return cmdAthleteLogTargets(client, a);
|
|
4055
4093
|
case "log-set": return cmdAthleteLogSet(client, a);
|
|
4094
|
+
case "prescribe-set": return cmdAthletePrescribeSet(client, a);
|
|
4056
4095
|
case "log-session": return cmdAthleteLogSession(client, a);
|
|
4057
4096
|
case "session-remove": return cmdAthleteSessionRemove(client, a);
|
|
4058
4097
|
case "swap-exercise": return cmdAthleteSwapExercise(client, a);
|
|
4059
|
-
default: return fail("usage: trainheroic athlete <whoami|profile|prefs|workouts|log-targets|exercises|history|prs|stats|working-maxes|leaderboard|export|log-set|log-session|session-remove|swap-exercise>");
|
|
4098
|
+
default: return fail("usage: trainheroic athlete <whoami|profile|prefs|workouts|log-targets|exercises|history|prs|stats|working-maxes|leaderboard|export|log-set|prescribe-set|log-session|session-remove|swap-exercise>");
|
|
4060
4099
|
}
|
|
4061
4100
|
}
|
|
4062
4101
|
async function cmdSkill(rest) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trainheroic-unofficial/cli",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^4.4.3",
|
|
24
|
-
"@trainheroic-unofficial/dto": "3.0
|
|
25
|
-
"@trainheroic-unofficial/js": "3.0
|
|
24
|
+
"@trainheroic-unofficial/dto": "3.1.0",
|
|
25
|
+
"@trainheroic-unofficial/js": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^26.2.0",
|
|
@@ -65,6 +65,7 @@ on a 401/403. Start with `$TH athlete whoami` to confirm auth and get your `id`.
|
|
|
65
65
|
| Download all historicals to JSON | `$TH athlete export [--out dir] [--full]` |
|
|
66
66
|
| Log ids for a scheduled workout | `$TH athlete log-targets --start Y-M-D --end Y-M-D [--program <title>]` |
|
|
67
67
|
| Log completed set results (gated) | `$TH athlete log-set --date Y-M-D --set <id> ... --yes` |
|
|
68
|
+
| Set planned reps/weight (gated) | `$TH athlete prescribe-set --date Y-M-D --set <id> ... --yes` |
|
|
68
69
|
| Log an off-plan session (gated) | `$TH athlete log-session --date Y-M-D '[{"exerciseId":N,"sets":[...]}]' --yes` |
|
|
69
70
|
| Swap a prescribed exercise (gated) | `$TH athlete swap-exercise --set-exercise <sweId> --exercise <exerciseId> --yes` |
|
|
70
71
|
| Remove a stray personal session | `$TH athlete session-remove --id <programWorkoutId> --date Y-M-D --yes` |
|
|
@@ -131,6 +132,21 @@ $TH athlete log-set --date 2026-06-01 --set 1593305783 --yes \
|
|
|
131
132
|
check the result landed as intended. `param1`/`param2` are the entered values by entry slot
|
|
132
133
|
(check the exercise's positional units first).
|
|
133
134
|
|
|
135
|
+
### Setting planned weight without logging
|
|
136
|
+
|
|
137
|
+
Use `$TH athlete prescribe-set` when you know the target reps or weight but have not performed the
|
|
138
|
+
set. It writes the prescription with every completion flag clear, so the workout remains open and
|
|
139
|
+
nothing is added to exercise history:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
$TH athlete prescribe-set --date 2026-06-01 --set 1593305783 --yes \
|
|
143
|
+
'[{"savedWorkoutSetExerciseId": 2712369448, "sets": [{"param1": 5, "param2": 225}]}]'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The write replaces that exercise's whole prescription. Include every planned set and every value
|
|
147
|
+
you want to keep; an omitted parameter is cleared. Get both ids from `athlete log-targets`, just as
|
|
148
|
+
for `log-set`.
|
|
149
|
+
|
|
134
150
|
### Logging an off-plan session
|
|
135
151
|
|
|
136
152
|
When you trained something a coach never scheduled (accessory work, a makeup lift, an
|
|
@@ -87,7 +87,8 @@ account) expose:
|
|
|
87
87
|
- Live reads: `athlete_whoami`, `athlete_profile`, `athlete_prefs`, `athlete_workouts`,
|
|
88
88
|
`athlete_exercises`, `athlete_exercise_history`, `athlete_personal_records`,
|
|
89
89
|
`athlete_exercise_stats`, `athlete_working_maxes`, `athlete_leaderboard`.
|
|
90
|
-
- Gated
|
|
90
|
+
- Gated writes include `athlete_log_set` for performed results and `athlete_prescribe_set` for
|
|
91
|
+
planned reps/weight that must not mark a set completed (elicitation or `confirm:true`).
|
|
91
92
|
|
|
92
93
|
## Warehouse tools (hosted worker only, D1-backed)
|
|
93
94
|
|