Rename module.

This commit is contained in:
Dillon Kearns 2019-11-11 17:48:08 -08:00
parent 7b78c2340a
commit 56933942c8
6 changed files with 38 additions and 38 deletions

View File

@ -31,7 +31,7 @@ import Pages.ImagePath as ImagePath
import Pages.Manifest as Manifest
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticHttpRequest as StaticHttpRequest
import Secrets2
import Secrets
import SecretsDict exposing (SecretsDict)
import Set exposing (Set)
import StaticHttp exposing (RequestDetails)
@ -539,11 +539,11 @@ performStaticHttpRequests allRawResponses secrets staticRequests =
-- |> Set.toList
|> List.map
(\urlBuilder ->
Secrets2.lookup secrets urlBuilder
Secrets.lookup secrets urlBuilder
|> Result.mapError MissingSecrets
|> Result.map
(\unmasked ->
{ unmasked = unmasked, masked = Secrets2.maskedLookup urlBuilder }
{ unmasked = unmasked, masked = Secrets.maskedLookup urlBuilder }
)
)
|> combineMultipleErrors
@ -631,7 +631,7 @@ staticResponsesUpdate newEntry model =
StaticHttpRequest.resolveUrls request
(updatedAllResponses |> dictCompact)
|> Tuple.second
|> List.map Secrets2.maskedLookup
|> List.map Secrets.maskedLookup
|> List.map hashUrl
includesUrl =
@ -698,7 +698,7 @@ sendStaticResponsesIfDone secrets allRawResponses errors staticResponses manifes
fetchedAllKnownUrls =
(knownUrlsToFetch
|> List.map Secrets2.maskedLookup
|> List.map Secrets.maskedLookup
|> List.map hashUrl
|> Set.fromList
|> Set.size

View File

@ -2,12 +2,12 @@ module Pages.StaticHttpRequest exposing (Error(..), Request(..), errorToString,
import BuildError exposing (BuildError)
import Dict exposing (Dict)
import Secrets2
import Secrets
import TerminalText as Terminal
type Request value
= Request ( List (Secrets2.Value { url : String, method : String, headers : List ( String, String ) }), Dict String String -> Result Error ( Dict String String, Request value ) )
= Request ( List (Secrets.Value { url : String, method : String, headers : List ( String, String ) }), Dict String String -> Result Error ( Dict String String, Request value ) )
| Done value
@ -45,7 +45,7 @@ type alias RequestDetails =
{ url : String, method : String, headers : List ( String, String ) }
urls : Request value -> List (Secrets2.Value RequestDetails)
urls : Request value -> List (Secrets.Value RequestDetails)
urls request =
case request of
Request ( urlList, lookupFn ) ->
@ -100,7 +100,7 @@ resolve request rawResponses =
Ok value
resolveUrls : Request value -> Dict String String -> ( Bool, List (Secrets2.Value RequestDetails) )
resolveUrls : Request value -> Dict String String -> ( Bool, List (Secrets.Value RequestDetails) )
resolveUrls request rawResponses =
case request of
Request ( urlList, lookupFn ) ->

View File

@ -1,4 +1,4 @@
module Secrets2 exposing (Value, lookup, map, maskedLookup, succeed, with)
module Secrets exposing (Value, lookup, map, maskedLookup, succeed, with)
import BuildError exposing (BuildError)
import Fuzzy

View File

@ -25,7 +25,7 @@ import Dict.Extra
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Exploration
import Pages.StaticHttpRequest exposing (Request(..))
import Secrets2
import Secrets
{-| TODO
@ -172,7 +172,7 @@ lookup requestInfo rawResponses =
Ok ( rawResponses, value )
addUrls : List (Secrets2.Value { url : String, method : String, headers : List ( String, String ) }) -> Pages.StaticHttpRequest.Request value -> Pages.StaticHttpRequest.Request value
addUrls : List (Secrets.Value { url : String, method : String, headers : List ( String, String ) }) -> Pages.StaticHttpRequest.Request value -> Pages.StaticHttpRequest.Request value
addUrls urlsToAdd requestInfo =
case requestInfo of
Request ( initialUrls, function ) ->
@ -186,7 +186,7 @@ addUrls urlsToAdd requestInfo =
-- Request ( urlsToAdd, \_ -> value |> Done |> Ok )
lookupUrls : Pages.StaticHttpRequest.Request value -> List (Secrets2.Value RequestDetails)
lookupUrls : Pages.StaticHttpRequest.Request value -> List (Secrets.Value RequestDetails)
lookupUrls requestInfo =
case requestInfo of
Request ( urls, lookupFn ) ->
@ -231,13 +231,13 @@ succeed value =
{-| TODO
-}
getWithSecrets :
Secrets2.Value String
Secrets.Value String
-> Decoder a
-> Request a
getWithSecrets url decoder =
jsonRequestWithSecrets
(url
|> Secrets2.map
|> Secrets.map
(\okUrl -> { url = okUrl, method = "GET", headers = [] })
)
decoder
@ -275,7 +275,7 @@ requestToString requestDetails =
jsonRequest : { url : String, method : String, headers : List ( String, String ) } -> Decoder a -> Request a
jsonRequest url decoder =
Request
( [ Secrets2.succeed url ]
( [ Secrets.succeed url ]
, \rawResponseDict ->
rawResponseDict
|> Dict.get (url |> hashRequest)
@ -324,7 +324,7 @@ reducedPost url decoder =
-}
reducedJsonRequest : RequestDetails -> Json.Decode.Exploration.Decoder a -> Request a
reducedJsonRequest requestInfo decoder =
request (Secrets2.succeed requestInfo) decoder
request (Secrets.succeed requestInfo) decoder
type Expect a
@ -338,7 +338,7 @@ type Expect a
{-| TODO
-}
request :
Secrets2.Value RequestDetails
Secrets.Value RequestDetails
-> Json.Decode.Exploration.Decoder a
-> Request a
request urlWithSecrets decoder =
@ -346,7 +346,7 @@ request urlWithSecrets decoder =
( [ urlWithSecrets ]
, \rawResponseDict ->
rawResponseDict
|> Dict.get (Secrets2.maskedLookup urlWithSecrets |> hashRequest)
|> Dict.get (Secrets.maskedLookup urlWithSecrets |> hashRequest)
|> (\maybeResponse ->
case maybeResponse of
Just rawResponse ->
@ -357,7 +357,7 @@ request urlWithSecrets decoder =
)
Nothing ->
Secrets2.maskedLookup urlWithSecrets
Secrets.maskedLookup urlWithSecrets
|> requestToString
|> Pages.StaticHttpRequest.MissingHttpResponse
|> Err
@ -393,7 +393,7 @@ request urlWithSecrets decoder =
(\finalRequest ->
( strippedResponses
|> Dict.insert
(Secrets2.maskedLookup urlWithSecrets |> hashRequest)
(Secrets.maskedLookup urlWithSecrets |> hashRequest)
reduced
, finalRequest
)
@ -405,7 +405,7 @@ request urlWithSecrets decoder =
{-| TODO
-}
jsonRequestWithSecrets :
Secrets2.Value RequestDetails
Secrets.Value RequestDetails
-> Decoder a
-> Request a
jsonRequestWithSecrets urlWithSecrets decoder =
@ -413,7 +413,7 @@ jsonRequestWithSecrets urlWithSecrets decoder =
( [ urlWithSecrets ]
, \rawResponseDict ->
rawResponseDict
|> Dict.get (Secrets2.maskedLookup urlWithSecrets |> hashRequest)
|> Dict.get (Secrets.maskedLookup urlWithSecrets |> hashRequest)
|> (\maybeResponse ->
case maybeResponse of
Just rawResponse ->
@ -422,7 +422,7 @@ jsonRequestWithSecrets urlWithSecrets decoder =
Nothing ->
-- Err <| "Couldn't find response for url `" ++ Pages.Internal.Secrets.useFakeSecrets urlWithSecrets ++ "`"
Secrets2.maskedLookup urlWithSecrets
Secrets.maskedLookup urlWithSecrets
|> requestToString
|> Pages.StaticHttpRequest.MissingHttpResponse
|> Err

View File

@ -14,7 +14,7 @@ import Pages.Manifest as Manifest
import Pages.PagePath as PagePath
import ProgramTest exposing (ProgramTest)
import Regex
import Secrets2
import Secrets
import SimulatedEffect.Cmd
import SimulatedEffect.Http as Http
import SimulatedEffect.Ports
@ -366,21 +366,21 @@ The user should get this message from the CLI."""
start
[ ( [ "elm-pages" ]
, StaticHttp.getWithSecrets
(Secrets2.succeed
(Secrets.succeed
(\apiKey ->
"https://api.github.com/repos/dillonkearns/elm-pages?apiKey=" ++ apiKey
)
|> Secrets2.with "API_KEY"
|> Secrets.with "API_KEY"
)
Decode.string
|> StaticHttp.andThen
(\url ->
StaticHttp.getWithSecrets
(Secrets2.succeed
(Secrets.succeed
(\missingSecret ->
url ++ "?apiKey=" ++ missingSecret
)
|> Secrets2.with "MISSING"
|> Secrets.with "MISSING"
)
(Decode.succeed ())
)
@ -437,15 +437,15 @@ So maybe MISSING should be API_KEY"""
start
[ ( []
, StaticHttp.request
(Secrets2.succeed
(Secrets.succeed
(\apiKey bearer ->
{ url = "https://api.github.com/repos/dillonkearns/elm-pages?apiKey=" ++ apiKey
, method = "GET"
, headers = [ ( "Authorization", "Bearer " ++ bearer ) ]
}
)
|> Secrets2.with "API_KEY"
|> Secrets2.with "BEARER"
|> Secrets.with "API_KEY"
|> Secrets.with "BEARER"
)
(Reduce.succeed ())
)

View File

@ -4,7 +4,7 @@ import Dict exposing (Dict)
import Expect
import Json.Decode as Decode
import Pages.StaticHttpRequest as StaticHttpRequest
import Secrets2
import Secrets
import StaticHttp
import Test exposing (Test, describe, only, test)
@ -27,7 +27,7 @@ all =
, ( "[GET]NEXT", "null" )
]
)
|> Tuple.mapSecond (List.map Secrets2.maskedLookup)
|> Tuple.mapSecond (List.map Secrets.maskedLookup)
|> Expect.equal ( True, [ get "first", get "NEXT" ] )
)
, test "andThen staring with done" <|
@ -43,7 +43,7 @@ all =
[ ( "[GET]NEXT", "null" )
]
)
|> Tuple.mapSecond (List.map Secrets2.maskedLookup)
|> Tuple.mapSecond (List.map Secrets.maskedLookup)
|> Expect.equal ( True, [ get "NEXT" ] )
)
, test "map" <|
@ -62,7 +62,7 @@ all =
, ( "[GET]NEXT", "null" )
]
)
|> Tuple.mapSecond (List.map Secrets2.maskedLookup)
|> Tuple.mapSecond (List.map Secrets.maskedLookup)
|> Expect.equal ( True, [ get "first", get "NEXT" ] )
)
, test "andThen chain with 1 response available and 1 pending" <|
@ -78,7 +78,7 @@ all =
[ ( "[GET]first", "null" )
]
)
|> Tuple.mapSecond (List.map Secrets2.maskedLookup)
|> Tuple.mapSecond (List.map Secrets.maskedLookup)
|> Expect.equal ( False, [ get "first", get "NEXT" ] )
)
, test "andThen chain with 1 response available and 2 pending" <|
@ -96,7 +96,7 @@ all =
|> (\request ->
StaticHttpRequest.resolveUrls request
(Dict.fromList [ ( "[GET]first", "1" ) ])
|> Tuple.mapSecond (List.map Secrets2.maskedLookup)
|> Tuple.mapSecond (List.map Secrets.maskedLookup)
|> Expect.equal ( False, [ get "first", get "NEXT" ] )
)
]