elm-pages 3.0.0-beta.40 → 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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.cjs +251 -285
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  6. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  7. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  8. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  9. package/generator/src/RouteBuilder.elm +19 -60
  10. package/generator/src/SharedTemplate.elm +5 -5
  11. package/generator/src/compatibility-key.js +2 -2
  12. package/package.json +2 -2
  13. package/src/ApiRoute.elm +3 -31
  14. package/src/BackendTask.elm +18 -24
  15. package/src/FormData.elm +21 -1
  16. package/src/Head/Seo.elm +4 -4
  17. package/src/Internal/Request.elm +84 -4
  18. package/src/Pages/ConcurrentSubmission.elm +127 -0
  19. package/src/Pages/Form.elm +151 -40
  20. package/src/Pages/FormData.elm +19 -0
  21. package/src/Pages/Internal/NotFoundReason.elm +4 -4
  22. package/src/Pages/Internal/Platform/Cli.elm +30 -17
  23. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  24. package/src/Pages/Internal/Platform.elm +39 -38
  25. package/src/Pages/Internal/ResponseSketch.elm +2 -2
  26. package/src/Pages/Manifest.elm +23 -7
  27. package/src/Pages/Navigation.elm +85 -0
  28. package/src/Pages/PageUrl.elm +3 -3
  29. package/src/Pages/ProgramConfig.elm +13 -11
  30. package/src/Pages/Script.elm +64 -7
  31. package/src/Pages/Url.elm +3 -3
  32. package/src/PagesMsg.elm +9 -3
  33. package/src/RenderRequest.elm +7 -7
  34. package/src/Scaffold/Form.elm +28 -5
  35. package/src/Scaffold/Route.elm +82 -53
  36. package/src/Server/Request.elm +446 -952
  37. package/src/Server/Session.elm +141 -91
  38. package/src/Server/SetCookie.elm +71 -31
  39. package/src/{Path.elm → UrlPath.elm} +21 -21
  40. package/src/Pages/Transition.elm +0 -79
@@ -15,18 +15,20 @@ import Http
15
15
  import Json.Decode as Decode
16
16
  import Json.Encode
17
17
  import PageServerResponse exposing (PageServerResponse)
18
+ import Pages.ConcurrentSubmission
18
19
  import Pages.Fetcher
19
20
  import Pages.Flags
20
21
  import Pages.Internal.NotFoundReason exposing (NotFoundReason)
21
22
  import Pages.Internal.Platform.ToJsPayload
22
23
  import Pages.Internal.ResponseSketch exposing (ResponseSketch)
23
24
  import Pages.Internal.RoutePattern exposing (RoutePattern)
25
+ import Pages.Navigation
24
26
  import Pages.PageUrl exposing (PageUrl)
25
27
  import Pages.SiteConfig exposing (SiteConfig)
26
- import Pages.Transition
27
28
  import PagesMsg exposing (PagesMsg)
28
- import Path exposing (Path)
29
+ import Server.Request
29
30
  import Url exposing (Url)
31
+ import UrlPath exposing (UrlPath)
30
32
 
31
33
 
32
34
  type alias ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage =
@@ -38,7 +40,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
38
40
  ->
39
41
  Maybe
40
42
  { path :
41
- { path : Path
43
+ { path : UrlPath
42
44
  , query : Maybe String
43
45
  , fragment : Maybe String
44
46
  }
@@ -46,18 +48,18 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
46
48
  , pageUrl : Maybe PageUrl
47
49
  }
48
50
  -> ( userModel, effect )
49
- , update : Form.Model -> Dict String (Pages.Transition.FetcherState actionData) -> Maybe Pages.Transition.Transition -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
50
- , subscriptions : route -> Path -> userModel -> Sub userMsg
51
+ , update : Form.Model -> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData) -> Maybe Pages.Navigation.Navigation -> sharedData -> pageData -> Maybe Browser.Navigation.Key -> userMsg -> userModel -> ( userModel, effect )
52
+ , subscriptions : route -> UrlPath -> userModel -> Sub userMsg
51
53
  , sharedData : BackendTask FatalError sharedData
