Plany: PATCH z startDate (aktywacja przy zapisie) i udostepnianie planow trener-podopieczny (PlanShare, sekcja Udostepnione mi, widok read-only)

This commit is contained in:
tisachi
2026-09-13 02:28:29 +02:00
parent 8049c4bc47
commit 1f29ce7003
19 changed files with 1791 additions and 76 deletions

View File

@@ -127,6 +127,13 @@ export const openapi: Record<string, unknown> = {
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'],
@@ -538,19 +545,42 @@ export const openapi: Record<string, unknown> = {
},
},
},
'/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',
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)',
'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',
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' },
409: { description: 'User already has an active plan' },
},
},
delete: {
tags: ['Plans'],
@@ -595,6 +625,50 @@ export const openapi: Record<string, unknown> = {
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
},
},
'/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'],