Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 2.26 KB

File metadata and controls

60 lines (49 loc) · 2.26 KB

CreateSessionReportUsecase

Purpose

Starts a session report for an athlete.

Trigger / entry point

  • Internal invocation through dependency injection (Inversify).

Inputs

Name Required Type Description
dto Yes object Use case input DTO (see implementation file).

Preconditions

  • Input DTO must respect constraints enforced by the implementation.
  • Caller context/authorization must satisfy business checks implemented in the use case.
  • Coaches creating reports for athletes must have an active link (verified via ResolveCoachAthleteVisibilityUsecase).

Main flow

  1. Validates input/access constraints defined in execute and assertCreationRights.
  2. Verifies coach-athlete link if requester is a COACH.
  3. Validates and sanitizes optional set payload values (repetitions, charge, rpe).
  4. Validates optional fatigue payload.
  5. Uses bddService to persist the session report.
  6. Uses getProgramUsecase to ensure program accessibility.

Outputs / side effects

  • Returns the created or existing session report.
  • Persists domain state changes in the database.
  • Logs execution errors.

Error cases / edge cases

  • Throws ERRORS.COACH_ATHLETE_VISIBILITY_FORBIDDEN if a coach attempts to create a report for an unauthorized athlete.
  • Throws 'INVALID_EVENT_DATE' when the corresponding guard/validation fails.
  • Throws 'INVALID_SESSION_REPORT_FATIGUE' when fatigue payload is invalid.
  • Throws 'INVALID_SESSION_REPORT_SET_PAYLOAD' when set payload contains invalid values.
  • Throws ERRORS.FORBIDDEN when the corresponding guard/validation fails.
  • Normalizes or references error code ERRORS.CREATE_SESSION_REPORT_USECASE.

Dependencies

  • bddService
  • getProgramUsecase
  • loggerService
  • resolveCoachAthleteVisibilityUsecase

Related files

  • api/src/usecases/sport/session-report/create.session-report.usecase.ts
  • api/src/usecases/sport/session-report/__tests__/create.session-report.usecase.spec.ts

Example

{
  "dto": "see implementation DTO"
}

Notes / limitations

  • This document is generated from code and should be updated whenever behavior changes in implementation.
  • If helper modules define additional rules, they are authoritative over this summary.