Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Commit

Permalink
Rename Lib.Api to Lib.HttpApi
Browse files Browse the repository at this point in the history
  • Loading branch information
hojberg committed Apr 6, 2022
1 parent e7ec23d commit 943f310
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/Code/CodebaseApi.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Code.EntityId exposing (EntityId)
import Code.FullyQualifiedName exposing (FQN)
import Code.Perspective exposing (Perspective)
import Code.Syntax as Syntax
import Lib.Api as Api
import Lib.HttpApi as HttpApi



Expand Down Expand Up @@ -34,4 +34,4 @@ type CodebaseEndpoint


type alias ToApiEndpointUrl =
CodebaseEndpoint -> Api.EndpointUrl
CodebaseEndpoint -> HttpApi.EndpointUrl
8 changes: 4 additions & 4 deletions src/Code/CodebaseTree.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Html exposing (Html, a, div, label, span, text)
import Html.Attributes exposing (class, title)
import Html.Events exposing (onClick)
import Http
import Lib.Api as Api exposing (ApiRequest)
import Lib.HttpApi as HttpApi exposing (ApiRequest)
import Lib.Util as Util
import RemoteData exposing (RemoteData(..), WebData)
import UI
Expand All @@ -45,7 +45,7 @@ init config =
model =
{ rootNamespaceListing = Loading, expandedNamespaceListings = FQNSet.empty }
in
( model, Api.perform config.apiBasePath (fetchRootNamespaceListing config) )
( model, HttpApi.perform config.apiBasePath (fetchRootNamespaceListing config) )



Expand Down Expand Up @@ -100,7 +100,7 @@ update config msg model =

cmd =
if shouldExpand && not namespaceContentFetched then
Api.perform config.apiBasePath (fetchSubNamespaceListing config fqn)
HttpApi.perform config.apiBasePath (fetchSubNamespaceListing config fqn)

else
Cmd.none
Expand Down Expand Up @@ -180,7 +180,7 @@ fetchNamespaceListing : Config -> Maybe FQN -> (Result Http.Error NamespaceListi
fetchNamespaceListing config fqn toMsg =
CodebaseApi.Browse { perspective = config.perspective, namespaceId = Maybe.map EntityId.NameId fqn }
|> config.toApiEndpointUrl
|> Api.toRequest (NamespaceListing.decode fqn) toMsg
|> HttpApi.toRequest (NamespaceListing.decode fqn) toMsg



Expand Down
2 changes: 1 addition & 1 deletion src/Code/Config.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Code.Config exposing (..)

import Code.CodebaseApi exposing (ToApiEndpointUrl)
import Code.Perspective exposing (Perspective)
import Lib.Api exposing (ApiBasePath)
import Lib.HttpApi exposing (ApiBasePath)
import Lib.OperatingSystem exposing (OperatingSystem)


Expand Down
8 changes: 4 additions & 4 deletions src/Code/Finder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Html.Attributes
)
import Html.Events exposing (onClick, onInput)
import Http
import Lib.Api as Api exposing (ApiRequest)
import Lib.HttpApi as HttpApi exposing (ApiRequest)
import Lib.SearchResults as SearchResults exposing (SearchResults(..))
import Lib.Util as Util
import List.Nonempty as NEL
Expand Down Expand Up @@ -171,7 +171,7 @@ update config msg model =
( search, fetch ) =
performSearch config model.options model.search query
in
( { model | search = search }, Api.perform config.apiBasePath fetch, Remain )
( { model | search = search }, HttpApi.perform config.apiBasePath fetch, Remain )

else
( model, Cmd.none, Remain )
Expand Down Expand Up @@ -207,7 +207,7 @@ update config msg model =
( search_, fetch ) =
performSearch config options model.search model.input
in
( search_, Api.perform config.apiBasePath fetch )
( search_, HttpApi.perform config.apiBasePath fetch )

else
( model.search, Cmd.none )
Expand Down Expand Up @@ -392,7 +392,7 @@ fetchMatches toApiEndpointUrl perspective withinFqn query =
, query = query
}
|> toApiEndpointUrl
|> Api.toRequest FinderMatch.decodeMatches (FetchMatchesFinished query)
|> HttpApi.toRequest FinderMatch.decodeMatches (FetchMatchesFinished query)


focusSearchInput : Cmd Msg
Expand Down
6 changes: 3 additions & 3 deletions src/Code/Workspace.elm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Code.Workspace.WorkspaceItems as WorkspaceItems exposing (WorkspaceItems)
import Html exposing (Html, article, div, section)
import Html.Attributes exposing (class, id)
import Http
import Lib.Api as Api exposing (ApiRequest)
import Lib.HttpApi as HttpApi exposing (ApiRequest)
import Lib.OperatingSystem as OperatingSystem exposing (OperatingSystem)
import Task
import UI.Button as Button
Expand Down Expand Up @@ -304,7 +304,7 @@ openItem config ({ workspaceItems } as model) relativeToRef ref =
WorkspaceItems.insertWithFocusBefore workspaceItems r toInsert
in
( { model | workspaceItems = nextWorkspaceItems }
, Cmd.batch [ Api.perform config.apiBasePath (fetchDefinition config ref), scrollToDefinition ref ]
, Cmd.batch [ HttpApi.perform config.apiBasePath (fetchDefinition config ref), scrollToDefinition ref ]
)


