{-# OPTIONS_GHC -Wno-unused-imports #-}

module WebDriverPreCore.BiDi.Network
  ( -- * NetworkCommand
    AddDataCollector (..),
    AddIntercept (..),
    InterceptPhase (..),
    UrlPattern (..),
    UrlPatternPattern (..),
    UrlPatternString (..),
    ContinueRequest (..),
    BytesValue (..),
    Cookie (..),
    SameSite (..),
    Header (..),
    CookieHeader (..),
    SetCookieHeader (..),
    ContinueResponse (..),
    ContinueWithAuth (..),
    Intercept (..),
    AuthCredentials (..),
    AuthAction (..),
    DisownData (..),
    FailRequest (..),
    GetData (..),
    ProvideResponse (..),
    RemoveDataCollector (..),
    RemoveIntercept (..),
    SetCacheBehavior (..),
    CacheBehavior (..),
    SetExtraHeaders (..),

    -- * Additional Network Types
    DataType (..),
    CollectorType (..),
    Collector (..),
    Request (..),

    -- * NetworkResult
    AddDataCollectorResult (..),
    AddInterceptResult (..),
    GetDataResult (..),

    -- * NetworkEvent
    NetworkEvent (..),
    AuthRequired (..),
    RequestData (..),
    ResponseData (..),
    ResponseContent (..),
    AuthChallenge (..),
    BeforeRequestSent (..),
    Initiator (..),
    InitiatorType (..),
    FetchError (..),
    ResponseCompleted (..),
    ResponseStarted (..),
    HTTPMethod (..),
    FetchTimingInfo (..),
  )
where

-- This module provides functionality related to BiDi (Bidirectional) network operations
-- for WebDriverPreCore. It is currently a placeholder for future implementation.

-- Data structures for network protocol

import Data.Aeson (FromArgs, FromJSON (..), ToJSON (..), Value (..), object, withObject, withText, (.:), (.=), Options (..), defaultOptions, genericParseJSON, (.:?))
import Data.Aeson.KeyMap qualified as KeyMap
import Data.Aeson.Types (Parser, parse)
import Data.Function ((&))
import Data.Functor ((<&>))
import Data.Text (Text, toLower)
import GHC.Generics (Generic (to))
import WebDriverPreCore.BiDi.BrowsingContext (Navigation)
import WebDriverPreCore.BiDi.CoreTypes (BrowsingContext, JSUInt, StringValue (..), SubscriptionType (..), UserContext, KnownSubscriptionType (..), URL)
import WebDriverPreCore.BiDi.Script (StackTrace)
import AesonUtils (addProps, enumCamelCase, fromJSONCamelCase, objectOrThrow, parseJSONOmitNothing, toJSONOmitNothing)

-- ######### REMOTE #########

data AddDataCollector = MkAddDataCollector
  { AddDataCollector -> [DataType]
dataTypes :: [DataType],
    AddDataCollector -> JSUInt
maxEncodedDataSize :: JSUInt,
    AddDataCollector -> Maybe CollectorType
collectorType :: Maybe CollectorType,
    AddDataCollector -> Maybe [BrowsingContext]
contexts :: Maybe [BrowsingContext],
    AddDataCollector -> Maybe [UserContext]
userContexts :: Maybe [UserContext]
  }
  deriving (Int -> AddDataCollector -> ShowS
[AddDataCollector] -> ShowS
AddDataCollector -> String
(Int -> AddDataCollector -> ShowS)
-> (AddDataCollector -> String)
-> ([AddDataCollector] -> ShowS)
-> Show AddDataCollector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddDataCollector -> ShowS
showsPrec :: Int -> AddDataCollector -> ShowS
$cshow :: AddDataCollector -> String
show :: AddDataCollector -> String
$cshowList :: [AddDataCollector] -> ShowS
showList :: [AddDataCollector] -> ShowS
Show, AddDataCollector -> AddDataCollector -> Bool
(AddDataCollector -> AddDataCollector -> Bool)
-> (AddDataCollector -> AddDataCollector -> Bool)
-> Eq AddDataCollector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddDataCollector -> AddDataCollector -> Bool
== :: AddDataCollector -> AddDataCollector -> Bool
$c/= :: AddDataCollector -> AddDataCollector -> Bool
/= :: AddDataCollector -> AddDataCollector -> Bool
Eq, (forall x. AddDataCollector -> Rep AddDataCollector x)
-> (forall x. Rep AddDataCollector x -> AddDataCollector)
-> Generic AddDataCollector
forall x. Rep AddDataCollector x -> AddDataCollector
forall x. AddDataCollector -> Rep AddDataCollector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddDataCollector -> Rep AddDataCollector x
from :: forall x. AddDataCollector -> Rep AddDataCollector x
$cto :: forall x. Rep AddDataCollector x -> AddDataCollector
to :: forall x. Rep AddDataCollector x -> AddDataCollector
Generic)

instance ToJSON AddDataCollector where
  toJSON :: AddDataCollector -> Value
  toJSON :: AddDataCollector -> Value
toJSON = AddDataCollector -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing


data DataType = Request | Response
  deriving (Int -> DataType -> ShowS
[DataType] -> ShowS
DataType -> String
(Int -> DataType -> ShowS)
-> (DataType -> String) -> ([DataType] -> ShowS) -> Show DataType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DataType -> ShowS
showsPrec :: Int -> DataType -> ShowS
$cshow :: DataType -> String
show :: DataType -> String
$cshowList :: [DataType] -> ShowS
showList :: [DataType] -> ShowS
Show, DataType -> DataType -> Bool
(DataType -> DataType -> Bool)
-> (DataType -> DataType -> Bool) -> Eq DataType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataType -> DataType -> Bool
== :: DataType -> DataType -> Bool
$c/= :: DataType -> DataType -> Bool
/= :: DataType -> DataType -> Bool
Eq, (forall x. DataType -> Rep DataType x)
-> (forall x. Rep DataType x -> DataType) -> Generic DataType
forall x. Rep DataType x -> DataType
forall x. DataType -> Rep DataType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataType -> Rep DataType x
from :: forall x. DataType -> Rep DataType x
$cto :: forall x. Rep DataType x -> DataType
to :: forall x. Rep DataType x -> DataType
Generic)

instance ToJSON DataType where
  toJSON :: DataType -> Value
  toJSON :: DataType -> Value
toJSON =  DataType -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

instance FromJSON DataType where
  parseJSON :: Value -> Parser DataType
  parseJSON :: Value -> Parser DataType
parseJSON = Value -> Parser DataType
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
fromJSONCamelCase

newtype CollectorType = MkCollectorType {CollectorType -> Text
collectorType :: Text}
  deriving (Int -> CollectorType -> ShowS
[CollectorType] -> ShowS
CollectorType -> String
(Int -> CollectorType -> ShowS)
-> (CollectorType -> String)
-> ([CollectorType] -> ShowS)
-> Show CollectorType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CollectorType -> ShowS
showsPrec :: Int -> CollectorType -> ShowS
$cshow :: CollectorType -> String
show :: CollectorType -> String
$cshowList :: [CollectorType] -> ShowS
showList :: [CollectorType] -> ShowS
Show, CollectorType -> CollectorType -> Bool
(CollectorType -> CollectorType -> Bool)
-> (CollectorType -> CollectorType -> Bool) -> Eq CollectorType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CollectorType -> CollectorType -> Bool
== :: CollectorType -> CollectorType -> Bool
$c/= :: CollectorType -> CollectorType -> Bool
/= :: CollectorType -> CollectorType -> Bool
Eq, (forall x. CollectorType -> Rep CollectorType x)
-> (forall x. Rep CollectorType x -> CollectorType)
-> Generic CollectorType
forall x. Rep CollectorType x -> CollectorType
forall x. CollectorType -> Rep CollectorType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CollectorType -> Rep CollectorType x
from :: forall x. CollectorType -> Rep CollectorType x
$cto :: forall x. Rep CollectorType x -> CollectorType
to :: forall x. Rep CollectorType x -> CollectorType
Generic)
  deriving newtype (Maybe CollectorType
Value -> Parser [CollectorType]
Value -> Parser CollectorType
(Value -> Parser CollectorType)
-> (Value -> Parser [CollectorType])
-> Maybe CollectorType
-> FromJSON CollectorType
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser CollectorType
parseJSON :: Value -> Parser CollectorType
$cparseJSONList :: Value -> Parser [CollectorType]
parseJSONList :: Value -> Parser [CollectorType]
$comittedField :: Maybe CollectorType
omittedField :: Maybe CollectorType
FromJSON, [CollectorType] -> Value
[CollectorType] -> Encoding
CollectorType -> Bool
CollectorType -> Value
CollectorType -> Encoding
(CollectorType -> Value)
-> (CollectorType -> Encoding)
-> ([CollectorType] -> Value)
-> ([CollectorType] -> Encoding)
-> (CollectorType -> Bool)
-> ToJSON CollectorType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: CollectorType -> Value
toJSON :: CollectorType -> Value
$ctoEncoding :: CollectorType -> Encoding
toEncoding :: CollectorType -> Encoding
$ctoJSONList :: [CollectorType] -> Value
toJSONList :: [CollectorType] -> Value
$ctoEncodingList :: [CollectorType] -> Encoding
toEncodingList :: [CollectorType] -> Encoding
$comitField :: CollectorType -> Bool
omitField :: CollectorType -> Bool
ToJSON)

data DisownData = MkDisownData
  { DisownData -> DataType
dataType :: DataType,
    DisownData -> Collector
collector :: Collector,
    DisownData -> Request
request :: Request
  }
  deriving (Int -> DisownData -> ShowS
[DisownData] -> ShowS
DisownData -> String
(Int -> DisownData -> ShowS)
-> (DisownData -> String)
-> ([DisownData] -> ShowS)
-> Show DisownData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DisownData -> ShowS
showsPrec :: Int -> DisownData -> ShowS
$cshow :: DisownData -> String
show :: DisownData -> String
$cshowList :: [DisownData] -> ShowS
showList :: [DisownData] -> ShowS
Show, DisownData -> DisownData -> Bool
(DisownData -> DisownData -> Bool)
-> (DisownData -> DisownData -> Bool) -> Eq DisownData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DisownData -> DisownData -> Bool
== :: DisownData -> DisownData -> Bool
$c/= :: DisownData -> DisownData -> Bool
/= :: DisownData -> DisownData -> Bool
Eq, (forall x. DisownData -> Rep DisownData x)
-> (forall x. Rep DisownData x -> DisownData) -> Generic DisownData
forall x. Rep DisownData x -> DisownData
forall x. DisownData -> Rep DisownData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DisownData -> Rep DisownData x
from :: forall x. DisownData -> Rep DisownData x
$cto :: forall x. Rep DisownData x -> DisownData
to :: forall x. Rep DisownData x -> DisownData
Generic)

instance ToJSON DisownData

newtype Collector = MkCollector {Collector -> Text
collector :: Text}
  deriving (Int -> Collector -> ShowS
[Collector] -> ShowS
Collector -> String
(Int -> Collector -> ShowS)
-> (Collector -> String)
-> ([Collector] -> ShowS)
-> Show Collector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Collector -> ShowS
showsPrec :: Int -> Collector -> ShowS
$cshow :: Collector -> String
show :: Collector -> String
$cshowList :: [Collector] -> ShowS
showList :: [Collector] -> ShowS
Show, Collector -> Collector -> Bool
(Collector -> Collector -> Bool)
-> (Collector -> Collector -> Bool) -> Eq Collector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Collector -> Collector -> Bool
== :: Collector -> Collector -> Bool
$c/= :: Collector -> Collector -> Bool
/= :: Collector -> Collector -> Bool
Eq, (forall x. Collector -> Rep Collector x)
-> (forall x. Rep Collector x -> Collector) -> Generic Collector
forall x. Rep Collector x -> Collector
forall x. Collector -> Rep Collector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Collector -> Rep Collector x
from :: forall x. Collector -> Rep Collector x
$cto :: forall x. Rep Collector x -> Collector
to :: forall x. Rep Collector x -> Collector
Generic)
  deriving newtype (Maybe Collector
Value -> Parser [Collector]
Value -> Parser Collector
(Value -> Parser Collector)
-> (Value -> Parser [Collector])
-> Maybe Collector
-> FromJSON Collector
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Collector
parseJSON :: Value -> Parser Collector
$cparseJSONList :: Value -> Parser [Collector]
parseJSONList :: Value -> Parser [Collector]
$comittedField :: Maybe Collector
omittedField :: Maybe Collector
FromJSON, [Collector] -> Value
[Collector] -> Encoding
Collector -> Bool
Collector -> Value
Collector -> Encoding
(Collector -> Value)
-> (Collector -> Encoding)
-> ([Collector] -> Value)
-> ([Collector] -> Encoding)
-> (Collector -> Bool)
-> ToJSON Collector
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: Collector -> Value
toJSON :: Collector -> Value
$ctoEncoding :: Collector -> Encoding
toEncoding :: Collector -> Encoding
$ctoJSONList :: [Collector] -> Value
toJSONList :: [Collector] -> Value
$ctoEncodingList :: [Collector] -> Encoding
toEncodingList :: [Collector] -> Encoding
$comitField :: Collector -> Bool
omitField :: Collector -> Bool
ToJSON)

newtype Request = MkRequest {Request -> Text
request :: Text}
  deriving (Int -> Request -> ShowS
[Request] -> ShowS
Request -> String
(Int -> Request -> ShowS)
-> (Request -> String) -> ([Request] -> ShowS) -> Show Request
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Request -> ShowS
showsPrec :: Int -> Request -> ShowS
$cshow :: Request -> String
show :: Request -> String
$cshowList :: [Request] -> ShowS
showList :: [Request] -> ShowS
Show, Request -> Request -> Bool
(Request -> Request -> Bool)
-> (Request -> Request -> Bool) -> Eq Request
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Request -> Request -> Bool
== :: Request -> Request -> Bool
$c/= :: Request -> Request -> Bool
/= :: Request -> Request -> Bool
Eq, (forall x. Request -> Rep Request x)
-> (forall x. Rep Request x -> Request) -> Generic Request
forall x. Rep Request x -> Request
forall x. Request -> Rep Request x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Request -> Rep Request x
from :: forall x. Request -> Rep Request x
$cto :: forall x. Rep Request x -> Request
to :: forall x. Rep Request x -> Request
Generic)
  deriving newtype (Maybe Request
Value -> Parser [Request]
Value -> Parser Request
(Value -> Parser Request)
-> (Value -> Parser [Request]) -> Maybe Request -> FromJSON Request
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Request
parseJSON :: Value -> Parser Request
$cparseJSONList :: Value -> Parser [Request]
parseJSONList :: Value -> Parser [Request]
$comittedField :: Maybe Request
omittedField :: Maybe Request
FromJSON,[Request] -> Value
[Request] -> Encoding
Request -> Bool
Request -> Value
Request -> Encoding
(Request -> Value)
-> (Request -> Encoding)
-> ([Request] -> Value)
-> ([Request] -> Encoding)
-> (Request -> Bool)
-> ToJSON Request
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: Request -> Value
toJSON :: Request -> Value
$ctoEncoding :: Request -> Encoding
toEncoding :: Request -> Encoding
$ctoJSONList :: [Request] -> Value
toJSONList :: [Request] -> Value
$ctoEncodingList :: [Request] -> Encoding
toEncodingList :: [Request] -> Encoding
$comitField :: Request -> Bool
omitField :: Request -> Bool
ToJSON)

data GetData = MkGetData
  { GetData -> DataType
dataType :: DataType,
    GetData -> Maybe Collector
collector :: Maybe Collector,
    GetData -> Maybe Bool
disown :: Maybe Bool,
    GetData -> Request
request :: Request
  }
  deriving (Int -> GetData -> ShowS
[GetData] -> ShowS
GetData -> String
(Int -> GetData -> ShowS)
-> (GetData -> String) -> ([GetData] -> ShowS) -> Show GetData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetData -> ShowS
showsPrec :: Int -> GetData -> ShowS
$cshow :: GetData -> String
show :: GetData -> String
$cshowList :: [GetData] -> ShowS
showList :: [GetData] -> ShowS
Show, GetData -> GetData -> Bool
(GetData -> GetData -> Bool)
-> (GetData -> GetData -> Bool) -> Eq GetData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetData -> GetData -> Bool
== :: GetData -> GetData -> Bool
$c/= :: GetData -> GetData -> Bool
/= :: GetData -> GetData -> Bool
Eq, (forall x. GetData -> Rep GetData x)
-> (forall x. Rep GetData x -> GetData) -> Generic GetData
forall x. Rep GetData x -> GetData
forall x. GetData -> Rep GetData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetData -> Rep GetData x
from :: forall x. GetData -> Rep GetData x
$cto :: forall x. Rep GetData x -> GetData
to :: forall x. Rep GetData x -> GetData
Generic)

instance ToJSON GetData

data RemoveDataCollector = MkRemoveDataCollector
  { RemoveDataCollector -> Collector
collector :: Collector
  }
  deriving (Int -> RemoveDataCollector -> ShowS
[RemoveDataCollector] -> ShowS
RemoveDataCollector -> String
(Int -> RemoveDataCollector -> ShowS)
-> (RemoveDataCollector -> String)
-> ([RemoveDataCollector] -> ShowS)
-> Show RemoveDataCollector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveDataCollector -> ShowS
showsPrec :: Int -> RemoveDataCollector -> ShowS
$cshow :: RemoveDataCollector -> String
show :: RemoveDataCollector -> String
$cshowList :: [RemoveDataCollector] -> ShowS
showList :: [RemoveDataCollector] -> ShowS
Show, RemoveDataCollector -> RemoveDataCollector -> Bool
(RemoveDataCollector -> RemoveDataCollector -> Bool)
-> (RemoveDataCollector -> RemoveDataCollector -> Bool)
-> Eq RemoveDataCollector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveDataCollector -> RemoveDataCollector -> Bool
== :: RemoveDataCollector -> RemoveDataCollector -> Bool
$c/= :: RemoveDataCollector -> RemoveDataCollector -> Bool
/= :: RemoveDataCollector -> RemoveDataCollector -> Bool
Eq, (forall x. RemoveDataCollector -> Rep RemoveDataCollector x)
-> (forall x. Rep RemoveDataCollector x -> RemoveDataCollector)
-> Generic RemoveDataCollector
forall x. Rep RemoveDataCollector x -> RemoveDataCollector
forall x. RemoveDataCollector -> Rep RemoveDataCollector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoveDataCollector -> Rep RemoveDataCollector x
from :: forall x. RemoveDataCollector -> Rep RemoveDataCollector x
$cto :: forall x. Rep RemoveDataCollector x -> RemoveDataCollector
to :: forall x. Rep RemoveDataCollector x -> RemoveDataCollector
Generic)

instance ToJSON RemoveDataCollector

-- | AddIntercept parameters
data AddIntercept = MkAddIntercept
  { AddIntercept -> [InterceptPhase]
phases :: [InterceptPhase],
    AddIntercept -> Maybe [BrowsingContext]
contexts :: Maybe [BrowsingContext],
    AddIntercept -> Maybe [UrlPattern]
urlPatterns :: Maybe [UrlPattern]
  }
  deriving (Int -> AddIntercept -> ShowS
[AddIntercept] -> ShowS
AddIntercept -> String
(Int -> AddIntercept -> ShowS)
-> (AddIntercept -> String)
-> ([AddIntercept] -> ShowS)
-> Show AddIntercept
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddIntercept -> ShowS
showsPrec :: Int -> AddIntercept -> ShowS
$cshow :: AddIntercept -> String
show :: AddIntercept -> String
$cshowList :: [AddIntercept] -> ShowS
showList :: [AddIntercept] -> ShowS
Show, AddIntercept -> AddIntercept -> Bool
(AddIntercept -> AddIntercept -> Bool)
-> (AddIntercept -> AddIntercept -> Bool) -> Eq AddIntercept
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddIntercept -> AddIntercept -> Bool
== :: AddIntercept -> AddIntercept -> Bool
$c/= :: AddIntercept -> AddIntercept -> Bool
/= :: AddIntercept -> AddIntercept -> Bool
Eq, (forall x. AddIntercept -> Rep AddIntercept x)
-> (forall x. Rep AddIntercept x -> AddIntercept)
-> Generic AddIntercept
forall x. Rep AddIntercept x -> AddIntercept
forall x. AddIntercept -> Rep AddIntercept x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddIntercept -> Rep AddIntercept x
from :: forall x. AddIntercept -> Rep AddIntercept x
$cto :: forall x. Rep AddIntercept x -> AddIntercept
to :: forall x. Rep AddIntercept x -> AddIntercept
Generic)

instance ToJSON AddIntercept where
  toJSON :: AddIntercept -> Value
  toJSON :: AddIntercept -> Value
toJSON = AddIntercept -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- | Intercept phases for network requests
data InterceptPhase
  = BeforeRequestSent
  | ResponseStarted
  | AuthRequired
  deriving (Int -> InterceptPhase -> ShowS
[InterceptPhase] -> ShowS
InterceptPhase -> String
(Int -> InterceptPhase -> ShowS)
-> (InterceptPhase -> String)
-> ([InterceptPhase] -> ShowS)
-> Show InterceptPhase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InterceptPhase -> ShowS
showsPrec :: Int -> InterceptPhase -> ShowS
$cshow :: InterceptPhase -> String
show :: InterceptPhase -> String
$cshowList :: [InterceptPhase] -> ShowS
showList :: [InterceptPhase] -> ShowS
Show, InterceptPhase -> InterceptPhase -> Bool
(InterceptPhase -> InterceptPhase -> Bool)
-> (InterceptPhase -> InterceptPhase -> Bool) -> Eq InterceptPhase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InterceptPhase -> InterceptPhase -> Bool
== :: InterceptPhase -> InterceptPhase -> Bool
$c/= :: InterceptPhase -> InterceptPhase -> Bool
/= :: InterceptPhase -> InterceptPhase -> Bool
Eq, (forall x. InterceptPhase -> Rep InterceptPhase x)
-> (forall x. Rep InterceptPhase x -> InterceptPhase)
-> Generic InterceptPhase
forall x. Rep InterceptPhase x -> InterceptPhase
forall x. InterceptPhase -> Rep InterceptPhase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InterceptPhase -> Rep InterceptPhase x
from :: forall x. InterceptPhase -> Rep InterceptPhase x
$cto :: forall x. Rep InterceptPhase x -> InterceptPhase
to :: forall x. Rep InterceptPhase x -> InterceptPhase
Generic)

instance FromJSON InterceptPhase

instance ToJSON InterceptPhase where
  toJSON :: InterceptPhase -> Value
toJSON = InterceptPhase -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
enumCamelCase

data UrlPattern
  = UrlPatternPattern UrlPatternPattern
  | UrlPatternString UrlPatternString
  deriving (Int -> UrlPattern -> ShowS
[UrlPattern] -> ShowS
UrlPattern -> String
(Int -> UrlPattern -> ShowS)
-> (UrlPattern -> String)
-> ([UrlPattern] -> ShowS)
-> Show UrlPattern
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UrlPattern -> ShowS
showsPrec :: Int -> UrlPattern -> ShowS
$cshow :: UrlPattern -> String
show :: UrlPattern -> String
$cshowList :: [UrlPattern] -> ShowS
showList :: [UrlPattern] -> ShowS
Show, UrlPattern -> UrlPattern -> Bool
(UrlPattern -> UrlPattern -> Bool)
-> (UrlPattern -> UrlPattern -> Bool) -> Eq UrlPattern
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UrlPattern -> UrlPattern -> Bool
== :: UrlPattern -> UrlPattern -> Bool
$c/= :: UrlPattern -> UrlPattern -> Bool
/= :: UrlPattern -> UrlPattern -> Bool
Eq, (forall x. UrlPattern -> Rep UrlPattern x)
-> (forall x. Rep UrlPattern x -> UrlPattern) -> Generic UrlPattern
forall x. Rep UrlPattern x -> UrlPattern
forall x. UrlPattern -> Rep UrlPattern x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UrlPattern -> Rep UrlPattern x
from :: forall x. UrlPattern -> Rep UrlPattern x
$cto :: forall x. Rep UrlPattern x -> UrlPattern
to :: forall x. Rep UrlPattern x -> UrlPattern
Generic)

instance ToJSON UrlPattern where
  toJSON :: UrlPattern -> Value
  toJSON :: UrlPattern -> Value
toJSON = \case
    UrlPatternPattern UrlPatternPattern
p -> UrlPatternPattern -> Value
forall a. ToJSON a => a -> Value
toJSON UrlPatternPattern
p
    UrlPatternString UrlPatternString
s -> UrlPatternString -> Value
forall a. ToJSON a => a -> Value
toJSON UrlPatternString
s

newtype UrlPatternString = MkUrlPatternString {UrlPatternString -> Text
patternString :: Text}
  deriving (Int -> UrlPatternString -> ShowS
[UrlPatternString] -> ShowS
UrlPatternString -> String
(Int -> UrlPatternString -> ShowS)
-> (UrlPatternString -> String)
-> ([UrlPatternString] -> ShowS)
-> Show UrlPatternString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UrlPatternString -> ShowS
showsPrec :: Int -> UrlPatternString -> ShowS
$cshow :: UrlPatternString -> String
show :: UrlPatternString -> String
$cshowList :: [UrlPatternString] -> ShowS
showList :: [UrlPatternString] -> ShowS
Show, UrlPatternString -> UrlPatternString -> Bool
(UrlPatternString -> UrlPatternString -> Bool)
-> (UrlPatternString -> UrlPatternString -> Bool)
-> Eq UrlPatternString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UrlPatternString -> UrlPatternString -> Bool
== :: UrlPatternString -> UrlPatternString -> Bool
$c/= :: UrlPatternString -> UrlPatternString -> Bool
/= :: UrlPatternString -> UrlPatternString -> Bool
Eq, (forall x. UrlPatternString -> Rep UrlPatternString x)
-> (forall x. Rep UrlPatternString x -> UrlPatternString)
-> Generic UrlPatternString
forall x. Rep UrlPatternString x -> UrlPatternString
forall x. UrlPatternString -> Rep UrlPatternString x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UrlPatternString -> Rep UrlPatternString x
from :: forall x. UrlPatternString -> Rep UrlPatternString x
$cto :: forall x. Rep UrlPatternString x -> UrlPatternString
to :: forall x. Rep UrlPatternString x -> UrlPatternString
Generic)

instance ToJSON UrlPatternString where
  toJSON :: UrlPatternString -> Value
  toJSON :: UrlPatternString -> Value
toJSON (MkUrlPatternString Text
p) =
    [Pair] -> Value
object
      [ Key
"type" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"string" :: Text),
        Key
"pattern" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
p
      ]

