elm-pages 3.0.0-beta.12 → 3.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.js +1496 -1126
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +151 -39
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/dead-code-review/elm.json +3 -2
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +58 -10
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +45 -29
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +45 -4
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm.json +3 -3
- package/generator/src/RouteBuilder.elm +66 -52
- package/generator/src/SharedTemplate.elm +3 -2
- package/generator/src/SiteConfig.elm +3 -2
- package/generator/src/build.js +6 -6
- package/generator/src/cli.js +12 -7
- package/generator/src/compatibility-key.js +1 -1
- package/generator/src/dev-server.js +7 -7
- package/generator/src/render-test.js +109 -0
- package/generator/src/render.js +77 -51
- package/generator/src/request-cache.js +149 -158
- package/generator/template/app/Api.elm +2 -2
- package/generator/template/app/Route/Index.elm +3 -3
- package/generator/template/app/Shared.elm +3 -3
- package/generator/template/app/Site.elm +3 -3
- package/package.json +11 -11
- package/src/ApiRoute.elm +63 -57
- package/src/BackendTask/Env.elm +87 -0
- package/src/{DataSource → BackendTask}/File.elm +89 -43
- package/src/{DataSource → BackendTask}/Glob.elm +134 -125
- package/src/BackendTask/Http.elm +637 -0
- package/src/{DataSource → BackendTask}/Internal/Glob.elm +1 -1
- package/src/BackendTask/Internal/Request.elm +28 -0
- package/src/BackendTask/Port.elm +202 -0
- package/src/{DataSource.elm → BackendTask.elm} +223 -207
- package/src/Exception.elm +37 -0
- package/src/Form.elm +20 -20
- package/src/Head.elm +7 -7
- package/src/Internal/ApiRoute.elm +7 -5
- package/src/PageServerResponse.elm +6 -1
- package/src/Pages/Generate.elm +35 -63
- package/src/Pages/Internal/Platform/Cli.elm +422 -731
- package/src/Pages/Internal/Platform/Cli.elm.bak +22 -22
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/Effect.elm +0 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +53 -113
- package/src/Pages/Internal/Platform/StaticResponses.elm +72 -256
- package/src/Pages/Internal/Platform/ToJsPayload.elm +4 -4
- package/src/Pages/Internal/Platform.elm +25 -31
- package/src/Pages/Internal/Script.elm +17 -0
- package/src/Pages/Internal/StaticHttpBody.elm +35 -1
- package/src/Pages/Manifest.elm +5 -4
- package/src/Pages/ProgramConfig.elm +8 -7
- package/src/Pages/Script.elm +34 -25
- package/src/Pages/SiteConfig.elm +3 -2
- package/src/Pages/StaticHttp/Request.elm +2 -2
- package/src/Pages/StaticHttpRequest.elm +37 -90
- package/src/RequestsAndPending.elm +8 -19
- package/src/Server/Request.elm +14 -14
- package/src/Server/Session.elm +34 -34
- package/src/Server/SetCookie.elm +1 -1
- package/src/DataSource/Env.elm +0 -62
- package/src/DataSource/Http.elm +0 -446
- package/src/DataSource/Internal/Request.elm +0 -20
- package/src/DataSource/Port.elm +0 -90
|
@@ -11,7 +11,7 @@ import BuildError exposing (BuildError)
|
|
|
11
11
|
import Bytes exposing (Bytes)
|
|
12
12
|
import Bytes.Encode
|
|
13
13
|
import Codec
|
|
14
|
-
import
|
|
14
|
+
import BackendTask exposing (BackendTask)
|
|
15
15
|
import Dict
|
|
16
16
|
import Head
|
|
17
17
|
import Html exposing (Html)
|
|
@@ -483,9 +483,9 @@ initLegacy site renderRequest { staticHttpCache, isDevServer } config =
|
|
|
483
483
|
case renderRequest of
|
|
484
484
|
RenderRequest.SinglePage _ singleRequest _ ->
|
|
485
485
|
let
|
|
486
|
-
globalHeadTags :
|
|
486
|
+
globalHeadTags : BackendTask (List Head.Tag)
|
|
487
487
|
globalHeadTags =
|
|
488
|
-
(config.globalHeadTags |> Maybe.withDefault (\_ ->
|
|
488
|
+
(config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
|
|
489
489
|
in
|
|
490
490
|
case singleRequest of
|
|
491
491
|
RenderRequest.Page serverRequestPayload ->
|
|
@@ -500,26 +500,26 @@ initLegacy site renderRequest { staticHttpCache, isDevServer } config =
|
|
|
500
500
|
(case isAction of
|
|
501
501
|
Just _ ->
|
|
502
502
|
config.action serverRequestPayload.frontmatter
|
|
503
|
-
|>
|
|
503
|
+
|> BackendTask.andThen
|
|
504
504
|
(\something ->
|
|
505
505
|
case something of
|
|
506
506
|
PageServerResponse.ErrorPage _ _ ->
|
|
507
|
-
|
|
508
|
-
|>
|
|
507
|
+
BackendTask.succeed something
|
|
508
|
+
|> BackendTask.map (\_ -> ())
|
|
509
509
|
|
|
510
510
|
PageServerResponse.RenderPage _ _ ->
|
|
511
|
-
|
|
511
|
+
BackendTask.map3 (\_ _ _ -> ())
|
|
512
512
|
(config.data serverRequestPayload.frontmatter)
|
|
513
513
|
config.sharedData
|
|
514
514
|
globalHeadTags
|
|
515
515
|
|
|
516
516
|
PageServerResponse.ServerResponse _ ->
|
|
517
|
-
|
|
518
|
-
|>
|
|
517
|
+
BackendTask.succeed something
|
|
518
|
+
|> BackendTask.map (\_ -> ())
|
|
519
519
|
)
|
|
520
520
|
|
|
521
521
|
Nothing ->
|
|
522
|
-
|
|
522
|
+
BackendTask.map3 (\_ _ _ -> ())
|
|
523
523
|
(config.data serverRequestPayload.frontmatter)
|
|
524
524
|
config.sharedData
|
|
525
525
|
globalHeadTags
|
|
@@ -528,20 +528,20 @@ initLegacy site renderRequest { staticHttpCache, isDevServer } config =
|
|
|
528
528
|
config.handleRoute serverRequestPayload.frontmatter
|
|
529
529
|
|
|
530
530
|
else
|
|
531
|
-
|
|
531
|
+
BackendTask.succeed Nothing
|
|
532
532
|
)
|
|
533
533
|
|
|
534
534
|
RenderRequest.Api ( path, ApiRoute apiRequest ) ->
|
|
535
535
|
StaticResponses.renderApiRequest
|
|
536
|
-
(
|
|
536
|
+
(BackendTask.map2 (\_ _ -> ())
|
|
537
537
|
(apiRequest.matchesToResponse path)
|
|
538
538
|
globalHeadTags
|
|
539
539
|
)
|
|
540
540
|
|
|
541
541
|
RenderRequest.NotFound _ ->
|
|
542
542
|
StaticResponses.renderApiRequest
|
|
543
|
-
(
|
|
544
|
-
(
|
|
543
|
+
(BackendTask.map2 (\_ _ -> ())
|
|
544
|
+
(BackendTask.succeed [])
|
|
545
545
|
globalHeadTags
|
|
546
546
|
)
|
|
547
547
|
|
|
@@ -692,7 +692,7 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
|
|
692
692
|
case requestPayload of
|
|
693
693
|
RenderRequest.Api ( path, ApiRoute apiHandler ) ->
|
|
694
694
|
let
|
|
695
|
-
thing :
|
|
695
|
+
thing : BackendTask (Maybe ApiRoute.Response)
|
|
696
696
|
thing =
|
|
697
697
|
apiHandler.matchesToResponse path
|
|
698
698
|
in
|
|
@@ -731,7 +731,7 @@ nextStepToEffect site config model ( updatedStaticResponsesModel, nextStep ) =
|
|
|
731
731
|
config.handleRoute payload.frontmatter
|
|
732
732
|
|
|
733
733
|
else
|
|
734
|
-
|
|
734
|
+
BackendTask.succeed Nothing
|
|
735
735
|
)
|
|
736
736
|
model.allRawResponses
|
|
737
737
|
|> Result.mapError (StaticHttpRequest.toBuildError (payload.path |> Path.toAbsolute))
|
|
@@ -798,7 +798,7 @@ sendSinglePageProgress site contentJson config model info =
|
|
|
798
798
|
config.handleRoute route
|
|
799
799
|
|
|
800
800
|
else
|
|
801
|
-
|
|
801
|
+
BackendTask.succeed Nothing
|
|
802
802
|
)
|
|
803
803
|
model.allRawResponses
|
|
804
804
|
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
|
@@ -945,12 +945,12 @@ sendSinglePageProgress site contentJson config model info =
|
|
|
945
945
|
(case isAction of
|
|
946
946
|
Just _ ->
|
|
947
947
|
config.action (urlToRoute config currentUrl)
|
|
948
|
-
|>
|
|
948
|
+
|> BackendTask.andThen
|
|
949
949
|
(\something ->
|
|
950
950
|
case something of
|
|
951
951
|
PageServerResponse.ErrorPage a b ->
|
|
952
952
|
PageServerResponse.ErrorPage a b
|
|
953
|
-
|>
|
|
953
|
+
|> BackendTask.succeed
|
|
954
954
|
|
|
955
955
|
PageServerResponse.RenderPage _ _ ->
|
|
956
956
|
-- TODO the headers/response codes are ignored from the action here
|
|
@@ -960,7 +960,7 @@ sendSinglePageProgress site contentJson config model info =
|
|
|
960
960
|
|
|
961
961
|
PageServerResponse.ServerResponse a ->
|
|
962
962
|
PageServerResponse.ServerResponse a
|
|
963
|
-
|>
|
|
963
|
+
|> BackendTask.succeed
|
|
964
964
|
)
|
|
965
965
|
|
|
966
966
|
Nothing ->
|
|
@@ -984,9 +984,9 @@ sendSinglePageProgress site contentJson config model info =
|
|
|
984
984
|
contentJson
|
|
985
985
|
|> Result.mapError (StaticHttpRequest.toBuildError currentUrl.path)
|
|
986
986
|
|
|
987
|
-
globalHeadTags :
|
|
987
|
+
globalHeadTags : BackendTask (List Head.Tag)
|
|
988
988
|
globalHeadTags =
|
|
989
|
-
(config.globalHeadTags |> Maybe.withDefault (\_ ->
|
|
989
|
+
(config.globalHeadTags |> Maybe.withDefault (\_ -> BackendTask.succeed [])) HtmlPrinter.htmlToString
|
|
990
990
|
|
|
991
991
|
siteDataResult : Result BuildError (List Head.Tag)
|
|
992
992
|
siteDataResult =
|
|
@@ -6,22 +6,22 @@ module Pages.Internal.Platform.GeneratorApplication exposing (Flags, Model, Msg(
|
|
|
6
6
|
|
|
7
7
|
-}
|
|
8
8
|
|
|
9
|
+
import BackendTask exposing (BackendTask)
|
|
9
10
|
import BuildError exposing (BuildError)
|
|
10
11
|
import Cli.Program as Program exposing (FlagsIncludingArgv)
|
|
11
12
|
import Codec
|
|
12
|
-
import DataSource exposing (DataSource)
|
|
13
13
|
import Dict
|
|
14
|
+
import Exception exposing (Throwable)
|
|
14
15
|
import HtmlPrinter
|
|
15
16
|
import Json.Decode as Decode
|
|
16
|
-
import Json.Encode
|
|
17
|
+
import Json.Encode as Encode
|
|
17
18
|
import Pages.GeneratorProgramConfig exposing (GeneratorProgramConfig)
|
|
18
19
|
import Pages.Internal.Platform.CompatibilityKey
|
|
19
20
|
import Pages.Internal.Platform.Effect as Effect exposing (Effect)
|
|
20
|
-
import Pages.Internal.Platform.StaticResponses as StaticResponses
|
|
21
|
+
import Pages.Internal.Platform.StaticResponses as StaticResponses
|
|
21
22
|
import Pages.Internal.Platform.ToJsPayload as ToJsPayload
|
|
22
|
-
import Pages.Script
|
|
23
|
+
import Pages.Internal.Script
|
|
23
24
|
import Pages.StaticHttp.Request
|
|
24
|
-
import Pages.StaticHttpRequest as StaticHttpRequest
|
|
25
25
|
import RequestsAndPending exposing (RequestsAndPending)
|
|
26
26
|
import TerminalText as Terminal
|
|
27
27
|
|
|
@@ -34,7 +34,7 @@ type alias Flags =
|
|
|
34
34
|
|
|
35
35
|
{-| -}
|
|
36
36
|
type alias Model =
|
|
37
|
-
{ staticResponses :
|
|
37
|
+
{ staticResponses : BackendTask Throwable ()
|
|
38
38
|
, errors : List BuildError
|
|
39
39
|
, allRawResponses : RequestsAndPending
|
|
40
40
|
, done : Bool
|
|
@@ -43,25 +43,20 @@ type alias Model =
|
|
|
43
43
|
|
|
44
44
|
{-| -}
|
|
45
45
|
type Msg
|
|
46
|
-
= GotDataBatch
|
|
47
|
-
(List
|
|
48
|
-
{ request : Pages.StaticHttp.Request.Request
|
|
49
|
-
, response : RequestsAndPending.Response
|
|
50
|
-
}
|
|
51
|
-
)
|
|
46
|
+
= GotDataBatch Decode.Value
|
|
52
47
|
| GotBuildError BuildError
|
|
53
48
|
|
|
54
49
|
|
|
55
50
|
{-| -}
|
|
56
51
|
app :
|
|
57
52
|
GeneratorProgramConfig
|
|
58
|
-
-> Program.StatefulProgram Model Msg (
|
|
53
|
+
-> Program.StatefulProgram Model Msg (BackendTask Throwable ()) Flags
|
|
59
54
|
app config =
|
|
60
55
|
let
|
|
61
|
-
cliConfig : Program.Config (
|
|
56
|
+
cliConfig : Program.Config (BackendTask Throwable ())
|
|
62
57
|
cliConfig =
|
|
63
58
|
case config.data of
|
|
64
|
-
|
|
59
|
+
Pages.Internal.Script.Script theCliConfig ->
|
|
65
60
|
theCliConfig HtmlPrinter.htmlToString
|
|
66
61
|
in
|
|
67
62
|
Program.stateful
|
|
@@ -70,8 +65,8 @@ app config =
|
|
|
70
65
|
init cliOptions flags
|
|
71
66
|
|> Tuple.mapSecond (perform config)
|
|
72
67
|
, update =
|
|
73
|
-
\
|
|
74
|
-
update
|
|
68
|
+
\_ msg model ->
|
|
69
|
+
update msg model
|
|
75
70
|
|> Tuple.mapSecond (perform config)
|
|
76
71
|
, subscriptions =
|
|
77
72
|
\_ ->
|
|
@@ -118,23 +113,7 @@ app config =
|
|
|
118
113
|
)
|
|
119
114
|
|> mergeResult
|
|
120
115
|
)
|
|
121
|
-
, config.gotBatchSub
|
|
122
|
-
|> Sub.map
|
|
123
|
-
(\newBatch ->
|
|
124
|
-
Decode.decodeValue batchDecoder newBatch
|
|
125
|
-
|> Result.map GotDataBatch
|
|
126
|
-
|> Result.mapError
|
|
127
|
-
(\error ->
|
|
128
|
-
("From location 2: "
|
|
129
|
-
++ (error
|
|
130
|
-
|> Decode.errorToString
|
|
131
|
-
)
|
|
132
|
-
)
|
|
133
|
-
|> BuildError.internal
|
|
134
|
-
|> GotBuildError
|
|
135
|
-
)
|
|
136
|
-
|> mergeResult
|
|
137
|
-
)
|
|
116
|
+
, config.gotBatchSub |> Sub.map GotDataBatch
|
|
138
117
|
]
|
|
139
118
|
, config = cliConfig
|
|
140
119
|
, printAndExitFailure =
|
|
@@ -151,18 +130,10 @@ app config =
|
|
|
151
130
|
|> Codec.encodeToValue (ToJsPayload.successCodecNew2 "" "")
|
|
152
131
|
|> config.toJsPort
|
|
153
132
|
|> Cmd.map never
|
|
154
|
-
, printAndExitSuccess = \string -> config.toJsPort (
|
|
133
|
+
, printAndExitSuccess = \string -> config.toJsPort (Encode.string string) |> Cmd.map never
|
|
155
134
|
}
|
|
156
135
|
|
|
157
136
|
|
|
158
|
-
batchDecoder : Decode.Decoder (List { request : Pages.StaticHttp.Request.Request, response : RequestsAndPending.Response })
|
|
159
|
-
batchDecoder =
|
|
160
|
-
Decode.map2 (\request response -> { request = request, response = response })
|
|
161
|
-
(Decode.field "request" requestDecoder)
|
|
162
|
-
(Decode.field "response" RequestsAndPending.decoder)
|
|
163
|
-
|> Decode.list
|
|
164
|
-
|
|
165
|
-
|
|
166
137
|
mergeResult : Result a a -> a
|
|
167
138
|
mergeResult r =
|
|
168
139
|
case r of
|
|
@@ -216,7 +187,7 @@ perform config effect =
|
|
|
216
187
|
flatten config list
|
|
217
188
|
|
|
218
189
|
Effect.FetchHttp unmasked ->
|
|
219
|
-
ToJsPayload.DoHttp unmasked unmasked
|
|
190
|
+
ToJsPayload.DoHttp (Pages.StaticHttp.Request.hash unmasked) unmasked
|
|
220
191
|
|> Codec.encoder (ToJsPayload.successCodecNew2 canonicalSiteUrl "")
|
|
221
192
|
|> config.toJsPort
|
|
222
193
|
|> Cmd.map never
|
|
@@ -256,9 +227,6 @@ perform config effect =
|
|
|
256
227
|
|> config.sendPageData
|
|
257
228
|
|> Cmd.map never
|
|
258
229
|
|
|
259
|
-
Effect.Continue ->
|
|
260
|
-
Cmd.none
|
|
261
|
-
|
|
262
230
|
|
|
263
231
|
|
|
264
232
|
-- TODO use Json.Decode.Value for flagsDecoder instead of hardcoded record flags
|
|
@@ -281,12 +249,12 @@ perform config effect =
|
|
|
281
249
|
|
|
282
250
|
{-| -}
|
|
283
251
|
init :
|
|
284
|
-
|
|
252
|
+
BackendTask Throwable ()
|
|
285
253
|
-> FlagsIncludingArgv Flags
|
|
286
254
|
-> ( Model, Effect )
|
|
287
255
|
init execute flags =
|
|
288
256
|
if flags.compatibilityKey == Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey then
|
|
289
|
-
initLegacy execute
|
|
257
|
+
initLegacy execute
|
|
290
258
|
|
|
291
259
|
else
|
|
292
260
|
let
|
|
@@ -304,8 +272,8 @@ init execute flags =
|
|
|
304
272
|
"The elm-pages NPM package is ahead of the elm-pages Elm package. Try updating the elm-pages Elm package?"
|
|
305
273
|
)
|
|
306
274
|
in
|
|
307
|
-
updateAndSendPortIfDone
|
|
308
|
-
{ staticResponses = StaticResponses.empty
|
|
275
|
+
updateAndSendPortIfDone
|
|
276
|
+
{ staticResponses = StaticResponses.empty ()
|
|
309
277
|
, errors =
|
|
310
278
|
[ { title = "Incompatible NPM and Elm package versions"
|
|
311
279
|
, message = [ Terminal.text <| message ]
|
|
@@ -313,18 +281,17 @@ init execute flags =
|
|
|
313
281
|
, path = ""
|
|
314
282
|
}
|
|
315
283
|
]
|
|
316
|
-
, allRawResponses =
|
|
284
|
+
, allRawResponses = Encode.object []
|
|
317
285
|
, done = False
|
|
318
286
|
}
|
|
319
287
|
|
|
320
288
|
|
|
321
289
|
initLegacy :
|
|
322
|
-
|
|
323
|
-
-> { staticHttpCache : RequestsAndPending }
|
|
290
|
+
BackendTask Throwable ()
|
|
324
291
|
-> ( Model, Effect )
|
|
325
|
-
initLegacy execute
|
|
292
|
+
initLegacy execute =
|
|
326
293
|
let
|
|
327
|
-
staticResponses :
|
|
294
|
+
staticResponses : BackendTask Throwable ()
|
|
328
295
|
staticResponses =
|
|
329
296
|
StaticResponses.renderApiRequest execute
|
|
330
297
|
|
|
@@ -332,33 +299,30 @@ initLegacy execute { staticHttpCache } =
|
|
|
332
299
|
initialModel =
|
|
333
300
|
{ staticResponses = staticResponses
|
|
334
301
|
, errors = []
|
|
335
|
-
, allRawResponses =
|
|
302
|
+
, allRawResponses = Encode.object []
|
|
336
303
|
, done = False
|
|
337
304
|
}
|
|
338
305
|
in
|
|
339
|
-
StaticResponses.nextStep initialModel
|
|
340
|
-
|> nextStepToEffect
|
|
306
|
+
StaticResponses.nextStep initialModel
|
|
307
|
+
|> nextStepToEffect
|
|
341
308
|
initialModel
|
|
342
309
|
|
|
343
310
|
|
|
344
311
|
updateAndSendPortIfDone :
|
|
345
|
-
|
|
346
|
-
-> Model
|
|
312
|
+
Model
|
|
347
313
|
-> ( Model, Effect )
|
|
348
|
-
updateAndSendPortIfDone
|
|
314
|
+
updateAndSendPortIfDone model =
|
|
349
315
|
StaticResponses.nextStep
|
|
350
316
|
model
|
|
351
|
-
|
|
352
|
-
|> nextStepToEffect execute model
|
|
317
|
+
|> nextStepToEffect model
|
|
353
318
|
|
|
354
319
|
|
|
355
320
|
{-| -}
|
|
356
321
|
update :
|
|
357
|
-
|
|
358
|
-
-> Msg
|
|
322
|
+
Msg
|
|
359
323
|
-> Model
|
|
360
324
|
-> ( Model, Effect )
|
|
361
|
-
update
|
|
325
|
+
update msg model =
|
|
362
326
|
case msg of
|
|
363
327
|
GotDataBatch batch ->
|
|
364
328
|
let
|
|
@@ -369,8 +333,7 @@ update execute msg model =
|
|
|
369
333
|
in
|
|
370
334
|
StaticResponses.nextStep
|
|
371
335
|
updatedModel
|
|
372
|
-
|
|
373
|
-
|> nextStepToEffect execute updatedModel
|
|
336
|
+
|> nextStepToEffect updatedModel
|
|
374
337
|
|
|
375
338
|
GotBuildError buildError ->
|
|
376
339
|
let
|
|
@@ -383,32 +346,29 @@ update execute msg model =
|
|
|
383
346
|
in
|
|
384
347
|
StaticResponses.nextStep
|
|
385
348
|
updatedModel
|
|
386
|
-
|
|
387
|
-
|> nextStepToEffect execute updatedModel
|
|
349
|
+
|> nextStepToEffect updatedModel
|
|
388
350
|
|
|
389
351
|
|
|
390
352
|
nextStepToEffect :
|
|
391
|
-
|
|
392
|
-
->
|
|
393
|
-
-> ( StaticResponses, StaticResponses.NextStep route )
|
|
353
|
+
Model
|
|
354
|
+
-> StaticResponses.NextStep route ()
|
|
394
355
|
-> ( Model, Effect )
|
|
395
|
-
nextStepToEffect
|
|
356
|
+
nextStepToEffect model nextStep =
|
|
396
357
|
case nextStep of
|
|
397
|
-
StaticResponses.Continue
|
|
358
|
+
StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
|
|
398
359
|
let
|
|
399
360
|
updatedModel : Model
|
|
400
361
|
updatedModel =
|
|
401
362
|
{ model
|
|
402
|
-
| allRawResponses =
|
|
363
|
+
| allRawResponses = Encode.object []
|
|
403
364
|
, staticResponses = updatedStaticResponsesModel
|
|
404
365
|
}
|
|
405
366
|
in
|
|
406
367
|
if List.isEmpty httpRequests then
|
|
407
|
-
nextStepToEffect
|
|
368
|
+
nextStepToEffect
|
|
408
369
|
updatedModel
|
|
409
370
|
(StaticResponses.nextStep
|
|
410
371
|
updatedModel
|
|
411
|
-
Nothing
|
|
412
372
|
)
|
|
413
373
|
|
|
414
374
|
else
|
|
@@ -419,37 +379,17 @@ nextStepToEffect execute model ( updatedStaticResponsesModel, nextStep ) =
|
|
|
419
379
|
|> Effect.Batch
|
|
420
380
|
)
|
|
421
381
|
|
|
422
|
-
StaticResponses.Finish
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
, staticHttpCache = Dict.empty
|
|
437
|
-
, statusCode = 200
|
|
438
|
-
}
|
|
439
|
-
|> ToJsPayload.SendApiResponse
|
|
440
|
-
|> Effect.SendSinglePage
|
|
441
|
-
|
|
442
|
-
Err error ->
|
|
443
|
-
[ error ]
|
|
444
|
-
|> ToJsPayload.Errors
|
|
445
|
-
|> Effect.SendSinglePage
|
|
446
|
-
)
|
|
447
|
-
in
|
|
448
|
-
( model
|
|
449
|
-
, apiResponse
|
|
450
|
-
)
|
|
451
|
-
|
|
452
|
-
StaticResponses.Errors errors ->
|
|
453
|
-
( model
|
|
454
|
-
, errors |> ToJsPayload.Errors |> Effect.SendSinglePage
|
|
455
|
-
)
|
|
382
|
+
StaticResponses.Finish () ->
|
|
383
|
+
( model
|
|
384
|
+
, { body = Encode.null
|
|
385
|
+
, staticHttpCache = Dict.empty
|
|
386
|
+
, statusCode = 200
|
|
387
|
+
}
|
|
388
|
+
|> ToJsPayload.SendApiResponse
|
|
389
|
+
|> Effect.SendSinglePage
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
StaticResponses.FinishedWithErrors buildErrors ->
|
|
393
|
+
( model
|
|
394
|
+
, buildErrors |> ToJsPayload.Errors |> Effect.SendSinglePage
|
|
395
|
+
)
|