Expand Down Expand Up @@ -455,7 +455,7 @@ fetchDefinition config ref =
in
endpoint
|> config.toApiEndpointUrl
|> Api.toRequest (WorkspaceItem.decodeItem ref) (FetchItemFinished ref)
|> HttpApi.toRequest (WorkspaceItem.decodeItem ref) (FetchItemFinished ref)


isDocCropped : Reference -> Cmd Msg
Expand Down
2 changes: 1 addition & 1 deletion src/Env.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Browser.Navigation as Nav
import Code.CodebaseApi as CodebaseApi
import Code.Config
import Code.Perspective exposing (Perspective)
import Lib.Api exposing (ApiBasePath(..))
import Lib.HttpApi exposing (ApiBasePath(..))
import Lib.OperatingSystem as OS exposing (OperatingSystem)


Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Api.elm → src/Lib/HttpApi.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Lib.Api exposing
module Lib.HttpApi exposing
( ApiBasePath(..)
, ApiRequest
, EndpointUrl(..)
Expand Down
2 changes: 1 addition & 1 deletion src/UnisonLocal/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Code.FullyQualifiedName as FQN exposing (FQN)
import Code.Hash as Hash exposing (Hash)
import Code.Perspective as Perspective exposing (Perspective(..))
import Code.Syntax as Syntax
import Lib.Api as Api exposing (EndpointUrl(..))
import Lib.HttpApi exposing (EndpointUrl(..))
import Regex
import Url.Builder exposing (QueryParameter, int, string)

Expand Down
2 changes: 1 addition & 1 deletion src/UnisonLocal/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Html exposing (Html, a, div, h1, h2, h3, nav, p, section, span, strong, t
import Html.Attributes exposing (class, classList, href, id, rel, target, title)
import Html.Events exposing (onClick)
import Http
import Lib.Api as HttpApi
import Lib.HttpApi as HttpApi
import Lib.OperatingSystem exposing (OperatingSystem(..))
import Lib.Util as Util
import RemoteData
Expand Down
2 changes: 1 addition & 1 deletion src/UnisonLocal/PreApp.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Code.Perspective as Perspective exposing (Perspective, PerspectiveParams)
import Env exposing (Flags)
import Html
import Http
import Lib.Api as HttpApi exposing (ApiBasePath(..), ApiRequest)
import Lib.HttpApi as HttpApi exposing (ApiBasePath(..), ApiRequest)
import UnisonLocal.Api as LocalApi
import UnisonLocal.App as App
import UnisonLocal.Route as Route exposing (Route)
Expand Down
6 changes: 3 additions & 3 deletions src/UnisonShare/Api.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Code.FullyQualifiedName as FQN exposing (FQN)
import Code.Hash as Hash exposing (Hash)
import Code.Perspective as Perspective exposing (Perspective(..))
import Code.Syntax as Syntax
import Lib.Api as Api exposing (EndpointUrl(..))
import Lib.HttpApi exposing (EndpointUrl(..))
import Regex
import Url.Builder exposing (QueryParameter, int, string)

Expand Down Expand Up @@ -45,11 +45,11 @@ projects owner =
EndpointUrl [ "projects" ] queryParams


catalog : Api.EndpointUrl
catalog : EndpointUrl
catalog =
[ "_catalog" ]
|> List.map (string "names")
|> (\names -> Api.EndpointUrl [ "getDefinition" ] names)
|> (\names -> EndpointUrl [ "getDefinition" ] names)


codebaseApiEndpointToEndpointUrl : CodebaseApi.CodebaseEndpoint -> EndpointUrl
Expand Down
10 changes: 5 additions & 5 deletions src/UnisonShare/App.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Html exposing (Html, a, div, h1, h2, nav, p, span, text)
import Html.Attributes exposing (class, classList, id, title)
import Html.Events exposing (onClick)
import Http
import Lib.Api as Api
import Lib.HttpApi as HttpApi
import Lib.Util as Util
import RemoteData exposing (RemoteData(..))
import UI
Expand Down Expand Up @@ -81,7 +81,7 @@ init env route =
fetchNamespaceDetailsCmd =
env.perspective
|> fetchNamespaceDetails
|> Maybe.map (Api.perform env.apiBasePath)
|> Maybe.map (HttpApi.perform env.apiBasePath)
|> Maybe.withDefault Cmd.none

( catalog, catalogCmd ) =
Expand Down Expand Up @@ -390,7 +390,7 @@ fetchPerspectiveAndCodebaseTree oldPerspective ({ env } as model) =
fetchNamespaceDetailsCmd =
env.perspective
|> fetchNamespaceDetails
|> Maybe.map (Api.perform env.apiBasePath)
|> Maybe.map (HttpApi.perform env.apiBasePath)
|> Maybe.withDefault Cmd.none
in
if Perspective.needsFetching env.perspective then
Expand Down Expand Up @@ -480,13 +480,13 @@ showFinder model withinNamespace =
-- EFFECTS


fetchNamespaceDetails : Perspective -> Maybe (Api.ApiRequest NamespaceDetails Msg)
fetchNamespaceDetails : Perspective -> Maybe (HttpApi.ApiRequest NamespaceDetails Msg)
fetchNamespaceDetails perspective =
case perspective of
Namespace { fqn } ->
fqn
|> ShareApi.namespace perspective
|> Api.toRequest Namespace.decodeDetails (FetchPerspectiveNamespaceDetailsFinished fqn)
|> HttpApi.toRequest Namespace.decodeDetails (FetchPerspectiveNamespaceDetailsFinished fqn)
|> Just

_ ->
Expand Down
6 changes: 3 additions & 3 deletions src/UnisonShare/Page/CatalogPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Html exposing (Html, div, h1, input, strong, table, tbody, td, text, tr)
import Html.Attributes exposing (autofocus, class, classList, placeholder)
import Html.Events exposing (onBlur, onFocus, onInput, onMouseDown)
import Http
import Lib.Api as Api
import Lib.HttpApi as HttpApi
import Lib.SearchResults as SearchResults exposing (SearchResults(..))
import List.Extra as ListE
import Maybe.Extra as MaybeE
Expand Down Expand Up @@ -75,11 +75,11 @@ projectListings and finally merging them into a Catalog
fetch : Env -> Cmd Msg
fetch env =
ShareApi.catalog
|> Api.toTask env.apiBasePath Catalog.decodeCatalogMask
|> HttpApi.toTask env.apiBasePath Catalog.decodeCatalogMask
|> Task.andThen
(\catalog ->
ShareApi.projects Nothing
|> Api.toTask env.apiBasePath Project.decodeListings
|> HttpApi.toTask env.apiBasePath Project.decodeListings
|> Task.map (\projects -> ( catalog, projects ))
)
|> Task.attempt FetchFinished
Expand Down
6 changes: 3 additions & 3 deletions src/UnisonShare/Page/UserPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Env exposing (Env)
import Html exposing (Html, div, h1, text)
import Html.Attributes exposing (class)
import Http
import Lib.Api as Api
import Lib.HttpApi as HttpApi
import RemoteData exposing (RemoteData(..), WebData)
import Task
import UI
Expand Down Expand Up @@ -55,11 +55,11 @@ fetchUser env username =
username |> User.usernameToString |> FQN.fromString
in
ShareApi.namespace perspective usernameFqn
|> Api.toTask env.apiBasePath User.decodeDetails
|> HttpApi.toTask env.apiBasePath User.decodeDetails
|> Task.andThen
(\userDetails ->
ShareApi.projects (username |> User.usernameToString |> Just)
|> Api.toTask env.apiBasePath Project.decodeListings
|> HttpApi.toTask env.apiBasePath Project.decodeListings
|> Task.map (\projects -> ( userDetails, projects ))
)
|> Task.attempt FetchUserProfileFinished
Expand Down
6 changes: 3 additions & 3 deletions src/UnisonShare/PreApp.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Code.Perspective as Perspective exposing (Perspective, PerspectiveParams)
import Env exposing (Flags)
import Html
import Http
import Lib.Api as Api exposing (ApiBasePath(..), ApiRequest)
import Lib.HttpApi as HttpApi exposing (ApiBasePath(..), ApiRequest)
import UnisonShare.Api as ShareApi
import UnisonShare.App as App
import UnisonShare.Route as Route exposing (Route)
Expand Down Expand Up @@ -56,7 +56,7 @@ init flags url navKey =
( Initialized app, Cmd.map AppMsg cmd )

fetchPerspective_ =
( Initializing preEnv, Api.perform (ApiBasePath flags.apiBasePath) (fetchPerspective preEnv) )
( Initializing preEnv, HttpApi.perform (ApiBasePath flags.apiBasePath) (fetchPerspective preEnv) )
in
-- If we have a codebase hash we can construct a full perspective,
-- otherwise we have to fetch the hash before being able to start up the
Expand All @@ -69,7 +69,7 @@ init flags url navKey =

fetchPerspective : PreEnv -> ApiRequest Perspective Msg
fetchPerspective preEnv =
ShareApi.codebaseHash |> Api.toRequest (Perspective.decode preEnv.perspectiveParams) (FetchPerspectiveFinished preEnv)
ShareApi.codebaseHash |> HttpApi.toRequest (Perspective.decode preEnv.perspectiveParams) (FetchPerspectiveFinished preEnv)


type Msg
Expand Down

0 comments on commit 943f310

Please sign in to comment.