DataSource.Request -> DataSource.DataSource.

This commit is contained in:
Dillon Kearns 2021-04-20 07:45:35 -07:00
parent 47fccf2cca
commit 84abfb4b2b
26 changed files with 134 additions and 133 deletions

View File

@ -17,7 +17,7 @@ type alias BlogPost =
}
blogPostsGlob : DataSource.Request (List { filePath : String, slug : String })
blogPostsGlob : DataSource.DataSource (List { filePath : String, slug : String })
blogPostsGlob =
Glob.succeed BlogPost
|> Glob.keep Glob.fullFilePath
@ -27,7 +27,7 @@ blogPostsGlob =
|> Glob.toStaticHttp
allMetadata : DataSource.Request (List ( PagePath, ArticleMetadata ))
allMetadata : DataSource.DataSource (List ( PagePath, ArticleMetadata ))
allMetadata =
--StaticFile.glob "content/blog/*.md"
blogPostsGlob
@ -69,7 +69,7 @@ type alias DataFromFile msg =
--fileRequest : String -> StaticHttp.Request (DataFromFile msg)
fileRequest : String -> DataSource.Request ArticleMetadata
fileRequest : String -> DataSource.DataSource ArticleMetadata
fileRequest filePath =
StaticFile.request
--"content/blog/extensible-markdown-parsing-in-elm.md"

View File

@ -10,7 +10,7 @@ install :
{ siteUrl : String
}
-> (List item -> List { path : String, lastMod : Maybe String })
-> DataSource.Request (List item)
-> DataSource.DataSource (List item)
-> Builder pathKey userModel userMsg route
-> Builder pathKey userModel userMsg route
install config toSitemapEntry request builder =

View File

@ -16,7 +16,7 @@ generate :
, indexPage : PagePath
}
-> (item -> Maybe Rss.Item)
-> DataSource.Request (List item)
-> DataSource.DataSource (List item)
-> Builder pathKey userModel userMsg route
-> Builder pathKey userModel userMsg route
generate options metadataToRssItem itemsRequest builder =

View File

@ -15,7 +15,7 @@ init constructor =
ServerRequest (OptimizedDecoder.succeed constructor)
staticData : DataSource.Request String
staticData : DataSource.DataSource String
staticData =
DataSource.get (Secrets.succeed "$$elm-pages$$headers")
(OptimizedDecoder.field "headers"
@ -23,7 +23,7 @@ staticData =
)
toStaticHttp : ServerRequest decodesTo -> DataSource.Request decodesTo
toStaticHttp : ServerRequest decodesTo -> DataSource.DataSource decodesTo
toStaticHttp (ServerRequest decoder) =
DataSource.get (Secrets.succeed "$$elm-pages$$headers") decoder

View File

@ -101,7 +101,7 @@ subscriptions _ _ =
Sub.none
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
(D.field "stargazers_count" D.int)

View File

@ -32,7 +32,7 @@ type alias SharedTemplate sharedMsg sharedModel sharedStaticData mappedMsg =
-> (sharedMsg -> mappedMsg)
-> Document mappedMsg
-> { body : Html mappedMsg, title : String }
, staticData : DataSource.Request sharedStaticData
, staticData : DataSource.DataSource sharedStaticData
, subscriptions : PagePath -> sharedModel -> Sub sharedMsg
, onPageChange :
Maybe

View File

@ -120,7 +120,7 @@ entryDecoder =
(Decode.maybe (Decode.field "Repository URL" Decode.string))
staticRequest : DataSource.Request (List Entry)
staticRequest : DataSource.DataSource (List Entry)
staticRequest =
DataSource.request
(Secrets.succeed

View File

@ -33,7 +33,7 @@ config =
generateFiles :
List (Maybe Route)
->
DataSource.Request
DataSource.DataSource
(List
(Result
String
@ -53,7 +53,7 @@ type alias StaticData =
}
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
DataSource.map StaticData
--(StaticFile.request "site-name.txt" StaticFile.body)

View File

@ -36,7 +36,7 @@ template =
}
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
--StaticFile.glob "content/blog/*.md"
Article.allMetadata

View File

@ -37,7 +37,7 @@ type alias RouteParams =
{ slug : String }
routes : DataSource.Request (List RouteParams)
routes : DataSource.DataSource (List RouteParams)
routes =
Article.blogPostsGlob
|> DataSource.map
@ -183,7 +183,7 @@ type alias StaticData =
}
staticData : RouteParams -> DataSource.Request StaticData
staticData : RouteParams -> DataSource.DataSource StaticData
staticData route =
StaticFile.request
("content/blog/" ++ route.slug ++ ".md")
@ -262,7 +262,7 @@ toRssItem article =
}
articlesRequest : DataSource.Request (List ArticleMetadata)
articlesRequest : DataSource.DataSource (List ArticleMetadata)
articlesRequest =
Glob.succeed identity
|> Glob.keep Glob.fullFilePath

