elm-pages 2.1.11 → 3.0.0-beta.0
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/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolationsTest.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Reporter.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Runner.elmo +0 -0
- 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/{template/public/style.css → review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/lock} +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 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +6795 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +27617 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +110 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +187 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/package.json +1 -0
- package/generator/review/elm-stuff/tests-0.19.1/src/Reporter.elm +26 -0
- package/generator/review/elm-stuff/tests-0.19.1/src/Runner.elm +62 -0
- package/generator/review/elm.json +13 -4
- package/{src → generator/review/src}/Pages/Review/NoContractViolations.elm +148 -148
- package/generator/review/tests/Pages/Review/NoContractViolationsTest.elm +331 -0
- package/generator/src/RouteBuilder.elm +420 -0
- package/generator/src/SharedTemplate.elm +4 -5
- package/generator/src/SiteConfig.elm +3 -9
- package/generator/src/build.js +308 -95
- package/generator/src/cli.js +103 -8
- package/generator/src/codegen.js +192 -35
- package/generator/src/compile-elm.js +183 -31
- package/generator/src/dev-server.js +353 -96
- package/generator/src/elm-application.json +3 -1
- package/generator/src/elm-codegen.js +34 -0
- package/generator/src/elm-file-constants.js +2 -0
- package/generator/src/error-formatter.js +20 -1
- package/generator/src/generate-template-module-connector.js +120 -924
- package/generator/src/hello.ts +5 -0
- package/generator/src/pre-render-html.js +58 -104
- package/generator/src/render-worker.js +27 -13
- package/generator/src/render.js +252 -197
- package/generator/src/request-cache-fs.js +18 -0
- package/generator/src/request-cache.js +128 -56
- package/generator/src/rewrite-client-elm-json.js +49 -0
- package/generator/src/route-codegen-helpers.js +62 -1
- package/generator/static-code/dev-style.css +22 -0
- package/generator/static-code/elm-pages.js +43 -39
- package/generator/static-code/hmr.js +98 -88
- package/generator/template/app/Api.elm +25 -0
- package/generator/template/app/ErrorPage.elm +38 -0
- package/generator/template/app/Route/Index.elm +87 -0
- package/generator/template/{src → app}/Shared.elm +34 -13
- package/generator/template/app/Site.elm +19 -0
- package/generator/template/{src → app}/View.elm +0 -0
- package/generator/template/elm-pages.config.mjs +5 -0
- package/generator/template/elm.json +1 -0
- package/generator/template/{public/index.js → index.ts} +7 -3
- package/generator/template/package.json +4 -4
- package/generator/template/public/favicon.ico +0 -0
- package/generator/template/public/images/icon-png.png +0 -0
- package/generator/template/src/.gitkeep +0 -0
- package/generator/template/style.css +4 -0
- package/package.json +30 -23
- package/src/ApiRoute.elm +176 -43
- package/src/BuildError.elm +10 -1
- package/src/CookieParser.elm +84 -0
- package/src/DataSource/Env.elm +38 -0
- package/src/DataSource/File.elm +27 -16
- package/src/DataSource/Glob.elm +126 -80
- package/src/DataSource/Http.elm +283 -304
- package/src/DataSource/Internal/Glob.elm +5 -21
- package/src/DataSource/Internal/Request.elm +25 -0
- package/src/DataSource/Port.elm +17 -14
- package/src/DataSource.elm +55 -318
- package/src/Form/Field.elm +717 -0
- package/src/Form/FieldStatus.elm +36 -0
- package/src/Form/FieldView.elm +417 -0
- package/src/Form/FormData.elm +22 -0
- package/src/Form/Validation.elm +391 -0
- package/src/Form/Value.elm +118 -0
- package/src/Form.elm +1683 -0
- package/src/FormData.elm +58 -0
- package/src/FormDecoder.elm +102 -0
- package/src/Head/Seo.elm +12 -4
- package/src/Head.elm +12 -2
- package/src/HtmlPrinter.elm +1 -1
- package/src/Internal/ApiRoute.elm +17 -4
- package/src/Internal/Request.elm +7 -0
- package/src/PageServerResponse.elm +68 -0
- package/src/Pages/ContentCache.elm +1 -229
- package/src/Pages/Fetcher.elm +58 -0
- package/src/Pages/FormState.elm +256 -0
- package/src/Pages/Generate.elm +800 -0
- package/src/Pages/Internal/Form.elm +17 -0
- package/src/Pages/Internal/NotFoundReason.elm +3 -55
- package/src/Pages/Internal/Platform/Cli.elm +777 -579
- package/src/Pages/Internal/Platform/Effect.elm +5 -5
- package/src/Pages/Internal/Platform/StaticResponses.elm +178 -394
- package/src/Pages/Internal/Platform/ToJsPayload.elm +24 -23
- package/src/Pages/Internal/Platform.elm +1244 -504
- package/src/Pages/Internal/ResponseSketch.elm +19 -0
- package/src/Pages/Internal/RoutePattern.elm +596 -45
- package/src/Pages/Manifest.elm +26 -0
- package/src/Pages/Msg.elm +79 -0
- package/src/Pages/ProgramConfig.elm +67 -14
- package/src/Pages/SiteConfig.elm +3 -6
- package/src/Pages/StaticHttp/Request.elm +4 -2
- package/src/Pages/StaticHttpRequest.elm +50 -215
- package/src/Pages/Transition.elm +70 -0
- package/src/Path.elm +1 -0
- package/src/Pattern.elm +98 -0
- package/src/RenderRequest.elm +2 -2
- package/src/RequestsAndPending.elm +111 -9
- package/src/Server/Request.elm +1253 -0
- package/src/Server/Response.elm +292 -0
- package/src/Server/Session.elm +316 -0
- package/src/Server/SetCookie.elm +169 -0
- package/src/TerminalText.elm +1 -1
- package/src/Test/Html/Internal/ElmHtml/Markdown.elm +0 -1
- package/src/Test/Html/Internal/ElmHtml/ToString.elm +1 -1
- package/generator/src/Page.elm +0 -359
- package/generator/src/codegen-template-module.js +0 -183
- package/generator/src/elm-pages-js-minified.js +0 -1
- package/generator/template/src/Api.elm +0 -14
- package/generator/template/src/Page/Index.elm +0 -69
- package/generator/template/src/Site.elm +0 -41
- package/src/DataSource/ServerRequest.elm +0 -60
- package/src/Internal/OptimizedDecoder.elm +0 -18
- package/src/KeepOrDiscard.elm +0 -6
- package/src/OptimizedDecoder/Pipeline.elm +0 -335
- package/src/OptimizedDecoder.elm +0 -818
- package/src/Pages/Internal/ApplicationType.elm +0 -6
- package/src/Pages/Secrets.elm +0 -83
- package/src/Secrets.elm +0 -111
- package/src/SecretsDict.elm +0 -45
package/src/Pages/Secrets.elm
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
module Pages.Secrets exposing (Value, map, succeed, with)
|
|
2
|
-
|
|
3
|
-
{-| Secrets are a secure way to use environment variables in your DataSource.Http requests. The actual environment
|
|
4
|
-
variable value is used to perform DataSource.Http requests, while the masked value is the only thing that ends up in your
|
|
5
|
-
built site. Let's go through what happens in a concrete example:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## Example
|
|
9
|
-
|
|
10
|
-
Let's say you execute this from the shell:
|
|
11
|
-
|
|
12
|
-
```shell
|
|
13
|
-
GITHUB_TOKEN=abcd1234 API_KEY=xyz789 elm-pages build
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
And your DataSource.Http request in your Elm code looks like this:
|
|
17
|
-
|
|
18
|
-
import Pages.Secrets as Secrets
|
|
19
|
-
import DataSource.Http
|
|
20
|
-
|
|
21
|
-
DataSource.Http.request
|
|
22
|
-
(Secrets.succeed
|
|
23
|
-
(\apiKey githubToken ->
|
|
24
|
-
{ url = "https://api.github.com/repos/dillonkearns/elm-pages?apiKey=" ++ apiKey
|
|
25
|
-
, method = "GET"
|
|
26
|
-
, headers = [ ( "Authorization", "Bearer " ++ githubToken ) ]
|
|
27
|
-
, body = DataSource.Http.emptyBody
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
|> Secrets.with "API_KEY"
|
|
31
|
-
|> Secrets.with "BEARER"
|
|
32
|
-
)
|
|
33
|
-
(Decode.succeed ())
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
The following masked values are what will be visible in your production bundle if you inspect the code or the Network tab:
|
|
37
|
-
|
|
38
|
-
[GET]https://api.github.com/repos/dillonkearns/elm-pages?apiKey=<API_KEY>Authorization : Bearer <BEARER>
|
|
39
|
-
|
|
40
|
-
So the actual Secrets only exist for the duration of the build in order to perform the DataSource.Http requests, but they
|
|
41
|
-
are replaced with `<SECRET_NAME>` once that step is done and your assets are bundled.
|
|
42
|
-
|
|
43
|
-
@docs Value, map, succeed, with
|
|
44
|
-
|
|
45
|
-
-}
|
|
46
|
-
|
|
47
|
-
import Secrets
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{-| Represents a Secure value from your environment variables. `Pages.Secrets.Value`s are much like `Json.Decode.Value`s
|
|
51
|
-
in that you can take raw values, map them, and combine them with other values into any data structure.
|
|
52
|
-
-}
|
|
53
|
-
type alias Value value =
|
|
54
|
-
Secrets.Value value
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{-| Hardcode a secret value. Or, this can be used to start a pipeline-style value with several different secrets (see
|
|
58
|
-
the example at the top of this page).
|
|
59
|
-
|
|
60
|
-
Warning: a hardcoded value is not protected by masking! Make sure to to use `Secrets.with` to fetch sentitive values from environment variables.
|
|
61
|
-
|
|
62
|
-
import Pages.Secrets as Secrets
|
|
63
|
-
|
|
64
|
-
Secrets.succeed "hardcoded-secret"
|
|
65
|
-
|
|
66
|
-
-}
|
|
67
|
-
succeed : value -> Value value
|
|
68
|
-
succeed =
|
|
69
|
-
Secrets.succeed
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{-| Map a Secret's raw value into an arbitrary type or value.
|
|
73
|
-
-}
|
|
74
|
-
map : (valueA -> valueB) -> Value valueA -> Value valueB
|
|
75
|
-
map =
|
|
76
|
-
Secrets.map
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{-| Allows you to chain together multiple secrets. See the top of this page for a full example.
|
|
80
|
-
-}
|
|
81
|
-
with : String -> Value (String -> value) -> Value value
|
|
82
|
-
with =
|
|
83
|
-
Secrets.with
|
package/src/Secrets.elm
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
module Secrets exposing
|
|
2
|
-
( Value
|
|
3
|
-
, lookup
|
|
4
|
-
, map
|
|
5
|
-
, maskedLookup
|
|
6
|
-
, succeed
|
|
7
|
-
, with
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
import BuildError exposing (BuildError)
|
|
11
|
-
import Fuzzy
|
|
12
|
-
import SecretsDict exposing (SecretsDict)
|
|
13
|
-
import TerminalText as Terminal
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type Value value
|
|
17
|
-
= Value (SecretsDict -> Result (List BuildError) value)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
lookup : SecretsDict -> Value a -> Result (List BuildError) a
|
|
21
|
-
lookup secrets (Value lookupSecrets) =
|
|
22
|
-
lookupSecrets secrets
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
maskedLookup : Value value -> value
|
|
26
|
-
maskedLookup (Value lookupSecrets) =
|
|
27
|
-
case lookupSecrets SecretsDict.masked of
|
|
28
|
-
Ok value ->
|
|
29
|
-
value
|
|
30
|
-
|
|
31
|
-
Err _ ->
|
|
32
|
-
-- crash
|
|
33
|
-
maskedLookup (Value lookupSecrets)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
succeed : value -> Value value
|
|
37
|
-
succeed value =
|
|
38
|
-
Value (\_ -> Ok value)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
buildError : String -> SecretsDict -> BuildError
|
|
42
|
-
buildError secretName secretsDict =
|
|
43
|
-
let
|
|
44
|
-
availableEnvironmentVariables : List String
|
|
45
|
-
availableEnvironmentVariables =
|
|
46
|
-
SecretsDict.available secretsDict
|
|
47
|
-
in
|
|
48
|
-
{ title = "Missing Secret"
|
|
49
|
-
, message =
|
|
50
|
-
[ Terminal.text "I expected to find this Secret in your environment variables but didn't find a match:\n\nSecrets.get \""
|
|
51
|
-
, Terminal.text secretName
|
|
52
|
-
, Terminal.text "\"\n "
|
|
53
|
-
, Terminal.red <| underlineText (secretName |> String.length)
|
|
54
|
-
, Terminal.text "\n\nSo maybe "
|
|
55
|
-
, Terminal.yellow <| secretName
|
|
56
|
-
, Terminal.text " should be "
|
|
57
|
-
, Terminal.green <| (sortMatches secretName availableEnvironmentVariables |> List.head |> Maybe.withDefault "")
|
|
58
|
-
]
|
|
59
|
-
, path = "" -- TODO wire in path here?
|
|
60
|
-
, fatal = True
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
underlineText : Int -> String
|
|
65
|
-
underlineText length =
|
|
66
|
-
String.repeat length "^"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
sortMatches : String -> List String -> List String
|
|
70
|
-
sortMatches missingSecret availableSecrets =
|
|
71
|
-
let
|
|
72
|
-
simpleMatch : List Fuzzy.Config -> List String -> String -> String -> Int
|
|
73
|
-
simpleMatch config separators needle hay =
|
|
74
|
-
Fuzzy.match config separators needle hay |> .score
|
|
75
|
-
in
|
|
76
|
-
List.sortBy (simpleMatch [] [] missingSecret) availableSecrets
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
map : (valueA -> valueB) -> Value valueA -> Value valueB
|
|
80
|
-
map mapFunction (Value lookupSecrets) =
|
|
81
|
-
Value
|
|
82
|
-
(\secrets ->
|
|
83
|
-
lookupSecrets secrets
|
|
84
|
-
|> Result.map mapFunction
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
with : String -> Value (String -> value) -> Value value
|
|
89
|
-
with newSecret (Value lookupSecrets) =
|
|
90
|
-
Value <|
|
|
91
|
-
\secrets ->
|
|
92
|
-
case lookupSecrets secrets of
|
|
93
|
-
Ok value ->
|
|
94
|
-
case SecretsDict.get newSecret secrets of
|
|
95
|
-
Just newValue ->
|
|
96
|
-
value newValue |> Ok
|
|
97
|
-
|
|
98
|
-
Nothing ->
|
|
99
|
-
Err [ buildError newSecret secrets ]
|
|
100
|
-
|
|
101
|
-
Err error ->
|
|
102
|
-
case SecretsDict.get newSecret secrets of
|
|
103
|
-
Just _ ->
|
|
104
|
-
Err error
|
|
105
|
-
|
|
106
|
-
Nothing ->
|
|
107
|
-
-- TODO add more errors
|
|
108
|
-
Err
|
|
109
|
-
(buildError newSecret secrets
|
|
110
|
-
:: error
|
|
111
|
-
)
|
package/src/SecretsDict.elm
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
module SecretsDict exposing (SecretsDict, available, decoder, get, masked, unmasked)
|
|
2
|
-
|
|
3
|
-
import Dict exposing (Dict)
|
|
4
|
-
import Json.Decode as Decode exposing (Decoder)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
available : SecretsDict -> List String
|
|
8
|
-
available secretsDict =
|
|
9
|
-
case secretsDict of
|
|
10
|
-
Masked ->
|
|
11
|
-
[]
|
|
12
|
-
|
|
13
|
-
Unmasked dict ->
|
|
14
|
-
Dict.keys dict
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
decoder : Decoder SecretsDict
|
|
18
|
-
decoder =
|
|
19
|
-
Decode.dict Decode.string
|
|
20
|
-
|> Decode.map Unmasked
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
unmasked : Dict String String -> SecretsDict
|
|
24
|
-
unmasked dict =
|
|
25
|
-
Unmasked dict
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
masked : SecretsDict
|
|
29
|
-
masked =
|
|
30
|
-
Masked
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
get : String -> SecretsDict -> Maybe String
|
|
34
|
-
get secretName secretsDict =
|
|
35
|
-
case secretsDict of
|
|
36
|
-
Masked ->
|
|
37
|
-
Just <| "<" ++ secretName ++ ">"
|
|
38
|
-
|
|
39
|
-
Unmasked dict ->
|
|
40
|
-
dict |> Dict.get secretName
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
type SecretsDict
|
|
44
|
-
= Masked
|
|
45
|
-
| Unmasked (Dict String String)
|