-- | URL pattern for interception
data UrlPatternPattern = MkUrlPatternPattern
  { UrlPatternPattern -> Maybe Text
protocol :: Maybe Text,
    UrlPatternPattern -> Maybe Text
hostname :: Maybe Text,
    UrlPatternPattern -> Maybe Text
port :: Maybe Text,
    UrlPatternPattern -> Maybe Text
pathname :: Maybe Text,
    UrlPatternPattern -> Maybe Text
search :: Maybe Text
  }
  deriving (Int -> UrlPatternPattern -> ShowS
[UrlPatternPattern] -> ShowS
UrlPatternPattern -> String
(Int -> UrlPatternPattern -> ShowS)
-> (UrlPatternPattern -> String)
-> ([UrlPatternPattern] -> ShowS)
-> Show UrlPatternPattern
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UrlPatternPattern -> ShowS
showsPrec :: Int -> UrlPatternPattern -> ShowS
$cshow :: UrlPatternPattern -> String
show :: UrlPatternPattern -> String
$cshowList :: [UrlPatternPattern] -> ShowS
showList :: [UrlPatternPattern] -> ShowS
Show, UrlPatternPattern -> UrlPatternPattern -> Bool
(UrlPatternPattern -> UrlPatternPattern -> Bool)
-> (UrlPatternPattern -> UrlPatternPattern -> Bool)
-> Eq UrlPatternPattern
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UrlPatternPattern -> UrlPatternPattern -> Bool
== :: UrlPatternPattern -> UrlPatternPattern -> Bool
$c/= :: UrlPatternPattern -> UrlPatternPattern -> Bool
/= :: UrlPatternPattern -> UrlPatternPattern -> Bool
Eq, (forall x. UrlPatternPattern -> Rep UrlPatternPattern x)
-> (forall x. Rep UrlPatternPattern x -> UrlPatternPattern)
-> Generic UrlPatternPattern
forall x. Rep UrlPatternPattern x -> UrlPatternPattern
forall x. UrlPatternPattern -> Rep UrlPatternPattern x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UrlPatternPattern -> Rep UrlPatternPattern x
from :: forall x. UrlPatternPattern -> Rep UrlPatternPattern x
$cto :: forall x. Rep UrlPatternPattern x -> UrlPatternPattern
to :: forall x. Rep UrlPatternPattern x -> UrlPatternPattern
Generic)

