From 943f310fb51af34386bd5ad20fd12debf531b714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8jberg?= Date: Wed, 6 Apr 2022 17:07:16 -0400 Subject: [PATCH] Rename Lib.Api to Lib.HttpApi --- src/Code/CodebaseApi.elm | 4 ++-- src/Code/CodebaseTree.elm | 8 ++++---- src/Code/Config.elm | 2 +- src/Code/Finder.elm | 8 ++++---- src/Code/Workspace.elm | 6 +++--- src/Env.elm | 2 +- src/Lib/{Api.elm => HttpApi.elm} | 2 +- src/UnisonLocal/Api.elm | 2 +- src/UnisonLocal/App.elm | 2 +- src/UnisonLocal/PreApp.elm | 2 +- src/UnisonShare/Api.elm | 6 +++--- src/UnisonShare/App.elm | 10 +++++----- src/UnisonShare/Page/CatalogPage.elm | 6 +++--- src/UnisonShare/Page/UserPage.elm | 6 +++--- src/UnisonShare/PreApp.elm | 6 +++--- 15 files changed, 36 insertions(+), 36 deletions(-) rename src/Lib/{Api.elm => HttpApi.elm} (99%) diff --git a/src/Code/CodebaseApi.elm b/src/Code/CodebaseApi.elm index e14c96d..841f373 100644 --- a/src/Code/CodebaseApi.elm +++ b/src/Code/CodebaseApi.elm @@ -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 @@ -34,4 +34,4 @@ type CodebaseEndpoint type alias ToApiEndpointUrl = - CodebaseEndpoint -> Api.EndpointUrl + CodebaseEndpoint -> HttpApi.EndpointUrl diff --git a/src/Code/CodebaseTree.elm b/src/Code/CodebaseTree.elm index d60e7a0..426d6ce 100644 --- a/src/Code/CodebaseTree.elm +++ b/src/Code/CodebaseTree.elm @@ -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 @@ -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) ) @@ -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 @@ -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 diff --git a/src/Code/Config.elm b/src/Code/Config.elm index b98e689..3307264 100644 --- a/src/Code/Config.elm +++ b/src/Code/Config.elm @@ -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) diff --git a/src/Code/Finder.elm b/src/Code/Finder.elm index 4b026a8..169472a 100644 --- a/src/Code/Finder.elm +++ b/src/Code/Finder.elm @@ -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 @@ -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 ) @@ -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 ) @@ -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 diff --git a/src/Code/Workspace.elm b/src/Code/Workspace.elm index 4f8a14b..e855169 100644 --- a/src/Code/Workspace.elm +++ b/src/Code/Workspace.elm @@ -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 @@ -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 ] ) @@ -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 diff --git a/src/Env.elm b/src/Env.elm index aea8865..3fc5a9e 100644 --- a/src/Env.elm +++ b/src/Env.elm @@ -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) diff --git a/src/Lib/Api.elm b/src/Lib/HttpApi.elm similarity index 99% rename from src/Lib/Api.elm rename to src/Lib/HttpApi.elm index aa103b9..a5d543d 100644 --- a/src/Lib/Api.elm +++ b/src/Lib/HttpApi.elm @@ -1,4 +1,4 @@ -module Lib.Api exposing +module Lib.HttpApi exposing ( ApiBasePath(..) , ApiRequest , EndpointUrl(..) diff --git a/src/UnisonLocal/Api.elm b/src/UnisonLocal/Api.elm index b585970..fc26bb6 100644 --- a/src/UnisonLocal/Api.elm +++ b/src/UnisonLocal/Api.elm @@ -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) diff --git a/src/UnisonLocal/App.elm b/src/UnisonLocal/App.elm index 5ab4d89..7934f02 100644 --- a/src/UnisonLocal/App.elm +++ b/src/UnisonLocal/App.elm @@ -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 diff --git a/src/UnisonLocal/PreApp.elm b/src/UnisonLocal/PreApp.elm index 13287bd..3d58cd9 100644 --- a/src/UnisonLocal/PreApp.elm +++ b/src/UnisonLocal/PreApp.elm @@ -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) diff --git a/src/UnisonShare/Api.elm b/src/UnisonShare/Api.elm index 68eb044..b90fbc4 100644 --- a/src/UnisonShare/Api.elm +++ b/src/UnisonShare/Api.elm @@ -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) @@ -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 diff --git a/src/UnisonShare/App.elm b/src/UnisonShare/App.elm index bb0cc22..e0af101 100644 --- a/src/UnisonShare/App.elm +++ b/src/UnisonShare/App.elm @@ -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 @@ -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 ) = @@ -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 @@ -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 _ -> diff --git a/src/UnisonShare/Page/CatalogPage.elm b/src/UnisonShare/Page/CatalogPage.elm index 3f15c70..40f511d 100644 --- a/src/UnisonShare/Page/CatalogPage.elm +++ b/src/UnisonShare/Page/CatalogPage.elm @@ -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 @@ -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 diff --git a/src/UnisonShare/Page/UserPage.elm b/src/UnisonShare/Page/UserPage.elm index 53c6bf8..6e8a4d0 100644 --- a/src/UnisonShare/Page/UserPage.elm +++ b/src/UnisonShare/Page/UserPage.elm @@ -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 @@ -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 diff --git a/src/UnisonShare/PreApp.elm b/src/UnisonShare/PreApp.elm index 376359c..5845968 100644 --- a/src/UnisonShare/PreApp.elm +++ b/src/UnisonShare/PreApp.elm @@ -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) @@ -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 @@ -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