1663 lines
60 KiB
TypeScript
1663 lines
60 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',
|
|
description: 'Writes an ActivityLog entry: user.logged_in (details: client = app|admin).',
|
|
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' },
|
|
403: {
|
|
description:
|
|
'ACCOUNT_SUSPENDED (details: until, reason) or ACCOUNT_BANNED (details: reason)',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/auth/refresh': {
|
|
post: {
|
|
tags: ['Auth'],
|
|
summary: 'Refresh access token (refresh cookie)',
|
|
responses: {
|
|
200: { description: 'OK (accessToken)' },
|
|
401: { description: 'Invalid/revoked refresh token' },
|
|
403: {
|
|
description:
|
|
'ACCOUNT_SUSPENDED (details: until, reason) or ACCOUNT_BANNED (details: reason)',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/auth/logout': {
|
|
post: {
|
|
tags: ['Auth'],
|
|
summary: 'Logout (clears refresh cookie)',
|
|
description:
|
|
'Writes an ActivityLog entry: user.logged_out (only when a refresh token is present).',
|
|
},
|
|
},
|
|
'/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: ['typeId', 'value'],
|
|
properties: {
|
|
typeId: {
|
|
type: 'string',
|
|
enum: ['chest', 'waist', 'hips', 'neck', 'biceps', 'forearm', 'thigh', 'calf'],
|
|
},
|
|
side: { type: 'string', enum: ['left', 'right'], nullable: true },
|
|
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 OWNER; admins only for REAL, REAL requires address)',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
kind: { type: 'string', enum: ['VIRTUAL', 'REAL'], default: 'VIRTUAL' },
|
|
isPrivate: { type: 'boolean', description: 'Tylko dla VIRTUAL' },
|
|
location: {
|
|
type: 'string',
|
|
description: 'Swobodna lokalizacja (VIRTUAL); dla REAL derivowana z adresu',
|
|
},
|
|
addressLine1: { type: 'string', description: 'Ulica i numer (REAL)' },
|
|
addressLine2: { type: 'string', nullable: true },
|
|
postalCode: { type: 'string', description: 'Kod pocztowy 00-001 (REAL)' },
|
|
city: { type: 'string', description: 'Miejscowość (REAL)' },
|
|
countryCode: { type: 'string', default: 'PL', description: 'ISO 3166-1 alpha-2' },
|
|
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:
|
|
'Create an equipment instance in a gym (owner only); repeats of a catalog type create new instances. Optional spec overrides the catalog spec (validated against its kind)',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.added.',
|
|
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' },
|
|
quantity: { type: 'integer', minimum: 1, maximum: 10000 },
|
|
spec: {
|
|
type: 'object',
|
|
nullable: true,
|
|
description: 'Override of the catalog spec, e.g. {minKg,maxKg} / {maxLoadKg}',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/gyms/{gymId}/equipment/{id}': {
|
|
patch: {
|
|
tags: ['Gyms'],
|
|
summary:
|
|
'Change quantity and/or spec override of an equipment instance (owner only); spec:null clears the override',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
quantity: { type: 'integer', minimum: 1, maximum: 10000 },
|
|
spec: { type: 'object', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Remove an equipment instance (and its photos) from a gym (owner only)',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.removed.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/gyms/{gymId}/equipment/{id}/photos': {
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary:
|
|
"Add photos to an equipment instance (owner or admin; multipart field 'photos', max 5, 5 MB)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
requestBody: {
|
|
required: true,
|
|
content: { 'multipart/form-data': { schema: { type: 'object' } } },
|
|
},
|
|
},
|
|
},
|
|
'/gyms/{gymId}/equipment/{id}/photos/{photoId}': {
|
|
get: {
|
|
tags: ['Gyms'],
|
|
summary:
|
|
'Serve an equipment photo (REAL visible to all logged-in users; VIRTUAL to managers)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'photoId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Remove a photo from an equipment instance (owner or admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'photoId', 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)',
|
|
description: 'Writes an ActivityLog entry: gym.exception.added.',
|
|
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)',
|
|
description: 'Writes an ActivityLog entry: gym.exception.removed.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'exceptionId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/gyms/{gymId}/announcements': {
|
|
get: {
|
|
tags: ['Gyms'],
|
|
summary: "List the gym's announcements (any member; canManage = OWNER)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
post: {
|
|
tags: ['Gyms'],
|
|
summary: "Publish an announcement to the gym's members (owner only)",
|
|
description: 'Writes an ActivityLog entry: announcement.published.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['title', 'body'],
|
|
properties: {
|
|
title: { type: 'string', maxLength: 120 },
|
|
body: { type: 'string', maxLength: 2000 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/gyms/{gymId}/announcements/{announcementId}': {
|
|
patch: {
|
|
tags: ['Gyms'],
|
|
summary: 'Edit a manual announcement (owner only)',
|
|
description: 'Writes an ActivityLog entry: announcement.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'announcementId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['title', 'body'],
|
|
properties: {
|
|
title: { type: 'string', maxLength: 120 },
|
|
body: { type: 'string', maxLength: 2000 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Gyms'],
|
|
summary: 'Delete a manual announcement (owner only)',
|
|
description: 'Writes an ActivityLog entry: announcement.deleted.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'gymId', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'announcementId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/me/feed': {
|
|
get: {
|
|
tags: ['Feed'],
|
|
summary:
|
|
'Merged feed of personal notifications and gym/global announcements (cursor = createdAt)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'limit', in: 'query', schema: { type: 'integer', default: 20 } },
|
|
{
|
|
name: 'cursor',
|
|
in: 'query',
|
|
schema: { type: 'string' },
|
|
description: 'ISO createdAt of the last item on the page',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
'/me/feed/unread-count': {
|
|
get: {
|
|
tags: ['Feed'],
|
|
summary: 'Unread counter (notifications + visible announcements)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/me/feed/read-all': {
|
|
post: {
|
|
tags: ['Feed'],
|
|
summary: 'Mark all feed items as read (both sources)',
|
|
security: [{ bearerAuth: [] }],
|
|
},
|
|
},
|
|
'/me/feed/notifications/{id}/read': {
|
|
post: {
|
|
tags: ['Feed'],
|
|
summary: 'Mark a personal notification as read',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/me/feed/announcements/{id}/read': {
|
|
post: {
|
|
tags: ['Feed'],
|
|
summary: 'Mark an announcement as read (visible to the user only)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', 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)',
|
|
description: 'Writes an ActivityLog entry: equipment.created.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
nameEn: { type: 'string', nullable: true },
|
|
description: { type: 'string', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/equipment/{id}': {
|
|
patch: {
|
|
tags: ['Equipment'],
|
|
summary: 'Update an equipment catalog entry (admin)',
|
|
description: 'Writes an ActivityLog entry: equipment.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Equipment'],
|
|
summary: 'Delete an equipment catalog entry (admin)',
|
|
description: 'Writes an ActivityLog entry: equipment.deleted.',
|
|
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.',
|
|
description: 'Writes an ActivityLog entry: exercise.created.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'primaryMuscle'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
nameEn: { type: 'string', nullable: true },
|
|
primaryMuscle: { type: 'string' },
|
|
secondaryMuscles: { type: 'array', items: { type: 'string' } },
|
|
description: { type: 'string', nullable: true },
|
|
howTo: { type: 'string', nullable: true },
|
|
commonMistakes: { type: 'string', nullable: true },
|
|
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.',
|
|
description: 'Writes an ActivityLog entry: exercise.updated.',
|
|
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.',
|
|
description: 'Writes an ActivityLog entry: exercise.deleted.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/announcements': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: 'List all announcements or those of one gym (?gymId=) (admin)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'gymId', in: 'query', schema: { type: 'string' } }],
|
|
},
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Create an announcement — global (gymId null) or for a gym (admin)',
|
|
description: 'Writes an ActivityLog entry: announcement.published.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['title', 'body'],
|
|
properties: {
|
|
title: { type: 'string', maxLength: 120 },
|
|
body: { type: 'string', maxLength: 2000 },
|
|
gymId: { type: 'string', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/announcements/{id}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Edit a manual announcement (admin)',
|
|
description: 'Writes an ActivityLog entry: announcement.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['title', 'body'],
|
|
properties: {
|
|
title: { type: 'string', maxLength: 120 },
|
|
body: { type: 'string', maxLength: 2000 },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete a manual announcement (admin)',
|
|
description: 'Writes an ActivityLog entry: announcement.deleted.',
|
|
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.',
|
|
description: 'Writes an ActivityLog entry: focus_area.created.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'muscle'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
nameEn: { type: 'string', nullable: true },
|
|
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.',
|
|
description: 'Writes an ActivityLog entry: focus_area.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete a focus area (admin)',
|
|
description: 'Writes an ActivityLog entry: focus_area.deleted.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/equipment': {
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary:
|
|
'Create an equipment instance in a gym (admin); repeats of a catalog type create new instances. Optional spec overrides the catalog spec (validated against its kind)',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.added.',
|
|
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' },
|
|
quantity: { type: 'integer', minimum: 1, maximum: 10000 },
|
|
spec: { type: 'object', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/equipment/{instanceId}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary:
|
|
'Change quantity and/or spec override of an equipment instance (admin); spec:null clears the override',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'instanceId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
quantity: { type: 'integer', minimum: 1, maximum: 10000 },
|
|
spec: { type: 'object', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Remove an equipment instance (and its photos) from a gym (admin)',
|
|
description: 'Writes an ActivityLog entry: gym.equipment.removed.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'instanceId', 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 and only when no training day is still planned; an in-progress plan can only be abandoned)',
|
|
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 / plan has pending training days',
|
|
},
|
|
404: { description: 'Plan not found' },
|
|
},
|
|
},
|
|
},
|
|
'/plans/{id}/reopen': {
|
|
post: {
|
|
tags: ['Plans'],
|
|
summary:
|
|
'Reopen a completed or abandoned plan (back to ACTIVE; skipped days are not revived)',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
responses: {
|
|
200: { description: 'OK' },
|
|
400: { description: 'Only a completed or abandoned plan can be reopened' },
|
|
404: { description: 'Plan not found' },
|
|
409: { description: 'User already has an active plan' },
|
|
},
|
|
},
|
|
},
|
|
'/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 (+ rekord, daty skutecznych dni z 30 ostatnich), globalna historia (plany/sesje/serie, pierwsza/ostatnia sesja, serie wg tygodni), tempo tygodnia i postęp aktywnego planu',
|
|
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 REAL gym (admin; ownerId becomes OWNER member, address required)',
|
|
description: 'Writes an ActivityLog entry: gym.created.',
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
required: ['name', 'ownerId', 'addressLine1', 'postalCode', 'city'],
|
|
properties: {
|
|
name: { type: 'string' },
|
|
ownerId: { type: 'string', description: 'User mianowany właścicielem (OWNER)' },
|
|
addressLine1: {
|
|
type: 'string',
|
|
description: 'Ulica i numer, np. Mokotowska 12A',
|
|
},
|
|
addressLine2: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description: 'Lokal/piętro itp.',
|
|
},
|
|
postalCode: { type: 'string', description: 'Kod pocztowy 00-001' },
|
|
city: { type: 'string' },
|
|
countryCode: { type: 'string', default: 'PL', description: 'ISO 3166-1 alpha-2' },
|
|
location: {
|
|
type: 'string',
|
|
description:
|
|
'Pole derivowane z adresu (ulica, kod miasto[, kraj]) — nie do zapisu',
|
|
},
|
|
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)',
|
|
description: 'Writes an ActivityLog entry: gym.owner.granted.',
|
|
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)',
|
|
description: 'Writes an ActivityLog entry: gym.owner.revoked.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'userId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/exceptions': {
|
|
get: {
|
|
tags: ['Admin'],
|
|
summary: "List a gym's schedule exceptions (admin)",
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
post: {
|
|
tags: ['Admin'],
|
|
summary: 'Add a one-off schedule exception (admin)',
|
|
description: 'Writes an ActivityLog entry: gym.exception.added.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
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',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
'/admin/gyms/{id}/exceptions/{exceptionId}': {
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Remove a schedule exception (admin)',
|
|
description: 'Writes an ActivityLog entry: gym.exception.removed.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{ name: 'id', in: 'path', required: true, schema: { type: 'string' } },
|
|
{ name: 'exceptionId', in: 'path', required: true, schema: { type: 'string' } },
|
|
],
|
|
},
|
|
},
|
|
'/admin/gyms/{id}': {
|
|
patch: {
|
|
tags: ['Admin'],
|
|
summary: 'Update gym (admin; address fields recompute derived location)',
|
|
description: 'Writes an ActivityLog entry: gym.updated.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
name: { type: 'string' },
|
|
addressLine1: { type: 'string', nullable: true },
|
|
addressLine2: { type: 'string', nullable: true },
|
|
postalCode: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description: 'Kod pocztowy 00-001',
|
|
},
|
|
city: { type: 'string', nullable: true },
|
|
countryCode: {
|
|
type: 'string',
|
|
nullable: true,
|
|
description: 'ISO 3166-1 alpha-2',
|
|
},
|
|
availability: {
|
|
type: 'array',
|
|
nullable: true,
|
|
items: { type: 'object', nullable: true },
|
|
},
|
|
capacity: { type: 'integer', nullable: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete gym (admin; memberships removed, plans kept)',
|
|
description: 'Writes an ActivityLog entry: gym.deleted.',
|
|
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)',
|
|
description:
|
|
'Writes an ActivityLog entry: user.created (details: email, isAdmin — never the password).',
|
|
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 or status change revokes JWT via token_version). ' +
|
|
'Status: SUSPENDED requires future suspensionUntil, BANNED requires restrictionReason; ACTIVE clears both',
|
|
description:
|
|
'Writes ActivityLog entries by body content: user.updated (field names only), ' +
|
|
'user.status.changed (status/suspensionUntil/restrictionReason), user.admin.changed (isAdmin). Never logs the password.',
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
|
},
|
|
delete: {
|
|
tags: ['Admin'],
|
|
summary: 'Delete user (admin; plans/sessions cascade-deleted)',
|
|
description:
|
|
'Writes an ActivityLog entry: user.deleted (details: email — the account is gone).',
|
|
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)',
|
|
description:
|
|
'Writes an ActivityLog entry: membership.created (details: userId, gymId, roles).',
|
|
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)',
|
|
description:
|
|
'Writes an ActivityLog entry: membership.updated (details: userId, gymId, roles).',
|
|
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)',
|
|
description:
|
|
'Writes an ActivityLog entry: membership.deleted (details: userId, gymId, roles).',
|
|
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: ['typeId', 'value'],
|
|
properties: {
|
|
typeId: {
|
|
type: 'string',
|
|
enum: ['chest', 'waist', 'hips', 'neck', 'biceps', 'forearm', 'thigh', 'calf'],
|
|
},
|
|
side: { type: 'string', enum: ['left', 'right'], nullable: true },
|
|
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' } }],
|
|
},
|
|
},
|
|
},
|
|
};
|