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

            Line data    Source code
       1            4 : (ns schemas.api.templates
       2              :   (:require
       3              :    [schemas.api.common :as api-common-schemas]
       4              :    [schemas.types :as types-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 BaseTemplateSchema
      27           36 :   [:map {:swagger/title       "BaseTemplateSchema"
      28              :          :swagger/description "Base schema for template data"
      29              :          :swagger/exclude     true}
      30           20 :    [:uuid {:optional true}
      31           20 :     [:maybe [:ref :types/UuidString]]]
      32           20 :    [:image-ids {:optional true}
      33           20 :     [:vector {:max 10}
      34           12 :      [:ref :types/UuidString]]]
      35           20 :    [:images-version {:optional true}
      36           20 :     [:int {:min 0}]]
      37           28 :    [:sport-code (into [:enum] api-common-schemas/sport-options)]
      38           28 :    [:activity-type-code (into [:enum] api-common-schemas/activity-type-options)]
      39           20 :    [:name {:optional true}
      40            8 :     [:or
      41           28 :      [:string {:min 0
      42              :                :max 255}]
      43            8 :      [:nil]]]
      44           20 :    [:description {:optional true}
      45           20 :     [:or :string [:nil]]]
      46           20 :    [:state {:default "active"}
      47           28 :     [:string {:min 1
      48              :               :max 50}]]
      49           28 :    [:visibility {:optional true
      50              :                  :default  "public"}
      51            8 :     (into
      52           20 :      [:enum {:error/message "Visibility must be public or private"}]
      53            4 :      api-common-schemas/visibility-options)]
      54           20 :    [:club-id {:optional true}
      55           20 :     [:maybe [:ref :types/UuidString]]]
      56           20 :    [:club-ids {:optional true}
      57           28 :     [:maybe [:sequential [:ref :types/UuidString]]]]
      58           12 :    [:fee api-common-schemas/NonNegativeNumber]
      59           24 :    [:fee-type [:enum "total" "per-person"]]
      60            8 :    [:currency
      61            8 :     (into
      62           20 :      [:enum {:error/message "Currency must be one of the supported options"}]
      63            4 :      api-common-schemas/currency-options)]
      64            8 :    [:timezone
      65            8 :     (into
      66           20 :      [:enum {:error/message "Timezone must be one of the supported options"}]
      67            4 :      api-common-schemas/timezone-options)]
      68           20 :    [:language {:optional true}
      69           24 :     [:maybe [:enum "en" "uk"]]]
      70           20 :    [:duration {:optional true}
      71           28 :     [:maybe [:int {:min 1}]]]
      72           28 :    [:score-entry-mode {:optional true
      73              :                        :default  "either"}
      74            8 :     (into
      75           20 :      [:enum {:error/message "Score entry mode must be sets, game, or either"}]
      76            4 :      api-common-schemas/score-entry-mode-options)]
      77           28 :    [:score-entry-default {:optional true
      78              :                           :default  "game"}
      79            8 :     (into
      80           20 :      [:enum {:error/message "Default score entry must be sets or game"}]
      81            4 :      api-common-schemas/score-entry-default-options)]
      82           24 :    [:automatic-event-creation {:optional true}
      83              :     :boolean]
      84           20 :    [:automatic-event-creation-delay-minutes {:optional true}
      85           28 :     [:int {:min 1
      86              :            :max 525600}]]
      87           20 :    [:rrule {:optional true}
      88           28 :     [:maybe [:string {:max 512}]]]
      89           20 :    [:rrule-json {:optional true}
      90           12 :     [:maybe :map]]
      91           20 :    [:ruleset-id {:optional true}
      92           20 :     [:maybe [:ref :types/UuidString]]]
      93           20 :    [:settings {:optional true}
      94            8 :     [:maybe
      95            8 :      [:map
      96           20 :       [:payments-enabled {:optional true}
      97           12 :        [:maybe :boolean]]
      98           20 :       [:payment-reminder {:optional true}
      99            4 :        PaymentReminderSchema]
     100           20 :       [:telegram-match-notifications-enabled {:optional true}
     101           12 :        [:maybe :boolean]]]]]])
     102              : 
     103              : 
     104            4 : (def TemplateRequestSchema
     105              :   "Template schema with swagger metadata wrapper for OpenAPI generation."
     106           28 :   [:and {:swagger/title       "EventTemplateSchema"
     107              :          :swagger/description "Template request schema"}
     108            4 :    BaseTemplateSchema])
     109              : 
     110              : 
     111            4 : (def TemplateCreateRequestSchema
     112              :   "Template creation input. Capacity belongs to the initial default class template."
     113            8 :   (->
     114            4 :     TemplateRequestSchema
     115           24 :     (assoc-in [1 :swagger/title] "EventTemplateCreateSchema")
     116            4 :     (update
     117              :      2
     118            4 :      conj
     119           20 :      [:default-class-max-players {:optional true}
     120           28 :       [:maybe [:int {:min 1}]]])))
     121              : 
     122              : 
     123            4 : (def TemplatePathParamsSchema
     124           20 :   [:map {:swagger/title "TemplatePathParamsSchema"}
     125           28 :    [:template-uuid {:description "Template UUID in v7 format"
     126              :                     :example     "550e8400-e29b-41d4-a716-446655440000"}
     127            4 :     types-schemas/UuidString]])
     128              : 
     129              : 
     130            4 : (def TemplateOccurrenceExceptionPathParamsSchema
     131           20 :   [:map {:swagger/title "TemplateOccurrenceExceptionPathParamsSchema"}
     132           12 :    [:template-uuid types-schemas/UuidString]
     133           12 :    [:exception-uuid types-schemas/UuidString]])
     134              : 
     135              : 
     136            4 : (def TemplateOccurrenceExceptionRequestSchema
     137           28 :   [:map {:swagger/title       "TemplateOccurrenceExceptionRequestSchema"
     138              :          :swagger/description "Skip one occurrence of a recurring event template"}
     139           12 :    [:occurrence-start api-common-schemas/DatetimeStringSchema]
     140           20 :    [:note {:optional true}
     141           28 :     [:maybe [:string {:max 1000}]]]
     142           32 :    [:notify-linked-chats {:optional true
     143              :                           :default  false}
     144              :     :boolean]
     145           32 :    [:notify-participants {:optional true
     146              :                           :default  false}
     147              :     :boolean]])
     148              : 
     149              : 
     150            4 : (def TemplateOccurrenceExceptionSchema
     151            8 :   [:map
     152           12 :    [:uuid types-schemas/UuidString]
     153           12 :    [:template-id types-schemas/UuidString]
     154           12 :    [:occurrence-start api-common-schemas/DatetimeStringSchema]
     155           20 :    [:note [:maybe :string]]
     156           12 :    [:notify-linked-chats :boolean]
     157           12 :    [:notify-participants :boolean]
     158           20 :    [:created-by [:maybe types-schemas/UuidString]]
     159           12 :    [:created-datetime api-common-schemas/DatetimeStringSchema]
     160           12 :    [:updated-datetime api-common-schemas/DatetimeStringSchema]])
     161              : 
     162              : 
     163            4 : (def TemplateOccurrenceExceptionListResponseSchema
     164            8 :   [:map
     165           20 :    [:status [:= 200]]
     166           48 :    [:body [:map [:message :string] [:data [:vector TemplateOccurrenceExceptionSchema]]]]])
     167              : 
     168              : 
     169            4 : (def TemplateOccurrenceExceptionResponseSchema
     170            8 :   [:or
     171            8 :    [:map
     172           24 :     [:status [:enum 200 201]]
     173           40 :     [:body [:map [:message :string] [:data TemplateOccurrenceExceptionSchema]]]]
     174            8 :    [:map
     175           24 :     [:status [:enum 400 404]]
     176            8 :     [:body
     177            8 :      [:map
     178           12 :       [:message :string]
     179           24 :       [:error {:optional true}
     180              :        :map]]]]])
     181              : 
     182              : 
     183            4 : (def TemplateResponseSuccess201Body
     184           28 :   [:map {:swagger/title       "TemplateResponseSuccess201Body"
     185              :          :swagger/description "Successful template creation response"}
     186           28 :    [:message [:string {:example "Template has been successfully created."}]]
     187           48 :    [:data [:or [:ref :domain/TemplateRecord] [:vector [:ref :domain/TemplateRecord]]]]])
     188              : 
     189              : 
     190            4 : (def TemplateResponseSuccess200Body
     191           28 :   [:map {:swagger/title       "TemplateResponseSuccess200Body"
     192              :          :swagger/description "Successful template retrieval/update response"}
     193           28 :    [:message [:string {:example "Template retrieved successfully."}]]
     194           48 :    [:data [:or [:ref :domain/TemplateRecord] [:vector [:ref :domain/TemplateRecord]]]]])
     195              : 
     196              : 
     197            4 : (def TemplateResponseError400Body
     198           28 :   [:map {:swagger/title       "TemplateResponseError400Body"
     199              :          :swagger/description "Bad request error response"}
     200           28 :    [:message [:string {:example "Invalid request data"}]]
     201           12 :    [:error :map]])
     202              : 
     203              : 
     204            4 : (def TemplateResponseError404Body
     205           28 :   [:map {:swagger/title       "TemplateResponseError404Body"
     206              :          :swagger/description "Template not found error response"}
     207           28 :    [:message [:string {:example "Template not found."}]]
     208           20 :    [:error {:optional true}
     209           20 :     [:string {:example "EVENT_TEMPLATE_NOT_FOUND"}]]])
     210              : 
     211              : 
     212            4 : (def TemplateResponseError403Body
     213           28 :   [:map {:swagger/title       "TemplateResponseError403Body"
     214              :          :swagger/description "Access denied error response"}
     215           28 :    [:message [:string {:example "Access denied."}]]
     216           28 :    [:error [:string {:example "ACCESS_DENIED"}]]])
     217              : 
     218              : 
     219            4 : (def TemplateResponseSchema
     220              :   "Union of possible template responses."
     221            8 :   [:or
     222           40 :    [:map [:status [:= 200]] [:body TemplateResponseSuccess200Body]]
     223           40 :    [:map [:status [:= 201]] [:body TemplateResponseSuccess201Body]]
     224           40 :    [:map [:status [:= 400]] [:body TemplateResponseError400Body]]
     225           40 :    [:map [:status [:= 403]] [:body TemplateResponseError403Body]]
     226           40 :    [:map [:status [:= 404]] [:body TemplateResponseError404Body]]])
     227              : 
     228              : 
     229            4 : (def TemplateTelegramAccessSuccess200BodySchema
     230           28 :   [:map {:swagger/title       "TemplateTelegramAccessSuccess200Body"
     231              :          :swagger/description "Telegram-membership view-access grant result"}
     232           12 :    [:message :string]
     233           12 :    [:granted :boolean]])
     234              : 
     235              : 
     236            4 : (def TemplateTelegramAccessResponseSchema
     237              :   "Union of possible Telegram view-access responses."
     238            8 :   [:or
     239           40 :    [:map [:status [:= 200]] [:body TemplateTelegramAccessSuccess200BodySchema]]
     240           40 :    [:map [:status [:= 400]] [:body TemplateResponseError400Body]]])
     241              : 
     242              : 
     243            4 : (def TemplateAddParticipantRequestSchema
     244           20 :   [:map {:swagger/title "TemplateAddParticipantRequestSchema"}
     245           12 :    [:user-uuid types-schemas/UuidString]
     246            8 :    [:roles
     247           20 :     {:optional true
     248              :      :description
     249              :      "Template roles of the new participant (`player`, `admin`). Defaults to `[\"player\"]`."}
     250            8 :     [:maybe
     251           28 :      [:vector {:min 1
     252              :                :max 2}
     253           16 :       [:enum "player" "admin"]]]]])
     254              : 
     255              : 
     256            4 : (def TemplateParticipantPathParamsSchema
     257           20 :   [:map {:swagger/title "TemplateParticipantPathParamsSchema"}
     258           28 :    [:template-uuid {:description "Template public id"
     259              :                     :example     "i4xpuEpAc9n_"}
     260           20 :     [:string {:min 1}]]
     261           28 :    [:participant-uuid {:description "Template participant (participant) UUID"
     262              :                        :example     "550e8400-e29b-41d4-a716-446655440001"}
     263            4 :     types-schemas/UuidString]])
     264              : 
     265              : 
     266            4 : (def TemplateUpdateParticipantRequestSchema
     267           20 :   [:map {:swagger/title "TemplateUpdateParticipantRequestSchema"}
     268           20 :    [:status {:optional true}
     269           28 :     [:maybe [:enum "registered" "confirmed" "withdrawn"]]]
     270           20 :    [:roles {:optional true}
     271            8 :     [:maybe
     272            8 :      [:vector
     273           28 :       [:string {:min 1
     274              :                 :max 50}]]]]])
     275              : 
     276              : 
     277            4 : (def TemplateAddParticipantResponseSchema
     278            8 :   [:or
     279           56 :    [:map [:status [:= 201]] [:body [:map [:message :string]]]]
     280           56 :    [:map [:status [:= 400]] [:body [:map [:message :string]]]]])
     281              : 
     282              : 
     283            4 : (def TemplateUpdateParticipantResponseSchema
     284            8 :   [:or
     285           56 :    [:map [:status [:= 200]] [:body [:map [:message :string]]]]
     286           56 :    [:map [:status [:= 400]] [:body [:map [:message :string]]]]
     287           56 :    [:map [:status [:= 404]] [:body [:map [:message :string]]]]])
        

Generated by: LCOV version 2.0-1