@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.
- package/LICENSE +661 -0
- package/README.md +96 -2
- package/dist/auth.d.ts +30 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +170 -0
- package/dist/auth.js.map +1 -0
- package/dist/available-plans.d.ts +10 -0
- package/dist/available-plans.d.ts.map +1 -0
- package/dist/available-plans.js +14 -0
- package/dist/available-plans.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/mappers.d.ts +33 -0
- package/dist/mappers.d.ts.map +1 -0
- package/dist/mappers.js +35 -0
- package/dist/mappers.js.map +1 -0
- package/dist/plan-edit.d.ts +79 -0
- package/dist/plan-edit.d.ts.map +1 -0
- package/dist/plan-edit.js +122 -0
- package/dist/plan-edit.js.map +1 -0
- package/dist/session.d.ts +20 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +59 -0
- package/dist/session.js.map +1 -0
- package/dist/shapes.d.ts +626 -0
- package/dist/shapes.d.ts.map +1 -0
- package/dist/shapes.js +219 -0
- package/dist/shapes.js.map +1 -0
- package/dist/tools/add-plan-exercise.d.ts +87 -0
- package/dist/tools/add-plan-exercise.d.ts.map +1 -0
- package/dist/tools/add-plan-exercise.js +47 -0
- package/dist/tools/add-plan-exercise.js.map +1 -0
- package/dist/tools/get-plan.d.ts +29 -0
- package/dist/tools/get-plan.d.ts.map +1 -0
- package/dist/tools/get-plan.js +150 -0
- package/dist/tools/get-plan.js.map +1 -0
- package/dist/tools/list-plans.d.ts +40 -0
- package/dist/tools/list-plans.d.ts.map +1 -0
- package/dist/tools/list-plans.js +110 -0
- package/dist/tools/list-plans.js.map +1 -0
- package/dist/tools/list-workouts.d.ts +73 -0
- package/dist/tools/list-workouts.d.ts.map +1 -0
- package/dist/tools/list-workouts.js +269 -0
- package/dist/tools/list-workouts.js.map +1 -0
- package/dist/tools/remove-plan-exercise.d.ts +23 -0
- package/dist/tools/remove-plan-exercise.d.ts.map +1 -0
- package/dist/tools/remove-plan-exercise.js +33 -0
- package/dist/tools/remove-plan-exercise.js.map +1 -0
- package/dist/tools/search-activities.d.ts +68 -0
- package/dist/tools/search-activities.d.ts.map +1 -0
- package/dist/tools/search-activities.js +136 -0
- package/dist/tools/search-activities.js.map +1 -0
- package/dist/tools/set-plan-exercise-sets.d.ts +79 -0
- package/dist/tools/set-plan-exercise-sets.d.ts.map +1 -0
- package/dist/tools/set-plan-exercise-sets.js +39 -0
- package/dist/tools/set-plan-exercise-sets.js.map +1 -0
- package/mappers.json +197 -0
- package/package.json +45 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { applyMapper, defineTool, z } from "@pontix/core/adapter";
|
|
2
|
+
import { ADAPTER_ID, MAPPERS } from "../mappers.js";
|
|
3
|
+
import { activity, activityList } from "../shapes.js";
|
|
4
|
+
const DEFAULT_LIMIT = 20;
|
|
5
|
+
/** The page size the capture used; nothing recorded says the service takes more. */
|
|
6
|
+
const MAX_LIMIT = 50;
|
|
7
|
+
const MAX_NAME_LENGTH = 100;
|
|
8
|
+
const ONE_HOUR_MS = 3_600_000;
|
|
9
|
+
/**
|
|
10
|
+
* What the search filters by. Not the `category` on a row, which is a different
|
|
11
|
+
* vocabulary (see `activity.category` in `shapes.ts`).
|
|
12
|
+
*
|
|
13
|
+
* An enum is safe here in a way it would not be on a row: a value the service
|
|
14
|
+
* does not know costs the caller one retry, where on a row it would fail a
|
|
15
|
+
* whole list.
|
|
16
|
+
*/
|
|
17
|
+
const SEARCH_CATEGORIES = ["STRENGTH", "COORDINATION", "MOBILITY", "FITNESS_CLASS"];
|
|
18
|
+
export const searchActivitiesInput = z.object({
|
|
19
|
+
name: z
|
|
20
|
+
.string()
|
|
21
|
+
.trim()
|
|
22
|
+
.max(MAX_NAME_LENGTH)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Part of an activity's name to search for, sent to the service as typed. Omit it to list everything in the category."),
|
|
25
|
+
category: z
|
|
26
|
+
.enum(SEARCH_CATEGORIES)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe("Only activities of this kind: STRENGTH, COORDINATION, MOBILITY or FITNESS_CLASS. Omit it for all. " +
|
|
29
|
+
"This is not the `category` field on each result, which is a different vocabulary (FREE_WEIGHTS, EGYM_MACHINE, TREADMILL, ...): a STRENGTH search returning FREE_WEIGHTS rows is the filter working."),
|
|
30
|
+
page: z
|
|
31
|
+
.number()
|
|
32
|
+
.int()
|
|
33
|
+
.min(0)
|
|
34
|
+
.default(0)
|
|
35
|
+
.describe("Which page to return, counting from 0. The result says whether there is another one (`hasMore`)."),
|
|
36
|
+
limit: z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(MAX_LIMIT)
|
|
41
|
+
.default(DEFAULT_LIMIT)
|
|
42
|
+
.describe(`How many activities per page. At most ${MAX_LIMIT}. The result also says how many matched in all.`),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Reading the envelope and the rows together is computed, so it lives here
|
|
46
|
+
* and not in `mappers.json`, as in `toPlanList`.
|
|
47
|
+
*
|
|
48
|
+
* **One unreadable row fails the whole call, on purpose**: the decision, and
|
|
49
|
+
* what it would take to re-open it, is written up on `toPlanList`.
|
|
50
|
+
*
|
|
51
|
+
* `hasMore` is the service's own `nextPageToken` and nothing else.
|
|
52
|
+
*
|
|
53
|
+
* Deriving it from `count` as well was tried and taken back out. One page is
|
|
54
|
+
* all that is ever in hand: nothing in a response says how many rows the pages
|
|
55
|
+
* behind it held, and `MAX_LIMIT` is the size one capture used rather than a
|
|
56
|
+
* published contract. Every arithmetic that fills that gap guesses. Measuring
|
|
57
|
+
* earlier pages at the size requested ends pagination early whenever the
|
|
58
|
+
* service hands back a short page, losing rows; measuring them at the size of
|
|
59
|
+
* the page in hand calls the ordinary last partial page unfinished, costing a
|
|
60
|
+
* request on every search whose total is not a multiple of the limit, and
|
|
61
|
+
* leans on the service answering an out-of-range page with no rows — which
|
|
62
|
+
* nothing here has observed it do.
|
|
63
|
+
*
|
|
64
|
+
* So this reports what the service said and does not invent the rest, which is
|
|
65
|
+
* what the rest of this connector does with a value it was not given. The cost
|
|
66
|
+
* is named: if that key is renamed, `hasMore` goes false and paging stops
|
|
67
|
+
* early. That is drift for the operator to catch — `pontix capture duin`
|
|
68
|
+
* reports which candidate key each field hit — and deliberately not something
|
|
69
|
+
* the model is asked to infer, because the comparison that would reveal it,
|
|
70
|
+
* `total` against the rows in hand, is equally true on the ordinary last page
|
|
71
|
+
* of a large result, where nothing is wrong at all.
|
|
72
|
+
*/
|
|
73
|
+
export function toActivityList(payload, requested) {
|
|
74
|
+
const mapped = applyMapper(MAPPERS, "activityList", payload, ADAPTER_ID);
|
|
75
|
+
const rows = mapped["activities"].map((row) => activity.parse(row));
|
|
76
|
+
// The service's own page, so a mismatch is visible. The requested page is
|
|
77
|
+
// only a fallback for a response that carries none.
|
|
78
|
+
const page = mapped["page"] ?? requested.page;
|
|
79
|
+
// Not `rows.length`: a missing total must stay missing, not become a
|
|
80
|
+
// confident wrong one.
|
|
81
|
+
const total = mapped["total"];
|
|
82
|
+
const token = mapped["nextPageToken"];
|
|
83
|
+
const hasMore = token !== null;
|
|
84
|
+
return activityList.parse({ page, total, returned: rows.length, hasMore, activities: rows });
|
|
85
|
+
}
|
|
86
|
+
export const searchActivities = defineTool({
|
|
87
|
+
name: "search_activities",
|
|
88
|
+
description: "Search eGym's exercise catalogue, one page per call: find an activity and its id by name or kind. " +
|
|
89
|
+
"Each result has an id, a name, a category, a difficulty and a met value. " +
|
|
90
|
+
"IMPORTANT: this is the whole eGym catalogue, not the gym's inventory. It includes smart machines this gym does not own, " +
|
|
91
|
+
"so never tell the member their gym has an activity because it is listed here. " +
|
|
92
|
+
"The `category` filter (STRENGTH, COORDINATION, MOBILITY, FITNESS_CLASS) is not the `category` field on each result " +
|
|
93
|
+
"(FREE_WEIGHTS, EGYM_MACHINE, TREADMILL, ...): they are two different vocabularies, so a STRENGTH search returning FREE_WEIGHTS rows means the filter worked; do not filter again yourself. " +
|
|
94
|
+
"`total` is how many matched across all pages (null when the service did not say), `returned` how many this page holds, " +
|
|
95
|
+
"and `hasMore` whether the service offered a next page: follow it to page through, and when it is false there are no more pages on offer. " +
|
|
96
|
+
"It carries no description, images, videos, muscles or equipment: use it to find an activity, not to describe one.",
|
|
97
|
+
descriptions: {
|
|
98
|
+
es: "Busca en el catálogo de ejercicios de eGym, una página por llamada: sirve para encontrar una actividad y su identificador por nombre o tipo. " +
|
|
99
|
+
"Cada resultado trae identificador, nombre, categoría, dificultad y valor met. " +
|
|
100
|
+
"IMPORTANTE: es todo el catálogo de eGym, no el inventario del gimnasio. Incluye máquinas inteligentes que este gimnasio no tiene, " +
|
|
101
|
+
"así que nunca le digas al socio que su gimnasio tiene una actividad solo porque aparece aquí. " +
|
|
102
|
+
"El filtro `category` (STRENGTH, COORDINATION, MOBILITY, FITNESS_CLASS) no es el campo `category` de cada resultado " +
|
|
103
|
+
"(FREE_WEIGHTS, EGYM_MACHINE, TREADMILL, ...): son dos vocabularios distintos, así que una búsqueda STRENGTH que devuelve filas FREE_WEIGHTS indica que el filtro funcionó; no vuelvas a filtrar por tu cuenta. " +
|
|
104
|
+
"`total` es cuántas coinciden en todas las páginas (nulo cuando el servicio no lo indicó), `returned` cuántas trae esta página " +
|
|
105
|
+
"y `hasMore` si el servicio ofreció una página siguiente: seguilo para ir paginando, y cuando sea falso no hay más páginas ofrecidas. " +
|
|
106
|
+
"No incluye descripción, imágenes, vídeos, músculos ni equipamiento: sirve para encontrar una actividad, no para describirla.",
|
|
107
|
+
},
|
|
108
|
+
input: searchActivitiesInput,
|
|
109
|
+
readOnly: true,
|
|
110
|
+
// An hour, unlike plans and workouts: this is eGym's static exercise library,
|
|
111
|
+
// not the member's data, so nothing they do makes it stale. The runtime keys
|
|
112
|
+
// the cache by the input, so each page and filter is cached on its own.
|
|
113
|
+
cacheTtlMs: ONE_HOUR_MS,
|
|
114
|
+
async execute(session, input) {
|
|
115
|
+
const { gymLocationId } = await session.auth.token();
|
|
116
|
+
const payload = await session.egymHttp.requestJson("/mwa/api/workouts/v2.0/activities", {
|
|
117
|
+
query: {
|
|
118
|
+
gymLocationId,
|
|
119
|
+
locale: "es-ES",
|
|
120
|
+
// A name of nothing but whitespace trims to "", and "" would go out as
|
|
121
|
+
// a real query parameter: `HttpClient` only leaves out `undefined`. An
|
|
122
|
+
// empty `name` filter is a request nobody has observed this service
|
|
123
|
+
// answer, and it has exactly one possible meaning anyway — no name
|
|
124
|
+
// filter — so it is read as the omission it is rather than refused.
|
|
125
|
+
// Nothing is being guessed on the member's behalf: there is no second
|
|
126
|
+
// reading of searching for the empty string.
|
|
127
|
+
name: input.name === "" ? undefined : input.name,
|
|
128
|
+
category: input.category,
|
|
129
|
+
page: input.page,
|
|
130
|
+
pageSize: input.limit,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
return toActivityList(payload, input);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=search-activities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-activities.js","sourceRoot":"","sources":["../../src/tools/search-activities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAC;AAGzE,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,oFAAoF;AACpF,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B;;;;;;;GA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AC7C,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;gBAChD,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,QAAQ,EAAE,KAAK,CAAC,KAAK;aACtB;SACF,CAAC,CAAC;QACH,OAAO,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "@pontix/core/adapter";
|
|
2
|
+
import type { DuinSession } from "../session.js";
|
|
3
|
+
export declare const setPlanExerciseSetsInput: z.ZodObject<{
|
|
4
|
+
planId: z.ZodString;
|
|
5
|
+
plannedExerciseId: z.ZodString;
|
|
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
|
+
plannedExerciseId: string;
|
|
24
|
+
sets: ({
|
|
25
|
+
reps: number;
|
|
26
|
+
weightKg?: number | undefined;
|
|
27
|
+
} | {
|
|
28
|
+
durationSeconds: number;
|
|
29
|
+
})[];
|
|
30
|
+
planId: string;
|
|
31
|
+
}, {
|
|
32
|
+
plannedExerciseId: string;
|
|
33
|
+
sets: ({
|
|
34
|
+
reps: number;
|
|
35
|
+
weightKg?: number | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
durationSeconds: number;
|
|
38
|
+
})[];
|
|
39
|
+
planId: string;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const setPlanExerciseSets: import("@pontix/core/adapter").ToolDefinition<DuinSession, z.ZodObject<{
|
|
42
|
+
planId: z.ZodString;
|
|
43
|
+
plannedExerciseId: z.ZodString;
|
|
44
|
+
sets: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
45
|
+
reps: z.ZodNumber;
|
|
46
|
+
weightKg: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
}, "strict", z.ZodTypeAny, {
|
|
48
|
+
reps: number;
|
|
49
|
+
weightKg?: number | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
reps: number;
|
|
52
|
+
weightKg?: number | undefined;
|
|
53
|
+
}>, z.ZodObject<{
|
|
54
|
+
durationSeconds: z.ZodNumber;
|
|
55
|
+
}, "strict", z.ZodTypeAny, {
|
|
56
|
+
durationSeconds: number;
|
|
57
|
+
}, {
|
|
58
|
+
durationSeconds: number;
|
|
59
|
+
}>]>, "many">;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
plannedExerciseId: string;
|
|
62
|
+
sets: ({
|
|
63
|
+
reps: number;
|
|
64
|
+
weightKg?: number | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
durationSeconds: number;
|
|
67
|
+
})[];
|
|
68
|
+
planId: string;
|
|
69
|
+
}, {
|
|
70
|
+
plannedExerciseId: string;
|
|
71
|
+
sets: ({
|
|
72
|
+
reps: number;
|
|
73
|
+
weightKg?: number | undefined;
|
|
74
|
+
} | {
|
|
75
|
+
durationSeconds: number;
|
|
76
|
+
})[];
|
|
77
|
+
planId: string;
|
|
78
|
+
}>>;
|
|
79
|
+
//# sourceMappingURL=set-plan-exercise-sets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-plan-exercise-sets.d.ts","sourceRoot":"","sources":["../../src/tools/set-plan-exercise-sets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOnC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+B9B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineTool, z } from "@pontix/core/adapter";
|
|
2
|
+
import { editPlan, newSet, setsInput, unknownExercise } from "../plan-edit.js";
|
|
3
|
+
export const setPlanExerciseSetsInput = 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
|
+
plannedExerciseId: z
|
|
6
|
+
.string()
|
|
7
|
+
.min(1)
|
|
8
|
+
.describe("The exercise's entry in this plan: `plannedExerciseId` from `duin_get_plan`, not the catalogue activity id."),
|
|
9
|
+
sets: setsInput,
|
|
10
|
+
});
|
|
11
|
+
export const setPlanExerciseSets = defineTool({
|
|
12
|
+
name: "set_plan_exercise_sets",
|
|
13
|
+
description: "WRITES to your DUIN account: replaces ALL the sets of one exercise in one of your own training plans with the sets given " +
|
|
14
|
+
"(the old sets are discarded, including fields this tool cannot express, such as recovery time). " +
|
|
15
|
+
"The service has no per-exercise call, so the whole plan is read and then REWRITTEN; the other exercises are sent back as they were read. " +
|
|
16
|
+
"Refused, with nothing sent, when the plan is not editable or has no exercise with that `plannedExerciseId`. " +
|
|
17
|
+
"Sets are { reps, weightKg? } or { durationSeconds }. Returns the plan as `duin_get_plan` does, read again after the change.",
|
|
18
|
+
descriptions: {
|
|
19
|
+
es: "ESCRIBE en tu cuenta de DUIN: sustituye TODAS las series de un ejercicio de uno de tus planes de entrenamiento por las indicadas " +
|
|
20
|
+
"(las antiguas se descartan, incluidos campos que esta herramienta no puede expresar, como el tiempo de recuperación). " +
|
|
21
|
+
"El servicio no tiene una llamada por ejercicio, así que se lee el plan completo y se REESCRIBE; los demás ejercicios se reenvían tal como se leyeron. " +
|
|
22
|
+
"Se rechaza, sin enviar nada, si el plan no es editable o no tiene ningún ejercicio con ese `plannedExerciseId`. " +
|
|
23
|
+
"Las series son { reps, weightKg? } o { durationSeconds }. Devuelve el plan como `duin_get_plan`, leído de nuevo tras el cambio.",
|
|
24
|
+
},
|
|
25
|
+
input: setPlanExerciseSetsInput,
|
|
26
|
+
readOnly: false,
|
|
27
|
+
async execute(session, input) {
|
|
28
|
+
return editPlan(session, input.planId, (body) => {
|
|
29
|
+
if (!body.exercises.some((exercise) => String(exercise.id) === input.plannedExerciseId)) {
|
|
30
|
+
throw unknownExercise(input.plannedExerciseId, input.planId);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...body,
|
|
34
|
+
exercises: body.exercises.map((exercise) => String(exercise.id) === input.plannedExerciseId ? { ...exercise, sets: input.sets.map(newSet) } : exercise),
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=set-plan-exercise-sets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-plan-exercise-sets.js","sourceRoot":"","sources":["../../src/tools/set-plan-exercise-sets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,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,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
package/mappers.json
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "Where each field is read from. Data, not code. The login and eGym token definitions come from earlier capture notes. The `workout`, `plan` and `activity` definitions were checked against live responses from one account at one gym on 2026-11-17: each list holds the one spelling that response showed, except the localized names, which fall back through a few languages. None of the three data endpoints wraps its rows except the activity catalogue, so only that one has a page definition; the workout and plan lists are bare arrays and are read in code. The output shapes live in src/shapes.ts and are NOT editable from here.",
|
|
3
|
+
"login": {
|
|
4
|
+
"kind": "object",
|
|
5
|
+
"describe": "The login response",
|
|
6
|
+
"$comment": "Key names from the capture notes, one candidate each: nothing observed suggests an alternative spelling, and an invented one would be a claim about somebody else's API. `uuid` is the exerciser id the token route needs; `homeClubUuid` is the gym location every eGym read takes, and only this response returns it.",
|
|
7
|
+
"fields": {
|
|
8
|
+
"exerciserId": {
|
|
9
|
+
"from": [
|
|
10
|
+
"uuid"
|
|
11
|
+
],
|
|
12
|
+
"as": "text",
|
|
13
|
+
"required": true
|
|
14
|
+
},
|
|
15
|
+
"gymLocationId": {
|
|
16
|
+
"from": [
|
|
17
|
+
"homeClubUuid"
|
|
18
|
+
],
|
|
19
|
+
"as": "text",
|
|
20
|
+
"required": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"fitnessToken": {
|
|
25
|
+
"kind": "object",
|
|
26
|
+
"describe": "The eGym token response",
|
|
27
|
+
"$comment": "No expiry field on purpose: the service publishes none, so none is read.",
|
|
28
|
+
"fields": {
|
|
29
|
+
"access": {
|
|
30
|
+
"from": [
|
|
31
|
+
"accessToken"
|
|
32
|
+
],
|
|
33
|
+
"as": "text",
|
|
34
|
+
"required": true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"workout": {
|
|
39
|
+
"kind": "object",
|
|
40
|
+
"describe": "A workout in the response",
|
|
41
|
+
"$comment": "Names from the live capture of GET /mwa/api/workouts/v1.0/workouts (2026-11-17): a workout has `completedAt` (a local wall-clock ISO string with no offset, e.g. 2026-11-16T19:08:17.216), `timezone` (an IANA zone, e.g. Europe/Madrid), `workoutPlanName`, `workoutPlanGroupType`, `templateGroupId`, `workoutPlanImageUrl` and `exercises[]`. There is NO workout id and NO workout-level duration: a duration exists only per exercise, so none is read. `completedAt` is read as text, not `instant`, because `instant` would label a local time as UTC; the tool combines it with `timezone`. Entries logged from a connected app (for example Apple Health) carry no plan name, and some are stamped 23:59:59 for the day. Counting exercises is `count`, which takes an array. Sorting, windowing and totals are computed in code.",
|
|
42
|
+
"fields": {
|
|
43
|
+
"completedAt": {
|
|
44
|
+
"from": [
|
|
45
|
+
"completedAt"
|
|
46
|
+
],
|
|
47
|
+
"as": "text"
|
|
48
|
+
},
|
|
49
|
+
"timezone": {
|
|
50
|
+
"from": [
|
|
51
|
+
"timezone"
|
|
52
|
+
],
|
|
53
|
+
"as": "text"
|
|
54
|
+
},
|
|
55
|
+
"name": {
|
|
56
|
+
"from": [
|
|
57
|
+
"workoutPlanName"
|
|
58
|
+
],
|
|
59
|
+
"as": "text"
|
|
60
|
+
},
|
|
61
|
+
"planGroupType": {
|
|
62
|
+
"from": [
|
|
63
|
+
"workoutPlanGroupType"
|
|
64
|
+
],
|
|
65
|
+
"as": "text"
|
|
66
|
+
},
|
|
67
|
+
"exerciseCount": {
|
|
68
|
+
"from": [
|
|
69
|
+
"exercises"
|
|
70
|
+
],
|
|
71
|
+
"as": "count"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"plan": {
|
|
76
|
+
"kind": "object",
|
|
77
|
+
"describe": "A plan in the response",
|
|
78
|
+
"$comment": "Names from the live capture of GET /mwa/api/workouts/v1.1/available-plans (2026-11-17): a bare array whose entries carry `id` (a number), `name`, `groupType`, `exerciseValueSource`, `editable`, `deletable`, `plannedExercises[]`, `type`, `labels`, `gym` and `imageUrl`. `editable` and `deletable` are real booleans and are deliberately NOT here: the vocabulary has no boolean coercion (`text` drops a boolean, `present` answers true for `false`), so src/tools/list-plans.ts reads them off the raw row. Only the length of `plannedExercises` is taken; each entry carries a full activity object (names in every language, muscle mapping, images, videos), which is what makes the response about 1.3 MB, and none of it is read.",
|
|
79
|
+
"fields": {
|
|
80
|
+
"id": {
|
|
81
|
+
"from": [
|
|
82
|
+
"id"
|
|
83
|
+
],
|
|
84
|
+
"as": "text",
|
|
85
|
+
"required": true
|
|
86
|
+
},
|
|
87
|
+
"name": {
|
|
88
|
+
"from": [
|
|
89
|
+
"name"
|
|
90
|
+
],
|
|
91
|
+
"as": "text"
|
|
92
|
+
},
|
|
93
|
+
"groupType": {
|
|
94
|
+
"from": [
|
|
95
|
+
"groupType"
|
|
96
|
+
],
|
|
97
|
+
"as": "text"
|
|
98
|
+
},
|
|
99
|
+
"exerciseValueSource": {
|
|
100
|
+
"from": [
|
|
101
|
+
"exerciseValueSource"
|
|
102
|
+
],
|
|
103
|
+
"as": "text"
|
|
104
|
+
},
|
|
105
|
+
"exerciseCount": {
|
|
106
|
+
"from": [
|
|
107
|
+
"plannedExercises"
|
|
108
|
+
],
|
|
109
|
+
"as": "count"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"activity": {
|
|
114
|
+
"kind": "object",
|
|
115
|
+
"describe": "An activity in the response",
|
|
116
|
+
"$comment": "Names from the live capture of GET /mwa/api/workouts/v2.0/activities (2026-11-17): `activityId` (an integer; `text` stringifies numbers), `name` (a map keyed by language that, in the capture, held only the one locale the service had: `es`, or `en` when there was no Spanish name), `category`, `difficulty` and `met` (null on most rows). `category` here is the row's own vocabulary (WEIGHT_MACHINE_BASED, BODY_WEIGHT_BASED, FITNESS_CLASS, SPORT, ...), not the STRENGTH/COORDINATION/... the search filters by. Deliberately left out: description, synonyms, images, videos, muscleMapping and equipmentsV2. The tool's job is to find an activity and its id; equipment and muscle mapping could be added by a tool that is asked for one activity.",
|
|
117
|
+
"fields": {
|
|
118
|
+
"id": {
|
|
119
|
+
"from": [
|
|
120
|
+
"activityId"
|
|
121
|
+
],
|
|
122
|
+
"as": "text",
|
|
123
|
+
"required": true
|
|
124
|
+
},
|
|
125
|
+
"name": {
|
|
126
|
+
"in": [
|
|
127
|
+
[
|
|
128
|
+
"name"
|
|
129
|
+
]
|
|
130
|
+
],
|
|
131
|
+
"from": [
|
|
132
|
+
"es",
|
|
133
|
+
"es-ES",
|
|
134
|
+
"en",
|
|
135
|
+
"en-US"
|
|
136
|
+
],
|
|
137
|
+
"as": "text",
|
|
138
|
+
"or": {
|
|
139
|
+
"from": [
|
|
140
|
+
"name"
|
|
141
|
+
],
|
|
142
|
+
"as": "text"
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"category": {
|
|
146
|
+
"from": [
|
|
147
|
+
"category"
|
|
148
|
+
],
|
|
149
|
+
"as": "text"
|
|
150
|
+
},
|
|
151
|
+
"difficulty": {
|
|
152
|
+
"from": [
|
|
153
|
+
"difficulty"
|
|
154
|
+
],
|
|
155
|
+
"as": "text"
|
|
156
|
+
},
|
|
157
|
+
"met": {
|
|
158
|
+
"from": [
|
|
159
|
+
"met"
|
|
160
|
+
],
|
|
161
|
+
"as": "number"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"activityList": {
|
|
166
|
+
"kind": "page",
|
|
167
|
+
"describe": "The activity catalogue response",
|
|
168
|
+
"$comment": "The envelope is the one recorded live (2026-11-17): `count`, `page`, `items`, `nextPageToken` (a string, \"1\" on the first page) and `categories` (a facet list of {category, docCount}, left out: it is counts per filter value, not rows). `nextPageToken` is read so the tool can say whether there is more, and is not handed on: the tool pages by number. `fields` run against the payload root, so a bare array (which the engine reads as rows) would leave `total`, `page` and `nextPageToken` null; the code treats each of those as absent, not as a value.",
|
|
169
|
+
"rows": {
|
|
170
|
+
"from": [
|
|
171
|
+
"items"
|
|
172
|
+
],
|
|
173
|
+
"of": "activity",
|
|
174
|
+
"into": "activities"
|
|
175
|
+
},
|
|
176
|
+
"fields": {
|
|
177
|
+
"total": {
|
|
178
|
+
"from": [
|
|
179
|
+
"count"
|
|
180
|
+
],
|
|
181
|
+
"as": "count"
|
|
182
|
+
},
|
|
183
|
+
"page": {
|
|
184
|
+
"from": [
|
|
185
|
+
"page"
|
|
186
|
+
],
|
|
187
|
+
"as": "count"
|
|
188
|
+
},
|
|
189
|
+
"nextPageToken": {
|
|
190
|
+
"from": [
|
|
191
|
+
"nextPageToken"
|
|
192
|
+
],
|
|
193
|
+
"as": "text"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pontix/adapter-duin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pontix connector for DUIN (an eGym / NetPulse gym): signs in with your own My DUIN account and reads your workouts, training plans and the exercise catalogue (private API).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pontix",
|
|
7
|
+
"mcp",
|
|
8
|
+
"pontix-adapter",
|
|
9
|
+
"duin",
|
|
10
|
+
"egym",
|
|
11
|
+
"netpulse",
|
|
12
|
+
"gym"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://pontix.dev",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/angeltonio/pontix.git",
|
|
18
|
+
"directory": "adapters/duin"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/angeltonio/pontix/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "AGPL-3.0-only",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20.12"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"mappers.json"
|
|
36
|
+
],
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@pontix/core": "^0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@pontix/core": "^0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
6
48
|
}
|