hevy-mcp 1.4.0 → 1.7.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/dist/index.js CHANGED
@@ -7,29 +7,84 @@ import "@dotenvx/dotenvx/config";
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
9
 
10
+ // package.json
11
+ var name = "hevy-mcp";
12
+ var version = "1.7.0";
13
+
10
14
  // src/tools/folders.ts
11
15
  import { z } from "zod";
12
16
 
17
+ // src/utils/error-handler.ts
18
+ function createErrorResponse(error, context) {
19
+ const errorMessage = error instanceof Error ? error.message : String(error);
20
+ const errorCode = error instanceof Error && "code" in error ? error.code : void 0;
21
+ const errorType = determineErrorType(error, errorMessage);
22
+ if (errorCode) {
23
+ console.debug(`Error code: ${errorCode}`);
24
+ }
25
+ const contextPrefix = context ? `[${context}] ` : "";
26
+ const formattedMessage = `${contextPrefix}Error: ${errorMessage}`;
27
+ console.error(`${formattedMessage} (Type: ${errorType})`, error);
28
+ return {
29
+ content: [
30
+ {
31
+ type: "text",
32
+ text: formattedMessage
33
+ }
34
+ ],
35
+ isError: true
36
+ };
37
+ }
38
+ function determineErrorType(error, message) {
39
+ const messageLower = message.toLowerCase();
40
+ const nameLower = error instanceof Error ? error.name.toLowerCase() : "";
41
+ if (nameLower.includes("network") || messageLower.includes("network") || nameLower.includes("fetch") || messageLower.includes("fetch") || nameLower.includes("timeout") || messageLower.includes("timeout")) {
42
+ return "NETWORK_ERROR" /* NETWORK_ERROR */;
43
+ }
44
+ if (nameLower.includes("validation") || messageLower.includes("validation") || messageLower.includes("invalid") || messageLower.includes("required")) {
45
+ return "VALIDATION_ERROR" /* VALIDATION_ERROR */;
46
+ }
47
+ if (messageLower.includes("not found") || messageLower.includes("404") || messageLower.includes("does not exist")) {
48
+ return "NOT_FOUND" /* NOT_FOUND */;
49
+ }
50
+ if (nameLower.includes("api") || messageLower.includes("api") || messageLower.includes("server error") || messageLower.includes("500")) {
51
+ return "API_ERROR" /* API_ERROR */;
52
+ }
53
+ return "UNKNOWN_ERROR" /* UNKNOWN_ERROR */;
54
+ }
55
+ function withErrorHandling(fn, context) {
56
+ return async (...args) => {
57
+ try {
58
+ return await fn(...args);
59
+ } catch (error) {
60
+ return createErrorResponse(error, context);
61
+ }
62
+ };
63
+ }
64
+
13
65
  // src/utils/formatters.ts