View File

@ -81,7 +81,7 @@ view static =
}
staticData : Route -> DataSource.Request (List (Element.Element msg))
staticData : Route -> DataSource.DataSource (List (Element.Element msg))
staticData route =
StaticFile.request
"content/index.md"

View File

@ -29,7 +29,7 @@ template =
|> Template.buildNoState { view = view }
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
Showcase.staticRequest

View File

@ -10,7 +10,7 @@ import TemplateType
template :
{ staticData :
List ( PagePath, TemplateType.Metadata )
-> DataSource.Request staticData
-> DataSource.DataSource staticData
, view :
List ( PagePath, TemplateType.Metadata )
-> staticData
@ -34,7 +34,7 @@ template config =
type alias Template metadata renderedTemplate staticData model view templateMsg =
{ staticData :
List ( PagePath, TemplateType.Metadata )
-> DataSource.Request staticData
-> DataSource.DataSource staticData
, view :
List ( PagePath, TemplateType.Metadata )
-> staticData

View File

@ -79,7 +79,7 @@ subscriptions _ _ =
Sub.none
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
DataSource.get (Secrets.succeed "https://api.github.com/repos/dillonkearns/elm-pages")
(D.field "stargazers_count" D.int)

View File

@ -32,7 +32,7 @@ type alias SharedTemplate sharedMsg sharedModel sharedStaticData mappedMsg =
-> (sharedMsg -> mappedMsg)
-> Document mappedMsg
-> { body : Html mappedMsg, title : String }
, staticData : DataSource.Request sharedStaticData
, staticData : DataSource.DataSource sharedStaticData
, subscriptions : PagePath -> sharedModel -> Sub sharedMsg
, onPageChange :
Maybe

View File

@ -32,7 +32,7 @@ config =
generateFiles :
List (Maybe Route)
->
DataSource.Request
DataSource.DataSource
(List
(Result
String
@ -52,7 +52,7 @@ type alias StaticData =
}
staticData : DataSource.Request StaticData
staticData : DataSource.DataSource StaticData
staticData =
DataSource.map StaticData
--(StaticFile.request "site-name.txt" StaticFile.body)

View File

@ -114,14 +114,14 @@ toDirection string =
Nothing
staticData : RouteParams -> DataSource.Request StaticData
staticData : RouteParams -> DataSource.DataSource StaticData
staticData routeParams =
DataSource.map2 StaticData
(slideBody routeParams)
slideCount
slideBody : RouteParams -> DataSource.Request (List (Html.Html Msg))
slideBody : RouteParams -> DataSource.DataSource (List (Html.Html Msg))
slideBody route =
StaticFile.request
"slides.md"
@ -147,7 +147,7 @@ slideBody route =
)
slideCount : DataSource.Request Int
slideCount : DataSource.DataSource Int
slideCount =
StaticFile.request "slides.md"
(StaticFile.body

View File

@ -49,14 +49,14 @@ import Browser.Navigation
import Document exposing (Document)
import Head
import Pages.PagePath exposing (PagePath)
import DataSource
import DataSource exposing (DataSource)
import Shared
{-| -}
type alias TemplateWithState routeParams templateStaticData templateModel templateMsg =
{ staticData : routeParams -> DataSource.Request templateStaticData
, staticRoutes : DataSource.Request (List routeParams)
{ staticData : routeParams -> DataSource templateStaticData
, staticRoutes : DataSource (List routeParams)
, view :
templateModel
-> Shared.Model
@ -88,8 +88,8 @@ type alias StaticPayload staticData routeParams =
{-| -}
type Builder routeParams templateStaticData
= WithStaticData
{ staticData : routeParams -> DataSource.Request templateStaticData
, staticRoutes : DataSource.Request (List routeParams)
{ staticData : routeParams -> DataSource templateStaticData
, staticRoutes : DataSource (List routeParams)
, head :
StaticPayload templateStaticData routeParams
-> List Head.Tag
@ -202,8 +202,8 @@ buildWithSharedState config builderState =
{-| -}
withStaticData :
{ staticData : routeParams -> DataSource.Request templateStaticData
, staticRoutes : DataSource.Request (List routeParams)
{ staticData : routeParams -> DataSource templateStaticData
, staticRoutes : DataSource (List routeParams)
, head : StaticPayload templateStaticData routeParams -> List Head.Tag
}
-> Builder routeParams templateStaticData
@ -218,7 +218,7 @@ withStaticData { staticData, head, staticRoutes } =
{-| -}
noStaticData :
{ head : StaticPayload () routeParams -> List Head.Tag
, staticRoutes : DataSource.Request (List routeParams)
, staticRoutes : DataSource (List routeParams)
}
-> Builder routeParams ()
noStaticData { head, staticRoutes } =

View File

@ -39,7 +39,7 @@ import Html exposing (Html)
import Pages.PagePath exposing (PagePath)
import Url
import Url.Parser as Parser exposing ((</>), Parser)
import DataSource
import DataSource exposing (DataSource)
${templates.map((name) => `import Template.${name.join(".")}`).join("\n")}
@ -390,7 +390,7 @@ main =
)
}
staticDataForRoute : Maybe Route -> DataSource.Request PageStaticData
staticDataForRoute : Maybe Route -> DataSource PageStaticData
staticDataForRoute route =
case route of
Nothing ->
@ -409,7 +409,7 @@ staticDataForRoute route =
.join("\n ")}
getStaticRoutes : DataSource.Request (List (Maybe Route))
getStaticRoutes : DataSource (List (Maybe Route))
getStaticRoutes =
DataSource.combine
[ DataSource.succeed
@ -434,7 +434,7 @@ getStaticRoutes =
|> DataSource.map (List.map Just)
manifestGenerator : List ( Maybe Route ) -> DataSource.Request (Result anyError { path : List String, content : String })
manifestGenerator : List ( Maybe Route ) -> DataSource (Result anyError { path : List String, content : String })
manifestGenerator resolvedRoutes =
Site.config resolvedRoutes
|> .staticData

View File

@ -1,5 +1,5 @@
module DataSource exposing
( Request, RequestDetails
( RequestDetails
, get, request
, map, succeed, fail
, Body, emptyBody, stringBody, jsonBody
@ -7,6 +7,7 @@ module DataSource exposing
, map2, map3, map4, map5, map6, map7, map8, map9
, unoptimizedRequest
, Expect, expectString, expectUnoptimizedJson
, DataSource
)
{-| StaticHttp requests are an alternative to doing Elm HTTP requests the traditional way using the `elm/http` package.
@ -122,10 +123,10 @@ type alias Body =
Body.Body
{-| A Request that will be made a build time. Multiple `StaticHttp.Request`s can be combined together using the `mapN` functions,
{-| A DataSource represents data that will be gathered at build time. Multiple `DataSource`s can be combined together using the `mapN` functions,
very similar to how you can manipulate values with Json Decoders in Elm.
-}
type alias Request value =
type alias DataSource value =
RawRequest value
@ -153,7 +154,7 @@ A common use for this is to map your data into your elm-pages view:
)
-}
map : (a -> b) -> Request a -> Request b
map : (a -> b) -> DataSource a -> DataSource b
map fn requestInfo =
case requestInfo of
Request ( urls, lookupFn ) ->
@ -173,7 +174,7 @@ map fn requestInfo =
{-| Helper to remove an inner layer of Request wrapping.
-}
resolve : Request (List (Request value)) -> Request (List value)
resolve : DataSource (List (DataSource value)) -> DataSource (List value)
resolve =
andThen combine
@ -212,7 +213,7 @@ resolve =
|> StaticHttp.andThen StaticHttp.combine
-}
combine : List (Request value) -> Request (List value)
combine : List (DataSource value) -> DataSource (List value)
combine =
List.foldl (map2 (::)) (succeed [])
@ -240,12 +241,12 @@ combine =
)
-}
map2 : (a -> b -> c) -> Request a -> Request b -> Request c
map2 : (a -> b -> c) -> DataSource a -> DataSource b -> DataSource c
map2 fn request1 request2 =
case ( request1, request2 ) of
( Request ( urls1, lookupFn1 ), Request ( urls2, lookupFn2 ) ) ->
let
value : ApplicationType -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, Request c )
value : ApplicationType -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, DataSource c )
value appType rawResponses =
case ( lookupFn1 appType rawResponses, lookupFn2 appType rawResponses ) of
( Ok ( newDict1, newValue1 ), Ok ( newDict2, newValue2 ) ) ->
@ -305,12 +306,12 @@ combineReducedDicts dict1 dict2 =
)
lookup : ApplicationType -> Request value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, value )
lookup : ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, value )
lookup =
lookupHelp Dict.empty
lookupHelp : Dict String String -> ApplicationType -> Request value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, value )
lookupHelp : Dict String String -> ApplicationType -> DataSource value -> RequestsAndPending -> Result Pages.StaticHttpRequest.Error ( Dict String String, value )
lookupHelp strippedSoFar appType requestInfo rawResponses =
case requestInfo of
Request ( urls, lookupFn ) ->
@ -327,7 +328,7 @@ lookupHelp strippedSoFar appType requestInfo rawResponses =
Ok ( strippedSoFar, value )
addUrls : List (Pages.Secrets.Value HashRequest.Request) -> Request value -> Request value
addUrls : List (Pages.Secrets.Value HashRequest.Request) -> DataSource value -> DataSource value
addUrls urlsToAdd requestInfo =
case requestInfo of
Request ( initialUrls, function ) ->
@ -337,7 +338,7 @@ addUrls urlsToAdd requestInfo =
Done value
lookupUrls : Request value -> List (Pages.Secrets.Value RequestDetails)
lookupUrls : DataSource value -> List (Pages.Secrets.Value RequestDetails)
lookupUrls requestInfo =
case requestInfo of
Request ( urls, _ ) ->
@ -364,7 +365,7 @@ from the previous response to build up the URL, headers, etc. that you send to t
)
-}
andThen : (a -> Request b) -> Request a -> Request b
andThen : (a -> DataSource b) -> DataSource a -> DataSource b
andThen fn requestInfo =
Request
( lookupUrls requestInfo
@ -407,7 +408,7 @@ andThen fn requestInfo =
}
-}
succeed : a -> Request a
succeed : a -> DataSource a
succeed value =
Request
( []
@ -420,7 +421,7 @@ succeed value =
you will get a build error. Or in the dev server, you will see the error message in an overlay in your browser (and in
the terminal).
-}
fail : String -> Request a
fail : String -> DataSource a
fail errorMessage =
Request
( []
@ -444,7 +445,7 @@ fail errorMessage =
get :
Pages.Secrets.Value String
-> Decoder a
-> Request a
-> DataSource a
get url decoder =
request
(Secrets.map
@ -483,7 +484,7 @@ with this as a low-level detail, or you can use functions like [StaticHttp.get](
request :
Pages.Secrets.Value RequestDetails
-> Decoder a
-> Request a
-> DataSource a
request urlWithSecrets decoder =
unoptimizedRequest urlWithSecrets (ExpectJson decoder)
@ -558,7 +559,7 @@ so you don't need any additional optimization as the payload is already reduced
unoptimizedRequest :
Pages.Secrets.Value RequestDetails
-> Expect a
-> Request a
-> DataSource a
unoptimizedRequest requestWithSecrets expect =
case expect of
ExpectJson decoder ->
@ -746,10 +747,10 @@ unoptimizedRequest requestWithSecrets expect =
{-| -}
map3 :
(value1 -> value2 -> value3 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource valueCombined
map3 combineFn request1 request2 request3 =
succeed combineFn
|> map2 (|>) request1
@ -760,11 +761,11 @@ map3 combineFn request1 request2 request3 =
{-| -}
map4 :
(value1 -> value2 -> value3 -> value4 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource valueCombined
map4 combineFn request1 request2 request3 request4 =
succeed combineFn
|> map2 (|>) request1
@ -776,12 +777,12 @@ map4 combineFn request1 request2 request3 request4 =
{-| -}
map5 :
(value1 -> value2 -> value3 -> value4 -> value5 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request value5
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource value5
-> DataSource valueCombined
map5 combineFn request1 request2 request3 request4 request5 =
succeed combineFn
|> map2 (|>) request1
@ -794,13 +795,13 @@ map5 combineFn request1 request2 request3 request4 request5 =
{-| -}
map6 :
(value1 -> value2 -> value3 -> value4 -> value5 -> value6 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request value5
-> Request value6
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource value5
-> DataSource value6
-> DataSource valueCombined
map6 combineFn request1 request2 request3 request4 request5 request6 =
succeed combineFn
|> map2 (|>) request1
@ -814,14 +815,14 @@ map6 combineFn request1 request2 request3 request4 request5 request6 =
{-| -}
map7 :
(value1 -> value2 -> value3 -> value4 -> value5 -> value6 -> value7 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request value5
-> Request value6
-> Request value7
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource value5
-> DataSource value6
-> DataSource value7
-> DataSource valueCombined
map7 combineFn request1 request2 request3 request4 request5 request6 request7 =
succeed combineFn
|> map2 (|>) request1
@ -836,15 +837,15 @@ map7 combineFn request1 request2 request3 request4 request5 request6 request7 =
{-| -}
map8 :
(value1 -> value2 -> value3 -> value4 -> value5 -> value6 -> value7 -> value8 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request value5
-> Request value6
-> Request value7
-> Request value8
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource value5
-> DataSource value6
-> DataSource value7
-> DataSource value8
-> DataSource valueCombined
map8 combineFn request1 request2 request3 request4 request5 request6 request7 request8 =
succeed combineFn
|> map2 (|>) request1
@ -860,16 +861,16 @@ map8 combineFn request1 request2 request3 request4 request5 request6 request7 re
{-| -}
map9 :
(value1 -> value2 -> value3 -> value4 -> value5 -> value6 -> value7 -> value8 -> value9 -> valueCombined)
-> Request value1
-> Request value2
-> Request value3
-> Request value4
-> Request value5
-> Request value6
-> Request value7
-> Request value8
-> Request value9
-> Request valueCombined
-> DataSource value1
-> DataSource value2
-> DataSource value3
-> DataSource value4
-> DataSource value5
-> DataSource value6
-> DataSource value7
-> DataSource value8
-> DataSource value9
-> DataSource valueCombined
map9 combineFn request1 request2 request3 request4 request5 request6 request7 request8 request9 =
succeed combineFn
|> map2 (|>) request1

View File

@ -298,7 +298,7 @@ type alias RawGlob =
{-| -}
toStaticHttp : Glob a -> DataSource.Request (List a)
toStaticHttp : Glob a -> DataSource.DataSource (List a)
toStaticHttp glob =
DataSource.get (Secrets.succeed <| "glob://" ++ toPattern glob)
(OptimizedDecoder.map2 RawGlob
@ -311,7 +311,7 @@ toStaticHttp glob =
{-| -}
singleFile : String -> DataSource.Request (Maybe String)
singleFile : String -> DataSource.DataSource (Maybe String)
singleFile filePath =
succeed identity
|> drop (literal filePath)

View File

@ -24,7 +24,7 @@ type StaticResponses
type StaticHttpResult
= NotFetched (DataSource.Request ()) (Dict String (Result () String))
= NotFetched (DataSource.DataSource ()) (Dict String (Result () String))
error : StaticResponses
@ -34,12 +34,12 @@ error =
init :
{ config
| getStaticRoutes : DataSource.Request (List route)
| getStaticRoutes : DataSource.DataSource (List route)
, site : SiteConfig route siteStaticData
, staticData : route -> DataSource.Request pageStaticData
, sharedStaticData : DataSource.Request sharedStaticData
, staticData : route -> DataSource.DataSource pageStaticData
, sharedStaticData : DataSource.DataSource sharedStaticData
, generateFiles :
DataSource.Request
DataSource.DataSource
(List
(Result
String
@ -71,7 +71,7 @@ renderSingleRoute :
| routeToPath : route -> List String
}
-> { path : PagePath, frontmatter : route }
-> DataSource.Request a
-> DataSource.DataSource a
-> StaticResponses
renderSingleRoute config pathAndRoute request =
[ pathAndRoute.frontmatter ]
@ -151,13 +151,13 @@ type NextStep route
nextStep :
{ config
| getStaticRoutes : DataSource.Request (List route)
| getStaticRoutes : DataSource.DataSource (List route)
, routeToPath : route -> List String
, staticData : route -> DataSource.Request pageStaticData
, sharedStaticData : DataSource.Request sharedStaticData
, staticData : route -> DataSource.DataSource pageStaticData
, sharedStaticData : DataSource.DataSource sharedStaticData
, site : SiteConfig route siteStaticData
, generateFiles :
DataSource.Request
DataSource.DataSource
(List
(Result
String
@ -319,7 +319,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
in
if pendingRequests then
let
requestContinuations : List ( String, DataSource.Request () )
requestContinuations : List ( String, DataSource.DataSource () )
requestContinuations =
staticResponses
|> Dict.toList
@ -469,7 +469,7 @@ nextStep config mode secrets allRawResponses errors staticResponses_ maybeRoutes
performStaticHttpRequests :
Dict String (Maybe String)
-> SecretsDict
-> List ( String, DataSource.Request a )
-> List ( String, DataSource.DataSource a )
-> Result (List BuildError) (List { unmasked : RequestDetails, masked : RequestDetails })
performStaticHttpRequests allRawResponses secrets staticRequests =
staticRequests

View File

@ -27,8 +27,8 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s
-> ( userModel, Cmd userMsg )
, update : pageStaticData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, Cmd userMsg )
, subscriptions : route -> PagePath -> userModel -> Sub userMsg
, sharedStaticData : DataSource.Request sharedStaticData
, staticData : route -> DataSource.Request pageStaticData
, sharedStaticData : DataSource.DataSource sharedStaticData
, staticData : route -> DataSource.DataSource pageStaticData
, view :
{ path : PagePath
, frontmatter : route
@ -39,14 +39,14 @@ type alias ProgramConfig userMsg userModel route siteStaticData pageStaticData s
{ view : userModel -> { title : String, body : Html userMsg }
, head : List Head.Tag
}
, getStaticRoutes : DataSource.Request (List route)
, getStaticRoutes : DataSource.DataSource (List route)
, urlToRoute : Url -> route
, routeToPath : route -> List String
, site : SiteConfig route siteStaticData
, toJsPort : Json.Encode.Value -> Cmd Never
, fromJsPort : Sub Decode.Value
, generateFiles :
DataSource.Request
DataSource.DataSource
(List
(Result
String

View File

@ -8,14 +8,14 @@ import Pages.Manifest
type alias SiteConfig route staticData =
List route
->
{ staticData : DataSource.Request staticData
{ staticData : DataSource.DataSource staticData
, canonicalUrl : String
, manifest : staticData -> Pages.Manifest.Config
, head :
staticData
-> List Head.Tag
, generateFiles :
DataSource.Request
DataSource.DataSource
(List
(Result
String

View File

@ -30,13 +30,13 @@ body =
{-| -}
request : String -> Decoder a -> DataSource.Request a
request : String -> Decoder a -> DataSource.DataSource a
request filePath =
DataSource.get (Secrets.succeed <| "file://" ++ filePath)
{-| -}
glob : String -> DataSource.Request (List String)
glob : String -> DataSource.DataSource (List String)
glob pattern =
DataSource.get (Secrets.succeed <| "glob://" ++ pattern)
(OptimizedDecoder.list OptimizedDecoder.string)

View File

@ -115,7 +115,7 @@ all =
(Secrets.succeed (get url))
decoder
pokemonDetailRequest : DataSource.Request ()
pokemonDetailRequest : DataSource.DataSource ()
pokemonDetailRequest =
getReq
"https://pokeapi.co/api/v2/pokemon/"
@ -780,7 +780,7 @@ type Route
= Route String
start : List ( List String, DataSource.Request a ) -> ProgramTest (Model Route) Msg Effect
start : List ( List String, DataSource.DataSource a ) -> ProgramTest (Model Route) Msg Effect
start pages =
startWithHttpCache (Ok ()) [] pages
@ -788,14 +788,14 @@ start pages =
startWithHttpCache :
Result String ()
-> List ( Request.Request, String )
-> List ( List String, DataSource.Request a )
-> List ( List String, DataSource.DataSource a )
-> ProgramTest (Model Route) Msg Effect
startWithHttpCache =
startLowLevel (DataSource.succeed [])
startLowLevel :
DataSource.Request
DataSource.DataSource
(List
(Result
String
@ -806,7 +806,7 @@ startLowLevel :
)
-> Result String ()
-> List ( Request.Request, String )
-> List ( List String, DataSource.Request a )
-> List ( List String, DataSource.DataSource a )
-> ProgramTest (Model Route) Msg Effect
startLowLevel generateFiles documentBodyResult staticHttpCache pages =
let