52
- , data : Decode.Value -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
53
- , action : Decode.Value -> route -> BackendTask FatalError (PageServerResponse actionData errorPage)
54
+ , data : Server.Request.Request -> route -> BackendTask FatalError (PageServerResponse pageData errorPage)
55
+ , action : Server.Request.Request -> route -> BackendTask FatalError (PageServerResponse actionData errorPage)
54
56
  , onActionData : actionData -> Maybe userMsg
55
57
  , view :
56
58
  Form.Model
57
- -> Dict String (Pages.Transition.FetcherState actionData)
58
- -> Maybe Pages.Transition.Transition
59
+ -> Dict String (Pages.ConcurrentSubmission.ConcurrentSubmission actionData)
60
+ -> Maybe Pages.Navigation.Navigation
59
61
  ->
60
- { path : Path
62
+ { path : UrlPath
61
63
  , route : route
62
64
  }
63
65
  -> Maybe PageUrl
@@ -81,7 +83,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
81
83
  { protocol : Url.Protocol
82
84
  , host : String
83
85
  , port_ : Maybe Int
84
- , path : Path
86
+ , path : UrlPath
85
87
  , query : Maybe String
86
88
  , fragment : Maybe String
87
89
  , metadata : route
@@ -6,10 +6,15 @@ module Pages.Script exposing
6
6
  , Error(..)
7
7
  )
8
8
 
9
- {-|
9
+ {-| An elm-pages Script is a way to execute an `elm-pages` `BackendTask`.
10
+
11
+ Read more about using the `elm-pages` CLI to run (or bundle) scripts, plus a brief tutorial, at <https://elm-pages-v3.netlify.app/docs/elm-pages-scripts>.
10
12
 
11
13
  @docs Script
12
14
 
15
+
16
+ ## Defining Scripts
17
+
13
18
  @docs withCliOptions, withoutCliOptions
14
19
 
15
20
 
@@ -40,18 +45,37 @@ import Json.Encode as Encode
40
45
  import Pages.Internal.Script
41
46
 
42
47
 
43
- {-| -}
48
+ {-| The type for your `run` function that can be executed by `elm-pages run`.
49
+ -}
44
50
  type alias Script =
45
51
  Pages.Internal.Script.Script
46
52
 
47
53
 
48
- {-| -}
54
+ {-| The recoverable error type for file writes. You can use `BackendTask.allowFatal` if you want to allow the program to crash
55
+ with an error message if a file write is unsuccessful.
56
+ -}
49
57
  type Error
50
58
  = --TODO make more descriptive
51
59
  FileWriteError
52
60
 
53
61
 
54
- {-| -}
62
+ {-| Write a file to the file system.
63
+
64
+ module MyScript exposing (run)
65
+
66
+ import BackendTask
67
+ import Pages.Script as Script
68
+
69
+ run =
70
+ Script.withoutCliOptions
71
+ (Script.writeFile
72
+ { path = "hello.json"
73
+ , body = """{ "message": "Hello, World!" }"""
74
+ }
75
+ |> BackendTask.allowFatal
76
+ )
77
+
78
+ -}
55
79
  writeFile : { path : String, body : String } -> BackendTask { fatal : FatalError, recoverable : Error } ()
56
80
  writeFile { path, body } =
57
81
  BackendTask.Internal.Request.request
@@ -69,7 +93,20 @@ writeFile { path, body } =
69
93
  }
70
94
 
71
95
 
72
- {-| -}
96
+ {-| Log to stdout.
97
+
98
+ module MyScript exposing (run)
99
+
100
+ import BackendTask
101
+ import Pages.Script as Script
102
+
103
+ run =
104
+ Script.withoutCliOptions
105
+ (Script.log "Hello!"
106
+ |> BackendTask.allowFatal
107
+ )
108
+
109
+ -}
73
110
  log : String -> BackendTask error ()
74
111
  log message =
75
112
  BackendTask.Internal.Request.request
@@ -84,7 +121,20 @@ log message =
84
121
  }
85
122
 
86
123
 
87
- {-| -}
124
+ {-| Define a simple Script (no CLI Options).
125
+
126
+ module MyScript exposing (run)
127
+
128
+ import BackendTask
129
+ import Pages.Script as Script
130
+
131
+ run =
132
+ Script.withoutCliOptions
133
+ (Script.log "Hello!"
134
+ |> BackendTask.allowFatal
135
+ )
136
+
137
+ -}
88
138
  withoutCliOptions : BackendTask FatalError () -> Script
89
139
  withoutCliOptions execute =
90
140
  Pages.Internal.Script.Script
@@ -99,7 +149,14 @@ withoutCliOptions execute =
99
149
  )
