elm-pages 3.0.0-beta.41 → 3.0.0-beta.42
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.cjs +47 -23
- 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/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/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/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/src/RouteBuilder.elm +12 -54
- package/generator/src/compatibility-key.js +2 -2
- package/package.json +2 -2
- package/src/ApiRoute.elm +3 -31
- package/src/FormData.elm +21 -1
- package/src/Internal/Request.elm +84 -4
- package/src/Pages/FormData.elm +2 -1
- package/src/Pages/Internal/Platform/Cli.elm +15 -2
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Navigation.elm +0 -2
- package/src/Pages/ProgramConfig.elm +3 -2
- package/src/Scaffold/Route.elm +70 -50
- package/src/Server/Request.elm +445 -952
- package/src/Server/Session.elm +140 -90
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ https://github.com/dillonkearns/elm-pages/projects
|
|
|
81
81
|
You will see an error if the NPM and Elm package do not have a matching Compatibility Key. Usually it's best to upgrade to the latest version of both the Elm and NPM
|
|
82
82
|
packages when you upgrade. However, in case you want to install versions that are behind the latest, the Compatibility Key is included here for reference.
|
|
83
83
|
|
|
84
|
-
Current Compatibility Key:
|
|
84
|
+
Current Compatibility Key: 19.
|
|
85
85
|
|
|
86
86
|
## Contributors ✨
|
|
87
87
|
|
|
@@ -26347,6 +26347,27 @@ var $author$project$Gen$PagesMsg$annotation_ = {
|
|
|
26347
26347
|
])));
|
|
26348
26348
|
}
|
|
26349
26349
|
};
|
|
26350
|
+
var $author$project$Gen$Server$Request$moduleName_ = _List_fromArray(
|
|
26351
|
+
['Server', 'Request']);
|
|
26352
|
+
var $author$project$Gen$Server$Request$annotation_ = {
|
|
26353
|
+
method: A3(
|
|
26354
|
+
$author$project$Elm$Annotation$namedWith,
|
|
26355
|
+
_List_fromArray(
|
|
26356
|
+
['Server', 'Request']),
|
|
26357
|
+
'Method',
|
|
26358
|
+
_List_Nil),
|
|
26359
|
+
request: A4(
|
|
26360
|
+
$author$project$Elm$Annotation$alias,
|
|
26361
|
+
$author$project$Gen$Server$Request$moduleName_,
|
|
26362
|
+
'Request',
|
|
26363
|
+
_List_Nil,
|
|
26364
|
+
A3(
|
|
26365
|
+
$author$project$Elm$Annotation$namedWith,
|
|
26366
|
+
_List_fromArray(
|
|
26367
|
+
['Internal', 'Request']),
|
|
26368
|
+
'Request',
|
|
26369
|
+
_List_Nil))
|
|
26370
|
+
};
|
|
26350
26371
|
var $author$project$Gen$Server$Response$moduleName_ = _List_fromArray(
|
|
26351
26372
|
['Server', 'Response']);
|
|
26352
26373
|
var $author$project$Gen$Server$Response$annotation_ = {
|
|
@@ -33186,32 +33207,35 @@ var $author$project$Gen$ApiRoute$values_ = {
|
|
|
33186
33207
|
'ApiRouteBuilder',
|
|
33187
33208
|
_List_fromArray(
|
|
33188
33209
|
[
|
|
33189
|
-
|
|
33190
|
-
$author$project$Elm$Annotation$
|
|
33191
|
-
_List_fromArray(
|
|
33192
|
-
['Server', 'Request']),
|
|
33193
|
-
'Parser',
|
|
33210
|
+
A2(
|
|
33211
|
+
$author$project$Elm$Annotation$function,
|
|
33194
33212
|
_List_fromArray(
|
|
33195
33213
|
[
|
|
33196
33214
|
A3(
|
|
33197
33215
|
$author$project$Elm$Annotation$namedWith,
|
|
33198
|
-
_List_Nil,
|
|
33199
|
-
'BackendTask',
|
|
33200
33216
|
_List_fromArray(
|
|
33201
|
-
[
|
|
33202
|
-
|
|
33203
|
-
|
|
33204
|
-
|
|
33205
|
-
|
|
33206
|
-
|
|
33207
|
-
|
|
33208
|
-
|
|
33209
|
-
|
|
33210
|
-
|
|
33211
|
-
|
|
33212
|
-
|
|
33213
|
-
|
|
33214
|
-
|
|
33217
|
+
['Server', 'Request']),
|
|
33218
|
+
'Request',
|
|
33219
|
+
_List_Nil)
|
|
33220
|
+
]),
|
|
33221
|
+
A3(
|
|
33222
|
+
$author$project$Elm$Annotation$namedWith,
|
|
33223
|
+
_List_Nil,
|
|
33224
|
+
'BackendTask',
|
|
33225
|
+
_List_fromArray(
|
|
33226
|
+
[
|
|
33227
|
+
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'FatalError', _List_Nil),
|
|
33228
|
+
A3(
|
|
33229
|
+
$author$project$Elm$Annotation$namedWith,
|
|
33230
|
+
_List_fromArray(
|
|
33231
|
+
['Server', 'Response']),
|
|
33232
|
+
'Response',
|
|
33233
|
+
_List_fromArray(
|
|
33234
|
+
[
|
|
33235
|
+
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'Never', _List_Nil),
|
|
33236
|
+
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'Never', _List_Nil)
|
|
33237
|
+
]))
|
|
33238
|
+
]))),
|
|
33215
33239
|
$author$project$Elm$Annotation$var('constructor')
|
|
33216
33240
|
]))
|
|
33217
33241
|
]),
|
|
@@ -37536,7 +37560,7 @@ var $author$project$GenerateMain$otherFile = F2(
|
|
|
37536
37560
|
'dataForRoute',
|
|
37537
37561
|
_Utils_Tuple2(
|
|
37538
37562
|
'requestPayload',
|
|
37539
|
-
$elm$core$Maybe$Just($author$project$Gen$
|
|
37563
|
+
$elm$core$Maybe$Just($author$project$Gen$Server$Request$annotation_.request)),
|
|
37540
37564
|
_Utils_Tuple2(
|
|
37541
37565
|
'maybeRoute',
|
|
37542
37566
|
$elm$core$Maybe$Just(
|
|
@@ -38019,7 +38043,7 @@ var $author$project$GenerateMain$otherFile = F2(
|
|
|
38019
38043
|
'action',
|
|
38020
38044
|
_Utils_Tuple2(
|
|
38021
38045
|
'requestPayload',
|
|
38022
|
-
$elm$core$Maybe$Just($author$project$Gen$
|
|
38046
|
+
$elm$core$Maybe$Just($author$project$Gen$Server$Request$annotation_.request)),
|
|
38023
38047
|
_Utils_Tuple2(
|
|
38024
38048
|
'maybeRoute',
|
|
38025
38049
|
$elm$core$Maybe$Just(
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 848138408, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 2748899408, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -98,20 +98,20 @@ import Pages.ConcurrentSubmission
|
|
|
98
98
|
import Pages.Fetcher
|
|
99
99
|
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
|
100
100
|
import Pages.Internal.RoutePattern exposing (RoutePattern)
|
|
101
|
-
import Pages.PageUrl exposing (PageUrl)
|
|
102
101
|
import Pages.Navigation
|
|
102
|
+
import Pages.PageUrl exposing (PageUrl)
|
|
103
103
|
import PagesMsg exposing (PagesMsg)
|
|
104
|
-
import UrlPath exposing (UrlPath)
|
|
105
104
|
import Server.Request
|
|
106
105
|
import Server.Response
|
|
107
106
|
import Shared
|
|
107
|
+
import UrlPath exposing (UrlPath)
|
|
108
108
|
import View exposing (View)
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
{-| -}
|
|
112
112
|
type alias StatefulRoute routeParams data action model msg =
|
|
113
|
-
{ data :
|
|
114
|
-
, action :
|
|
113
|
+
{ data : Server.Request.Request -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
114
|
+
, action : Server.Request.Request -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
|
|
115
115
|
, staticRoutes : BackendTask FatalError (List routeParams)
|
|
116
116
|
, view :
|
|
117
117
|
Shared.Model
|
|
@@ -155,8 +155,8 @@ type alias App data action routeParams =
|
|
|
155
155
|
{-| -}
|
|
156
156
|
type Builder routeParams data action
|
|
157
157
|
= WithData
|
|
158
|
-
{ data :
|
|
159
|
-
, action :
|
|
158
|
+
{ data : Server.Request.Request -> routeParams -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
159
|
+
, action : Server.Request.Request -> routeParams -> BackendTask FatalError (Server.Response.Response action ErrorPage)
|
|
160
160
|
, staticRoutes : BackendTask FatalError (List routeParams)
|
|
161
161
|
, head :
|
|
162
162
|
App data action routeParams
|
|
@@ -362,61 +362,19 @@ preRenderWithFallback { data, head, pages } =
|
|
|
362
362
|
|
|
363
363
|
{-| -}
|
|
364
364
|
serverRender :
|
|
365
|
-
{ data : routeParams -> Server.Request.
|
|
366
|
-
, action : routeParams -> Server.Request.
|
|
365
|
+
{ data : routeParams -> Server.Request.Request -> BackendTask FatalError (Server.Response.Response data ErrorPage)
|
|
366
|
+
, action : routeParams -> Server.Request.Request -> BackendTask FatalError (Server.Response.Response action ErrorPage)
|
|
367
367
|
, head : App data action routeParams -> List Head.Tag
|
|
368
368
|
}
|
|
369
369
|
-> Builder routeParams data action
|
|
370
370
|
serverRender { data, action, head } =
|
|
371
371
|
WithData
|
|
372
372
|
{ data =
|
|
373
|
-
\
|
|
374
|
-
|
|
375
|
-
|> data
|
|
376
|
-
|> Server.Request.getDecoder
|
|
377
|
-
|> (\decoder ->
|
|
378
|
-
Json.Decode.decodeValue decoder requestPayload
|
|
379
|
-
|> Result.mapError Json.Decode.errorToString
|
|
380
|
-
|> BackendTask.fromResult
|
|
381
|
-
-- TODO include title and better error context and formatting
|
|
382
|
-
|> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
|
|
383
|
-
)
|
|
384
|
-
)
|
|
385
|
-
|> BackendTask.andThen
|
|
386
|
-
(\rendered ->
|
|
387
|
-
case rendered of
|
|
388
|
-
Ok okRendered ->
|
|
389
|
-
okRendered
|
|
390
|
-
|
|
391
|
-
Err error ->
|
|
392
|
-
Server.Request.errorsToString error
|
|
393
|
-
|> FatalError.fromString
|
|
394
|
-
|> BackendTask.fail
|
|
395
|
-
)
|
|
373
|
+
\request routeParams ->
|
|
374
|
+
data routeParams request
|
|
396
375
|
, action =
|
|
397
|
-
\
|
|
398
|
-
|
|
399
|
-
|> action
|
|
400
|
-
|> Server.Request.getDecoder
|
|
401
|
-
|> (\decoder ->
|
|
402
|
-
Json.Decode.decodeValue decoder requestPayload
|
|
403
|
-
|> Result.mapError Json.Decode.errorToString
|
|
404
|
-
|> BackendTask.fromResult
|
|
405
|
-
-- TODO include title and better error context and formatting
|
|
406
|
-
|> BackendTask.onError (\error -> BackendTask.fail (FatalError.fromString error))
|
|
407
|
-
)
|
|
408
|
-
)
|
|
409
|
-
|> BackendTask.andThen
|
|
410
|
-
(\rendered ->
|
|
411
|
-
case rendered of
|
|
412
|
-
Ok okRendered ->
|
|
413
|
-
okRendered
|
|
414
|
-
|
|
415
|
-
Err error ->
|
|
416
|
-
Server.Request.errorsToString error
|
|
417
|
-
|> FatalError.fromString
|
|
418
|
-
|> BackendTask.fail
|
|
419
|
-
)
|
|
376
|
+
\request routeParams ->
|
|
377
|
+
action routeParams request
|
|
420
378
|
, staticRoutes = BackendTask.succeed []
|
|
421
379
|
, head = head
|
|
422
380
|
, serverless = True
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const compatibilityKey =
|
|
1
|
+
export const compatibilityKey = 19;
|
|
2
2
|
|
|
3
|
-
export const packageVersion = "3.0.0-beta.
|
|
3
|
+
export const packageVersion = "3.0.0-beta.42";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.42",
|
|
5
5
|
"homepage": "https://elm-pages.com",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/micromatch": "^4.0.2",
|
|
56
56
|
"@types/node": "^20.1.0",
|
|
57
57
|
"@types/serve-static": "^1.15.1",
|
|
58
|
-
"cypress": "^12.
|
|
58
|
+
"cypress": "^12.13.0",
|
|
59
59
|
"elm-codegen": "^0.3.0",
|
|
60
60
|
"elm-optimize-level-2": "^0.3.5",
|
|
61
61
|
"elm-review": "^2.10.2",
|
package/src/ApiRoute.elm
CHANGED
|
@@ -176,6 +176,7 @@ import BackendTask exposing (BackendTask)
|
|
|
176
176
|
import FatalError exposing (FatalError)
|
|
177
177
|
import Head
|
|
178
178
|
import Internal.ApiRoute exposing (ApiRoute(..), ApiRouteBuilder(..))
|
|
179
|
+
import Internal.Request
|
|
179
180
|
import Json.Decode as Decode
|
|
180
181
|
import Json.Encode
|
|
181
182
|
import Pattern
|
|
@@ -199,7 +200,7 @@ single handler =
|
|
|
199
200
|
|
|
200
201
|
|
|
201
202
|
{-| -}
|
|
202
|
-
serverRender : ApiRouteBuilder (Server.Request.
|
|
203
|
+
serverRender : ApiRouteBuilder (Server.Request.Request -> BackendTask FatalError (Server.Response.Response Never Never)) constructor -> ApiRoute Response
|
|
203
204
|
serverRender ((ApiRouteBuilder patterns pattern _ _ _) as fullHandler) =
|
|
204
205
|
ApiRoute
|
|
205
206
|
{ regex = Regex.fromString ("^" ++ pattern ++ "$") |> Maybe.withDefault Regex.never
|
|
@@ -208,36 +209,7 @@ serverRender ((ApiRouteBuilder patterns pattern _ _ _) as fullHandler) =
|
|
|
208
209
|
Internal.ApiRoute.tryMatch path fullHandler
|
|
209
210
|
|> Maybe.map
|
|
210
211
|
(\toBackendTask ->
|
|
211
|
-
|
|
212
|
-
|> (\decoder ->
|
|
213
|
-
Decode.decodeValue decoder serverRequest
|
|
214
|
-
|> Result.mapError Decode.errorToString
|
|
215
|
-
|> BackendTask.fromResult
|
|
216
|
-
|> BackendTask.map Just
|
|
217
|
-
)
|
|
218
|
-
|> BackendTask.onError
|
|
219
|
-
(\stringError ->
|
|
220
|
-
-- TODO make error with title and better context/formatting
|
|
221
|
-
FatalError.fromString stringError |> BackendTask.fail
|
|
222
|
-
)
|
|
223
|
-
|> BackendTask.andThen
|
|
224
|
-
(\rendered ->
|
|
225
|
-
case rendered of
|
|
226
|
-
Just (Ok okRendered) ->
|
|
227
|
-
okRendered
|
|
228
|
-
|
|
229
|
-
Just (Err errors) ->
|
|
230
|
-
errors
|
|
231
|
-
|> Server.Request.errorsToString
|
|
232
|
-
|> Server.Response.plainText
|
|
233
|
-
|> Server.Response.withStatusCode 400
|
|
234
|
-
|> BackendTask.succeed
|
|
235
|
-
|
|
236
|
-
Nothing ->
|
|
237
|
-
Server.Response.plainText "No matching request handler"
|
|
238
|
-
|> Server.Response.withStatusCode 400
|
|
239
|
-
|> BackendTask.succeed
|
|
240
|
-
)
|
|
212
|
+
toBackendTask (Internal.Request.toRequest serverRequest)
|
|
241
213
|
)
|
|
242
214
|
|> Maybe.map (BackendTask.map (Server.Response.toJson >> Just))
|
|
243
215
|
|> Maybe.withDefault
|
package/src/FormData.elm
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module FormData exposing (encode, parse)
|
|
1
|
+
module FormData exposing (encode, parse, parseToList)
|
|
2
2
|
|
|
3
3
|
import Dict exposing (Dict)
|
|
4
4
|
import List.NonEmpty exposing (NonEmpty)
|
|
@@ -34,6 +34,26 @@ parse rawString =
|
|
|
34
34
|
Dict.empty
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
parseToList : String -> List ( String, String )
|
|
38
|
+
parseToList rawString =
|
|
39
|
+
rawString
|
|
40
|
+
|> String.split "&"
|
|
41
|
+
|> List.concatMap
|
|
42
|
+
(\entry ->
|
|
43
|
+
case entry |> String.split "=" of
|
|
44
|
+
[ key, value ] ->
|
|
45
|
+
let
|
|
46
|
+
newValue : String
|
|
47
|
+
newValue =
|
|
48
|
+
value |> decode
|
|
49
|
+
in
|
|
50
|
+
[ ( key, newValue ) ]
|
|
51
|
+
|
|
52
|
+
_ ->
|
|
53
|
+
[]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
37
57
|
decode : String -> String
|
|
38
58
|
decode string =
|
|
39
59
|
string
|
package/src/Internal/Request.elm
CHANGED
|
@@ -1,7 +1,87 @@
|
|
|
1
|
-
module Internal.Request exposing (
|
|
1
|
+
module Internal.Request exposing (Request(..), RequestRecord, fakeRequest, toRequest)
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import CookieParser
|
|
4
|
+
import Dict exposing (Dict)
|
|
5
|
+
import Json.Decode as Decode
|
|
6
|
+
import Time
|
|
4
7
|
|
|
5
8
|
|
|
6
|
-
type
|
|
7
|
-
=
|
|
9
|
+
type Request
|
|
10
|
+
= Request RequestRecord
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
type alias RequestRecord =
|
|
14
|
+
{ time : Time.Posix
|
|
15
|
+
, method : String
|
|
16
|
+
, body : Maybe String
|
|
17
|
+
, rawUrl : String
|
|
18
|
+
, rawHeaders : Dict String String
|
|
19
|
+
, cookies : Dict String String
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
toRequest : Decode.Value -> Request
|
|
24
|
+
toRequest value =
|
|
25
|
+
Decode.decodeValue requestDecoder value
|
|
26
|
+
|> Result.map Request
|
|
27
|
+
|> Result.withDefault fakeRequest
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
fakeRequest : Request
|
|
31
|
+
fakeRequest =
|
|
32
|
+
Request
|
|
33
|
+
{ time = Time.millisToPosix 0
|
|
34
|
+
, method = "ERROR"
|
|
35
|
+
, body = Just "ERROR"
|
|
36
|
+
, rawUrl = "ERROR"
|
|
37
|
+
, rawHeaders = Dict.empty
|
|
38
|
+
, cookies = Dict.empty
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
requestDecoder : Decode.Decoder RequestRecord
|
|
43
|
+
requestDecoder =
|
|
44
|
+
Decode.succeed RequestRecord
|
|
45
|
+
|> andMap
|
|
46
|
+
(Decode.field "requestTime"
|
|
47
|
+
(Decode.int |> Decode.map Time.millisToPosix)
|
|
48
|
+
)
|
|
49
|
+
|> andMap (Decode.field "method" Decode.string)
|
|
50
|
+
|> andMap (Decode.field "body" (Decode.nullable Decode.string))
|
|
51
|
+
|> andMap
|
|
52
|
+
(Decode.string
|
|
53
|
+
|> Decode.field "rawUrl"
|
|
54
|
+
)
|
|
55
|
+
|> andMap (Decode.field "headers" (Decode.dict Decode.string))
|
|
56
|
+
|> andMap
|
|
57
|
+
(Decode.field "headers"
|
|
58
|
+
(optionalField "cookie" Decode.string
|
|
59
|
+
|> Decode.map
|
|
60
|
+
(Maybe.map CookieParser.parse
|
|
61
|
+
>> Maybe.withDefault Dict.empty
|
|
62
|
+
)
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
andMap : Decode.Decoder a -> Decode.Decoder (a -> b) -> Decode.Decoder b
|
|
68
|
+
andMap =
|
|
69
|
+
Decode.map2 (|>)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
optionalField : String -> Decode.Decoder a -> Decode.Decoder (Maybe a)
|
|
73
|
+
optionalField fieldName decoder_ =
|
|
74
|
+
let
|
|
75
|
+
finishDecoding : Decode.Value -> Decode.Decoder (Maybe a)
|
|
76
|
+
finishDecoding json =
|
|
77
|
+
case Decode.decodeValue (Decode.field fieldName Decode.value) json of
|
|
78
|
+
Ok _ ->
|
|
79
|
+
-- The field is present, so run the decoder on it.
|
|
80
|
+
Decode.map Just (Decode.field fieldName decoder_)
|
|
81
|
+
|
|
82
|
+
Err _ ->
|
|
83
|
+
-- The field was missing, which is fine!
|
|
84
|
+
Decode.succeed Nothing
|
|
85
|
+
in
|
|
86
|
+
Decode.value
|
|
87
|
+
|> Decode.andThen finishDecoding
|
package/src/Pages/FormData.elm
CHANGED
|
@@ -17,6 +17,7 @@ import Head exposing (Tag)
|
|
|
17
17
|
import Html exposing (Html)
|
|
18
18
|
import HtmlPrinter
|
|
19
19
|
import Internal.ApiRoute exposing (ApiRoute(..))
|
|
20
|
+
import Internal.Request
|
|
20
21
|
import Json.Decode as Decode
|
|
21
22
|
import Json.Encode
|
|
22
23
|
import PageServerResponse exposing (PageServerResponse)
|
|
@@ -422,7 +423,13 @@ initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as rende
|
|
|
422
423
|
--sendSinglePageProgress site model.allRawResponses config model payload
|
|
423
424
|
(case isAction of
|
|
424
425
|
Just _ ->
|
|
425
|
-
config.action
|
|
426
|
+
config.action
|
|
427
|
+
(RenderRequest.maybeRequestPayload renderRequest
|
|
428
|
+
|> Maybe.map Internal.Request.toRequest
|
|
429
|
+
|> Maybe.withDefault Internal.Request.fakeRequest
|
|
430
|
+
)
|
|
431
|
+
serverRequestPayload.frontmatter
|
|
432
|
+
|> BackendTask.map Just
|
|
426
433
|
|
|
427
434
|
Nothing ->
|
|
428
435
|
BackendTask.succeed Nothing
|
|
@@ -674,7 +681,13 @@ initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as rende
|
|
|
674
681
|
in
|
|
675
682
|
renderedResult
|
|
676
683
|
)
|
|
677
|
-
(config.data
|
|
684
|
+
(config.data
|
|
685
|
+
(RenderRequest.maybeRequestPayload renderRequest
|
|
686
|
+
|> Maybe.map Internal.Request.toRequest
|
|
687
|
+
|> Maybe.withDefault Internal.Request.fakeRequest
|
|
688
|
+
)
|
|
689
|
+
serverRequestPayload.frontmatter
|
|
690
|
+
)
|
|
678
691
|
config.sharedData
|
|
679
692
|
globalHeadTags
|
|
680
693
|
)
|
package/src/Pages/Navigation.elm
CHANGED
|
@@ -26,6 +26,7 @@ import Pages.Navigation
|
|
|
26
26
|
import Pages.PageUrl exposing (PageUrl)
|
|
27
27
|
import Pages.SiteConfig exposing (SiteConfig)
|
|
28
28
|
import PagesMsg exposing (PagesMsg)
|
|
29
|
+
import Server.Request
|
|
29
30
|
import Url exposing (Url)
|
|
30
31
|
import UrlPath exposing (UrlPath)
|
|
31
32
|
|
|
@@ -50,8 +51,8 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
|
|
50
51
|
, update : Form.Model -> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData) -> Maybe Pages.Navigation.Navigation -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
|
|
51
52
|
, subscriptions : route -> UrlPath -> userModel -> Sub userMsg
|
|
52
53
|
, sharedData : BackendTask FatalError sharedData
|
|
53
|
-
, data :
|
|
54
|
-
, action :
|
|
54
|
+
, data : Server.Request.Request -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
|
|
55
|
+
, action : Server.Request.Request -> route -> BackendTask FatalError (PageServerResponse actionData errorPage)
|
|
55
56
|
, onActionData : actionData -> Maybe userMsg
|
|
56
57
|
, view :
|
|
57
58
|
Form.Model
|