instance ToJSON UrlPatternPattern where
  toJSON :: UrlPatternPattern -> Value
  toJSON :: UrlPatternPattern -> Value
toJSON UrlPatternPattern
p = Text -> [Pair] -> Value -> Value
addProps Text
"UrlPatternPattern" [Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"pattern"] (Value -> Value) -> Value -> Value
forall a b. (a -> b) -> a -> b
$ UrlPatternPattern -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing UrlPatternPattern
p

-- | ContinueRequest parameters
data ContinueRequest = MkContinueRequest
  { ContinueRequest -> Request
request :: Request,
    ContinueRequest -> Maybe BytesValue
body :: Maybe BytesValue,
    ContinueRequest -> Maybe [CookieHeader]
cookies :: Maybe [CookieHeader],
    ContinueRequest -> Maybe [Header]
headers :: Maybe [Header],
    ContinueRequest -> Maybe Text
method :: Maybe Text,
    ContinueRequest -> Maybe URL
url :: Maybe URL
  }
  deriving (Int -> ContinueRequest -> ShowS
[ContinueRequest] -> ShowS
ContinueRequest -> String
(Int -> ContinueRequest -> ShowS)
-> (ContinueRequest -> String)
-> ([ContinueRequest] -> ShowS)
-> Show ContinueRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContinueRequest -> ShowS
showsPrec :: Int -> ContinueRequest -> ShowS
$cshow :: ContinueRequest -> String
show :: ContinueRequest -> String
$cshowList :: [ContinueRequest] -> ShowS
showList :: [ContinueRequest] -> ShowS
Show, ContinueRequest -> ContinueRequest -> Bool
(ContinueRequest -> ContinueRequest -> Bool)
-> (ContinueRequest -> ContinueRequest -> Bool)
-> Eq ContinueRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContinueRequest -> ContinueRequest -> Bool
== :: ContinueRequest -> ContinueRequest -> Bool
$c/= :: ContinueRequest -> ContinueRequest -> Bool
/= :: ContinueRequest -> ContinueRequest -> Bool
Eq, (forall x. ContinueRequest -> Rep ContinueRequest x)
-> (forall x. Rep ContinueRequest x -> ContinueRequest)
-> Generic ContinueRequest
forall x. Rep ContinueRequest x -> ContinueRequest
forall x. ContinueRequest -> Rep ContinueRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContinueRequest -> Rep ContinueRequest x
from :: forall x. ContinueRequest -> Rep ContinueRequest x
$cto :: forall x. Rep ContinueRequest x -> ContinueRequest
to :: forall x. Rep ContinueRequest x -> ContinueRequest
Generic)

instance ToJSON ContinueRequest where
  toJSON :: ContinueRequest -> Value
  toJSON :: ContinueRequest -> Value
toJSON = ContinueRequest -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

data CookieHeader = MkCookieHeader
  { CookieHeader -> Text
cookieHeaderName :: Text,
    CookieHeader -> BytesValue
cookieHeaderValue :: BytesValue
  }
  deriving (Int -> CookieHeader -> ShowS
[CookieHeader] -> ShowS
CookieHeader -> String
(Int -> CookieHeader -> ShowS)
-> (CookieHeader -> String)
-> ([CookieHeader] -> ShowS)
-> Show CookieHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CookieHeader -> ShowS
showsPrec :: Int -> CookieHeader -> ShowS
$cshow :: CookieHeader -> String
show :: CookieHeader -> String
$cshowList :: [CookieHeader] -> ShowS
showList :: [CookieHeader] -> ShowS
Show, CookieHeader -> CookieHeader -> Bool
(CookieHeader -> CookieHeader -> Bool)
-> (CookieHeader -> CookieHeader -> Bool) -> Eq CookieHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CookieHeader -> CookieHeader -> Bool
== :: CookieHeader -> CookieHeader -> Bool
$c/= :: CookieHeader -> CookieHeader -> Bool
/= :: CookieHeader -> CookieHeader -> Bool
Eq, (forall x. CookieHeader -> Rep CookieHeader x)
-> (forall x. Rep CookieHeader x -> CookieHeader)
-> Generic CookieHeader
forall x. Rep CookieHeader x -> CookieHeader
forall x. CookieHeader -> Rep CookieHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CookieHeader -> Rep CookieHeader x
from :: forall x. CookieHeader -> Rep CookieHeader x
$cto :: forall x. Rep CookieHeader x -> CookieHeader
to :: forall x. Rep CookieHeader x -> CookieHeader
Generic)

instance ToJSON CookieHeader where
  toJSON :: CookieHeader -> Value
  toJSON :: CookieHeader -> Value
toJSON CookieHeader
h =
    [Pair] -> Value
object
      [ Key
"name" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CookieHeader
h.cookieHeaderName,
        Key
"value" Key -> BytesValue -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= CookieHeader
h.cookieHeaderValue
      ]

instance FromJSON CookieHeader where
  parseJSON :: Value -> Parser CookieHeader
  parseJSON :: Value -> Parser CookieHeader
parseJSON = String
-> (Object -> Parser CookieHeader) -> Value -> Parser CookieHeader
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"CookieHeader" ((Object -> Parser CookieHeader) -> Value -> Parser CookieHeader)
-> (Object -> Parser CookieHeader) -> Value -> Parser CookieHeader
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    cookieHeaderName <- Object
obj Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
    cookieHeaderValue <- obj .: "value"
    pure $ MkCookieHeader {cookieHeaderName, cookieHeaderValue}

-- | BytesValue can be either string or base64-encoded
data BytesValue
  = TextBytesValue StringValue
  | Base64Value Text
  deriving (Int -> BytesValue -> ShowS
[BytesValue] -> ShowS
BytesValue -> String
(Int -> BytesValue -> ShowS)
-> (BytesValue -> String)
-> ([BytesValue] -> ShowS)
-> Show BytesValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BytesValue -> ShowS
showsPrec :: Int -> BytesValue -> ShowS
$cshow :: BytesValue -> String
show :: BytesValue -> String
$cshowList :: [BytesValue] -> ShowS
showList :: [BytesValue] -> ShowS
Show, BytesValue -> BytesValue -> Bool
(BytesValue -> BytesValue -> Bool)
-> (BytesValue -> BytesValue -> Bool) -> Eq BytesValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BytesValue -> BytesValue -> Bool
== :: BytesValue -> BytesValue -> Bool
$c/= :: BytesValue -> BytesValue -> Bool
/= :: BytesValue -> BytesValue -> Bool
Eq, (forall x. BytesValue -> Rep BytesValue x)
-> (forall x. Rep BytesValue x -> BytesValue) -> Generic BytesValue
forall x. Rep BytesValue x -> BytesValue
forall x. BytesValue -> Rep BytesValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BytesValue -> Rep BytesValue x
from :: forall x. BytesValue -> Rep BytesValue x
$cto :: forall x. Rep BytesValue x -> BytesValue
to :: forall x. Rep BytesValue x -> BytesValue
Generic)

instance FromJSON BytesValue where
  parseJSON :: Value -> Parser BytesValue
  parseJSON :: Value -> Parser BytesValue
parseJSON Value
v = do
    obj <- String -> (Object -> Parser Object) -> Value -> Parser Object
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"BytesValue" Object -> Parser Object
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value
v
    typ <- obj .: "type"
    case typ of
      String
"string" -> StringValue -> BytesValue
TextBytesValue (StringValue -> BytesValue)
-> Parser StringValue -> Parser BytesValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser StringValue
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
      String
"base64" -> Text -> BytesValue
Base64Value (Text -> BytesValue) -> Parser Text -> Parser BytesValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
      String
_ -> String -> Parser BytesValue
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser BytesValue) -> String -> Parser BytesValue
forall a b. (a -> b) -> a -> b
$ String
"Invalid BytesValue type: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ShowS
forall a. Show a => a -> String
show String
typ

instance ToJSON BytesValue where
  toJSON :: BytesValue -> Value
  toJSON :: BytesValue -> Value
toJSON = \case
    TextBytesValue StringValue
val ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"string",
          Key
"value" Key -> StringValue -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= StringValue
val
        ]
    Base64Value Text
val ->
      [Pair] -> Value
object
        [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"base64",
          Key
"value" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
val
        ]

-- | Cookie information
data Cookie = MkCookie
  { Cookie -> Text
name :: Text,
    Cookie -> BytesValue
value :: BytesValue,
    Cookie -> Text
domain :: Text,
    Cookie -> Text
path :: Text,
    Cookie -> Word
size :: Word,
    Cookie -> Bool
httpOnly :: Bool,
    Cookie -> Bool
secure :: Bool,
    Cookie -> SameSite
sameSite :: SameSite,
    Cookie -> Maybe Word
expiry :: Maybe Word
  }
  deriving (Int -> Cookie -> ShowS
[Cookie] -> ShowS
Cookie -> String
(Int -> Cookie -> ShowS)
-> (Cookie -> String) -> ([Cookie] -> ShowS) -> Show Cookie
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cookie -> ShowS
showsPrec :: Int -> Cookie -> ShowS
$cshow :: Cookie -> String
show :: Cookie -> String
$cshowList :: [Cookie] -> ShowS
showList :: [Cookie] -> ShowS
Show, Cookie -> Cookie -> Bool
(Cookie -> Cookie -> Bool)
-> (Cookie -> Cookie -> Bool) -> Eq Cookie
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cookie -> Cookie -> Bool
== :: Cookie -> Cookie -> Bool
$c/= :: Cookie -> Cookie -> Bool
/= :: Cookie -> Cookie -> Bool
Eq, (forall x. Cookie -> Rep Cookie x)
-> (forall x. Rep Cookie x -> Cookie) -> Generic Cookie
forall x. Rep Cookie x -> Cookie
forall x. Cookie -> Rep Cookie x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Cookie -> Rep Cookie x
from :: forall x. Cookie -> Rep Cookie x
$cto :: forall x. Rep Cookie x -> Cookie
to :: forall x. Rep Cookie x -> Cookie
Generic)

instance FromJSON Cookie

instance ToJSON Cookie where
  toJSON :: Cookie -> Value
  toJSON :: Cookie -> Value
toJSON = Cookie -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

data SameSite
  = Strict
  | Lax
  | SameSiteNone
  | Default
  deriving (Int -> SameSite -> ShowS
[SameSite] -> ShowS
SameSite -> String
(Int -> SameSite -> ShowS)
-> (SameSite -> String) -> ([SameSite] -> ShowS) -> Show SameSite
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SameSite -> ShowS
showsPrec :: Int -> SameSite -> ShowS
$cshow :: SameSite -> String
show :: SameSite -> String
$cshowList :: [SameSite] -> ShowS
showList :: [SameSite] -> ShowS
Show, SameSite -> SameSite -> Bool
(SameSite -> SameSite -> Bool)
-> (SameSite -> SameSite -> Bool) -> Eq SameSite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SameSite -> SameSite -> Bool
== :: SameSite -> SameSite -> Bool
$c/= :: SameSite -> SameSite -> Bool
/= :: SameSite -> SameSite -> Bool
Eq, (forall x. SameSite -> Rep SameSite x)
-> (forall x. Rep SameSite x -> SameSite) -> Generic SameSite
forall x. Rep SameSite x -> SameSite
forall x. SameSite -> Rep SameSite x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SameSite -> Rep SameSite x
from :: forall x. SameSite -> Rep SameSite x
$cto :: forall x. Rep SameSite x -> SameSite
to :: forall x. Rep SameSite x -> SameSite
Generic)

instance FromJSON SameSite where
  parseJSON :: Value -> Parser SameSite
  parseJSON :: Value -> Parser SameSite
parseJSON =
    String -> (Text -> Parser SameSite) -> Value -> Parser SameSite
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"SameSite" ((Text -> Parser SameSite) -> Value -> Parser SameSite)
-> (Text -> Parser SameSite) -> Value -> Parser SameSite
forall a b. (a -> b) -> a -> b
$ \case
      Text
"strict" -> SameSite -> Parser SameSite
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SameSite
Strict
      Text
"lax" -> SameSite -> Parser SameSite
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SameSite
Lax
      Text
"none" -> SameSite -> Parser SameSite
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SameSite
SameSiteNone
      Text
"default" -> SameSite -> Parser SameSite
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SameSite
Default
      Text
_ -> String -> Parser SameSite
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Invalid SameSite value"

instance ToJSON SameSite where
  toJSON :: SameSite -> Value
  toJSON :: SameSite -> Value
toJSON = \case
    SameSite
Strict -> Value
"strict"
    SameSite
Lax -> Value
"lax"
    SameSite
SameSiteNone -> Value
"none"
    SameSite
Default -> Value
"default"

-- | Headers for requests and responses
data Header = MkHeader
  { Header -> Text
headerName :: Text,
    Header -> BytesValue
headerValue :: BytesValue
  }
  deriving (Int -> Header -> ShowS
[Header] -> ShowS
Header -> String
(Int -> Header -> ShowS)
-> (Header -> String) -> ([Header] -> ShowS) -> Show Header
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Header -> ShowS
showsPrec :: Int -> Header -> ShowS
$cshow :: Header -> String
show :: Header -> String
$cshowList :: [Header] -> ShowS
showList :: [Header] -> ShowS
Show, Header -> Header -> Bool
(Header -> Header -> Bool)
-> (Header -> Header -> Bool) -> Eq Header
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Header -> Header -> Bool
== :: Header -> Header -> Bool
$c/= :: Header -> Header -> Bool
/= :: Header -> Header -> Bool
Eq, (forall x. Header -> Rep Header x)
-> (forall x. Rep Header x -> Header) -> Generic Header
forall x. Rep Header x -> Header
forall x. Header -> Rep Header x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Header -> Rep Header x
from :: forall x. Header -> Rep Header x
$cto :: forall x. Rep Header x -> Header
to :: forall x. Rep Header x -> Header
Generic)