100
150
 
101
151
 
102
- {-| -}
152
+ {-| Same as [`withoutCliOptions`](#withoutCliOptions), but allows you to define a CLI Options Parser so the user can
153
+ pass in additional options for the script.
154
+
155
+ Uses <https://package.elm-lang.org/packages/dillonkearns/elm-cli-options-parser/latest/>.
156
+
157
+ Read more at <https://elm-pages-v3.netlify.app/docs/elm-pages-scripts/#adding-command-line-options>.
158
+
159
+ -}
103
160
  withCliOptions : Program.Config cliOptions -> (cliOptions -> BackendTask FatalError ()) -> Script
104
161
  withCliOptions config execute =
105
162
  Pages.Internal.Script.Script
package/src/Pages/Url.elm CHANGED
@@ -12,7 +12,7 @@ If you refer to a local page, like `Route.Index |> Route.toPath |> Pages.Url.fro
12
12
  -}
13
13
 
14
14
  import Pages.Internal.String as String
15
- import Path exposing (Path)
15
+ import UrlPath exposing (UrlPath)
16
16
 
17
17
 
18
18
  {-| -}
@@ -22,9 +22,9 @@ type Url
22
22
 
23
23
 
24
24
  {-| -}
25
- fromPath : Path -> Url
25
+ fromPath : UrlPath -> Url
26
26
  fromPath path =
27
- path |> Path.toAbsolute |> Internal
27
+ path |> UrlPath.toAbsolute |> Internal
28
28
 
29
29
 
30
30
  {-| -}
package/src/PagesMsg.elm CHANGED
@@ -27,6 +27,8 @@ type alias PagesMsg userMsg =
27
27
 
28
28
  {-|
29
29
 
30
+ import Form
31
+ import Pages.Form
30
32
  import PagesMsg exposing (PagesMsg)
31
33
 
32
34
  type Msg
@@ -46,10 +48,14 @@ type alias PagesMsg userMsg =
46
48
  [ onClick (PagesMsg.fromMsg ToggleMenu) ]
47
49
  []
48
50
 
49
- -- `Form.renderHtml` gives us `Html (PagesMsg msg)`, so we don't need to wrap its Msg type
51
+ -- `Pages.Form.renderHtml` gives us `Html (PagesMsg msg)`, so we don't need to wrap its Msg type
50
52
  , logoutForm
51
- |> Form.withOnSubmit (\_ -> NewItemSubmitted)
52
- |> Form.renderHtml "logout" [] (\_ -> Nothing) app Nothing
53
+ |> Pages.Form.renderHtml []
54
+ Pages.Form.Serial
55
+ (Form.options "logout"
56
+ |> Form.withOnSubmit (\_ -> NewItemSubmitted)
57
+ )
58
+ app
53
59
  ]
54
60
  }
55
61
 
@@ -13,15 +13,15 @@ import Internal.ApiRoute
13
13
  import Json.Decode as Decode
14
14
  import Json.Encode as Encode
15
15
  import Pages.ProgramConfig exposing (ProgramConfig)
16
- import Path exposing (Path)
17
16
  import Regex
18
17
  import Url exposing (Url)
18
+ import UrlPath exposing (UrlPath)
19
19
 
20
20
 
21
21
  type RequestPayload route
22
- = Page { path : Path, frontmatter : route }
22
+ = Page { path : UrlPath, frontmatter : route }
23
23
  | Api ( String, ApiRoute.ApiRoute ApiRoute.Response )
24
- | NotFound Path
24
+ | NotFound UrlPath
25
25
 
26
26
 
27
27
  type RenderRequest route
@@ -32,7 +32,7 @@ default : RenderRequest route
32
32
  default =
33
33
  SinglePage
34
34
  HtmlAndJson
35
- (NotFound (Path.fromString "/error"))
35
+ (NotFound (UrlPath.fromString "/error"))
36
36
  Encode.null
37
37
 
38
38
 
@@ -119,12 +119,12 @@ requestPayloadDecoder config =
119
119
  ( path, justApi ) |> Api
120
120
 
121
121
  Nothing ->
122
- NotFound (Path.fromString path)
122
+ NotFound (UrlPath.fromString path)
123
123
 
124
124
  else
125
125
  Page
126
126
  { frontmatter = route
127
- , path = config.routeToPath route |> Path.join
127
+ , path = config.routeToPath route |> UrlPath.join
128
128
  }
129
129
 
130
130
  Nothing ->
@@ -133,7 +133,7 @@ requestPayloadDecoder config =
133
133
  ( path, justApi ) |> Api
134
134
 
135
135
  Nothing ->
136
- NotFound (Path.fromString path)
136
+ NotFound (UrlPath.fromString path)
137
137
  )
138
138
  )
139
139
  |> Decode.field "path"
@@ -1,16 +1,27 @@
1
1
  module Scaffold.Form exposing
2
2
  ( Kind(..), provide, restArgsParser
3
3
  , Context
4
- , fieldEncoder, recordEncoder
4
+ , recordEncoder, fieldEncoder
5
5
  )
6
6
 
7
- {-|
7
+ {-| This module helps you with scaffolding a form in `elm-pages`, similar to how rails generators are used to scaffold out forms to
8
+ get up and running quickly with the starting point for a form with different field types. See also [`Scaffold.Route`](Scaffold-Route).
9
+
10
+ See the `AddRoute` script in the starter template for an example. It's usually easiest to modify that script as a starting
11
+ point rather than using this API from scratch.
12
+
13
+ Using the `AddRoute` script from the default starter template, you can run a command like this:
14
+
15
+ `npx elm-pages run AddRoute Profile.Username_.Edit first last bio:textarea dob:date` to generate a Route module `app/Route/Profile/Username_/Edit.elm`
16
+ with the wiring form a `Form`.
17
+
18
+ [Learn more about writing and running elm-pages Scripts for scaffolding](https://elm-pages-v3.netlify.app/docs/elm-pages-scripts#scaffolding-a-route-module).
8
19
 
9
20
  @docs Kind, provide, restArgsParser
10
21
 
11
22
  @docs Context
12
23
 
13
- @docs fieldEncoder, recordEncoder
24
+ @docs recordEncoder, fieldEncoder
14
25
 
15
26
  -}
16
27
 
@@ -159,7 +170,18 @@ fieldToParam ( name, _ ) =
159
170
  ( name, Nothing )
160
171
 
161
172
 
162
- {-| -}
173
+ {-| This parser handles the following field types (or `text` if none is provided):
174
+
175
+ - `text`
176
+ - `textarea`
177
+ - `checkbox`
178
+ - `time`
179
+ - `date`
180
+
181
+ The naming convention follows the same naming as the HTML form field elements or attributes that are used to represent them.
182
+ In addition to using the appropriate field type, this will also give you an Elm type with the corresponding base type (like `Date` for `date` or `Bool` for `checkbox`).
183
+
184
+ -}
163
185
  restArgsParser : Cli.Option.Option (List String) (List ( String, Kind )) Cli.Option.RestArgsOption
164
186
  restArgsParser =
165
187
  Cli.Option.restArgs "formFields"
@@ -506,7 +528,8 @@ recordEncoder record fields =
506
528
  )
507
529
 
508
530
 
509
- {-| -}
531
+ {-| A lower-level, more granular version of `recordEncoder` - lets you generate a JSON Encoder `Expression` for an individual Field rather than a group of Fields.
532
+ -}
510
533
  fieldEncoder : Elm.Expression -> String -> Kind -> Elm.Expression
511
534
  fieldEncoder record name kind =
512
535
  Elm.apply
@@ -9,12 +9,17 @@ module Scaffold.Route exposing
9
9
 
10
10
  {-| This module provides some functions for scaffolding code for a new Route Module. It uses [`elm-codegen`'s API](https://package.elm-lang.org/packages/mdgriffith/elm-codegen/latest/) for generating code.
11
11
 
12
- Typically you'll want to use this via the `elm-pages codegen` CLI command. The default starter template includes a file that uses these functions, which you can tweak to customize your scaffolding commands.
13
- Learn more about [the `elm-pages run` CLI command in its docs page](https://elm-pages.com/docs/run-command).
12
+ Typically you'll want to use this via the `elm-pages run` CLI command. The default starter template includes a Script that uses these functions, which you can tweak to customize your scaffolding commands.
13
+ [Learn more about writing and running elm-pages Scripts for scaffolding](https://elm-pages-v3.netlify.app/docs/elm-pages-scripts#scaffolding-a-route-module).
14
+
15
+ It's typically easiest to modify the `AddRoute` script from the starter template and adjust it to your needs rather than writing one from scratch.
14
16
 
15
17
 
16
18
  ## Initializing the Generator Builder
17
19
 
20
+ These functions mirror the `RouteBuilder` API that you use in your Route modules to define your route. The difference is that
21
+ instead of defining a route, this is defining a code generator for a Route module.
22
+
18
23
  @docs buildWithLocalState, buildWithSharedState, buildNoState, Builder
19
24
 
20
25
  @docs Type
@@ -87,8 +92,8 @@ typeToDeclaration name type_ =
87
92
  type Builder
88
93
  = ServerRender
89
94
  (List Elm.Declaration)
90
- { data : ( Type, Elm.Expression -> Elm.Expression )
91
- , action : ( Type, Elm.Expression -> Elm.Expression )
95
+ { data : ( Type, Elm.Expression -> Elm.Expression -> Elm.Expression )
96
+ , action : ( Type, Elm.Expression -> Elm.Expression -> Elm.Expression )
92
97
  , head : Elm.Expression -> Elm.Expression
93
98
  , moduleName : List String
94
99
  }
@@ -103,8 +108,8 @@ type Builder
103
108
 
104
109
  {-| -}
105
110
  serverRender :
106
- { data : ( Type, Elm.Expression -> Elm.Expression )
107
- , action : ( Type, Elm.Expression -> Elm.Expression )
111
+ { data : ( Type, Elm.Expression -> Elm.Expression -> Elm.Expression )
112
+ , action : ( Type, Elm.Expression -> Elm.Expression -> Elm.Expression )
108
113
  , head : Elm.Expression -> Elm.Expression
109
114
  , moduleName : List String
110
115
  }
@@ -198,7 +203,7 @@ buildNoState definitions builder_ =
198
203
  , app = app
199
204
  }
200
205
  , localState = Nothing
201
- , data = builder.data |> Tuple.second
206
+ , data = builder.data |> Tuple.second |> (\fn -> \_ -> fn)
202
207
  , action = builder.pages |> Pages
203
208
  , head = builder.head
204
209
  , types =
@@ -214,7 +219,11 @@ buildNoState definitions builder_ =
214
219
  }
215
220
 
216
221
 
217
- {-| -}
222
+ {-| The helpers in this module help you generate a Route module file with the core boilerplate abstracted away.
223
+
224
+ You can also define additional top-level declarations in the generated Route module using this helper.
225
+
226
+ -}
218
227
  addDeclarations : List Elm.Declaration -> Builder -> Builder
219
228
  addDeclarations declarations builder =
220
229
  case builder of
@@ -337,7 +346,7 @@ buildWithLocalState definitions builder_ =
337
346
  }
338
347
  , state = LocalState
339
348
  }
340
- , data = builder.data |> Tuple.second
349
+ , data = builder.data |> Tuple.second |> (\fn -> \_ -> fn)
341
350
  , action = builder.pages |> Pages
342
351
  , head = builder.head
343
352
  , types =
@@ -465,7 +474,7 @@ buildWithSharedState definitions builder_ =
465
474
  }
466
475
  , state = SharedState
467
476
  }
468
- , data = builder.data |> Tuple.second
477
+ , data = builder.data |> Tuple.second |> (\fn -> \_ -> fn)
469
478
  , action = builder.pages |> Pages
470
479
  , head = builder.head
471
480
  , types =
@@ -487,7 +496,7 @@ type State
487
496
 
488
497
 
489
498
  type ActionOrPages
490
- = Action (Elm.Expression -> Elm.Expression)
499
+ = Action (Elm.Expression -> Elm.Expression -> Elm.Expression)
491
500
  | Pages (Maybe Elm.Expression)
492
501
 
493
502
 
@@ -503,7 +512,7 @@ userFunction :
503
512
  , subscriptions : Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
504
513
  , state : State
505
514
  }
506
- , data : Elm.Expression -> Elm.Expression
515
+ , data : Elm.Expression -> Elm.Expression -> Elm.Expression
507
516
  , action : ActionOrPages
508
517
  , head : Elm.Expression -> Elm.Expression
509
518
  , types : { model : Type, msg : Type, data : Type, actionData : Type }
@@ -629,7 +638,7 @@ userFunction moduleName definitions =
629
638
  Elm.Declare.fn4
630
639
  "subscriptions"
631
640
  ( "routeParams", "RouteParams" |> Elm.Annotation.named [] |> Just )
632
- ( "path", Elm.Annotation.namedWith [ "Path" ] "Path" [] |> Just )
641
+ ( "path", Elm.Annotation.namedWith [ "UrlPath" ] "UrlPath" [] |> Just )
633
642
  ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") )
634
643
  ( "model", localType "Model" |> Just )
635
644
  (\routeParams path shared model ->
@@ -647,7 +656,7 @@ userFunction moduleName definitions =
647
656
  Elm.Declare.function "data"
648
657
  []
649
658
  (\_ ->
650
- definitions.data Elm.unit
659
+ definitions.data Elm.unit Elm.unit
651
660
  |> Elm.withType
652
661
  (case definitions.action of
653
662
  Pages _ ->
@@ -665,11 +674,16 @@ userFunction moduleName definitions =
665
674
  |> Elm.Annotation.named []
666
675
  |> Just
667
676
  )
677
+ , ( "request"
678
+ , "Request"
679
+ |> Elm.Annotation.named [ "Server", "Request" ]
680
+ |> Just
681
+ )
668
682
  ]
669
683
  (\args ->
670
684
  case args of
671
- [ arg ] ->
672
- definitions.data arg
685
+ [ arg, arg2 ] ->
686
+ definitions.data arg arg2
673
687
  |> Elm.withType
674
688
  (case definitions.action of
675
689
  Pages _ ->
@@ -693,11 +707,16 @@ userFunction moduleName definitions =
693
707
  |> Elm.Annotation.named []
694
708
  |> Just
695
709
  )
710
+ , ( "request"
711
+ , "Request"
712
+ |> Elm.Annotation.named [ "Server", "Request" ]
713
+ |> Just
714
+ )
696
715
  ]
697
716
  (\args ->
698
717
  case args of
699
- [ arg ] ->
700
- action_ arg |> Elm.withType (myType "ActionData")
718
+ [ arg1, arg2 ] ->
719
+ action_ arg1 arg2 |> Elm.withType (myType "ActionData")
701
720
 
702
721
  _ ->
703
722
  Elm.unit
@@ -741,17 +760,17 @@ userFunction moduleName definitions =
741
760
  Action _ ->
742
761
  serverRender_
743
762
  { action =
744
- \routeParams ->
763
+ \routeParams request ->
745
764
  actionFn
746
765
  |> Maybe.map
747
766
  (\justActionFn ->
748
- justActionFn.call [ routeParams ]
767
+ justActionFn.call [ routeParams, request ]
749
768
  |> Elm.withType (myType "ActionData")
750
769
  )
751
770
  |> Maybe.withDefault Elm.unit
752
771
  , data =
753
- \routeParams ->
754
- dataFn.call [ routeParams ]
772
+ \routeParams request ->
773
+ dataFn.call [ routeParams, request ]
755
774
  |> Elm.withType (myType "Data")
756
775
  , head = headFn.call
757
776
  }
@@ -852,16 +871,18 @@ localType =
852
871
 
853
872
  myType : String -> Elm.Annotation.Annotation
854
873
  myType dataType =
855
- Elm.Annotation.namedWith [ "Server", "Request" ]
856
- "Parser"
857
- [ throwableTask
858
- (Elm.Annotation.namedWith [ "Server", "Response" ]
859
- "Response"
860
- [ Elm.Annotation.named [] dataType
861
- , Elm.Annotation.named [ "ErrorPage" ] "ErrorPage"
862
- ]
863
- )
864
- ]
874
+ --Elm.Annotation.function
875
+ -- [ Elm.Annotation.namedWith [ "Server", "Request" ]
876
+ -- "Request"
877
+ -- []
878
+ -- ]
879
+ throwableTask
880
+ (Elm.Annotation.namedWith [ "Server", "Response" ]
881
+ "Response"
882
+ [ Elm.Annotation.named [] dataType
883
+ , Elm.Annotation.named [ "ErrorPage" ] "ErrorPage"
884
+ ]
885
+ )
865
886
 
866
887
 
867
888
  appType : Elm.Annotation.Annotation
@@ -875,8 +896,8 @@ appType =
875
896
 
876
897
 
877
898
  serverRender_ :
878
- { data : Elm.Expression -> Elm.Expression
879
- , action : Elm.Expression -> Elm.Expression
899
+ { data : Elm.Expression -> Elm.Expression -> Elm.Expression
900
+ , action : Elm.Expression -> Elm.Expression -> Elm.Expression
880
901
  , head : Elm.Expression -> Elm.Expression
881
902
  }
882
903
  -> Elm.Expression
@@ -911,22 +932,20 @@ serverRender_ serverRenderArg =
911
932
  )
912
933
  , ( "action"
913
934
  , Elm.Annotation.function
914
- [ Elm.Annotation.var "routeParams" ]
915
- (Elm.Annotation.namedWith
916
- [ "Server", "Request" ]
917
- "Parser"
918
- [ throwableTask
919
- (Elm.Annotation.namedWith
920
- [ "Server", "Response" ]
921
- "Response"
922
- [ Elm.Annotation.var "action"
923
- , Elm.Annotation.namedWith
924
- [ "ErrorPage" ]
925
- "ErrorPage"
926
- []
927
- ]
928
- )
929
- ]
935
+ [ Elm.Annotation.var "routeParams"
936
+ , Elm.Annotation.named [ "Server", "Request" ] "Request"
937
+ ]
938
+ (throwableTask
939
+ (Elm.Annotation.namedWith
940
+ [ "Server", "Response" ]
941
+ "Response"
942
+ [ Elm.Annotation.var "action"
943
+ , Elm.Annotation.namedWith
944
+ [ "ErrorPage" ]
945
+ "ErrorPage"
946
+ []
947
+ ]
948
+ )
930
949
  )
931
950
  )
932
951
  , ( "head"
@@ -959,10 +978,20 @@ serverRender_ serverRenderArg =
959
978
  [ Elm.record
960
979
  [ Tuple.pair
961
980
  "data"
962
- (Elm.functionReduced "serverRenderUnpack" serverRenderArg.data)
981
+ (Elm.functionReduced
982
+ "dataUnpack"
983
+ (\functionReducedUnpack ->
984
+ Elm.functionReduced "dataUnpack2" (serverRenderArg.data functionReducedUnpack)
985
+ )
986
+ )
963
987
  , Tuple.pair
964
988
  "action"
965
- (Elm.functionReduced "serverRenderUnpack" serverRenderArg.action)
989
+ (Elm.functionReduced
990
+ "actionUnpack"
991
+ (\functionReducedUnpack ->
992
+ Elm.functionReduced "actionUnpack2" (serverRenderArg.action functionReducedUnpack)
993
+ )
994
+ )
966
995
  , Tuple.pair
967
996
  "head"
968
997
  (Elm.functionReduced "serverRenderUnpack" serverRenderArg.head)
@@ -1199,7 +1228,7 @@ buildWithLocalState_ buildWithLocalStateArg buildWithLocalStateArg0 =
1199
1228
  , ( "subscriptions"
1200
1229
  , Elm.Annotation.function
1201
1230
  [ Elm.Annotation.var "routeParams"
1202
- , Elm.Annotation.namedWith [ "Path" ] "Path" []
1231
+ , Elm.Annotation.namedWith [ "UrlPath" ] "UrlPath" []
1203
1232
  , Elm.Annotation.namedWith [ "Shared" ] "Model" []
1204
1233
  , Elm.Annotation.var "model"
1205
1234
  ]