1204 lines
41 KiB
TypeScript
1204 lines
41 KiB
TypeScript
export const openapi: Record<string, unknown> = {
|
|
openapi: '3.0.0',
|
|
info: {
|
|
title: 'FitOS API',
|
|
version: '1.0.0',
|
|
description:
|
|
'FitOS — silnik planów treningowych. Autoryzacja: Bearer access token (15 min) + refresh token (httpOnly cookie).',
|
|
},
|
|
servers: [{ url: '/api/v1' }],
|
|
components: {
|
|
securitySchemes: {
|
|
bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' },
|
|
},
|
|
},
|
|
paths: {
|
|
'/auth/register': {
|
|
post: {
|
|
tags: ['Auth'],
|
|
summary: 'Self-registration (default role: member)',
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['email', 'password'],
|
|
properties: {
|
|
email: { type: 'string' },
|
|
password: { type: 'string', minLength: 8 },
|
|
firstName: { type: 'string' },
|
|
lastName: { type: 'string' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
201: { description: 'Created (user + accessToken)' },
|
|
409: { description: 'Email already registered' },
|
|
},
|
|
},
|
|
},
|
|
'/auth/login': {
|
|
post: {
|
|
tags: ['Auth'],
|
|
summary: 'Login',
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['email', 'password'],
|
|
properties: {
|
|
email: { type: 'string' },
|
|
password: { type: 'string' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
200: { description: 'OK (user + accessToken)' },
|
|
401: { description: 'Invalid credentials' },
|
|
},
|
|
},
|
|
},
|
|
'/auth/refresh': {
|
|
post: {
|
|
tags: ['Auth'],
|
|
summary: 'Refresh access token (refresh cookie)',
|
|
responses: {
|
|
200: { description: 'OK (accessToken)' },
|
|
401: { description: 'Invalid/revoked refresh token' },
|
|
},
|
|
},
|
|
},
|
|
'/auth/logout': {
|
|
post: { tags: ['Auth'], summary: 'Logout (clears refresh cookie)' },
|
|
},
|
|
'/me': {
|
|
get: {
|
|
tags: ['Profile'],
|
|
summary: 'Current user profile + gym memberships',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
patch: {
|
|
tags: ['Profile'],
|
|
summary: 'Update profile (personal data, priorities, exclusions, available time)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
firstName: { type: 'string' },
|
|
lastName: { type: 'string' },
|
|
age: { type: 'integer' },
|
|
heightCm: { type: 'number' },
|
|
availability: {
|
|
type: 'array',
|
|
description: '7 dni (Pon-Niedz), każdy null lub { start, end }',
|
|
items: {
|
|
type: 'object',
|
|
nullable: true,
|
|
properties: { start: { type: 'string' }, end: { type: 'string' } },
|
|
},
|
|
},
|
|
priorities: { type: 'string' },
|
|
exclusions: { type: 'string' },
|
|
developMuscles: { type: 'array', items: { type: 'string' } },
|
|
canDoMuscles: { type: 'array', items: { type: 'string' } },
|
|
difficultMuscles: { type: 'array', items: { type: 'string' } },
|
|
avoidMuscles: { type: 'array', items: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/me/active-session': {
|
|
get: {
|
|
tags: ['Sessions'],
|
|
summary: 'Active (IN_PROGRESS) training session of the current user, if any',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/me/trainers': {
|
|
get: {
|
|
tags: ['Profile'],
|
|
summary: 'My trainers (ACTIVE coaching relations where I am the trainee)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/me/body-parameters': {
|
|
get: {
|
|
tags: ['Profile'],
|
|
summary: 'Body parameters over time (weight + circumference series)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/me/body-parameters/weight': {
|
|
post: {
|
|
tags: ['Profile'],
|
|
summary: 'Add weight measurement',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['value'],
|
|
properties: { value: { type: 'number' }, date: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/me/body-parameters/circumference': {
|
|
post: {
|
|
tags: ['Profile'],
|
|
summary: 'Add circumference measurement',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'value'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
value: { type: 'number' },
|
|
date: { type: 'string' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/exercises': {
|
|
get: {
|
|
tags: ['Exercises'],
|
|
summary: 'Exercise pool (MVP: full built-in pool)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/exercises/{id}': {
|
|
get: {
|
|
tags: ['Exercises'],
|
|
summary: 'Exercise details',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/gyms': {
|
|
get: {
|
|
tags: ['Gyms'],
|
|
summary: "User's gyms (memberships)",
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary: 'Create a gym (creator becomes its OWNER)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
location: { type: 'string' },
|
|
availability: {
|
|
type: 'array',
|
|
description: '7 dni (Pon-Niedz), każdy null lub { start, end }',
|
|
items: {
|
|
type: 'object',
|
|
nullable: true,
|
|
properties: { start: { type: 'string' }, end: { type: 'string' } },
|
|
},
|
|
},
|
|
capacity: { type: 'integer' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/gyms/all': {
|
|
get: {
|
|
tags: ['Gyms'],
|
|
summary: 'All gyms (for selecting an existing gym)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/gyms/{gymId}/join': {
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary: 'Join an existing gym (MEMBER membership)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/gyms/{gymId}/equipment': {
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary: 'Add a catalog equipment item to a gym (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['equipmentId'],
|
|
properties: { equipmentId: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/gyms/{gymId}/equipment/{equipmentId}': {
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Remove a catalog equipment item from a gym (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'equipmentId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/gyms/{gymId}': {
|
|
patch: {
|
|
tags: ['Gyms'],
|
|
summary: 'Update a gym (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: false,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
name: { type: 'string' },
|
|
location: { type: 'string', nullable: true },
|
|
availability: { type: 'array', nullable: true },
|
|
capacity: { type: 'integer', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Delete a gym (owner only). Memberships are removed; user plans are kept.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/gyms/{gymId}/exceptions': {
|
|
get: {
|
|
tags: ['Gyms'],
|
|
summary: "List a gym's schedule exceptions (owner only)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary: 'Add a one-off schedule exception (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['date'],
|
|
properties: {
|
|
date: { type: 'string', description: 'YYYY-MM-DD' },
|
|
availability: {
|
|
type: 'object',
|
|
nullable: true,
|
|
description: 'null = closed, { start, end } = different hours',
|
|
properties: { start: { type: 'string' }, end: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/gyms/{gymId}/exceptions/{exceptionId}': {
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Remove a schedule exception (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'exceptionId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/equipment': {
|
|
get: {
|
|
tags: ['Equipment'],
|
|
summary: 'List the equipment (machine/device) catalog with usage counts (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Equipment'],
|
|
summary: 'Create an equipment catalog entry (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
description: { type: 'string', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/equipment/{id}': {
|
|
patch: {
|
|
tags: ['Equipment'],
|
|
summary: 'Update an equipment catalog entry (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Equipment'],
|
|
summary: 'Delete an equipment catalog entry (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/exercises': {
|
|
get: {
|
|
tags: ['Exercises'],
|
|
summary: 'List exercise types with linked equipment and plan-usage count (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Exercises'],
|
|
summary:
|
|
'Create an exercise type (admin). Optional has* flags override the default strength combination.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'primaryMuscle'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
primaryMuscle: { type: 'string' },
|
|
secondaryMuscles: { type: 'array', items: { type: 'string' } },
|
|
description: { type: 'string', nullable: true },
|
|
howTo: { type: 'string', nullable: true },
|
|
commonMistakes: { type: 'string', nullable: true },
|
|
difficulty: { type: 'integer', minimum: 1, maximum: 10 },
|
|
equipmentIds: { type: 'array', items: { type: 'string' } },
|
|
hasReps: { type: 'boolean' },
|
|
hasLoad: { type: 'boolean' },
|
|
hasRest: { type: 'boolean' },
|
|
hasSets: { type: 'boolean' },
|
|
hasRir: { type: 'boolean' },
|
|
hasDifficulty: { type: 'boolean' },
|
|
hasCardio: { type: 'boolean' },
|
|
hasTime: { type: 'boolean' },
|
|
hasSpeed: { type: 'boolean' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/exercises/{id}': {
|
|
get: {
|
|
tags: ['Exercises'],
|
|
summary: 'Get an exercise type with linked equipment (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
patch: {
|
|
tags: ['Exercises'],
|
|
summary:
|
|
'Update an exercise type (admin). equipmentIds replaces the linked set; has* flags optional.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Exercises'],
|
|
summary: 'Delete an exercise type (admin). Fails if used in plans.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/focus-areas': {
|
|
get: {
|
|
tags: ['FocusAreas'],
|
|
summary: 'Catalog of training focus areas to choose priorities/exclusions from',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/admin/focus-areas': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: 'List focus areas with exercise usage counts (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Create a focus area (admin). Requires setsMin <= setsMax when both are set.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'muscle'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
muscle: { type: 'string' },
|
|
description: { type: 'string', nullable: true },
|
|
setsMin: { type: 'integer', nullable: true, minimum: 0, maximum: 100 },
|
|
setsMax: { type: 'integer', nullable: true, minimum: 0, maximum: 100 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/focus-areas/{id}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Update a focus area (admin). Sets range validated against the merged values.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete a focus area (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/equipment': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Add a catalog equipment item to a gym (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['equipmentId'],
|
|
properties: { equipmentId: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/equipment/{equipmentId}': {
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Remove a catalog equipment item from a gym (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'equipmentId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/plans': {
|
|
get: {
|
|
tags: ['Plans'],
|
|
summary: "User's plans",
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary:
|
|
'Create plan: weeks -> days (dayOfWeek) -> exercises -> sets. Optional startDate (a Monday) creates and activates the plan in one step. Creation is always allowed; when the user already has an active plan the new plan stays a DRAFT and the response carries activationSkipped: true. Optional gymId (informational; the plan owner must be a gym member) and per-week customName (alias, max 40)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['title', 'weeksCount', 'weeks'],
|
|
properties: {
|
|
title: { type: 'string' },
|
|
weeksCount: { type: 'integer', minimum: 1, maximum: 52 },
|
|
gymId: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description: 'Informational gym; the plan owner must be a member of it',
|
|
},
|
|
startDate: {
|
|
type: 'string',
|
|
description: 'YYYY-MM-DD, must be a Monday of the current or a future week',
|
|
},
|
|
weeks: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['index', 'days'],
|
|
properties: {
|
|
index: { type: 'integer', minimum: 0 },
|
|
customName: { type: 'string', nullable: true, maxLength: 40 },
|
|
days: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['dayOfWeek', 'exercises'],
|
|
properties: {
|
|
dayOfWeek: { type: 'integer', minimum: 1, maximum: 7 },
|
|
exercises: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['exerciseId', 'order', 'sets'],
|
|
properties: {
|
|
exerciseId: { type: 'string' },
|
|
order: { type: 'integer', minimum: 0 },
|
|
sets: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['index'],
|
|
properties: {
|
|
index: { type: 'integer' },
|
|
reps: { type: 'integer', nullable: true },
|
|
loadKg: { type: 'number', nullable: true },
|
|
restSec: { type: 'integer', nullable: true },
|
|
rir: { type: 'integer', nullable: true },
|
|
cardioBpm: { type: 'integer', nullable: true },
|
|
timeSec: { type: 'integer', nullable: true },
|
|
speed: { type: 'number', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/plans/shared-with-me': {
|
|
get: {
|
|
tags: ['Plans'],
|
|
summary: 'Plans explicitly shared with the user (read-only)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/plans/{id}': {
|
|
get: {
|
|
tags: ['Plans'],
|
|
summary:
|
|
'Plan details. Access: owner, trainer with an ACTIVE coaching relation, or a share recipient (read-only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
patch: {
|
|
tags: ['Plans'],
|
|
summary:
|
|
'Replace plan structure (draft only). Same body as POST /plans (gymId and weeks[].customName included). Optional startDate (a Monday of the current or a future week) updates and activates the plan in one step. The update is always allowed; when the user already has an active plan the structure is saved and the response carries activationSkipped: true',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/paths/~1plans/post/requestBody/content/application~1json/schema',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
200: { description: 'OK' },
|
|
400: { description: 'Not a draft / start date not a Monday / start week in the past' },
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Plans'],
|
|
summary: 'Delete plan (draft only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/plans/{id}/activate': {
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary: 'Activate plan (startDate must be a Monday of the current or a future week)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['startDate'],
|
|
properties: { startDate: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/plans/{id}/abandon': {
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary: 'Abandon plan (only from ACTIVE status)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: {
|
|
200: { description: 'OK' },
|
|
400: { description: 'Only an active plan can be abandoned' },
|
|
404: { description: 'Plan not found' },
|
|
},
|
|
},
|
|
},
|
|
'/plans/{id}/complete': {
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary: 'Manually archive plan (only from ACTIVE status)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: {
|
|
200: { description: 'OK' },
|
|
400: { description: 'Only an active plan can be completed' },
|
|
404: { description: 'Plan not found' },
|
|
},
|
|
},
|
|
},
|
|
'/plans/{id}/share': {
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary:
|
|
'Share the plan with a user in an ACTIVE coaching relation (trainer <-> trainee). Owner only; recipients get read-only access',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['userId'],
|
|
properties: { userId: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
201: { description: 'Shared' },
|
|
400: { description: 'Self-share / no active coaching relation' },
|
|
403: { description: 'Not the plan owner' },
|
|
404: { description: 'Plan not found' },
|
|
409: { description: 'Already shared with this user' },
|
|
},
|
|
},
|
|
},
|
|
'/plans/{id}/share/{userId}': {
|
|
delete: {
|
|
tags: ['Plans'],
|
|
summary: 'Revoke a plan share (owner only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'userId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
responses: {
|
|
204: { description: 'Unshared' },
|
|
403: { description: 'Not the plan owner' },
|
|
404: { description: 'Plan not found / not shared with this user' },
|
|
},
|
|
},
|
|
},
|
|
'/days/{dayId}/sessions': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary:
|
|
'Start session for a planned day (requires ACTIVE plan, one active session per user)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'dayId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: {
|
|
201: { description: 'Session started' },
|
|
400: { description: 'Training plan is not active / Day is not in planned state' },
|
|
404: { description: 'Day not found' },
|
|
409: { description: 'You already have an active session' },
|
|
},
|
|
},
|
|
},
|
|
'/sessions/{id}': {
|
|
get: {
|
|
tags: ['Sessions'],
|
|
summary: 'Session details (exercises -> sets, planned parameters as parent)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/sessions/{id}/exercises': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary: 'Add exercise to session (kept for restore)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['exerciseId'],
|
|
properties: { exerciseId: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/sessions/exercises/{id}': {
|
|
patch: {
|
|
tags: ['Sessions'],
|
|
summary:
|
|
'Hide or remove exercise (data kept for restore); removing allowed only for exercises added to the session',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: { hidden: { type: 'boolean' }, removed: { type: 'boolean' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
responses: {
|
|
200: { description: 'OK' },
|
|
400: { description: 'Only exercises added to the session can be removed' },
|
|
404: { description: 'Session exercise not found' },
|
|
},
|
|
},
|
|
},
|
|
'/sessions/exercises/{id}/sets': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary:
|
|
"Add extra (bonus) set to session exercise (requires this exercise's planned sets recorded; at most one pending extra per exercise)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/sessions/sets/{id}': {
|
|
patch: {
|
|
tags: ['Sessions'],
|
|
summary: 'Record actual set results (reps, RIR, difficulty, note)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
reps: { type: 'integer', nullable: true },
|
|
rir: { type: 'integer', nullable: true },
|
|
difficulty: { type: 'integer', nullable: true },
|
|
note: { type: 'string', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/sessions/{id}/complete': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary: 'Complete session (requires all sets recorded; day -> completed)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/sessions/{id}/abandon': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary:
|
|
'Abandon session (data kept, day -> skipped, the training cannot be executed again)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/sessions/{id}/reopen': {
|
|
post: {
|
|
tags: ['Sessions'],
|
|
summary:
|
|
'Reopen completed session (naprawa pomyłki; session -> in progress, day -> planned; requires no other active session)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/dashboard': {
|
|
get: {
|
|
tags: ['Dashboard'],
|
|
summary: 'Dashboard — killstreak, next training, plan progress',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/calendar': {
|
|
get: {
|
|
tags: ['Calendar'],
|
|
summary: 'Calendar — training days of the active plan in a month',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{
|
|
name: 'month',
|
|
in: 'query',
|
|
schema: { type: 'string' },
|
|
description: 'YYYY-MM (default: current)',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
'/admin/gyms': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: 'List gyms (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Create gym (admin; ownerId becomes OWNER member)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'ownerId'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
ownerId: { type: 'string', description: 'User mianowany właścicielem (OWNER)' },
|
|
location: { type: 'string' },
|
|
availability: {
|
|
type: 'array',
|
|
description: '7 dni (Pon-Niedz), każdy null lub { start, end }',
|
|
items: {
|
|
type: 'object',
|
|
nullable: true,
|
|
properties: { start: { type: 'string' }, end: { type: 'string' } },
|
|
},
|
|
},
|
|
capacity: { type: 'integer' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/owners': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Grant the OWNER role to a user in a gym (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['userId'],
|
|
properties: { userId: { type: 'string' } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/owners/{userId}': {
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Revoke the OWNER role in a gym (admin; membership removed when no roles left)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'userId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/gyms/{id}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Update gym (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete gym (admin; memberships removed, plans kept)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/users': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: 'List users (admin, optional ?search=)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Create user (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['email', 'password'],
|
|
properties: {
|
|
email: { type: 'string' },
|
|
password: { type: 'string' },
|
|
firstName: { type: 'string' },
|
|
lastName: { type: 'string' },
|
|
age: { type: 'integer' },
|
|
isAdmin: { type: 'boolean' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/users/{id}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Update user (admin; role change revokes JWT via token_version)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete user (admin; plans/sessions cascade-deleted)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/users/{id}/memberships': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Assign gym membership with roles (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['gymId', 'roles'],
|
|
properties: {
|
|
gymId: { type: 'string' },
|
|
roles: {
|
|
type: 'array',
|
|
items: { type: 'string', enum: ['OWNER', 'TRAINER', 'MEMBER'] },
|
|
minItems: 1,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/users/{id}/memberships/{gymId}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Change gym membership roles (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['roles'],
|
|
properties: {
|
|
roles: {
|
|
type: 'array',
|
|
items: { type: 'string', enum: ['OWNER', 'TRAINER', 'MEMBER'] },
|
|
minItems: 1,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Remove gym membership (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/users/{id}/killstreak': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: "User's killstreak (admin)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: { 200: { description: 'OK' }, 404: { description: 'User not found' } },
|
|
},
|
|
},
|
|
'/admin/users/{id}/body-parameters': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: "User's body parameters over time (admin)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: { 200: { description: 'OK' }, 404: { description: 'User not found' } },
|
|
},
|
|
},
|
|
'/admin/users/{id}/body-parameters/weight': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Add weight measurement for user (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['value'],
|
|
properties: {
|
|
value: { type: 'number' },
|
|
date: { type: 'string', format: 'date-time' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/users/{id}/body-parameters/weight/{measurementId}': {
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete a weight measurement of user (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'measurementId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/users/{id}/body-parameters/circumference': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Add circumference measurement for user (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'value'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
value: { type: 'number' },
|
|
date: { type: 'string', format: 'date-time' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/users/{id}/body-parameters/circumference/{measurementId}': {
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete a circumference measurement of user (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'measurementId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/users/{id}/history': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: "User's training history (admin, optional ?month=YYYY-MM)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'month', in: 'query', required: false, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/users/{id}/exercise-progress': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: "User's per-exercise progress — 1RM Epley + volume (admin)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
},
|
|
};
|