@sctg/openclaw-coach 0.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +296 -66
- package/assets/fonts/Inter_400Regular.ttf +0 -0
- package/assets/fonts/Inter_600SemiBold.ttf +0 -0
- package/assets/fonts/LICENSE.txt +93 -0
- package/assets/logo.png +0 -0
- package/assets/logo.svg +62 -0
- package/dist/charts/build.d.ts +71 -0
- package/dist/charts/build.js +276 -0
- package/dist/charts/labels.d.ts +38 -0
- package/dist/charts/labels.js +73 -0
- package/dist/charts/render.d.ts +10 -0
- package/dist/charts/render.js +26 -0
- package/dist/charts/svg.d.ts +47 -0
- package/dist/charts/svg.js +92 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.js +38 -0
- package/dist/dates.d.ts +22 -0
- package/dist/dates.js +71 -0
- package/dist/garmin/gc.d.ts +25 -0
- package/dist/garmin/gc.js +81 -0
- package/dist/garmin/normalize.d.ts +20 -0
- package/dist/garmin/normalize.js +132 -0
- package/dist/index.js +188 -163
- package/dist/profile.d.ts +4 -0
- package/dist/profile.js +43 -0
- package/dist/science/associations.d.ts +56 -0
- package/dist/science/associations.js +102 -0
- package/dist/science/healthspan.d.ts +25 -0
- package/dist/science/healthspan.js +89 -0
- package/dist/science/hrv.d.ts +61 -0
- package/dist/science/hrv.js +119 -0
- package/dist/science/load.d.ts +107 -0
- package/dist/science/load.js +228 -0
- package/dist/science/performance.d.ts +93 -0
- package/dist/science/performance.js +191 -0
- package/dist/science/readiness.d.ts +47 -0
- package/dist/science/readiness.js +97 -0
- package/dist/science/recovery.d.ts +74 -0
- package/dist/science/recovery.js +173 -0
- package/dist/science/sleep.d.ts +79 -0
- package/dist/science/sleep.js +165 -0
- package/dist/science/stats.d.ts +50 -0
- package/dist/science/stats.js +201 -0
- package/dist/science/strength.d.ts +47 -0
- package/dist/science/strength.js +120 -0
- package/dist/store.d.ts +36 -0
- package/dist/store.js +78 -0
- package/dist/sync.d.ts +36 -0
- package/dist/sync.js +145 -0
- package/dist/tools.d.ts +427 -0
- package/dist/tools.js +721 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.js +2 -0
- package/docs/SCIENCE.md +717 -0
- package/examples/ATHLETE-fr.md +72 -0
- package/examples/ATHLETE.md +74 -0
- package/examples/PLAN-fr.md +55 -0
- package/examples/PLAN.md +55 -0
- package/openclaw.plugin.json +152 -5
- package/package.json +14 -3
- package/skills/coach/SKILL.md +283 -208
package/dist/dates.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Calendar-date helpers. Dates are `YYYY-MM-DD` strings in the athlete's timezone. */
|
|
2
|
+
export declare function isIsoDate(value: unknown): value is string;
|
|
3
|
+
export declare function addDays(date: string, days: number): string;
|
|
4
|
+
/** Whole days from `from` to `to` (positive when `to` is later). */
|
|
5
|
+
export declare function daysBetween(from: string, to: string): number;
|
|
6
|
+
/** Every date from `start` to `end`, both included. */
|
|
7
|
+
export declare function dateRange(start: string, end: string): string[];
|
|
8
|
+
/** 0 = Monday ... 6 = Sunday. */
|
|
9
|
+
export declare function weekdayIndex(date: string): number;
|
|
10
|
+
/** Monday of the week containing `date`. */
|
|
11
|
+
export declare function weekStart(date: string): string;
|
|
12
|
+
/** Today's calendar date in an IANA timezone. */
|
|
13
|
+
export declare function todayIn(timezone: string, now?: Date): string;
|
|
14
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Minutes after midnight of a local wall-clock timestamp (`YYYY-MM-DDTHH:MM:SS`,
|
|
17
|
+
* no zone suffix, as written by `gc daily`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function clockMinutes(localIso: string | null | undefined): number | null;
|
|
20
|
+
/** Epoch minutes of a local wall-clock timestamp, read as if it were UTC. */
|
|
21
|
+
export declare function localEpochMinutes(localIso: string | null | undefined): number | null;
|
|
22
|
+
export declare function formatClock(minutes: number): string;
|
package/dist/dates.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Calendar-date helpers. Dates are `YYYY-MM-DD` strings in the athlete's timezone. */
|
|
2
|
+
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
3
|
+
const DAY_MS = 86_400_000;
|
|
4
|
+
export function isIsoDate(value) {
|
|
5
|
+
if (typeof value !== "string" || !ISO_DATE.test(value))
|
|
6
|
+
return false;
|
|
7
|
+
const time = Date.parse(`${value}T00:00:00Z`);
|
|
8
|
+
return Number.isFinite(time) && new Date(time).toISOString().slice(0, 10) === value;
|
|
9
|
+
}
|
|
10
|
+
function toUtc(date) {
|
|
11
|
+
return Date.parse(`${date}T00:00:00Z`);
|
|
12
|
+
}
|
|
13
|
+
export function addDays(date, days) {
|
|
14
|
+
return new Date(toUtc(date) + days * DAY_MS).toISOString().slice(0, 10);
|
|
15
|
+
}
|
|
16
|
+
/** Whole days from `from` to `to` (positive when `to` is later). */
|
|
17
|
+
export function daysBetween(from, to) {
|
|
18
|
+
return Math.round((toUtc(to) - toUtc(from)) / DAY_MS);
|
|
19
|
+
}
|
|
20
|
+
/** Every date from `start` to `end`, both included. */
|
|
21
|
+
export function dateRange(start, end) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (let day = start; day <= end; day = addDays(day, 1))
|
|
24
|
+
out.push(day);
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
/** 0 = Monday ... 6 = Sunday. */
|
|
28
|
+
export function weekdayIndex(date) {
|
|
29
|
+
return (new Date(toUtc(date)).getUTCDay() + 6) % 7;
|
|
30
|
+
}
|
|
31
|
+
/** Monday of the week containing `date`. */
|
|
32
|
+
export function weekStart(date) {
|
|
33
|
+
return addDays(date, -weekdayIndex(date));
|
|
34
|
+
}
|
|
35
|
+
/** Today's calendar date in an IANA timezone. */
|
|
36
|
+
export function todayIn(timezone, now = new Date()) {
|
|
37
|
+
// The en-CA locale formats dates as YYYY-MM-DD.
|
|
38
|
+
return new Intl.DateTimeFormat("en-CA", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit" }).format(now);
|
|
39
|
+
}
|
|
40
|
+
export function isValidTimezone(timezone) {
|
|
41
|
+
try {
|
|
42
|
+
new Intl.DateTimeFormat("en-CA", { timeZone: timezone });
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Minutes after midnight of a local wall-clock timestamp (`YYYY-MM-DDTHH:MM:SS`,
|
|
51
|
+
* no zone suffix, as written by `gc daily`).
|
|
52
|
+
*/
|
|
53
|
+
export function clockMinutes(localIso) {
|
|
54
|
+
if (typeof localIso !== "string")
|
|
55
|
+
return null;
|
|
56
|
+
const match = /T(\d{2}):(\d{2})/.exec(localIso);
|
|
57
|
+
if (!match)
|
|
58
|
+
return null;
|
|
59
|
+
return Number(match[1]) * 60 + Number(match[2]);
|
|
60
|
+
}
|
|
61
|
+
/** Epoch minutes of a local wall-clock timestamp, read as if it were UTC. */
|
|
62
|
+
export function localEpochMinutes(localIso) {
|
|
63
|
+
if (typeof localIso !== "string")
|
|
64
|
+
return null;
|
|
65
|
+
const time = Date.parse(`${localIso.slice(0, 19)}Z`);
|
|
66
|
+
return Number.isFinite(time) ? Math.round(time / 60_000) : null;
|
|
67
|
+
}
|
|
68
|
+
export function formatClock(minutes) {
|
|
69
|
+
const wrapped = ((Math.round(minutes) % 1440) + 1440) % 1440;
|
|
70
|
+
return `${String(Math.floor(wrapped / 60)).padStart(2, "0")}:${String(wrapped % 60).padStart(2, "0")}`;
|
|
71
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the garmin-cli binary (`gc`). Arguments are passed as an array to
|
|
3
|
+
* execFile, never through a shell, and callers validate every value coming
|
|
4
|
+
* from a tool call. Failures are returned as stable codes, never thrown, and
|
|
5
|
+
* never include the CLI's full output.
|
|
6
|
+
*/
|
|
7
|
+
export type GcErrorCode = "not_configured" | "auth" | "rate_limited" | "timeout" | "unsupported" | "parse_error" | "connection" | "error";
|
|
8
|
+
export type GcResult<T = unknown> = {
|
|
9
|
+
ok: true;
|
|
10
|
+
data: T;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
code: GcErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function classifyGcError(error: {
|
|
17
|
+
code?: unknown;
|
|
18
|
+
killed?: boolean;
|
|
19
|
+
signal?: unknown;
|
|
20
|
+
} | null, stderr: string): GcErrorCode;
|
|
21
|
+
export type GcRunner = (args: string[], options?: {
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}) => Promise<GcResult>;
|
|
24
|
+
/** Builds a runner with its own concurrency limit (Garmin rate-limits bursts). */
|
|
25
|
+
export declare function createGcRunner(binary: string): GcRunner;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs the garmin-cli binary (`gc`). Arguments are passed as an array to
|
|
3
|
+
* execFile, never through a shell, and callers validate every value coming
|
|
4
|
+
* from a tool call. Failures are returned as stable codes, never thrown, and
|
|
5
|
+
* never include the CLI's full output.
|
|
6
|
+
*/
|
|
7
|
+
import { execFile } from "node:child_process";
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
9
|
+
const MAX_BUFFER_BYTES = 32 * 1024 * 1024;
|
|
10
|
+
const MAX_CONCURRENT = 3;
|
|
11
|
+
export function classifyGcError(error, stderr) {
|
|
12
|
+
if (error?.code === "ENOENT" || error?.code === "EACCES")
|
|
13
|
+
return "not_configured";
|
|
14
|
+
if (error?.killed || error?.signal === "SIGTERM")
|
|
15
|
+
return "timeout";
|
|
16
|
+
const text = stderr.toLowerCase();
|
|
17
|
+
// Checked first: a usage message mentions "--tokenstore" and must not read as an auth failure.
|
|
18
|
+
if (text.includes("no such command") || text.includes("no such option") || text.includes("usage:"))
|
|
19
|
+
return "unsupported";
|
|
20
|
+
if (text.includes("authentication") || text.includes("gc login") || text.includes("not logged in"))
|
|
21
|
+
return "auth";
|
|
22
|
+
if (text.includes("rate limit") || text.includes("too many requests") || text.includes("429"))
|
|
23
|
+
return "rate_limited";
|
|
24
|
+
if (text.includes("connection error") || text.includes("timed out") || text.includes("max retries"))
|
|
25
|
+
return "connection";
|
|
26
|
+
return "error";
|
|
27
|
+
}
|
|
28
|
+
const MESSAGES = {
|
|
29
|
+
not_configured: "The gc binary was not found or is not executable (check gcBinary).",
|
|
30
|
+
auth: "Garmin session missing or expired: run `gc login` in the Gateway environment.",
|
|
31
|
+
rate_limited: "Garmin Connect is rate limiting requests: wait before retrying.",
|
|
32
|
+
timeout: "The gc command timed out.",
|
|
33
|
+
unsupported: "This gc version does not support the command (garmin-cli >= 0.4.0 is required for `gc daily`).",
|
|
34
|
+
parse_error: "gc returned output that is not valid JSON.",
|
|
35
|
+
connection: "Could not reach Garmin Connect.",
|
|
36
|
+
error: "The gc command failed.",
|
|
37
|
+
};
|
|
38
|
+
/** Builds a runner with its own concurrency limit (Garmin rate-limits bursts). */
|
|
39
|
+
export function createGcRunner(binary) {
|
|
40
|
+
let active = 0;
|
|
41
|
+
const waiting = [];
|
|
42
|
+
const acquire = () => new Promise((resolve) => {
|
|
43
|
+
if (active < MAX_CONCURRENT) {
|
|
44
|
+
active += 1;
|
|
45
|
+
resolve();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
waiting.push(resolve);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const release = () => {
|
|
52
|
+
const next = waiting.shift();
|
|
53
|
+
if (next)
|
|
54
|
+
next();
|
|
55
|
+
else
|
|
56
|
+
active -= 1;
|
|
57
|
+
};
|
|
58
|
+
return async (args, options = {}) => {
|
|
59
|
+
await acquire();
|
|
60
|
+
try {
|
|
61
|
+
return await new Promise((resolve) => {
|
|
62
|
+
execFile(binary, [...args, "--format", "json"], { timeout: options.timeoutMs ?? DEFAULT_TIMEOUT_MS, maxBuffer: MAX_BUFFER_BYTES }, (error, stdout, stderr) => {
|
|
63
|
+
if (error) {
|
|
64
|
+
const code = classifyGcError(error, String(stderr ?? ""));
|
|
65
|
+
resolve({ ok: false, code, message: MESSAGES[code] });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
resolve({ ok: true, data: JSON.parse(String(stdout)) });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
resolve({ ok: false, code: "parse_error", message: MESSAGES.parse_error });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
release();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Turns gc output into the plugin's types. Unknown shapes give null fields, never guesses. */
|
|
2
|
+
import type { Split } from "../science/performance.ts";
|
|
3
|
+
import type { Activity, DayRecord } from "../types.ts";
|
|
4
|
+
type Json = Record<string, unknown>;
|
|
5
|
+
/** Validates the envelope of `gc daily` and returns its day records. */
|
|
6
|
+
export declare function parseDailyExport(payload: unknown): {
|
|
7
|
+
days: DayRecord[];
|
|
8
|
+
errors: Record<string, string>;
|
|
9
|
+
} | null;
|
|
10
|
+
/** True when the record holds at least one measured signal. */
|
|
11
|
+
export declare function hasSignal(day: DayRecord): boolean;
|
|
12
|
+
export declare function normalizeActivity(raw: unknown): Activity | null;
|
|
13
|
+
export declare function normalizeActivities(payload: unknown): Activity[];
|
|
14
|
+
/** Laps of `gc activities splits ID` (the `lapDTOs` list). */
|
|
15
|
+
export declare function normalizeSplits(payload: unknown): Split[];
|
|
16
|
+
/** Lactate-threshold heart rate from `gc metrics lactate-threshold`. */
|
|
17
|
+
export declare function lthrFromPayload(payload: unknown): number | null;
|
|
18
|
+
/** Garmin's own readiness, status and load figures for the day, reduced to a few fields. */
|
|
19
|
+
export declare function garminDaySignals(readiness: unknown, status: unknown): Json;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Turns gc output into the plugin's types. Unknown shapes give null fields, never guesses. */
|
|
2
|
+
import { isIsoDate } from "../dates.js";
|
|
3
|
+
import { isNum } from "../science/stats.js";
|
|
4
|
+
function obj(value) {
|
|
5
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
6
|
+
}
|
|
7
|
+
function num(source, ...keys) {
|
|
8
|
+
for (const key of keys) {
|
|
9
|
+
const value = source?.[key];
|
|
10
|
+
if (isNum(value))
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function positive(source, ...keys) {
|
|
16
|
+
const value = num(source, ...keys);
|
|
17
|
+
return value !== null && value > 0 ? value : null;
|
|
18
|
+
}
|
|
19
|
+
/** Validates the envelope of `gc daily` and returns its day records. */
|
|
20
|
+
export function parseDailyExport(payload) {
|
|
21
|
+
const root = obj(payload);
|
|
22
|
+
if (!root || root.schemaVersion !== 1 || !Array.isArray(root.days))
|
|
23
|
+
return null;
|
|
24
|
+
const days = root.days.filter((day) => isIsoDate(obj(day)?.date) && Array.isArray(obj(day)?.sources));
|
|
25
|
+
const errors = obj(root.errors) ?? {};
|
|
26
|
+
return { days, errors: Object.fromEntries(Object.entries(errors).map(([key, value]) => [key, String(value)])) };
|
|
27
|
+
}
|
|
28
|
+
/** True when the record holds at least one measured signal. */
|
|
29
|
+
export function hasSignal(day) {
|
|
30
|
+
return Boolean(day.sleep || day.hrv || day.restingHr !== null || day.stress || day.bodyBattery || day.respiration || day.spo2);
|
|
31
|
+
}
|
|
32
|
+
export function normalizeActivity(raw) {
|
|
33
|
+
const a = obj(raw);
|
|
34
|
+
const id = a?.activityId;
|
|
35
|
+
const start = typeof a?.startTimeLocal === "string" ? a.startTimeLocal : null;
|
|
36
|
+
if (!a || (typeof id !== "number" && typeof id !== "string") || !start || !isIsoDate(start.slice(0, 10)))
|
|
37
|
+
return null;
|
|
38
|
+
const zones = [1, 2, 3, 4, 5].map((zone) => num(a, `hrTimeInZone_${zone}`));
|
|
39
|
+
const type = obj(a.activityType);
|
|
40
|
+
return {
|
|
41
|
+
id: String(id),
|
|
42
|
+
date: start.slice(0, 10),
|
|
43
|
+
startLocal: start.replace(" ", "T").slice(0, 19),
|
|
44
|
+
type: typeof type?.typeKey === "string" ? type.typeKey : "unknown",
|
|
45
|
+
name: typeof a.activityName === "string" ? a.activityName : null,
|
|
46
|
+
durationS: positive(a, "duration"),
|
|
47
|
+
movingS: positive(a, "movingDuration"),
|
|
48
|
+
distanceM: positive(a, "distance"),
|
|
49
|
+
elevGainM: num(a, "elevationGain"),
|
|
50
|
+
elevLossM: num(a, "elevationLoss"),
|
|
51
|
+
avgHr: positive(a, "averageHR"),
|
|
52
|
+
maxHr: positive(a, "maxHR"),
|
|
53
|
+
hrZonesS: zones.some((value) => value !== null && value > 0) ? zones.map((value) => value ?? 0) : null,
|
|
54
|
+
aerobicTE: positive(a, "aerobicTrainingEffect"),
|
|
55
|
+
anaerobicTE: num(a, "anaerobicTrainingEffect"),
|
|
56
|
+
garminLoad: positive(a, "activityTrainingLoad"),
|
|
57
|
+
avgSpeedMs: positive(a, "averageSpeed"),
|
|
58
|
+
gapSpeedMs: positive(a, "avgGradeAdjustedSpeed"),
|
|
59
|
+
avgPowerW: positive(a, "avgPower"),
|
|
60
|
+
normPowerW: positive(a, "normPower"),
|
|
61
|
+
kcal: positive(a, "calories"),
|
|
62
|
+
vo2max: positive(a, "vO2MaxValue"),
|
|
63
|
+
tempMinC: num(a, "minTemperature"),
|
|
64
|
+
tempMaxC: num(a, "maxTemperature"),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function normalizeActivities(payload) {
|
|
68
|
+
if (!Array.isArray(payload))
|
|
69
|
+
return [];
|
|
70
|
+
return payload.map(normalizeActivity).filter((activity) => activity !== null);
|
|
71
|
+
}
|
|
72
|
+
/** Laps of `gc activities splits ID` (the `lapDTOs` list). */
|
|
73
|
+
export function normalizeSplits(payload) {
|
|
74
|
+
const laps = obj(payload)?.lapDTOs;
|
|
75
|
+
if (!Array.isArray(laps))
|
|
76
|
+
return [];
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const raw of laps) {
|
|
79
|
+
const lap = obj(raw);
|
|
80
|
+
const durationS = positive(lap, "movingDuration", "duration");
|
|
81
|
+
const distanceM = positive(lap, "distance");
|
|
82
|
+
if (durationS === null || distanceM === null)
|
|
83
|
+
continue;
|
|
84
|
+
out.push({
|
|
85
|
+
durationS,
|
|
86
|
+
distanceM,
|
|
87
|
+
avgHr: positive(lap, "averageHR"),
|
|
88
|
+
elevGainM: num(lap, "elevationGain"),
|
|
89
|
+
elevLossM: num(lap, "elevationLoss"),
|
|
90
|
+
gapSpeedMs: positive(lap, "avgGradeAdjustedSpeed"),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
/** Lactate-threshold heart rate from `gc metrics lactate-threshold`. */
|
|
96
|
+
export function lthrFromPayload(payload) {
|
|
97
|
+
const root = obj(payload);
|
|
98
|
+
const block = obj(root?.speed_and_heart_rate) ?? root;
|
|
99
|
+
const value = positive(block, "heartRate", "lactateThresholdHeartRate");
|
|
100
|
+
return value !== null && value >= 100 && value <= 210 ? Math.round(value) : null;
|
|
101
|
+
}
|
|
102
|
+
/** Garmin's own readiness, status and load figures for the day, reduced to a few fields. */
|
|
103
|
+
export function garminDaySignals(readiness, status) {
|
|
104
|
+
const first = Array.isArray(readiness) ? obj(readiness[0]) : obj(readiness);
|
|
105
|
+
const out = {};
|
|
106
|
+
if (first) {
|
|
107
|
+
out.trainingReadiness = {
|
|
108
|
+
score: num(first, "score"),
|
|
109
|
+
level: first.level ?? null,
|
|
110
|
+
recoveryTimeMin: num(first, "recoveryTime"),
|
|
111
|
+
acuteLoad: num(first, "acuteLoad"),
|
|
112
|
+
sleepScore: num(first, "sleepScore"),
|
|
113
|
+
hrvWeeklyAverageMs: num(first, "hrvWeeklyAverage"),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const root = obj(status);
|
|
117
|
+
const vo2 = obj(obj(root?.mostRecentVO2Max)?.generic);
|
|
118
|
+
if (vo2)
|
|
119
|
+
out.vo2max = { value: num(vo2, "vo2MaxPreciseValue", "vo2MaxValue"), date: vo2.calendarDate ?? null };
|
|
120
|
+
const latest = obj(obj(root?.mostRecentTrainingStatus)?.latestTrainingStatusData);
|
|
121
|
+
const device = latest ? obj(Object.values(latest)[0]) : null;
|
|
122
|
+
if (device) {
|
|
123
|
+
const acute = obj(device.acuteTrainingLoadDTO);
|
|
124
|
+
out.trainingStatus = {
|
|
125
|
+
phrase: device.trainingStatusFeedbackPhrase ?? null,
|
|
126
|
+
acuteLoad: num(acute, "dailyTrainingLoadAcute"),
|
|
127
|
+
chronicLoad: num(acute, "dailyTrainingLoadChronic"),
|
|
128
|
+
loadRatio: num(acute, "dailyAcuteChronicWorkloadRatio"),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|