LCOV - code coverage report
Current view: top level - schemas/api - events.clj Coverage Total Hit
Test: lcov.info Lines: 99.5 % 192 191
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.api.events
       2              :   (:require
       3              :    [schemas.api.common :as api-common-schemas]
       4              :    [schemas.domain.event-participants :as domain-event-participant-schemas]))
       5              : 
       6              : 
       7            4 : (def PaymentReminderSchema
       8            8 :   [:and
       9            8 :    [:map
      10           12 :     [:enabled :boolean]
      11           20 :     [:timing {:optional true}
      12           16 :      [:enum "before-start" "after-start"]]
      13           20 :     [:hours {:optional true}
      14           28 :      [:int {:min 0
      15              :             :max 168}]]
      16           20 :     [:payment-method-ids {:optional true}
      17           20 :      [:vector [:ref :types/UuidString]]]
      18           20 :     [:payment-purpose {:optional true}
      19           28 :      [:maybe [:string {:max 160}]]]]
      20           20 :    [:fn {:error/message
      21              :          "Enabled payment reminders require timing, hours, and at least one payment method"}
      22            4 :     (fn [{:keys [enabled timing hours payment-method-ids]}]
      23            0 :      (or (not enabled) (and timing (some? hours) (seq payment-method-ids))))]])
      24              : 
      25              : 
      26            4 : (def EventRequestSchema
      27              :   "Event schema for create and update requests."
      28           28 :   [:and {:swagger/title       "EventSchema"
      29              :          :swagger/description "Event request schema"}
      30            8 :    [:map
      31           20 :     [:uuid {:optional true}
      32           20 :      [:maybe [:ref :types/UuidString]]]
      33           20 :     [:template-id {:optional true}
      34           20 :      [:maybe [:ref :types/UuidString]]]
      35           20 :     [:image-ids {:optional true}
      36           20 :      [:vector {:max 10}
      37           12 :       [:ref :types/UuidString]]]
      38           20 :     [:images-version {:optional true}
      39           20 :      [:int {:min 0}]]
      40           20 :     [:datetime-start {:optional true}
      41           12 :      [:maybe api-common-schemas/DatetimeStringSchema]]
      42           20 :     [:datetime-end {:optional true}
      43           12 :      [:maybe api-common-schemas/DatetimeStringSchema]]
      44           20 :     [:state {:optional true}
      45            8 :      [:maybe
      46           28 :       [:string {:min 1
      47              :                 :max 50}]]]
      48           20 :     [:visibility {:optional true}
      49            8 :      (into
      50           20 :       [:enum {:error/message "Visibility must be public or private"}]
      51            4 :       api-common-schemas/visibility-options)]
      52           20 :     [:club-id {:optional true}
      53           20 :      [:maybe [:ref :types/UuidString]]]
      54           20 :     [:club-ids {:optional true}
      55           28 :      [:maybe [:sequential [:ref :types/UuidString]]]]
      56           20 :     [:name {:optional true}
      57           28 :      [:maybe [:string {:max 255}]]]
      58           20 :     [:fee {:optional true}
      59           12 :      [:maybe api-common-schemas/NonNegativeNumber]]
      60           20 :     [:fee-type {:optional true}
      61           24 :      [:maybe [:enum "total" "per-person"]]]
      62           20 :     [:currency {:optional true}
      63            8 :      [:maybe
      64            8 :       (into
      65           20 :        [:enum {:error/message "Currency must be one of the supported options"}]
      66            4 :        api-common-schemas/currency-options)]]
      67           20 :     [:duration {:optional true}
      68           28 :      [:maybe [:int {:min 1}]]]
      69           28 :     [:score-entry-mode {:optional true
      70              :                         :default  "either"}
      71            8 :      (into
      72           20 :       [:enum {:error/message "Score entry mode must be sets, game, or either"}]
      73            4 :       api-common-schemas/score-entry-mode-options)]
      74           28 :     [:score-entry-default {:optional true
      75              :                            :default  "game"}
      76            8 :      (into
      77           20 :       [:enum {:error/message "Default score entry must be sets or game"}]
      78            4 :       api-common-schemas/score-entry-default-options)]
      79           20 :     [:timezone {:optional true}
      80           28 :      [:maybe [:string {:max 100}]]]
      81           20 :     [:language {:optional true}
      82           24 :      [:maybe [:enum "en" "uk"]]]
      83           20 :     [:description {:optional true}
      84           12 :      [:maybe :string]]
      85           20 :     [:sport-code {:optional true}
      86            8 :      [:maybe
      87            8 :       (into
      88           20 :        [:enum {:error/message "Sport code must be one of the supported options"}]
      89            4 :        api-common-schemas/sport-options)]]
      90           20 :     [:activity-type-code {:optional true}
      91            8 :      [:maybe
      92            8 :       (into
      93           20 :        [:enum {:error/message "Activity type code must be one of the supported options"}]
      94            4 :        api-common-schemas/activity-type-options)]]
      95           20 :     [:settings {:optional true}
      96            8 :      [:maybe
      97            8 :       [:map
      98           20 :        [:payments-enabled {:optional true}
      99           12 :         [:maybe :boolean]]
     100           20 :        [:payment-reminder {:optional true}
     101            4 :         PaymentReminderSchema]
     102           20 :        [:telegram-match-notifications-enabled {:optional true}
     103           12 :         [:maybe :boolean]]
     104              :        ;; The event's court plan from the stage planner: the courts in use from
     105              :        ;; :from minutes after the event start (club resource uuids), in time order.
     106           20 :        [:courts {:optional true}
     107           72 :         [:maybe [:sequential [:map [:from [:int {:min 0}]] [:ids [:sequential :string]]]]]]]]]]])
     108              : 
     109              : 
     110            4 : (def EventCreateRequestSchema
     111              :   "Event creation input. Capacity belongs to the initial default class, not the event."
     112            8 :   (->
     113            4 :     EventRequestSchema
     114           24 :     (assoc-in [1 :swagger/title] "EventCreateSchema")
     115            4 :     (update
     116              :      2
     117            4 :      conj
     118           20 :      [:default-class-max-players {:optional true}
     119           28 :       [:maybe [:int {:min 1}]]])))
     120              : 
     121              : 
     122            4 : (def EventPathParamsSchema
     123           20 :   [:map {:swagger/title "EventPathParamsSchema"}
     124           28 :    [:event-uuid {:description "Event UUID in v7 format"
     125              :                  :example     "550e8400-e29b-41d4-a716-446655440000"}
     126           12 :     [:ref :types/UuidString]]])
     127              : 
     128              : 
     129            4 : (def EventStateUpdateRequestSchema
     130           28 :   [:map {:swagger/title       "EventStateUpdateRequestSchema"
     131              :          :swagger/description "Event state update request"}
     132            8 :    [:state
     133           36 :     [:enum {:error/message "State must be scheduled, active, completed, or cancelled"}
     134              :      "scheduled" "active"
     135              :      "completed" "cancelled"]]
     136           20 :    [:note {:optional true}
     137           28 :     [:maybe [:string {:max 1000}]]]
     138           24 :    [:notify-linked-chats {:optional true}
     139              :     :boolean]
     140           24 :    [:notify-participants {:optional true}
     141              :     :boolean]])
     142              : 
     143              : 
     144            4 : (def EventResponseSuccess201Body
     145           28 :   [:map {:swagger/title       "EventResponseSuccess201Body"
     146              :          :swagger/description "Successful event creation response"}
     147           28 :    [:message [:string {:example "Event has been successfully created."}]]
     148           48 :    [:data [:or [:ref :domain/EventRecord] [:vector [:ref :domain/EventRecord]]]]])
     149              : 
     150              : 
     151            4 : (def EventResponseSuccess200Body
     152           28 :   [:map {:swagger/title       "EventResponseSuccess200Body"
     153              :          :swagger/description "Successful event update response"}
     154           28 :    [:message [:string {:example "Event updated successfully."}]]
     155           48 :    [:data [:or [:ref :domain/EventRecord] [:vector [:ref :domain/EventRecord]]]]])
     156              : 
     157              : 
     158            4 : (def EventResponseError400Body
     159           28 :   [:map {:swagger/title       "EventResponseError400Body"
     160              :          :swagger/description "Bad request error response"}
     161           28 :    [:message [:string {:example "Invalid request data"}]]
     162           12 :    [:error :map]])
     163              : 
     164              : 
     165            4 : (def EventCreateResponseSchema
     166              :   "Union of possible event create responses."
     167            8 :   [:or
     168           40 :    [:map [:status [:= 201]] [:body EventResponseSuccess201Body]]
     169           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]])
     170              : 
     171              : 
     172            4 : (def EventUpdateResponseSchema
     173              :   "Union of possible event update responses."
     174            8 :   [:or
     175           40 :    [:map [:status [:= 200]] [:body EventResponseSuccess200Body]]
     176           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]])
     177              : 
     178              : 
     179            4 : (def EventStateUpdateResponseSchema
     180              :   "Union of possible event state update responses."
     181            8 :   [:or
     182           40 :    [:map [:status [:= 200]] [:body EventResponseSuccess200Body]]
     183           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]
     184           56 :    [:map [:status [:= 404]] [:body [:map [:message :string]]]]])
     185              : 
     186              : 
     187            4 : (def ParticipantAddRolesSchema
     188              :   "Roles given to a newly added participant. Defaults to `[\"player\"]` when omitted."
     189            8 :   [:maybe
     190           28 :    [:vector {:min 1
     191              :              :max 2}
     192           16 :     [:enum "player" "admin"]]])
     193              : 
     194              : 
     195            4 : (def EventAddParticipantRequestSchema
     196           20 :   [:map {:swagger/title "EventAddParticipantRequestSchema"}
     197           20 :    [:user-uuid [:ref :types/UuidString]]
     198           28 :    [:class-uuid {:optional true
     199              :                  :description
     200              :                  "Class to add the user to. A player needs a class when the event has several."}
     201           20 :     [:maybe [:ref :types/UuidString]]]
     202            8 :    [:class-uuids
     203           20 :     {:optional true
     204              :      :description
     205              :      "Classes to add the user to, in addition to `class_uuid`. All must belong to the event."}
     206           28 :     [:maybe [:vector [:ref :types/UuidString]]]]
     207            8 :    [:roles
     208           20 :     {:optional true
     209              :      :description
     210              :      "Event roles of the new participant (`player`, `admin`). Defaults to `[\"player\"]`. Without `player` the user may be added without a class."}
     211            4 :     ParticipantAddRolesSchema]])
     212              : 
     213              : 
     214            4 : (def EventAddParticipantSuccess201Body
     215           20 :   [:map {:swagger/title "EventAddParticipantSuccess201Body"}
     216           12 :    [:message :string]
     217           20 :    [:data [:ref :domain/EventParticipantRecord]]
     218           20 :    [:class-participant {:optional true}
     219           20 :     [:maybe [:ref :domain/ClassParticipantRecord]]]
     220           20 :    [:class-participants {:optional true}
     221           28 :     [:maybe [:vector [:ref :domain/ClassParticipantRecord]]]]])
     222              : 
     223              : 
     224            4 : (def EventAddParticipantResponseSchema
     225            8 :   [:or
     226           40 :    [:map [:status [:= 201]] [:body EventAddParticipantSuccess201Body]]
     227           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]
     228           40 :    [:map [:status [:= 404]] [:body EventResponseError400Body]]])
     229              : 
     230              : 
     231            4 : (def EventParticipantPathParamsSchema
     232           20 :   [:map {:swagger/title "EventParticipantPathParamsSchema"}
     233           28 :    [:event-uuid {:description "Event UUID in v7 format"
     234              :                  :example     "550e8400-e29b-41d4-a716-446655440000"}
     235           12 :     [:ref :types/UuidString]]
     236           28 :    [:participant-uuid {:description "Event participant UUID"
     237              :                        :example     "550e8400-e29b-41d4-a716-446655440001"}
     238           12 :     [:ref :types/UuidString]]])
     239              : 
     240              : 
     241            4 : (def EventUpdateParticipantRequestSchema
     242           20 :   [:map {:swagger/title "EventUpdateParticipantRequestSchema"}
     243           20 :    [:status {:optional true}
     244           12 :     [:maybe domain-event-participant-schemas/ParticipantStatusSchema]]
     245           20 :    [:roles {:optional true}
     246            8 :     [:maybe
     247            8 :      [:vector
     248           28 :       [:string {:min 1
     249              :                 :max 50}]]]]])
     250              : 
     251              : 
     252            4 : (def EventUpdateParticipantSuccess200Body
     253           20 :   [:map {:swagger/title "EventUpdateParticipantSuccess200Body"}
     254           12 :    [:message :string]
     255           20 :    [:data [:ref :domain/EventParticipantRecord]]])
     256              : 
     257              : 
     258            4 : (def EventEndResponseSchema
     259              :   "Union of possible event end responses."
     260            8 :   [:or
     261           40 :    [:map [:status [:= 200]] [:body EventResponseSuccess200Body]]
     262           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]
     263           56 :    [:map [:status [:= 404]] [:body [:map [:message :string]]]]])
     264              : 
     265              : 
     266            4 : (def EventUpdateParticipantResponseSchema
     267            8 :   [:or
     268           40 :    [:map [:status [:= 200]] [:body EventUpdateParticipantSuccess200Body]]
     269           40 :    [:map [:status [:= 400]] [:body EventResponseError400Body]]
     270           56 :    [:map [:status [:= 404]] [:body [:map [:message :string]]]]])
        

Generated by: LCOV version 2.0-1