Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/tools/folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
createEmptyResponse,
createJsonResponse,
} from "../utils/response-formatter.js";
import { createPassthroughSchema } from "../utils/schema-helpers.js";

// Type definitions for the folder operations
type HevyClient = ReturnType<
Expand All @@ -25,10 +26,10 @@ export function registerFolderTools(
server.tool(
"get-routine-folders",
"Get a paginated list of your routine folders, including both default and custom folders. Useful for organizing and browsing your workout routines.",
{
createPassthroughSchema({
page: z.coerce.number().int().gte(1).default(1),
pageSize: z.coerce.number().int().gte(1).lte(10).default(5),
},
}),
withErrorHandling(
async ({ page, pageSize }: { page: number; pageSize: number }) => {
if (!hevyClient) {
Expand Down Expand Up @@ -63,9 +64,9 @@ export function registerFolderTools(
server.tool(
"get-routine-folder",
"Get complete details of a specific routine folder by its ID, including name, creation date, and associated routines.",
{
createPassthroughSchema({
folderId: z.string().min(1),
},
}),
withErrorHandling(async ({ folderId }: { folderId: string }) => {
if (!hevyClient) {
throw new Error(
Expand All @@ -89,9 +90,9 @@ export function registerFolderTools(
server.tool(
"create-routine-folder",
"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.",
{
createPassthroughSchema({
name: z.string().min(1),
},
}),
withErrorHandling(async ({ name }: { name: string }) => {
if (!hevyClient) {
throw new Error(
Expand Down
17 changes: 9 additions & 8 deletions src/tools/routines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
createEmptyResponse,
createJsonResponse,
} from "../utils/response-formatter.js";
import { createPassthroughSchema } from "../utils/schema-helpers.js";

// Type definitions for the routine operations
type HevyClient = ReturnType<
Expand Down Expand Up @@ -74,10 +75,10 @@ export function registerRoutineTools(
server.tool(
"get-routines",
"Get a paginated list of your workout routines, including custom and default routines. Useful for browsing or searching your available routines.",
{
createPassthroughSchema({
page: z.coerce.number().int().gte(1).default(1),
pageSize: z.coerce.number().int().gte(1).lte(10).default(5),
},
}),
withErrorHandling(async (args) => {
if (!hevyClient) {
throw new Error(
Expand Down Expand Up @@ -108,9 +109,9 @@ export function registerRoutineTools(
server.tool(
"get-routine",
"Get a routine by its ID using the direct endpoint. Returns all details for the specified routine.",
{
createPassthroughSchema({
routineId: z.string().min(1),
},
}),
withErrorHandling(async ({ routineId }) => {
if (!hevyClient) {
throw new Error(
Expand All @@ -130,7 +131,7 @@ export function registerRoutineTools(
server.tool(
"create-routine",
"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.",
{
createPassthroughSchema({
title: z.string().min(1),
folderId: z.coerce.number().nullable().optional(),
notes: z.string().optional(),
Expand All @@ -154,7 +155,7 @@ export function registerRoutineTools(
),
}),
),
},
}),
withErrorHandling(async (args) => {
if (!hevyClient) {
throw new Error(
Expand Down Expand Up @@ -206,7 +207,7 @@ export function registerRoutineTools(
server.tool(
"update-routine",
"Update an existing routine by ID. You can modify the title, notes, and exercise configurations. Returns the updated routine with all changes applied.",
{
createPassthroughSchema({
routineId: z.string().min(1),
title: z.string().min(1),
notes: z.string().optional(),
Expand All @@ -230,7 +231,7 @@ export function registerRoutineTools(
),
}),
),
},
}),
withErrorHandling(async (args) => {
if (!hevyClient) {
throw new Error(
Expand Down
9 changes: 5 additions & 4 deletions src/tools/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
createEmptyResponse,
createJsonResponse,
} from "../utils/response-formatter.js";
import { createPassthroughSchema } from "../utils/schema-helpers.js";

// Type definitions for the template operations
type HevyClient = ReturnType<
Expand All @@ -25,10 +26,10 @@ export function registerTemplateTools(
server.tool(
"get-exercise-templates",
"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.",
{
createPassthroughSchema({
page: z.coerce.number().int().gte(1).default(1),
pageSize: z.coerce.number().int().gte(1).lte(100).default(5),
},
}),
withErrorHandling(
async ({ page, pageSize }: { page: number; pageSize: number }) => {
if (!hevyClient) {
Expand Down Expand Up @@ -63,9 +64,9 @@ export function registerTemplateTools(
server.tool(
"get-exercise-template",
"Get complete details of a specific exercise template by its ID, including name, category, equipment, muscle groups, and notes.",
{
createPassthroughSchema({
exerciseTemplateId: z.string().min(1),
},
}),
withErrorHandling(
async ({ exerciseTemplateId }: { exerciseTemplateId: string }) => {
if (!hevyClient) {
Expand Down
9 changes: 5 additions & 4 deletions src/tools/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createEmptyResponse,
createJsonResponse,
} from "../utils/response-formatter.js";
import { createPassthroughSchema } from "../utils/schema-helpers.js";

type HevyClient = ReturnType<
typeof import("../utils/hevyClientKubb.js").createClient
Expand Down Expand Up @@ -52,7 +53,7 @@ export function registerWebhookTools(
server.tool(
"get-webhook-subscription",
"Get the current webhook subscription for this account. Returns the webhook URL and auth token if a subscription exists.",
{},
createPassthroughSchema({}),
withErrorHandling(async () => {
if (!hevyClient) {
throw new Error(
Expand All @@ -73,7 +74,7 @@ export function registerWebhookTools(
server.tool(
"create-webhook-subscription",
"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.",
{
createPassthroughSchema({
url: webhookUrlSchema.describe(
"The webhook URL that will receive POST requests when workouts are created",
),
Expand All @@ -83,7 +84,7 @@ export function registerWebhookTools(
.describe(
"Optional auth token that will be sent as Authorization header in webhook requests",
),
},
}),
withErrorHandling(async ({ url, authToken }) => {
if (!hevyClient) {
throw new Error(
Expand All @@ -110,7 +111,7 @@ export function registerWebhookTools(
server.tool(
"delete-webhook-subscription",
"Delete the current webhook subscription for this account. This will stop all webhook notifications.",
{},
createPassthroughSchema({}),
withErrorHandling(async () => {
if (!hevyClient) {
throw new Error(
Expand Down
23 changes: 12 additions & 11 deletions src/tools/workouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
createEmptyResponse,
createJsonResponse,
} from "../utils/response-formatter.js";
import { createPassthroughSchema } from "../utils/schema-helpers.js";

/**
* Type definition for exercise set types
Expand Down Expand Up @@ -48,10 +49,10 @@ export function registerWorkoutTools(
server.tool(
"get-workouts",
"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.",
{
createPassthroughSchema({
page: z.coerce.number().gte(1).default(1),
pageSize: z.coerce.number().int().gte(1).lte(10).default(5),
},
}),
withErrorHandling(async ({ page, pageSize }) => {
if (!hevyClient) {
throw new Error(
Expand Down Expand Up @@ -81,9 +82,9 @@ export function registerWorkoutTools(
server.tool(
"get-workout",
"Get complete details of a specific workout by ID. Returns all workout information including title, description, start/end times, and detailed exercise data.",
{
createPassthroughSchema({
workoutId: z.string().min(1),
},
}),
withErrorHandling(async ({ workoutId }) => {
if (!hevyClient) {
throw new Error(
Expand All @@ -105,7 +106,7 @@ export function registerWorkoutTools(
server.tool(
"get-workout-count",
"Get the total number of workouts on the account. Useful for pagination or statistics.",
{},
createPassthroughSchema({}),
withErrorHandling(async () => {
if (!hevyClient) {
throw new Error(
Expand All @@ -125,11 +126,11 @@ export function registerWorkoutTools(
server.tool(
"get-workout-events",
"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.",
{
createPassthroughSchema({
page: z.coerce.number().int().gte(1).default(1),
pageSize: z.coerce.number().int().gte(1).lte(10).default(5),
since: z.string().default("1970-01-01T00:00:00Z"),
},
}),
withErrorHandling(async ({ page, pageSize, since }) => {
if (!hevyClient) {
throw new Error(
Expand Down Expand Up @@ -158,7 +159,7 @@ export function registerWorkoutTools(
server.tool(
"create-workout",
"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.",
{
createPassthroughSchema({
title: z.string().min(1),
description: z.string().optional().nullable(),
startTime: z.string().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/),
Expand All @@ -184,7 +185,7 @@ export function registerWorkoutTools(
),
}),
),
},
}),
withErrorHandling(
async ({
title,
Expand Down Expand Up @@ -245,7 +246,7 @@ export function registerWorkoutTools(
server.tool(
"update-workout",
"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.",
{
createPassthroughSchema({
workoutId: z.string().min(1),
title: z.string().min(1),
description: z.string().optional().nullable(),
Expand All @@ -272,7 +273,7 @@ export function registerWorkoutTools(
),
}),
),
},
}),
withErrorHandling(
async ({
workoutId,
Expand Down
Loading
Loading