Training
Training routines (step-based and timed timelines), performed workouts, thresholds, targets, ramps, and load bases.
@fitdata/training defines portable training contracts independently of any application or database. It covers strength sessions, timed indoor classes, wearable activities, and personal performance thresholds.
Record kinds
| Kind | Lifecycle | Required training fields | Optional fields |
|---|---|---|---|
training.routine | version | name, namespaced sport, structure (steps or timeline) | description, scheduled |
training.workout | revision | Namespaced sport, interval | name, movingSeconds, routine, status, metrics, steps, sessionRpe |
training.threshold | revision | metric, quantity, effectiveAt, method (tested or estimated) | basis, exercise |
training.workoutunifies wearable activity summaries (metrics,movingSeconds) and structured exercise logs (steps).movingSecondscannot exceedinterval.durationSeconds.training.routineunifies reusable class blueprints (nosubject, noscheduled) and athlete-assigned sessions (optionalsubjectandscheduled).
Routine structures
A training.routine declares one of two execution layouts in structure:
Step-based (structure.kind: "steps")
Built for strength, mobility, and circuit training where duration follows execution pace:
steps:1–1,000ordered planned steps.- Each step has a local
id,exercise({ id, name? }),1–20metrictargets, and optionalrole,load,restSeconds, andside.
Timeline-based (structure.kind: "timeline")
Built for indoor cycling classes, erg workouts, and timed audio sessions running on an elapsed clock:
durationSeconds: total class duration.segments: ordered, non-overlapping windows withid,startSeconds,endSeconds,1–20targets, and optionallabelandrole.cues(optional): timed cues withatSecondsand at least one ofposture,resistance, ortext.
Presentation concerns (music playlists, video overlays, player themes) stay outside FitData or under namespaced extensions.
{
"kind": "training.routine",
"id": "example:five-minute-climb",
"version": "1",
"sport": "fitdata:indoor_cycling",
"name": "Five-minute climb",
"structure": {
"kind": "timeline",
"durationSeconds": 300,
"segments": [
{
"id": "climb",
"startSeconds": 0,
"endSeconds": 300,
"targets": [
{
"metric": "fitdata:power",
"target": {
"kind": "ramp",
"basis": "fitdata:ftp",
"unit": "%",
"start": 70,
"end": 85,
"interpolation": "linear"
}
},
{
"metric": "fitdata:cadence",
"target": {
"kind": "range",
"unit": "/min",
"min": 75,
"max": 85
}
}
]
}
],
"cues": [
{ "atSeconds": 0, "posture": "seated", "text": "Start seated." },
{ "atSeconds": 180, "posture": "standing", "text": "Stand for the final two minutes." }
]
}
}Performed steps and results
Performed steps inside training.workout carry local id, exercise, tagged result, and optional plannedStepId, role, and side.
completedorpartialresults carry1–20metric amounts plus optionalloadandrpe(0–10).skippedresults require areason.- Setting
plannedStepIdrequires aroutinereference ({ id, version }) on the workout, and document validation verifies thatplannedStepIdexists in that routine version's steps or segments.
Targets and loads
Every target pairs a namespaced metric with a tagged target:
Target kind | Fields and rules |
|---|---|
exact | Quantity value and unit |
range | min, max, and unit; min <= max |
relative | Non-negative fraction plus basis code (e.g. fitdata:ftp), pinned threshold reference, or both |
ramp | start, end, unit, optional interpolation (linear or step), plus optional basis or pinned threshold (relative ramps require % or 1) |
Using a basis code without a pinned threshold lets one routine be shared across athletes and resolved dynamically against each athlete's active training.threshold. When a threshold reference is pinned, its metric must match the target metric.
Loads separate magnitude from mechanical meaning:
basis | Meaning | Allowed units |
|---|---|---|
external_total | Total external load | kg, [lb_av] |
external_per_hand | External load per hand | kg, [lb_av] |
added | Load added to bodyweight | kg, [lb_av] |
assisted | Positive assistance magnitude | kg, [lb_av] |
bodyweight_fraction | Fraction of bodyweight | 1 |
Validation entry points
import { validateTrainingRecord, type Workout } from "@fitdata/training";
const result = validateTrainingRecord(input);
if (result.ok && result.value.kind === "training.workout") {
const workout: Workout = result.value;
console.log(workout.sport, result.issues);
}validateTrainingRecord checks local structure, quantities, loads, ramps, segment windows, cues, local step IDs, and scheduled timezones. Run validateDocument from fitdata to verify cross-record routine and threshold references.