@pontix/adapter-duin 0.0.0-stage → 0.1.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.
Files changed (60) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +96 -2
  3. package/dist/auth.d.ts +30 -0
  4. package/dist/auth.d.ts.map +1 -0
  5. package/dist/auth.js +170 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/available-plans.d.ts +10 -0
  8. package/dist/available-plans.d.ts.map +1 -0
  9. package/dist/available-plans.js +14 -0
  10. package/dist/available-plans.js.map +1 -0
  11. package/dist/index.d.ts +16 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +85 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/mappers.d.ts +33 -0
  16. package/dist/mappers.d.ts.map +1 -0
  17. package/dist/mappers.js +35 -0
  18. package/dist/mappers.js.map +1 -0
  19. package/dist/plan-edit.d.ts +79 -0
  20. package/dist/plan-edit.d.ts.map +1 -0
  21. package/dist/plan-edit.js +122 -0
  22. package/dist/plan-edit.js.map +1 -0
  23. package/dist/session.d.ts +20 -0
  24. package/dist/session.d.ts.map +1 -0
  25. package/dist/session.js +59 -0
  26. package/dist/session.js.map +1 -0
  27. package/dist/shapes.d.ts +626 -0
  28. package/dist/shapes.d.ts.map +1 -0
  29. package/dist/shapes.js +219 -0
  30. package/dist/shapes.js.map +1 -0
  31. package/dist/tools/add-plan-exercise.d.ts +87 -0
  32. package/dist/tools/add-plan-exercise.d.ts.map +1 -0
  33. package/dist/tools/add-plan-exercise.js +47 -0
  34. package/dist/tools/add-plan-exercise.js.map +1 -0
  35. package/dist/tools/get-plan.d.ts +29 -0
  36. package/dist/tools/get-plan.d.ts.map +1 -0
  37. package/dist/tools/get-plan.js +150 -0
  38. package/dist/tools/get-plan.js.map +1 -0
  39. package/dist/tools/list-plans.d.ts +40 -0
  40. package/dist/tools/list-plans.d.ts.map +1 -0
  41. package/dist/tools/list-plans.js +110 -0
  42. package/dist/tools/list-plans.js.map +1 -0
  43. package/dist/tools/list-workouts.d.ts +73 -0
  44. package/dist/tools/list-workouts.d.ts.map +1 -0
  45. package/dist/tools/list-workouts.js +269 -0
  46. package/dist/tools/list-workouts.js.map +1 -0
  47. package/dist/tools/remove-plan-exercise.d.ts +23 -0
  48. package/dist/tools/remove-plan-exercise.d.ts.map +1 -0
  49. package/dist/tools/remove-plan-exercise.js +33 -0
  50. package/dist/tools/remove-plan-exercise.js.map +1 -0
  51. package/dist/tools/search-activities.d.ts +68 -0
  52. package/dist/tools/search-activities.d.ts.map +1 -0
  53. package/dist/tools/search-activities.js +136 -0
  54. package/dist/tools/search-activities.js.map +1 -0
  55. package/dist/tools/set-plan-exercise-sets.d.ts +79 -0
  56. package/dist/tools/set-plan-exercise-sets.d.ts.map +1 -0
  57. package/dist/tools/set-plan-exercise-sets.js +39 -0
  58. package/dist/tools/set-plan-exercise-sets.js.map +1 -0
  59. package/mappers.json +197 -0
  60. package/package.json +45 -3