14
66
  function formatWorkout(workout) {
15
67
  return {
16
68
  id: workout.id,
17
- date: workout.createdAt,
69
+ date: workout.created_at,
18
70
  name: workout.title,
19
71
  description: workout.description,
20
- duration: calculateDuration(workout.startTime || "", workout.endTime || ""),
72
+ duration: calculateDuration(
73
+ workout.start_time || "",
74
+ workout.end_time || ""
75
+ ),
21
76
  exercises: workout.exercises?.map((exercise) => {
22
77
  return {
23
78
  name: exercise.title,
24
79
  notes: exercise.notes,
25
80
  sets: exercise.sets?.map((set) => ({
26
81
  type: set.type,
27
- weight: set.weightKg,
82
+ weight: set.weight_kg,
28
83
  reps: set.reps,
29
- distance: set.distanceMeters,
30
- duration: set.durationSeconds,
84
+ distance: set.distance_meters,
85
+ duration: set.duration_seconds,
31
86
  rpe: set.rpe,
32
- customMetric: set.customMetric
87
+ customMetric: set.custom_metric
33
88
  }))
34
89
  };
35
90
  })
@@ -39,24 +94,24 @@ function formatRoutine(routine) {
39
94
  return {
40
95
  id: routine.id,
41
96
  title: routine.title,
42
- folderId: routine.folderId,
43
- createdAt: routine.createdAt,
44
- updatedAt: routine.updatedAt,
97
+ folderId: routine.folder_id,
98
+ createdAt: routine.created_at,
99
+ updatedAt: routine.updated_at,
45
100
  exercises: routine.exercises?.map((exercise) => {
46
101
  return {
47
102
  name: exercise.title,
48
103
  index: exercise.index,
49
- exerciseTemplateId: exercise.exerciseTemplateId,
104
+ exerciseTemplateId: exercise.exercise_template_id,
50
105
  notes: exercise.notes,
51
- supersetId: exercise.supersetsId,
106
+ supersetId: exercise.supersets_id,
52
107
  sets: exercise.sets?.map((set) => ({
53
108
  index: set.index,
54
109
  type: set.type,
55
- weight: set.weightKg,
110
+ weight: set.weight_kg,
56
111
  reps: set.reps,
57
- distance: set.distanceMeters,
58
- duration: set.durationSeconds,
59
- customMetric: set.customMetric
112
+ distance: set.distance_meters,
113
+ duration: set.duration_seconds,
114
+ customMetric: set.custom_metric
60
115
  }))
61
116
  };
62
117
  })
@@ -66,8 +121,8 @@ function formatRoutineFolder(folder) {
66
121
  return {
67
122
  id: folder.id,
68
123
  title: folder.title,
69
- createdAt: folder.createdAt,
70
- updatedAt: folder.updatedAt
124
+ createdAt: folder.created_at,
125
+ updatedAt: folder.updated_at
71
126
  };
72
127
  }
73
128
  function calculateDuration(startTime, endTime) {
@@ -96,9 +151,32 @@ function formatExerciseTemplate(template) {
96
151
  id: template.id,
97
152
  title: template.title,
98
153
  type: template.type,
99
- primaryMuscleGroup: template.primaryMuscleGroup,
100
- secondaryMuscleGroups: template.secondaryMuscleGroups,
101
- isCustom: template.isCustom
154
+ primaryMuscleGroup: template.primary_muscle_group,
155
+ secondaryMuscleGroups: template.secondary_muscle_groups,
156
+ isCustom: template.is_custom
157
+ };
158
+ }
159
+
160
+ // src/utils/response-formatter.ts
161
+ function createJsonResponse(data, options = { pretty: true, indent: 2 }) {
162
+ const jsonString = options.pretty ? JSON.stringify(data, null, options.indent) : JSON.stringify(data);
163
+ return {
164
+ content: [
165
+ {
166
+ type: "text",
167
+ text: jsonString
168
+ }
169
+ ]
170
+ };
171
+ }
172
+ function createEmptyResponse(message = "No data found") {
173
+ return {
174
+ content: [
175
+ {
176
+ type: "text",
177
+ text: message
178
+ }
179
+ ]
102
180
  };
103
181
  }
104
182
 
@@ -106,130 +184,70 @@ function formatExerciseTemplate(template) {
106
184
  function registerFolderTools(server2, hevyClient2) {
107
185
  server2.tool(
108
186
  "get-routine-folders",
109
- "Get a paginated list of routine folders available on the account. Returns folder details including ID, title, index (order position), and creation/update timestamps. Useful for organizing routines into categories.",
187
+ "Get a paginated list of your routine folders, including both default and custom folders. Useful for organizing and browsing your workout routines.",
110
188
  {
111
189
  page: z.coerce.number().int().gte(1).default(1),
112
190
  pageSize: z.coerce.number().int().gte(1).lte(10).default(5)
113
191
  },
114
- async ({ page, pageSize }) => {
115
- try {
116
- const data = await hevyClient2.v1.routine_folders.get({
117
- queryParameters: {
118
- page,
119
- pageSize
120
- }
192
+ withErrorHandling(
193
+ async ({ page, pageSize }) => {
194
+ const data = await hevyClient2.getRoutineFolders({
195
+ page,
196
+ pageSize
121
197
  });
122
- const folders = data?.routineFolders?.map((folder) => formatRoutineFolder(folder)) || [];
123
- return {
124
- content: [
125
- {
126
- type: "text",
127
- text: JSON.stringify(folders, null, 2)
128
- }
129
- ]
130
- };
131
- } catch (error) {
132
- console.error("Error fetching routine folders:", error);
133
- return {
134
- content: [
135
- {
136
- type: "text",
137
- text: `Error fetching routine folders: ${error instanceof Error ? error.message : String(error)}`
138
- }
139
- ],
140
- isError: true
141
- };
142
- }
143
- }
198
+ const folders = data?.routine_folders?.map(
199
+ (folder) => formatRoutineFolder(folder)
200
+ ) || [];
201
+ if (folders.length === 0) {
202
+ return createEmptyResponse(
203
+ "No routine folders found for the specified parameters"
204
+ );
205
+ }
206
+ return createJsonResponse(folders);
207
+ },
208
+ "get-routine-folders"
209
+ )
144
210
  );
145
211
  server2.tool(
146
212
  "get-routine-folder",
147
- "Get complete details of a specific routine folder by ID. Returns all folder information including title, index (order position), and creation/update timestamps.",
213
+ "Get complete details of a specific routine folder by its ID, including name, creation date, and associated routines.",
148
214
  {
149
- folderId: z.coerce.number().int()
215
+ folderId: z.string().min(1)
150
216
  },
151
- async ({ folderId }) => {
152
- try {
153
- const data = await hevyClient2.v1.routine_folders.byFolderId(folderId.toString()).get();
154
- if (!data) {
155
- return {
156
- content: [
157
- {
158
- type: "text",
159
- text: `Routine folder with ID ${folderId} not found`
160
- }
161
- ]
162
- };
163
- }
164
- const folder = formatRoutineFolder(data);
165
- return {
166
- content: [
167
- {
168
- type: "text",
169
- text: JSON.stringify(folder, null, 2)
170
- }
171
- ]
172
- };
173
- } catch (error) {
174
- console.error(`Error fetching routine folder ${folderId}:`, error);
175
- return {
176
- content: [
177
- {
178
- type: "text",
179
- text: `Error fetching routine folder: ${error instanceof Error ? error.message : String(error)}`
180
- }
181
- ],
182
- isError: true
183
- };
217
+ withErrorHandling(async ({ folderId }) => {
218
+ const data = await hevyClient2.getRoutineFolder(folderId);
219
+ if (!data) {
220
+ return createEmptyResponse(
221
+ `Routine folder with ID ${folderId} not found`
222
+ );
184
223
  }
185
- }
224
+ const folder = formatRoutineFolder(data);
225
+ return createJsonResponse(folder);
226
+ }, "get-routine-folder")
186
227
  );
187
228
  server2.tool(
188
229
  "create-routine-folder",
189
- "Create a new routine folder in your Hevy account. The folder will be created at index 0, and all other folders will have their indexes incremented. Returns the complete folder details upon successful creation including the newly assigned folder ID.",
230
+ "Create a new routine folder in your Hevy account. Requires a name for the folder. Returns the full folder details including the new folder ID.",
190
231
  {
191
- title: z.string().min(1)
232
+ name: z.string().min(1)
192
233
  },
193
- async ({ title }) => {
194
- try {
195
- const data = await hevyClient2.v1.routine_folders.post({
196
- routineFolder: {
197
- title
198
- }
199
- });
200
- if (!data) {
201
- return {
202
- content: [
203
- {
204
- type: "text",
205
- text: "Failed to create routine folder"
206
- }
207
- ]
208
- };
234
+ withErrorHandling(async ({ name: name2 }) => {
235
+ const data = await hevyClient2.createRoutineFolder({
236
+ routine_folder: {
237
+ title: name2
209
238
  }
210
- const folder = formatRoutineFolder(data);
211
- return {
212
- content: [
213
- {
214
- type: "text",
215
- text: `Routine folder created successfully:
216
- ${JSON.stringify(folder, null, 2)}`
217
- }
218
- ]
219
- };
220
- } catch (error) {
221
- console.error("Error creating routine folder:", error);
222
- return {
223
- content: [
224
- {
225
- type: "text",
226
- text: `Error creating routine folder: ${error instanceof Error ? error.message : String(error)}`
227
- }
228
- ],
229
- isError: true
230
- };
239
+ });
240
+ if (!data) {
241
+ return createEmptyResponse(
242
+ "Failed to create routine folder: Server returned no data"
243
+ );
231
244
  }
232
- }
245
+ const folder = formatRoutineFolder(data);
246
+ return createJsonResponse(folder, {
247
+ pretty: true,
248
+ indent: 2
249
+ });
250
+ }, "create-routine-folder")
233
251
  );
234
252
  }
235
253
 
@@ -238,92 +256,44 @@ import { z as z2 } from "zod";
238
256
  function registerRoutineTools(server2, hevyClient2) {
239
257
  server2.tool(
240
258
  "get-routines",
241
- "Get a paginated list of routines. Returns routine details including title, creation date, folder assignment, and exercise configurations. Results include both default and custom routines.",
259
+ "Get a paginated list of your workout routines, including custom and default routines. Useful for browsing or searching your available routines.",
242
260
  {
243
261
  page: z2.coerce.number().int().gte(1).default(1),
244
262
  pageSize: z2.coerce.number().int().gte(1).lte(10).default(5)
245
263
  },
246
- async ({ page, pageSize }) => {
247
- try {
248
- const data = await hevyClient2.v1.routines.get({
249
- queryParameters: {
250
- page,
251
- pageSize
252
- }
253
- });
254
- const routines = data?.routines?.map((routine) => formatRoutine(routine)) || [];
255
- return {
256
- content: [
257
- {
258
- type: "text",
259
- text: JSON.stringify(routines, null, 2)
260
- }
261
- ]
262
- };
263
- } catch (error) {
264
- console.error("Error fetching routines:", error);
265
- return {
266
- content: [
267
- {
268
- type: "text",
269
- text: `Error fetching routines: ${error instanceof Error ? error.message : String(error)}`
270
- }
271
- ],
272
- isError: true
273
- };
264
+ withErrorHandling(async (args) => {
265
+ const { page, pageSize } = args;
266
+ const data = await hevyClient2.getRoutines({
267
+ page,
268
+ pageSize
269
+ });
270
+ const routines = data?.routines?.map((routine) => formatRoutine(routine)) || [];
271
+ if (routines.length === 0) {
272
+ return createEmptyResponse(
273
+ "No routines found for the specified parameters"
274
+ );
274
275
  }
275
- }
276
+ return createJsonResponse(routines);
277
+ }, "get-routines")
276
278
  );
277
279
  server2.tool(
278
280
  "get-routine",
279
- "Get complete details of a specific routine by ID. Returns all routine information including title, notes, assigned folder, and detailed exercise data with set configurations.",
281
+ "Get a routine by its ID using the direct endpoint. Returns all details for the specified routine.",
280
282
  {
281
283
  routineId: z2.string().min(1)
282
284
  },
283
- async ({ routineId }) => {
284
- try {
285
- const data = await hevyClient2.v1.routines.byRoutineId(routineId).put({
286
- routine: {
287
- title: ""
288
- // We're providing a minimal body as required by the API
289
- }
290
- });
291
- if (!data) {
292
- return {
293
- content: [
294
- {
295
- type: "text",
296
- text: `Routine with ID ${routineId} not found`
297
- }
298
- ]
299
- };
300
- }
301
- const routine = formatRoutine(data);
302
- return {
303
- content: [
304
- {
305
- type: "text",
306
- text: JSON.stringify(routine, null, 2)
307
- }
308
- ]
309
- };
310
- } catch (error) {
311
- console.error(`Error fetching routine ${routineId}:`, error);
312
- return {
313
- content: [
314
- {
315
- type: "text",
316
- text: `Error fetching routine: ${error instanceof Error ? error.message : String(error)}`
317
- }
318
- ],
319
- isError: true
320
- };
285
+ withErrorHandling(async ({ routineId }) => {
286
+ const data = await hevyClient2.getRoutineById(String(routineId));
287
+ if (!data || !data.routine) {
288
+ return createEmptyResponse(`Routine with ID ${routineId} not found`);
321
289
  }
322
- }
290
+ const routine = formatRoutine(data.routine);
291
+ return createJsonResponse(routine);
292
+ }, "get-routine")
323
293
  );
324
294
  server2.tool(
325
295
  "create-routine",
326
- "Create a new workout routine in your Hevy account. Requires title and at least one exercise with sets. Optionally assign to a specific folder. Returns the complete routine details upon successful creation including the newly assigned routine ID.",
296
+ "Create a new workout routine in your Hevy account. Requires a title and at least one exercise with sets. Optionally assign to a folder. Returns the full routine details including the new routine ID.",
327
297
  {
328
298
  title: z2.string().min(1),
329
299
  folderId: z2.coerce.number().nullable().optional(),
@@ -347,66 +317,48 @@ function registerRoutineTools(server2, hevyClient2) {
347
317
  })
348
318
  )
349
319
  },
350
- async ({ title, folderId, notes, exercises }) => {
351
- try {
352
- const data = await hevyClient2.v1.routines.post({
353
- routine: {
354
- title,
355
- folderId: folderId || null,
356
- notes: notes || "",
357
- exercises: exercises.map((exercise) => ({
358
- exerciseTemplateId: exercise.exerciseTemplateId,
359
- supersetId: exercise.supersetId || null,
360
- restSeconds: exercise.restSeconds || null,
361
- notes: exercise.notes || null,
362
- sets: exercise.sets.map((set) => ({
363
- type: set.type,
364
- weightKg: set.weightKg || null,
365
- reps: set.reps || null,
366
- distanceMeters: set.distanceMeters || null,
367
- durationSeconds: set.durationSeconds || null,
368
- customMetric: set.customMetric || null
369
- }))
370
- }))
371
- }
372
- });
373
- if (!data) {
374
- return {
375
- content: [
376
- {
377
- type: "text",
378
- text: "Failed to create routine"
379
- }
380
- ]
381
- };
320
+ withErrorHandling(async (args) => {
321
+ const { title, folderId, notes, exercises } = args;
322
+ const data = await hevyClient2.createRoutine({
323
+ routine: {
324
+ title,
325
+ folder_id: folderId ?? null,
326
+ notes: notes ?? "",
327
+ exercises: exercises.map(
328
+ (exercise) => ({
329
+ exercise_template_id: exercise.exerciseTemplateId,
330
+ superset_id: exercise.supersetId ?? null,
331
+ rest_seconds: exercise.restSeconds ?? null,
332
+ notes: exercise.notes ?? null,
333
+ sets: exercise.sets.map(
334
+ (set) => ({
335
+ type: set.type,
336
+ weight_kg: set.weightKg ?? null,
337
+ reps: set.reps ?? null,
338
+ distance_meters: set.distanceMeters ?? null,
339
+ duration_seconds: set.durationSeconds ?? null,
340
+ custom_metric: set.customMetric ?? null
341
+ })
342
+ )
343
+ })
344
+ )
382
345
  }
383
- const routine = formatRoutine(data);
384
- return {
385
- content: [
386
- {
387
- type: "text",
388
- text: `Routine created successfully:
389
- ${JSON.stringify(routine, null, 2)}`
390
- }
391
- ]
392
- };
393
- } catch (error) {
394
- console.error("Error creating routine:", error);
395
- return {
396
- content: [
397
- {
398
- type: "text",
399
- text: `Error creating routine: ${error instanceof Error ? error.message : String(error)}`
400
- }
401
- ],
402
- isError: true
403
- };
346
+ });
347
+ if (!data) {
348
+ return createEmptyResponse(
349
+ "Failed to create routine: Server returned no data"
350
+ );
404
351
  }
405
- }
352
+ const routine = formatRoutine(data);
353
+ return createJsonResponse(routine, {
354
+ pretty: true,
355
+ indent: 2
356
+ });
357
+ }, "create-routine")
406
358
  );
407
359
  server2.tool(
408
360
  "update-routine",
409
- "Update an existing workout routine by ID. You can modify the title, notes, and exercise data. Returns the updated routine with all changes applied. Note that you cannot change the folder assignment through this method.",
361
+ "Update an existing routine by ID. You can modify the title, notes, and exercise configurations. Returns the updated routine with all changes applied.",
410
362
  {
411
363
  routineId: z2.string().min(1),
412
364
  title: z2.string().min(1),
@@ -430,61 +382,43 @@ ${JSON.stringify(routine, null, 2)}`
430
382
  })
431
383
  )
432
384
  },
433
- async ({ routineId, title, notes, exercises }) => {
434
- try {
435
- const data = await hevyClient2.v1.routines.byRoutineId(routineId).put({
436
- routine: {
437
- title,
438
- notes: notes || null,
439
- exercises: exercises.map((exercise) => ({
440
- exerciseTemplateId: exercise.exerciseTemplateId,
441
- supersetId: exercise.supersetId || null,
442
- restSeconds: exercise.restSeconds || null,
443
- notes: exercise.notes || null,
444
- sets: exercise.sets.map((set) => ({
445
- type: set.type,
446
- weightKg: set.weightKg || null,
447
- reps: set.reps || null,
448
- distanceMeters: set.distanceMeters || null,
449
- durationSeconds: set.durationSeconds || null,
450
- customMetric: set.customMetric || null
451
- }))
452
- }))
453
- }
454
- });
455
- if (!data) {
456
- return {
457
- content: [
458
- {
459
- type: "text",
460
- text: `Failed to update routine with ID ${routineId}`
461
- }
462
- ]
463
- };
385
+ withErrorHandling(async (args) => {
386
+ const { routineId, title, notes, exercises } = args;
387
+ const data = await hevyClient2.updateRoutine(routineId, {
388
+ routine: {
389
+ title,
390
+ notes: notes ?? "",
391
+ exercises: exercises.map(
392
+ (exercise) => ({
393
+ exercise_template_id: exercise.exerciseTemplateId,
394
+ superset_id: exercise.supersetId ?? null,
395
+ rest_seconds: exercise.restSeconds ?? null,
396
+ notes: exercise.notes ?? null,
397
+ sets: exercise.sets.map(
398
+ (set) => ({
399
+ type: set.type,
400
+ weight_kg: set.weightKg ?? null,
401
+ reps: set.reps ?? null,
402
+ distance_meters: set.distanceMeters ?? null,
403
+ duration_seconds: set.durationSeconds ?? null,
404
+ custom_metric: set.customMetric ?? null
405
+ })
406
+ )
407
+ })
408
+ )
464
409
  }
465
- const routine = formatRoutine(data);
466
- return {
467
- content: [
468
- {
469
- type: "text",
470
- text: `Routine updated successfully:
471
- ${JSON.stringify(routine, null, 2)}`
472
- }
473
- ]
474
- };
475
- } catch (error) {
476
- console.error(`Error updating routine ${routineId}:`, error);
477
- return {
478
- content: [
479
- {
480
- type: "text",
481
- text: `Error updating routine: ${error instanceof Error ? error.message : String(error)}`
482
- }
483
- ],
484
- isError: true
485
- };
410
+ });
411
+ if (!data) {
412
+ return createEmptyResponse(
413
+ `Failed to update routine with ID ${routineId}`
414
+ );
486
415
  }
487
- }
416
+ const routine = formatRoutine(data);
417
+ return createJsonResponse(routine, {
418
+ pretty: true,
419
+ indent: 2
420
+ });
421
+ }, "update-routine")
488
422
  );
489
423
  }
490
424
 
@@ -493,167 +427,625 @@ import { z as z3 } from "zod";
493
427
  function registerTemplateTools(server2, hevyClient2) {
494
428
  server2.tool(
495
429
  "get-exercise-templates",
496
- "Get a paginated list of exercise templates available on the account. Returns both default and custom exercise templates with details including title, type, primary muscle group, and secondary muscle groups. Supports up to 100 templates per page.",
430
+ "Get a paginated list of exercise templates (default and custom) with details like name, category, equipment, and muscle groups. Useful for browsing or searching available exercises.",
497
431
  {
498
432
  page: z3.coerce.number().int().gte(1).default(1),
499
- pageSize: z3.coerce.number().int().gte(1).lte(100).default(20)
433
+ pageSize: z3.coerce.number().int().gte(1).lte(100).default(5)
500
434
  },
501
- async ({ page, pageSize }) => {
502
- try {
503
- const data = await hevyClient2.v1.exercise_templates.get({
504
- queryParameters: {
505
- page,
506
- pageSize
507
- }
435
+ withErrorHandling(
436
+ async ({ page, pageSize }) => {
437
+ const data = await hevyClient2.getExerciseTemplates({
438
+ page,
439
+ pageSize
508
440
  });
509
- const templates = data?.exerciseTemplates?.map(
441
+ const templates = data?.exercise_templates?.map(
510
442
  (template) => formatExerciseTemplate(template)
511
443
  ) || [];
512
- return {
513
- content: [
514
- {
515
- type: "text",
516
- text: JSON.stringify(templates, null, 2)
517
- }
518
- ]
519
- };
520
- } catch (error) {
521
- console.error("Error fetching exercise templates:", error);
522
- return {
523
- content: [
524
- {
525
- type: "text",
526
- text: `Error fetching exercise templates: ${error instanceof Error ? error.message : String(error)}`
527
- }
528
- ],
529
- isError: true
530
- };
531
- }
532
- }
444
+ if (templates.length === 0) {
445
+ return createEmptyResponse(
446
+ "No exercise templates found for the specified parameters"
447
+ );
448
+ }
449
+ return createJsonResponse(templates);
450
+ },
451
+ "get-exercise-templates"
452
+ )
533
453
  );
534
454
  server2.tool(
535
455
  "get-exercise-template",
536
- "Get complete details of a specific exercise template by ID. Returns all template information including title, type, primary muscle group, secondary muscle groups, and whether it's a custom exercise.",
456
+ "Get complete details of a specific exercise template by its ID, including name, category, equipment, muscle groups, and notes.",
537
457
  {
538
458
  exerciseTemplateId: z3.string().min(1)
539
459
  },
540
- async ({ exerciseTemplateId }) => {
541
- try {
542
- const data = await hevyClient2.v1.exercise_templates.byExerciseTemplateId(exerciseTemplateId).get();
460
+ withErrorHandling(
461
+ async ({ exerciseTemplateId }) => {
462
+ const data = await hevyClient2.getExerciseTemplate(exerciseTemplateId);
543
463
  if (!data) {
544
- return {
545
- content: [
546
- {
547
- type: "text",
548
- text: `Exercise template with ID ${exerciseTemplateId} not found`
549
- }
550
- ]
551
- };
464
+ return createEmptyResponse(
465
+ `Exercise template with ID ${exerciseTemplateId} not found`
466
+ );
552
467
  }
553
468
  const template = formatExerciseTemplate(data);
554
- return {
555
- content: [
556
- {
557
- type: "text",
558
- text: JSON.stringify(template, null, 2)
559
- }
560
- ]
561
- };
562
- } catch (error) {
563
- console.error(
564
- `Error fetching exercise template ${exerciseTemplateId}:`,
565
- error
566
- );
567
- return {
568
- content: [
569
- {
570
- type: "text",
571
- text: `Error fetching exercise template: ${error instanceof Error ? error.message : String(error)}`
572
- }
573
- ],
574
- isError: true
575
- };
576
- }
577
- }
469
+ return createJsonResponse(template);
470
+ },
471
+ "get-exercise-template"
472
+ )
578
473
  );
579
474
  }
580
475
 
581
- // src/tools/workouts.ts
476
+ // src/tools/webhooks.ts
477
+ import { z as z40 } from "zod";
478
+
479
+ // src/generated/client/schemas/deletedWorkoutSchema.ts
582
480
  import { z as z4 } from "zod";
481
+ var deletedWorkoutSchema = z4.object({
482
+ type: z4.string().describe("Indicates the type of the event (deleted)"),
483
+ id: z4.string().describe("The unique identifier of the deleted workout"),
484
+ deleted_at: z4.string().describe("A date string indicating when the workout was deleted").optional()
485
+ });
583
486
 
584
- // src/utils/error-handler.ts
585
- function createErrorResponse(error, context) {
586
- const errorMessage = error instanceof Error ? error.message : String(error);
587
- const errorCode = error instanceof Error && "code" in error ? error.code : void 0;
588
- if (errorCode) {
589
- console.debug(`Error code: ${errorCode}`);
590
- }
591
- const contextPrefix = context ? `[${context}] ` : "";
592
- const formattedMessage = `${contextPrefix}Error: ${errorMessage}`;
593
- console.error(formattedMessage, error);
594
- return {
595
- content: [
596
- {
597
- type: "text",
598
- text: formattedMessage
599
- }
600
- ],
601
- isError: true
602
- };
603
- }
604
- function withErrorHandling(fn, context) {
605
- return async (...args) => {
606
- try {
607
- return await fn(...args);
608
- } catch (error) {
609
- return createErrorResponse(error, context);
610
- }
611
- };
612
- }
487
+ // src/generated/client/schemas/deleteV1WebhookSubscriptionSchema.ts
488
+ import { z as z5 } from "zod";
489
+ var deleteV1WebhookSubscriptionHeaderParamsSchema = z5.object({
490
+ "api-key": z5.string().uuid().describe("Your API key")
491
+ });
492
+ var deleteV1WebhookSubscription200Schema = z5.any();
493
+ var deleteV1WebhookSubscriptionMutationResponseSchema = z5.lazy(() => deleteV1WebhookSubscription200Schema);
613
494
 
614
- // src/utils/response-formatter.ts
615
- function createJsonResponse(data, options = { pretty: true, indent: 2 }) {
616
- const jsonString = options.pretty ? JSON.stringify(data, null, options.indent) : JSON.stringify(data);
617
- return {
618
- content: [
619
- {
620
- type: "text",
621
- text: jsonString
622
- }
623
- ]
624
- };
625
- }
626
- function createEmptyResponse(message = "No data found") {
627
- return {
628
- content: [
629
- {
630
- type: "text",
631
- text: message
632
- }
633
- ]
634
- };
635
- }
495
+ // src/generated/client/schemas/exerciseTemplateSchema.ts
496
+ import { z as z6 } from "zod";
497
+ var exerciseTemplateSchema = z6.object({
498
+ id: z6.string().describe("The exercise template ID.").optional(),
499
+ title: z6.string().describe("The exercise title.").optional(),
500
+ type: z6.string().describe("The exercise type.").optional(),
501
+ primary_muscle_group: z6.string().describe("The primary muscle group of the exercise.").optional(),
502
+ secondary_muscle_groups: z6.array(z6.string()).describe("The secondary muscle groups of the exercise.").optional(),
503
+ is_custom: z6.boolean().describe("A boolean indicating whether the exercise is a custom exercise.").optional()
504
+ });
636
505
 
637
- // src/tools/workouts.ts
638
- function registerWorkoutTools(server2, hevyClient2) {
639
- server2.tool(
640
- "get-workouts",
641
- "Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.",
642
- {
643
- page: z4.coerce.number().gte(1).default(1),
644
- pageSize: z4.coerce.number().int().gte(1).lte(10).default(5)
645
- },
646
- withErrorHandling(async ({ page, pageSize }) => {
647
- const data = await hevyClient2.v1.workouts.get({
648
- queryParameters: {
649
- page,
650
- pageSize
651
- }
652
- });
653
- const workouts = data?.workouts?.map((workout) => formatWorkout(workout)) || [];
654
- if (workouts.length === 0) {
655
- return createEmptyResponse(
656
- "No workouts found for the specified parameters"
506
+ // src/generated/client/schemas/getV1ExerciseTemplatesExercisetemplateidSchema.ts
507
+ import { z as z7 } from "zod";
508
+ var getV1ExerciseTemplatesExercisetemplateidPathParamsSchema = z7.object({
509
+ exerciseTemplateId: z7.any()
510
+ });
511
+ var getV1ExerciseTemplatesExercisetemplateidHeaderParamsSchema = z7.object({
512
+ "api-key": z7.string().uuid()
513
+ });
514
+ var getV1ExerciseTemplatesExercisetemplateid200Schema = z7.lazy(() => exerciseTemplateSchema);
515
+ var getV1ExerciseTemplatesExercisetemplateid404Schema = z7.any();
516
+ var getV1ExerciseTemplatesExercisetemplateidQueryResponseSchema = z7.lazy(() => getV1ExerciseTemplatesExercisetemplateid200Schema);
517
+
518
+ // src/generated/client/schemas/getV1ExerciseTemplatesSchema.ts
519
+ import { z as z8 } from "zod";
520
+ var getV1ExerciseTemplatesQueryParamsSchema = z8.object({
521
+ page: z8.coerce.number().int().default(1).describe("Page number (Must be 1 or greater)"),
522
+ pageSize: z8.coerce.number().int().default(5).describe("Number of items on the requested page (Max 100)")
523
+ });
524
+ var getV1ExerciseTemplatesHeaderParamsSchema = z8.object({
525
+ "api-key": z8.string().uuid()
526
+ });
527
+ var getV1ExerciseTemplates200Schema = z8.object({
528
+ page: z8.number().int().default(1).describe("Current page number"),
529
+ page_count: z8.number().int().default(5).describe("Total number of pages"),
530
+ exercise_templates: z8.array(z8.lazy(() => exerciseTemplateSchema)).optional()
531
+ });
532
+ var getV1ExerciseTemplates400Schema = z8.any();
533
+ var getV1ExerciseTemplatesQueryResponseSchema = z8.lazy(() => getV1ExerciseTemplates200Schema);
534
+
535
+ // src/generated/client/schemas/routineFolderSchema.ts
536
+ import { z as z9 } from "zod";
537
+ var routineFolderSchema = z9.object({
538
+ id: z9.number().describe("The routine folder ID.").optional(),
539
+ index: z9.number().describe("The routine folder index. Describes the order of the folder in the list.").optional(),
540
+ title: z9.string().describe("The routine folder title.").optional(),
541
+ updated_at: z9.string().describe("ISO 8601 timestamp of when the folder was last updated.").optional(),
542
+ created_at: z9.string().describe("ISO 8601 timestamp of when the folder was created.").optional()
543
+ });
544
+
545
+ // src/generated/client/schemas/getV1RoutineFoldersFolderidSchema.ts
546
+ import { z as z10 } from "zod";
547
+ var getV1RoutineFoldersFolderidPathParamsSchema = z10.object({
548
+ folderId: z10.any()
549
+ });
550
+ var getV1RoutineFoldersFolderidHeaderParamsSchema = z10.object({
551
+ "api-key": z10.string().uuid()
552
+ });
553
+ var getV1RoutineFoldersFolderid200Schema = z10.lazy(() => routineFolderSchema);
554
+ var getV1RoutineFoldersFolderid404Schema = z10.any();
555
+ var getV1RoutineFoldersFolderidQueryResponseSchema = z10.lazy(() => getV1RoutineFoldersFolderid200Schema);
556
+
557
+ // src/generated/client/schemas/getV1RoutineFoldersSchema.ts
558
+ import { z as z11 } from "zod";
559
+ var getV1RoutineFoldersQueryParamsSchema = z11.object({
560
+ page: z11.coerce.number().int().default(1).describe("Page number (Must be 1 or greater)"),
561
+ pageSize: z11.coerce.number().int().default(5).describe("Number of items on the requested page (Max 10)")
562
+ });
563
+ var getV1RoutineFoldersHeaderParamsSchema = z11.object({
564
+ "api-key": z11.string().uuid()
565
+ });
566
+ var getV1RoutineFolders200Schema = z11.object({
567
+ page: z11.number().int().default(1).describe("Current page number"),
568
+ page_count: z11.number().int().default(5).describe("Total number of pages"),
569
+ routine_folders: z11.array(z11.lazy(() => routineFolderSchema)).optional()
570
+ });
571
+ var getV1RoutineFolders400Schema = z11.any();
572
+ var getV1RoutineFoldersQueryResponseSchema = z11.lazy(() => getV1RoutineFolders200Schema);
573
+
574
+ // src/generated/client/schemas/routineSchema.ts
575
+ import { z as z12 } from "zod";
576
+ var routineSchema = z12.object({
577
+ id: z12.string().describe("The routine ID.").optional(),
578
+ title: z12.string().describe("The routine title.").optional(),
579
+ folder_id: z12.number().describe("The routine folder ID.").nullable().nullish(),
580
+ updated_at: z12.string().describe("ISO 8601 timestamp of when the routine was last updated.").optional(),
581
+ created_at: z12.string().describe("ISO 8601 timestamp of when the routine was created.").optional(),
582
+ exercises: z12.array(
583
+ z12.object({
584
+ index: z12.number().describe("Index indicating the order of the exercise in the routine.").optional(),
585
+ title: z12.string().describe("Title of the exercise").optional(),
586
+ rest_seconds: z12.string().describe("The rest time in seconds between sets of the exercise").optional(),
587
+ notes: z12.string().describe("Routine notes on the exercise").optional(),
588
+ exercise_template_id: z12.string().describe("The id of the exercise template. This can be used to fetch the exercise template.").optional(),
589
+ supersets_id: z12.number().describe("The id of the superset that the exercise belongs to. A value of null indicates the exercise is not part of a superset.").nullable().nullish(),
590
+ sets: z12.array(
591
+ z12.object({
592
+ index: z12.number().describe("Index indicating the order of the set in the routine.").optional(),
593
+ type: z12.string().describe("The type of set. This can be one of 'normal', 'warmup', 'dropset', 'failure'").optional(),
594
+ weight_kg: z12.number().describe("Weight lifted in kilograms.").nullable().nullish(),
595
+ reps: z12.number().describe("Number of reps logged for the set").nullable().nullish(),
596
+ distance_meters: z12.number().describe("Number of meters logged for the set").nullable().nullish(),
597
+ duration_seconds: z12.number().describe("Number of seconds logged for the set").nullable().nullish(),
598
+ rpe: z12.number().describe("RPE (Relative perceived exertion) value logged for the set").nullable().nullish(),
599
+ custom_metric: z12.number().describe("Custom metric logged for the set (Currently only used to log floors or steps for stair machine exercises)").nullable().nullish()
600
+ })
601
+ ).optional()
602
+ })
603
+ ).optional()
604
+ });
605
+
606
+ // src/generated/client/schemas/getV1RoutinesRoutineidSchema.ts
607
+ import { z as z13 } from "zod";
608
+ var getV1RoutinesRoutineidPathParamsSchema = z13.object({
609
+ routineId: z13.any()
610
+ });
611
+ var getV1RoutinesRoutineidHeaderParamsSchema = z13.object({
612
+ "api-key": z13.string().uuid()
613
+ });
614
+ var getV1RoutinesRoutineid200Schema = z13.object({
615
+ routine: z13.lazy(() => routineSchema).optional()
616
+ });
617
+ var getV1RoutinesRoutineid400Schema = z13.object({
618
+ error: z13.string().describe("Error message").optional()
619
+ });
620
+ var getV1RoutinesRoutineidQueryResponseSchema = z13.lazy(() => getV1RoutinesRoutineid200Schema);
621
+
622
+ // src/generated/client/schemas/getV1RoutinesSchema.ts
623
+ import { z as z14 } from "zod";
624
+ var getV1RoutinesQueryParamsSchema = z14.object({
625
+ page: z14.coerce.number().int().default(1).describe("Page number (Must be 1 or greater)"),
626
+ pageSize: z14.coerce.number().int().default(5).describe("Number of items on the requested page (Max 10)")
627
+ });
628
+ var getV1RoutinesHeaderParamsSchema = z14.object({
629
+ "api-key": z14.string().uuid()
630
+ });
631
+ var getV1Routines200Schema = z14.object({
632
+ page: z14.number().int().describe("Current page number").optional(),
633
+ page_count: z14.number().int().describe("Total number of pages").optional(),
634
+ routines: z14.array(z14.lazy(() => routineSchema)).optional()
635
+ });
636
+ var getV1Routines400Schema = z14.any();
637
+ var getV1RoutinesQueryResponseSchema = z14.lazy(() => getV1Routines200Schema);
638
+
639
+ // src/generated/client/schemas/getV1WebhookSubscriptionSchema.ts
640
+ import { z as z15 } from "zod";
641
+ var getV1WebhookSubscriptionHeaderParamsSchema = z15.object({
642
+ "api-key": z15.string().uuid().describe("Your API key")
643
+ });
644
+ var getV1WebhookSubscription200Schema = z15.object({
645
+ url: z15.string().describe("The webhook URL").optional(),
646
+ auth_token: z15.string().describe("The auth token for the webhook").optional()
647
+ });
648
+ var getV1WebhookSubscription404Schema = z15.any();
649
+ var getV1WebhookSubscriptionQueryResponseSchema = z15.lazy(() => getV1WebhookSubscription200Schema);
650
+
651
+ // src/generated/client/schemas/getV1WorkoutsCountSchema.ts
652
+ import { z as z16 } from "zod";
653
+ var getV1WorkoutsCountHeaderParamsSchema = z16.object({
654
+ "api-key": z16.string().uuid()
655
+ });
656
+ var getV1WorkoutsCount200Schema = z16.object({
657
+ workout_count: z16.number().int().default(42).describe("The total number of workouts")
658
+ });
659
+ var getV1WorkoutsCountQueryResponseSchema = z16.lazy(() => getV1WorkoutsCount200Schema);
660
+
661
+ // src/generated/client/schemas/workoutSchema.ts
662
+ import { z as z17 } from "zod";
663
+ var workoutSchema = z17.object({
664
+ id: z17.string().describe("The workout ID.").optional(),
665
+ title: z17.string().describe("The workout title.").optional(),
666
+ description: z17.string().describe("The workout description.").optional(),
667
+ start_time: z17.number().describe("ISO 8601 timestamp of when the workout was recorded to have started.").optional(),
668
+ end_time: z17.number().describe("ISO 8601 timestamp of when the workout was recorded to have ended.").optional(),
669
+ updated_at: z17.string().describe("ISO 8601 timestamp of when the workout was last updated.").optional(),
670
+ created_at: z17.string().describe("ISO 8601 timestamp of when the workout was created.").optional(),
671
+ exercises: z17.array(
672
+ z17.object({
673
+ index: z17.number().describe("Index indicating the order of the exercise in the workout.").optional(),
674
+ title: z17.string().describe("Title of the exercise").optional(),
675
+ notes: z17.string().describe("Notes on the exercise").optional(),
676
+ exercise_template_id: z17.string().describe("The id of the exercise template. This can be used to fetch the exercise template.").optional(),
677
+ supersets_id: z17.number().describe("The id of the superset that the exercise belongs to. A value of null indicates the exercise is not part of a superset.").nullable().nullish(),
678
+ sets: z17.array(
679
+ z17.object({
680
+ index: z17.number().describe("Index indicating the order of the set in the workout.").optional(),
681
+ type: z17.string().describe("The type of set. This can be one of 'normal', 'warmup', 'dropset', 'failure'").optional(),
682
+ weight_kg: z17.number().describe("Weight lifted in kilograms.").nullable().nullish(),
683
+ reps: z17.number().describe("Number of reps logged for the set").nullable().nullish(),
684
+ distance_meters: z17.number().describe("Number of meters logged for the set").nullable().nullish(),
685
+ duration_seconds: z17.number().describe("Number of seconds logged for the set").nullable().nullish(),
686
+ rpe: z17.number().describe("RPE (Relative perceived exertion) value logged for the set").nullable().nullish(),
687
+ custom_metric: z17.number().describe("Custom metric logged for the set (Currently only used to log floors or steps for stair machine exercises)").nullable().nullish()
688
+ })
689
+ ).optional()
690
+ })
691
+ ).optional()
692
+ });
693
+
694
+ // src/generated/client/schemas/updatedWorkoutSchema.ts
695
+ import { z as z18 } from "zod";
696
+ var updatedWorkoutSchema = z18.object({
697
+ type: z18.string().describe("Indicates the type of the event (updated)"),
698
+ workout: z18.lazy(() => workoutSchema)
699
+ });
700
+
701
+ // src/generated/client/schemas/paginatedWorkoutEventsSchema.ts
702
+ import { z as z19 } from "zod";
703
+ var paginatedWorkoutEventsSchema = z19.object({
704
+ page: z19.number().int().describe("The current page number"),
705
+ page_count: z19.number().int().describe("The total number of pages available"),
706
+ events: z19.array(z19.union([z19.lazy(() => updatedWorkoutSchema), z19.lazy(() => deletedWorkoutSchema)])).describe("An array of workout events (either updated or deleted)")
707
+ });
708
+
709
+ // src/generated/client/schemas/getV1WorkoutsEventsSchema.ts
710
+ import { z as z20 } from "zod";
711
+ var getV1WorkoutsEventsQueryParamsSchema = z20.object({
712
+ page: z20.coerce.number().int().default(1).describe("Page number (Must be 1 or greater)"),
713
+ pageSize: z20.coerce.number().int().default(5).describe("Number of items on the requested page (Max 10)"),
714
+ since: z20.string().default("1970-01-01T00:00:00Z")
715
+ });
716
+ var getV1WorkoutsEventsHeaderParamsSchema = z20.object({
717
+ "api-key": z20.string().uuid()
718
+ });
719
+ var getV1WorkoutsEvents200Schema = z20.lazy(() => paginatedWorkoutEventsSchema);
720
+ var getV1WorkoutsEvents500Schema = z20.any();
721
+ var getV1WorkoutsEventsQueryResponseSchema = z20.lazy(() => getV1WorkoutsEvents200Schema);
722
+
723
+ // src/generated/client/schemas/getV1WorkoutsSchema.ts
724
+ import { z as z21 } from "zod";
725
+ var getV1WorkoutsQueryParamsSchema = z21.object({
726
+ page: z21.coerce.number().int().default(1).describe("Page number (Must be 1 or greater)"),
727
+ pageSize: z21.coerce.number().int().default(5).describe("Number of items on the requested page (Max 10)")
728
+ });
729
+ var getV1WorkoutsHeaderParamsSchema = z21.object({
730
+ "api-key": z21.string().uuid()
731
+ });
732
+ var getV1Workouts200Schema = z21.object({
733
+ page: z21.number().int().describe("Current page number").optional(),
734
+ page_count: z21.number().int().describe("Total number of pages").optional(),
735
+ workouts: z21.array(z21.lazy(() => workoutSchema)).optional()
736
+ });
737
+ var getV1Workouts400Schema = z21.any();
738
+ var getV1WorkoutsQueryResponseSchema = z21.lazy(() => getV1Workouts200Schema);
739
+
740
+ // src/generated/client/schemas/getV1WorkoutsWorkoutidSchema.ts
741
+ import { z as z22 } from "zod";
742
+ var getV1WorkoutsWorkoutidPathParamsSchema = z22.object({
743
+ workoutId: z22.any()
744
+ });
745
+ var getV1WorkoutsWorkoutidHeaderParamsSchema = z22.object({
746
+ "api-key": z22.string().uuid()
747
+ });
748
+ var getV1WorkoutsWorkoutid200Schema = z22.lazy(() => workoutSchema);
749
+ var getV1WorkoutsWorkoutid404Schema = z22.any();
750
+ var getV1WorkoutsWorkoutidQueryResponseSchema = z22.lazy(() => getV1WorkoutsWorkoutid200Schema);
751
+
752
+ // src/generated/client/schemas/postRoutineFolderRequestBodySchema.ts
753
+ import { z as z23 } from "zod";
754
+ var postRoutineFolderRequestBodySchema = z23.object({
755
+ routine_folder: z23.object({
756
+ title: z23.string().describe("The title of the routine folder.").optional()
757
+ }).optional()
758
+ });
759
+
760
+ // src/generated/client/schemas/postRoutinesRequestSetSchema.ts
761
+ import { z as z24 } from "zod";
762
+ var postRoutinesRequestSetSchema = z24.object({
763
+ type: z24.enum(["warmup", "normal", "failure", "dropset"]).describe("The type of the set.").optional(),
764
+ weight_kg: z24.number().describe("The weight in kilograms.").nullable().nullish(),
765
+ reps: z24.number().int().describe("The number of repetitions.").nullable().nullish(),
766
+ distance_meters: z24.number().int().describe("The distance in meters.").nullable().nullish(),
767
+ duration_seconds: z24.number().int().describe("The duration in seconds.").nullable().nullish(),
768
+ custom_metric: z24.number().describe("A custom metric for the set. Currently used for steps and floors.").nullable().nullish()
769
+ });
770
+
771
+ // src/generated/client/schemas/postRoutinesRequestExerciseSchema.ts
772
+ import { z as z25 } from "zod";
773
+ var postRoutinesRequestExerciseSchema = z25.object({
774
+ exercise_template_id: z25.string().describe("The ID of the exercise template.").optional(),
775
+ superset_id: z25.number().int().describe("The ID of the superset.").nullable().nullish(),
776
+ rest_seconds: z25.number().int().describe("The rest time in seconds.").nullable().nullish(),
777
+ notes: z25.string().describe("Additional notes for the exercise.").nullable().nullish(),
778
+ sets: z25.array(z25.lazy(() => postRoutinesRequestSetSchema)).optional()
779
+ });
780
+
781
+ // src/generated/client/schemas/postRoutinesRequestBodySchema.ts
782
+ import { z as z26 } from "zod";
783
+ var postRoutinesRequestBodySchema = z26.object({
784
+ routine: z26.object({
785
+ title: z26.string().describe("The title of the routine.").optional(),
786
+ folder_id: z26.number().describe('The folder id the routine should be added to. Pass null to insert the routine into default "My Routines" folder').nullable().nullish(),
787
+ notes: z26.string().describe("Additional notes for the routine.").optional(),
788
+ exercises: z26.array(z26.lazy(() => postRoutinesRequestExerciseSchema)).optional()
789
+ }).optional()
790
+ });
791
+
792
+ // src/generated/client/schemas/postV1RoutineFoldersSchema.ts
793
+ import { z as z27 } from "zod";
794
+ var postV1RoutineFoldersHeaderParamsSchema = z27.object({
795
+ "api-key": z27.string().uuid()
796
+ });
797
+ var postV1RoutineFolders201Schema = z27.lazy(() => routineFolderSchema);
798
+ var postV1RoutineFolders400Schema = z27.object({
799
+ error: z27.string().describe("Error message").optional()
800
+ });
801
+ var postV1RoutineFoldersMutationRequestSchema = z27.lazy(() => postRoutineFolderRequestBodySchema);
802
+ var postV1RoutineFoldersMutationResponseSchema = z27.lazy(() => postV1RoutineFolders201Schema);
803
+
804
+ // src/generated/client/schemas/postV1RoutinesSchema.ts
805
+ import { z as z28 } from "zod";
806
+ var postV1RoutinesHeaderParamsSchema = z28.object({
807
+ "api-key": z28.string().uuid()
808
+ });
809
+ var postV1Routines201Schema = z28.lazy(() => routineSchema);
810
+ var postV1Routines400Schema = z28.object({
811
+ error: z28.string().describe("Error message").optional()
812
+ });
813
+ var postV1Routines403Schema = z28.object({
814
+ error: z28.string().describe("Error message").optional()
815
+ });
816
+ var postV1RoutinesMutationRequestSchema = z28.lazy(() => postRoutinesRequestBodySchema);
817
+ var postV1RoutinesMutationResponseSchema = z28.lazy(() => postV1Routines201Schema);
818
+
819
+ // src/generated/client/schemas/webhookRequestBodySchema.ts
820
+ import { z as z29 } from "zod";
821
+ var webhookRequestBodySchema = z29.object({
822
+ authToken: z29.string().describe("The auth token that will be send as Authorization header in the webhook.").optional(),
823
+ url: z29.string().describe("The webhook URL.").optional()
824
+ });
825
+
826
+ // src/generated/client/schemas/postV1WebhookSubscriptionSchema.ts
827
+ import { z as z30 } from "zod";
828
+ var postV1WebhookSubscriptionHeaderParamsSchema = z30.object({
829
+ "api-key": z30.string().uuid()
830
+ });
831
+ var postV1WebhookSubscription201Schema = z30.any();
832
+ var postV1WebhookSubscription400Schema = z30.object({
833
+ error: z30.string().describe("Error message").optional()
834
+ });
835
+ var postV1WebhookSubscriptionMutationRequestSchema = z30.lazy(() => webhookRequestBodySchema);
836
+ var postV1WebhookSubscriptionMutationResponseSchema = z30.lazy(() => postV1WebhookSubscription201Schema);
837
+
838
+ // src/generated/client/schemas/postWorkoutsRequestSetSchema.ts
839
+ import { z as z31 } from "zod";
840
+ var postWorkoutsRequestSetSchema = z31.object({
841
+ type: z31.enum(["warmup", "normal", "failure", "dropset"]).describe("The type of the set.").optional(),
842
+ weight_kg: z31.number().describe("The weight in kilograms.").nullable().nullish(),
843
+ reps: z31.number().int().describe("The number of repetitions.").nullable().nullish(),
844
+ distance_meters: z31.number().int().describe("The distance in meters.").nullable().nullish(),
845
+ duration_seconds: z31.number().int().describe("The duration in seconds.").nullable().nullish(),
846
+ custom_metric: z31.number().describe("A custom metric for the set. Currently used for steps and floors.").nullable().nullish(),
847
+ rpe: z31.union([z31.literal(6), z31.literal(7), z31.literal(7.5), z31.literal(8), z31.literal(8.5), z31.literal(9), z31.literal(9.5), z31.literal(10)]).describe("The Rating of Perceived Exertion (RPE).").nullable().nullish()
848
+ });
849
+
850
+ // src/generated/client/schemas/postWorkoutsRequestExerciseSchema.ts
851
+ import { z as z32 } from "zod";
852
+ var postWorkoutsRequestExerciseSchema = z32.object({
853
+ exercise_template_id: z32.string().describe("The ID of the exercise template.").optional(),
854
+ superset_id: z32.number().int().describe("The ID of the superset.").nullable().nullish(),
855
+ notes: z32.string().describe("Additional notes for the exercise.").nullable().nullish(),
856
+ sets: z32.array(z32.lazy(() => postWorkoutsRequestSetSchema)).optional()
857
+ });
858
+
859
+ // src/generated/client/schemas/postWorkoutsRequestBodySchema.ts
860
+ import { z as z33 } from "zod";
861
+ var postWorkoutsRequestBodySchema = z33.object({
862
+ workout: z33.object({
863
+ title: z33.string().describe("The title of the workout.").optional(),
864
+ description: z33.string().describe("A description for the workout workout.").nullable().nullish(),
865
+ start_time: z33.string().describe("The time the workout started.").optional(),
866
+ end_time: z33.string().describe("The time the workout ended.").optional(),
867
+ is_private: z33.boolean().describe("A boolean indicating if the workout is private.").optional(),
868
+ exercises: z33.array(z33.lazy(() => postWorkoutsRequestExerciseSchema)).optional()
869
+ }).optional()
870
+ });
871
+
872
+ // src/generated/client/schemas/postV1WorkoutsSchema.ts
873
+ import { z as z34 } from "zod";
874
+ var postV1WorkoutsHeaderParamsSchema = z34.object({
875
+ "api-key": z34.string().uuid()
876
+ });
877
+ var postV1Workouts201Schema = z34.lazy(() => workoutSchema);
878
+ var postV1Workouts400Schema = z34.object({
879
+ error: z34.string().describe("Error message").optional()
880
+ });
881
+ var postV1WorkoutsMutationRequestSchema = z34.lazy(() => postWorkoutsRequestBodySchema);
882
+ var postV1WorkoutsMutationResponseSchema = z34.lazy(() => postV1Workouts201Schema);
883
+
884
+ // src/generated/client/schemas/putRoutinesRequestSetSchema.ts
885
+ import { z as z35 } from "zod";
886
+ var putRoutinesRequestSetSchema = z35.object({
887
+ type: z35.enum(["warmup", "normal", "failure", "dropset"]).describe("The type of the set.").optional(),
888
+ weight_kg: z35.number().describe("The weight in kilograms.").nullable().nullish(),
889
+ reps: z35.number().int().describe("The number of repetitions.").nullable().nullish(),
890
+ distance_meters: z35.number().int().describe("The distance in meters.").nullable().nullish(),
891
+ duration_seconds: z35.number().int().describe("The duration in seconds.").nullable().nullish(),
892
+ custom_metric: z35.number().describe("A custom metric for the set. Currently used for steps and floors.").nullable().nullish()
893
+ });
894
+
895
+ // src/generated/client/schemas/putRoutinesRequestExerciseSchema.ts
896
+ import { z as z36 } from "zod";
897
+ var putRoutinesRequestExerciseSchema = z36.object({
898
+ exercise_template_id: z36.string().describe("The ID of the exercise template.").optional(),
899
+ superset_id: z36.number().int().describe("The ID of the superset.").nullable().nullish(),
900
+ rest_seconds: z36.number().int().describe("The rest time in seconds.").nullable().nullish(),
901
+ notes: z36.string().describe("Additional notes for the exercise.").nullable().nullish(),
902
+ sets: z36.array(z36.lazy(() => putRoutinesRequestSetSchema)).optional()
903
+ });
904
+
905
+ // src/generated/client/schemas/putRoutinesRequestBodySchema.ts
906
+ import { z as z37 } from "zod";
907
+ var putRoutinesRequestBodySchema = z37.object({
908
+ routine: z37.object({
909
+ title: z37.string().describe("The title of the routine.").optional(),
910
+ notes: z37.string().describe("Additional notes for the routine.").nullable().nullish(),
911
+ exercises: z37.array(z37.lazy(() => putRoutinesRequestExerciseSchema)).optional()
912
+ }).optional()
913
+ });
914
+
915
+ // src/generated/client/schemas/putV1RoutinesRoutineidSchema.ts
916
+ import { z as z38 } from "zod";
917
+ var putV1RoutinesRoutineidPathParamsSchema = z38.object({
918
+ routineId: z38.any()
919
+ });
920
+ var putV1RoutinesRoutineidHeaderParamsSchema = z38.object({
921
+ "api-key": z38.string().uuid()
922
+ });
923
+ var putV1RoutinesRoutineid200Schema = z38.lazy(() => routineSchema);
924
+ var putV1RoutinesRoutineid400Schema = z38.object({
925
+ error: z38.string().describe("Error message").optional()
926
+ });
927
+ var putV1RoutinesRoutineid404Schema = z38.object({
928
+ error: z38.string().describe("Error message").optional()
929
+ });
930
+ var putV1RoutinesRoutineidMutationRequestSchema = z38.lazy(() => putRoutinesRequestBodySchema);
931
+ var putV1RoutinesRoutineidMutationResponseSchema = z38.lazy(() => putV1RoutinesRoutineid200Schema);
932
+
933
+ // src/generated/client/schemas/putV1WorkoutsWorkoutidSchema.ts
934
+ import { z as z39 } from "zod";
935
+ var putV1WorkoutsWorkoutidPathParamsSchema = z39.object({
936
+ workoutId: z39.any()
937
+ });
938
+ var putV1WorkoutsWorkoutidHeaderParamsSchema = z39.object({
939
+ "api-key": z39.string().uuid()
940
+ });
941
+ var putV1WorkoutsWorkoutid200Schema = z39.lazy(() => workoutSchema);
942
+ var putV1WorkoutsWorkoutid400Schema = z39.object({
943
+ error: z39.string().describe("Error message").optional()
944
+ });
945
+ var putV1WorkoutsWorkoutidMutationRequestSchema = z39.lazy(() => postWorkoutsRequestBodySchema);
946
+ var putV1WorkoutsWorkoutidMutationResponseSchema = z39.lazy(() => putV1WorkoutsWorkoutid200Schema);
947
+
948
+ // src/tools/webhooks.ts
949
+ var webhookUrlSchema = z40.string().url().refine(
950
+ (url) => {
951
+ try {
952
+ const parsed = new URL(url);
953
+ return parsed.protocol === "https:" || parsed.protocol === "http:";
954
+ } catch {
955
+ return false;
956
+ }
957
+ },
958
+ {
959
+ message: "Webhook URL must be a valid HTTP or HTTPS URL"
960
+ }
961
+ ).refine(
962
+ (url) => {
963
+ try {
964
+ const parsed = new URL(url);
965
+ return parsed.hostname !== "localhost" && !parsed.hostname.startsWith("127.");
966
+ } catch {
967
+ return false;
968
+ }
969
+ },
970
+ {
971
+ message: "Webhook URL cannot be localhost or loopback address"
972
+ }
973
+ );
974
+ function registerWebhookTools(server2, hevyClient2) {
975
+ server2.tool(
976
+ "get-webhook-subscription",
977
+ "Get the current webhook subscription for this account. Returns the webhook URL and auth token if a subscription exists.",
978
+ {},
979
+ withErrorHandling(async () => {
980
+ const data = await hevyClient2.getWebhookSubscription();
981
+ if (!data) {
982
+ return createEmptyResponse(
983
+ "No webhook subscription found for this account"
984
+ );
985
+ }
986
+ return createJsonResponse(data);
987
+ }, "get-webhook-subscription")
988
+ );
989
+ server2.tool(
990
+ "create-webhook-subscription",
991
+ "Create a new webhook subscription for this account. The webhook will receive POST requests when workouts are created. Your endpoint must respond with 200 OK within 5 seconds.",
992
+ {
993
+ url: webhookUrlSchema.describe(
994
+ "The webhook URL that will receive POST requests when workouts are created"
995
+ ),
996
+ authToken: z40.string().optional().describe(
997
+ "Optional auth token that will be sent as Authorization header in webhook requests"
998
+ )
999
+ },
1000
+ withErrorHandling(async ({ url, authToken }) => {
1001
+ const requestBody = webhookRequestBodySchema.parse({
1002
+ url,
1003
+ authToken
1004
+ });
1005
+ const data = await hevyClient2.createWebhookSubscription(requestBody);
1006
+ if (!data) {
1007
+ return createEmptyResponse(
1008
+ "Failed to create webhook subscription - please check your URL and try again"
1009
+ );
1010
+ }
1011
+ return createJsonResponse(data);
1012
+ }, "create-webhook-subscription")
1013
+ );
1014
+ server2.tool(
1015
+ "delete-webhook-subscription",
1016
+ "Delete the current webhook subscription for this account. This will stop all webhook notifications.",
1017
+ {},
1018
+ withErrorHandling(async () => {
1019
+ const data = await hevyClient2.deleteWebhookSubscription();
1020
+ if (!data) {
1021
+ return createEmptyResponse(
1022
+ "Failed to delete webhook subscription - no subscription may exist or there was a server error"
1023
+ );
1024
+ }
1025
+ return createJsonResponse(data);
1026
+ }, "delete-webhook-subscription")
1027
+ );
1028
+ }
1029
+
1030
+ // src/tools/workouts.ts
1031
+ import { z as z41 } from "zod";
1032
+ function registerWorkoutTools(server2, hevyClient2) {
1033
+ server2.tool(
1034
+ "get-workouts",
1035
+ "Get a paginated list of workouts. Returns workout details including title, description, start/end times, and exercises performed. Results are ordered from newest to oldest.",
1036
+ {
1037
+ page: z41.coerce.number().gte(1).default(1),
1038
+ pageSize: z41.coerce.number().int().gte(1).lte(10).default(5)
1039
+ },
1040
+ withErrorHandling(async ({ page, pageSize }) => {
1041
+ const data = await hevyClient2.getWorkouts({
1042
+ page,
1043
+ pageSize
1044
+ });
1045
+ const workouts = data?.workouts?.map((workout) => formatWorkout(workout)) || [];
1046
+ if (workouts.length === 0) {
1047
+ return createEmptyResponse(
1048
+ "No workouts found for the specified parameters"
657
1049
  );
658
1050
  }
659
1051
  return createJsonResponse(workouts);
@@ -663,10 +1055,10 @@ function registerWorkoutTools(server2, hevyClient2) {
663
1055
  "get-workout",
664
1056
  "Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.",
665
1057
  {
666
- workoutId: z4.string().min(1)
1058
+ workoutId: z41.string().min(1)
667
1059
  },
668
1060
  withErrorHandling(async ({ workoutId }) => {
669
- const data = await hevyClient2.v1.workouts.byWorkoutId(workoutId).get();
1061
+ const data = await hevyClient2.getWorkout(workoutId);
670
1062
  if (!data) {
671
1063
  return createEmptyResponse(`Workout with ID ${workoutId} not found`);
672
1064
  }
@@ -679,7 +1071,7 @@ function registerWorkoutTools(server2, hevyClient2) {
679
1071
  "Get the total number of workouts on the account. Useful for pagination or statistics.",
680
1072
  {},
681
1073
  withErrorHandling(async () => {
682
- const data = await hevyClient2.v1.workouts.count.get();
1074
+ const data = await hevyClient2.getWorkoutCount();
683
1075
  const count = data ? data.workoutCount || 0 : 0;
684
1076
  return createJsonResponse({ count });
685
1077
  }, "get-workout-count")
@@ -688,17 +1080,15 @@ function registerWorkoutTools(server2, hevyClient2) {
688
1080
  "get-workout-events",
689
1081
  "Retrieve a paged list of workout events (updates or deletes) since a given date. Events are ordered from newest to oldest. The intention is to allow clients to keep their local cache of workouts up to date without having to fetch the entire list of workouts.",
690
1082
  {
691
- page: z4.coerce.number().int().gte(1).default(1),
692
- pageSize: z4.coerce.number().int().gte(1).lte(10).default(5),
693
- since: z4.string().default("1970-01-01T00:00:00Z")
1083
+ page: z41.coerce.number().int().gte(1).default(1),
1084
+ pageSize: z41.coerce.number().int().gte(1).lte(10).default(5),
1085
+ since: z41.string().default("1970-01-01T00:00:00Z")
694
1086
  },
695
1087
  withErrorHandling(async ({ page, pageSize, since }) => {
696
- const data = await hevyClient2.v1.workouts.events.get({
697
- queryParameters: {
698
- page,
699
- pageSize,
700
- since
701
- }
1088
+ const data = await hevyClient2.getWorkoutEvents({
1089
+ page,
1090
+ pageSize,
1091
+ since
702
1092
  });
703
1093
  const events = data?.events || [];
704
1094
  if (events.length === 0) {
@@ -713,25 +1103,25 @@ function registerWorkoutTools(server2, hevyClient2) {
713
1103
  "create-workout",
714
1104
  "Create a new workout in your Hevy account. Requires title, start/end times, and at least one exercise with sets. Returns the complete workout details upon successful creation including the newly assigned workout ID.",
715
1105
  {
716
- title: z4.string().min(1),
717
- description: z4.string().optional().nullable(),
718
- startTime: z4.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
719
- endTime: z4.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
720
- isPrivate: z4.boolean().default(false),
721
- exercises: z4.array(
722
- z4.object({
723
- exerciseTemplateId: z4.string().min(1),
724
- supersetId: z4.coerce.number().nullable().optional(),
725
- notes: z4.string().optional().nullable(),
726
- sets: z4.array(
727
- z4.object({
728
- type: z4.enum(["warmup", "normal", "failure", "dropset"]).default("normal"),
729
- weightKg: z4.coerce.number().optional().nullable(),
730
- reps: z4.coerce.number().int().optional().nullable(),
731
- distanceMeters: z4.coerce.number().int().optional().nullable(),
732
- durationSeconds: z4.coerce.number().int().optional().nullable(),
733
- rpe: z4.coerce.number().optional().nullable(),
734
- customMetric: z4.coerce.number().optional().nullable()
1106
+ title: z41.string().min(1),
1107
+ description: z41.string().optional().nullable(),
1108
+ startTime: z41.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
1109
+ endTime: z41.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
1110
+ isPrivate: z41.boolean().default(false),
1111
+ exercises: z41.array(
1112
+ z41.object({
1113
+ exerciseTemplateId: z41.string().min(1),
1114
+ supersetId: z41.coerce.number().nullable().optional(),
1115
+ notes: z41.string().optional().nullable(),
1116
+ sets: z41.array(
1117
+ z41.object({
1118
+ type: z41.enum(["warmup", "normal", "failure", "dropset"]).default("normal"),
1119
+ weightKg: z41.coerce.number().optional().nullable(),
1120
+ reps: z41.coerce.number().int().optional().nullable(),
1121
+ distanceMeters: z41.coerce.number().int().optional().nullable(),
1122
+ durationSeconds: z41.coerce.number().int().optional().nullable(),
1123
+ rpe: z41.coerce.number().optional().nullable(),
1124
+ customMetric: z41.coerce.number().optional().nullable()
735
1125
  })
736
1126
  )
737
1127
  })
@@ -769,7 +1159,7 @@ function registerWorkoutTools(server2, hevyClient2) {
769
1159
  }))
770
1160
  }
771
1161
  };
772
- const data = await hevyClient2.v1.workouts.post(requestBody);
1162
+ const data = await hevyClient2.createWorkout(requestBody);
773
1163
  if (!data) {
774
1164
  return createEmptyResponse(
775
1165
  "Failed to create workout: Server returned no data"
@@ -788,26 +1178,26 @@ function registerWorkoutTools(server2, hevyClient2) {
788
1178
  "update-workout",
789
1179
  "Update an existing workout by ID. You can modify the title, description, start/end times, privacy setting, and exercise data. Returns the updated workout with all changes applied.",
790
1180
  {
791
- workoutId: z4.string().min(1),
792
- title: z4.string().min(1),
793
- description: z4.string().optional().nullable(),
794
- startTime: z4.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
795
- endTime: z4.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
796
- isPrivate: z4.boolean().default(false),
797
- exercises: z4.array(
798
- z4.object({
799
- exerciseTemplateId: z4.string().min(1),
800
- supersetId: z4.coerce.number().nullable().optional(),
801
- notes: z4.string().optional().nullable(),
802
- sets: z4.array(
803
- z4.object({
804
- type: z4.enum(["warmup", "normal", "failure", "dropset"]).default("normal"),
805
- weightKg: z4.coerce.number().optional().nullable(),
806
- reps: z4.coerce.number().int().optional().nullable(),
807
- distanceMeters: z4.coerce.number().int().optional().nullable(),
808
- durationSeconds: z4.coerce.number().int().optional().nullable(),
809
- rpe: z4.coerce.number().optional().nullable(),
810
- customMetric: z4.coerce.number().optional().nullable()
1181
+ workoutId: z41.string().min(1),
1182
+ title: z41.string().min(1),
1183
+ description: z41.string().optional().nullable(),
1184
+ startTime: z41.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
1185
+ endTime: z41.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
1186
+ isPrivate: z41.boolean().default(false),
1187
+ exercises: z41.array(
1188
+ z41.object({
1189
+ exerciseTemplateId: z41.string().min(1),
1190
+ supersetId: z41.coerce.number().nullable().optional(),
1191
+ notes: z41.string().optional().nullable(),
1192
+ sets: z41.array(
1193
+ z41.object({
1194
+ type: z41.enum(["warmup", "normal", "failure", "dropset"]).default("normal"),
1195
+ weightKg: z41.coerce.number().optional().nullable(),
1196
+ reps: z41.coerce.number().int().optional().nullable(),
1197
+ distanceMeters: z41.coerce.number().int().optional().nullable(),
1198
+ durationSeconds: z41.coerce.number().int().optional().nullable(),
1199
+ rpe: z41.coerce.number().optional().nullable(),
1200
+ customMetric: z41.coerce.number().optional().nullable()
811
1201
  })
812
1202
  )
813
1203
  })
@@ -846,7 +1236,7 @@ function registerWorkoutTools(server2, hevyClient2) {
846
1236
  }))
847
1237
  }
848
1238
  };
849
- const data = await hevyClient2.v1.workouts.byWorkoutId(workoutId).put(requestBody);
1239
+ const data = await hevyClient2.updateWorkout(workoutId, requestBody);
850
1240
  if (!data) {
851
1241
  return createEmptyResponse(
852
1242
  `Failed to update workout with ID ${workoutId}`
@@ -863,1239 +1253,366 @@ function registerWorkoutTools(server2, hevyClient2) {
863
1253
  );
864
1254
  }
865
1255
 
866
- // src/utils/hevyClient.ts
867
- import {
868
- ApiKeyAuthenticationProvider,
869
- ApiKeyLocation
870
- } from "@microsoft/kiota-abstractions";
871
- import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
872
-
873
- // src/generated/client/models/index.ts
874
- function createDeletedWorkoutFromDiscriminatorValue(parseNode) {
875
- return deserializeIntoDeletedWorkout;
876
- }
877
- function createExerciseTemplateFromDiscriminatorValue(parseNode) {
878
- return deserializeIntoExerciseTemplate;
879
- }
880
- function createPaginatedWorkoutEventsFromDiscriminatorValue(parseNode) {
881
- return deserializeIntoPaginatedWorkoutEvents;
882
- }
883
- function createRoutine_exercises_setsFromDiscriminatorValue(parseNode) {
884
- return deserializeIntoRoutine_exercises_sets;
885
- }
886
- function createRoutine_exercisesFromDiscriminatorValue(parseNode) {
887
- return deserializeIntoRoutine_exercises;
888
- }
889
- function createRoutineFolderFromDiscriminatorValue(parseNode) {
890
- return deserializeIntoRoutineFolder;
891
- }
892
- function createRoutineFromDiscriminatorValue(parseNode) {
893
- return deserializeIntoRoutine;
894
- }
895
- function createUpdatedWorkoutFromDiscriminatorValue(parseNode) {
896
- return deserializeIntoUpdatedWorkout;
897
- }
898
- function createWorkout_exercises_setsFromDiscriminatorValue(parseNode) {
899
- return deserializeIntoWorkout_exercises_sets;
900
- }
901
- function createWorkout_exercisesFromDiscriminatorValue(parseNode) {
902
- return deserializeIntoWorkout_exercises;
903
- }
904
- function createWorkoutFromDiscriminatorValue(parseNode) {
905
- return deserializeIntoWorkout;
906
- }
907
- function deserializeIntoDeletedWorkout(deletedWorkout = {}) {
908
- return {
909
- "deleted_at": (n) => {
910
- deletedWorkout.deletedAt = n.getStringValue();
911
- },
912
- "id": (n) => {
913
- deletedWorkout.id = n.getStringValue();
914
- },
915
- "type": (n) => {
916
- deletedWorkout.type = n.getStringValue();
917
- }
918
- };
919
- }
920
- function deserializeIntoExerciseTemplate(exerciseTemplate = {}) {
921
- return {
922
- "id": (n) => {
923
- exerciseTemplate.id = n.getStringValue();
924
- },
925
- "is_custom": (n) => {
926
- exerciseTemplate.isCustom = n.getBooleanValue();
927
- },
928
- "primary_muscle_group": (n) => {
929
- exerciseTemplate.primaryMuscleGroup = n.getStringValue();
930
- },
931
- "secondary_muscle_groups": (n) => {
932
- exerciseTemplate.secondaryMuscleGroups = n.getCollectionOfPrimitiveValues();
933
- },
934
- "title": (n) => {
935
- exerciseTemplate.title = n.getStringValue();
936
- },
937
- "type": (n) => {
938
- exerciseTemplate.type = n.getStringValue();
939
- }
940
- };
941
- }
942
- function deserializeIntoPaginatedWorkoutEvents(paginatedWorkoutEvents = {}) {
943
- return {
944
- "events": (n) => {
945
- paginatedWorkoutEvents.events = n.getCollectionOfObjectValues(createDeletedWorkoutFromDiscriminatorValue) ?? n.getCollectionOfObjectValues(createUpdatedWorkoutFromDiscriminatorValue);
946
- },
947
- "page": (n) => {
948
- paginatedWorkoutEvents.page = n.getNumberValue();
949
- },
950
- "page_count": (n) => {
951
- paginatedWorkoutEvents.pageCount = n.getNumberValue();
952
- }
953
- };
954
- }
955
- function deserializeIntoRoutine(routine = {}) {
956
- return {
957
- "created_at": (n) => {
958
- routine.createdAt = n.getStringValue();
959
- },
960
- "exercises": (n) => {
961
- routine.exercises = n.getCollectionOfObjectValues(createRoutine_exercisesFromDiscriminatorValue);
962
- },
963
- "folder_id": (n) => {
964
- routine.folderId = n.getNumberValue();
965
- },
966
- "id": (n) => {
967
- routine.id = n.getStringValue();
968
- },
969
- "title": (n) => {
970
- routine.title = n.getStringValue();
971
- },
972
- "updated_at": (n) => {
973
- routine.updatedAt = n.getStringValue();
974
- }
975
- };
976
- }
977
- function deserializeIntoRoutine_exercises(routine_exercises = {}) {
978
- return {
979
- "exercise_template_id": (n) => {
980
- routine_exercises.exerciseTemplateId = n.getStringValue();
981
- },
982
- "index": (n) => {
983
- routine_exercises.index = n.getNumberValue();
984
- },
985
- "notes": (n) => {
986
- routine_exercises.notes = n.getStringValue();
987
- },
988
- "sets": (n) => {
989
- routine_exercises.sets = n.getCollectionOfObjectValues(createRoutine_exercises_setsFromDiscriminatorValue);
990
- },
991
- "supersets_id": (n) => {
992
- routine_exercises.supersetsId = n.getNumberValue();
993
- },
994
- "title": (n) => {
995
- routine_exercises.title = n.getStringValue();
996
- }
997
- };
998
- }
999
- function deserializeIntoRoutine_exercises_sets(routine_exercises_sets = {}) {
1000
- return {
1001
- "custom_metric": (n) => {
1002
- routine_exercises_sets.customMetric = n.getNumberValue();
1003
- },
1004
- "distance_meters": (n) => {
1005
- routine_exercises_sets.distanceMeters = n.getNumberValue();
1006
- },
1007
- "duration_seconds": (n) => {
1008
- routine_exercises_sets.durationSeconds = n.getNumberValue();
1009
- },
1010
- "index": (n) => {
1011
- routine_exercises_sets.index = n.getNumberValue();
1012
- },
1013
- "reps": (n) => {
1014
- routine_exercises_sets.reps = n.getNumberValue();
1015
- },
1016
- "rpe": (n) => {
1017
- routine_exercises_sets.rpe = n.getNumberValue();
1018
- },
1019
- "type": (n) => {
1020
- routine_exercises_sets.type = n.getStringValue();
1021
- },
1022
- "weight_kg": (n) => {
1023
- routine_exercises_sets.weightKg = n.getNumberValue();
1024
- }
1025
- };
1026
- }
1027
- function deserializeIntoRoutineFolder(routineFolder = {}) {
1028
- return {
1029
- "created_at": (n) => {
1030
- routineFolder.createdAt = n.getStringValue();
1031
- },
1032
- "id": (n) => {
1033
- routineFolder.id = n.getNumberValue();
1034
- },
1035
- "index": (n) => {
1036
- routineFolder.index = n.getNumberValue();
1037
- },
1038
- "title": (n) => {
1039
- routineFolder.title = n.getStringValue();
1040
- },
1041
- "updated_at": (n) => {
1042
- routineFolder.updatedAt = n.getStringValue();
1043
- }
1044
- };
1045
- }
1046
- function deserializeIntoUpdatedWorkout(updatedWorkout = {}) {
1047
- return {
1048
- "type": (n) => {
1049
- updatedWorkout.type = n.getStringValue();
1050
- },
1051
- "workout": (n) => {
1052
- updatedWorkout.workout = n.getObjectValue(createWorkoutFromDiscriminatorValue);
1053
- }
1054
- };
1055
- }
1056
- function deserializeIntoWorkout(workout = {}) {
1057
- return {
1058
- "created_at": (n) => {
1059
- workout.createdAt = n.getStringValue();
1060
- },
1061
- "description": (n) => {
1062
- workout.description = n.getStringValue();
1063
- },
1064
- "end_time": (n) => {
1065
- workout.endTime = n.getNumberValue();
1066
- },
1067
- "exercises": (n) => {
1068
- workout.exercises = n.getCollectionOfObjectValues(createWorkout_exercisesFromDiscriminatorValue);
1069
- },
1070
- "id": (n) => {
1071
- workout.id = n.getStringValue();
1072
- },
1073
- "start_time": (n) => {
1074
- workout.startTime = n.getNumberValue();
1075
- },
1076
- "title": (n) => {
1077
- workout.title = n.getStringValue();
1078
- },
1079
- "updated_at": (n) => {
1080
- workout.updatedAt = n.getStringValue();
1081
- }
1082
- };
1083
- }
1084
- function deserializeIntoWorkout_exercises(workout_exercises = {}) {
1085
- return {
1086
- "exercise_template_id": (n) => {
1087
- workout_exercises.exerciseTemplateId = n.getStringValue();
1088
- },
1089
- "index": (n) => {
1090
- workout_exercises.index = n.getNumberValue();
1091
- },
1092
- "notes": (n) => {
1093
- workout_exercises.notes = n.getStringValue();
1094
- },
1095
- "sets": (n) => {
1096
- workout_exercises.sets = n.getCollectionOfObjectValues(createWorkout_exercises_setsFromDiscriminatorValue);
1097
- },
1098
- "supersets_id": (n) => {
1099
- workout_exercises.supersetsId = n.getNumberValue();
1100
- },
1101
- "title": (n) => {
1102
- workout_exercises.title = n.getStringValue();
1103
- }
1104
- };
1105
- }
1106
- function deserializeIntoWorkout_exercises_sets(workout_exercises_sets = {}) {
1107
- return {
1108
- "custom_metric": (n) => {
1109
- workout_exercises_sets.customMetric = n.getNumberValue();
1110
- },
1111
- "distance_meters": (n) => {
1112
- workout_exercises_sets.distanceMeters = n.getNumberValue();
1113
- },
1114
- "duration_seconds": (n) => {
1115
- workout_exercises_sets.durationSeconds = n.getNumberValue();
1116
- },
1117
- "index": (n) => {
1118
- workout_exercises_sets.index = n.getNumberValue();
1119
- },
1120
- "reps": (n) => {
1121
- workout_exercises_sets.reps = n.getNumberValue();
1122
- },
1123
- "rpe": (n) => {
1124
- workout_exercises_sets.rpe = n.getNumberValue();
1125
- },
1126
- "type": (n) => {
1127
- workout_exercises_sets.type = n.getStringValue();
1128
- },
1129
- "weight_kg": (n) => {
1130
- workout_exercises_sets.weightKg = n.getNumberValue();
1131
- }
1132
- };
1133
- }
1134
- function serializePostRoutineFolderRequestBody(writer, postRoutineFolderRequestBody = {}) {
1135
- if (postRoutineFolderRequestBody) {
1136
- writer.writeObjectValue("routine_folder", postRoutineFolderRequestBody.routineFolder, serializePostRoutineFolderRequestBody_routine_folder);
1137
- writer.writeAdditionalData(postRoutineFolderRequestBody.additionalData);
1138
- }
1139
- }
1140
- function serializePostRoutineFolderRequestBody_routine_folder(writer, postRoutineFolderRequestBody_routine_folder = {}) {
1141
- if (postRoutineFolderRequestBody_routine_folder) {
1142
- writer.writeStringValue("title", postRoutineFolderRequestBody_routine_folder.title);
1143
- writer.writeAdditionalData(postRoutineFolderRequestBody_routine_folder.additionalData);
1144
- }
1145
- }
1146
- function serializePostRoutinesRequestBody(writer, postRoutinesRequestBody = {}) {
1147
- if (postRoutinesRequestBody) {
1148
- writer.writeObjectValue("routine", postRoutinesRequestBody.routine, serializePostRoutinesRequestBody_routine);
1149
- writer.writeAdditionalData(postRoutinesRequestBody.additionalData);
1150
- }
1151
- }
1152
- function serializePostRoutinesRequestBody_routine(writer, postRoutinesRequestBody_routine = {}) {
1153
- if (postRoutinesRequestBody_routine) {
1154
- writer.writeCollectionOfObjectValues("exercises", postRoutinesRequestBody_routine.exercises, serializePostRoutinesRequestExercise);
1155
- writer.writeNumberValue("folder_id", postRoutinesRequestBody_routine.folderId);
1156
- writer.writeStringValue("notes", postRoutinesRequestBody_routine.notes);
1157
- writer.writeStringValue("title", postRoutinesRequestBody_routine.title);
1158
- writer.writeAdditionalData(postRoutinesRequestBody_routine.additionalData);
1159
- }
1160
- }
1161
- function serializePostRoutinesRequestExercise(writer, postRoutinesRequestExercise = {}) {
1162
- if (postRoutinesRequestExercise) {
1163
- writer.writeStringValue("exercise_template_id", postRoutinesRequestExercise.exerciseTemplateId);
1164
- writer.writeStringValue("notes", postRoutinesRequestExercise.notes);
1165
- writer.writeNumberValue("rest_seconds", postRoutinesRequestExercise.restSeconds);
1166
- writer.writeCollectionOfObjectValues("sets", postRoutinesRequestExercise.sets, serializePostRoutinesRequestSet);
1167
- writer.writeNumberValue("superset_id", postRoutinesRequestExercise.supersetId);
1168
- writer.writeAdditionalData(postRoutinesRequestExercise.additionalData);
1169
- }
1170
- }
1171
- function serializePostRoutinesRequestSet(writer, postRoutinesRequestSet = {}) {
1172
- if (postRoutinesRequestSet) {
1173
- writer.writeNumberValue("custom_metric", postRoutinesRequestSet.customMetric);
1174
- writer.writeNumberValue("distance_meters", postRoutinesRequestSet.distanceMeters);
1175
- writer.writeNumberValue("duration_seconds", postRoutinesRequestSet.durationSeconds);
1176
- writer.writeNumberValue("reps", postRoutinesRequestSet.reps);
1177
- writer.writeEnumValue("type", postRoutinesRequestSet.type);
1178
- writer.writeNumberValue("weight_kg", postRoutinesRequestSet.weightKg);
1179
- writer.writeAdditionalData(postRoutinesRequestSet.additionalData);
1180
- }
1181
- }
1182
- function serializePostWorkoutsRequestBody(writer, postWorkoutsRequestBody = {}) {
1183
- if (postWorkoutsRequestBody) {
1184
- writer.writeObjectValue("workout", postWorkoutsRequestBody.workout, serializePostWorkoutsRequestBody_workout);
1185
- writer.writeAdditionalData(postWorkoutsRequestBody.additionalData);
1186
- }
1187
- }
1188
- function serializePostWorkoutsRequestBody_workout(writer, postWorkoutsRequestBody_workout = {}) {
1189
- if (postWorkoutsRequestBody_workout) {
1190
- writer.writeStringValue("description", postWorkoutsRequestBody_workout.description);
1191
- writer.writeStringValue("end_time", postWorkoutsRequestBody_workout.endTime);
1192
- writer.writeCollectionOfObjectValues("exercises", postWorkoutsRequestBody_workout.exercises, serializePostWorkoutsRequestExercise);
1193
- writer.writeBooleanValue("is_private", postWorkoutsRequestBody_workout.isPrivate);
1194
- writer.writeStringValue("start_time", postWorkoutsRequestBody_workout.startTime);
1195
- writer.writeStringValue("title", postWorkoutsRequestBody_workout.title);
1196
- writer.writeAdditionalData(postWorkoutsRequestBody_workout.additionalData);
1197
- }
1198
- }
1199
- function serializePostWorkoutsRequestExercise(writer, postWorkoutsRequestExercise = {}) {
1200
- if (postWorkoutsRequestExercise) {
1201
- writer.writeStringValue("exercise_template_id", postWorkoutsRequestExercise.exerciseTemplateId);
1202
- writer.writeStringValue("notes", postWorkoutsRequestExercise.notes);
1203
- writer.writeCollectionOfObjectValues("sets", postWorkoutsRequestExercise.sets, serializePostWorkoutsRequestSet);
1204
- writer.writeNumberValue("superset_id", postWorkoutsRequestExercise.supersetId);
1205
- writer.writeAdditionalData(postWorkoutsRequestExercise.additionalData);
1206
- }
1207
- }
1208
- function serializePostWorkoutsRequestSet(writer, postWorkoutsRequestSet = {}) {
1209
- if (postWorkoutsRequestSet) {
1210
- writer.writeNumberValue("custom_metric", postWorkoutsRequestSet.customMetric);
1211
- writer.writeNumberValue("distance_meters", postWorkoutsRequestSet.distanceMeters);
1212
- writer.writeNumberValue("duration_seconds", postWorkoutsRequestSet.durationSeconds);
1213
- writer.writeNumberValue("reps", postWorkoutsRequestSet.reps);
1214
- writer.writeNumberValue("rpe", postWorkoutsRequestSet.rpe);
1215
- writer.writeEnumValue("type", postWorkoutsRequestSet.type);
1216
- writer.writeNumberValue("weight_kg", postWorkoutsRequestSet.weightKg);
1217
- writer.writeAdditionalData(postWorkoutsRequestSet.additionalData);
1218
- }
1219
- }
1220
- function serializePutRoutinesRequestBody(writer, putRoutinesRequestBody = {}) {
1221
- if (putRoutinesRequestBody) {
1222
- writer.writeObjectValue("routine", putRoutinesRequestBody.routine, serializePutRoutinesRequestBody_routine);
1223
- writer.writeAdditionalData(putRoutinesRequestBody.additionalData);
1224
- }
1225
- }
1226
- function serializePutRoutinesRequestBody_routine(writer, putRoutinesRequestBody_routine = {}) {
1227
- if (putRoutinesRequestBody_routine) {
1228
- writer.writeCollectionOfObjectValues("exercises", putRoutinesRequestBody_routine.exercises, serializePutRoutinesRequestExercise);
1229
- writer.writeStringValue("notes", putRoutinesRequestBody_routine.notes);
1230
- writer.writeStringValue("title", putRoutinesRequestBody_routine.title);
1231
- writer.writeAdditionalData(putRoutinesRequestBody_routine.additionalData);
1232
- }
1233
- }
1234
- function serializePutRoutinesRequestExercise(writer, putRoutinesRequestExercise = {}) {
1235
- if (putRoutinesRequestExercise) {
1236
- writer.writeStringValue("exercise_template_id", putRoutinesRequestExercise.exerciseTemplateId);
1237
- writer.writeStringValue("notes", putRoutinesRequestExercise.notes);
1238
- writer.writeNumberValue("rest_seconds", putRoutinesRequestExercise.restSeconds);
1239
- writer.writeCollectionOfObjectValues("sets", putRoutinesRequestExercise.sets, serializePutRoutinesRequestSet);
1240
- writer.writeNumberValue("superset_id", putRoutinesRequestExercise.supersetId);
1241
- writer.writeAdditionalData(putRoutinesRequestExercise.additionalData);
1242
- }
1243
- }
1244
- function serializePutRoutinesRequestSet(writer, putRoutinesRequestSet = {}) {
1245
- if (putRoutinesRequestSet) {
1246
- writer.writeNumberValue("custom_metric", putRoutinesRequestSet.customMetric);
1247
- writer.writeNumberValue("distance_meters", putRoutinesRequestSet.distanceMeters);
1248
- writer.writeNumberValue("duration_seconds", putRoutinesRequestSet.durationSeconds);
1249
- writer.writeNumberValue("reps", putRoutinesRequestSet.reps);
1250
- writer.writeEnumValue("type", putRoutinesRequestSet.type);
1251
- writer.writeNumberValue("weight_kg", putRoutinesRequestSet.weightKg);
1252
- writer.writeAdditionalData(putRoutinesRequestSet.additionalData);
1253
- }
1254
- }
1256
+ // src/utils/hevyClientKubb.ts
1257
+ import axios from "axios";
1255
1258
 
1256
- // src/generated/client/v1/exercise_templates/item/index.ts
1257
- var WithExerciseTemplateItemRequestBuilderUriTemplate = "{+baseurl}/v1/exercise_templates/{exerciseTemplateId}";
1258
- var WithExerciseTemplateItemRequestBuilderRequestsMetadata = {
1259
- get: {
1260
- uriTemplate: WithExerciseTemplateItemRequestBuilderUriTemplate,
1261
- responseBodyContentType: "application/json",
1262
- adapterMethodName: "send",
1263
- responseBodyFactory: createExerciseTemplateFromDiscriminatorValue
1264
- }
1265
- };
1266
-
1267
- // src/generated/client/v1/exercise_templates/index.ts
1268
- function createExercise_templatesGetResponseFromDiscriminatorValue(parseNode) {
1269
- return deserializeIntoExercise_templatesGetResponse;
1270
- }
1271
- function deserializeIntoExercise_templatesGetResponse(exercise_templatesGetResponse = {}) {
1272
- return {
1273
- "exercise_templates": (n) => {
1274
- exercise_templatesGetResponse.exerciseTemplates = n.getCollectionOfObjectValues(createExerciseTemplateFromDiscriminatorValue);
1275
- },
1276
- "page": (n) => {
1277
- exercise_templatesGetResponse.page = n.getNumberValue();
1278
- },
1279
- "page_count": (n) => {
1280
- exercise_templatesGetResponse.pageCount = n.getNumberValue();
1281
- }
1282
- };
1259
+ // src/generated/client/api/deleteV1WebhookSubscription.ts
1260
+ import fetch from "@kubb/plugin-client/clients/axios";
1261
+ function getDeleteV1WebhookSubscriptionUrl() {
1262
+ return `/v1/webhook-subscription`;
1263
+ }
1264
+ async function deleteV1WebhookSubscription(headers, config = {}) {
1265
+ const { client: request = fetch, ...requestConfig } = config;
1266
+ const res = await request({
1267
+ method: "DELETE",
1268
+ url: getDeleteV1WebhookSubscriptionUrl().toString(),
1269
+ ...requestConfig,
1270
+ headers: { ...headers, ...requestConfig.headers }
1271
+ });
1272
+ return res.data;
1283
1273
  }
1284
- var Exercise_templatesRequestBuilderUriTemplate = "{+baseurl}/v1/exercise_templates{?page*,pageSize*}";
1285
- var Exercise_templatesRequestBuilderNavigationMetadata = {
1286
- byExerciseTemplateId: {
1287
- requestsMetadata: WithExerciseTemplateItemRequestBuilderRequestsMetadata,
1288
- pathParametersMappings: ["exerciseTemplateId"]
1289
- }
1290
- };
1291
- var Exercise_templatesRequestBuilderRequestsMetadata = {
1292
- get: {
1293
- uriTemplate: Exercise_templatesRequestBuilderUriTemplate,
1294
- responseBodyContentType: "application/json",
1295
- adapterMethodName: "send",
1296
- responseBodyFactory: createExercise_templatesGetResponseFromDiscriminatorValue
1297
- }
1298
- };
1299
-
1300
- // src/generated/client/v1/routine_folders/item/index.ts
1301
- var WithFolderItemRequestBuilderUriTemplate = "{+baseurl}/v1/routine_folders/{folderId}";
1302
- var WithFolderItemRequestBuilderRequestsMetadata = {
1303
- get: {
1304
- uriTemplate: WithFolderItemRequestBuilderUriTemplate,
1305
- responseBodyContentType: "application/json",
1306
- adapterMethodName: "send",
1307
- responseBodyFactory: createRoutineFolderFromDiscriminatorValue
1308
- }
1309
- };
1310
1274
 
1311
- // src/generated/client/v1/routine_folders/index.ts
1312
- function createRoutine_foldersGetResponseFromDiscriminatorValue(parseNode) {
1313
- return deserializeIntoRoutine_foldersGetResponse;
1275
+ // src/generated/client/api/getV1ExerciseTemplates.ts
1276
+ import fetch2 from "@kubb/plugin-client/clients/axios";
1277
+ function getGetV1ExerciseTemplatesUrl() {
1278
+ return `/v1/exercise_templates`;
1279
+ }
1280
+ async function getV1ExerciseTemplates(headers, params, config = {}) {
1281
+ const { client: request = fetch2, ...requestConfig } = config;
1282
+ const res = await request({
1283
+ method: "GET",
1284
+ url: getGetV1ExerciseTemplatesUrl().toString(),
1285
+ params,
1286
+ ...requestConfig,
1287
+ headers: { ...headers, ...requestConfig.headers }
1288
+ });
1289
+ return res.data;
1314
1290
  }
1315
- function createRoutineFolder400ErrorFromDiscriminatorValue(parseNode) {
1316
- return deserializeIntoRoutineFolder400Error;
1317
- }
1318
- function deserializeIntoRoutine_foldersGetResponse(routine_foldersGetResponse = {}) {
1319
- return {
1320
- "page": (n) => {
1321
- routine_foldersGetResponse.page = n.getNumberValue();
1322
- },
1323
- "page_count": (n) => {
1324
- routine_foldersGetResponse.pageCount = n.getNumberValue();
1325
- },
1326
- "routine_folders": (n) => {
1327
- routine_foldersGetResponse.routineFolders = n.getCollectionOfObjectValues(createRoutineFolderFromDiscriminatorValue);
1328
- }
1329
- };
1330
- }
1331
- function deserializeIntoRoutineFolder400Error(routineFolder400Error = {}) {
1332
- return {
1333
- "error": (n) => {
1334
- routineFolder400Error.errorEscaped = n.getStringValue();
1335
- }
1336
- };
1337
- }
1338
- var Routine_foldersRequestBuilderUriTemplate = "{+baseurl}/v1/routine_folders{?page*,pageSize*}";
1339
- var Routine_foldersRequestBuilderNavigationMetadata = {
1340
- byFolderId: {
1341
- requestsMetadata: WithFolderItemRequestBuilderRequestsMetadata,
1342
- pathParametersMappings: ["folderId"]
1343
- }
1344
- };
1345
- var Routine_foldersRequestBuilderRequestsMetadata = {
1346
- get: {
1347
- uriTemplate: Routine_foldersRequestBuilderUriTemplate,
1348
- responseBodyContentType: "application/json",
1349
- adapterMethodName: "send",
1350
- responseBodyFactory: createRoutine_foldersGetResponseFromDiscriminatorValue
1351
- },
1352
- post: {
1353
- uriTemplate: Routine_foldersRequestBuilderUriTemplate,
1354
- responseBodyContentType: "application/json",
1355
- errorMappings: {
1356
- 400: createRoutineFolder400ErrorFromDiscriminatorValue
1357
- },
1358
- adapterMethodName: "send",
1359
- responseBodyFactory: createRoutineFolderFromDiscriminatorValue,
1360
- requestBodyContentType: "application/json",
1361
- requestBodySerializer: serializePostRoutineFolderRequestBody,
1362
- requestInformationContentSetMethod: "setContentFromParsable"
1363
- }
1364
- };
1365
1291
 
1366
- // src/generated/client/v1/routines/item/index.ts
1367
- function createRoutine400ErrorFromDiscriminatorValue(parseNode) {
1368
- return deserializeIntoRoutine400Error;
1292
+ // src/generated/client/api/getV1ExerciseTemplatesExercisetemplateid.ts
1293
+ import fetch3 from "@kubb/plugin-client/clients/axios";
1294
+ function getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId) {
1295
+ return `/v1/exercise_templates/${exerciseTemplateId}`;
1296
+ }
1297
+ async function getV1ExerciseTemplatesExercisetemplateid(exerciseTemplateId, headers, config = {}) {
1298
+ const { client: request = fetch3, ...requestConfig } = config;
1299
+ const res = await request({
1300
+ method: "GET",
1301
+ url: getGetV1ExerciseTemplatesExercisetemplateidUrl(exerciseTemplateId).toString(),
1302
+ ...requestConfig,
1303
+ headers: { ...headers, ...requestConfig.headers }
1304
+ });
1305
+ return res.data;
1369
1306
  }
1370
- function createRoutine404ErrorFromDiscriminatorValue(parseNode) {
1371
- return deserializeIntoRoutine404Error;
1307
+
1308
+ // src/generated/client/api/getV1RoutineFolders.ts
1309
+ import fetch4 from "@kubb/plugin-client/clients/axios";
1310
+ function getGetV1RoutineFoldersUrl() {
1311
+ return `/v1/routine_folders`;
1312
+ }
1313
+ async function getV1RoutineFolders(headers, params, config = {}) {
1314
+ const { client: request = fetch4, ...requestConfig } = config;
1315
+ const res = await request({
1316
+ method: "GET",
1317
+ url: getGetV1RoutineFoldersUrl().toString(),
1318
+ params,
1319
+ ...requestConfig,
1320
+ headers: { ...headers, ...requestConfig.headers }
1321
+ });
1322
+ return res.data;
1372
1323
  }
1373
- function deserializeIntoRoutine400Error(routine400Error = {}) {
1374
- return {
1375
- "error": (n) => {
1376
- routine400Error.errorEscaped = n.getStringValue();
1377
- }
1378
- };
1324
+
1325
+ // src/generated/client/api/getV1RoutineFoldersFolderid.ts
1326
+ import fetch5 from "@kubb/plugin-client/clients/axios";
1327
+ function getGetV1RoutineFoldersFolderidUrl(folderId) {
1328
+ return `/v1/routine_folders/${folderId}`;
1329
+ }
1330
+ async function getV1RoutineFoldersFolderid(folderId, headers, config = {}) {
1331
+ const { client: request = fetch5, ...requestConfig } = config;
1332
+ const res = await request({
1333
+ method: "GET",
1334
+ url: getGetV1RoutineFoldersFolderidUrl(folderId).toString(),
1335
+ ...requestConfig,
1336
+ headers: { ...headers, ...requestConfig.headers }
1337
+ });
1338
+ return res.data;
1379
1339
  }
1380
- function deserializeIntoRoutine404Error(routine404Error = {}) {
1381
- return {
1382
- "error": (n) => {
1383
- routine404Error.errorEscaped = n.getStringValue();
1384
- }
1385
- };
1340
+
1341
+ // src/generated/client/api/getV1Routines.ts
1342
+ import fetch6 from "@kubb/plugin-client/clients/axios";
1343
+ function getGetV1RoutinesUrl() {
1344
+ return `/v1/routines`;
1345
+ }
1346
+ async function getV1Routines(headers, params, config = {}) {
1347
+ const { client: request = fetch6, ...requestConfig } = config;
1348
+ const res = await request({
1349
+ method: "GET",
1350
+ url: getGetV1RoutinesUrl().toString(),
1351
+ params,
1352
+ ...requestConfig,
1353
+ headers: { ...headers, ...requestConfig.headers }
1354
+ });
1355
+ return res.data;
1386
1356
  }
1387
- var WithRoutineItemRequestBuilderUriTemplate = "{+baseurl}/v1/routines/{routineId}";
1388
- var WithRoutineItemRequestBuilderRequestsMetadata = {
1389
- put: {
1390
- uriTemplate: WithRoutineItemRequestBuilderUriTemplate,
1391
- responseBodyContentType: "application/json",
1392
- errorMappings: {
1393
- 400: createRoutine400ErrorFromDiscriminatorValue,
1394
- 404: createRoutine404ErrorFromDiscriminatorValue
1395
- },
1396
- adapterMethodName: "send",
1397
- responseBodyFactory: createRoutineFromDiscriminatorValue,
1398
- requestBodyContentType: "application/json",
1399
- requestBodySerializer: serializePutRoutinesRequestBody,
1400
- requestInformationContentSetMethod: "setContentFromParsable"
1401
- }
1402
- };
1403
1357
 
1404
- // src/generated/client/v1/routines/index.ts
1405
- function createRoutine400ErrorFromDiscriminatorValue2(parseNode) {
1406
- return deserializeIntoRoutine400Error2;
1358
+ // src/generated/client/api/getV1RoutinesRoutineid.ts
1359
+ import fetch7 from "@kubb/plugin-client/clients/axios";
1360
+ function getGetV1RoutinesRoutineidUrl(routineId) {
1361
+ return `/v1/routines/${routineId}`;
1362
+ }
1363
+ async function getV1RoutinesRoutineid(routineId, headers, config = {}) {
1364
+ const { client: request = fetch7, ...requestConfig } = config;
1365
+ const res = await request({
1366
+ method: "GET",
1367
+ url: getGetV1RoutinesRoutineidUrl(routineId).toString(),
1368
+ ...requestConfig,
1369
+ headers: { ...headers, ...requestConfig.headers }
1370
+ });
1371
+ return res.data;
1407
1372
  }
1408
- function createRoutine403ErrorFromDiscriminatorValue(parseNode) {
1409
- return deserializeIntoRoutine403Error;
1373
+
1374
+ // src/generated/client/api/getV1WebhookSubscription.ts
1375
+ import fetch8 from "@kubb/plugin-client/clients/axios";
1376
+ function getGetV1WebhookSubscriptionUrl() {
1377
+ return `/v1/webhook-subscription`;
1378
+ }
1379
+ async function getV1WebhookSubscription(headers, config = {}) {
1380
+ const { client: request = fetch8, ...requestConfig } = config;
1381
+ const res = await request({
1382
+ method: "GET",
1383
+ url: getGetV1WebhookSubscriptionUrl().toString(),
1384
+ ...requestConfig,
1385
+ headers: { ...headers, ...requestConfig.headers }
1386
+ });
1387
+ return res.data;
1410
1388
  }
1411
- function createRoutinesGetResponseFromDiscriminatorValue(parseNode) {
1412
- return deserializeIntoRoutinesGetResponse;
1389
+
1390
+ // src/generated/client/api/getV1Workouts.ts
1391
+ import fetch9 from "@kubb/plugin-client/clients/axios";
1392
+ function getGetV1WorkoutsUrl() {
1393
+ return `/v1/workouts`;
1394
+ }
1395
+ async function getV1Workouts(headers, params, config = {}) {
1396
+ const { client: request = fetch9, ...requestConfig } = config;
1397
+ const res = await request({
1398
+ method: "GET",
1399
+ url: getGetV1WorkoutsUrl().toString(),
1400
+ params,
1401
+ ...requestConfig,
1402
+ headers: { ...headers, ...requestConfig.headers }
1403
+ });
1404
+ return res.data;
1413
1405
  }
1414
- function deserializeIntoRoutine400Error2(routine400Error = {}) {
1415
- return {
1416
- "error": (n) => {
1417
- routine400Error.errorEscaped = n.getStringValue();
1418
- }
1419
- };
1406
+
1407
+ // src/generated/client/api/getV1WorkoutsCount.ts
1408
+ import fetch10 from "@kubb/plugin-client/clients/axios";
1409
+ function getGetV1WorkoutsCountUrl() {
1410
+ return `/v1/workouts/count`;
1411
+ }
1412
+ async function getV1WorkoutsCount(headers, config = {}) {
1413
+ const { client: request = fetch10, ...requestConfig } = config;
1414
+ const res = await request({
1415
+ method: "GET",
1416
+ url: getGetV1WorkoutsCountUrl().toString(),
1417
+ ...requestConfig,
1418
+ headers: { ...headers, ...requestConfig.headers }
1419
+ });
1420
+ return res.data;
1420
1421
  }
1421
- function deserializeIntoRoutine403Error(routine403Error = {}) {
1422
- return {
1423
- "error": (n) => {
1424
- routine403Error.errorEscaped = n.getStringValue();
1425
- }
1426
- };
1422
+
1423
+ // src/generated/client/api/getV1WorkoutsEvents.ts
1424
+ import fetch11 from "@kubb/plugin-client/clients/axios";
1425
+ function getGetV1WorkoutsEventsUrl() {
1426
+ return `/v1/workouts/events`;
1427
+ }
1428
+ async function getV1WorkoutsEvents(headers, params, config = {}) {
1429
+ const { client: request = fetch11, ...requestConfig } = config;
1430
+ const res = await request({
1431
+ method: "GET",
1432
+ url: getGetV1WorkoutsEventsUrl().toString(),
1433
+ params,
1434
+ ...requestConfig,
1435
+ headers: { ...headers, ...requestConfig.headers }
1436
+ });
1437
+ return res.data;
1427
1438
  }
1428
- function deserializeIntoRoutinesGetResponse(routinesGetResponse = {}) {
1429
- return {
1430
- "page": (n) => {
1431
- routinesGetResponse.page = n.getNumberValue();
1432
- },
1433
- "page_count": (n) => {
1434
- routinesGetResponse.pageCount = n.getNumberValue();
1435
- },
1436
- "routines": (n) => {
1437
- routinesGetResponse.routines = n.getCollectionOfObjectValues(createRoutineFromDiscriminatorValue);
1438
- }
1439
- };
1439
+
1440
+ // src/generated/client/api/getV1WorkoutsWorkoutid.ts
1441
+ import fetch12 from "@kubb/plugin-client/clients/axios";
1442
+ function getGetV1WorkoutsWorkoutidUrl(workoutId) {
1443
+ return `/v1/workouts/${workoutId}`;
1444
+ }
1445
+ async function getV1WorkoutsWorkoutid(workoutId, headers, config = {}) {
1446
+ const { client: request = fetch12, ...requestConfig } = config;
1447
+ const res = await request({
1448
+ method: "GET",
1449
+ url: getGetV1WorkoutsWorkoutidUrl(workoutId).toString(),
1450
+ ...requestConfig,
1451
+ headers: { ...headers, ...requestConfig.headers }
1452
+ });
1453
+ return res.data;
1440
1454
  }
1441
- var RoutinesRequestBuilderUriTemplate = "{+baseurl}/v1/routines{?page*,pageSize*}";
1442
- var RoutinesRequestBuilderNavigationMetadata = {
1443
- byRoutineId: {
1444
- requestsMetadata: WithRoutineItemRequestBuilderRequestsMetadata,
1445
- pathParametersMappings: ["routineId"]
1446
- }
1447
- };
1448
- var RoutinesRequestBuilderRequestsMetadata = {
1449
- get: {
1450
- uriTemplate: RoutinesRequestBuilderUriTemplate,
1451
- responseBodyContentType: "application/json",
1452
- adapterMethodName: "send",
1453
- responseBodyFactory: createRoutinesGetResponseFromDiscriminatorValue
1454
- },
1455
- post: {
1456
- uriTemplate: RoutinesRequestBuilderUriTemplate,
1457
- responseBodyContentType: "application/json",
1458
- errorMappings: {
1459
- 400: createRoutine400ErrorFromDiscriminatorValue2,
1460
- 403: createRoutine403ErrorFromDiscriminatorValue
1461
- },
1462
- adapterMethodName: "send",
1463
- responseBodyFactory: createRoutineFromDiscriminatorValue,
1464
- requestBodyContentType: "application/json",
1465
- requestBodySerializer: serializePostRoutinesRequestBody,
1466
- requestInformationContentSetMethod: "setContentFromParsable"
1467
- }
1468
- };
1469
1455
 
1470
- // src/generated/client/v1/workouts/count/index.ts
1471
- function createCountGetResponseFromDiscriminatorValue(parseNode) {
1472
- return deserializeIntoCountGetResponse;
1456
+ // src/generated/client/api/postV1RoutineFolders.ts
1457
+ import fetch13 from "@kubb/plugin-client/clients/axios";
1458
+ function getPostV1RoutineFoldersUrl() {
1459
+ return `/v1/routine_folders`;
1460
+ }
1461
+ async function postV1RoutineFolders(headers, data, config = {}) {
1462
+ const { client: request = fetch13, ...requestConfig } = config;
1463
+ const requestData = data;
1464
+ const res = await request({
1465
+ method: "POST",
1466
+ url: getPostV1RoutineFoldersUrl().toString(),
1467
+ data: requestData,
1468
+ ...requestConfig,
1469
+ headers: { ...headers, ...requestConfig.headers }
1470
+ });
1471
+ return res.data;
1473
1472
  }
1474
- function deserializeIntoCountGetResponse(countGetResponse = {}) {
1475
- return {
1476
- "workout_count": (n) => {
1477
- countGetResponse.workoutCount = n.getNumberValue();
1478
- }
1479
- };
1473
+
1474
+ // src/generated/client/api/postV1Routines.ts
1475
+ import fetch14 from "@kubb/plugin-client/clients/axios";
1476
+ function getPostV1RoutinesUrl() {
1477
+ return `/v1/routines`;
1478
+ }
1479
+ async function postV1Routines(headers, data, config = {}) {
1480
+ const { client: request = fetch14, ...requestConfig } = config;
1481
+ const requestData = data;
1482
+ const res = await request({
1483
+ method: "POST",
1484
+ url: getPostV1RoutinesUrl().toString(),
1485
+ data: requestData,
1486
+ ...requestConfig,
1487
+ headers: { ...headers, ...requestConfig.headers }
1488
+ });
1489
+ return res.data;
1480
1490
  }
1481
- var CountRequestBuilderUriTemplate = "{+baseurl}/v1/workouts/count";
1482
- var CountRequestBuilderRequestsMetadata = {
1483
- get: {
1484
- uriTemplate: CountRequestBuilderUriTemplate,
1485
- responseBodyContentType: "application/json",
1486
- adapterMethodName: "send",
1487
- responseBodyFactory: createCountGetResponseFromDiscriminatorValue
1488
- }
1489
- };
1490
-
1491
- // src/generated/client/v1/workouts/events/index.ts
1492
- var EventsRequestBuilderUriTemplate = "{+baseurl}/v1/workouts/events{?page*,pageSize*,since*}";
1493
- var EventsRequestBuilderRequestsMetadata = {
1494
- get: {
1495
- uriTemplate: EventsRequestBuilderUriTemplate,
1496
- responseBodyContentType: "application/json",
1497
- adapterMethodName: "send",
1498
- responseBodyFactory: createPaginatedWorkoutEventsFromDiscriminatorValue
1499
- }
1500
- };
1501
1491
 
1502
- // src/generated/client/v1/workouts/item/index.ts
1503
- function createWorkout400ErrorFromDiscriminatorValue(parseNode) {
1504
- return deserializeIntoWorkout400Error;
1492
+ // src/generated/client/api/postV1WebhookSubscription.ts
1493
+ import fetch15 from "@kubb/plugin-client/clients/axios";
1494
+ function getPostV1WebhookSubscriptionUrl() {
1495
+ return `/v1/webhook-subscription`;
1496
+ }
1497
+ async function postV1WebhookSubscription(headers, data, config = {}) {
1498
+ const { client: request = fetch15, ...requestConfig } = config;
1499
+ const requestData = data;
1500
+ const res = await request({
1501
+ method: "POST",
1502
+ url: getPostV1WebhookSubscriptionUrl().toString(),
1503
+ data: requestData,
1504
+ ...requestConfig,
1505
+ headers: { ...headers, ...requestConfig.headers }
1506
+ });
1507
+ return res.data;
1505
1508
  }
1506
- function deserializeIntoWorkout400Error(workout400Error = {}) {
1507
- return {
1508
- "error": (n) => {
1509
- workout400Error.errorEscaped = n.getStringValue();
1510
- }
1511
- };
1509
+
1510
+ // src/generated/client/api/postV1Workouts.ts
1511
+ import fetch16 from "@kubb/plugin-client/clients/axios";
1512
+ function getPostV1WorkoutsUrl() {
1513
+ return `/v1/workouts`;
1514
+ }
1515
+ async function postV1Workouts(headers, data, config = {}) {
1516
+ const { client: request = fetch16, ...requestConfig } = config;
1517
+ const requestData = data;
1518
+ const res = await request({
1519
+ method: "POST",
1520
+ url: getPostV1WorkoutsUrl().toString(),
1521
+ data: requestData,
1522
+ ...requestConfig,
1523
+ headers: { ...headers, ...requestConfig.headers }
1524
+ });
1525
+ return res.data;
1512
1526
  }
1513
- var WithWorkoutItemRequestBuilderUriTemplate = "{+baseurl}/v1/workouts/{workoutId}";
1514
- var WithWorkoutItemRequestBuilderRequestsMetadata = {
1515
- get: {
1516
- uriTemplate: WithWorkoutItemRequestBuilderUriTemplate,
1517
- responseBodyContentType: "application/json",
1518
- adapterMethodName: "send",
1519
- responseBodyFactory: createWorkoutFromDiscriminatorValue
1520
- },
1521
- put: {
1522
- uriTemplate: WithWorkoutItemRequestBuilderUriTemplate,
1523
- responseBodyContentType: "application/json",
1524
- errorMappings: {
1525
- 400: createWorkout400ErrorFromDiscriminatorValue
1526
- },
1527
- adapterMethodName: "send",
1528
- responseBodyFactory: createWorkoutFromDiscriminatorValue,
1529
- requestBodyContentType: "application/json",
1530
- requestBodySerializer: serializePostWorkoutsRequestBody,
1531
- requestInformationContentSetMethod: "setContentFromParsable"
1532
- }
1533
- };
1534
1527
 
1535
- // src/generated/client/v1/workouts/index.ts
1536
- function createWorkout400ErrorFromDiscriminatorValue2(parseNode) {
1537
- return deserializeIntoWorkout400Error2;
1528
+ // src/generated/client/api/putV1RoutinesRoutineid.ts
1529
+ import fetch17 from "@kubb/plugin-client/clients/axios";
1530
+ function getPutV1RoutinesRoutineidUrl(routineId) {
1531
+ return `/v1/routines/${routineId}`;
1532
+ }
1533
+ async function putV1RoutinesRoutineid(routineId, headers, data, config = {}) {
1534
+ const { client: request = fetch17, ...requestConfig } = config;
1535
+ const requestData = data;
1536
+ const res = await request({
1537
+ method: "PUT",
1538
+ url: getPutV1RoutinesRoutineidUrl(routineId).toString(),
1539
+ data: requestData,
1540
+ ...requestConfig,
1541
+ headers: { ...headers, ...requestConfig.headers }
1542
+ });
1543
+ return res.data;
1538
1544
  }
1539
- function createWorkoutsGetResponseFromDiscriminatorValue(parseNode) {
1540
- return deserializeIntoWorkoutsGetResponse;
1545
+
1546
+ // src/generated/client/api/putV1WorkoutsWorkoutid.ts
1547
+ import fetch18 from "@kubb/plugin-client/clients/axios";
1548
+ function getPutV1WorkoutsWorkoutidUrl(workoutId) {
1549
+ return `/v1/workouts/${workoutId}`;
1550
+ }
1551
+ async function putV1WorkoutsWorkoutid(workoutId, headers, data, config = {}) {
1552
+ const { client: request = fetch18, ...requestConfig } = config;
1553
+ const requestData = data;
1554
+ const res = await request({
1555
+ method: "PUT",
1556
+ url: getPutV1WorkoutsWorkoutidUrl(workoutId).toString(),
1557
+ data: requestData,
1558
+ ...requestConfig,
1559
+ headers: { ...headers, ...requestConfig.headers }
1560
+ });
1561
+ return res.data;
1541
1562
  }
1542
- function deserializeIntoWorkout400Error2(workout400Error = {}) {
1543
- return {
1544
- "error": (n) => {
1545
- workout400Error.errorEscaped = n.getStringValue();
1563
+
1564
+ // src/utils/hevyClientKubb.ts
1565
+ function createClient(apiKey2, baseUrl = "https://api.hevyapp.com") {
1566
+ const axiosInstance = axios.create({
1567
+ baseURL: baseUrl,
1568
+ headers: {
1569
+ "api-key": apiKey2
1546
1570
  }
1571
+ });
1572
+ const headers = {
1573
+ "api-key": apiKey2
1547
1574
  };
1548
- }
1549
- function deserializeIntoWorkoutsGetResponse(workoutsGetResponse = {}) {
1575
+ const client = axiosInstance;
1550
1576
  return {
1551
- "page": (n) => {
1552
- workoutsGetResponse.page = n.getNumberValue();
1553
- },
1554
- "page_count": (n) => {
1555
- workoutsGetResponse.pageCount = n.getNumberValue();
1556
- },
1557
- "workouts": (n) => {
1558
- workoutsGetResponse.workouts = n.getCollectionOfObjectValues(createWorkoutFromDiscriminatorValue);
1559
- }
1577
+ // Workouts
1578
+ getWorkouts: (params) => getV1Workouts(headers, params, { client }),
1579
+ getWorkout: (workoutId) => getV1WorkoutsWorkoutid(workoutId, headers, { client }),
1580
+ createWorkout: (data) => postV1Workouts(headers, data, { client }),
1581
+ updateWorkout: (workoutId, data) => putV1WorkoutsWorkoutid(workoutId, headers, data, {
1582
+ client
1583
+ }),
1584
+ getWorkoutCount: () => getV1WorkoutsCount(headers, { client }),
1585
+ getWorkoutEvents: (params) => getV1WorkoutsEvents(headers, params, { client }),
1586
+ // Routines
1587
+ getRoutines: (params) => getV1Routines(headers, params, { client }),
1588
+ getRoutineById: (routineId) => getV1RoutinesRoutineid(routineId, headers, { client }),
1589
+ createRoutine: (data) => postV1Routines(headers, data, { client }),
1590
+ updateRoutine: (routineId, data) => putV1RoutinesRoutineid(routineId, headers, data, {
1591
+ client
1592
+ }),
1593
+ // Exercise Templates
1594
+ getExerciseTemplates: (params) => getV1ExerciseTemplates(headers, params, { client }),
1595
+ getExerciseTemplate: (templateId) => getV1ExerciseTemplatesExercisetemplateid(templateId, headers, {
1596
+ client
1597
+ }),
1598
+ // Routine Folders
1599
+ getRoutineFolders: (params) => getV1RoutineFolders(headers, params, { client }),
1600
+ createRoutineFolder: (data) => postV1RoutineFolders(headers, data, { client }),
1601
+ getRoutineFolder: (folderId) => getV1RoutineFoldersFolderid(folderId, headers, {
1602
+ client
1603
+ }),
1604
+ // Webhooks
1605
+ getWebhookSubscription: () => getV1WebhookSubscription(headers, { client }),
1606
+ createWebhookSubscription: (data) => postV1WebhookSubscription(headers, data, { client }),
1607
+ deleteWebhookSubscription: () => deleteV1WebhookSubscription(headers, { client })
1560
1608
  };
1561
1609
  }
1562
- var WorkoutsRequestBuilderUriTemplate = "{+baseurl}/v1/workouts{?page*,pageSize*}";
1563
- var WorkoutsRequestBuilderNavigationMetadata = {
1564
- byWorkoutId: {
1565
- requestsMetadata: WithWorkoutItemRequestBuilderRequestsMetadata,
1566
- pathParametersMappings: ["workoutId"]
1567
- },
1568
- count: {
1569
- requestsMetadata: CountRequestBuilderRequestsMetadata
1570
- },
1571
- events: {
1572
- requestsMetadata: EventsRequestBuilderRequestsMetadata
1573
- }
1574
- };
1575
- var WorkoutsRequestBuilderRequestsMetadata = {
1576
- get: {
1577
- uriTemplate: WorkoutsRequestBuilderUriTemplate,
1578
- responseBodyContentType: "application/json",
1579
- adapterMethodName: "send",
1580
- responseBodyFactory: createWorkoutsGetResponseFromDiscriminatorValue
1581
- },
1582
- post: {
1583
- uriTemplate: WorkoutsRequestBuilderUriTemplate,
1584
- responseBodyContentType: "application/json",
1585
- errorMappings: {
1586
- 400: createWorkout400ErrorFromDiscriminatorValue2
1587
- },
1588
- adapterMethodName: "send",
1589
- responseBodyFactory: createWorkoutFromDiscriminatorValue,
1590
- requestBodyContentType: "application/json",
1591
- requestBodySerializer: serializePostWorkoutsRequestBody,
1592
- requestInformationContentSetMethod: "setContentFromParsable"
1593
- }
1594
- };
1595
-
1596
- // src/generated/client/v1/index.ts
1597
- var V1RequestBuilderNavigationMetadata = {
1598
- exercise_templates: {
1599
- requestsMetadata: Exercise_templatesRequestBuilderRequestsMetadata,
1600
- navigationMetadata: Exercise_templatesRequestBuilderNavigationMetadata
1601
- },
1602
- routines: {
1603
- requestsMetadata: RoutinesRequestBuilderRequestsMetadata,
1604
- navigationMetadata: RoutinesRequestBuilderNavigationMetadata
1605
- },
1606
- routine_folders: {
1607
- requestsMetadata: Routine_foldersRequestBuilderRequestsMetadata,
1608
- navigationMetadata: Routine_foldersRequestBuilderNavigationMetadata
1609
- },
1610
- workouts: {
1611
- requestsMetadata: WorkoutsRequestBuilderRequestsMetadata,
1612
- navigationMetadata: WorkoutsRequestBuilderNavigationMetadata
1613
- }
1614
- };
1615
-
1616
- // src/generated/client/hevyClient.ts
1617
- import { apiClientProxifier, ParseNodeFactoryRegistry, SerializationWriterFactoryRegistry } from "@microsoft/kiota-abstractions";
1618
-
1619
- // node_modules/@microsoft/kiota-serialization-form/dist/es/src/formParseNode.js
1620
- import { createBackedModelProxyHandler, DateOnly, Duration, parseGuidString, TimeOnly, isBackingStoreEnabled, getEnumValueFromStringValue } from "@microsoft/kiota-abstractions";
1621
- var FormParseNode = class _FormParseNode {
1622
- /**
1623
- * Creates a new instance of FormParseNode
1624
- * @param _rawString the raw string to parse
1625
- * @param backingStoreFactory the factory to create backing stores
1626
- */
1627
- constructor(_rawString, backingStoreFactory) {
1628
- this._rawString = _rawString;
1629
- this.backingStoreFactory = backingStoreFactory;
1630
- this._fields = {};
1631
- this.normalizeKey = (key) => decodeURIComponent(key).trim();
1632
- this.getStringValue = () => decodeURIComponent(this._rawString);
1633
- this.getChildNode = (identifier) => {
1634
- if (this._fields[identifier]) {
1635
- return new _FormParseNode(this._fields[identifier], this.backingStoreFactory);
1636
- }
1637
- return void 0;
1638
- };
1639
- this.getBooleanValue = () => {
1640
- var _a;
1641
- const value = (_a = this.getStringValue()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
1642
- if (value === "true" || value === "1") {
1643
- return true;
1644
- } else if (value === "false" || value === "0") {
1645
- return false;
1646
- }
1647
- return void 0;
1648
- };
1649
- this.getNumberValue = () => parseFloat(this.getStringValue());
1650
- this.getGuidValue = () => parseGuidString(this.getStringValue());
1651
- this.getDateValue = () => new Date(Date.parse(this.getStringValue()));
1652
- this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
1653
- this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
1654
- this.getDurationValue = () => Duration.parse(this.getStringValue());
1655
- this.getCollectionOfPrimitiveValues = () => {
1656
- return this._rawString.split(",").map((x) => {
1657
- const currentParseNode = new _FormParseNode(x, this.backingStoreFactory);
1658
- const typeOfX = typeof x;
1659
- if (typeOfX === "boolean") {
1660
- return currentParseNode.getBooleanValue();
1661
- } else if (typeOfX === "string") {
1662
- return currentParseNode.getStringValue();
1663
- } else if (typeOfX === "number") {
1664
- return currentParseNode.getNumberValue();
1665
- } else if (x instanceof Date) {
1666
- return currentParseNode.getDateValue();
1667
- } else if (x instanceof DateOnly) {
1668
- return currentParseNode.getDateValue();
1669
- } else if (x instanceof TimeOnly) {
1670
- return currentParseNode.getDateValue();
1671
- } else if (x instanceof Duration) {
1672
- return currentParseNode.getDateValue();
1673
- } else {
1674
- throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
1675
- }
1676
- });
1677
- };
1678
- this.getCollectionOfObjectValues = (parsableFactory) => {
1679
- throw new Error(`serialization of collections is not supported with URI encoding`);
1680
- };
1681
- this.getObjectValue = (parsableFactory) => {
1682
- const temp = {};
1683
- const enableBackingStore = isBackingStoreEnabled(parsableFactory(this)(temp));
1684
- const value = enableBackingStore && this.backingStoreFactory ? new Proxy(temp, createBackedModelProxyHandler(this.backingStoreFactory)) : temp;
1685
- if (this.onBeforeAssignFieldValues) {
1686
- this.onBeforeAssignFieldValues(value);
1687
- }
1688
- this.assignFieldValues(value, parsableFactory);
1689
- if (this.onAfterAssignFieldValues) {
1690
- this.onAfterAssignFieldValues(value);
1691
- }
1692
- return value;
1693
- };
1694
- this.getCollectionOfEnumValues = (type) => {
1695
- const rawValues = this.getStringValue();
1696
- if (!rawValues) {
1697
- return [];
1698
- }
1699
- return rawValues.split(",").map((x) => getEnumValueFromStringValue(x, type));
1700
- };
1701
- this.getEnumValue = (type) => {
1702
- const rawValue = this.getStringValue();
1703
- if (!rawValue) {
1704
- return void 0;
1705
- }
1706
- return getEnumValueFromStringValue(rawValue, type);
1707
- };
1708
- this.assignFieldValues = (model, parsableFactory) => {
1709
- const fields = parsableFactory(this)(model);
1710
- Object.entries(this._fields).filter((x) => !/^null$/i.test(x[1])).forEach(([k, v]) => {
1711
- const deserializer = fields[k];
1712
- if (deserializer) {
1713
- deserializer(new _FormParseNode(v, this.backingStoreFactory));
1714
- } else {
1715
- model[k] = v;
1716
- }
1717
- });
1718
- };
1719
- if (!_rawString) {
1720
- throw new Error("rawString cannot be undefined");
1721
- }
1722
- _rawString.split("&").map((x) => x.split("=")).filter((x) => x.length === 2).forEach((x) => {
1723
- const key = this.normalizeKey(x[0]);
1724
- if (this._fields[key]) {
1725
- this._fields[key] += "," + x[1];
1726
- } else {
1727
- this._fields[key] = x[1];
1728
- }
1729
- });
1730
- }
1731
- getByteArrayValue() {
1732
- throw new Error("serialization of byt arrays is not supported with URI encoding");
1733
- }
1734
- };
1735
-
1736
- // node_modules/@microsoft/kiota-serialization-form/dist/es/src/formSerializationWriter.js
1737
- import { DateOnly as DateOnly2, Duration as Duration2, TimeOnly as TimeOnly2 } from "@microsoft/kiota-abstractions";
1738
- var FormSerializationWriter = class _FormSerializationWriter {
1739
- constructor() {
1740
- this.writer = [];
1741
- this.depth = -1;
1742
- this.writeStringValue = (key, value) => {
1743
- if (value === null) {
1744
- value = "null";
1745
- }
1746
- if (key && value) {
1747
- this.writePropertyName(key);
1748
- this.writer.push(`=${encodeURIComponent(value)}`);
1749
- this.writer.push(_FormSerializationWriter.propertySeparator);
1750
- }
1751
- };
1752
- this.writePropertyName = (key) => {
1753
- this.writer.push(encodeURIComponent(key));
1754
- };
1755
- this.shouldWriteValueOrNull = (key, value) => {
1756
- if (value === null) {
1757
- this.writeNullValue(key);
1758
- return false;
1759
- }
1760
- return true;
1761
- };
1762
- this.writeBooleanValue = (key, value) => {
1763
- if (this.shouldWriteValueOrNull(key, value)) {
1764
- value !== void 0 && this.writeStringValue(key, `${value}`);
1765
- }
1766
- };
1767
- this.writeNumberValue = (key, value) => {
1768
- if (this.shouldWriteValueOrNull(key, value)) {
1769
- value && this.writeStringValue(key, `${value}`);
1770
- }
1771
- };
1772
- this.writeGuidValue = (key, value) => {
1773
- if (this.shouldWriteValueOrNull(key, value)) {
1774
- value && this.writeStringValue(key, value.toString());
1775
- }
1776
- };
1777
- this.writeDateValue = (key, value) => {
1778
- if (this.shouldWriteValueOrNull(key, value)) {
1779
- value && this.writeStringValue(key, value.toISOString());
1780
- }
1781
- };
1782
- this.writeDateOnlyValue = (key, value) => {
1783
- if (this.shouldWriteValueOrNull(key, value)) {
1784
- value && this.writeStringValue(key, value.toString());
1785
- }
1786
- };
1787
- this.writeTimeOnlyValue = (key, value) => {
1788
- if (this.shouldWriteValueOrNull(key, value)) {
1789
- value && this.writeStringValue(key, value.toString());
1790
- }
1791
- };
1792
- this.writeDurationValue = (key, value) => {
1793
- if (this.shouldWriteValueOrNull(key, value)) {
1794
- value && this.writeStringValue(key, value.toString());
1795
- }
1796
- };
1797
- this.writeNullValue = (key) => {
1798
- key && this.writeStringValue(key, null);
1799
- };
1800
- this.writeCollectionOfPrimitiveValues = (_key, _values) => {
1801
- if (_key && _values) {
1802
- _values.forEach((val) => {
1803
- this.writeAnyValue(_key, val);
1804
- });
1805
- }
1806
- };
1807
- this.writeCollectionOfObjectValues = (_key, _values) => {
1808
- throw new Error(`serialization of collections is not supported with URI encoding`);
1809
- };
1810
- this.writeObjectValue = (key, value, serializerMethod) => {
1811
- if (++this.depth > 0) {
1812
- throw new Error(`serialization of nested objects is not supported with URI encoding`);
1813
- }
1814
- if (!this.shouldWriteValueOrNull(key, value)) {
1815
- return;
1816
- }
1817
- if (value) {
1818
- if (key) {
1819
- this.writePropertyName(key);
1820
- }
1821
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
1822
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
1823
- serializerMethod(this, value);
1824
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
1825
- if (this.writer.length > 0 && this.writer[this.writer.length - 1] === _FormSerializationWriter.propertySeparator) {
1826
- this.writer.pop();
1827
- }
1828
- key && this.writer.push(_FormSerializationWriter.propertySeparator);
1829
- }
1830
- };
1831
- this.writeEnumValue = (key, ...values) => {
1832
- if (values.length > 0) {
1833
- const rawValues = values.filter((x) => x !== void 0).map((x) => `${x}`);
1834
- if (rawValues.length > 0) {
1835
- this.writeStringValue(key, rawValues.reduce((x, y) => `${x}, ${y}`));
1836
- }
1837
- }
1838
- };
1839
- this.writeCollectionOfEnumValues = (key, values) => {
1840
- if (key && values && values.length > 0) {
1841
- const rawValues = values.filter((x) => x !== void 0).map((x) => `${x}`);
1842
- if (rawValues.length > 0) {
1843
- this.writeCollectionOfPrimitiveValues(key, rawValues);
1844
- }
1845
- }
1846
- };
1847
- this.getSerializedContent = () => {
1848
- return this.convertStringToArrayBuffer(this.writer.join(``));
1849
- };
1850
- this.convertStringToArrayBuffer = (str) => {
1851
- const encoder = new TextEncoder();
1852
- const encodedString = encoder.encode(str);
1853
- return encodedString.buffer;
1854
- };
1855
- this.writeAdditionalData = (additionalData) => {
1856
- if (additionalData === void 0)
1857
- return;
1858
- for (const key in additionalData) {
1859
- this.writeAnyValue(key, additionalData[key]);
1860
- }
1861
- };
1862
- this.writeAnyValue = (key, value) => {
1863
- if (value === null) {
1864
- return this.writeNullValue(key);
1865
- }
1866
- if (value !== void 0) {
1867
- const valueType = typeof value;
1868
- if (valueType === "boolean") {
1869
- this.writeBooleanValue(key, value);
1870
- } else if (valueType === "string") {
1871
- this.writeStringValue(key, value);
1872
- } else if (value instanceof Date) {
1873
- this.writeDateValue(key, value);
1874
- } else if (value instanceof DateOnly2) {
1875
- this.writeDateOnlyValue(key, value);
1876
- } else if (value instanceof TimeOnly2) {
1877
- this.writeTimeOnlyValue(key, value);
1878
- } else if (value instanceof Duration2) {
1879
- this.writeDurationValue(key, value);
1880
- } else if (valueType === "number") {
1881
- this.writeNumberValue(key, value);
1882
- } else {
1883
- throw new Error(`encountered unknown ${value} value type during serialization ${valueType} for key ${key}`);
1884
- }
1885
- }
1886
- };
1887
- }
1888
- writeByteArrayValue(key, value) {
1889
- throw new Error("serialization of byt arrays is not supported with URI encoding");
1890
- }
1891
- };
1892
- FormSerializationWriter.propertySeparator = `&`;
1893
-
1894
- // node_modules/@microsoft/kiota-serialization-form/dist/es/src/formParseNodeFactory.js
1895
- var FormParseNodeFactory = class {
1896
- /**
1897
- * Creates an instance of JsonParseNode.
1898
- * @param backingStoreFactory - The factory to create backing stores.
1899
- */
1900
- constructor(backingStoreFactory) {
1901
- this.backingStoreFactory = backingStoreFactory;
1902
- }
1903
- getValidContentType() {
1904
- return "application/x-www-form-urlencoded";
1905
- }
1906
- getRootParseNode(contentType, content) {
1907
- if (!content) {
1908
- throw new Error("content cannot be undefined of empty");
1909
- } else if (!contentType) {
1910
- throw new Error("content type cannot be undefined or empty");
1911
- } else if (this.getValidContentType() !== contentType) {
1912
- throw new Error(`expected a ${this.getValidContentType()} content type`);
1913
- }
1914
- return new FormParseNode(this.convertArrayBufferToString(content), this.backingStoreFactory);
1915
- }
1916
- convertArrayBufferToString(content) {
1917
- const decoder = new TextDecoder();
1918
- return decoder.decode(content);
1919
- }
1920
- };
1921
-
1922
- // node_modules/@microsoft/kiota-serialization-form/dist/es/src/formSerializationWriterFactory.js
1923
- var FormSerializationWriterFactory = class {
1924
- getValidContentType() {
1925
- return "application/x-www-form-urlencoded";
1926
- }
1927
- getSerializationWriter(contentType) {
1928
- if (!contentType) {
1929
- throw new Error("content type cannot be undefined or empty");
1930
- } else if (this.getValidContentType() !== contentType) {
1931
- throw new Error(`expected a ${this.getValidContentType()} content type`);
1932
- }
1933
- return new FormSerializationWriter();
1934
- }
1935
- };
1936
-
1937
- // src/generated/client/hevyClient.ts
1938
- import { JsonParseNodeFactory, JsonSerializationWriterFactory } from "@microsoft/kiota-serialization-json";
1939
-
1940
- // node_modules/@microsoft/kiota-serialization-multipart/dist/es/src/multipartSerializationWriter.js
1941
- import { MultipartBody } from "@microsoft/kiota-abstractions";
1942
- var MultipartSerializationWriter = class {
1943
- constructor() {
1944
- this.writer = new ArrayBuffer(0);
1945
- this.writeStringValue = (key, value) => {
1946
- if (key) {
1947
- this.writeRawStringValue(key);
1948
- }
1949
- if (value) {
1950
- if (key) {
1951
- this.writeRawStringValue(": ");
1952
- }
1953
- this.writeRawStringValue(value);
1954
- }
1955
- };
1956
- this.writeRawStringValue = (value) => {
1957
- if (value) {
1958
- this.writeByteArrayValue(void 0, new TextEncoder().encode(value).buffer);
1959
- }
1960
- };
1961
- this.writeBooleanValue = (key, value) => {
1962
- throw new Error(`serialization of boolean values is not supported with multipart`);
1963
- };
1964
- this.writeNumberValue = (key, value) => {
1965
- throw new Error(`serialization of number values is not supported with multipart`);
1966
- };
1967
- this.writeGuidValue = (key, value) => {
1968
- throw new Error(`serialization of guid values is not supported with multipart`);
1969
- };
1970
- this.writeDateValue = (key, value) => {
1971
- throw new Error(`serialization of date values is not supported with multipart`);
1972
- };
1973
- this.writeDateOnlyValue = (key, value) => {
1974
- throw new Error(`serialization of date only values is not supported with multipart`);
1975
- };
1976
- this.writeTimeOnlyValue = (key, value) => {
1977
- throw new Error(`serialization of time only values is not supported with multipart`);
1978
- };
1979
- this.writeDurationValue = (key, value) => {
1980
- throw new Error(`serialization of duration values is not supported with multipart`);
1981
- };
1982
- this.writeNullValue = (key) => {
1983
- throw new Error(`serialization of null values is not supported with multipart`);
1984
- };
1985
- this.writeCollectionOfPrimitiveValues = (_key, _values) => {
1986
- throw new Error(`serialization of collections is not supported with multipart`);
1987
- };
1988
- this.writeCollectionOfObjectValues = (_key, _values) => {
1989
- throw new Error(`serialization of collections is not supported with multipart`);
1990
- };
1991
- this.writeObjectValue = (key, value, serializerMethod) => {
1992
- if (!value) {
1993
- throw new Error(`value cannot be undefined`);
1994
- }
1995
- if (!(value instanceof MultipartBody)) {
1996
- throw new Error(`expected MultipartBody instance`);
1997
- }
1998
- if (!serializerMethod) {
1999
- throw new Error(`serializer method cannot be undefined`);
2000
- }
2001
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
2002
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
2003
- serializerMethod(this, value);
2004
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
2005
- };
2006
- this.writeEnumValue = (key, ...values) => {
2007
- throw new Error(`serialization of enum values is not supported with multipart`);
2008
- };
2009
- this.writeCollectionOfEnumValues = (key, values) => {
2010
- throw new Error(`serialization of collection of enum values is not supported with multipart`);
2011
- };
2012
- this.getSerializedContent = () => {
2013
- return this.writer;
2014
- };
2015
- this.writeAdditionalData = (additionalData) => {
2016
- throw new Error(`serialization of additional data is not supported with multipart`);
2017
- };
2018
- }
2019
- writeByteArrayValue(key, value) {
2020
- if (!value) {
2021
- throw new Error("value cannot be undefined");
2022
- }
2023
- const previousValue = this.writer;
2024
- this.writer = new ArrayBuffer(previousValue.byteLength + value.byteLength);
2025
- const pipe = new Uint8Array(this.writer);
2026
- pipe.set(new Uint8Array(previousValue), 0);
2027
- pipe.set(new Uint8Array(value), previousValue.byteLength);
2028
- }
2029
- };
2030
-
2031
- // node_modules/@microsoft/kiota-serialization-multipart/dist/es/src/multipartSerializationWriterFactory.js
2032
- var MultipartSerializationWriterFactory = class {
2033
- getValidContentType() {
2034
- return "multipart/form-data";
2035
- }
2036
- getSerializationWriter(contentType) {
2037
- if (!contentType) {
2038
- throw new Error("content type cannot be undefined or empty");
2039
- } else if (this.getValidContentType() !== contentType) {
2040
- throw new Error(`expected a ${this.getValidContentType()} content type`);
2041
- }
2042
- return new MultipartSerializationWriter();
2043
- }
2044
- };
2045
-
2046
- // src/generated/client/hevyClient.ts
2047
- import { TextParseNodeFactory, TextSerializationWriterFactory } from "@microsoft/kiota-serialization-text";
2048
- function createHevyClient(requestAdapter) {
2049
- if (requestAdapter === void 0) {
2050
- throw new Error("requestAdapter cannot be undefined");
2051
- }
2052
- let serializationWriterFactory;
2053
- let parseNodeFactoryRegistry;
2054
- if (requestAdapter.getParseNodeFactory() instanceof ParseNodeFactoryRegistry) {
2055
- parseNodeFactoryRegistry = requestAdapter.getParseNodeFactory();
2056
- } else {
2057
- throw new Error("requestAdapter.getParseNodeFactory() is not a ParseNodeFactoryRegistry");
2058
- }
2059
- if (requestAdapter.getSerializationWriterFactory() instanceof SerializationWriterFactoryRegistry) {
2060
- serializationWriterFactory = requestAdapter.getSerializationWriterFactory();
2061
- } else {
2062
- throw new Error("requestAdapter.getSerializationWriterFactory() is not a SerializationWriterFactoryRegistry");
2063
- }
2064
- serializationWriterFactory.registerDefaultSerializer(JsonSerializationWriterFactory);
2065
- serializationWriterFactory.registerDefaultSerializer(TextSerializationWriterFactory);
2066
- serializationWriterFactory.registerDefaultSerializer(FormSerializationWriterFactory);
2067
- serializationWriterFactory.registerDefaultSerializer(MultipartSerializationWriterFactory);
2068
- const backingStoreFactory = requestAdapter.getBackingStoreFactory();
2069
- parseNodeFactoryRegistry.registerDefaultDeserializer(JsonParseNodeFactory, backingStoreFactory);
2070
- parseNodeFactoryRegistry.registerDefaultDeserializer(TextParseNodeFactory, backingStoreFactory);
2071
- parseNodeFactoryRegistry.registerDefaultDeserializer(FormParseNodeFactory, backingStoreFactory);
2072
- const pathParameters = {
2073
- "baseurl": requestAdapter.baseUrl
2074
- };
2075
- return apiClientProxifier(requestAdapter, pathParameters, HevyClientNavigationMetadata, void 0);
2076
- }
2077
- var HevyClientNavigationMetadata = {
2078
- v1: {
2079
- navigationMetadata: V1RequestBuilderNavigationMetadata
2080
- }
2081
- };
2082
1610
 
2083
1611
  // src/utils/hevyClient.ts
2084
- function createClient(apiKey2, baseUrl) {
2085
- const authProvider = new ApiKeyAuthenticationProvider(
2086
- apiKey2,
2087
- "api-key",
2088
- ApiKeyLocation.Header
2089
- );
2090
- const adapter = new FetchRequestAdapter(authProvider);
2091
- adapter.baseUrl = baseUrl;
2092
- return createHevyClient(adapter);
1612
+ function createClient2(apiKey2, baseUrl) {
1613
+ return createClient(apiKey2, baseUrl);
2093
1614
  }
2094
1615
 
2095
- // package.json
2096
- var name = "hevy-mcp";
2097
- var version = "1.3.1";
2098
-
2099
1616
  // src/index.ts
2100
1617
  var HEVY_API_BASEURL = "https://api.hevyapp.com";
2101
1618
  var server = new McpServer({
@@ -2107,11 +1624,12 @@ if (!process.env.HEVY_API_KEY) {
2107
1624
  process.exit(1);
2108
1625
  }
2109
1626
  var apiKey = process.env.HEVY_API_KEY || "";
2110
- var hevyClient = createClient(apiKey, HEVY_API_BASEURL);
1627
+ var hevyClient = createClient2(apiKey, HEVY_API_BASEURL);
2111
1628
  registerWorkoutTools(server, hevyClient);
2112
1629
  registerRoutineTools(server, hevyClient);
2113
1630
  registerTemplateTools(server, hevyClient);
2114
1631
  registerFolderTools(server, hevyClient);
1632
+ registerWebhookTools(server, hevyClient);
2115
1633
  async function runServer() {
2116
1634
  const transport = new StdioServerTransport();
2117
1635
  await server.connect(transport);