instance FromJSON Header where
  parseJSON :: Value -> Parser Header
  parseJSON :: Value -> Parser Header
parseJSON = String -> (Object -> Parser Header) -> Value -> Parser Header
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Header" ((Object -> Parser Header) -> Value -> Parser Header)
-> (Object -> Parser Header) -> Value -> Parser Header
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    headerName <- Object
obj Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
    headerValue <- obj .: "value"
    pure $ MkHeader {headerName, headerValue}

instance ToJSON Header where
  toJSON :: Header -> Value
  toJSON :: Header -> Value
toJSON Header
h =
    [Pair] -> Value
object
      [ Key
"name" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Header
h.headerName,
        Key
"value" Key -> BytesValue -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Header
h.headerValue
      ]

-- | ContinueResponse parameters
data ContinueResponse = MkContinueResponse
  { ContinueResponse -> Request
request :: Request,
    ContinueResponse -> Maybe [SetCookieHeader]
cookies :: Maybe [SetCookieHeader],
    ContinueResponse -> Maybe AuthCredentials
credentials :: Maybe AuthCredentials,
    ContinueResponse -> Maybe [Header]
headers :: Maybe [Header],
    ContinueResponse -> Maybe Text
reasonPhrase :: Maybe Text,
    ContinueResponse -> Maybe JSUInt
statusCode :: Maybe JSUInt
  }
  deriving (Int -> ContinueResponse -> ShowS
[ContinueResponse] -> ShowS
ContinueResponse -> String
(Int -> ContinueResponse -> ShowS)
-> (ContinueResponse -> String)
-> ([ContinueResponse] -> ShowS)
-> Show ContinueResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContinueResponse -> ShowS
showsPrec :: Int -> ContinueResponse -> ShowS
$cshow :: ContinueResponse -> String
show :: ContinueResponse -> String
$cshowList :: [ContinueResponse] -> ShowS
showList :: [ContinueResponse] -> ShowS
Show, ContinueResponse -> ContinueResponse -> Bool
(ContinueResponse -> ContinueResponse -> Bool)
-> (ContinueResponse -> ContinueResponse -> Bool)
-> Eq ContinueResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContinueResponse -> ContinueResponse -> Bool
== :: ContinueResponse -> ContinueResponse -> Bool
$c/= :: ContinueResponse -> ContinueResponse -> Bool
/= :: ContinueResponse -> ContinueResponse -> Bool
Eq, (forall x. ContinueResponse -> Rep ContinueResponse x)
-> (forall x. Rep ContinueResponse x -> ContinueResponse)
-> Generic ContinueResponse
forall x. Rep ContinueResponse x -> ContinueResponse
forall x. ContinueResponse -> Rep ContinueResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContinueResponse -> Rep ContinueResponse x
from :: forall x. ContinueResponse -> Rep ContinueResponse x
$cto :: forall x. Rep ContinueResponse x -> ContinueResponse
to :: forall x. Rep ContinueResponse x -> ContinueResponse
Generic)

instance ToJSON ContinueResponse where
  toJSON :: ContinueResponse -> Value
  toJSON :: ContinueResponse -> Value
toJSON = ContinueResponse -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- | Partial cookie for setting
data SetCookieHeader = MkSetCookieHeader
  { SetCookieHeader -> Text
name :: Text,
    SetCookieHeader -> BytesValue
value :: BytesValue,
    SetCookieHeader -> Maybe Text
domain :: Maybe Text,
    SetCookieHeader -> Maybe Bool
httpOnly :: Maybe Bool,
    SetCookieHeader -> Maybe Text
expiry :: Maybe Text,
    SetCookieHeader -> Maybe JSUInt
maxAge :: Maybe JSUInt,
    SetCookieHeader -> Maybe Text
path :: Maybe Text,
    SetCookieHeader -> Maybe Bool
secure :: Maybe Bool,
    SetCookieHeader -> Maybe SameSite
sameSite :: Maybe SameSite
  }
  deriving (Int -> SetCookieHeader -> ShowS
[SetCookieHeader] -> ShowS
SetCookieHeader -> String
(Int -> SetCookieHeader -> ShowS)
-> (SetCookieHeader -> String)
-> ([SetCookieHeader] -> ShowS)
-> Show SetCookieHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCookieHeader -> ShowS
showsPrec :: Int -> SetCookieHeader -> ShowS
$cshow :: SetCookieHeader -> String
show :: SetCookieHeader -> String
$cshowList :: [SetCookieHeader] -> ShowS
showList :: [SetCookieHeader] -> ShowS
Show, SetCookieHeader -> SetCookieHeader -> Bool
(SetCookieHeader -> SetCookieHeader -> Bool)
-> (SetCookieHeader -> SetCookieHeader -> Bool)
-> Eq SetCookieHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCookieHeader -> SetCookieHeader -> Bool
== :: SetCookieHeader -> SetCookieHeader -> Bool
$c/= :: SetCookieHeader -> SetCookieHeader -> Bool
/= :: SetCookieHeader -> SetCookieHeader -> Bool
Eq, (forall x. SetCookieHeader -> Rep SetCookieHeader x)
-> (forall x. Rep SetCookieHeader x -> SetCookieHeader)
-> Generic SetCookieHeader
forall x. Rep SetCookieHeader x -> SetCookieHeader
forall x. SetCookieHeader -> Rep SetCookieHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetCookieHeader -> Rep SetCookieHeader x
from :: forall x. SetCookieHeader -> Rep SetCookieHeader x
$cto :: forall x. Rep SetCookieHeader x -> SetCookieHeader
to :: forall x. Rep SetCookieHeader x -> SetCookieHeader
Generic)

instance ToJSON SetCookieHeader where
  toJSON :: SetCookieHeader -> Value
  toJSON :: SetCookieHeader -> Value
toJSON = SetCookieHeader -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- | ContinueWithAuth parameters - using union type approach from spec
data ContinueWithAuth = MkContinueWithAuth
  { ContinueWithAuth -> Request
request :: Request,
    ContinueWithAuth -> AuthAction
authAction :: AuthAction
  }
  deriving (Int -> ContinueWithAuth -> ShowS
[ContinueWithAuth] -> ShowS
ContinueWithAuth -> String
(Int -> ContinueWithAuth -> ShowS)
-> (ContinueWithAuth -> String)
-> ([ContinueWithAuth] -> ShowS)
-> Show ContinueWithAuth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ContinueWithAuth -> ShowS
showsPrec :: Int -> ContinueWithAuth -> ShowS
$cshow :: ContinueWithAuth -> String
show :: ContinueWithAuth -> String
$cshowList :: [ContinueWithAuth] -> ShowS
showList :: [ContinueWithAuth] -> ShowS
Show, ContinueWithAuth -> ContinueWithAuth -> Bool
(ContinueWithAuth -> ContinueWithAuth -> Bool)
-> (ContinueWithAuth -> ContinueWithAuth -> Bool)
-> Eq ContinueWithAuth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ContinueWithAuth -> ContinueWithAuth -> Bool
== :: ContinueWithAuth -> ContinueWithAuth -> Bool
$c/= :: ContinueWithAuth -> ContinueWithAuth -> Bool
/= :: ContinueWithAuth -> ContinueWithAuth -> Bool
Eq, (forall x. ContinueWithAuth -> Rep ContinueWithAuth x)
-> (forall x. Rep ContinueWithAuth x -> ContinueWithAuth)
-> Generic ContinueWithAuth
forall x. Rep ContinueWithAuth x -> ContinueWithAuth
forall x. ContinueWithAuth -> Rep ContinueWithAuth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ContinueWithAuth -> Rep ContinueWithAuth x
from :: forall x. ContinueWithAuth -> Rep ContinueWithAuth x
$cto :: forall x. Rep ContinueWithAuth x -> ContinueWithAuth
to :: forall x. Rep ContinueWithAuth x -> ContinueWithAuth
Generic)

instance ToJSON ContinueWithAuth where
  toJSON :: ContinueWithAuth -> Value
  toJSON :: ContinueWithAuth -> Value
toJSON (MkContinueWithAuth Request
req AuthAction
action) =
    Text -> [Pair] -> Value -> Value
addProps Text
"ContinueWithAuth" [Key
"request" Key -> Request -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Request
req] (Value -> Value) -> Value -> Value
forall a b. (a -> b) -> a -> b
$ AuthAction -> Value
forall a. ToJSON a => a -> Value
toJSON AuthAction
action

-- | Auth action - matches spec's union type structure
data AuthAction
  = ProvideCredentials AuthCredentials
  | DefaultAuth
  | CancelAuth
  deriving (Int -> AuthAction -> ShowS
[AuthAction] -> ShowS
AuthAction -> String
(Int -> AuthAction -> ShowS)
-> (AuthAction -> String)
-> ([AuthAction] -> ShowS)
-> Show AuthAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthAction -> ShowS
showsPrec :: Int -> AuthAction -> ShowS
$cshow :: AuthAction -> String
show :: AuthAction -> String
$cshowList :: [AuthAction] -> ShowS
showList :: [AuthAction] -> ShowS
Show, AuthAction -> AuthAction -> Bool
(AuthAction -> AuthAction -> Bool)
-> (AuthAction -> AuthAction -> Bool) -> Eq AuthAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthAction -> AuthAction -> Bool
== :: AuthAction -> AuthAction -> Bool
$c/= :: AuthAction -> AuthAction -> Bool
/= :: AuthAction -> AuthAction -> Bool
Eq, (forall x. AuthAction -> Rep AuthAction x)
-> (forall x. Rep AuthAction x -> AuthAction) -> Generic AuthAction
forall x. Rep AuthAction x -> AuthAction
forall x. AuthAction -> Rep AuthAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AuthAction -> Rep AuthAction x
from :: forall x. AuthAction -> Rep AuthAction x
$cto :: forall x. Rep AuthAction x -> AuthAction
to :: forall x. Rep AuthAction x -> AuthAction
Generic)

instance ToJSON AuthAction where
  toJSON :: AuthAction -> Value
  toJSON :: AuthAction -> Value
toJSON (ProvideCredentials AuthCredentials
creds) = [Pair] -> Value
object [Key
"action" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"provideCredentials", Key
"credentials" Key -> AuthCredentials -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AuthCredentials
creds]
  toJSON AuthAction
DefaultAuth = [Pair] -> Value
object [Key
"action" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"default"]
  toJSON AuthAction
CancelAuth = [Pair] -> Value
object [Key
"action" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"cancel"]

-- | Network intercept identifier
newtype Intercept = MkIntercept Text
  deriving (Int -> Intercept -> ShowS
[Intercept] -> ShowS
Intercept -> String
(Int -> Intercept -> ShowS)
-> (Intercept -> String)
-> ([Intercept] -> ShowS)
-> Show Intercept
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Intercept -> ShowS
showsPrec :: Int -> Intercept -> ShowS
$cshow :: Intercept -> String
show :: Intercept -> String
$cshowList :: [Intercept] -> ShowS
showList :: [Intercept] -> ShowS
Show, Intercept -> Intercept -> Bool
(Intercept -> Intercept -> Bool)
-> (Intercept -> Intercept -> Bool) -> Eq Intercept
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Intercept -> Intercept -> Bool
== :: Intercept -> Intercept -> Bool
$c/= :: Intercept -> Intercept -> Bool
/= :: Intercept -> Intercept -> Bool
Eq, (forall x. Intercept -> Rep Intercept x)
-> (forall x. Rep Intercept x -> Intercept) -> Generic Intercept
forall x. Rep Intercept x -> Intercept
forall x. Intercept -> Rep Intercept x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Intercept -> Rep Intercept x
from :: forall x. Intercept -> Rep Intercept x
$cto :: forall x. Rep Intercept x -> Intercept
to :: forall x. Rep Intercept x -> Intercept
Generic, Maybe Intercept
Value -> Parser [Intercept]
Value -> Parser Intercept
(Value -> Parser Intercept)
-> (Value -> Parser [Intercept])
-> Maybe Intercept
-> FromJSON Intercept
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Intercept
parseJSON :: Value -> Parser Intercept
$cparseJSONList :: Value -> Parser [Intercept]
parseJSONList :: Value -> Parser [Intercept]
$comittedField :: Maybe Intercept
omittedField :: Maybe Intercept
FromJSON, [Intercept] -> Value
[Intercept] -> Encoding
Intercept -> Bool
Intercept -> Value
Intercept -> Encoding
(Intercept -> Value)
-> (Intercept -> Encoding)
-> ([Intercept] -> Value)
-> ([Intercept] -> Encoding)
-> (Intercept -> Bool)
-> ToJSON Intercept
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: Intercept -> Value
toJSON :: Intercept -> Value
$ctoEncoding :: Intercept -> Encoding
toEncoding :: Intercept -> Encoding
$ctoJSONList :: [Intercept] -> Value
toJSONList :: [Intercept] -> Value
$ctoEncodingList :: [Intercept] -> Encoding
toEncodingList :: [Intercept] -> Encoding
$comitField :: Intercept -> Bool
omitField :: Intercept -> Bool
ToJSON)

