Merge branch 'main' into lot-1f-deploiement

This commit is contained in:
Pierre MARTIN
2026-11-18 01:00:02 +01:00
14 changed files with 122 additions and 27 deletions
+2 -1
View File
@@ -68,7 +68,7 @@ export const EVENT_VERSION = 1;
* | Envelope<"TrackingModeSet", {key: string, mode: import("./vocabulary.js").TrackingMode|null}>
* | Envelope<"WeightRecorded", {date: string, kg: number}>
* | Envelope<"WeightDeleted", {date: string}>
* | Envelope<"ProgramProposed", {program: import("./program.js").Program, source: import("./vocabulary.js").ProgramSource, reason: string}>
* | Envelope<"ProgramProposed", {program: import("./program.js").Program, source: import("./vocabulary.js").ProgramSource, reason: string, profile?: import("./profile.js").Profile}>
* | Envelope<"ProgramAdopted", {program: import("./program.js").Program, source: import("./vocabulary.js").ProgramSource, reason?: string, proposalId?: string}>
* | Envelope<"ProposalRejected", {proposalId: string, reason?: string}>
* | Envelope<"ProfileUpdated", {profile: import("./profile.js").Profile}>
@@ -127,6 +127,7 @@ const DATA_CHECKS = {
ProgramProposed: (d) =>
!PROGRAM_SOURCES.includes(d.source) ? "source inconnue"
: typeof d.reason !== "string" ? "raison manquante"
: d.profile !== undefined && validateProfile(d.profile).length ? "profil proposé : " + validateProfile(d.profile)[0]
: validateProgram(d.program)[0] ?? null,
ProgramAdopted: (d) =>
!PROGRAM_SOURCES.includes(d.source) ? "source inconnue"
@@ -1,10 +1,11 @@
// Programme proposé au premier lancement : celui d'Atelier, pensé pour un
// entraînement à domicile (banc, barre, haltères, élastiques).
// Programme d'exemple : celui d'Atelier, pensé pour un entraînement à domicile
// (banc, barre, haltères, élastiques). Il n'est jamais imposé : l'utilisateur
// peut le choisir à l'accueil, comme une proposition à valider (ADR 0008).
/** @type {import("./program.js").Program} */
export const DEFAULT_PROGRAM =
export const EXAMPLE_PROGRAM =
{
"name": "Programme de départ",
"name": "Programme d'exemple : home gym",
"subtitle": "Trois séances de fonte, deux sorties. On répète, on ajoute 2,5 kg quand ça passe.",
"sessions": [
{
+7 -4
View File
@@ -2,7 +2,6 @@
// tourne dans l'app et dans le serveur MCP.
import { compareEvents, validateEvent } from "./events.js";
import { DEFAULT_PROGRAM } from "./default-program.js";
import { DEFAULT_PROFILE } from "./profile.js";
/**
@@ -27,11 +26,12 @@ import { DEFAULT_PROFILE } from "./profile.js";
* @property {import("./vocabulary.js").ProgramSource} source
* @property {string} reason
* @property {import("./program.js").Program} program
* @property {import("./profile.js").Profile|null} profile profil proposé avec le programme, s'il y en a un
*/
/**
* @typedef {object} State
* @property {import("./program.js").Program} program programme courant
* @property {import("./program.js").Program|null} program programme courant ; null tant qu'aucun n'est adopté (accueil, ADR 0008)
* @property {ProgramVersion[]} programVersions du plus ancien au plus récent
* @property {Proposal[]} proposals en attente de décision
* @property {import("./profile.js").Profile} profile
@@ -49,7 +49,7 @@ import { DEFAULT_PROFILE } from "./profile.js";
/** @returns {State} */
export function emptyState() {
return {
program: structuredClone(DEFAULT_PROGRAM),
program: null,
programVersions: [],
proposals: [],
profile: structuredClone(DEFAULT_PROFILE),
@@ -122,7 +122,10 @@ export function foldEvents(events) {
weights.delete(e.data.date);
break;
case "ProgramProposed":
proposals.set(e.id, { id: e.id, at: e.at, source: e.data.source, reason: e.data.reason, program: structuredClone(e.data.program) });
proposals.set(e.id, {
id: e.id, at: e.at, source: e.data.source, reason: e.data.reason,
program: structuredClone(e.data.program), profile: e.data.profile ? structuredClone(e.data.profile) : null,
});
break;
case "ProgramAdopted":
state.program = structuredClone(e.data.program);
+1 -1
View File
@@ -21,7 +21,7 @@ export const MODES = /** @type {const} */ (["progression", "maintenance", "recov
export const SESSION_KINDS = /** @type {const} */ (["strength", "cardio", "activity"]);
/** D'où vient un programme adopté ou proposé. */
export const PROGRAM_SOURCES = /** @type {const} */ (["default", "app", "ai", "link", "import", "atelier"]);
export const PROGRAM_SOURCES = /** @type {const} */ (["example", "app", "ai", "link", "import", "atelier"]);
/** Types de jours imposés dans le planning (« strength:C », « cardio:1 », « activity:foot »…). */
export const LOCK_KINDS = /** @type {const} */ (["strength", "cardio", "activity", "rest"]);