-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAPI.hs
More file actions
77 lines (67 loc) · 2.98 KB
/
API.hs
File metadata and controls
77 lines (67 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
module Share.Web.API where
import Crypto.JOSE.JWK qualified as JWK
import Servant
import Share.OAuth.API qualified as OAuth
import Share.OAuth.Session (MaybeAuthenticatedSession, MaybeAuthenticatedUserId)
import Share.Prelude
import Share.Web.Admin.API qualified as Admin
import Share.Web.Local.API qualified as Local
import Share.Web.Share.API qualified as Share
import Share.Web.Share.Orgs.API qualified as Orgs
import Share.Web.Share.Projects.API qualified as Projects
import Share.Web.Share.Users.API qualified as Users
import Share.Web.Share.Webhooks.API qualified as Webhooks
import Share.Web.Support.API qualified as Support
import Share.Web.Types
import Share.Web.UCM.SyncV2.API qualified as SyncV2
import Unison.Server.HistoryComments.API qualified as Unison.HistoryComments
import Unison.Share.API.Projects qualified as UCMProjects
import Unison.Sync.API qualified as Unison.Sync
-- Some APIs are pulled out separately to make building clients easier.
type OrgsAPI = ("orgs" :> Orgs.API)
type UsersAPI = ("users" :> Users.API)
type API =
OAuth.ServiceProviderAPI
:<|> OAuth.IdentityProviderAPI
:<|> ("codebases" :> Share.UserPublicCodebaseAPI)
:<|> UsersAPI
:<|> OrgsAPI
:<|> ("search" :> Share.OmniSearchEndpoint)
:<|> ("search-names" :> Share.SearchDefinitionNamesEndpoint)
:<|> ("search-definitions" :> Share.SearchDefinitionsEndpoint)
:<|> ("account" :> Share.AccountAPI)
:<|> ("catalog" :> Projects.CatalogAPI)
:<|> ( ".well-known"
:> (
-- This path is part of the standard: https://datatracker.ietf.org/doc/html/rfc5785
("openid-configuration" :> DiscoveryEndpoint)
-- This path is convention, the location is provided explicitly as part of
-- the discovery document's jwks_uri field.
:<|> ("jwks.json" :> JWKSEndpoint)
)
)
:<|> ("user-info" :> UserInfoEndpoint)
:<|> ("support" :> Support.API)
:<|> ("local" :> Local.API)
:<|> ("health" :> HealthEndpoint)
-- This path is deprecated, but is still in use by existing clients.
:<|> ("sync" :> MaybeAuthenticatedSession :> Unison.Sync.API)
:<|> ("ucm" :> "v1" :> "sync" :> MaybeAuthenticatedSession :> Unison.Sync.API)
:<|> ("ucm" :> "v1" :> "history-comments" :> MaybeAuthenticatedUserId :> Unison.HistoryComments.API)
:<|> ("ucm" :> "v1" :> "projects" :> MaybeAuthenticatedSession :> UCMProjects.ProjectsAPI)
:<|> ("ucm" :> "v2" :> "sync" :> MaybeAuthenticatedUserId :> SyncV2.API)
:<|> ("admin" :> Admin.API)
:<|> ("webhooks" :> Webhooks.API)
api :: Proxy API
api = Proxy @API
-- | https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest
type DiscoveryEndpoint =
Get '[JSON] DiscoveryDocument
type JWKSEndpoint =
Get '[JSON] JWK.JWKSet
type UserInfoEndpoint =
MaybeAuthenticatedSession :> Get '[JSON] UserInfo
type HealthEndpoint =
Get '[PlainText] Text