-- | Auth credentials for authentication
data AuthCredentials = MkAuthCredentials
  { AuthCredentials -> Text
username :: Text,
    AuthCredentials -> Text
password :: Text
  }
  deriving (Int -> AuthCredentials -> ShowS
[AuthCredentials] -> ShowS
AuthCredentials -> String
(Int -> AuthCredentials -> ShowS)
-> (AuthCredentials -> String)
-> ([AuthCredentials] -> ShowS)
-> Show AuthCredentials
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthCredentials -> ShowS
showsPrec :: Int -> AuthCredentials -> ShowS
$cshow :: AuthCredentials -> String
show :: AuthCredentials -> String
$cshowList :: [AuthCredentials] -> ShowS
showList :: [AuthCredentials] -> ShowS
Show, AuthCredentials -> AuthCredentials -> Bool
(AuthCredentials -> AuthCredentials -> Bool)
-> (AuthCredentials -> AuthCredentials -> Bool)
-> Eq AuthCredentials
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthCredentials -> AuthCredentials -> Bool
== :: AuthCredentials -> AuthCredentials -> Bool
$c/= :: AuthCredentials -> AuthCredentials -> Bool
/= :: AuthCredentials -> AuthCredentials -> Bool
Eq, (forall x. AuthCredentials -> Rep AuthCredentials x)
-> (forall x. Rep AuthCredentials x -> AuthCredentials)
-> Generic AuthCredentials
forall x. Rep AuthCredentials x -> AuthCredentials
forall x. AuthCredentials -> Rep AuthCredentials x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AuthCredentials -> Rep AuthCredentials x
from :: forall x. AuthCredentials -> Rep AuthCredentials x
$cto :: forall x. Rep AuthCredentials x -> AuthCredentials
to :: forall x. Rep AuthCredentials x -> AuthCredentials
Generic)

instance ToJSON AuthCredentials where
  toJSON :: AuthCredentials -> Value
  toJSON :: AuthCredentials -> Value
toJSON (MkAuthCredentials Text
user Text
pass) =
    [Pair] -> Value
object
      [ Key
"type" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
"password",
        Key
"username" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
user,
        Key
"password" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
pass
      ]

-- | FailRequest parameters
data FailRequest = MkFailRequest
  { FailRequest -> Request
request :: Request
  }
  deriving (Int -> FailRequest -> ShowS
[FailRequest] -> ShowS
FailRequest -> String
(Int -> FailRequest -> ShowS)
-> (FailRequest -> String)
-> ([FailRequest] -> ShowS)
-> Show FailRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FailRequest -> ShowS
showsPrec :: Int -> FailRequest -> ShowS
$cshow :: FailRequest -> String
show :: FailRequest -> String
$cshowList :: [FailRequest] -> ShowS
showList :: [FailRequest] -> ShowS
Show, FailRequest -> FailRequest -> Bool
(FailRequest -> FailRequest -> Bool)
-> (FailRequest -> FailRequest -> Bool) -> Eq FailRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FailRequest -> FailRequest -> Bool
== :: FailRequest -> FailRequest -> Bool
$c/= :: FailRequest -> FailRequest -> Bool
/= :: FailRequest -> FailRequest -> Bool
Eq, (forall x. FailRequest -> Rep FailRequest x)
-> (forall x. Rep FailRequest x -> FailRequest)
-> Generic FailRequest
forall x. Rep FailRequest x -> FailRequest
forall x. FailRequest -> Rep FailRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FailRequest -> Rep FailRequest x
from :: forall x. FailRequest -> Rep FailRequest x
$cto :: forall x. Rep FailRequest x -> FailRequest
to :: forall x. Rep FailRequest x -> FailRequest
Generic)

instance ToJSON FailRequest

-- | ProvideResponse parameters
data ProvideResponse = MkProvideResponse
  { ProvideResponse -> Request
request :: Request,
    ProvideResponse -> Intercept
intercept :: Intercept,
    ProvideResponse -> Maybe BytesValue
body :: Maybe BytesValue,
    ProvideResponse -> Maybe [Cookie]
cookies :: Maybe [Cookie],
    ProvideResponse -> Maybe [Header]
headers :: Maybe [Header],
    ProvideResponse -> Text
reasonPhrase :: Text,
    ProvideResponse -> Word
statusCode :: Word
  }
  deriving (Int -> ProvideResponse -> ShowS
[ProvideResponse] -> ShowS
ProvideResponse -> String
(Int -> ProvideResponse -> ShowS)
-> (ProvideResponse -> String)
-> ([ProvideResponse] -> ShowS)
-> Show ProvideResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ProvideResponse -> ShowS
showsPrec :: Int -> ProvideResponse -> ShowS
$cshow :: ProvideResponse -> String
show :: ProvideResponse -> String
$cshowList :: [ProvideResponse] -> ShowS
showList :: [ProvideResponse] -> ShowS
Show, ProvideResponse -> ProvideResponse -> Bool
(ProvideResponse -> ProvideResponse -> Bool)
-> (ProvideResponse -> ProvideResponse -> Bool)
-> Eq ProvideResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ProvideResponse -> ProvideResponse -> Bool
== :: ProvideResponse -> ProvideResponse -> Bool
$c/= :: ProvideResponse -> ProvideResponse -> Bool
/= :: ProvideResponse -> ProvideResponse -> Bool
Eq, (forall x. ProvideResponse -> Rep ProvideResponse x)
-> (forall x. Rep ProvideResponse x -> ProvideResponse)
-> Generic ProvideResponse
forall x. Rep ProvideResponse x -> ProvideResponse
forall x. ProvideResponse -> Rep ProvideResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ProvideResponse -> Rep ProvideResponse x
from :: forall x. ProvideResponse -> Rep ProvideResponse x
$cto :: forall x. Rep ProvideResponse x -> ProvideResponse
to :: forall x. Rep ProvideResponse x -> ProvideResponse
Generic)

instance ToJSON ProvideResponse where
  toJSON :: ProvideResponse -> Value
  toJSON :: ProvideResponse -> Value
toJSON = ProvideResponse -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- | RemoveIntercept parameters
newtype RemoveIntercept = MkRemoveIntercept
  { RemoveIntercept -> Intercept
intercept :: Intercept
  }
  deriving (Int -> RemoveIntercept -> ShowS
[RemoveIntercept] -> ShowS
RemoveIntercept -> String
(Int -> RemoveIntercept -> ShowS)
-> (RemoveIntercept -> String)
-> ([RemoveIntercept] -> ShowS)
-> Show RemoveIntercept
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoveIntercept -> ShowS
showsPrec :: Int -> RemoveIntercept -> ShowS
$cshow :: RemoveIntercept -> String
show :: RemoveIntercept -> String
$cshowList :: [RemoveIntercept] -> ShowS
showList :: [RemoveIntercept] -> ShowS
Show, RemoveIntercept -> RemoveIntercept -> Bool
(RemoveIntercept -> RemoveIntercept -> Bool)
-> (RemoveIntercept -> RemoveIntercept -> Bool)
-> Eq RemoveIntercept
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoveIntercept -> RemoveIntercept -> Bool
== :: RemoveIntercept -> RemoveIntercept -> Bool
$c/= :: RemoveIntercept -> RemoveIntercept -> Bool
/= :: RemoveIntercept -> RemoveIntercept -> Bool
Eq, (forall x. RemoveIntercept -> Rep RemoveIntercept x)
-> (forall x. Rep RemoveIntercept x -> RemoveIntercept)
-> Generic RemoveIntercept
forall x. Rep RemoveIntercept x -> RemoveIntercept
forall x. RemoveIntercept -> Rep RemoveIntercept x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoveIntercept -> Rep RemoveIntercept x
from :: forall x. RemoveIntercept -> Rep RemoveIntercept x
$cto :: forall x. Rep RemoveIntercept x -> RemoveIntercept
to :: forall x. Rep RemoveIntercept x -> RemoveIntercept
Generic)

instance ToJSON RemoveIntercept

-- | SetCacheBehavior parameters
data SetCacheBehavior = MkSetCacheBehavior
  { SetCacheBehavior -> CacheBehavior
cacheBehavior :: CacheBehavior,
    SetCacheBehavior -> Maybe [BrowsingContext]
contexts :: Maybe [BrowsingContext]
  }
  deriving (Int -> SetCacheBehavior -> ShowS
[SetCacheBehavior] -> ShowS
SetCacheBehavior -> String
(Int -> SetCacheBehavior -> ShowS)
-> (SetCacheBehavior -> String)
-> ([SetCacheBehavior] -> ShowS)
-> Show SetCacheBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCacheBehavior -> ShowS
showsPrec :: Int -> SetCacheBehavior -> ShowS
$cshow :: SetCacheBehavior -> String
show :: SetCacheBehavior -> String
$cshowList :: [SetCacheBehavior] -> ShowS
showList :: [SetCacheBehavior] -> ShowS
Show, SetCacheBehavior -> SetCacheBehavior -> Bool
(SetCacheBehavior -> SetCacheBehavior -> Bool)
-> (SetCacheBehavior -> SetCacheBehavior -> Bool)
-> Eq SetCacheBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCacheBehavior -> SetCacheBehavior -> Bool
== :: SetCacheBehavior -> SetCacheBehavior -> Bool
$c/= :: SetCacheBehavior -> SetCacheBehavior -> Bool
/= :: SetCacheBehavior -> SetCacheBehavior -> Bool
Eq, (forall x. SetCacheBehavior -> Rep SetCacheBehavior x)
-> (forall x. Rep SetCacheBehavior x -> SetCacheBehavior)
-> Generic SetCacheBehavior
forall x. Rep SetCacheBehavior x -> SetCacheBehavior
forall x. SetCacheBehavior -> Rep SetCacheBehavior x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetCacheBehavior -> Rep SetCacheBehavior x
from :: forall x. SetCacheBehavior -> Rep SetCacheBehavior x
$cto :: forall x. Rep SetCacheBehavior x -> SetCacheBehavior
to :: forall x. Rep SetCacheBehavior x -> SetCacheBehavior
Generic)

instance ToJSON SetCacheBehavior where
  toJSON :: SetCacheBehavior -> Value
  toJSON :: SetCacheBehavior -> Value
toJSON = SetCacheBehavior -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- | Cache behavior options
data CacheBehavior
  = DefaultCacheBehavior
  | BypassCache
  deriving (Int -> CacheBehavior -> ShowS
[CacheBehavior] -> ShowS
CacheBehavior -> String
(Int -> CacheBehavior -> ShowS)
-> (CacheBehavior -> String)
-> ([CacheBehavior] -> ShowS)
-> Show CacheBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CacheBehavior -> ShowS
showsPrec :: Int -> CacheBehavior -> ShowS
$cshow :: CacheBehavior -> String
show :: CacheBehavior -> String
$cshowList :: [CacheBehavior] -> ShowS
showList :: [CacheBehavior] -> ShowS
Show, CacheBehavior -> CacheBehavior -> Bool
(CacheBehavior -> CacheBehavior -> Bool)
-> (CacheBehavior -> CacheBehavior -> Bool) -> Eq CacheBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CacheBehavior -> CacheBehavior -> Bool
== :: CacheBehavior -> CacheBehavior -> Bool
$c/= :: CacheBehavior -> CacheBehavior -> Bool
/= :: CacheBehavior -> CacheBehavior -> Bool
Eq, (forall x. CacheBehavior -> Rep CacheBehavior x)
-> (forall x. Rep CacheBehavior x -> CacheBehavior)
-> Generic CacheBehavior
forall x. Rep CacheBehavior x -> CacheBehavior
forall x. CacheBehavior -> Rep CacheBehavior x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CacheBehavior -> Rep CacheBehavior x
from :: forall x. CacheBehavior -> Rep CacheBehavior x
$cto :: forall x. Rep CacheBehavior x -> CacheBehavior
to :: forall x. Rep CacheBehavior x -> CacheBehavior
Generic)

instance ToJSON CacheBehavior where
  toJSON :: CacheBehavior -> Value
  toJSON :: CacheBehavior -> Value
toJSON CacheBehavior
DefaultCacheBehavior = Value
"default"
  toJSON CacheBehavior
BypassCache = Value
"bypass"

-- | SetExtraHeaders parameters
data SetExtraHeaders = MkSetExtraHeaders
  { SetExtraHeaders -> [Header]
headers :: [Header],
    SetExtraHeaders -> Maybe [BrowsingContext]
contexts :: Maybe [BrowsingContext],
    SetExtraHeaders -> Maybe [UserContext]
userContexts :: Maybe [UserContext]
  }
  deriving (Int -> SetExtraHeaders -> ShowS
[SetExtraHeaders] -> ShowS
SetExtraHeaders -> String
(Int -> SetExtraHeaders -> ShowS)
-> (SetExtraHeaders -> String)
-> ([SetExtraHeaders] -> ShowS)
-> Show SetExtraHeaders
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetExtraHeaders -> ShowS
showsPrec :: Int -> SetExtraHeaders -> ShowS
$cshow :: SetExtraHeaders -> String
show :: SetExtraHeaders -> String
$cshowList :: [SetExtraHeaders] -> ShowS
showList :: [SetExtraHeaders] -> ShowS
Show, SetExtraHeaders -> SetExtraHeaders -> Bool
(SetExtraHeaders -> SetExtraHeaders -> Bool)
-> (SetExtraHeaders -> SetExtraHeaders -> Bool)
-> Eq SetExtraHeaders
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetExtraHeaders -> SetExtraHeaders -> Bool
== :: SetExtraHeaders -> SetExtraHeaders -> Bool
$c/= :: SetExtraHeaders -> SetExtraHeaders -> Bool
/= :: SetExtraHeaders -> SetExtraHeaders -> Bool
Eq, (forall x. SetExtraHeaders -> Rep SetExtraHeaders x)
-> (forall x. Rep SetExtraHeaders x -> SetExtraHeaders)
-> Generic SetExtraHeaders
forall x. Rep SetExtraHeaders x -> SetExtraHeaders
forall x. SetExtraHeaders -> Rep SetExtraHeaders x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SetExtraHeaders -> Rep SetExtraHeaders x
from :: forall x. SetExtraHeaders -> Rep SetExtraHeaders x
$cto :: forall x. Rep SetExtraHeaders x -> SetExtraHeaders
to :: forall x. Rep SetExtraHeaders x -> SetExtraHeaders
Generic)

instance ToJSON SetExtraHeaders where
  toJSON :: SetExtraHeaders -> Value
  toJSON :: SetExtraHeaders -> Value
