@pontix/adapter-duin 0.0.0-stage → 0.1.1

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 +98 -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/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # @pontix/adapter-duin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Reads your own gym account on DUIN, a NetPulse white label whose training data
4
+ comes from eGym. DUIN publishes no API, so this talks to the endpoints the My
5
+ DUIN app uses.
6
+
7
+ Field names for the three data tools were confirmed on 2026-11-17 against one
8
+ live account at one gym (the v1.1 available-plans, v2.0 activities and v1.0
9
+ workouts responses, plus the opt-ins healthcheck), and the fixtures in
10
+ `src/__fixtures__/` are scrubbed copies of those responses. The two sign-in
11
+ responses (NetPulse login and the eGym token) come from earlier capture notes
12
+ and were not part of that run.
13
+
14
+ - Source kind: `private_api` — undocumented endpoints, expect breakage.
15
+ - Access: with your own My DUIN account, rate limited. Reads by default; three tools write to your own training plans (see Tools).
16
+ - Backends: the gym chain's NetPulse host (login, and the token eGym accepts)
17
+ and eGym's `mwa-api` (catalogue, plans, workouts). The NetPulse session cookie
18
+ is only the sign-in bootstrap and is never sent to eGym; every data call
19
+ carries an `Authorization: Bearer` token.
20
+ - Package: `private: true`, discovered from a checkout of this repository and
21
+ not installed from npm.
22
+
23
+ ## Credentials
24
+
25
+ | Variable | Required | Notes |
26
+ | --- | --- | --- |
27
+ | `PONTIX_DUIN_EMAIL` | yes | Your own account |
28
+ | `PONTIX_DUIN_PASSWORD` | yes | Stays in your environment, never in the repo |
29
+ | `PONTIX_DUIN_BASE_URL` | no | NetPulse host override. Testing only — decides where your credentials are sent |
30
+ | `PONTIX_DUIN_EGYM_BASE_URL` | no | eGym `mwa-api` host override. Testing only — decides where your access token is sent |
31
+
32
+ Extra accounts use the `__NAME` suffix on every variable (`PONTIX_DUIN_EMAIL__MARIA`), or `pontix login duin --account maria`; see the [CLI README](../../packages/cli/README.md#several-accounts-of-one-service). Each account needs its own values, overrides included.
33
+
34
+ ## Tools
35
+
36
+ The first four are read-only: three are about your own data, the catalogue
37
+ search is about eGym's. The last three **write** to your account: they change
38
+ your own training plans, and nothing else; the runtime leaves them
39
+ unregistered unless you start with `--allow-writes`.
40
+
41
+ | Tool | Returns |
42
+ | --- | --- |
43
+ | `duin_list_workouts` | Your workouts in a date range (default: the last 30 days), most recent first: when completed (the gym's local clock, with its `timezone`), the plan's name and kind when there was one, and exercise count. A session logged from a connected app such as Apple Health has no plan. The service sends no workout id and no workout-level duration, so neither is returned. `limit` defaults to 20 (at most 100) and the result says how many the window held, because the service sends the whole window in one response and this tool does the bounding. No per-set detail. |
44
+ | `duin_list_plans` | The plans you can start: id, name, kind (`USER_OWN`, `TRAINER_ASSIGNED` or `BRAND_SPECIFIC`), where its exercise values come from, how many exercises it holds, and whether you may edit (`editable`) or delete (`deletable`) it. Your own plans come first, then those a trainer assigned, then the gym's catalogue, and `groups` counts each kind so the catalogue is not listed to be counted. Optional `groupType` filter; `limit` defaults to 20 (at most 100). The service sends about 1.3 MB, almost all of it exercise detail, which is dropped. `editable` and `deletable` are `true`, `false` or `null`: `true` for your own plans and `false` for the gym's and a trainer's, and `null` is a third answer, the service said nothing, which is not the same as no. |
45
+ | `duin_get_plan` | One plan by `planId` (from `duin_list_plans`) with its exercises: name (Spanish, then English, then any language), the catalogue `activityId` (the `id` `duin_search_activities` returns), `category`, the three muscles it loads most (strongest first) and its sets: `type` (`REP_BASED` or `TIME_BASED`), `reps`, `durationSeconds` and `weightKg`, each omitted when the service sent null. Also `editable` and `deletable`. Distance, speed, incline and heart rate are not returned (their units were never confirmed). An id that is not among your plans is refused as `invalid_input`. No descriptions, images or videos. |
46
+ | `duin_search_activities` | A search of eGym's exercise catalogue: id, name, `category`, difficulty and met value. Optional `name` (part of a name, at most 100 characters) and `category` filter. One page per call: `page` counts from 0, `limit` defaults to 20 (at most 50), and the result carries `total` (null when the service did not say), `returned` and `hasMore`. No description, images, videos, muscles or equipment. |
47
+ | `duin_add_plan_exercise` | **Writes.** Appends one exercise to the end of one of your own plans. Takes `planId`, `activityId` (a number: the `id` `duin_search_activities` returns) and `sets` (1 to 20, each `{ reps, weightKg? }` or `{ durationSeconds }`; a missing weight is sent as 0). The service has no per-exercise call: it takes the whole plan, so the tool reads the plan, appends the exercise and sends everything back, then reads the plan again and returns it as `duin_get_plan` does. Existing exercises and their sets are sent exactly as read, fields this connector does not return included. The new exercise gets a numeric id made from the clock, as the app does. |
48
+ | `duin_remove_plan_exercise` | **Writes, and deletes data.** Removes one exercise and its sets from one of your own plans. Takes `planId` and `plannedExerciseId` (from `duin_get_plan`, not the catalogue id); an id the plan does not hold is `invalid_input`. Rewrites the whole plan without it and returns the plan read again. |
49
+ | `duin_set_plan_exercise_sets` | **Writes.** Replaces all the sets of one exercise in one of your own plans. Takes `planId`, `plannedExerciseId` and `sets` as above. The old sets are discarded, including recovery time, speed and the like, which the new ones do not carry. Rewrites the whole plan and returns it read again. |
50
+
51
+ ### Writing plans
52
+
53
+ - **Only your own plans.** A plan whose `editable` is not exactly `true` (a
54
+ trainer's, the gym's) is refused as `not_supported` before anything is sent.
55
+ - **Every write replaces the whole plan.** One `POST` carries the full list of
56
+ exercises; a change that lands between the read and the write is overwritten.
57
+ The result is read back from the service, so what it shows is what is saved.
58
+ - **Captured once, on 2026-11-19, from the iOS app.** Not yet exercised by this
59
+ connector against the live service.
60
+
61
+ ### Reading `duin_search_activities`
62
+
63
+ - **The `category` filter and the `category` on a row are different
64
+ vocabularies.** The filter takes `STRENGTH`, `COORDINATION`, `MOBILITY` or
65
+ `FITNESS_CLASS`; a row answers `FREE_WEIGHTS`, `EGYM_MACHINE`, `TREADMILL` and
66
+ similar. A `STRENGTH` search that returns `FREE_WEIGHTS` rows is the filter
67
+ working. The row keeps the service's name for it rather than being renamed out
68
+ of sight of where it came from.
69
+ - **The catalogue is eGym's whole exercise line, not your gym's inventory.** It
70
+ lists smart machines your gym does not own. A result here is not evidence that
71
+ the gym has it.
72
+ - **`hasMore` is the service's own next-page token and nothing else**, never
73
+ arithmetic over `total`. It can be false while `total` is far above the rows
74
+ in hand, and that is the ordinary last page of a large result. The cost is
75
+ stated: if the service renames that key, `hasMore` goes false and paging stops
76
+ after the first page, with nothing in the output saying so.
77
+ `pontix capture duin` reports which candidate key each field hit, which is
78
+ where that drift would show.
79
+ - **It is the only cached tool: one hour**, keyed by the input, so each page and
80
+ filter is cached on its own. That is right here because this is eGym's static
81
+ exercise library, and nothing the member does makes it stale. It would be
82
+ wrong for `duin_list_workouts` and `duin_list_plans`, which are the member's
83
+ own data: someone who logs a session or makes a plan asks about it straight
84
+ away, so neither is cached.
85
+
86
+ ## Implementation notes
87
+
88
+ Field names live in `mappers.json`, not in code, so a rename upstream is a data
89
+ fix. Every response is parsed into `src/shapes.ts`, so an upstream change fails
90
+ loudly instead of returning silent garbage.
91
+
92
+ - `editable` and `deletable` on a plan are read in code, not in `mappers.json`:
93
+ the mapper vocabulary has no boolean coercion, and `text` and `present` would
94
+ each erase the `false` that separates the gym's plans from yours.
95
+ - The workout and plan lists are bare arrays; anything else is reported as
96
+ drift. The activity catalogue is the only enveloped response.
97
+ - Record real responses as fixtures under `src/__fixtures__/` with real key
98
+ names and invented values: workout history is health data. See that
99
+ directory's README for what is scrubbed.
package/dist/auth.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { type AuthFlow, type HttpClient } from "@pontix/core/adapter";
2
+ export interface DuinToken {
3
+ /**
4
+ * NetPulse's `JSESSIONID=<value>` pair. It is what renews `access` without
5
+ * the password, and it is NEVER sent to eGym: see `authorize`.
6
+ */
7
+ readonly cookie: string;
8
+ /** The eGym bearer. Short lived, with no refresh token behind it. */
9
+ readonly access: string;
10
+ /** Names the member in the token route; only the login returns it. */
11
+ readonly exerciserId: string;
12
+ /** `homeClubUuid`. Every eGym read takes it, and only the login returns it. */
13
+ readonly gymLocationId: string;
14
+ }
15
+ /**
16
+ * Two services, one sign-in: the member logs in to the gym chain's NetPulse,
17
+ * which hands out a short-lived token that eGym accepts.
18
+ *
19
+ * `client` is the NetPulse one and must be unauthenticated. Both calls here
20
+ * obtain credentials rather than present them, so an authenticated client would
21
+ * need a token to get one. The `AuthSession` built from this flow is attached
22
+ * to the eGym client only.
23
+ *
24
+ * **No `expiresAt`.** The service publishes no expiry. "About 20 minutes" is an
25
+ * observation from one capture, not a contract, and hardcoding it would state
26
+ * something about somebody else's API as if it were fact. Absent, core recovers
27
+ * from a rejected request, which is what the capture describes.
28
+ */
29
+ export declare function createAuthFlow(client: HttpClient): AuthFlow<DuinToken>;
30
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAmED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,CAwGtE"}
package/dist/auth.js ADDED
@@ -0,0 +1,170 @@
1
+ import { PontixError, applyMapper, bearer, upstreamChanged, } from "@pontix/core/adapter";
2
+ import { ADAPTER_ID, MAPPERS } from "./mappers.js";
3
+ /**
4
+ * A field the definition marks `required`, checked again here.
5
+ *
6
+ * `mappers.json` is data and can be edited without a release, so `required`
7
+ * alone is not trusted: `String(null)` would become a bearer token with the
8
+ * literal value "null", sent to a real service on somebody's behalf.
9
+ */
10
+ function mustHave(value, describe, payload) {
11
+ if (typeof value === "string" && value !== "")
12
+ return value;
13
+ throw upstreamChanged(ADAPTER_ID, describe, payload);
14
+ }
15
+ /**
16
+ * A declared credential, or a refusal to go to the network without it.
17
+ *
18
+ * Unreachable through every path this repository has: the runtime, `pontix
19
+ * check` and `pontix capture` all call `resolveCredentials` first and report a
20
+ * module whose required fields are missing as unavailable, so this adapter is
21
+ * never started without them. It exists because an index read is typed
22
+ * `string | undefined`, and because posting an empty password to somebody's
23
+ * real login is a worse answer than naming what is missing.
24
+ */
25
+ function credential(context, name) {
26
+ const value = context.credentials[name];
27
+ if (value === undefined || value === "") {
28
+ throw new PontixError("auth_required", `No "${name}" credential for ${ADAPTER_ID}.`, {
29
+ adapterId: ADAPTER_ID,
30
+ });
31
+ }
32
+ return value;
33
+ }
34
+ const SESSION_COOKIE = "JSESSIONID";
35
+ /**
36
+ * Only the `name=value` pair goes back, not the `Set-Cookie` line: its
37
+ * attributes (Path, HttpOnly, Secure) are instructions to a browser's cookie
38
+ * jar and are not valid in a `Cookie` request header.
39
+ */
40
+ function readSessionCookie(response, payload) {
41
+ for (const line of response.headers.getSetCookie()) {
42
+ const pair = line.split(";", 1)[0]?.trim() ?? "";
43
+ if (pair.startsWith(`${SESSION_COOKIE}=`) && pair.length > SESSION_COOKIE.length + 1)
44
+ return pair;
45
+ }
46
+ throw upstreamChanged(ADAPTER_ID, `The login response (${SESSION_COOKIE} cookie)`, payload);
47
+ }
48
+ /** Fetches the eGym bearer with a live NetPulse session. */
49
+ async function fetchAccessToken(client, cookie, exerciserId) {
50
+ // `FLS` is the token kind the app asks for on this route, copied from the
51
+ // capture rather than understood: the notes record the path verbatim and
52
+ // nothing explains what the three letters stand for. It is somebody else's
53
+ // constant, so it is quoted, not derived.
54
+ const payload = await client.requestJson(`/np/micro-web-app/v1.0/exercisers/${encodeURIComponent(exerciserId)}/tokens/FLS`, { headers: { cookie } });
55
+ const mapped = applyMapper(MAPPERS, "fitnessToken", payload, ADAPTER_ID);
56
+ return mustHave(mapped["access"], "The eGym token response (access token)", payload);
57
+ }
58
+ /**
59
+ * Two services, one sign-in: the member logs in to the gym chain's NetPulse,
60
+ * which hands out a short-lived token that eGym accepts.
61
+ *
62
+ * `client` is the NetPulse one and must be unauthenticated. Both calls here
63
+ * obtain credentials rather than present them, so an authenticated client would
64
+ * need a token to get one. The `AuthSession` built from this flow is attached
65
+ * to the eGym client only.
66
+ *
67
+ * **No `expiresAt`.** The service publishes no expiry. "About 20 minutes" is an
68
+ * observation from one capture, not a contract, and hardcoding it would state
69
+ * something about somebody else's API as if it were fact. Absent, core recovers
70
+ * from a rejected request, which is what the capture describes.
71
+ */
72
+ export function createAuthFlow(client) {
73
+ /**
74
+ * Whether the token route last failed on a session this flow had just opened.
75
+ *
76
+ * It separates the two things an unreadable token response can mean. After a
77
+ * fresh login the cookie is as live as it will ever be, so a token route that
78
+ * still cannot be read is the route, not the session — and `renew` must stop
79
+ * offering "sign in again" as the explanation, or every eGym rejection would
80
+ * post the member's password at a service that is going to refuse it anyway.
81
+ */
82
+ let tokenRouteFailedOnAFreshSession = false;
83
+ return {
84
+ async login(context) {
85
+ // `request`, not `requestJson`: the session is in a response header, which
86
+ // `requestJson` would discard. The form is encoded here because core sends
87
+ // a string body exactly as written.
88
+ const response = await client.request("/np/exerciser/login", {
89
+ method: "POST",
90
+ headers: { "content-type": "application/x-www-form-urlencoded" },
91
+ body: new URLSearchParams({
92
+ // The member types an email; NetPulse's form calls the field
93
+ // `username`. The credential is named for what a person supplies.
94
+ username: credential(context, "email"),
95
+ password: credential(context, "password"),
96
+ }).toString(),
97
+ });
98
+ let payload;
99
+ try {
100
+ payload = await response.json();
101
+ }
102
+ catch {
103
+ throw upstreamChanged(ADAPTER_ID, "The login response (not JSON)", undefined);
104
+ }
105
+ // Wrong credentials arrive as a rejected status and become `auth_failed`;
106
+ // a 200 without these fields is drift, and says which keys it did get.
107
+ const mapped = applyMapper(MAPPERS, "login", payload, ADAPTER_ID);
108
+ const exerciserId = mustHave(mapped["exerciserId"], "The login response (exerciser id)", payload);
109
+ const gymLocationId = mustHave(mapped["gymLocationId"], "The login response (home club)", payload);
110
+ const cookie = readSessionCookie(response, payload);
111
+ let access;
112
+ try {
113
+ access = await fetchAccessToken(client, cookie, exerciserId);
114
+ }
115
+ catch (cause) {
116
+ // This cookie is seconds old, so an unreadable answer here is about the
117
+ // route. Remembered so renewal stops treating the same answer as an
118
+ // expired session and asking for another login.
119
+ if (cause instanceof PontixError && cause.code === "upstream_changed") {
120
+ tokenRouteFailedOnAFreshSession = true;
121
+ }
122
+ throw cause;
123
+ }
124
+ tokenRouteFailedOnAFreshSession = false;
125
+ return { token: { cookie, access, exerciserId, gymLocationId } };
126
+ },
127
+ /**
128
+ * Core tries this before a full login, so without it every expiry would post
129
+ * the member's password again.
130
+ *
131
+ * `AuthSession` in `@pontix/core/adapter` falls back to a full login only when this
132
+ * throws an auth rejection, and rethrows anything else. That matters because
133
+ * nobody has watched NetPulse answer the token route with a dead session: a
134
+ * 401 would recover on its own, but a 200 carrying a sign-in page would
135
+ * arrive here as `upstream_changed`, be rethrown, and leave the connector
136
+ * holding the same dead cookie until the process restarts.
137
+ *
138
+ * So a response this route cannot be read from is treated as the session
139
+ * being over — once. Here, unlike in `login`, there is a cheaper
140
+ * explanation than redesign: we are holding a cookie we believed was live.
141
+ * Being wrong costs one login, which either succeeds, because the session
142
+ * had simply ended, or fails the same way and reports it from there.
143
+ *
144
+ * Only once, because that login is what tells the two apart. If it opened a
145
+ * new session and the token route still could not be read, the route is
146
+ * what changed, and saying "sign in again" to every later rejection would
147
+ * post the member's password at a service already refusing to answer.
148
+ */
149
+ async renew(current) {
150
+ try {
151
+ return {
152
+ token: {
153
+ ...current,
154
+ access: await fetchAccessToken(client, current.cookie, current.exerciserId),
155
+ },
156
+ };
157
+ }
158
+ catch (cause) {
159
+ const unreadable = cause instanceof PontixError && cause.code === "upstream_changed";
160
+ if (!unreadable || tokenRouteFailedOnAFreshSession)
161
+ throw cause;
162
+ throw new PontixError("auth_failed", `The NetPulse session for ${ADAPTER_ID} no longer buys a token; signing in again.`, { adapterId: ADAPTER_ID, cause });
163
+ }
164
+ },
165
+ // The bearer and nothing else. `cookie` is a credential for a different
166
+ // party, the gym chain's NetPulse, and eGym has no business holding it.
167
+ authorize: (token) => bearer(token.access),
168
+ };
169
+ }
170
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EACX,MAAM,EACN,eAAe,GAIhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgBnD;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,KAAc,EAAE,QAAgB,EAAE,OAAgB;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAC5D,MAAM,eAAe,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvD,CA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,CAAC;QACH,CAAC;QAED,wEAAwE;QACxE,wEAAwE;QACxE,SAAS,EAAE,CAAC,KAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;KACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { DuinSession } from "./session.js";
2
+ /**
3
+ * The raw available-plans response, shared by `list_plans` and `get_plan`.
4
+ *
5
+ * Not cached: the member may create or change a plan and ask about it straight
6
+ * away. The query is copied from the capture: METRIC is what a Spanish gym
7
+ * reports in, and the locale picks which translation of a name comes back.
8
+ */
9
+ export declare function fetchAvailablePlans(session: DuinSession): Promise<unknown>;
10
+ //# sourceMappingURL=available-plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"available-plans.d.ts","sourceRoot":"","sources":["../src/available-plans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAKhF"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The raw available-plans response, shared by `list_plans` and `get_plan`.
3
+ *
4
+ * Not cached: the member may create or change a plan and ask about it straight
5
+ * away. The query is copied from the capture: METRIC is what a Spanish gym
6
+ * reports in, and the locale picks which translation of a name comes back.
7
+ */
8
+ export async function fetchAvailablePlans(session) {
9
+ const { gymLocationId } = await session.auth.token();
10
+ return session.egymHttp.requestJson("/mwa/api/workouts/v1.1/available-plans", {
11
+ query: { gymLocationId, measurementSystem: "METRIC", locale: "es-ES" },
12
+ });
13
+ }
14
+ //# sourceMappingURL=available-plans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"available-plans.js","sourceRoot":"","sources":["../src/available-plans.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAoB;IAC5D,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACrD,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAU,wCAAwC,EAAE;QACrF,KAAK,EAAE,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;KACvE,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { type DuinSession } from "./session.js";
2
+ /**
3
+ * DUIN connector. `adapters/wallapop` is the worked example.
4
+ *
5
+ * DUIN publishes no API. Its app is a NetPulse white label and the training
6
+ * data comes from eGym, so this adapter talks to the endpoints those two
7
+ * backends serve the app, on behalf of the member who owns the account,
8
+ * rate limited. Reading is the rule; the only writes are the three plan-edit
9
+ * tools, which rewrite one of the member's own plans and say so. The endpoints
10
+ * are undocumented and change without notice.
11
+ *
12
+ * This file is the manifest and nothing else. Each tool is a file in `tools/`.
13
+ */
14
+ declare const _default: import("@pontix/core/adapter").Adapter<DuinSession>;
15
+ export default _default;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAS/D;;;;;;;;;;;GAWG;;AACH,wBA+DG"}
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ import { defineAdapter } from "@pontix/core/adapter";
2
+ import { ADAPTER_ID } from "./mappers.js";
3
+ import { createSession } from "./session.js";
4
+ import { addPlanExercise } from "./tools/add-plan-exercise.js";
5
+ import { getPlan } from "./tools/get-plan.js";
6
+ import { listPlans } from "./tools/list-plans.js";
7
+ import { listWorkouts } from "./tools/list-workouts.js";
8
+ import { removePlanExercise } from "./tools/remove-plan-exercise.js";
9
+ import { searchActivities } from "./tools/search-activities.js";
10
+ import { setPlanExerciseSets } from "./tools/set-plan-exercise-sets.js";
11
+ /**
12
+ * DUIN connector. `adapters/wallapop` is the worked example.
13
+ *
14
+ * DUIN publishes no API. Its app is a NetPulse white label and the training
15
+ * data comes from eGym, so this adapter talks to the endpoints those two
16
+ * backends serve the app, on behalf of the member who owns the account,
17
+ * rate limited. Reading is the rule; the only writes are the three plan-edit
18
+ * tools, which rewrite one of the member's own plans and say so. The endpoints
19
+ * are undocumented and change without notice.
20
+ *
21
+ * This file is the manifest and nothing else. Each tool is a file in `tools/`.
22
+ */
23
+ export default defineAdapter({
24
+ id: ADAPTER_ID,
25
+ displayName: "DUIN",
26
+ // DUIN's own site. The company behind it is Duet Spa & Sports, SL, which is
27
+ // why the API host is `duetsport.netpulse.com` and not something called duin.
28
+ homepage: "https://www.duinclub.com",
29
+ sourceKind: "private_api",
30
+ // `AdapterCategory` has no gym or fitness member, so it files under `sport`.
31
+ category: "sport",
32
+ country: "ES",
33
+ // The data surfaces (`list_workouts`, `list_plans`, `get_plan`, `search_activities`)
34
+ // and the opt-ins healthcheck were captured live on 2026-11-17, from one
35
+ // account at one gym, and the mappers and fixtures follow those responses.
36
+ // The two sign-in responses (NetPulse login, eGym token) come from earlier
37
+ // capture notes, not from that run.
38
+ verifiedAt: "2026-11-17",
39
+ credentials: {
40
+ fields: [
41
+ {
42
+ name: "email",
43
+ env: "PONTIX_DUIN_EMAIL",
44
+ description: "Email of your own My DUIN account",
45
+ secret: false,
46
+ required: true,
47
+ },
48
+ {
49
+ name: "password",
50
+ env: "PONTIX_DUIN_PASSWORD",
51
+ description: "Password of your own My DUIN account",
52
+ secret: true,
53
+ required: true,
54
+ },
55
+ {
56
+ // Two overrides because the service is two hosts, and a stub has to
57
+ // stand in for each. Declared rather than read from process.env, because
58
+ // an adapter must only see the environment it asked for.
59
+ name: "baseUrl",
60
+ env: "PONTIX_DUIN_BASE_URL",
61
+ description: "Override the NetPulse base URL (login, profile, the eGym token). Testing only — it decides which host your credentials are sent to.",
62
+ secret: false,
63
+ required: false,
64
+ },
65
+ {
66
+ name: "egymBaseUrl",
67
+ env: "PONTIX_DUIN_EGYM_BASE_URL",
68
+ description: "Override the eGym mwa-api base URL (catalogue, plans, workouts). Testing only — it decides which host your access token is sent to.",
69
+ secret: false,
70
+ required: false,
71
+ },
72
+ ],
73
+ },
74
+ tools: [
75
+ listWorkouts,
76
+ listPlans,
77
+ getPlan,
78
+ searchActivities,
79
+ addPlanExercise,
80
+ removePlanExercise,
81
+ setPlanExerciseSets,
82
+ ],
83
+ createSession,
84
+ });
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAoB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE;;;;;;;;;;;GAWG;AACH,eAAe,aAAa,CAAc;IACxC,EAAE,EAAE,UAAU;IACd,WAAW,EAAE,MAAM;IACnB,4EAA4E;IAC5E,8EAA8E;IAC9E,QAAQ,EAAE,0BAA0B;IACpC,UAAU,EAAE,aAAa;IACzB,6EAA6E;IAC7E,QAAQ,EAAE,OAAO;IACjB,OAAO,EAAE,IAAI;IACb,qFAAqF;IACrF,yEAAyE;IACzE,2EAA2E;IAC3E,2EAA2E;IAC3E,oCAAoC;IACpC,UAAU,EAAE,YAAY;IACxB,WAAW,EAAE;QACX,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,mBAAmB;gBACxB,WAAW,EAAE,mCAAmC;gBAChD,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,GAAG,EAAE,sBAAsB;gBAC3B,WAAW,EAAE,sCAAsC;gBACnD,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,oEAAoE;gBACpE,yEAAyE;gBACzE,yDAAyD;gBACzD,IAAI,EAAE,SAAS;gBACf,GAAG,EAAE,sBAAsB;gBAC3B,WAAW,EACT,qIAAqI;gBACvI,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,KAAK;aAChB;YACD;gBACE,IAAI,EAAE,aAAa;gBACnB,GAAG,EAAE,2BAA2B;gBAChC,WAAW,EACT,qIAAqI;gBACvI,MAAM,EAAE,KAAK;gBACb,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;IACD,KAAK,EAAE;QACL,YAAY;QACZ,SAAS;QACT,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,mBAAmB;KACpB;IACD,aAAa;CACd,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { MapperSet } from "@pontix/core/adapter";
2
+ /**
3
+ * The connector's own name.
4
+ *
5
+ * Here because every `applyMapper` call needs it to attribute a drift report,
6
+ * and this is the one module in the package that imports nothing from it — so
7
+ * everything else can read it without a cycle.
8
+ */
9
+ export declare const ADAPTER_ID = "duin";
10
+ /**
11
+ * Where each field is read from.
12
+ *
13
+ * Loaded from `mappers.json` rather than written in code, because this is the
14
+ * part that breaks. A fact about somebody else's API can then be corrected
15
+ * without releasing a package; a program cannot.
16
+ *
17
+ * Read from disk rather than imported, for two reasons. JSON module imports are
18
+ * still experimental in Node and warn on every start; and an import is resolved
19
+ * once, so the definitions could never be reloaded — which is the whole point
20
+ * of making them data.
21
+ *
22
+ * The cast is not a validation, on purpose: this file ships inside the package
23
+ * and is as trusted as the code beside it. A definition arriving from anywhere
24
+ * else must be validated before it reaches here.
25
+ *
26
+ * **A login response belongs in here too.** It is the payload with the least
27
+ * confirmed field names in any connector — nobody captures a login twice — so
28
+ * reading it with a hand-written `??` chain is the one place a rename would
29
+ * need a release, and the one response `pontix capture` could not observe.
30
+ * See `adapters/wallapop` for the worked example.
31
+ */
32
+ export declare const MAPPERS: MapperSet;
33
+ //# sourceMappingURL=mappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,OAAO,EAEf,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /**
5
+ * The connector's own name.
6
+ *
7
+ * Here because every `applyMapper` call needs it to attribute a drift report,
8
+ * and this is the one module in the package that imports nothing from it — so
9
+ * everything else can read it without a cycle.
10
+ */
11
+ export const ADAPTER_ID = "duin";
12
+ /**
13
+ * Where each field is read from.
14
+ *
15
+ * Loaded from `mappers.json` rather than written in code, because this is the
16
+ * part that breaks. A fact about somebody else's API can then be corrected
17
+ * without releasing a package; a program cannot.
18
+ *
19
+ * Read from disk rather than imported, for two reasons. JSON module imports are
20
+ * still experimental in Node and warn on every start; and an import is resolved
21
+ * once, so the definitions could never be reloaded — which is the whole point
22
+ * of making them data.
23
+ *
24
+ * The cast is not a validation, on purpose: this file ships inside the package
25
+ * and is as trusted as the code beside it. A definition arriving from anywhere
26
+ * else must be validated before it reaches here.
27
+ *
28
+ * **A login response belongs in here too.** It is the payload with the least
29
+ * confirmed field names in any connector — nobody captures a login twice — so
30
+ * reading it with a hand-written `??` chain is the one place a rename would
31
+ * need a release, and the one response `pontix capture` could not observe.
32
+ * See `adapters/wallapop` for the worked example.
33
+ */
34
+ export const MAPPERS = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "mappers.json"), "utf8"));
35
+ //# sourceMappingURL=mappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappers.js","sourceRoot":"","sources":["../src/mappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAC/B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAC7E,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { PontixError, z } from "@pontix/core/adapter";
2
+ import type { PlanDetail } from "./shapes.js";
3
+ import type { DuinSession } from "./session.js";
4
+ export declare const setInput: z.ZodUnion<[z.ZodObject<{
5
+ reps: z.ZodNumber;
6
+ weightKg: z.ZodOptional<z.ZodNumber>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ reps: number;
9
+ weightKg?: number | undefined;
10
+ }, {
11
+ reps: number;
12
+ weightKg?: number | undefined;
13
+ }>, z.ZodObject<{
14
+ durationSeconds: z.ZodNumber;
15
+ }, "strict", z.ZodTypeAny, {
16
+ durationSeconds: number;
17
+ }, {
18
+ durationSeconds: number;
19
+ }>]>;
20
+ /** The `sets` argument shared by `add_plan_exercise` and `set_plan_exercise_sets`. */
21
+ export declare const setsInput: z.ZodArray<z.ZodUnion<[z.ZodObject<{
22
+ reps: z.ZodNumber;
23
+ weightKg: z.ZodOptional<z.ZodNumber>;
24
+ }, "strict", z.ZodTypeAny, {
25
+ reps: number;
26
+ weightKg?: number | undefined;
27
+ }, {
28
+ reps: number;
29
+ weightKg?: number | undefined;
30
+ }>, z.ZodObject<{
31
+ durationSeconds: z.ZodNumber;
32
+ }, "strict", z.ZodTypeAny, {
33
+ durationSeconds: number;
34
+ }, {
35
+ durationSeconds: number;
36
+ }>]>, "many">;
37
+ export type SetInput = z.infer<typeof setInput>;
38
+ /** An exercise as the service takes it. Existing ones keep every field of their sets. */
39
+ export interface PlanBodyExercise {
40
+ id: number | string;
41
+ activityId: number;
42
+ sets: unknown[];
43
+ }
44
+ export interface PlanBody {
45
+ name: string;
46
+ exercises: PlanBodyExercise[];
47
+ }
48
+ /**
49
+ * A set as the app sent it for an exercise it had just added: the type and the
50
+ * one or two values, nothing else (the app also sent `pristineSet` and `isDone`
51
+ * flags, which are editor state and are not needed).
52
+ */
53
+ export declare function newSet(input: SetInput): Record<string, unknown>;
54
+ /**
55
+ * The body that would leave this plan exactly as it is.
56
+ *
57
+ * Built from the raw upstream row, not from the tool's summary, because the
58
+ * summary drops fields (distance, speed, incline, recovery time...) and sending
59
+ * it back would silently erase them. Each exercise is reduced to the three keys
60
+ * the app sent (`id`, `activityId`, `sets`): the rest of a planned exercise is
61
+ * the catalogue activity, notes and equipment, which the service owns. The sets
62
+ * are passed through, null fields included, so what was read is what is
63
+ * written, with one exception the service forces (see `writableSet`); no field
64
+ * this adapter does not understand is dropped.
65
+ */
66
+ export declare function bodyFromRow(row: Record<string, unknown>): PlanBody;
67
+ /** The error for an exercise id that is not in the plan, before anything is sent. */
68
+ export declare function unknownExercise(plannedExerciseId: string, planId: string): PontixError;
69
+ /**
70
+ * Reads the plan, lets `change` edit the body, sends it and reads the plan back.
71
+ *
72
+ * Refuses before sending anything when the plan is unknown or is not one the
73
+ * member may edit (`editable` must be exactly `true`: null means the service did
74
+ * not say, and a rewrite is not worth a guess). The answer to the POST is an
75
+ * empty `200`, so it goes through `request`, which does not parse the body.
76
+ * The re-read is what the caller sees, so a change the service ignored shows.
77
+ */
78
+ export declare function editPlan(session: DuinSession, planId: string, change: (body: PlanBody) => PlanBody): Promise<PlanDetail>;
79
+ //# sourceMappingURL=plan-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-edit.d.ts","sourceRoot":"","sources":["../src/plan-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAmB,CAAC,EAAE,MAAM,sBAAsB,CAAC;AAGvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA2BhD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;IAA6B,CAAC;AAEnD,sFAAsF;AACtF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;aAMnB,CAAC;AAEJ,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,gBAAgB,EAAE,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI/D;AAsBD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,GAA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