package/dist/shapes.js ADDED
@@ -0,0 +1,219 @@
1
+ import { z } from "@pontix/core/adapter";
2
+ /**
3
+ * What the tools return to the model.
4
+ *
5
+ * Ours, not DUIN's, and deliberately not data: a mapper may change where a value
6
+ * is read from, never what a caller receives. Every mapped result is validated
7
+ * against these.
8
+ */
9
+ /**
10
+ * One workout, summarised.
11
+ *
12
+ * Enough to answer "how often did I train" and "what did I do on Tuesday", and
13
+ * no more. Sets, weights and heart rate are health data and belong to a tool
14
+ * that is asked for them.
15
+ *
16
+ * No `id` and no `duration`: the live response has neither at workout level.
17
+ * A workout is identified by its date and plan, and a duration exists only per
18
+ * exercise (a set's `duration` and the exercise `summary`), which this summary
19
+ * does not open.
20
+ */
21
+ export const workout = z.object({
22
+ /**
23
+ * Exactly as the service reports it: the gym-local wall clock with no
24
+ * offset, such as `2026-11-16T19:08:17.216`. Read it together with
25
+ * `timezone`; it is not a UTC instant.
26
+ */
27
+ completedAt: z.string().nullable(),
28
+ /** The IANA zone `completedAt` is local to, such as `Europe/Madrid`. */
29
+ timezone: z.string().nullable(),
30
+ /**
31
+ * The name of the plan the member trained, or null when there was none: a
32
+ * session logged from a connected app (Apple Health, for one) carries no plan.
33
+ */
34
+ name: z.string().nullable(),
35
+ /** `USER_OWN`, `TRAINER_ASSIGNED` or `BRAND_SPECIFIC` of that plan, as the service says; null with no plan. */
36
+ planGroupType: z.string().nullable(),
37
+ /** How many exercises the workout held; null when the entry does not list them. */
38
+ exerciseCount: z.number().int().nullable(),
39
+ });
40
+ export const workoutList = z.object({
41
+ /** The window that was asked for, as ISO instants. */
42
+ window: z.object({ from: z.string(), to: z.string() }),
43
+ /**
44
+ * How many workouts fell inside the window, before `limit` was applied.
45
+ *
46
+ * The service paginates nothing and answers every entry in the window in one
47
+ * response, so the tool is what bounds the output. Without this a model that sees twenty
48
+ * rows cannot tell a member who trained twenty times from one who trained
49
+ * five hundred.
50
+ *
51
+ * Counted here rather than taken from the response length, because nobody
52
+ * has watched the service honour the window it was asked for. Reporting what
53
+ * came back as what the window held would turn that mistake into a confident
54
+ * wrong number.
55
+ */
56
+ total: z.number().int(),
57
+ returned: z.number().int(),
58
+ truncated: z.boolean(),
59
+ /**
60
+ * Entries whose `completedAt` could not be read as a date, and which are
61
+ * therefore in neither count above.
62
+ *
63
+ * If the service ever sends a missing, malformed or non-date `completedAt`
64
+ * (epoch numbers, say), this is where that shows up instead of the tool
65
+ * quietly sorting and truncating the wrong rows — so a model reading a
66
+ * non-zero value here should say the dates could not be read rather than
67
+ * answer "how often did I train".
68
+ */
69
+ undated: z.number().int(),
70
+ /** Most recent first. */
71
+ workouts: z.array(workout),
72
+ });
73
+ /**
74
+ * One plan, summarised.
75
+ *
76
+ * Enough to answer "which plans do I have" and "how big is it". The embedded
77
+ * activities are what make the response about 1.3 MB, and the sets are per-exercise
78
+ * detail, so neither is here: a tool that is asked for a plan's exercises can
79
+ * fetch them.
80
+ */
81
+ export const plan = z.object({
82
+ id: z.string(),
83
+ name: z.string().nullable(),
84
+ /**
85
+ * `USER_OWN`, `TRAINER_ASSIGNED` or `BRAND_SPECIFIC` as recorded. A plain
86
+ * string rather than an enum: a fourth value from the service should reach
87
+ * the model, not fail the whole list.
88
+ */
89
+ groupType: z.string().nullable(),
90
+ /** `MANUAL_INPUT` or `HISTORIC` as recorded; the same reasoning as `groupType`. */
91
+ exerciseValueSource: z.string().nullable(),
92
+ /**
93
+ * Whether the service says the member may change this plan, and whether they
94
+ * may remove it.
95
+ *
96
+ * Null is a third answer and not a no: it means the service did not say. A
97
+ * plan the member cannot edit and a plan nobody asked about lead somewhere
98
+ * different, so they are not collapsed.
99
+ */
100
+ editable: z.boolean().nullable(),
101
+ deletable: z.boolean().nullable(),
102
+ /** How many exercises the plan holds; null when the entry does not list them. */
103
+ exerciseCount: z.number().int().nullable(),
104
+ });
105
+ export const planList = z.object({
106
+ /** How many plans matched the filter, before `limit` was applied. */
107
+ total: z.number().int(),
108
+ returned: z.number().int(),
109
+ truncated: z.boolean(),
110
+ /**
111
+ * How many plans the service sent in each group, whatever the filter.
112
+ *
113
+ * So "you have 3 of your own and the gym offers 180" can be said without
114
+ * 180 rows. `other` holds plans with no `groupType` or one that is not
115
+ * among the three recorded: above zero means the service has a group this
116
+ * code does not know.
117
+ */
118
+ groups: z.object({
119
+ USER_OWN: z.number().int(),
120
+ TRAINER_ASSIGNED: z.number().int(),
121
+ BRAND_SPECIFIC: z.number().int(),
122
+ other: z.number().int(),
123
+ }),
124
+ /** The member's own plans first, then trainer-assigned, then the gym's catalogue. */
125
+ plans: z.array(plan),
126
+ });
127
+ /**
128
+ * One catalogue activity, summarised.
129
+ *
130
+ * Enough to find an activity and its id, and no more. The catalogue row also
131
+ * carries localized `name`/`description`/`synonyms` maps, `muscleMapping`,
132
+ * `images[]`, `videos[]` and `equipmentsV2[]`; none of it is here, for the same
133
+ * reason `plan` drops its embedded activities. A tool that is asked for one
134
+ * activity can fetch the rest.
135
+ */
136
+ export const activity = z.object({
137
+ /** `activityId` upstream, an integer there; it is a string here, like every id this connector returns. */
138
+ id: z.string(),
139
+ /** In the first language the service published, Spanish preferred. Null when none came. */
140
+ name: z.string().nullable(),
141
+ /**
142
+ * What the service calls this activity's `category`: `WEIGHT_MACHINE_BASED`,
143
+ * `EGYM_MACHINE`, `FREE_WEIGHTS`, `BODY_WEIGHT_BASED`, `FITNESS_CLASS`, `SPORT`,
144
+ * `STRETCHING`, `ELLIPTICAL`, `TREADMILL` or `BIKES`, as recorded.
145
+ *
146
+ * **Not the `category` the search filters by.** That one is `STRENGTH`,
147
+ * `COORDINATION`, `MOBILITY` or `FITNESS_CLASS`; both are the service's own
148
+ * words for two different things. A row read back as `FREE_WEIGHTS` from a
149
+ * search filtered by `STRENGTH` is the filter working, not being ignored.
150
+ * Kept under the service's name so a recorded field is not renamed out of
151
+ * sight of where it came from. A plain string, not an enum: a new value
152
+ * should reach the model, not fail the whole list.
153
+ */
154
+ category: z.string().nullable(),
155
+ difficulty: z.string().nullable(),
156
+ /** The metabolic equivalent the service reports for the activity. */
157
+ met: z.number().nullable(),
158
+ });
159
+ export const activityList = z.object({
160
+ /**
161
+ * The page the service says it answered, not the page that was asked for, so
162
+ * a mismatch shows instead of being assumed away. When the response carries
163
+ * no page the requested one stands in, because there is nothing else to say.
164
+ */
165
+ page: z.number().int(),
166
+ /**
167
+ * How many activities match the search, across all pages, as the service
168
+ * counts them. Null when the response carried no count: `returned` would
169
+ * turn a missing total into a confident wrong one.
170
+ */
171
+ total: z.number().int().nullable(),
172
+ returned: z.number().int(),
173
+ /**
174
+ * Whether the service offered a next page, and only that: it is its own
175
+ * next-page token, never arithmetic over `total`.
176
+ *
177
+ * Which means it can be false while `total` is far above the rows in hand —
178
+ * and that is the ordinary last page of a large result, not a fault. The
179
+ * reasoning, and what the connector gives up by not inferring more, is on
180
+ * `toActivityList`.
181
+ */
182
+ hasMore: z.boolean(),
183
+ activities: z.array(activity),
184
+ });
185
+ /**
186
+ * One set of a planned exercise. Fields the service left null are absent, so a
187
+ * cardio set reads `{ type: "TIME_BASED", durationSeconds: 300 }` and not a row
188
+ * of nulls.
189
+ */
190
+ export const plannedSet = z.object({
191
+ /** `REP_BASED` or `TIME_BASED` as recorded; a plain string so a new kind reaches the model. */
192
+ type: z.string().nullable(),
193
+ reps: z.number().optional(),
194
+ durationSeconds: z.number().optional(),
195
+ /** Kilograms: the plans call asks for `measurementSystem=METRIC`. */
196
+ weightKg: z.number().optional(),
197
+ });
198
+ export const plannedExercise = z.object({
199
+ /** The entry of this exercise in this plan (`plannedExercises[].id`), not the catalogue id. */
200
+ plannedExerciseId: z.string(),
201
+ /** The catalogue id, the one `duin_search_activities` returns as `id`. */
202
+ activityId: z.string(),
203
+ /** Spanish, then English, then any language the service sent. */
204
+ name: z.string().nullable(),
205
+ /** The activity's own `category`, such as `TREADMILL` or `EGYM_MACHINE`. */
206
+ category: z.string().nullable(),
207
+ /** The (at most) three muscles the activity loads most, strongest first. */
208
+ primaryMuscles: z.array(z.string()),
209
+ sets: z.array(plannedSet),
210
+ });
211
+ export const planDetail = z.object({
212
+ id: z.string(),
213
+ name: z.string().nullable(),
214
+ groupType: z.string().nullable(),
215
+ editable: z.boolean().nullable(),
216
+ deletable: z.boolean().nullable(),
217
+ exercises: z.array(plannedExercise),
218
+ });
219
+ //# sourceMappingURL=shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shapes.js","sourceRoot":"","sources":["../src/shapes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAEzC;;;;;;GAMG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B;;;;OAIG;IACH,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,wEAAwE;IACxE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B;;;OAGG;IACH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KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;CACpC,CAAC,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { z } from "@pontix/core/adapter";
2
+ import type { DuinSession } from "../session.js";
3
+ export declare const addPlanExerciseInput: z.ZodObject<{
4
+ planId: z.ZodString;
5
+ activityId: z.ZodNumber;
6
+ sets: z.ZodArray<z.ZodUnion<[z.ZodObject<{
7
+ reps: z.ZodNumber;
8
+ weightKg: z.ZodOptional<z.ZodNumber>;
9
+ }, "strict", z.ZodTypeAny, {
10
+ reps: number;
11
+ weightKg?: number | undefined;
12
+ }, {
13
+ reps: number;
14
+ weightKg?: number | undefined;
15
+ }>, z.ZodObject<{
16
+ durationSeconds: z.ZodNumber;
17
+ }, "strict", z.ZodTypeAny, {
18
+ durationSeconds: number;
19
+ }, {
20
+ durationSeconds: number;
21
+ }>]>, "many">;
22
+ }, "strip", z.ZodTypeAny, {
23
+ activityId: number;
24
+ sets: ({
25
+ reps: number;
26
+ weightKg?: number | undefined;
27
+ } | {
28
+ durationSeconds: number;
29
+ })[];
30
+ planId: string;
31
+ }, {
32
+ activityId: number;
33
+ sets: ({
34
+ reps: number;
35
+ weightKg?: number | undefined;
36
+ } | {
37
+ durationSeconds: number;
38
+ })[];
39
+ planId: string;
40
+ }>;
41
+ /**
42
+ * Adds an exercise at the end of an own plan.
43
+ *
44
+ * The service has no per-exercise call, so the whole plan is read, extended and
45
+ * sent back (see `editPlan`). The new exercise needs an id the service has not
46
+ * issued yet; the app made one from the clock in milliseconds, so this does too,
47
+ * moved forward if it happens to collide with an existing exercise.
48
+ */
49
+ export declare const addPlanExercise: import("@pontix/core/adapter").ToolDefinition<DuinSession, z.ZodObject<{
50
+ planId: z.ZodString;
51
+ activityId: z.ZodNumber;
52
+ sets: z.ZodArray<z.ZodUnion<[z.ZodObject<{
53
+ reps: z.ZodNumber;
54
+ weightKg: z.ZodOptional<z.ZodNumber>;
55
+ }, "strict", z.ZodTypeAny, {
56
+ reps: number;
57
+ weightKg?: number | undefined;
58
+ }, {
59
+ reps: number;
60
+ weightKg?: number | undefined;
61
+ }>, z.ZodObject<{
62
+ durationSeconds: z.ZodNumber;
63
+ }, "strict", z.ZodTypeAny, {
64
+ durationSeconds: number;
65
+ }, {
66
+ durationSeconds: number;
67
+ }>]>, "many">;
68
+ }, "strip", z.ZodTypeAny, {
69
+ activityId: number;
70
+ sets: ({
71
+ reps: number;
72
+ weightKg?: number | undefined;
73
+ } | {
74
+ durationSeconds: number;
75
+ })[];
76
+ planId: string;
77
+ }, {
78
+ activityId: number;
79
+ sets: ({
80
+ reps: number;
81
+ weightKg?: number | undefined;
82
+ } | {
83
+ durationSeconds: number;
84
+ })[];
85
+ planId: string;
86
+ }>>;
87
+ //# sourceMappingURL=add-plan-exercise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-plan-exercise.d.ts","sourceRoot":"","sources":["../../src/tools/add-plan-exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ/B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2B1B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { defineTool, z } from "@pontix/core/adapter";
2
+ import { editPlan, newSet, setsInput } from "../plan-edit.js";
3
+ export const addPlanExerciseInput = z.object({
4
+ planId: z.string().min(1).describe("The plan's id, from `duin_list_plans`. It must be one of your own (editable) plans."),
5
+ activityId: z
6
+ .number()
7
+ .int()
8
+ .positive()
9
+ .describe("The catalogue activity to add: the `id` `duin_search_activities` returns, as a number."),
10
+ sets: setsInput,
11
+ });
12
+ /**
13
+ * Adds an exercise at the end of an own plan.
14
+ *
15
+ * The service has no per-exercise call, so the whole plan is read, extended and
16
+ * sent back (see `editPlan`). The new exercise needs an id the service has not
17
+ * issued yet; the app made one from the clock in milliseconds, so this does too,
18
+ * moved forward if it happens to collide with an existing exercise.
19
+ */
20
+ export const addPlanExercise = defineTool({
21
+ name: "add_plan_exercise",
22
+ description: "WRITES to your DUIN account: adds one exercise (a catalogue activity) with the given sets at the end of one of your own training plans. " +
23
+ "The service has no per-exercise call, so the whole plan is read and then REWRITTEN with the new exercise appended; other exercises and sets are sent back as they were read. " +
24
+ "Refused, with nothing sent, when the plan is not editable (a trainer's or the gym's plan). Sets are { reps, weightKg? } or { durationSeconds }. " +
25
+ "Returns the plan as `duin_get_plan` does, read again after the change.",
26
+ descriptions: {
27
+ es: "ESCRIBE en tu cuenta de DUIN: añade un ejercicio (una actividad del catálogo) con las series indicadas al final de uno de tus planes de entrenamiento. " +
28
+ "El servicio no tiene una llamada por ejercicio, así que se lee el plan completo y se REESCRIBE con el ejercicio nuevo al final; los demás ejercicios y series se reenvían tal como se leyeron. " +
29
+ "Se rechaza, sin enviar nada, si el plan no es editable (los de un entrenador o del gimnasio). Las series son { reps, weightKg? } o { durationSeconds }. " +
30
+ "Devuelve el plan como `duin_get_plan`, leído de nuevo tras el cambio.",
31
+ },
32
+ input: addPlanExerciseInput,
33
+ readOnly: false,
34
+ async execute(session, input) {
35
+ return editPlan(session, input.planId, (body) => {
36
+ const taken = new Set(body.exercises.map((exercise) => String(exercise.id)));
37
+ let id = Date.now();
38
+ while (taken.has(String(id)))
39
+ id += 1;
40
+ return {
41
+ ...body,
42
+ exercises: [...body.exercises, { id, activityId: input.activityId, sets: input.sets.map(newSet) }],
43
+ };
44
+ });
45
+ },
46
+ });
47
+ //# sourceMappingURL=add-plan-exercise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-plan-exercise.js","sourceRoot":"","sources":["../../src/tools/add-plan-exercise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,qFAAqF,CAAC;IACzH,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,CAAC,wFAAwF,CAAC;IACrG,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAA2C;IAClF,IAAI,EAAE,mBAAmB;IACzB,WAAW,EACT,0IAA0I;QAC1I,+KAA+K;QAC/K,kJAAkJ;QAClJ,wEAAwE;IAC1E,YAAY,EAAE;QACZ,EAAE,EACA,yJAAyJ;YACzJ,iMAAiM;YACjM,0JAA0J;YAC1J,uEAAuE;KAC1E;IACD,KAAK,EAAE,oBAAoB;IAC3B,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK;QAC1B,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAC9C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7E,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAAE,EAAE,IAAI,CAAC,CAAC;YACtC,OAAO;gBACL,GAAG,IAAI;gBACP,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;aACnG,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { z } from "@pontix/core/adapter";
2
+ import { type PlanDetail } from "../shapes.js";
3
+ import type { DuinSession } from "../session.js";
4
+ export declare const getPlanInput: z.ZodObject<{
5
+ planId: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ planId: string;
8
+ }, {
9
+ planId: string;
10
+ }>;
11
+ /**
12
+ * The raw row of one plan in the available-plans response.
13
+ *
14
+ * The id is compared as text: the service sends it as a number and the tools
15
+ * return it as a string, so a caller passing back what `list_plans` gave works.
16
+ * An unknown id is `invalid_input`, since the error code set has no not-found.
17
+ * Shared with the write tools, which build the request body from this row.
18
+ */
19
+ export declare function findPlanRow(payload: unknown, planId: string): Record<string, unknown>;
20
+ /** One plan out of the available-plans response, with its exercises and sets. */
21
+ export declare function toPlanDetail(payload: unknown, planId: string): PlanDetail;
22
+ export declare const getPlan: import("@pontix/core/adapter").ToolDefinition<DuinSession, z.ZodObject<{
23
+ planId: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ planId: string;
26
+ }, {
27
+ planId: string;
28
+ }>>;
29
+ //# sourceMappingURL=get-plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-plan.d.ts","sourceRoot":"","sources":["../../src/tools/get-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAGhG,OAAO,EAAc,KAAK,UAAU,EAAyC,MAAM,cAAc,CAAC;AAClG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,YAAY;;;;;;EAKvB,CAAC;AA4FH;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBrF;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAYzE;AAED,eAAO,MAAM,OAAO;;;;;;GAoBlB,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { PontixError, applyMapper, defineTool, upstreamChanged, z } from "@pontix/core/adapter";
2
+ import { fetchAvailablePlans } from "../available-plans.js";
3
+ import { ADAPTER_ID, MAPPERS } from "../mappers.js";
4
+ import { planDetail } from "../shapes.js";
5
+ export const getPlanInput = z.object({
6
+ planId: z
7
+ .string()
8
+ .min(1)
9
+ .describe("The plan's id, as `duin_list_plans` returns it. Digits only, such as 2000000000001."),
10
+ });
11
+ /** How many muscles to name per exercise. */
12
+ const MAIN_MUSCLES = 3;
13
+ function record(value) {
14
+ return typeof value === "object" && value !== null && !Array.isArray(value)
15
+ ? value
16
+ : undefined;
17
+ }
18
+ function finite(value) {
19
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
20
+ }
21
+ /** Reads a boolean off a raw row; see `flag` in `list-plans.ts` for why it is not a mapper. */
22
+ function flag(row, key) {
23
+ const value = row[key];
24
+ return typeof value === "boolean" ? value : null;
25
+ }
26
+ /** The first language of a localized map when neither Spanish nor English came: any beats nothing. */
27
+ function anyName(names) {
28
+ const map = record(names);
29
+ if (map === undefined)
30
+ return null;
31
+ for (const value of Object.values(map)) {
32
+ if (typeof value === "string" && value.trim() !== "")
33
+ return value;
34
+ }
35
+ return null;
36
+ }
37
+ /**
38
+ * The muscles the activity loads most, strongest first, at most three.
39
+ *
40
+ * Top three rather than a threshold: a threshold (say 80) leaves a machine
41
+ * exercise whose best muscle scores 40 with no muscles at all. Ties keep a
42
+ * stable order by name so the output does not depend on key order upstream.
43
+ */
44
+ function mainMuscles(mapping) {
45
+ const map = record(mapping);
46
+ if (map === undefined)
47
+ return [];
48
+ return Object.entries(map)
49
+ .flatMap(([muscle, weight]) => {
50
+ const value = finite(weight);
51
+ return value === undefined ? [] : [{ muscle, value }];
52
+ })
53
+ .sort((a, b) => b.value - a.value || a.muscle.localeCompare(b.muscle))
54
+ .slice(0, MAIN_MUSCLES)
55
+ .map((entry) => entry.muscle);
56
+ }
57
+ /**
58
+ * One set, without the fields the service sent as null.
59
+ *
60
+ * Distance, speed, incline, heart rate and recovery time are not returned: the
61
+ * units of the first three were never confirmed, and the rest are not what
62
+ * someone adjusting a plan asks about.
63
+ */
64
+ function toSet(raw) {
65
+ const set = record(raw) ?? {};
66
+ const reps = finite(set["numberOfReps"]);
67
+ const durationSeconds = finite(set["duration"]);
68
+ const weightKg = finite(set["weight"]);
69
+ return {
70
+ type: typeof set["setType"] === "string" ? set["setType"] : null,
71
+ ...(reps === undefined ? {} : { reps }),
72
+ ...(durationSeconds === undefined ? {} : { durationSeconds }),
73
+ ...(weightKg === undefined ? {} : { weightKg }),
74
+ };
75
+ }
76
+ function toExercise(raw) {
77
+ const row = record(raw);
78
+ const activityRow = record(row?.["activity"]);
79
+ if (row === undefined || activityRow === undefined) {
80
+ throw upstreamChanged(ADAPTER_ID, "A planned exercise", raw);
81
+ }
82
+ // The `activity` mapper already reads the id, the category and the name in
83
+ // Spanish, then English; only the "any language" fallback is computed here.
84
+ const mapped = applyMapper(MAPPERS, "activity", activityRow, ADAPTER_ID);
85
+ const id = row["id"];
86
+ const sets = row["sets"];
87
+ return {
88
+ plannedExerciseId: typeof id === "number" || typeof id === "string" ? String(id) : "",
89
+ activityId: String(mapped["id"]),
90
+ name: typeof mapped["name"] === "string" ? mapped["name"] : anyName(activityRow["name"]),
91
+ category: typeof mapped["category"] === "string" ? mapped["category"] : null,
92
+ primaryMuscles: mainMuscles(activityRow["muscleMapping"]),
93
+ sets: Array.isArray(sets) ? sets.map(toSet) : [],
94
+ };
95
+ }
96
+ /**
97
+ * The raw row of one plan in the available-plans response.
98
+ *
99
+ * The id is compared as text: the service sends it as a number and the tools
100
+ * return it as a string, so a caller passing back what `list_plans` gave works.
101
+ * An unknown id is `invalid_input`, since the error code set has no not-found.
102
+ * Shared with the write tools, which build the request body from this row.
103
+ */
104
+ export function findPlanRow(payload, planId) {
105
+ if (!Array.isArray(payload)) {
106
+ throw upstreamChanged(ADAPTER_ID, "The available plans response", payload);
107
+ }
108
+ const row = payload.find((entry) => {
109
+ const id = record(entry)?.["id"];
110
+ return (typeof id === "number" || typeof id === "string") && String(id) === planId;
111
+ });
112
+ if (row === undefined) {
113
+ throw new PontixError("invalid_input", `No plan with id "${planId}" among the plans this member can see. Use duin_list_plans to find a valid id.`, { adapterId: ADAPTER_ID });
114
+ }
115
+ return record(row);
116
+ }
117
+ /** One plan out of the available-plans response, with its exercises and sets. */
118
+ export function toPlanDetail(payload, planId) {
119
+ const raw = findPlanRow(payload, planId);
120
+ const header = applyMapper(MAPPERS, "plan", raw, ADAPTER_ID);
121
+ const exercises = raw["plannedExercises"];
122
+ return planDetail.parse({
123
+ id: header["id"],
124
+ name: header["name"],
125
+ groupType: header["groupType"],
126
+ editable: flag(raw, "editable"),
127
+ deletable: flag(raw, "deletable"),
128
+ exercises: Array.isArray(exercises) ? exercises.map(toExercise) : [],
129
+ });
130
+ }
131
+ export const getPlan = defineTool({
132
+ name: "get_plan",
133
+ description: "Read one training plan with its exercises: for each, its name, the catalogue activity id, its category, the main muscles it works and its sets " +
134
+ "(type REP_BASED or TIME_BASED, reps, duration in seconds, weight in kg; fields the service left empty are omitted). " +
135
+ "Also says whether the plan is editable and deletable. Takes the plan id from `duin_list_plans`. " +
136
+ "It carries no descriptions, images or videos.",
137
+ descriptions: {
138
+ es: "Lee un plan de entrenamiento con sus ejercicios: de cada uno, el nombre, el id de la actividad del catálogo, su categoría, los músculos principales que trabaja y sus series " +
139
+ "(tipo REP_BASED o TIME_BASED, repeticiones, duración en segundos, peso en kg; se omiten los campos que el servicio dejó vacíos). " +
140
+ "También indica si el plan es editable y eliminable. Recibe el id del plan de `duin_list_plans`. " +
141
+ "No incluye descripciones, imágenes ni vídeos.",
142
+ },
143
+ input: getPlanInput,
144
+ readOnly: true,
145
+ // No cache, like `list_plans`: the member's own plans change.
146
+ async execute(session, input) {
147
+ return toPlanDetail(await fetchAvailablePlans(session), input.planId);
148
+ },
149
+ });
150
+ //# sourceMappingURL=get-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-plan.js","sourceRoot":"","sources":["../../src/tools/get-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAA0D,MAAM,cAAc,CAAC;AAGlG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,C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AAG,CAAC,kBAAkB,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,KAAK,CAAC;QACtB,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC;QAC9B,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC;QAC/B,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;QACjC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE;KACrE,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAmC;IAClE,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,iJAAiJ;QACjJ,sHAAsH;QACtH,kGAAkG;QAClG,+CAA+C;IACjD,YAAY,EAAE;QACZ,EAAE,EACA,+KAA+K;YAC/K,mIAAmI;YACnI,kGAAkG;YAClG,+CAA+C;KAClD;IACD,KAAK,EAAE,YAAY;IACnB,QAAQ,EAAE,IAAI;IACd,8DAA8D;IAC9D,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK;QAC1B,OAAO,YAAY,CAAC,MAAM,mBAAmB,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxE,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { z } from "@pontix/core/adapter";
2
+ import { type PlanList } from "../shapes.js";
3
+ import type { DuinSession } from "../session.js";
4
+ export declare const listPlansInput: z.ZodObject<{
5
+ groupType: z.ZodOptional<z.ZodEnum<["USER_OWN", "TRAINER_ASSIGNED", "BRAND_SPECIFIC"]>>;
6
+ limit: z.ZodDefault<z.ZodNumber>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ limit: number;
9
+ groupType?: "USER_OWN" | "TRAINER_ASSIGNED" | "BRAND_SPECIFIC" | undefined;
10
+ }, {
11
+ groupType?: "USER_OWN" | "TRAINER_ASSIGNED" | "BRAND_SPECIFIC" | undefined;
12
+ limit?: number | undefined;
13
+ }>;
14
+ type Input = z.infer<typeof listPlansInput>;
15
+ /**
16
+ * Ordering, counting, filtering and truncating are computed, so they live here
17
+ * and not in `mappers.json`, as in `toWorkoutList`.
18
+ *
19
+ * **One unreadable row fails the whole call, on purpose.** `applyMapper` maps
20
+ * rows atomically (`packages/core/src/mapper.ts`) and nothing here tolerates a
21
+ * bad one. The rows come from one API through one code path, so one bad row
22
+ * among hundreds is far less likely than every row being bad — and that is
23
+ * drift, which must be loud. `upstreamChanged` already names the keys received.
24
+ * Tolerating rows would hide exactly that case behind a partial answer. This
25
+ * was weighed twice in review and decided; do not re-open it without a response
26
+ * where some rows are unreadable and others are not.
27
+ */
28
+ export declare function toPlanList(payload: unknown, filter: Input["groupType"], limit: number): PlanList;
29
+ export declare const listPlans: import("@pontix/core/adapter").ToolDefinition<DuinSession, z.ZodObject<{
30
+ groupType: z.ZodOptional<z.ZodEnum<["USER_OWN", "TRAINER_ASSIGNED", "BRAND_SPECIFIC"]>>;
31
+ limit: z.ZodDefault<z.ZodNumber>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ limit: number;
34
+ groupType?: "USER_OWN" | "TRAINER_ASSIGNED" | "BRAND_SPECIFIC" | undefined;
35
+ }, {
36
+ groupType?: "USER_OWN" | "TRAINER_ASSIGNED" | "BRAND_SPECIFIC" | undefined;
37
+ limit?: number | undefined;
38
+ }>>;
39
+ export {};
40
+ //# sourceMappingURL=list-plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-plans.d.ts","sourceRoot":"","sources":["../../src/tools/list-plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4C,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAajD,eAAO,MAAM,cAAc;;;;;;;;;EAczB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAuB5C;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAiChG;AAED,eAAO,MAAM,SAAS;;;;;;;;;GAuBpB,CAAC"}