toJSON = SetExtraHeaders -> Value
forall a. (Generic a, GToJSON' Value Zero (Rep a)) => a -> Value
toJSONOmitNothing

-- ######### Local #########

newtype AddInterceptResult = MkAddInterceptResult
  { -- name changed to avoid conflict with field name in AddIntercept
    AddInterceptResult -> Intercept
addedIntercept :: Intercept
  }
  deriving (Int -> AddInterceptResult -> ShowS
[AddInterceptResult] -> ShowS
AddInterceptResult -> String
(Int -> AddInterceptResult -> ShowS)
-> (AddInterceptResult -> String)
-> ([AddInterceptResult] -> ShowS)
-> Show AddInterceptResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddInterceptResult -> ShowS
showsPrec :: Int -> AddInterceptResult -> ShowS
$cshow :: AddInterceptResult -> String
show :: AddInterceptResult -> String
$cshowList :: [AddInterceptResult] -> ShowS
showList :: [AddInterceptResult] -> ShowS
Show, AddInterceptResult -> AddInterceptResult -> Bool
(AddInterceptResult -> AddInterceptResult -> Bool)
-> (AddInterceptResult -> AddInterceptResult -> Bool)
-> Eq AddInterceptResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddInterceptResult -> AddInterceptResult -> Bool
== :: AddInterceptResult -> AddInterceptResult -> Bool
$c/= :: AddInterceptResult -> AddInterceptResult -> Bool
/= :: AddInterceptResult -> AddInterceptResult -> Bool
Eq, (forall x. AddInterceptResult -> Rep AddInterceptResult x)
-> (forall x. Rep AddInterceptResult x -> AddInterceptResult)
-> Generic AddInterceptResult
forall x. Rep AddInterceptResult x -> AddInterceptResult
forall x. AddInterceptResult -> Rep AddInterceptResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddInterceptResult -> Rep AddInterceptResult x
from :: forall x. AddInterceptResult -> Rep AddInterceptResult x
$cto :: forall x. Rep AddInterceptResult x -> AddInterceptResult
to :: forall x. Rep AddInterceptResult x -> AddInterceptResult
Generic)

instance FromJSON AddInterceptResult where
  parseJSON :: Value -> Parser AddInterceptResult
  parseJSON :: Value -> Parser AddInterceptResult
parseJSON =
    String
-> (Object -> Parser AddInterceptResult)
-> Value
-> Parser AddInterceptResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"AddInterceptResult" ((Object -> Parser AddInterceptResult)
 -> Value -> Parser AddInterceptResult)
-> (Object -> Parser AddInterceptResult)
-> Value
-> Parser AddInterceptResult
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
      Intercept -> AddInterceptResult
MkAddInterceptResult (Intercept -> AddInterceptResult)
-> Parser Intercept -> Parser AddInterceptResult
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj Object -> Key -> Parser Intercept
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"intercept"

data NetworkEvent
  = AuthRequiredEvent AuthRequired
  | BeforeRequestSentEvent BeforeRequestSent
  | FetchError FetchError
  | ResponseCompleted ResponseCompleted
  | ResponseStartedEvent ResponseStarted
  deriving (Int -> NetworkEvent -> ShowS
[NetworkEvent] -> ShowS
NetworkEvent -> String
(Int -> NetworkEvent -> ShowS)
-> (NetworkEvent -> String)
-> ([NetworkEvent] -> ShowS)
-> Show NetworkEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NetworkEvent -> ShowS
showsPrec :: Int -> NetworkEvent -> ShowS
$cshow :: NetworkEvent -> String
show :: NetworkEvent -> String
$cshowList :: [NetworkEvent] -> ShowS
showList :: [NetworkEvent] -> ShowS
Show, NetworkEvent -> NetworkEvent -> Bool
(NetworkEvent -> NetworkEvent -> Bool)
-> (NetworkEvent -> NetworkEvent -> Bool) -> Eq NetworkEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NetworkEvent -> NetworkEvent -> Bool
== :: NetworkEvent -> NetworkEvent -> Bool
$c/= :: NetworkEvent -> NetworkEvent -> Bool
/= :: NetworkEvent -> NetworkEvent -> Bool
Eq, (forall x. NetworkEvent -> Rep NetworkEvent x)
-> (forall x. Rep NetworkEvent x -> NetworkEvent)
-> Generic NetworkEvent
forall x. Rep NetworkEvent x -> NetworkEvent
forall x. NetworkEvent -> Rep NetworkEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. NetworkEvent -> Rep NetworkEvent x
from :: forall x. NetworkEvent -> Rep NetworkEvent x
$cto :: forall x. Rep NetworkEvent x -> NetworkEvent
to :: forall x. Rep NetworkEvent x -> NetworkEvent
Generic)

instance FromJSON NetworkEvent where
  parseJSON :: Value -> Parser NetworkEvent
  parseJSON :: Value -> Parser NetworkEvent
parseJSON Value
val =
    Value
val
      Value -> (Value -> Parser NetworkEvent) -> Parser NetworkEvent
forall a b. a -> (a -> b) -> b
& ( String
-> (Object -> Parser NetworkEvent) -> Value -> Parser NetworkEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"NetworkEvent" ((Object -> Parser NetworkEvent) -> Value -> Parser NetworkEvent)
-> (Object -> Parser NetworkEvent) -> Value -> Parser NetworkEvent
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
            eventType <- Object
obj Object -> Key -> Parser KnownSubscriptionType
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"method"
            params <- obj .: "params"
            let parseParams :: forall a b. (FromJSON a) => (a -> b) -> Parser b
                parseParams = Parser a -> (a -> b) -> Parser b
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
(<&>) (Value -> Parser a
forall a. FromJSON a => Value -> Parser a
parseJSON Value
params)
            case eventType of
              KnownSubscriptionType
NetworkAuthRequired -> (AuthRequired -> NetworkEvent) -> Parser NetworkEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parseParams AuthRequired -> NetworkEvent
AuthRequiredEvent
              KnownSubscriptionType
NetworkBeforeRequestSent -> (BeforeRequestSent -> NetworkEvent) -> Parser NetworkEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parseParams BeforeRequestSent -> NetworkEvent
BeforeRequestSentEvent
              KnownSubscriptionType
NetworkFetchError -> (FetchError -> NetworkEvent) -> Parser NetworkEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parseParams FetchError -> NetworkEvent
FetchError
              KnownSubscriptionType
NetworkResponseCompleted -> (ResponseCompleted -> NetworkEvent) -> Parser NetworkEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parseParams ResponseCompleted -> NetworkEvent
ResponseCompleted
              KnownSubscriptionType
NetworkResponseStarted -> (ResponseStarted -> NetworkEvent) -> Parser NetworkEvent
forall a b. FromJSON a => (a -> b) -> Parser b
parseParams ResponseStarted -> NetworkEvent
ResponseStartedEvent
              KnownSubscriptionType
_ -> String -> Parser NetworkEvent
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser NetworkEvent) -> String -> Parser NetworkEvent
forall a b. (a -> b) -> a -> b
$ String
"Unknown NetworkEvent type: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> KnownSubscriptionType -> String
forall a. Show a => a -> String
show KnownSubscriptionType
eventType
        )


data HTTPMethod
  = GET
  | POST
  | PUT
  | DELETE
  | HEAD
  | OPTIONS
  | PATCH
  | TRACE
  | CONNECT
  deriving (Int -> HTTPMethod -> ShowS
[HTTPMethod] -> ShowS
HTTPMethod -> String
(Int -> HTTPMethod -> ShowS)
-> (HTTPMethod -> String)
-> ([HTTPMethod] -> ShowS)
-> Show HTTPMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HTTPMethod -> ShowS
showsPrec :: Int -> HTTPMethod -> ShowS
$cshow :: HTTPMethod -> String
show :: HTTPMethod -> String
$cshowList :: [HTTPMethod] -> ShowS
showList :: [HTTPMethod] -> ShowS
Show, HTTPMethod -> HTTPMethod -> Bool
(HTTPMethod -> HTTPMethod -> Bool)
-> (HTTPMethod -> HTTPMethod -> Bool) -> Eq HTTPMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HTTPMethod -> HTTPMethod -> Bool
== :: HTTPMethod -> HTTPMethod -> Bool
$c/= :: HTTPMethod -> HTTPMethod -> Bool
/= :: HTTPMethod -> HTTPMethod -> Bool
Eq, (forall x. HTTPMethod -> Rep HTTPMethod x)
-> (forall x. Rep HTTPMethod x -> HTTPMethod) -> Generic HTTPMethod
forall x. Rep HTTPMethod x -> HTTPMethod
forall x. HTTPMethod -> Rep HTTPMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HTTPMethod -> Rep HTTPMethod x
from :: forall x. HTTPMethod -> Rep HTTPMethod x
$cto :: forall x. Rep HTTPMethod x -> HTTPMethod
to :: forall x. Rep HTTPMethod x -> HTTPMethod
Generic)

instance FromJSON HTTPMethod where
  parseJSON :: Value -> Parser HTTPMethod
  parseJSON :: Value -> Parser HTTPMethod
parseJSON = String -> (Text -> Parser HTTPMethod) -> Value -> Parser HTTPMethod
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"Method" ((Text -> Parser HTTPMethod) -> Value -> Parser HTTPMethod)
-> (Text -> Parser HTTPMethod) -> Value -> Parser HTTPMethod
forall a b. (a -> b) -> a -> b
$ \Text
t ->
    case Text -> Text
toLower Text
t of
      Text
"get" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
GET
      Text
"post" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
POST
      Text
"put" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
PUT
      Text
"delete" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
DELETE
      Text
"head" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
HEAD
      Text
"options" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
OPTIONS
      Text
"patch" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
PATCH
      Text
"trace" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
TRACE
      Text
"connect" -> HTTPMethod -> Parser HTTPMethod
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HTTPMethod
CONNECT
      Text
_ -> String -> Parser HTTPMethod
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser HTTPMethod) -> String -> Parser HTTPMethod
forall a b. (a -> b) -> a -> b
$ String
"Unknown HTTP method: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
t

data RequestData = MkRequestData
  { RequestData -> Request
request :: Request,
    RequestData -> Text
url :: Text,
    RequestData -> HTTPMethod
method :: HTTPMethod,
    RequestData -> [Header]
headers :: [Header],
    -- not as per spec but geckodriver appears to be returning cookie headers rather than cookies
    RequestData -> Maybe [CookieHeader]
cookies :: Maybe [CookieHeader],
    -- cookies :: Maybe [Cookie],
    RequestData -> JSUInt
headersSize :: JSUInt,
    RequestData -> Maybe JSUInt
bodySize :: Maybe JSUInt,
    RequestData -> Text
destination :: Text,
    RequestData -> Maybe InitiatorType
initiatorType :: Maybe InitiatorType,
    RequestData -> Maybe FetchTimingInfo
timings :: Maybe FetchTimingInfo
  }
  deriving (Int -> RequestData -> ShowS
[RequestData] -> ShowS
RequestData -> String
(Int -> RequestData -> ShowS)
-> (RequestData -> String)
-> ([RequestData] -> ShowS)
-> Show RequestData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RequestData -> ShowS
showsPrec :: Int -> RequestData -> ShowS
$cshow :: RequestData -> String
show :: RequestData -> String
$cshowList :: [RequestData] -> ShowS
showList :: [RequestData] -> ShowS
Show, RequestData -> RequestData -> Bool
(RequestData -> RequestData -> Bool)
-> (RequestData -> RequestData -> Bool) -> Eq RequestData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RequestData -> RequestData -> Bool
== :: RequestData -> RequestData -> Bool
$c/= :: RequestData -> RequestData -> Bool
/= :: RequestData -> RequestData -> Bool
Eq, (forall x. RequestData -> Rep RequestData x)
-> (forall x. Rep RequestData x -> RequestData)
-> Generic RequestData
forall x. Rep RequestData x -> RequestData
forall x. RequestData -> Rep RequestData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RequestData -> Rep RequestData x
from :: forall x. RequestData -> Rep RequestData x
$cto :: forall x. Rep RequestData x -> RequestData
to :: forall x. Rep RequestData x -> RequestData
Generic)

instance FromJSON RequestData where
  parseJSON :: Value -> Parser RequestData
  parseJSON :: Value -> Parser RequestData
parseJSON = Value -> Parser RequestData
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

data FetchTimingInfo = MkFetchTimingInfo
  { FetchTimingInfo -> Double
timeOrigin :: Double,
    FetchTimingInfo -> Double
requestTime :: Double,
    FetchTimingInfo -> Double
redirectStart :: Double,
    FetchTimingInfo -> Double
redirectEnd :: Double,
    FetchTimingInfo -> Double
fetchStart :: Double,
    FetchTimingInfo -> Double
dnsStart :: Double,
    FetchTimingInfo -> Double
dnsEnd :: Double,
    FetchTimingInfo -> Double
connectStart :: Double,
    FetchTimingInfo -> Double
connectEnd :: Double,
    FetchTimingInfo -> Double
tlsStart :: Double,
    FetchTimingInfo -> Double
requestStart :: Double,
    FetchTimingInfo -> Double
responseStart :: Double,
    FetchTimingInfo -> Double
responseEnd :: Double
  }
  deriving (Int -> FetchTimingInfo -> ShowS
[FetchTimingInfo] -> ShowS
FetchTimingInfo -> String
(Int -> FetchTimingInfo -> ShowS)
-> (FetchTimingInfo -> String)
-> ([FetchTimingInfo] -> ShowS)
-> Show FetchTimingInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FetchTimingInfo -> ShowS
showsPrec :: Int -> FetchTimingInfo -> ShowS
$cshow :: FetchTimingInfo -> String
show :: FetchTimingInfo -> String
$cshowList :: [FetchTimingInfo] -> ShowS
showList :: [FetchTimingInfo] -> ShowS
Show, FetchTimingInfo -> FetchTimingInfo -> Bool
(FetchTimingInfo -> FetchTimingInfo -> Bool)
-> (FetchTimingInfo -> FetchTimingInfo -> Bool)
-> Eq FetchTimingInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FetchTimingInfo -> FetchTimingInfo -> Bool
== :: FetchTimingInfo -> FetchTimingInfo -> Bool
$c/= :: FetchTimingInfo -> FetchTimingInfo -> Bool
/= :: FetchTimingInfo -> FetchTimingInfo -> Bool
Eq, (forall x. FetchTimingInfo -> Rep FetchTimingInfo x)
-> (forall x. Rep FetchTimingInfo x -> FetchTimingInfo)
-> Generic FetchTimingInfo
forall x. Rep FetchTimingInfo x -> FetchTimingInfo
forall x. FetchTimingInfo -> Rep FetchTimingInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FetchTimingInfo -> Rep FetchTimingInfo x
from :: forall x. FetchTimingInfo -> Rep FetchTimingInfo x
$cto :: forall x. Rep FetchTimingInfo x -> FetchTimingInfo
to :: forall x. Rep FetchTimingInfo x -> FetchTimingInfo
Generic)

