@trainheroic-unofficial/js 3.6.0 → 3.7.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 +14 -7
- package/dist/index.d.mts +192 -180
- package/dist/index.mjs +256 -159
- package/dist/node.d.mts +3 -4
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,8 @@ type RequestBodySummary = {
|
|
|
12
12
|
type: "object";
|
|
13
13
|
keys: string[];
|
|
14
14
|
values?: Record<string, JsonScalar>;
|
|
15
|
+
arrayLengths?: Record<string, number>;
|
|
16
|
+
dateSpanDays?: number;
|
|
15
17
|
} | {
|
|
16
18
|
type: "boolean" | "number" | "other" | "string";
|
|
17
19
|
};
|
|
@@ -19,8 +21,10 @@ type TrainHeroicHttpErrorDiagnostics = {
|
|
|
19
21
|
requestBody?: unknown;
|
|
20
22
|
responseBody?: unknown;
|
|
21
23
|
};
|
|
24
|
+
/** Format a bounded provider diagnostic for an in-band tool or SDK error. */
|
|
25
|
+
export declare function trainHeroicApiErrorMessage(label: string, status: number, responseBody: unknown): string;
|
|
22
26
|
/** A final non-2xx response plus bounded, telemetry-safe request and response diagnostics. */
|
|
23
|
-
declare class TrainHeroicHttpError extends Error {
|
|
27
|
+
export declare class TrainHeroicHttpError extends Error {
|
|
24
28
|
readonly name = "TrainHeroicHttpError";
|
|
25
29
|
readonly method: string;
|
|
26
30
|
readonly status: number;
|
|
@@ -31,16 +35,22 @@ declare class TrainHeroicHttpError extends Error {
|
|
|
31
35
|
}
|
|
32
36
|
type TrainHeroicHttpErrorHandler = (error: TrainHeroicHttpError) => void | PromiseLike<void>;
|
|
33
37
|
//#endregion
|
|
38
|
+
//#region src/transport.d.ts
|
|
39
|
+
/** The HTTP seam used by the SDK. It defaults to global `fetch` and stays injectable for hosts. */
|
|
40
|
+
type TrainHeroicTransport = (url: string, init: RequestInit) => Promise<Response>;
|
|
41
|
+
//#endregion
|
|
34
42
|
//#region src/auth.d.ts
|
|
35
|
-
type TrainHeroicSession = {
|
|
43
|
+
export type TrainHeroicSession = {
|
|
36
44
|
thUserId: number;
|
|
37
45
|
sessionId: string;
|
|
38
46
|
scope: string;
|
|
39
47
|
role: string;
|
|
40
48
|
};
|
|
41
|
-
type LoginOptions = {
|
|
49
|
+
export type LoginOptions = {
|
|
42
50
|
/** Called for every non-2xx login response; callback failures never change the result. */
|
|
43
51
|
onHttpError?: TrainHeroicHttpErrorHandler;
|
|
52
|
+
/** Override HTTP dispatch while retaining the SDK's request and response behavior. */
|
|
53
|
+
transport?: TrainHeroicTransport;
|
|
44
54
|
};
|
|
45
55
|
/**
|
|
46
56
|
* Authenticate against TrainHeroic. Returns the session bundle, or null on bad
|
|
@@ -48,25 +58,25 @@ type LoginOptions = {
|
|
|
48
58
|
* the Phase 0 spike: no refresh_token, no api_token, no TTL). The 48-char session_id
|
|
49
59
|
* is sent as the `session-token` header and works against both API hosts.
|
|
50
60
|
*/
|
|
51
|
-
declare function loginTrainHeroic(email: string, password: string, options?: LoginOptions): Promise<TrainHeroicSession | null>;
|
|
61
|
+
export declare function loginTrainHeroic(email: string, password: string, options?: LoginOptions): Promise<TrainHeroicSession | null>;
|
|
52
62
|
//#endregion
|
|
53
63
|
//#region src/client.d.ts
|
|
54
|
-
declare class TrainHeroicAuthError extends Error {
|
|
64
|
+
export declare class TrainHeroicAuthError extends Error {
|
|
55
65
|
name: string;
|
|
56
66
|
}
|
|
57
|
-
type ApiBase = "coach" | "apis";
|
|
58
|
-
type RequestOptions = {
|
|
67
|
+
export type ApiBase = "coach" | "apis";
|
|
68
|
+
export type RequestOptions = {
|
|
59
69
|
body?: unknown;
|
|
60
70
|
base?: ApiBase;
|
|
61
71
|
/** Final non-2xx statuses the caller handles as part of normal control flow. */
|
|
62
72
|
expectedStatuses?: readonly number[];
|
|
63
73
|
};
|
|
64
|
-
type ClientResult<T = unknown> = {
|
|
74
|
+
export type ClientResult<T = unknown> = {
|
|
65
75
|
status: number;
|
|
66
76
|
ok: boolean;
|
|
67
77
|
data: T;
|
|
68
78
|
};
|
|
69
|
-
type ClientOptions = {
|
|
79
|
+
export type ClientOptions = {
|
|
70
80
|
/**
|
|
71
81
|
* Called with each newly acquired session token — the cold login and the post-401 re-login
|
|
72
82
|
* both fire it. Callers that outlive the client (the hosted Worker's per-request factory, the
|
|
@@ -81,6 +91,8 @@ type ClientOptions = {
|
|
|
81
91
|
* failures never change the API result returned to the caller.
|
|
82
92
|
*/
|
|
83
93
|
onHttpError?: TrainHeroicHttpErrorHandler;
|
|
94
|
+
/** Override HTTP dispatch while retaining authentication, retry, and parsing behavior. */
|
|
95
|
+
transport?: TrainHeroicTransport;
|
|
84
96
|
};
|
|
85
97
|
/**
|
|
86
98
|
* Authenticated TrainHeroic API client. Holds the credentials (on the hosted Worker, from the
|
|
@@ -93,7 +105,7 @@ type ClientOptions = {
|
|
|
93
105
|
* wherever clients are short-lived — the hosted Worker builds one per HTTP request, and each CLI
|
|
94
106
|
* invocation is a fresh process — because otherwise every operation replays the password.
|
|
95
107
|
*/
|
|
96
|
-
declare class TrainHeroicClient {
|
|
108
|
+
export declare class TrainHeroicClient {
|
|
97
109
|
#private;
|
|
98
110
|
constructor(email: string, password: string, sessionId?: string | null, options?: ClientOptions);
|
|
99
111
|
get sessionId(): string | null;
|
|
@@ -106,7 +118,7 @@ declare class TrainHeroicClient {
|
|
|
106
118
|
* Never throws: callers keep working via defensive coercion. This only surfaces a signal
|
|
107
119
|
* when TrainHeroic renames or drops a field we read.
|
|
108
120
|
*/
|
|
109
|
-
declare function checkResponse(schema: ZodType, data: unknown, label: string): void;
|
|
121
|
+
export declare function checkResponse(schema: ZodType, data: unknown, label: string): void;
|
|
110
122
|
//#endregion
|
|
111
123
|
//#region src/exercise-util.d.ts
|
|
112
124
|
/**
|
|
@@ -115,62 +127,62 @@ declare function checkResponse(schema: ZodType, data: unknown, label: string): v
|
|
|
115
127
|
* resolve/search surface it to stop callers picking, say, the miles "Run" for a
|
|
116
128
|
* metric workout. Keep in sync with the workout builder's unit table.
|
|
117
129
|
*/
|
|
118
|
-
declare const PARAM_UNIT: Readonly<Record<number, string | null>>;
|
|
119
|
-
declare const PARAM_NONE = 0;
|
|
120
|
-
declare const PARAM_WEIGHT = 1;
|
|
121
|
-
declare const PARAM_PCT_MAX = 2;
|
|
122
|
-
declare const PARAM_REPS = 3;
|
|
123
|
-
declare const PARAM_RPE = 14;
|
|
130
|
+
export declare const PARAM_UNIT: Readonly<Record<number, string | null>>;
|
|
131
|
+
export declare const PARAM_NONE = 0;
|
|
132
|
+
export declare const PARAM_WEIGHT = 1;
|
|
133
|
+
export declare const PARAM_PCT_MAX = 2;
|
|
134
|
+
export declare const PARAM_REPS = 3;
|
|
135
|
+
export declare const PARAM_RPE = 14;
|
|
124
136
|
/** TrainHeroic stores up to 10 sets per exercise as `param_N_data_1..10`. One source of truth for
|
|
125
137
|
* the bound, shared by the workout presenters and the set-logging write path. */
|
|
126
|
-
declare const MAX_PARAM_SLOTS = 10;
|
|
127
|
-
declare function coerceInt(value: unknown): number | null;
|
|
128
|
-
declare function coerceNum(value: unknown): number | null;
|
|
129
|
-
declare function unitLabel(paramType: unknown): string | null;
|
|
138
|
+
export declare const MAX_PARAM_SLOTS = 10;
|
|
139
|
+
export declare function coerceInt(value: unknown): number | null;
|
|
140
|
+
export declare function coerceNum(value: unknown): number | null;
|
|
141
|
+
export declare function unitLabel(paramType: unknown): string | null;
|
|
130
142
|
/**
|
|
131
143
|
* Fixed measurement units for an exercise, ordered by entry slot (param 1, then param 2).
|
|
132
144
|
* Positional, not semantic: some exercises reverse the slots, so the array is not labelled
|
|
133
145
|
* by role. A null entry is an unset slot.
|
|
134
146
|
*/
|
|
135
|
-
declare function exerciseUnits(param1: unknown, param2: unknown): Array<string | null>;
|
|
147
|
+
export declare function exerciseUnits(param1: unknown, param2: unknown): Array<string | null>;
|
|
136
148
|
/** Present a row for display: drop the raw param-type codes, surface units positionally. */
|
|
137
|
-
declare function withUnits(row: ExerciseRow): ExerciseView;
|
|
149
|
+
export declare function withUnits(row: ExerciseRow): ExerciseView;
|
|
138
150
|
/**
|
|
139
151
|
* Present a full raw exercise object for display: drop the raw param-type codes and add the
|
|
140
152
|
* positional `units` array. Keeps every other field of the raw object intact.
|
|
141
153
|
*/
|
|
142
|
-
declare function presentExercise(raw: Record<string, unknown>): Record<string, unknown>;
|
|
143
|
-
declare function buildSearchText(title: string): string;
|
|
154
|
+
export declare function presentExercise(raw: Record<string, unknown>): Record<string, unknown>;
|
|
155
|
+
export declare function buildSearchText(title: string): string;
|
|
144
156
|
/** Strip the {"success":1,"data":X} envelope some 2.0/coach endpoints use. */
|
|
145
|
-
declare function unwrapEnvelope(body: unknown): unknown;
|
|
157
|
+
export declare function unwrapEnvelope(body: unknown): unknown;
|
|
146
158
|
/** Pull the exercise array out of whatever shape the bulk endpoint returns. */
|
|
147
|
-
declare function asExerciseList(body: unknown): Array<Record<string, unknown>>;
|
|
148
|
-
declare function isRecord(x: unknown): x is Record<string, unknown>;
|
|
159
|
+
export declare function asExerciseList(body: unknown): Array<Record<string, unknown>>;
|
|
160
|
+
export declare function isRecord(x: unknown): x is Record<string, unknown>;
|
|
149
161
|
/** A non-empty string, or null. Narrows a loosely-typed API field to a usable string. */
|
|
150
|
-
declare function str(v: unknown): string | null;
|
|
162
|
+
export declare function str(v: unknown): string | null;
|
|
151
163
|
/**
|
|
152
164
|
* The display title of a saved-copy exercise row, preferring `exercise_title`, then `title`, then
|
|
153
165
|
* the given fallback. The saved-workout shape carries the title under either key depending on the
|
|
154
166
|
* endpoint, so this is the one place that reconciles them.
|
|
155
167
|
*/
|
|
156
|
-
declare function exerciseTitle(ex: Record<string, unknown>, fallback?: string): string;
|
|
168
|
+
export declare function exerciseTitle(ex: Record<string, unknown>, fallback?: string): string;
|
|
157
169
|
/**
|
|
158
170
|
* True when a program-workout range item is a personal (athlete-created) session rather than a
|
|
159
171
|
* coach-scheduled one. The API marks these with `personal_cal === true`; this is the single
|
|
160
172
|
* definition every consumer (presenter, find-or-create, the remove guard) reads through.
|
|
161
173
|
*/
|
|
162
|
-
declare function isPersonalSession(pw: unknown): boolean;
|
|
174
|
+
export declare function isPersonalSession(pw: unknown): boolean;
|
|
163
175
|
/**
|
|
164
176
|
* The `saved_workout` blob on a program-workout range item, or null if the athlete has no saved
|
|
165
177
|
* copy yet. Session notes, RPE, and set writes all resolve through this.
|
|
166
178
|
*/
|
|
167
|
-
declare function savedWorkoutOf(pw: unknown): Record<string, unknown> | null;
|
|
179
|
+
export declare function savedWorkoutOf(pw: unknown): Record<string, unknown> | null;
|
|
168
180
|
/**
|
|
169
181
|
* Rank candidate rows for a free-text query (FTS5 replacement). Higher is better:
|
|
170
182
|
* exact title, then prefix, then count of matched tokens, with shorter titles and
|
|
171
183
|
* standard (non-custom) exercises preferred on ties.
|
|
172
184
|
*/
|
|
173
|
-
declare function rankSearch<T extends {
|
|
185
|
+
export declare function rankSearch<T extends {
|
|
174
186
|
title: string;
|
|
175
187
|
can_edit?: number;
|
|
176
188
|
}>(rows: readonly T[], query: string, limit: number): T[];
|
|
@@ -179,7 +191,7 @@ declare function rankSearch<T extends {
|
|
|
179
191
|
* fetches (per-exercise history, the CLI export) without bursting the host all at once or,
|
|
180
192
|
* on workerd, blowing the subrequest budget.
|
|
181
193
|
*/
|
|
182
|
-
declare function mapPool<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
194
|
+
export declare function mapPool<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
183
195
|
/**
|
|
184
196
|
* A concurrency limiter shared across independent call sites: at most `max` tasks run at once,
|
|
185
197
|
* the rest wait in FIFO order. Where {@link mapPool} bounds one fan-out, a limiter bounds the sum
|
|
@@ -188,22 +200,22 @@ declare function mapPool<T, R>(items: readonly T[], limit: number, fn: (item: T,
|
|
|
188
200
|
* after it, reject with the given error, while tasks already running finish normally, so one
|
|
189
201
|
* failed write halts the rest of a session without abandoning requests already on the wire.
|
|
190
202
|
*/
|
|
191
|
-
type Limiter = {
|
|
203
|
+
export type Limiter = {
|
|
192
204
|
run<T>(task: () => Promise<T>): Promise<T>;
|
|
193
205
|
/** Run required finalization even after cancellation, while preserving the same concurrency cap. */
|
|
194
206
|
runFinalizer<T>(task: () => Promise<T>): Promise<T>;
|
|
195
207
|
cancel(error: unknown): void;
|
|
196
208
|
};
|
|
197
|
-
declare function createLimiter(max: number): Limiter;
|
|
209
|
+
export declare function createLimiter(max: number): Limiter;
|
|
198
210
|
/**
|
|
199
211
|
* The exercise-library surface the tools depend on, so the tools work over either a
|
|
200
212
|
* D1-backed mirror (hosted, multi-tenant) or an in-memory cache (local, single-user).
|
|
201
213
|
*/
|
|
202
|
-
type ExerciseDefaults = {
|
|
214
|
+
export type ExerciseDefaults = {
|
|
203
215
|
param1: number | null;
|
|
204
216
|
param2: number | null;
|
|
205
217
|
};
|
|
206
|
-
interface ExerciseIndex {
|
|
218
|
+
export interface ExerciseIndex {
|
|
207
219
|
ensureFresh(): Promise<void>;
|
|
208
220
|
refresh(): Promise<Record<string, unknown>>;
|
|
209
221
|
resolve(name: string): Promise<ResolveResult>;
|
|
@@ -225,16 +237,16 @@ interface ExerciseIndex {
|
|
|
225
237
|
* query arg for several athlete endpoints). Works from any session — coach or athlete — and
|
|
226
238
|
* even from a cached session that never went through login.
|
|
227
239
|
*/
|
|
228
|
-
declare function resolveAthleteUserId(client: TrainHeroicClient): Promise<number>;
|
|
240
|
+
export declare function resolveAthleteUserId(client: TrainHeroicClient): Promise<number>;
|
|
229
241
|
/** Lifetime training totals. `use_metric` is required by the API (omitting it 400s). */
|
|
230
|
-
declare function fetchAthleteProfileSummary(client: TrainHeroicClient, userId: number, useMetric?: boolean): Promise<AthleteProfileSummary>;
|
|
231
|
-
declare function fetchAthleteUser(client: TrainHeroicClient, userId: number): Promise<AthleteUser>;
|
|
242
|
+
export declare function fetchAthleteProfileSummary(client: TrainHeroicClient, userId: number, useMetric?: boolean): Promise<AthleteProfileSummary>;
|
|
243
|
+
export declare function fetchAthleteUser(client: TrainHeroicClient, userId: number): Promise<AthleteUser>;
|
|
232
244
|
/**
|
|
233
245
|
* Sort a roster-activity list most-recently-active first; never-logged rows (null date) last.
|
|
234
246
|
* Athletes tied on lastLoggedDate break by session count (more sessions first), so a tie is not
|
|
235
247
|
* left to arbitrary input order.
|
|
236
248
|
*/
|
|
237
|
-
declare function sortRosterByRecency(rows: readonly RosterActivityRow[]): RosterActivityRow[];
|
|
249
|
+
export declare function sortRosterByRecency(rows: readonly RosterActivityRow[]): RosterActivityRow[];
|
|
238
250
|
/**
|
|
239
251
|
* A coach's roster-activity ranking: each athlete's all-time training snapshot (session count,
|
|
240
252
|
* first/last logged date, total reps/volume), sorted most-recently-active first. There is no
|
|
@@ -242,33 +254,33 @@ declare function sortRosterByRecency(rows: readonly RosterActivityRow[]): Roster
|
|
|
242
254
|
* a small concurrency cap; pass the subset you care about for a large org. A failed or missing
|
|
243
255
|
* summary becomes a null-data row (sorted last), not an error.
|
|
244
256
|
*/
|
|
245
|
-
declare function fetchRosterActivity(client: TrainHeroicClient, athleteIds: readonly number[], useMetric?: boolean): Promise<RosterActivityRow[]>;
|
|
246
|
-
declare function fetchAthletePrefs(client: TrainHeroicClient): Promise<AthletePrefs>;
|
|
247
|
-
declare function fetchWorkingMaxes(client: TrainHeroicClient): Promise<AthleteWorkingMax[]>;
|
|
248
|
-
declare function fetchExerciseHistoryList(client: TrainHeroicClient): Promise<ExerciseHistoryListItem[]>;
|
|
249
|
-
declare function fetchRecentExercises(client: TrainHeroicClient): Promise<unknown[]>;
|
|
250
|
-
declare function fetchAthleteCircuits(client: TrainHeroicClient, kind?: "recent" | "history"): Promise<unknown[]>;
|
|
251
|
-
declare function fetchAthleteProgrammingPrograms(client: TrainHeroicClient): Promise<unknown[]>;
|
|
257
|
+
export declare function fetchRosterActivity(client: TrainHeroicClient, athleteIds: readonly number[], useMetric?: boolean): Promise<RosterActivityRow[]>;
|
|
258
|
+
export declare function fetchAthletePrefs(client: TrainHeroicClient): Promise<AthletePrefs>;
|
|
259
|
+
export declare function fetchWorkingMaxes(client: TrainHeroicClient): Promise<AthleteWorkingMax[]>;
|
|
260
|
+
export declare function fetchExerciseHistoryList(client: TrainHeroicClient): Promise<ExerciseHistoryListItem[]>;
|
|
261
|
+
export declare function fetchRecentExercises(client: TrainHeroicClient): Promise<unknown[]>;
|
|
262
|
+
export declare function fetchAthleteCircuits(client: TrainHeroicClient, kind?: "recent" | "history"): Promise<unknown[]>;
|
|
263
|
+
export declare function fetchAthleteProgrammingPrograms(client: TrainHeroicClient): Promise<unknown[]>;
|
|
252
264
|
/**
|
|
253
265
|
* Free-text search over the athlete's logged exercises (FTS replacement via rankSearch). Only
|
|
254
266
|
* rows whose title carries every query token are candidates; rankSearch scores but never drops a
|
|
255
267
|
* row, so ranking the whole catalog would pad a no-match query with the shortest titles up to
|
|
256
268
|
* `limit`. Mirrors the coach `ExerciseLibrary.search` filter, and a blank query returns nothing.
|
|
257
269
|
*/
|
|
258
|
-
declare function searchExerciseHistory(client: TrainHeroicClient, query: string, limit?: number): Promise<ExerciseHistoryListItem[]>;
|
|
259
|
-
declare function fetchExerciseHistoryDetail(client: TrainHeroicClient, exerciseId: number, userId: number): Promise<ExerciseHistoryDetail>;
|
|
260
|
-
declare function fetchPersonalRecords(client: TrainHeroicClient, exerciseId: number): Promise<PersonalRecord[]>;
|
|
270
|
+
export declare function searchExerciseHistory(client: TrainHeroicClient, query: string, limit?: number): Promise<ExerciseHistoryListItem[]>;
|
|
271
|
+
export declare function fetchExerciseHistoryDetail(client: TrainHeroicClient, exerciseId: number, userId: number): Promise<ExerciseHistoryDetail>;
|
|
272
|
+
export declare function fetchPersonalRecords(client: TrainHeroicClient, exerciseId: number): Promise<PersonalRecord[]>;
|
|
261
273
|
/** Last performance + PR for an exercise. `date` (YYYY-MM-DD) is required by the API. */
|
|
262
|
-
declare function fetchExerciseStats(client: TrainHeroicClient, exerciseId: number, userId: number, date: string): Promise<ExerciseStats>;
|
|
274
|
+
export declare function fetchExerciseStats(client: TrainHeroicClient, exerciseId: number, userId: number, date: string): Promise<ExerciseStats>;
|
|
263
275
|
/** Scheduled + completed workouts in an inclusive YYYY-MM-DD window. */
|
|
264
|
-
declare function fetchAthleteWorkouts(client: TrainHeroicClient, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
|
|
276
|
+
export declare function fetchAthleteWorkouts(client: TrainHeroicClient, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
|
|
265
277
|
/**
|
|
266
278
|
* The program-workout row with this id on this date. Throws if that id is not on the day's range;
|
|
267
279
|
* callers should take the id from `athlete_workouts`.
|
|
268
280
|
*/
|
|
269
|
-
declare function programWorkoutOnDate(client: TrainHeroicClient, date: string, programWorkoutId: number): Promise<ProgramWorkout>;
|
|
270
|
-
/** Split an inclusive
|
|
271
|
-
declare function dateWindows(startDate: string, endDate: string, windowDays: number): Array<{
|
|
281
|
+
export declare function programWorkoutOnDate(client: TrainHeroicClient, date: string, programWorkoutId: number): Promise<ProgramWorkout>;
|
|
282
|
+
/** Split an inclusive range into at most 100 consecutive, non-overlapping windows. */
|
|
283
|
+
export declare function dateWindows(startDate: string, endDate: string, windowDays: number): Array<{
|
|
272
284
|
start: string;
|
|
273
285
|
end: string;
|
|
274
286
|
}>;
|
|
@@ -277,7 +289,7 @@ declare function dateWindows(startDate: string, endDate: string, windowDays: num
|
|
|
277
289
|
* window boundary must not double up, first occurrence wins), then sorted oldest-first by date so
|
|
278
290
|
* the order is stable regardless of window seams. Id-less rows are kept and appended.
|
|
279
291
|
*/
|
|
280
|
-
declare function mergeWorkoutsById(pages: readonly ProgramWorkout[][]): ProgramWorkout[];
|
|
292
|
+
export declare function mergeWorkoutsById(pages: readonly ProgramWorkout[][]): ProgramWorkout[];
|
|
281
293
|
/**
|
|
282
294
|
* Fetch an athlete's workouts across a long range by splitting it into windows and fetching them
|
|
283
295
|
* with bounded concurrency, then merging (deduped by workout id, sorted oldest-first). The
|
|
@@ -285,12 +297,12 @@ declare function mergeWorkoutsById(pages: readonly ProgramWorkout[][]): ProgramW
|
|
|
285
297
|
* `windowDays` defaults to 180; `onProgress(done, total)` reports completed windows for a progress
|
|
286
298
|
* indicator. A range that fits one window delegates to the plain fetch (API order preserved).
|
|
287
299
|
*/
|
|
288
|
-
declare function fetchAthleteWorkoutsChunked(client: TrainHeroicClient, startDate: string, endDate: string, opts?: {
|
|
300
|
+
export declare function fetchAthleteWorkoutsChunked(client: TrainHeroicClient, startDate: string, endDate: string, opts?: {
|
|
289
301
|
windowDays?: number;
|
|
290
302
|
concurrency?: number;
|
|
291
303
|
onProgress?: (done: number, total: number) => void;
|
|
292
304
|
}): Promise<ProgramWorkout[]>;
|
|
293
|
-
declare function fetchLeaderboard(client: TrainHeroicClient, workoutId: number, opts?: {
|
|
305
|
+
export declare function fetchLeaderboard(client: TrainHeroicClient, workoutId: number, opts?: {
|
|
294
306
|
page?: number;
|
|
295
307
|
pageSize?: number;
|
|
296
308
|
gender?: number;
|
|
@@ -301,7 +313,7 @@ declare function fetchLeaderboard(client: TrainHeroicClient, workoutId: number,
|
|
|
301
313
|
* that only need "which exercises were logged" (the main-lift discovery over a year of sessions)
|
|
302
314
|
* and skips the prescription merge and string formatting `presentAthleteWorkouts` does per set.
|
|
303
315
|
*/
|
|
304
|
-
declare function performedExercises(workouts: readonly ProgramWorkout[]): Array<{
|
|
316
|
+
export declare function performedExercises(workouts: readonly ProgramWorkout[]): Array<{
|
|
305
317
|
exerciseId: number;
|
|
306
318
|
title: string;
|
|
307
319
|
}>;
|
|
@@ -310,14 +322,14 @@ declare function performedExercises(workouts: readonly ProgramWorkout[]): Array<
|
|
|
310
322
|
* `performed` sets as joined `"5 @ 225"` strings; athlete-added/personal work that has no
|
|
311
323
|
* prescription is appended as its own blocks. No `raw` is needed to see logged results.
|
|
312
324
|
*/
|
|
313
|
-
declare function presentAthleteWorkout(raw: ProgramWorkout): AthleteWorkoutView;
|
|
314
|
-
declare function presentAthleteWorkouts(list: readonly ProgramWorkout[]): AthleteWorkoutView[];
|
|
325
|
+
export declare function presentAthleteWorkout(raw: ProgramWorkout): AthleteWorkoutView;
|
|
326
|
+
export declare function presentAthleteWorkouts(list: readonly ProgramWorkout[]): AthleteWorkoutView[];
|
|
315
327
|
/** Flatten one workout into the structured export shape (numeric sets), from the same merge as
|
|
316
328
|
* {@link presentAthleteWorkout}. */
|
|
317
|
-
declare function presentAthleteWorkoutExport(raw: ProgramWorkout): WorkoutHistoryExport;
|
|
318
|
-
declare function presentAthleteWorkoutsExport(list: readonly ProgramWorkout[]): WorkoutHistoryExport[];
|
|
329
|
+
export declare function presentAthleteWorkoutExport(raw: ProgramWorkout): WorkoutHistoryExport;
|
|
330
|
+
export declare function presentAthleteWorkoutsExport(list: readonly ProgramWorkout[]): WorkoutHistoryExport[];
|
|
319
331
|
/** The minimal id scaffold `log-set` / `logForAthlete` needs for one saved workout set. */
|
|
320
|
-
type LogSetTarget = {
|
|
332
|
+
export type LogSetTarget = {
|
|
321
333
|
date: string;
|
|
322
334
|
workoutTitle: string;
|
|
323
335
|
/** The program this saved workout belongs to — lets a caller pick the right one of several. */
|
|
@@ -346,7 +358,7 @@ type LogSetTarget = {
|
|
|
346
358
|
* `program_title`/`team_title`) — the title match lets a caller target a program by name without
|
|
347
359
|
* first resolving its id. Any one match keeps the workout; with no filter the list is unchanged.
|
|
348
360
|
*/
|
|
349
|
-
declare function selectWorkoutsByProgram(list: readonly ProgramWorkout[], filter: {
|
|
361
|
+
export declare function selectWorkoutsByProgram(list: readonly ProgramWorkout[], filter: {
|
|
350
362
|
programId?: number;
|
|
351
363
|
teamId?: number;
|
|
352
364
|
programTitle?: string;
|
|
@@ -360,7 +372,7 @@ declare function selectWorkoutsByProgram(list: readonly ProgramWorkout[], filter
|
|
|
360
372
|
* so a caller can pick the right session when the athlete is on several. One row per saved set,
|
|
361
373
|
* dropping any set with no resolvable id.
|
|
362
374
|
*/
|
|
363
|
-
declare function presentLogTargets(list: readonly ProgramWorkout[]): LogSetTarget[];
|
|
375
|
+
export declare function presentLogTargets(list: readonly ProgramWorkout[]): LogSetTarget[];
|
|
364
376
|
/**
|
|
365
377
|
* Narrow a workout list for the common "what did I actually do" reads. `loggedOnly` keeps only
|
|
366
378
|
* workouts the athlete logged a set on (the reliable signal, not the API's completion flag).
|
|
@@ -368,7 +380,7 @@ declare function presentLogTargets(list: readonly ProgramWorkout[]): LogSetTarge
|
|
|
368
380
|
* path is left untouched. Generic over the presented (`AthleteWorkoutView`) and exported
|
|
369
381
|
* (`WorkoutHistoryExport`) shapes, which both carry `date` and `logged`, so one rule serves both.
|
|
370
382
|
*/
|
|
371
|
-
declare function selectWorkouts<T extends {
|
|
383
|
+
export declare function selectWorkouts<T extends {
|
|
372
384
|
date: string;
|
|
373
385
|
logged: boolean;
|
|
374
386
|
}>(list: readonly T[], opts?: {
|
|
@@ -381,7 +393,7 @@ declare function selectWorkouts<T extends {
|
|
|
381
393
|
* tens of KB; this keeps an overview question to one small row per session, with a drill-in
|
|
382
394
|
* (narrow the date range) when the detail is actually needed.
|
|
383
395
|
*/
|
|
384
|
-
declare function summarizeAthleteWorkouts(list: readonly AthleteWorkoutView[]): AthleteWorkoutSummary[];
|
|
396
|
+
export declare function summarizeAthleteWorkouts(list: readonly AthleteWorkoutView[]): AthleteWorkoutSummary[];
|
|
385
397
|
/**
|
|
386
398
|
* Flatten the coach athlete-calendar summary into compact per-session rows: title, the `logged`
|
|
387
399
|
* flag (the reliable did-they-train signal), rpe/duration/notes, and the exercises performed with
|
|
@@ -389,9 +401,9 @@ declare function summarizeAthleteWorkouts(list: readonly AthleteWorkoutView[]):
|
|
|
389
401
|
* the discovery handle a coach otherwise lacks: read what the athlete actually did, then pull the
|
|
390
402
|
* specific lift's PRs.
|
|
391
403
|
*/
|
|
392
|
-
declare function presentCoachAthleteTraining(raw: readonly unknown[], athleteId: number, year: number, month: number): CoachAthleteTraining;
|
|
404
|
+
export declare function presentCoachAthleteTraining(raw: readonly unknown[], athleteId: number, year: number, month: number): CoachAthleteTraining;
|
|
393
405
|
/** Flatten `/v5/exercises/{id}/history` into PRs + a session time-series. */
|
|
394
|
-
declare function presentExerciseHistory(detail: ExerciseHistoryDetail): PresentedExerciseHistory;
|
|
406
|
+
export declare function presentExerciseHistory(detail: ExerciseHistoryDetail): PresentedExerciseHistory;
|
|
395
407
|
//#endregion
|
|
396
408
|
//#region src/exercise-history.d.ts
|
|
397
409
|
/**
|
|
@@ -401,7 +413,7 @@ declare function presentExerciseHistory(detail: ExerciseHistoryDetail): Presente
|
|
|
401
413
|
* window rule shared by the athlete's own history tool, the coach's per-roster-athlete history
|
|
402
414
|
* tool, and the CLI, so a timestamped session cannot fall out of an inclusive upper bound.
|
|
403
415
|
*/
|
|
404
|
-
declare function historyInRange(presented: PresentedExerciseHistory, since: string | undefined, until: string | undefined): PresentedExerciseHistory;
|
|
416
|
+
export declare function historyInRange(presented: PresentedExerciseHistory, since: string | undefined, until: string | undefined): PresentedExerciseHistory;
|
|
405
417
|
//#endregion
|
|
406
418
|
//#region src/coach-athlete-calendar.d.ts
|
|
407
419
|
/**
|
|
@@ -410,16 +422,16 @@ declare function historyInRange(presented: PresentedExerciseHistory, since: stri
|
|
|
410
422
|
* `ProgramWorkout[]` shape as `fetchAthleteWorkouts`, so the same presenters and
|
|
411
423
|
* `findSavedWorkoutSet` apply — it just reads another athlete's data through the coach surface.
|
|
412
424
|
*/
|
|
413
|
-
declare function fetchCoachAthleteWorkouts(client: TrainHeroicClient, athleteId: number, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
|
|
425
|
+
export declare function fetchCoachAthleteWorkouts(client: TrainHeroicClient, athleteId: number, startDate: string, endDate: string): Promise<ProgramWorkout[]>;
|
|
414
426
|
/**
|
|
415
427
|
* A coach's month view of a roster athlete's logged sessions
|
|
416
428
|
* (`/2.0/coach/athlete/calendar/summary`). The trailing path segment is required by the API but
|
|
417
429
|
* ignored (any value returns the whole month); it mirrors the coach web app, which sends 7. The
|
|
418
430
|
* `userId` in each row is the roster athlete, not the calling coach.
|
|
419
431
|
*/
|
|
420
|
-
declare function fetchCoachAthleteCalendarSummary(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<unknown[]>;
|
|
432
|
+
export declare function fetchCoachAthleteCalendarSummary(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<unknown[]>;
|
|
421
433
|
/** A roster athlete's coach-writable calendar (from `GET /v5/calendars/athletes/{id}`). */
|
|
422
|
-
type CoachAthleteCalendar = {
|
|
434
|
+
export type CoachAthleteCalendar = {
|
|
423
435
|
programId: number;
|
|
424
436
|
title: string;
|
|
425
437
|
/** Program type: 5 = individual athlete calendar, 4 = coach own calendar (observed). */
|
|
@@ -435,13 +447,13 @@ type CoachAthleteCalendar = {
|
|
|
435
447
|
* with `createWorkoutForDay` when you open an athlete from My Athletes → calendar — distinct
|
|
436
448
|
* from athlete-created `personal_cal` ad-hoc sessions.
|
|
437
449
|
*/
|
|
438
|
-
declare function fetchCoachAthleteCalendar(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<CoachAthleteCalendar>;
|
|
450
|
+
export declare function fetchCoachAthleteCalendar(client: TrainHeroicClient, athleteId: number, year: number, month: number): Promise<CoachAthleteCalendar>;
|
|
439
451
|
/**
|
|
440
452
|
* Resolve the calendar program id for `workout_build` / `coach workout build`: either an
|
|
441
453
|
* explicit team/group `programId`, or a roster `athleteId` (+ date) via
|
|
442
454
|
* `fetchCoachAthleteCalendar`. Exactly one of programId / athleteId is required.
|
|
443
455
|
*/
|
|
444
|
-
declare function resolveBuildProgramId(client: TrainHeroicClient, args: {
|
|
456
|
+
export declare function resolveBuildProgramId(client: TrainHeroicClient, args: {
|
|
445
457
|
programId?: number;
|
|
446
458
|
athleteId?: number;
|
|
447
459
|
date?: string;
|
|
@@ -469,7 +481,7 @@ type ExerciseSetPayload = Record<string, unknown> & {
|
|
|
469
481
|
* blanked so TrainHeroic cannot fabricate performed results from them. A prescription replaces the
|
|
470
482
|
* full payload and never marks slots or the exercise complete.
|
|
471
483
|
*/
|
|
472
|
-
declare function buildExerciseSetPayload(savedWorkoutSetExerciseId: number, savedWorkoutSetId: number, workoutSetExerciseId: number, results: readonly ExerciseSetInput[], mode: SetWriteMode, existing?: Record<string, unknown>): ExerciseSetPayload;
|
|
484
|
+
export declare function buildExerciseSetPayload(savedWorkoutSetExerciseId: number, savedWorkoutSetId: number, workoutSetExerciseId: number, results: readonly ExerciseSetInput[], mode: SetWriteMode, existing?: Record<string, unknown>): ExerciseSetPayload;
|
|
473
485
|
//#endregion
|
|
474
486
|
//#region src/athlete-set-write.d.ts
|
|
475
487
|
/**
|
|
@@ -478,7 +490,7 @@ declare function buildExerciseSetPayload(savedWorkoutSetExerciseId: number, save
|
|
|
478
490
|
* (e.g. reps and weight). Optional `slot` is the 1-based prescribed position this set fills;
|
|
479
491
|
* omit it and the sets fill positions sequentially from the first. At most 10 sets are supported.
|
|
480
492
|
*/
|
|
481
|
-
type SetResult = {
|
|
493
|
+
export type SetResult = {
|
|
482
494
|
savedWorkoutSetExerciseId: number;
|
|
483
495
|
sets: Array<{
|
|
484
496
|
param1?: number | string;
|
|
@@ -493,7 +505,7 @@ type SetResult = {
|
|
|
493
505
|
* values (so the per-set type stays free of `undefined` under exactOptionalPropertyTypes). Shared
|
|
494
506
|
* by the MCP tools and the CLI so the mapping lives in one place rather than once per surface.
|
|
495
507
|
*/
|
|
496
|
-
declare function toSetResults(results: ReadonlyArray<{
|
|
508
|
+
export declare function toSetResults(results: ReadonlyArray<{
|
|
497
509
|
savedWorkoutSetExerciseId: number | string;
|
|
498
510
|
sets: ReadonlyArray<{
|
|
499
511
|
param1?: number | string | undefined;
|
|
@@ -507,7 +519,7 @@ declare function toSetResults(results: ReadonlyArray<{
|
|
|
507
519
|
* can look up `workout_set_exercise_id` by `savedWorkoutSetExerciseId`, and the raw set
|
|
508
520
|
* record so callers can build the set-completion PUT body via `buildSetCompletePayload`.
|
|
509
521
|
*/
|
|
510
|
-
declare function findSavedWorkoutSet(workouts: readonly ProgramWorkout[], savedWorkoutSetId: number): {
|
|
522
|
+
export declare function findSavedWorkoutSet(workouts: readonly ProgramWorkout[], savedWorkoutSetId: number): {
|
|
511
523
|
savedWorkoutId: number;
|
|
512
524
|
exercises: Record<string, unknown>[];
|
|
513
525
|
rawSet: Record<string, unknown>;
|
|
@@ -528,7 +540,7 @@ declare function findSavedWorkoutSet(workouts: readonly ProgramWorkout[], savedW
|
|
|
528
540
|
*
|
|
529
541
|
* Exported for unit testing — callers should use `logAthleteSet` instead.
|
|
530
542
|
*/
|
|
531
|
-
declare function buildSetCompletePayload(rawSet: Record<string, unknown>, exerciseIds: readonly number[], complete: boolean): Record<string, unknown>;
|
|
543
|
+
export declare function buildSetCompletePayload(rawSet: Record<string, unknown>, exerciseIds: readonly number[], complete: boolean): Record<string, unknown>;
|
|
532
544
|
/**
|
|
533
545
|
* Record entered set results for one saved workout set.
|
|
534
546
|
*
|
|
@@ -545,7 +557,7 @@ declare function buildSetCompletePayload(rawSet: Record<string, unknown>, exerci
|
|
|
545
557
|
* `saved_workout_id` and `workout_set_exercise_id` for each exercise. Both are required
|
|
546
558
|
* by the respective PUT bodies.
|
|
547
559
|
*/
|
|
548
|
-
declare function logAthleteSet(client: TrainHeroicClient, args: {
|
|
560
|
+
export declare function logAthleteSet(client: TrainHeroicClient, args: {
|
|
549
561
|
date: string;
|
|
550
562
|
savedWorkoutSetId: number;
|
|
551
563
|
results: readonly SetResult[];
|
|
@@ -562,7 +574,7 @@ declare function logAthleteSet(client: TrainHeroicClient, args: {
|
|
|
562
574
|
* The write replaces the selected exercise's whole prescription, so callers must pass every set
|
|
563
575
|
* they want to keep. An omitted param is cleared rather than preserved.
|
|
564
576
|
*/
|
|
565
|
-
declare function prescribeAthleteSet(client: TrainHeroicClient, args: {
|
|
577
|
+
export declare function prescribeAthleteSet(client: TrainHeroicClient, args: {
|
|
566
578
|
date: string;
|
|
567
579
|
savedWorkoutSetId: number;
|
|
568
580
|
results: readonly SetResult[];
|
|
@@ -580,7 +592,7 @@ declare function prescribeAthleteSet(client: TrainHeroicClient, args: {
|
|
|
580
592
|
* NOTE: TrainHeroic's seeded *demo* athletes are read-only for results and return 401 on the
|
|
581
593
|
* data-write step; real (invited) athletes accept it.
|
|
582
594
|
*/
|
|
583
|
-
declare function logForAthlete(client: TrainHeroicClient, args: {
|
|
595
|
+
export declare function logForAthlete(client: TrainHeroicClient, args: {
|
|
584
596
|
athleteId: number;
|
|
585
597
|
date: string;
|
|
586
598
|
savedWorkoutSetId: number;
|
|
@@ -606,7 +618,7 @@ declare function logForAthlete(client: TrainHeroicClient, args: {
|
|
|
606
618
|
* NOTE: TrainHeroic's seeded *demo* athletes are read-only and return 401/403; real (invited)
|
|
607
619
|
* athletes accept it.
|
|
608
620
|
*/
|
|
609
|
-
declare function prescribeForAthlete(client: TrainHeroicClient, args: {
|
|
621
|
+
export declare function prescribeForAthlete(client: TrainHeroicClient, args: {
|
|
610
622
|
athleteId: number;
|
|
611
623
|
date: string;
|
|
612
624
|
savedWorkoutSetId: number;
|
|
@@ -616,7 +628,7 @@ declare function prescribeForAthlete(client: TrainHeroicClient, args: {
|
|
|
616
628
|
exercisesPrescribed: number;
|
|
617
629
|
}>;
|
|
618
630
|
/** Outcome of a per-athlete exercise swap: the slot that changed and what it changed to/from. */
|
|
619
|
-
type SwapExerciseResult = {
|
|
631
|
+
export type SwapExerciseResult = {
|
|
620
632
|
savedWorkoutSetExerciseId: number;
|
|
621
633
|
/** The athlete who owns the slot (`user_id` off the updated row), when the API returns it. */
|
|
622
634
|
athleteId: number | null;
|
|
@@ -644,11 +656,11 @@ type SwapExerciseResult = {
|
|
|
644
656
|
* NOTE: as with logging, TrainHeroic's seeded *demo* athletes are read-only and return 401/403;
|
|
645
657
|
* real (invited) athletes accept the swap.
|
|
646
658
|
*/
|
|
647
|
-
declare function swapAthleteExercise(client: TrainHeroicClient, args: {
|
|
659
|
+
export declare function swapAthleteExercise(client: TrainHeroicClient, args: {
|
|
648
660
|
savedWorkoutSetExerciseId: number;
|
|
649
661
|
exerciseId: number;
|
|
650
662
|
}): Promise<SwapExerciseResult>;
|
|
651
|
-
type PersonalWorkoutCreated = {
|
|
663
|
+
export type PersonalWorkoutCreated = {
|
|
652
664
|
programWorkoutId: number;
|
|
653
665
|
workoutId: number;
|
|
654
666
|
savedWorkoutId: number;
|
|
@@ -660,9 +672,9 @@ type PersonalWorkoutCreated = {
|
|
|
660
672
|
* Returns the key ids: workoutId (needed for addExercisesToWorkout), programWorkoutId,
|
|
661
673
|
* savedWorkoutId, and groupId.
|
|
662
674
|
*/
|
|
663
|
-
declare function createPersonalWorkout(client: TrainHeroicClient, date: string): Promise<PersonalWorkoutCreated>;
|
|
675
|
+
export declare function createPersonalWorkout(client: TrainHeroicClient, date: string): Promise<PersonalWorkoutCreated>;
|
|
664
676
|
/** One exercise item for addExercisesToWorkout. */
|
|
665
|
-
type AddedExercise = {
|
|
677
|
+
export type AddedExercise = {
|
|
666
678
|
exerciseId: number;
|
|
667
679
|
order: number;
|
|
668
680
|
};
|
|
@@ -672,7 +684,7 @@ type AddedExercise = {
|
|
|
672
684
|
* and `savedWorkoutSetExercises[].id` is a savedWorkoutSetExerciseId, both needed by
|
|
673
685
|
* logAthleteSet.
|
|
674
686
|
*/
|
|
675
|
-
declare function addExercisesToWorkout(client: TrainHeroicClient, workoutId: number, exercises: AddedExercise[]): Promise<unknown>;
|
|
687
|
+
export declare function addExercisesToWorkout(client: TrainHeroicClient, workoutId: number, exercises: AddedExercise[]): Promise<unknown>;
|
|
676
688
|
/**
|
|
677
689
|
* DELETE /v5/programWorkouts/{programWorkoutId} — remove a personal (athlete-created) workout
|
|
678
690
|
* session from the athlete's own calendar. Re-reads the day and removes ONLY a personal session
|
|
@@ -681,12 +693,12 @@ declare function addExercisesToWorkout(client: TrainHeroicClient, workoutId: num
|
|
|
681
693
|
* delete itself, so no caller can issue the DELETE against a coach workout by skipping a check.
|
|
682
694
|
* Throws on a non-ok response.
|
|
683
695
|
*/
|
|
684
|
-
declare function removePersonalWorkout(client: TrainHeroicClient, args: {
|
|
696
|
+
export declare function removePersonalWorkout(client: TrainHeroicClient, args: {
|
|
685
697
|
programWorkoutId: number;
|
|
686
698
|
date: string;
|
|
687
699
|
}): Promise<void>;
|
|
688
700
|
/** One exercise's entered sets, keyed by the exercise id rather than a saved-set id. */
|
|
689
|
-
type SessionExercise = {
|
|
701
|
+
export type SessionExercise = {
|
|
690
702
|
exerciseId: number;
|
|
691
703
|
order?: number;
|
|
692
704
|
sets: ReadonlyArray<{
|
|
@@ -696,7 +708,7 @@ type SessionExercise = {
|
|
|
696
708
|
};
|
|
697
709
|
/** A coach-scheduled prescription on the same day that matches an exercise the athlete just logged
|
|
698
710
|
* ad-hoc. Surfaced as a hint that {@link logAthleteSet} could log into the scheduled workout. */
|
|
699
|
-
type ScheduledAlternative = {
|
|
711
|
+
export type ScheduledAlternative = {
|
|
700
712
|
exerciseId: number;
|
|
701
713
|
title: string;
|
|
702
714
|
program: string | null;
|
|
@@ -706,7 +718,7 @@ type ScheduledAlternative = {
|
|
|
706
718
|
};
|
|
707
719
|
/** Result of logging a session by exercise: which sets were written, and (athlete) whether a
|
|
708
720
|
* new personal session had to be created for the date. */
|
|
709
|
-
type LogSessionResult = {
|
|
721
|
+
export type LogSessionResult = {
|
|
710
722
|
date: string;
|
|
711
723
|
created: boolean;
|
|
712
724
|
sets: Array<{
|
|
@@ -728,7 +740,7 @@ type LogSessionResult = {
|
|
|
728
740
|
* This is the "log whatever I just did" path — extra accessory work, a makeup lift, an off-plan
|
|
729
741
|
* gym session.
|
|
730
742
|
*/
|
|
731
|
-
declare function logAdHocSession(client: TrainHeroicClient, args: {
|
|
743
|
+
export declare function logAdHocSession(client: TrainHeroicClient, args: {
|
|
732
744
|
date: string;
|
|
733
745
|
exercises: readonly SessionExercise[];
|
|
734
746
|
}): Promise<LogSessionResult>;
|
|
@@ -739,7 +751,7 @@ declare function logAdHocSession(client: TrainHeroicClient, args: {
|
|
|
739
751
|
* is resolved to a prescribed saved set and its results are written via the coach "Log for
|
|
740
752
|
* Athlete" surface. Throws a readable error naming the prescribed exercises when one is missing.
|
|
741
753
|
*/
|
|
742
|
-
declare function logSessionForAthlete(client: TrainHeroicClient, args: {
|
|
754
|
+
export declare function logSessionForAthlete(client: TrainHeroicClient, args: {
|
|
743
755
|
athleteId: number;
|
|
744
756
|
date: string;
|
|
745
757
|
exercises: readonly SessionExercise[];
|
|
@@ -752,7 +764,7 @@ declare function logSessionForAthlete(client: TrainHeroicClient, args: {
|
|
|
752
764
|
* the saved workout; GET on that path 405s, so the range read is the lookup. A notes-only body
|
|
753
765
|
* leaves rpe untouched and vice versa. Empty `notes` clears the note. Coach-visible.
|
|
754
766
|
*/
|
|
755
|
-
declare function setAthleteWorkoutNote(client: TrainHeroicClient, args: {
|
|
767
|
+
export declare function setAthleteWorkoutNote(client: TrainHeroicClient, args: {
|
|
756
768
|
date: string;
|
|
757
769
|
programWorkoutId: number | string;
|
|
758
770
|
notes?: string | undefined;
|
|
@@ -766,38 +778,38 @@ declare function setAthleteWorkoutNote(client: TrainHeroicClient, args: {
|
|
|
766
778
|
* untouched. Empty `notes` clears the note. GET on that path 405s; the range read and exercise
|
|
767
779
|
* history both echo the stored string. Coach-visible.
|
|
768
780
|
*/
|
|
769
|
-
declare function setAthleteExerciseNote(client: TrainHeroicClient, args: {
|
|
781
|
+
export declare function setAthleteExerciseNote(client: TrainHeroicClient, args: {
|
|
770
782
|
savedWorkoutSetExerciseId: number | string;
|
|
771
783
|
notes: string;
|
|
772
784
|
}): Promise<AthleteExerciseNoteOutput>;
|
|
773
785
|
//#endregion
|
|
774
786
|
//#region src/workout-export.d.ts
|
|
775
|
-
type WorkoutExportFormat = "json" | "csv" | "text";
|
|
787
|
+
export type WorkoutExportFormat = "json" | "csv" | "text";
|
|
776
788
|
/** A serialized export ready to write to a file or hand to a browser download. */
|
|
777
|
-
type SerializedExport = {
|
|
789
|
+
export type SerializedExport = {
|
|
778
790
|
content: string;
|
|
779
791
|
contentType: string;
|
|
780
792
|
extension: string;
|
|
781
793
|
filename: string;
|
|
782
794
|
};
|
|
783
795
|
/** Pretty-printed JSON of the structured workouts, exactly as `presentAthleteWorkoutsExport` yields. */
|
|
784
|
-
declare function workoutsToJson(workouts: readonly WorkoutHistoryExport[]): string;
|
|
796
|
+
export declare function workoutsToJson(workouts: readonly WorkoutHistoryExport[]): string;
|
|
785
797
|
/**
|
|
786
798
|
* One row per set. `reps`/`weight` columns hold the broken-out numeric values for the common
|
|
787
799
|
* lifting case; the trailing `prescribed`/`performed` columns hold the raw `"p1 @ p2"` display so a
|
|
788
800
|
* time, distance, or percentage exercise (where the reps/weight columns are blank) loses nothing.
|
|
789
801
|
*/
|
|
790
|
-
declare function workoutsToCsv(workouts: readonly WorkoutHistoryExport[]): string;
|
|
802
|
+
export declare function workoutsToCsv(workouts: readonly WorkoutHistoryExport[]): string;
|
|
791
803
|
/** A readable, indented rendering — one athlete-friendly block of text per session. */
|
|
792
|
-
declare function workoutsToText(workouts: readonly WorkoutHistoryExport[]): string;
|
|
804
|
+
export declare function workoutsToText(workouts: readonly WorkoutHistoryExport[]): string;
|
|
793
805
|
/** Serialize the workout history to the chosen format, with content-type and a suggested filename. */
|
|
794
|
-
declare function serializeWorkoutHistory(workouts: readonly WorkoutHistoryExport[], format: WorkoutExportFormat, opts?: {
|
|
806
|
+
export declare function serializeWorkoutHistory(workouts: readonly WorkoutHistoryExport[], format: WorkoutExportFormat, opts?: {
|
|
795
807
|
filenameBase?: string;
|
|
796
808
|
}): SerializedExport;
|
|
797
809
|
//#endregion
|
|
798
810
|
//#region src/main-lifts.d.ts
|
|
799
|
-
type MainLiftFamilyKey = "cleanjerk" | "snatch" | "deadlift" | "squat" | "bench" | "overhead";
|
|
800
|
-
type MainLiftFamily = {
|
|
811
|
+
export type MainLiftFamilyKey = "cleanjerk" | "snatch" | "deadlift" | "squat" | "bench" | "overhead";
|
|
812
|
+
export type MainLiftFamily = {
|
|
801
813
|
key: MainLiftFamilyKey;
|
|
802
814
|
label: string;
|
|
803
815
|
/** True when a lowercased exercise title belongs to this family. */
|
|
@@ -810,17 +822,17 @@ type MainLiftFamily = {
|
|
|
810
822
|
* swept up as an overhead press, and why "Clean & Jerk" is not mistaken for a clean-only movement.
|
|
811
823
|
* This is the single place to edit the lift set.
|
|
812
824
|
*/
|
|
813
|
-
declare const MAIN_LIFT_FAMILIES: readonly MainLiftFamily[];
|
|
825
|
+
export declare const MAIN_LIFT_FAMILIES: readonly MainLiftFamily[];
|
|
814
826
|
/** The lift family a logged exercise title belongs to, or null if it is not a main lift. */
|
|
815
|
-
declare function classifyMainLift(title: string): MainLiftFamilyKey | null;
|
|
827
|
+
export declare function classifyMainLift(title: string): MainLiftFamilyKey | null;
|
|
816
828
|
/** The main-lift variant an athlete actually logs (the most-used exercise in that family). */
|
|
817
|
-
type ResolvedLift = {
|
|
829
|
+
export type ResolvedLift = {
|
|
818
830
|
family: MainLiftFamilyKey;
|
|
819
831
|
label: string;
|
|
820
832
|
exerciseId: number;
|
|
821
833
|
title: string;
|
|
822
834
|
};
|
|
823
|
-
type MainLiftResolution = {
|
|
835
|
+
export type MainLiftResolution = {
|
|
824
836
|
athleteId: number;
|
|
825
837
|
athleteName: string | null;
|
|
826
838
|
lifts: ResolvedLift[];
|
|
@@ -833,12 +845,12 @@ type MainLiftResolution = {
|
|
|
833
845
|
* families they never trained are simply absent. (The monthly calendar summary is not used: it
|
|
834
846
|
* comes back empty for some accounts that have logged sets in the range endpoint.)
|
|
835
847
|
*/
|
|
836
|
-
declare function resolveAthleteMainLifts(client: TrainHeroicClient, athleteId: number, opts?: {
|
|
848
|
+
export declare function resolveAthleteMainLifts(client: TrainHeroicClient, athleteId: number, opts?: {
|
|
837
849
|
months?: number;
|
|
838
850
|
now?: Date;
|
|
839
851
|
}): Promise<MainLiftResolution>;
|
|
840
852
|
/** One main lift's best PR for an athlete. A family the athlete has not logged has a null body. */
|
|
841
|
-
type MainLiftPR = {
|
|
853
|
+
export type MainLiftPR = {
|
|
842
854
|
family: MainLiftFamilyKey;
|
|
843
855
|
label: string;
|
|
844
856
|
exerciseId: number | null;
|
|
@@ -848,7 +860,7 @@ type MainLiftPR = {
|
|
|
848
860
|
units: string | null;
|
|
849
861
|
date: string | null;
|
|
850
862
|
};
|
|
851
|
-
type AthleteMainLiftPRs = {
|
|
863
|
+
export type AthleteMainLiftPRs = {
|
|
852
864
|
athleteId: number;
|
|
853
865
|
athleteName: string | null;
|
|
854
866
|
prs: MainLiftPR[];
|
|
@@ -860,7 +872,7 @@ type AthleteMainLiftPRs = {
|
|
|
860
872
|
* athlete has not logged comes back with null fields (the "no PR yet" case), so a dashboard can
|
|
861
873
|
* render a stable row of columns.
|
|
862
874
|
*/
|
|
863
|
-
declare function fetchAthleteMainLiftPRs(client: TrainHeroicClient, athleteId: number, opts?: {
|
|
875
|
+
export declare function fetchAthleteMainLiftPRs(client: TrainHeroicClient, athleteId: number, opts?: {
|
|
864
876
|
months?: number;
|
|
865
877
|
now?: Date;
|
|
866
878
|
}): Promise<AthleteMainLiftPRs>;
|
|
@@ -871,7 +883,7 @@ declare function fetchAthleteMainLiftPRs(client: TrainHeroicClient, athleteId: n
|
|
|
871
883
|
* to the roster name when the per-athlete read can't supply one. This is the single roster-level
|
|
872
884
|
* primitive the CLI, the MCP tool, and the warehouse store all build on.
|
|
873
885
|
*/
|
|
874
|
-
declare function fetchRosterMainLiftPRs(client: TrainHeroicClient, opts?: {
|
|
886
|
+
export declare function fetchRosterMainLiftPRs(client: TrainHeroicClient, opts?: {
|
|
875
887
|
athleteIds?: readonly number[];
|
|
876
888
|
months?: number;
|
|
877
889
|
now?: Date;
|
|
@@ -879,10 +891,10 @@ declare function fetchRosterMainLiftPRs(client: TrainHeroicClient, opts?: {
|
|
|
879
891
|
}): Promise<AthleteMainLiftPRs[]>;
|
|
880
892
|
//#endregion
|
|
881
893
|
//#region src/coach.d.ts
|
|
882
|
-
declare const DEFAULT_INVITE_MESSAGE = "Follow these steps and you'll be set up and ready to go!";
|
|
883
|
-
declare const PROGRAM_KINDS: readonly ["calendar", "fixed"];
|
|
884
|
-
type ProgramKind = (typeof PROGRAM_KINDS)[number];
|
|
885
|
-
type CreatedProgram = {
|
|
894
|
+
export declare const DEFAULT_INVITE_MESSAGE = "Follow these steps and you'll be set up and ready to go!";
|
|
895
|
+
export declare const PROGRAM_KINDS: readonly ["calendar", "fixed"];
|
|
896
|
+
export type ProgramKind = (typeof PROGRAM_KINDS)[number];
|
|
897
|
+
export type CreatedProgram = {
|
|
886
898
|
/** Container/group id returned by list_programs and used by calendar edit/sync endpoints. */
|
|
887
899
|
containerId: number;
|
|
888
900
|
/** Actual program id used by get_program, workout creation, and other program-scoped writes. */
|
|
@@ -902,11 +914,11 @@ type CreatedProgram = {
|
|
|
902
914
|
* result. The live API currently accepts `name` but may generate its own title; `nameApplied`
|
|
903
915
|
* reports what happened.
|
|
904
916
|
*/
|
|
905
|
-
declare function createProgram(client: TrainHeroicClient, args: {
|
|
917
|
+
export declare function createProgram(client: TrainHeroicClient, args: {
|
|
906
918
|
kind: ProgramKind;
|
|
907
919
|
name: string;
|
|
908
920
|
}): Promise<CreatedProgram>;
|
|
909
|
-
type DeletedProgram = {
|
|
921
|
+
export type DeletedProgram = {
|
|
910
922
|
/** Actual program id sent to `DELETE /v5/programs/{id}`. */
|
|
911
923
|
programId: number;
|
|
912
924
|
/** Container id when the caller passed a list_programs row id (otherwise null). */
|
|
@@ -919,9 +931,9 @@ type DeletedProgram = {
|
|
|
919
931
|
* resolves a container to its `group_program` first. Team calendars are not in that list; their
|
|
920
932
|
* program id is deleted as given. This is not idempotent against an unknown failure.
|
|
921
933
|
*/
|
|
922
|
-
declare function deleteProgram(client: TrainHeroicClient, programId: number): Promise<DeletedProgram>;
|
|
934
|
+
export declare function deleteProgram(client: TrainHeroicClient, programId: number): Promise<DeletedProgram>;
|
|
923
935
|
/** A roster member as id + display name. */
|
|
924
|
-
type CoachRosterAthlete = {
|
|
936
|
+
export type CoachRosterAthlete = {
|
|
925
937
|
id: number;
|
|
926
938
|
name: string | null;
|
|
927
939
|
};
|
|
@@ -931,13 +943,13 @@ type CoachRosterAthlete = {
|
|
|
931
943
|
* and the warehouse store map the roster identically. Includes the account owner and
|
|
932
944
|
* demo/placeholder athletes (the raw roster does); pass `ids` to keep only a subset.
|
|
933
945
|
*/
|
|
934
|
-
declare function fetchCoachRoster(client: TrainHeroicClient, ids?: readonly number[]): Promise<CoachRosterAthlete[]>;
|
|
946
|
+
export declare function fetchCoachRoster(client: TrainHeroicClient, ids?: readonly number[]): Promise<CoachRosterAthlete[]>;
|
|
935
947
|
/**
|
|
936
948
|
* Invite athletes to a team — TrainHeroic's two-step "create athlete" flow: validate the
|
|
937
949
|
* addresses (`POST /v5/emails/validate`), then invite the validated ones
|
|
938
950
|
* (`POST /v5/athletes/inviteToTeam`). Throws with the API detail on failure.
|
|
939
951
|
*/
|
|
940
|
-
declare function inviteAthletes(client: TrainHeroicClient, args: {
|
|
952
|
+
export declare function inviteAthletes(client: TrainHeroicClient, args: {
|
|
941
953
|
teamId: number;
|
|
942
954
|
emails: readonly string[];
|
|
943
955
|
message?: string;
|
|
@@ -954,18 +966,18 @@ declare function inviteAthletes(client: TrainHeroicClient, args: {
|
|
|
954
966
|
* has only `group_program` (HTTP 400 "Invalid parameters"). When `title` is omitted we read
|
|
955
967
|
* the current title first so callers can re-link without renaming.
|
|
956
968
|
*/
|
|
957
|
-
declare function updateTeam(client: TrainHeroicClient, args: {
|
|
969
|
+
export declare function updateTeam(client: TrainHeroicClient, args: {
|
|
958
970
|
teamId: number;
|
|
959
971
|
title?: string;
|
|
960
972
|
groupProgram?: number;
|
|
961
973
|
}): Promise<unknown>;
|
|
962
|
-
type TeamPublishTarget = {
|
|
974
|
+
export type TeamPublishTarget = {
|
|
963
975
|
programId: number;
|
|
964
976
|
} | {
|
|
965
977
|
teamId: number;
|
|
966
978
|
};
|
|
967
979
|
/** Collapse the MCP/CLI XOR flags into a single publish target. */
|
|
968
|
-
declare function teamPublishTarget(ids: {
|
|
980
|
+
export declare function teamPublishTarget(ids: {
|
|
969
981
|
programId?: number;
|
|
970
982
|
teamId?: number;
|
|
971
983
|
}): TeamPublishTarget;
|
|
@@ -974,7 +986,7 @@ declare function teamPublishTarget(ids: {
|
|
|
974
986
|
* The live API 500s on a partial body; it wants the full program object from
|
|
975
987
|
* `GET /3.0/coach/program/{programId}` with `pub_*` fields merged on top.
|
|
976
988
|
*/
|
|
977
|
-
declare function updateTeamPublishSettings(client: TrainHeroicClient, args: TeamPublishTarget & {
|
|
989
|
+
export declare function updateTeamPublishSettings(client: TrainHeroicClient, args: TeamPublishTarget & {
|
|
978
990
|
patch: TeamPublishPatch;
|
|
979
991
|
}): Promise<unknown>;
|
|
980
992
|
/**
|
|
@@ -982,13 +994,13 @@ declare function updateTeamPublishSettings(client: TrainHeroicClient, args: Team
|
|
|
982
994
|
* The API wants the target date as a structured object (with weekday and an isToday flag),
|
|
983
995
|
* which is computed here from `toDate` (YYYY-M-D). Creates a new (unpublished) session.
|
|
984
996
|
*/
|
|
985
|
-
declare function copySession(client: TrainHeroicClient, args: {
|
|
997
|
+
export declare function copySession(client: TrainHeroicClient, args: {
|
|
986
998
|
toProgramId: number;
|
|
987
999
|
pwId: number;
|
|
988
1000
|
toDate: string;
|
|
989
1001
|
}): Promise<unknown>;
|
|
990
|
-
declare const ANALYTICS_METRIC_KEYS: readonly ["readiness-team", "readiness-athlete", "lift-1rm-history", "training-summary-athlete", "compliance-team", "lift-progress-team", "working-max-history"];
|
|
991
|
-
type AnalyticsMetric = (typeof ANALYTICS_METRIC_KEYS)[number];
|
|
1002
|
+
export declare const ANALYTICS_METRIC_KEYS: readonly ["readiness-team", "readiness-athlete", "lift-1rm-history", "training-summary-athlete", "compliance-team", "lift-progress-team", "working-max-history"];
|
|
1003
|
+
export type AnalyticsMetric = (typeof ANALYTICS_METRIC_KEYS)[number];
|
|
992
1004
|
/**
|
|
993
1005
|
* A serializable description of every analytics metric: its scope (does it need a `teamId` or
|
|
994
1006
|
* `userIds`) and which date/exercise inputs it requires vs. optionally accepts. The CLI/MCP
|
|
@@ -996,14 +1008,14 @@ type AnalyticsMetric = (typeof ANALYTICS_METRIC_KEYS)[number];
|
|
|
996
1008
|
* shape by trial and error. These curated keys are deliberately NOT the raw category names from
|
|
997
1009
|
* `GET /v5/analytics`; this catalog is the source of truth for `analytics-query`.
|
|
998
1010
|
*/
|
|
999
|
-
declare function analyticsMetricCatalog(): Array<{
|
|
1011
|
+
export declare function analyticsMetricCatalog(): Array<{
|
|
1000
1012
|
metric: AnalyticsMetric;
|
|
1001
1013
|
scope: "team" | "user";
|
|
1002
1014
|
scopeParam: "teamId" | "userIds";
|
|
1003
1015
|
requires: string[];
|
|
1004
1016
|
optional: string[];
|
|
1005
1017
|
}>;
|
|
1006
|
-
type AnalyticsQueryArgs = {
|
|
1018
|
+
export type AnalyticsQueryArgs = {
|
|
1007
1019
|
metric: AnalyticsMetric;
|
|
1008
1020
|
teamId?: number;
|
|
1009
1021
|
userIds?: readonly number[];
|
|
@@ -1014,35 +1026,35 @@ type AnalyticsQueryArgs = {
|
|
|
1014
1026
|
useMetric?: boolean;
|
|
1015
1027
|
};
|
|
1016
1028
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1029
|
+
* Query one analytics metric. Large training-summary reads are serialized as small user/date
|
|
1030
|
+
* batches because that endpoint otherwise spends roughly a minute building one oversized report
|
|
1031
|
+
* before its gateway returns 504. Rejects plans above 100 total requests.
|
|
1020
1032
|
*/
|
|
1021
|
-
declare function queryAnalytics(client: TrainHeroicClient, args: AnalyticsQueryArgs): Promise<unknown>;
|
|
1033
|
+
export declare function queryAnalytics(client: TrainHeroicClient, args: AnalyticsQueryArgs): Promise<unknown>;
|
|
1022
1034
|
/**
|
|
1023
1035
|
* Resolve a team's roster to athlete user ids. `/v5/athletes` is the org-wide roster and the only
|
|
1024
1036
|
* place per-team membership lives (each row's `groups` holds the team/group ids it belongs to);
|
|
1025
1037
|
* there is no per-team roster endpoint. Returns the ids of athletes whose `groups` include the
|
|
1026
1038
|
* given id, matched as a string. Throws when the roster fetch fails.
|
|
1027
1039
|
*/
|
|
1028
|
-
declare function fetchTeamAthleteIds(client: TrainHeroicClient, teamId: number): Promise<number[]>;
|
|
1040
|
+
export declare function fetchTeamAthleteIds(client: TrainHeroicClient, teamId: number): Promise<number[]>;
|
|
1029
1041
|
/**
|
|
1030
1042
|
* Team-wide training volume over an inclusive date window. The `training-summary-athlete`
|
|
1031
|
-
* analytics report
|
|
1032
|
-
*
|
|
1033
|
-
* volume/reps
|
|
1043
|
+
* analytics report returns one row per logged session across all `athleteIds`; `queryAnalytics`
|
|
1044
|
+
* splits oversized requests and merges those rows before this function groups them by athlete,
|
|
1045
|
+
* sums volume/reps, counts sessions, and rolls the athletes up into a team total. Athletes who
|
|
1034
1046
|
* logged nothing in range simply have no rows and are omitted. The windowed counterpart to the
|
|
1035
1047
|
* all-time `fetchRosterActivity` snapshot, which has no date range.
|
|
1036
1048
|
*/
|
|
1037
|
-
declare function teamVolume(client: TrainHeroicClient, args: {
|
|
1049
|
+
export declare function teamVolume(client: TrainHeroicClient, args: {
|
|
1038
1050
|
athleteIds: readonly number[];
|
|
1039
1051
|
dateStart: string;
|
|
1040
1052
|
dateEnd: string;
|
|
1041
1053
|
}): Promise<TeamVolumeReport>;
|
|
1042
1054
|
/** Create a reusable session template in the coach library (`POST /v5/sessions/template`). */
|
|
1043
|
-
declare function createSessionTemplate(client: TrainHeroicClient, args: SessionTemplateCreate): Promise<Record<string, unknown>>;
|
|
1055
|
+
export declare function createSessionTemplate(client: TrainHeroicClient, args: SessionTemplateCreate): Promise<Record<string, unknown>>;
|
|
1044
1056
|
/** First page of the coach session-template library (`GET /1.0/coach/workouts`). */
|
|
1045
|
-
declare const SESSION_TEMPLATES_LIST_PATH = "/1.0/coach/workouts?page=1&pageSize=50";
|
|
1057
|
+
export declare const SESSION_TEMPLATES_LIST_PATH = "/1.0/coach/workouts?page=1&pageSize=50";
|
|
1046
1058
|
//#endregion
|
|
1047
1059
|
//#region src/util.d.ts
|
|
1048
1060
|
/**
|
|
@@ -1054,49 +1066,49 @@ declare const SESSION_TEMPLATES_LIST_PATH = "/1.0/coach/workouts?page=1&pageSize
|
|
|
1054
1066
|
* Example:
|
|
1055
1067
|
* definedProps({ metric, teamId: maybeId, date }) // omits teamId/date if they're undefined
|
|
1056
1068
|
*/
|
|
1057
|
-
declare function definedProps<T extends object>(obj: T): { [K in keyof T]: Exclude<T[K], undefined>; };
|
|
1069
|
+
export declare function definedProps<T extends object>(obj: T): { [K in keyof T]: Exclude<T[K], undefined>; };
|
|
1058
1070
|
//#endregion
|
|
1059
1071
|
//#region src/workout-encode.d.ts
|
|
1060
1072
|
type AdvisoryIndex = Pick<ExerciseIndex, "defaultsMany" | "ensureFresh">;
|
|
1061
|
-
type SetSplit = {
|
|
1073
|
+
export type SetSplit = {
|
|
1062
1074
|
blockTitle: string;
|
|
1063
1075
|
exerciseTitle: string;
|
|
1064
1076
|
setCount: number;
|
|
1065
1077
|
blockCount: number;
|
|
1066
1078
|
};
|
|
1067
|
-
declare const LEADERBOARD_TYPE: Readonly<Record<string, number>>;
|
|
1068
|
-
declare const LEADERBOARD_LABEL: Readonly<Record<number, string>>;
|
|
1069
|
-
type Leaderboard = {
|
|
1079
|
+
export declare const LEADERBOARD_TYPE: Readonly<Record<string, number>>;
|
|
1080
|
+
export declare const LEADERBOARD_LABEL: Readonly<Record<number, string>>;
|
|
1081
|
+
export type Leaderboard = {
|
|
1070
1082
|
isRedzone: number | null;
|
|
1071
1083
|
redzoneType: number;
|
|
1072
1084
|
smallerIsBetter: number | null;
|
|
1073
1085
|
redzoneInstruction: string;
|
|
1074
1086
|
};
|
|
1075
|
-
declare function resolveLeaderboard(block: BlockSpec): Leaderboard;
|
|
1076
|
-
declare function repsList(ex: ExerciseSpec): string[];
|
|
1087
|
+
export declare function resolveLeaderboard(block: BlockSpec): Leaderboard;
|
|
1088
|
+
export declare function repsList(ex: ExerciseSpec): string[];
|
|
1077
1089
|
/** Number of sets that the encoder will write for an exercise. */
|
|
1078
|
-
declare function exerciseSetCount(ex: ExerciseSpec): number;
|
|
1079
|
-
declare function findSetSplits(blocks: readonly BlockSpec[]): SetSplit[];
|
|
1080
|
-
declare function setSplitSummary(blocks: readonly BlockSpec[]): string | null;
|
|
1090
|
+
export declare function exerciseSetCount(ex: ExerciseSpec): number;
|
|
1091
|
+
export declare function findSetSplits(blocks: readonly BlockSpec[]): SetSplit[];
|
|
1092
|
+
export declare function setSplitSummary(blocks: readonly BlockSpec[]): string | null;
|
|
1081
1093
|
/**
|
|
1082
1094
|
* Split blocks so no encoded exercise exceeds TrainHeroic's ten parameter slots.
|
|
1083
1095
|
* Exercises in a superset stay aligned by set range; shorter exercises appear only in
|
|
1084
1096
|
* chunks where they still have sets.
|
|
1085
1097
|
*/
|
|
1086
|
-
declare function splitOversizedBlocks(blocks: readonly BlockSpec[]): BlockSpec[];
|
|
1098
|
+
export declare function splitOversizedBlocks(blocks: readonly BlockSpec[]): BlockSpec[];
|
|
1087
1099
|
/** Build one saveWorkoutSetExercises payload entry with all ten param slots filled. */
|
|
1088
|
-
declare function makeExercise(ex: ExerciseSpec, workoutSetId: number, order: number, key: string): Record<string, unknown>;
|
|
1100
|
+
export declare function makeExercise(ex: ExerciseSpec, workoutSetId: number, order: number, key: string): Record<string, unknown>;
|
|
1089
1101
|
/** Block `type` values the coach calendar accepts (verified in workout-creation.md). */
|
|
1090
|
-
declare const BLOCK_TYPE_CONDITIONING = 1;
|
|
1091
|
-
declare const BLOCK_TYPE_HYPERTROPHY = 2;
|
|
1102
|
+
export declare const BLOCK_TYPE_CONDITIONING = 1;
|
|
1103
|
+
export declare const BLOCK_TYPE_HYPERTROPHY = 2;
|
|
1092
1104
|
/**
|
|
1093
1105
|
* Default block type: text-only (empty exercises) blocks are Conditioning / Circuit (type 1);
|
|
1094
1106
|
* structured exercise blocks default to Hypertrophy (type 2). An explicit `type` always wins.
|
|
1095
1107
|
*/
|
|
1096
|
-
declare function defaultBlockType(block: BlockSpec): number;
|
|
1097
|
-
declare function buildBlockPayload(blocks: readonly BlockSpec[], workoutId: number): Array<Record<string, unknown>>;
|
|
1108
|
+
export declare function defaultBlockType(block: BlockSpec): number;
|
|
1109
|
+
export declare function buildBlockPayload(blocks: readonly BlockSpec[], workoutId: number): Array<Record<string, unknown>>;
|
|
1098
1110
|
/** Flag spec params the API will silently override to the exercise's fixed units. */
|
|
1099
|
-
declare function unitAdvisory(blockTitle: string, ex: ExerciseSpec, defaults: {
|
|
1111
|
+
export declare function unitAdvisory(blockTitle: string, ex: ExerciseSpec, defaults: {
|
|
1100
1112
|
param1: number | null;
|
|
1101
1113
|
param2: number | null;
|
|
1102
1114
|
}): Advisory;
|
|
@@ -1106,10 +1118,10 @@ declare function unitAdvisory(blockTitle: string, ex: ExerciseSpec, defaults: {
|
|
|
1106
1118
|
* index is loaded first, otherwise the defaults map is empty on a cold index and every
|
|
1107
1119
|
* advisory is silently dropped.
|
|
1108
1120
|
*/
|
|
1109
|
-
declare function collectAdvisories(blocks: readonly BlockSpec[], index: AdvisoryIndex): Promise<Advisory>;
|
|
1121
|
+
export declare function collectAdvisories(blocks: readonly BlockSpec[], index: AdvisoryIndex): Promise<Advisory>;
|
|
1110
1122
|
//#endregion
|
|
1111
1123
|
//#region src/workout-session.d.ts
|
|
1112
|
-
type BuildOptions = {
|
|
1124
|
+
export type BuildOptions = {
|
|
1113
1125
|
programId: number;
|
|
1114
1126
|
blocks: BlockSpec[];
|
|
1115
1127
|
date?: WorkoutDate;
|
|
@@ -1125,8 +1137,8 @@ type BuildOptions = {
|
|
|
1125
1137
|
* on personal calendars (Coach Plan / `personal_cal`). Shared by `buildSession` and
|
|
1126
1138
|
* `copySession` so the hint stays in one place.
|
|
1127
1139
|
*/
|
|
1128
|
-
declare function calendarWriteError(method: string, path: string, status: number, detail: string): Error;
|
|
1129
|
-
declare function buildSession(client: TrainHeroicClient, opts: BuildOptions): Promise<{
|
|
1140
|
+
export declare function calendarWriteError(method: string, path: string, status: number, detail: string): Error;
|
|
1141
|
+
export declare function buildSession(client: TrainHeroicClient, opts: BuildOptions): Promise<{
|
|
1130
1142
|
pwId: number;
|
|
1131
1143
|
workoutId: number;
|
|
1132
1144
|
}>;
|
|
@@ -1136,14 +1148,14 @@ declare function buildSession(client: TrainHeroicClient, opts: BuildOptions): Pr
|
|
|
1136
1148
|
* the whole object back with `instruction` set and `sets`/`setKeys` as a flat list of block
|
|
1137
1149
|
* ids. This does NOT change publish state: `published` is sent exactly as it is on `pw`.
|
|
1138
1150
|
*/
|
|
1139
|
-
declare function setSessionInstruction(client: TrainHeroicClient, workoutId: number, pw: Record<string, unknown>, instruction: string, blockIds: number[]): Promise<void>;
|
|
1140
|
-
declare function removeSession(client: TrainHeroicClient, programId: number, pwId: number): Promise<void>;
|
|
1141
|
-
declare function publishSession(client: TrainHeroicClient, pwId: number): Promise<void>;
|
|
1142
|
-
declare function readSession(client: TrainHeroicClient, programId: number, date: WorkoutDate, pwId: number): Promise<ReadResult>;
|
|
1151
|
+
export declare function setSessionInstruction(client: TrainHeroicClient, workoutId: number, pw: Record<string, unknown>, instruction: string, blockIds: number[]): Promise<void>;
|
|
1152
|
+
export declare function removeSession(client: TrainHeroicClient, programId: number, pwId: number): Promise<void>;
|
|
1153
|
+
export declare function publishSession(client: TrainHeroicClient, pwId: number): Promise<void>;
|
|
1154
|
+
export declare function readSession(client: TrainHeroicClient, programId: number, date: WorkoutDate, pwId: number): Promise<ReadResult>;
|
|
1143
1155
|
//#endregion
|
|
1144
1156
|
//#region src/messaging.d.ts
|
|
1145
1157
|
/** Live list of chat streams, flattened to (stream, kind) tuples. */
|
|
1146
|
-
declare function fetchStreams(client: TrainHeroicClient): Promise<Array<{
|
|
1158
|
+
export declare function fetchStreams(client: TrainHeroicClient): Promise<Array<{
|
|
1147
1159
|
stream: Record<string, unknown>;
|
|
1148
1160
|
kind: string;
|
|
1149
1161
|
}>>;
|
|
@@ -1151,10 +1163,10 @@ declare function fetchStreams(client: TrainHeroicClient): Promise<Array<{
|
|
|
1151
1163
|
* The exact chat comment body the web app sends. The non-obvious required field is
|
|
1152
1164
|
* `feed_id` (the stream id repeated in the body); omitting it returns 400.
|
|
1153
1165
|
*/
|
|
1154
|
-
declare function buildCommentPayload(streamId: number, text: string, replyTo?: number | null): Record<string, unknown>;
|
|
1155
|
-
declare function sendComment(client: TrainHeroicClient, streamId: number, text: string, replyTo?: number | null): Promise<Record<string, unknown>>;
|
|
1156
|
-
declare function deleteComment(client: TrainHeroicClient, streamId: number, commentId: number): Promise<unknown>;
|
|
1157
|
-
declare function readLive(client: TrainHeroicClient, streamId: number, limit?: number, afterCommentId?: number): Promise<unknown[]>;
|
|
1166
|
+
export declare function buildCommentPayload(streamId: number, text: string, replyTo?: number | null): Record<string, unknown>;
|
|
1167
|
+
export declare function sendComment(client: TrainHeroicClient, streamId: number, text: string, replyTo?: number | null): Promise<Record<string, unknown>>;
|
|
1168
|
+
export declare function deleteComment(client: TrainHeroicClient, streamId: number, commentId: number): Promise<unknown>;
|
|
1169
|
+
export declare function readLive(client: TrainHeroicClient, streamId: number, limit?: number, afterCommentId?: number): Promise<unknown[]>;
|
|
1158
1170
|
//#endregion
|
|
1159
1171
|
//#region src/exercise-index.d.ts
|
|
1160
1172
|
/**
|
|
@@ -1162,7 +1174,7 @@ declare function readLive(client: TrainHeroicClient, streamId: number, limit?: n
|
|
|
1162
1174
|
* LibraryCache (JSON file for a CLI/local server, in-memory by default). Same
|
|
1163
1175
|
* resolve/search/unit behavior as the D1-backed store, with no database.
|
|
1164
1176
|
*/
|
|
1165
|
-
declare class ExerciseLibrary implements ExerciseIndex {
|
|
1177
|
+
export declare class ExerciseLibrary implements ExerciseIndex {
|
|
1166
1178
|
#private;
|
|
1167
1179
|
constructor(client: TrainHeroicClient, cache?: LibraryCache);
|
|
1168
1180
|
ensureFresh(): Promise<void>;
|
|
@@ -1178,4 +1190,4 @@ declare class ExerciseLibrary implements ExerciseIndex {
|
|
|
1178
1190
|
stats(): Promise<Record<string, unknown>>;
|
|
1179
1191
|
}
|
|
1180
1192
|
//#endregion
|
|
1181
|
-
export {
|
|
1193
|
+
export { type ExerciseSetInput, type ExerciseSetPayload, LibraryCache, LibrarySnapshot, MemoryLibraryCache, type RequestBodySummary, type SetWriteMode, type TrainHeroicHttpErrorDiagnostics, type TrainHeroicHttpErrorHandler, type TrainHeroicTransport, chunk };
|