elm-pages 3.0.0-beta.30 → 3.0.0-beta.31

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 (41) hide show
  1. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
  2. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
  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/elm-stuff/0.19.1/i.dat +0 -0
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  6. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
  7. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +4 -104
  8. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +7125 -6415
  9. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  10. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  11. package/generator/dead-code-review/elm.json +4 -4
  12. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
  13. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
  14. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
  15. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -0
  16. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  17. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
  18. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
  19. package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
  20. package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +4 -104
  21. package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +16847 -16037
  22. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  23. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  24. package/generator/review/elm.json +5 -5
  25. package/generator/src/build.js +2 -1
  26. package/generator/src/cli.js +99 -93
  27. package/generator/src/compatibility-key.js +1 -1
  28. package/generator/src/compile-elm.js +18 -1
  29. package/generator/src/render.js +0 -2
  30. package/generator/src/resolve-elm-module.js +63 -0
  31. package/generator/src/rewrite-client-elm-json.js +1 -0
  32. package/generator/src/rewrite-elm-json-help.js +56 -0
  33. package/generator/src/rewrite-elm-json.js +13 -3
  34. package/generator/template/elm.json +1 -2
  35. package/package.json +17 -16
  36. package/src/Pages/Internal/Platform/Cli.elm +91 -0
  37. package/src/Pages/Internal/Platform.elm +1 -0
  38. package/src/Scaffold/Form.elm +187 -111
  39. package/src/Scaffold/Route.elm +261 -249
  40. package/src/Server/Session.elm +29 -9
  41. package/src/Server/SetCookie.elm +11 -3
@@ -1,5 +1,5 @@
1
1
  module Server.Session exposing
2
- ( withSession
2
+ ( withSession, withSessionResult
3
3
  , NotLoadedReason(..)
4
4
  , Session, empty, get, insert, remove, update, withFlash
5
5
  )
@@ -59,7 +59,7 @@ still be used to attempt to "unsign" the cookies. So if you have a single secret
59
59
  , secrets =
60
60
  BackendTask.map List.singleton
61
61
  (Env.expect "SESSION_SECRET2022-09-01")
62
- , options = cookieOptions
62
+ , options = Nothing
63
63
  }
64
64
 
65
65
  Then you add a second secret
@@ -71,7 +71,7 @@ Then you add a second secret
71
71
  (\newSecret oldSecret -> [ newSecret, oldSecret ])
72
72
  (Env.expect "SESSION_SECRET2022-12-01")
73
73
  (Env.expect "SESSION_SECRET2022-09-01")
74
- , options = cookieOptions
74
+ , options = Nothing
75
75
  }
76
76
 
77
77
  The new secret (`2022-12-01`) will be used to sign all requests. This API always re-signs using the newest secret in the list
@@ -89,14 +89,14 @@ it will invalidate all cookies signed with that. For example, if we remove our o
89
89
  , secrets =
90
90
  BackendTask.map List.singleton
91
91
  (Env.expect "SESSION_SECRET2022-12-01")
92
- , options = cookieOptions
92
+ , options = Nothing
93
93
  }
94
94
 
95
95
  And then a user makes a request but had a session signed with our old secret (`2022-09-01`), the session will be invalid
96
96
  (so `withSession` would parse the session for that request as `Nothing`). It's standard for cookies to have an expiration date,
97
97
  so there's nothing wrong with an old session expiring (and the browser will eventually delete old cookies), just be aware of that when rotating secrets.
98
98
 
99
- @docs withSession
99
+ @docs withSession, withSessionResult
100
100
 
101
101
  @docs NotLoadedReason
102
102
 
@@ -243,12 +243,32 @@ flashPrefix =
243
243
  withSession :
244
244
  { name : String
245
245
  , secrets : BackendTask error (List String)
246
- , options : SetCookie.Options
246
+ , options : Maybe SetCookie.Options
247
247
  }
