@@ -52,10 +52,6 @@ module Wire.API.User
5252 AppInfo (.. ),
5353 PutApp (.. ),
5454 Category (.. ),
55- categoryTextMapping ,
56- categoryMap ,
57- categoryFromText ,
58- categoryToText ,
5955 CreatedApp (.. ),
6056 RefreshAppCookieResponse (.. ),
6157
@@ -184,7 +180,6 @@ import Data.Default
184180import Data.Domain (Domain (Domain ))
185181import Data.Either.Extra (maybeToEither )
186182import Data.Handle (Handle )
187- import Data.HashMap.Strict qualified as HM
188183import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
189184import Data.Id
190185import Data.Json.Util (UTCTimeMillis , (#) )
@@ -2125,68 +2120,15 @@ data PutApp = PutApp
21252120 deriving (Arbitrary ) via (GenericUniform PutApp )
21262121 deriving (A.FromJSON , A.ToJSON , S.ToSchema ) via Schema PutApp
21272122
2128- data Category
2129- = Security
2130- | Collaboration
2131- | Productivity
2132- | Automation
2133- | Files
2134- | AI
2135- | Developer
2136- | Support
2137- | Finance
2138- | HR
2139- | Integration
2140- | Compliance
2141- | Other
2123+ newtype Category = Category { fromCategory :: Text }
21422124 deriving (Eq , Ord , Show , Read , Generic )
21432125 deriving (Arbitrary ) via GenericUniform Category
21442126 deriving (A.FromJSON , A.ToJSON , S.ToSchema ) via (Schema Category )
21452127
2146- categoryTextMapping :: [(Text , Category )]
2147- categoryTextMapping =
2148- [ (" security" , Security ),
2149- (" collaboration" , Collaboration ),
2150- (" productivity" , Productivity ),
2151- (" automation" , Automation ),
2152- (" files" , Files ),
2153- (" ai" , AI ),
2154- (" developer" , Developer ),
2155- (" support" , Support ),
2156- (" finance" , Finance ),
2157- (" hr" , HR ),
2158- (" integration" , Integration ),
2159- (" compliance" , Compliance ),
2160- (" other" , Other )
2161- ]
2162-
2163- categoryMap :: HM. HashMap Text Category
2164- categoryMap = HM. fromList categoryTextMapping
2165-
2166- categoryFromText :: Text -> Maybe Category
2167- categoryFromText text' = HM. lookup text' categoryMap
2168-
2169- categoryToText :: Category -> Text
2170- categoryToText = \ case
2171- Security -> " security"
2172- Collaboration -> " collaboration"
2173- Productivity -> " productivity"
2174- Automation -> " automation"
2175- Files -> " files"
2176- AI -> " ai"
2177- Developer -> " developer"
2178- Support -> " support"
2179- Finance -> " finance"
2180- HR -> " hr"
2181- Integration -> " integration"
2182- Compliance -> " compliance"
2183- Other -> " other"
2184-
21852128instance ToSchema Category where
2186- schema =
2187- enum @ Text " Category" $
2188- mconcat $
2189- map (uncurry element) categoryTextMapping
2129+ schema = over doc desc (Category <$> fromCategory .= schema @ Text )
2130+ where
2131+ desc = S. description ?~ " Category name (if uncertain, pick \" other\" )"
21902132
21912133instance ToSchema NewApp where
21922134 schema =
0 commit comments