instance FromJSON FetchTimingInfo

-- | AuthRequired parameters
data AuthRequired = MkAuthRequired
  { AuthRequired -> BrowsingContext
context :: BrowsingContext,
    AuthRequired -> Bool
isBlocked :: Bool,
    AuthRequired -> Maybe Navigation
navigation :: Maybe Navigation,
    AuthRequired -> JSUInt
redirectCount :: JSUInt,
    AuthRequired -> RequestData
request :: RequestData,
    AuthRequired -> JSUInt
timestamp :: JSUInt,
    AuthRequired -> Maybe [Intercept]
intercepts :: Maybe [Intercept],
    AuthRequired -> ResponseData
response :: ResponseData
  }
  deriving (Int -> AuthRequired -> ShowS
[AuthRequired] -> ShowS
AuthRequired -> String
(Int -> AuthRequired -> ShowS)
-> (AuthRequired -> String)
-> ([AuthRequired] -> ShowS)
-> Show AuthRequired
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthRequired -> ShowS
showsPrec :: Int -> AuthRequired -> ShowS
$cshow :: AuthRequired -> String
show :: AuthRequired -> String
$cshowList :: [AuthRequired] -> ShowS
showList :: [AuthRequired] -> ShowS
Show, AuthRequired -> AuthRequired -> Bool
(AuthRequired -> AuthRequired -> Bool)
-> (AuthRequired -> AuthRequired -> Bool) -> Eq AuthRequired
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthRequired -> AuthRequired -> Bool
== :: AuthRequired -> AuthRequired -> Bool
$c/= :: AuthRequired -> AuthRequired -> Bool
/= :: AuthRequired -> AuthRequired -> Bool
Eq, (forall x. AuthRequired -> Rep AuthRequired x)
-> (forall x. Rep AuthRequired x -> AuthRequired)
-> Generic AuthRequired
forall x. Rep AuthRequired x -> AuthRequired
forall x. AuthRequired -> Rep AuthRequired x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AuthRequired -> Rep AuthRequired x
from :: forall x. AuthRequired -> Rep AuthRequired x
$cto :: forall x. Rep AuthRequired x -> AuthRequired
to :: forall x. Rep AuthRequired x -> AuthRequired
Generic)

instance FromJSON AuthRequired

-- | Response data
-- Note: responseStatus is Int (not Word/JSUInt) because Chrome sends -1 for authRequired events
-- where the response hasn't been completed yet (deviation from spec which says js-uint)
data ResponseData = MkResponseData
  { ResponseData -> Text
responseUrl :: Text,
    ResponseData -> Text
responseProtocol :: Text,
    ResponseData -> Int
responseStatus :: Int,
    ResponseData -> Text
responseStatusText :: Text,
    ResponseData -> Bool
responseFromCache :: Bool,
    ResponseData -> [Header]
responseHeaders :: [Header],
    ResponseData -> Text
responseMimeType :: Text,
    ResponseData -> Word
responseBytesReceived :: Word,
    ResponseData -> Maybe Word
responseHeadersSize :: Maybe Word,
    ResponseData -> Maybe Word
responseBodySize :: Maybe Word,
    ResponseData -> ResponseContent
responseContent :: ResponseContent,
    ResponseData -> Maybe [AuthChallenge]
responseAuthChallenges :: Maybe [AuthChallenge]
  }
  deriving (Int -> ResponseData -> ShowS
[ResponseData] -> ShowS
ResponseData -> String
(Int -> ResponseData -> ShowS)
-> (ResponseData -> String)
-> ([ResponseData] -> ShowS)
-> Show ResponseData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResponseData -> ShowS
showsPrec :: Int -> ResponseData -> ShowS
$cshow :: ResponseData -> String
show :: ResponseData -> String
$cshowList :: [ResponseData] -> ShowS
showList :: [ResponseData] -> ShowS
Show, ResponseData -> ResponseData -> Bool
(ResponseData -> ResponseData -> Bool)
-> (ResponseData -> ResponseData -> Bool) -> Eq ResponseData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResponseData -> ResponseData -> Bool
== :: ResponseData -> ResponseData -> Bool
$c/= :: ResponseData -> ResponseData -> Bool
/= :: ResponseData -> ResponseData -> Bool
Eq, (forall x. ResponseData -> Rep ResponseData x)
-> (forall x. Rep ResponseData x -> ResponseData)
-> Generic ResponseData
forall x. Rep ResponseData x -> ResponseData
forall x. ResponseData -> Rep ResponseData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ResponseData -> Rep ResponseData x
from :: forall x. ResponseData -> Rep ResponseData x
$cto :: forall x. Rep ResponseData x -> ResponseData
to :: forall x. Rep ResponseData x -> ResponseData
Generic)

instance FromJSON ResponseData where
  parseJSON :: Value -> Parser ResponseData
  parseJSON :: Value -> Parser ResponseData
parseJSON = String
-> (Object -> Parser ResponseData) -> Value -> Parser ResponseData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ResponseData" ((Object -> Parser ResponseData) -> Value -> Parser ResponseData)
-> (Object -> Parser ResponseData) -> Value -> Parser ResponseData
forall a b. (a -> b) -> a -> b
$ \Object
obj -> do
    responseUrl <- Object
obj Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
    responseProtocol <- obj .: "protocol"
    responseStatus <- obj .: "status"
    responseStatusText <- obj .: "statusText"
    responseFromCache <- obj .: "fromCache"
    responseHeaders <- obj .: "headers"
    responseMimeType <- obj .: "mimeType"
    responseBytesReceived <- obj .: "bytesReceived"
    responseHeadersSize <- obj .:? "headersSize"
    responseBodySize <- obj .:? "bodySize"
    responseContent <- obj .: "content"
    responseAuthChallenges <- obj .:? "authChallenges"
    pure MkResponseData {..}

-- | Response content information
newtype ResponseContent = MkResponseContent
  { ResponseContent -> JSUInt
size :: JSUInt
  }
  deriving (Int -> ResponseContent -> ShowS
[ResponseContent] -> ShowS
ResponseContent -> String
(Int -> ResponseContent -> ShowS)
-> (ResponseContent -> String)
-> ([ResponseContent] -> ShowS)
-> Show ResponseContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResponseContent -> ShowS
showsPrec :: Int -> ResponseContent -> ShowS
$cshow :: ResponseContent -> String
show :: ResponseContent -> String
$cshowList :: [ResponseContent] -> ShowS
showList :: [ResponseContent] -> ShowS
Show, ResponseContent -> ResponseContent -> Bool
(ResponseContent -> ResponseContent -> Bool)
-> (ResponseContent -> ResponseContent -> Bool)
-> Eq ResponseContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResponseContent -> ResponseContent -> Bool
== :: ResponseContent -> ResponseContent -> Bool
$c/= :: ResponseContent -> ResponseContent -> Bool
/= :: ResponseContent -> ResponseContent -> Bool
Eq, (forall x. ResponseContent -> Rep ResponseContent x)
-> (forall x. Rep ResponseContent x -> ResponseContent)
-> Generic ResponseContent
forall x. Rep ResponseContent x -> ResponseContent
forall x. ResponseContent -> Rep ResponseContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ResponseContent -> Rep ResponseContent x
from :: forall x. ResponseContent -> Rep ResponseContent x
$cto :: forall x. Rep ResponseContent x -> ResponseContent
to :: forall x. Rep ResponseContent x -> ResponseContent
Generic)

instance FromJSON ResponseContent

data AuthChallenge = MkAuthChallenge
  { AuthChallenge -> Text
scheme :: Text,
    AuthChallenge -> Text
realm :: Text
  }
  deriving (Int -> AuthChallenge -> ShowS
[AuthChallenge] -> ShowS
AuthChallenge -> String
(Int -> AuthChallenge -> ShowS)
-> (AuthChallenge -> String)
-> ([AuthChallenge] -> ShowS)
-> Show AuthChallenge
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthChallenge -> ShowS
showsPrec :: Int -> AuthChallenge -> ShowS
$cshow :: AuthChallenge -> String
show :: AuthChallenge -> String
$cshowList :: [AuthChallenge] -> ShowS
showList :: [AuthChallenge] -> ShowS
Show, AuthChallenge -> AuthChallenge -> Bool
(AuthChallenge -> AuthChallenge -> Bool)
-> (AuthChallenge -> AuthChallenge -> Bool) -> Eq AuthChallenge
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthChallenge -> AuthChallenge -> Bool
== :: AuthChallenge -> AuthChallenge -> Bool
$c/= :: AuthChallenge -> AuthChallenge -> Bool
/= :: AuthChallenge -> AuthChallenge -> Bool
Eq, (forall x. AuthChallenge -> Rep AuthChallenge x)
-> (forall x. Rep AuthChallenge x -> AuthChallenge)
-> Generic AuthChallenge
forall x. Rep AuthChallenge x -> AuthChallenge
forall x. AuthChallenge -> Rep AuthChallenge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AuthChallenge -> Rep AuthChallenge x
from :: forall x. AuthChallenge -> Rep AuthChallenge x
$cto :: forall x. Rep AuthChallenge x -> AuthChallenge
to :: forall x. Rep AuthChallenge x -> AuthChallenge
Generic)

instance FromJSON AuthChallenge

-- | BeforeRequestSent parameters
data BeforeRequestSent = MkBeforeRequestSent
  { BeforeRequestSent -> BrowsingContext
context :: BrowsingContext,
    BeforeRequestSent -> Bool
isBlocked :: Bool,
    BeforeRequestSent -> Maybe Navigation
navigation :: Maybe Navigation,
    BeforeRequestSent -> JSUInt
redirectCount :: JSUInt,
    BeforeRequestSent -> RequestData
request :: RequestData,
    BeforeRequestSent -> JSUInt
timestamp :: JSUInt,
    BeforeRequestSent -> Maybe [Intercept]
intercepts :: Maybe [Intercept],
    BeforeRequestSent -> Maybe Initiator
beforeRequestInitiator :: Maybe Initiator
  }
  deriving (Int -> BeforeRequestSent -> ShowS
[BeforeRequestSent] -> ShowS
BeforeRequestSent -> String
(Int -> BeforeRequestSent -> ShowS)
-> (BeforeRequestSent -> String)
-> ([BeforeRequestSent] -> ShowS)
-> Show BeforeRequestSent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BeforeRequestSent -> ShowS
showsPrec :: Int -> BeforeRequestSent -> ShowS
$cshow :: BeforeRequestSent -> String
show :: BeforeRequestSent -> String
$cshowList :: [BeforeRequestSent] -> ShowS
showList :: [BeforeRequestSent] -> ShowS
Show, BeforeRequestSent -> BeforeRequestSent -> Bool
(BeforeRequestSent -> BeforeRequestSent -> Bool)
-> (BeforeRequestSent -> BeforeRequestSent -> Bool)
-> Eq BeforeRequestSent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BeforeRequestSent -> BeforeRequestSent -> Bool
== :: BeforeRequestSent -> BeforeRequestSent -> Bool
$c/= :: BeforeRequestSent -> BeforeRequestSent -> Bool
/= :: BeforeRequestSent -> BeforeRequestSent -> Bool
Eq, (forall x. BeforeRequestSent -> Rep BeforeRequestSent x)
-> (forall x. Rep BeforeRequestSent x -> BeforeRequestSent)
-> Generic BeforeRequestSent
forall x. Rep BeforeRequestSent x -> BeforeRequestSent
forall x. BeforeRequestSent -> Rep BeforeRequestSent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BeforeRequestSent -> Rep BeforeRequestSent x
from :: forall x. BeforeRequestSent -> Rep BeforeRequestSent x
$cto :: forall x. Rep BeforeRequestSent x -> BeforeRequestSent
to :: forall x. Rep BeforeRequestSent x -> BeforeRequestSent
Generic)

instance FromJSON BeforeRequestSent where
  parseJSON :: Value -> Parser BeforeRequestSent
  parseJSON :: Value -> Parser BeforeRequestSent
parseJSON = Value -> Parser BeforeRequestSent
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

data Initiator = MkInitiator
  { Initiator -> Maybe Word
initiatorColumnNumber :: Maybe Word,
    Initiator -> Maybe Word
initiatorLineNumber :: Maybe Word,
    Initiator -> Maybe Request
initiatorRequest :: Maybe Request,
    Initiator -> Maybe StackTrace
initiatorStackTrace :: Maybe StackTrace,
    Initiator -> Maybe InitiatorType
initiatorType :: Maybe InitiatorType
  }
  deriving (Int -> Initiator -> ShowS
[Initiator] -> ShowS
Initiator -> String
(Int -> Initiator -> ShowS)
-> (Initiator -> String)
-> ([Initiator] -> ShowS)
-> Show Initiator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Initiator -> ShowS
showsPrec :: Int -> Initiator -> ShowS
$cshow :: Initiator -> String
show :: Initiator -> String
$cshowList :: [Initiator] -> ShowS
showList :: [Initiator] -> ShowS
Show, Initiator -> Initiator -> Bool
(Initiator -> Initiator -> Bool)
-> (Initiator -> Initiator -> Bool) -> Eq Initiator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Initiator -> Initiator -> Bool
== :: Initiator -> Initiator -> Bool
$c/= :: Initiator -> Initiator -> Bool
/= :: Initiator -> Initiator -> Bool
Eq, (forall x. Initiator -> Rep Initiator x)
-> (forall x. Rep Initiator x -> Initiator) -> Generic Initiator
forall x. Rep Initiator x -> Initiator
forall x. Initiator -> Rep Initiator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Initiator -> Rep Initiator x
from :: forall x. Initiator -> Rep Initiator x
$cto :: forall x. Rep Initiator x -> Initiator
to :: forall x. Rep Initiator x -> Initiator
Generic)

instance FromJSON Initiator where
  parseJSON :: Value -> Parser Initiator
  parseJSON :: Value -> Parser Initiator
parseJSON = Value -> Parser Initiator
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

