mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-21 10:41:39 +03:00
Delete obsolete type.
This commit is contained in:
parent
43866be8d5
commit
da1ca86caf
@ -83,7 +83,6 @@ So it's best to use that mental model to avoid confusion.
|
||||
|
||||
-}
|
||||
|
||||
import Pages.Internal.ApplicationType exposing (ApplicationType)
|
||||
import Pages.Internal.StaticHttpBody as Body
|
||||
import Pages.StaticHttp.Request as HashRequest
|
||||
import Pages.StaticHttpRequest exposing (RawRequest(..))
|
||||
@ -132,8 +131,8 @@ map fn requestInfo =
|
||||
Request partiallyStripped ( urls, lookupFn ) ->
|
||||
Request partiallyStripped
|
||||
( urls
|
||||
, \appType rawResponses ->
|
||||
map fn (lookupFn appType rawResponses)
|
||||
, \rawResponses ->
|
||||
map fn (lookupFn rawResponses)
|
||||
)
|
||||
|
||||
ApiRoute stripped value ->
|
||||
@ -222,28 +221,28 @@ map2 fn request1 request2 =
|
||||
( Request newDict1 ( urls1, lookupFn1 ), Request newDict2 ( urls2, lookupFn2 ) ) ->
|
||||
Request (combineReducedDicts newDict1 newDict2)
|
||||
( urls1 ++ urls2
|
||||
, \appType rawResponses ->
|
||||
, \rawResponses ->
|
||||
map2 fn
|
||||
(lookupFn1 appType rawResponses)
|
||||
(lookupFn2 appType rawResponses)
|
||||
(lookupFn1 rawResponses)
|
||||
(lookupFn2 rawResponses)
|
||||
)
|
||||
|
||||
( Request dict1 ( urls1, lookupFn1 ), ApiRoute stripped2 value2 ) ->
|
||||
Request dict1
|
||||
( urls1
|
||||
, \appType rawResponses ->
|
||||
, \rawResponses ->
|
||||
map2 fn
|
||||
(lookupFn1 appType rawResponses)
|
||||
(lookupFn1 rawResponses)
|
||||
(ApiRoute stripped2 value2)
|
||||
)
|
||||
|
||||
( ApiRoute stripped2 value2, Request dict1 ( urls1, lookupFn1 ) ) ->
|
||||
Request dict1
|
||||
( urls1
|
||||
, \appType rawResponses ->
|
||||
, \rawResponses ->
|
||||
map2 fn
|
||||
(ApiRoute stripped2 value2)
|
||||
(lookupFn1 appType rawResponses)
|
||||
(lookupFn1 rawResponses)
|
||||
)
|
||||
|
||||
( ApiRoute stripped1 value1, ApiRoute stripped2 value2 ) ->
|
||||
@ -261,21 +260,20 @@ combineReducedDicts dict1 dict2 =
|
||||
Set.union dict1 dict2
|
||||
|
||||
|
||||
lookup : ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Set String, value )
|
||||
lookup : DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Set String, value )
|
||||
lookup =
|
||||
lookupHelp Set.empty
|
||||
|
||||
|
||||
lookupHelp : Set String -> ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Set String, value )
|
||||
lookupHelp strippedSoFar appType requestInfo rawResponses =
|
||||
lookupHelp : Set String -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Set String, value )
|
||||
lookupHelp strippedSoFar requestInfo rawResponses =
|
||||
case requestInfo of
|
||||
RequestError error ->
|
||||
Err error
|
||||
|
||||
Request strippedResponses ( urls, lookupFn ) ->
|
||||
lookupHelp (combineReducedDicts strippedResponses strippedSoFar)
|
||||
appType
|
||||
(addUrls urls (lookupFn appType rawResponses))
|
||||
(addUrls urls (lookupFn rawResponses))
|
||||
rawResponses
|
||||
|
||||
ApiRoute stripped value ->
|
||||
@ -341,9 +339,8 @@ andThen fn requestInfo =
|
||||
-- TODO should this be non-empty Dict? Or should it be passed down some other way?
|
||||
Request Set.empty
|
||||
( lookupUrls requestInfo
|
||||
, \appType rawResponses ->
|
||||
, \rawResponses ->
|
||||
lookup
|
||||
appType
|
||||
requestInfo
|
||||
rawResponses
|
||||
|> (\result ->
|
||||
|
@ -209,7 +209,7 @@ request request_ expect =
|
||||
ExpectJson decoder ->
|
||||
Request Set.empty
|
||||
( [ request_ ]
|
||||
, \_ rawResponseDict ->
|
||||
, \rawResponseDict ->
|
||||
rawResponseDict
|
||||
|> RequestsAndPending.get (request_ |> HashRequest.hash)
|
||||
|> (\maybeResponse ->
|
||||
@ -257,7 +257,7 @@ request request_ expect =
|
||||
ExpectString mapStringFn ->
|
||||
Request Set.empty
|
||||
( [ request_ ]
|
||||
, \_ rawResponseDict ->
|
||||
, \rawResponseDict ->
|
||||
rawResponseDict
|
||||
|> RequestsAndPending.get (request_ |> HashRequest.hash)
|
||||
|> (\maybeResponse ->
|
||||
|
@ -1,5 +0,0 @@
|
||||
module Pages.Internal.ApplicationType exposing (ApplicationType(..))
|
||||
|
||||
|
||||
type ApplicationType
|
||||
= Cli
|
@ -24,7 +24,6 @@ import Json.Encode
|
||||
import PageServerResponse exposing (PageServerResponse)
|
||||
import Pages.Flags
|
||||
import Pages.Http
|
||||
import Pages.Internal.ApplicationType as ApplicationType
|
||||
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
||||
import Pages.Internal.Platform.Effect as Effect exposing (Effect)
|
||||
import Pages.Internal.Platform.StaticResponses as StaticResponses exposing (StaticResponses)
|
||||
@ -652,7 +651,7 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
||||
thing =
|
||||
apiHandler.matchesToResponse path
|
||||
in
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
thing
|
||||
model.allRawResponses
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError "TODO - path from request")
|
||||
@ -684,7 +683,7 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
||||
let
|
||||
pageFoundResult : Result BuildError (Maybe NotFoundReason)
|
||||
pageFoundResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(if model.isDevServer then
|
||||
config.handleRoute payload.frontmatter
|
||||
|
||||
@ -717,21 +716,21 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
||||
|
||||
pageDataResult : Result BuildError (PageServerResponse pageData)
|
||||
pageDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(config.data (config.urlToRoute currentUrl))
|
||||
(staticData |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
||||
|
||||
sharedDataResult : Result BuildError sharedData
|
||||
sharedDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
config.sharedData
|
||||
(staticData |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
||||
|
||||
siteDataResult : Result BuildError siteData
|
||||
siteDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
site.data
|
||||
(staticData |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError "Site.elm")
|
||||
@ -884,7 +883,7 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
||||
routeResult
|
||||
|> Result.andThen
|
||||
(\route ->
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(config.data route)
|
||||
(contentJson |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError "TODO url")
|
||||
@ -914,7 +913,7 @@ sendSinglePageProgress site contentJson config model =
|
||||
let
|
||||
pageFoundResult : Result BuildError (Maybe NotFoundReason)
|
||||
pageFoundResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(if model.isDevServer then
|
||||
config.handleRoute route
|
||||
|
||||
@ -992,21 +991,21 @@ sendSinglePageProgress site contentJson config model =
|
||||
|
||||
pageDataResult : Result BuildError (PageServerResponse pageData)
|
||||
pageDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(config.data (config.urlToRoute currentUrl))
|
||||
(contentJson |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
||||
|
||||
sharedDataResult : Result BuildError sharedData
|
||||
sharedDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
config.sharedData
|
||||
(contentJson |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
||||
|
||||
siteDataResult : Result BuildError siteData
|
||||
siteDataResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
site.data
|
||||
(contentJson |> Dict.map (\_ v -> Just v))
|
||||
|> Result.mapError (StaticHttpRequest.toBuildError "Site.elm")
|
||||
|
@ -10,7 +10,6 @@ import Html exposing (Html)
|
||||
import HtmlPrinter exposing (htmlToString)
|
||||
import Internal.ApiRoute exposing (ApiRoute(..))
|
||||
import Json.Encode
|
||||
import Pages.Internal.ApplicationType as ApplicationType
|
||||
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
||||
import Pages.SiteConfig exposing (SiteConfig)
|
||||
import Pages.StaticHttp.Request as HashRequest
|
||||
@ -157,7 +156,7 @@ encode requestsAndPending staticResponses =
|
||||
|> Dict.toList
|
||||
|> List.map
|
||||
(\( key, NotFetched request _ ) ->
|
||||
StaticHttpRequest.strippedResponsesEncode ApplicationType.Cli request requestsAndPending
|
||||
StaticHttpRequest.strippedResponsesEncode request requestsAndPending
|
||||
|> Result.map (Tuple.pair key)
|
||||
)
|
||||
|> combineMultipleErrors
|
||||
@ -223,7 +222,7 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
allRawResponses
|
||||
|> StaticHttpRequest.cacheRequestResolution ApplicationType.Cli request
|
||||
|> StaticHttpRequest.cacheRequestResolution request
|
||||
|
||||
hasPermanentError : Bool
|
||||
hasPermanentError =
|
||||
@ -359,7 +358,6 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
StaticHttpRequest.cacheRequestResolution
|
||||
ApplicationType.Cli
|
||||
request
|
||||
usableRawResponses
|
||||
|
||||
@ -395,7 +393,7 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
|
||||
resolvedGenerateFilesResult : Result StaticHttpRequest.Error (List (Result String { path : List String, content : String }))
|
||||
resolvedGenerateFilesResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
(buildTimeFilesRequest config)
|
||||
(allRawResponses |> Dict.Extra.filterMap (\_ value -> Just value))
|
||||
in
|
||||
@ -449,7 +447,7 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
let
|
||||
pageFoundResult : Result StaticHttpRequest.Error (Maybe NotFoundReason)
|
||||
pageFoundResult =
|
||||
StaticHttpRequest.resolve ApplicationType.Cli
|
||||
StaticHttpRequest.resolve
|
||||
pageFoundDataSource
|
||||
(allRawResponses |> Dict.Extra.filterMap (\_ value -> Just value))
|
||||
in
|
||||
@ -475,7 +473,6 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
|
||||
staticRequestsStatus : StaticHttpRequest.Status ()
|
||||
staticRequestsStatus =
|
||||
StaticHttpRequest.cacheRequestResolution
|
||||
ApplicationType.Cli
|
||||
request
|
||||
usableRawResponses
|
||||
|
||||
@ -526,7 +523,7 @@ performStaticHttpRequests allRawResponses staticRequests =
|
||||
-- TODO look for performance bottleneck in this double nesting
|
||||
|> List.map
|
||||
(\( _, request ) ->
|
||||
StaticHttpRequest.resolveUrls ApplicationType.Cli request allRawResponses
|
||||
StaticHttpRequest.resolveUrls request allRawResponses
|
||||
)
|
||||
-- TODO prevent duplicates... can't because Set needs comparable
|
||||
-- |> Set.fromList
|
||||
|
@ -3,7 +3,6 @@ module Pages.StaticHttpRequest exposing (Error(..), RawRequest(..), Status(..),
|
||||
import BuildError exposing (BuildError)
|
||||
import Dict exposing (Dict)
|
||||
import List.Extra
|
||||
import Pages.Internal.ApplicationType exposing (ApplicationType)
|
||||
import Pages.StaticHttp.Request
|
||||
import RequestsAndPending exposing (RequestsAndPending)
|
||||
import Set exposing (Set)
|
||||
@ -11,19 +10,19 @@ import TerminalText as Terminal
|
||||
|
||||
|
||||
type RawRequest value
|
||||
= Request (Set String) ( List Pages.StaticHttp.Request.Request, ApplicationType -> RequestsAndPending -> RawRequest value )
|
||||
= Request (Set String) ( List Pages.StaticHttp.Request.Request, RequestsAndPending -> RawRequest value )
|
||||
| RequestError Error
|
||||
| ApiRoute (Set String) value
|
||||
|
||||
|
||||
strippedResponses : ApplicationType -> RawRequest value -> RequestsAndPending -> Set String
|
||||
strippedResponses : RawRequest value -> RequestsAndPending -> Set String
|
||||
strippedResponses =
|
||||
strippedResponsesHelp Set.empty
|
||||
|
||||
|
||||
strippedResponsesEncode : ApplicationType -> RawRequest value -> RequestsAndPending -> Result (List BuildError) (Dict String String)
|
||||
strippedResponsesEncode appType rawRequest requestsAndPending =
|
||||
strippedResponses appType rawRequest requestsAndPending
|
||||
strippedResponsesEncode : RawRequest value -> RequestsAndPending -> Result (List BuildError) (Dict String String)
|
||||
strippedResponsesEncode rawRequest requestsAndPending =
|
||||
strippedResponses rawRequest requestsAndPending
|
||||
|> Set.toList
|
||||
|> List.map
|
||||
(\k ->
|
||||
@ -65,21 +64,20 @@ combineMultipleErrors results =
|
||||
results
|
||||
|
||||
|
||||
strippedResponsesHelp : Set String -> ApplicationType -> RawRequest value -> RequestsAndPending -> Set String
|
||||
strippedResponsesHelp usedSoFar appType request rawResponses =
|
||||
strippedResponsesHelp : Set String -> RawRequest value -> RequestsAndPending -> Set String
|
||||
strippedResponsesHelp usedSoFar request rawResponses =
|
||||
case request of
|
||||
RequestError _ ->
|
||||
usedSoFar
|
||||
|
||||
Request partiallyStrippedResponses ( _, lookupFn ) ->
|
||||
case lookupFn appType rawResponses of
|
||||
case lookupFn rawResponses of
|
||||
followupRequest ->
|
||||
strippedResponsesHelp
|
||||
(Set.union
|
||||
usedSoFar
|
||||
partiallyStrippedResponses
|
||||
)
|
||||
appType
|
||||
followupRequest
|
||||
rawResponses
|
||||
|
||||
@ -126,28 +124,28 @@ toBuildError path error =
|
||||
}
|
||||
|
||||
|
||||
resolve : ApplicationType -> RawRequest value -> RequestsAndPending -> Result Error value
|
||||
resolve appType request rawResponses =
|
||||
resolve : RawRequest value -> RequestsAndPending -> Result Error value
|
||||
resolve request rawResponses =
|
||||
case request of
|
||||
RequestError error ->
|
||||
Err error
|
||||
|
||||
Request _ ( _, lookupFn ) ->
|
||||
case lookupFn appType rawResponses of
|
||||
case lookupFn rawResponses of
|
||||
nextRequest ->
|
||||
resolve appType nextRequest rawResponses
|
||||
resolve nextRequest rawResponses
|
||||
|
||||
ApiRoute _ value ->
|
||||
Ok value
|
||||
|
||||
|
||||
resolveUrls : ApplicationType -> RawRequest value -> RequestsAndPending -> List Pages.StaticHttp.Request.Request
|
||||
resolveUrls appType request rawResponses =
|
||||
resolveUrlsHelp appType rawResponses [] request
|
||||
resolveUrls : RawRequest value -> RequestsAndPending -> List Pages.StaticHttp.Request.Request
|
||||
resolveUrls request rawResponses =
|
||||
resolveUrlsHelp rawResponses [] request
|
||||
|
||||
|
||||
resolveUrlsHelp : ApplicationType -> RequestsAndPending -> List Pages.StaticHttp.Request.Request -> RawRequest value -> List Pages.StaticHttp.Request.Request
|
||||
resolveUrlsHelp appType rawResponses soFar request =
|
||||
resolveUrlsHelp : RequestsAndPending -> List Pages.StaticHttp.Request.Request -> RawRequest value -> List Pages.StaticHttp.Request.Request
|
||||
resolveUrlsHelp rawResponses soFar request =
|
||||
case request of
|
||||
RequestError error ->
|
||||
case error of
|
||||
@ -159,22 +157,21 @@ resolveUrlsHelp appType rawResponses soFar request =
|
||||
soFar
|
||||
|
||||
Request _ ( urlList, lookupFn ) ->
|
||||
resolveUrlsHelp appType
|
||||
resolveUrlsHelp
|
||||
rawResponses
|
||||
(soFar ++ urlList)
|
||||
(lookupFn appType rawResponses)
|
||||
(lookupFn rawResponses)
|
||||
|
||||
ApiRoute _ _ ->
|
||||
soFar
|
||||
|
||||
|
||||
cacheRequestResolution :
|
||||
ApplicationType
|
||||
-> RawRequest value
|
||||
RawRequest value
|
||||
-> RequestsAndPending
|
||||
-> Status value
|
||||
cacheRequestResolution appType request rawResponses =
|
||||
cacheRequestResolutionHelp [] appType rawResponses request
|
||||
cacheRequestResolution request rawResponses =
|
||||
cacheRequestResolutionHelp [] rawResponses request
|
||||
|
||||
|
||||
type Status value
|
||||
@ -185,11 +182,10 @@ type Status value
|
||||
|
||||
cacheRequestResolutionHelp :
|
||||
List Pages.StaticHttp.Request.Request
|
||||
-> ApplicationType
|
||||
-> RequestsAndPending
|
||||
-> RawRequest value
|
||||
-> Status value
|
||||
cacheRequestResolutionHelp foundUrls appType rawResponses request =
|
||||
cacheRequestResolutionHelp foundUrls rawResponses request =
|
||||
case request of
|
||||
RequestError error ->
|
||||
case error of
|
||||
@ -205,9 +201,8 @@ cacheRequestResolutionHelp foundUrls appType rawResponses request =
|
||||
|
||||
Request _ ( urlList, lookupFn ) ->
|
||||
cacheRequestResolutionHelp urlList
|
||||
appType
|
||||
rawResponses
|
||||
(lookupFn appType rawResponses)
|
||||
(lookupFn rawResponses)
|
||||
|
||||
ApiRoute _ _ ->
|
||||
Complete
|
||||
|
Loading…
Reference in New Issue
Block a user