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