-- | Information about what initiated a request
data InitiatorType
  = Audio
  | Beacon
  | Body
  | CSSInitiatorType
  | EarlyHints
  | Embed
  | Fetch
  | Font
  | Frame
  | IFrame
  | Image
  | Img
  | Input
  | Link
  | ObjectElement
  | Ping
  | Script
  | Track
  | Video
  | XMLHttpRequest
  | Other
  deriving (Int -> InitiatorType -> ShowS
[InitiatorType] -> ShowS
InitiatorType -> String
(Int -> InitiatorType -> ShowS)
-> (InitiatorType -> String)
-> ([InitiatorType] -> ShowS)
-> Show InitiatorType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InitiatorType -> ShowS
showsPrec :: Int -> InitiatorType -> ShowS
$cshow :: InitiatorType -> String
show :: InitiatorType -> String
$cshowList :: [InitiatorType] -> ShowS
showList :: [InitiatorType] -> ShowS
Show, InitiatorType -> InitiatorType -> Bool
(InitiatorType -> InitiatorType -> Bool)
-> (InitiatorType -> InitiatorType -> Bool) -> Eq InitiatorType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InitiatorType -> InitiatorType -> Bool
== :: InitiatorType -> InitiatorType -> Bool
$c/= :: InitiatorType -> InitiatorType -> Bool
/= :: InitiatorType -> InitiatorType -> Bool
Eq, (forall x. InitiatorType -> Rep InitiatorType x)
-> (forall x. Rep InitiatorType x -> InitiatorType)
-> Generic InitiatorType
forall x. Rep InitiatorType x -> InitiatorType
forall x. InitiatorType -> Rep InitiatorType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InitiatorType -> Rep InitiatorType x
from :: forall x. InitiatorType -> Rep InitiatorType x
$cto :: forall x. Rep InitiatorType x -> InitiatorType
to :: forall x. Rep InitiatorType x -> InitiatorType
Generic)

instance FromJSON InitiatorType where
  parseJSON :: Value -> Parser InitiatorType
  parseJSON :: Value -> Parser InitiatorType
parseJSON = String
-> (Text -> Parser InitiatorType) -> Value -> Parser InitiatorType
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"InitiatorType" ((Text -> Parser InitiatorType) -> Value -> Parser InitiatorType)
-> (Text -> Parser InitiatorType) -> Value -> Parser InitiatorType
forall a b. (a -> b) -> a -> b
$ \Text
t ->
    case Text -> Text
toLower Text
t of
      Text
"audio" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Audio
      Text
"beacon" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Beacon
      Text
"body" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Body
      Text
"css" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
CSSInitiatorType
      Text
"early-hints" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
EarlyHints
      Text
"embed" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Embed
      Text
"fetch" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Fetch
      Text
"font" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Font
      Text
"frame" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Frame
      Text
"iframe" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
IFrame
      Text
"image" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Image
      Text
"img" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Img
      Text
"input" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Input
      Text
"link" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Link
      Text
"object" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
ObjectElement
      Text
"ping" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Ping
      Text
"script" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Script
      Text
"track" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Track
      Text
"video" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Video
      Text
"xmlhttprequest" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
XMLHttpRequest
      Text
"other" -> InitiatorType -> Parser InitiatorType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InitiatorType
Other
      Text
_ -> String -> Parser InitiatorType
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser InitiatorType) -> String -> Parser InitiatorType
forall a b. (a -> b) -> a -> b
$ String
"Unknown InitiatorType: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
forall a. Show a => a -> String
show Text
t

-- | FetchError parameters
data FetchError = MkFetchError
  { FetchError -> BrowsingContext
context :: BrowsingContext,
    FetchError -> Bool
isBlocked :: Bool,
    FetchError -> Maybe Navigation
navigation :: Maybe Navigation,
    FetchError -> JSUInt
redirectCount :: JSUInt,
    FetchError -> RequestData
request :: RequestData,
    FetchError -> JSUInt
timestamp :: JSUInt,
    FetchError -> Maybe [Intercept]
intercepts :: Maybe [Intercept],
    FetchError -> Text
errorText :: Text
  }
  deriving (Int -> FetchError -> ShowS
[FetchError] -> ShowS
FetchError -> String
(Int -> FetchError -> ShowS)
-> (FetchError -> String)
-> ([FetchError] -> ShowS)
-> Show FetchError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FetchError -> ShowS
showsPrec :: Int -> FetchError -> ShowS
$cshow :: FetchError -> String
show :: FetchError -> String
$cshowList :: [FetchError] -> ShowS
showList :: [FetchError] -> ShowS
Show, FetchError -> FetchError -> Bool
(FetchError -> FetchError -> Bool)
-> (FetchError -> FetchError -> Bool) -> Eq FetchError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FetchError -> FetchError -> Bool
== :: FetchError -> FetchError -> Bool
$c/= :: FetchError -> FetchError -> Bool
/= :: FetchError -> FetchError -> Bool
Eq, (forall x. FetchError -> Rep FetchError x)
-> (forall x. Rep FetchError x -> FetchError) -> Generic FetchError
forall x. Rep FetchError x -> FetchError
forall x. FetchError -> Rep FetchError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FetchError -> Rep FetchError x
from :: forall x. FetchError -> Rep FetchError x
$cto :: forall x. Rep FetchError x -> FetchError
to :: forall x. Rep FetchError x -> FetchError
Generic)

instance FromJSON FetchError where
  parseJSON :: Value -> Parser FetchError
  parseJSON :: Value -> Parser FetchError
parseJSON = Value -> Parser FetchError
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

-- | ResponseCompleted parameters
data ResponseCompleted = MkResponseCompleted
  { ResponseCompleted -> BrowsingContext
context :: BrowsingContext,
    ResponseCompleted -> Bool
isBlocked :: Bool,
    ResponseCompleted -> Maybe Navigation
navigation :: Maybe Navigation,
    ResponseCompleted -> JSUInt
redirectCount :: JSUInt,
    ResponseCompleted -> RequestData
request :: RequestData,
    ResponseCompleted -> JSUInt
timestamp :: JSUInt,
    ResponseCompleted -> Maybe [Intercept]
intercepts :: Maybe [Intercept],
    ResponseCompleted -> ResponseData
response :: ResponseData
  }
  deriving (Int -> ResponseCompleted -> ShowS
[ResponseCompleted] -> ShowS
ResponseCompleted -> String
(Int -> ResponseCompleted -> ShowS)
-> (ResponseCompleted -> String)
-> ([ResponseCompleted] -> ShowS)
-> Show ResponseCompleted
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResponseCompleted -> ShowS
showsPrec :: Int -> ResponseCompleted -> ShowS
$cshow :: ResponseCompleted -> String
show :: ResponseCompleted -> String
$cshowList :: [ResponseCompleted] -> ShowS
showList :: [ResponseCompleted] -> ShowS
Show, ResponseCompleted -> ResponseCompleted -> Bool
(ResponseCompleted -> ResponseCompleted -> Bool)
-> (ResponseCompleted -> ResponseCompleted -> Bool)
-> Eq ResponseCompleted
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResponseCompleted -> ResponseCompleted -> Bool
== :: ResponseCompleted -> ResponseCompleted -> Bool
$c/= :: ResponseCompleted -> ResponseCompleted -> Bool
/= :: ResponseCompleted -> ResponseCompleted -> Bool
Eq, (forall x. ResponseCompleted -> Rep ResponseCompleted x)
-> (forall x. Rep ResponseCompleted x -> ResponseCompleted)
-> Generic ResponseCompleted
forall x. Rep ResponseCompleted x -> ResponseCompleted
forall x. ResponseCompleted -> Rep ResponseCompleted x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ResponseCompleted -> Rep ResponseCompleted x
from :: forall x. ResponseCompleted -> Rep ResponseCompleted x
$cto :: forall x. Rep ResponseCompleted x -> ResponseCompleted
to :: forall x. Rep ResponseCompleted x -> ResponseCompleted
Generic)

instance FromJSON ResponseCompleted where
  parseJSON :: Value -> Parser ResponseCompleted
  parseJSON :: Value -> Parser ResponseCompleted
parseJSON = Value -> Parser ResponseCompleted
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

-- | ResponseStarted parameters
data ResponseStarted = MkResponseStarted
  { ResponseStarted -> BrowsingContext
context :: BrowsingContext,
    ResponseStarted -> Bool
isBlocked :: Bool,
    ResponseStarted -> Maybe Navigation
navigation :: Maybe Navigation,
    ResponseStarted -> JSUInt
redirectCount :: JSUInt,
    ResponseStarted -> RequestData
request :: RequestData,
    ResponseStarted -> JSUInt
timestamp :: JSUInt,
    ResponseStarted -> Maybe [Intercept]
intercepts :: Maybe [Intercept],
    ResponseStarted -> ResponseData
response :: ResponseData
  }
  deriving (Int -> ResponseStarted -> ShowS
[ResponseStarted] -> ShowS
ResponseStarted -> String
(Int -> ResponseStarted -> ShowS)
-> (ResponseStarted -> String)
-> ([ResponseStarted] -> ShowS)
-> Show ResponseStarted
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResponseStarted -> ShowS
showsPrec :: Int -> ResponseStarted -> ShowS
$cshow :: ResponseStarted -> String
show :: ResponseStarted -> String
$cshowList :: [ResponseStarted] -> ShowS
showList :: [ResponseStarted] -> ShowS
Show, ResponseStarted -> ResponseStarted -> Bool
(ResponseStarted -> ResponseStarted -> Bool)
-> (ResponseStarted -> ResponseStarted -> Bool)
-> Eq ResponseStarted
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResponseStarted -> ResponseStarted -> Bool
== :: ResponseStarted -> ResponseStarted -> Bool
$c/= :: ResponseStarted -> ResponseStarted -> Bool
/= :: ResponseStarted -> ResponseStarted -> Bool
Eq, (forall x. ResponseStarted -> Rep ResponseStarted x)
-> (forall x. Rep ResponseStarted x -> ResponseStarted)
-> Generic ResponseStarted
forall x. Rep ResponseStarted x -> ResponseStarted
forall x. ResponseStarted -> Rep ResponseStarted x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ResponseStarted -> Rep ResponseStarted x
from :: forall x. ResponseStarted -> Rep ResponseStarted x
$cto :: forall x. Rep ResponseStarted x -> ResponseStarted
to :: forall x. Rep ResponseStarted x -> ResponseStarted
Generic)

instance FromJSON ResponseStarted where
  parseJSON :: Value -> Parser ResponseStarted
  parseJSON :: Value -> Parser ResponseStarted
parseJSON = Value -> Parser ResponseStarted
forall a. (Generic a, GFromJSON Zero (Rep a)) => Value -> Parser a
parseJSONOmitNothing

newtype GetDataResult = MkGetDataResult
  { GetDataResult -> BytesValue
bytes :: BytesValue
  }
  deriving (Int -> GetDataResult -> ShowS
[GetDataResult] -> ShowS
GetDataResult -> String
(Int -> GetDataResult -> ShowS)
-> (GetDataResult -> String)
-> ([GetDataResult] -> ShowS)
-> Show GetDataResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetDataResult -> ShowS
showsPrec :: Int -> GetDataResult -> ShowS
$cshow :: GetDataResult -> String
show :: GetDataResult -> String
$cshowList :: [GetDataResult] -> ShowS
showList :: [GetDataResult] -> ShowS
Show, GetDataResult -> GetDataResult -> Bool
(GetDataResult -> GetDataResult -> Bool)
-> (GetDataResult -> GetDataResult -> Bool) -> Eq GetDataResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetDataResult -> GetDataResult -> Bool
== :: GetDataResult -> GetDataResult -> Bool
$c/= :: GetDataResult -> GetDataResult -> Bool
/= :: GetDataResult -> GetDataResult -> Bool
Eq, (forall x. GetDataResult -> Rep GetDataResult x)
-> (forall x. Rep GetDataResult x -> GetDataResult)
-> Generic GetDataResult
forall x. Rep GetDataResult x -> GetDataResult
forall x. GetDataResult -> Rep GetDataResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GetDataResult -> Rep GetDataResult x
from :: forall x. GetDataResult -> Rep GetDataResult x
$cto :: forall x. Rep GetDataResult x -> GetDataResult
to :: forall x. Rep GetDataResult x -> GetDataResult
Generic)

instance FromJSON GetDataResult

newtype AddDataCollectorResult = MkAddDataCollectorResult
  { AddDataCollectorResult -> Collector
collector :: Collector
  }
  deriving (Int -> AddDataCollectorResult -> ShowS
[AddDataCollectorResult] -> ShowS
AddDataCollectorResult -> String
(Int -> AddDataCollectorResult -> ShowS)
-> (AddDataCollectorResult -> String)
-> ([AddDataCollectorResult] -> ShowS)
-> Show AddDataCollectorResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddDataCollectorResult -> ShowS
showsPrec :: Int -> AddDataCollectorResult -> ShowS
$cshow :: AddDataCollectorResult -> String
show :: AddDataCollectorResult -> String
$cshowList :: [AddDataCollectorResult] -> ShowS
showList :: [AddDataCollectorResult] -> ShowS
Show, AddDataCollectorResult -> AddDataCollectorResult -> Bool
(AddDataCollectorResult -> AddDataCollectorResult -> Bool)
-> (AddDataCollectorResult -> AddDataCollectorResult -> Bool)
-> Eq AddDataCollectorResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddDataCollectorResult -> AddDataCollectorResult -> Bool
== :: AddDataCollectorResult -> AddDataCollectorResult -> Bool
$c/= :: AddDataCollectorResult -> AddDataCollectorResult -> Bool
/= :: AddDataCollectorResult -> AddDataCollectorResult -> Bool
Eq, (forall x. AddDataCollectorResult -> Rep AddDataCollectorResult x)
-> (forall x.
    Rep AddDataCollectorResult x -> AddDataCollectorResult)
-> Generic AddDataCollectorResult
forall x. Rep AddDataCollectorResult x -> AddDataCollectorResult
forall x. AddDataCollectorResult -> Rep AddDataCollectorResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. AddDataCollectorResult -> Rep AddDataCollectorResult x
from :: forall x. AddDataCollectorResult -> Rep AddDataCollectorResult x
$cto :: forall x. Rep AddDataCollectorResult x -> AddDataCollectorResult
to :: forall x. Rep AddDataCollectorResult x -> AddDataCollectorResult
Generic)

instance FromJSON AddDataCollectorResult