248
- -> (request -> Result NotLoadedReason Session -> BackendTask error ( Session, Response data errorPage ))
248
+ -> (request -> Session -> BackendTask error ( Session, Response data errorPage ))
249
249
  -> Server.Request.Parser request
250
250
  -> Server.Request.Parser (BackendTask error (Response data errorPage))
251
251
  withSession config toRequest userRequest =
252
+ withSessionResult config
253
+ (\request session ->
254
+ toRequest request
255
+ (session
256
+ |> Result.withDefault empty
257
+ )
258
+ )
259
+ userRequest
260
+
261
+
262
+ {-| -}
263
+ withSessionResult :
264
+ { name : String
265
+ , secrets : BackendTask error (List String)
266
+ , options : Maybe SetCookie.Options
267
+ }
268
+ -> (request -> Result NotLoadedReason Session -> BackendTask error ( Session, Response data errorPage ))
269
+ -> Server.Request.Parser request
270
+ -> Server.Request.Parser (BackendTask error (Response data errorPage))
271
+ withSessionResult config toRequest userRequest =
252
272
  Server.Request.map2
253
273
  (\maybeSessionCookie userRequestData ->
254
274
  let
@@ -283,7 +303,7 @@ withSession config toRequest userRequest =
283
303
  encodeSessionUpdate :
284
304
  { name : String
285
305
  , secrets : BackendTask error (List String)
286
- , options : SetCookie.Options
306
+ , options : Maybe SetCookie.Options
287
307
  }
288
308
  -> (c -> d -> BackendTask error ( Session, Response data errorPage ))
289
309
  -> c
@@ -298,7 +318,7 @@ encodeSessionUpdate config toRequest userRequestData sessionResult =
298
318
  (\encoded ->
299
319
  response
300
320
  |> Server.Response.withSetCookieHeader
301
- (SetCookie.setCookie config.name encoded config.options)
321
+ (SetCookie.setCookie config.name encoded (config.options |> Maybe.withDefault SetCookie.initOptions))
302
322
  )
303
323
  (sign config.secrets
304
324
  (encodeNonExpiringPairs sessionUpdate)
@@ -2,7 +2,7 @@ module Server.SetCookie exposing
2
2
  ( SetCookie
3
3
  , SameSite(..)
4
4
  , Options, initOptions
5
- , withImmediateExpiration, makeVisibleToJavaScript, nonSecure, setCookie, withDomain, withExpiration, withMaxAge, withPath, withSameSite
5
+ , withImmediateExpiration, makeVisibleToJavaScript, nonSecure, setCookie, withDomain, withExpiration, withMaxAge, withPath, withoutPath, withSameSite
6
6
  , toString
7
7
  )
8
8
 
@@ -29,7 +29,7 @@ You can learn more about the basics of cookies in the Web Platform in these help
29
29
 
30
30
  @docs Options, initOptions
31
31
 
32
- @docs withImmediateExpiration, makeVisibleToJavaScript, nonSecure, setCookie, withDomain, withExpiration, withMaxAge, withPath, withSameSite
32
+ @docs withImmediateExpiration, makeVisibleToJavaScript, nonSecure, setCookie, withDomain, withExpiration, withMaxAge, withPath, withoutPath, withSameSite
33
33
 
34
34
 
35
35
  ## Internal
@@ -143,7 +143,7 @@ initOptions =
143
143
  { expiration = Nothing
144
144
  , visibleToJavaScript = False
145
145
  , maxAge = Nothing
146
- , path = Nothing
146
+ , path = Just "/"
147
147
  , domain = Nothing
148
148
  , secure = True
149
149
  , sameSite = Nothing
@@ -200,6 +200,14 @@ withPath path builder =
200
200
  }
201
201
 
202
202
 
203
+ {-| -}
204
+ withoutPath : Options -> Options
205
+ withoutPath builder =
206
+ { builder
207
+ | path = Nothing
208
+ }
209
+
210
+
203
211
  {-| -}
204
212
  withDomain : String -> Options -> Options
205
213
  withDomain domain builder =