{-# LANGUAGE DeriveAnyClass #-}
module Hasura.Backends.DataConnector.Adapter.Types
( ConnSourceConfig (..),
SourceConfig (..),
DataConnectorName (..),
DataConnectorOptions (..),
CountType (..),
SourceTimeout (),
sourceTimeoutMicroseconds,
)
where
import Autodocodec (HasCodec (codec), named)
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey, genericParseJSON, genericToJSON)
import Data.Aeson qualified as J
import Data.Aeson.KeyMap qualified as J
import Data.Text.Extended (ToTxt)
import Data.Text.NonEmpty (NonEmptyText)
import Hasura.Backends.DataConnector.API qualified as API
import Hasura.Backends.DataConnector.IR.Column qualified as IR.C
import Hasura.Incremental (Cacheable (..))
import Hasura.Metadata.DTO.Placeholder (placeholderCodecViaJSON)
import Hasura.Prelude
import Network.HTTP.Client qualified as HTTP
import Servant.Client (BaseUrl)
import Witch qualified
data ConnSourceConfig = ConnSourceConfig
{
ConnSourceConfig -> Config
value :: API.Config,
ConnSourceConfig -> Maybe Text
template :: Maybe Text,
ConnSourceConfig -> Maybe SourceTimeout
timeout :: Maybe SourceTimeout
}
deriving stock (ConnSourceConfig -> ConnSourceConfig -> Bool
(ConnSourceConfig -> ConnSourceConfig -> Bool)
-> (ConnSourceConfig -> ConnSourceConfig -> Bool)
-> Eq ConnSourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c/= :: ConnSourceConfig -> ConnSourceConfig -> Bool
== :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c== :: ConnSourceConfig -> ConnSourceConfig -> Bool
Eq, Eq ConnSourceConfig
Eq ConnSourceConfig
-> (ConnSourceConfig -> ConnSourceConfig -> Ordering)
-> (ConnSourceConfig -> ConnSourceConfig -> Bool)
-> (ConnSourceConfig -> ConnSourceConfig -> Bool)
-> (ConnSourceConfig -> ConnSourceConfig -> Bool)
-> (ConnSourceConfig -> ConnSourceConfig -> Bool)
-> (ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig)
-> (ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig)
-> Ord ConnSourceConfig
ConnSourceConfig -> ConnSourceConfig -> Bool
ConnSourceConfig -> ConnSourceConfig -> Ordering
ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
$cmin :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
max :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
$cmax :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
>= :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c>= :: ConnSourceConfig -> ConnSourceConfig -> Bool
> :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c> :: ConnSourceConfig -> ConnSourceConfig -> Bool
<= :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c<= :: ConnSourceConfig -> ConnSourceConfig -> Bool
< :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c< :: ConnSourceConfig -> ConnSourceConfig -> Bool
compare :: ConnSourceConfig -> ConnSourceConfig -> Ordering
$ccompare :: ConnSourceConfig -> ConnSourceConfig -> Ordering
$cp1Ord :: Eq ConnSourceConfig
Ord, Int -> ConnSourceConfig -> ShowS
[ConnSourceConfig] -> ShowS
ConnSourceConfig -> String
(Int -> ConnSourceConfig -> ShowS)
-> (ConnSourceConfig -> String)
-> ([ConnSourceConfig] -> ShowS)
-> Show ConnSourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnSourceConfig] -> ShowS
$cshowList :: [ConnSourceConfig] -> ShowS
show :: ConnSourceConfig -> String
$cshow :: ConnSourceConfig -> String
showsPrec :: Int -> ConnSourceConfig -> ShowS
$cshowsPrec :: Int -> ConnSourceConfig -> ShowS
Show, (forall x. ConnSourceConfig -> Rep ConnSourceConfig x)
-> (forall x. Rep ConnSourceConfig x -> ConnSourceConfig)
-> Generic ConnSourceConfig
forall x. Rep ConnSourceConfig x -> ConnSourceConfig
forall x. ConnSourceConfig -> Rep ConnSourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnSourceConfig x -> ConnSourceConfig
$cfrom :: forall x. ConnSourceConfig -> Rep ConnSourceConfig x
Generic)
deriving anyclass (Int -> ConnSourceConfig -> Int
ConnSourceConfig -> Int
(Int -> ConnSourceConfig -> Int)
-> (ConnSourceConfig -> Int) -> Hashable ConnSourceConfig
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ConnSourceConfig -> Int
$chash :: ConnSourceConfig -> Int
hashWithSalt :: Int -> ConnSourceConfig -> Int
$chashWithSalt :: Int -> ConnSourceConfig -> Int
Hashable, ConnSourceConfig -> ()
(ConnSourceConfig -> ()) -> NFData ConnSourceConfig
forall a. (a -> ()) -> NFData a
rnf :: ConnSourceConfig -> ()
$crnf :: ConnSourceConfig -> ()
NFData, [ConnSourceConfig] -> Value
[ConnSourceConfig] -> Encoding
ConnSourceConfig -> Value
ConnSourceConfig -> Encoding
(ConnSourceConfig -> Value)
-> (ConnSourceConfig -> Encoding)
-> ([ConnSourceConfig] -> Value)
-> ([ConnSourceConfig] -> Encoding)
-> ToJSON ConnSourceConfig
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ConnSourceConfig] -> Encoding
$ctoEncodingList :: [ConnSourceConfig] -> Encoding
toJSONList :: [ConnSourceConfig] -> Value
$ctoJSONList :: [ConnSourceConfig] -> Value
toEncoding :: ConnSourceConfig -> Encoding
$ctoEncoding :: ConnSourceConfig -> Encoding
toJSON :: ConnSourceConfig -> Value
$ctoJSON :: ConnSourceConfig -> Value
ToJSON)
instance FromJSON ConnSourceConfig where
parseJSON :: Value -> Parser ConnSourceConfig
parseJSON = String
-> (Object -> Parser ConnSourceConfig)
-> Value
-> Parser ConnSourceConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
J.withObject String
"ConnSourceConfig" \Object
o ->
case Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
J.lookup Key
"value" Object
o of
Just Value
_ -> Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig
ConnSourceConfig (Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
-> Parser Config
-> Parser (Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Config
forall a. FromJSON a => Object -> Key -> Parser a
J..: Key
"value" Parser (Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
-> Parser (Maybe Text)
-> Parser (Maybe SourceTimeout -> ConnSourceConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
J..:? Key
"template" Parser (Maybe SourceTimeout -> ConnSourceConfig)
-> Parser (Maybe SourceTimeout) -> Parser ConnSourceConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Object
o Object -> Key -> Parser (Maybe SourceTimeout)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
J..:? Key
"timeout")
Maybe Value
Nothing -> Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig
ConnSourceConfig (Object -> Config
API.Config Object
o) Maybe Text
forall a. Maybe a
Nothing (Maybe SourceTimeout -> ConnSourceConfig)
-> Parser (Maybe SourceTimeout) -> Parser ConnSourceConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Object
o Object -> Key -> Parser (Maybe SourceTimeout)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
J..:? Key
"timeout")
instance HasCodec ConnSourceConfig where
codec :: JSONCodec ConnSourceConfig
codec = Text -> JSONCodec ConnSourceConfig -> JSONCodec ConnSourceConfig
forall input output.
Text -> ValueCodec input output -> ValueCodec input output
named Text
"DataConnectorConnConfiguration" (JSONCodec ConnSourceConfig -> JSONCodec ConnSourceConfig)
-> JSONCodec ConnSourceConfig -> JSONCodec ConnSourceConfig
forall a b. (a -> b) -> a -> b
$ JSONCodec ConnSourceConfig
forall a. (FromJSON a, ToJSON a) => JSONCodec a
placeholderCodecViaJSON
instance Cacheable ConnSourceConfig where
unchanged :: Accesses -> ConnSourceConfig -> ConnSourceConfig -> Bool
unchanged Accesses
_ = ConnSourceConfig -> ConnSourceConfig -> Bool
forall a. Eq a => a -> a -> Bool
(==)
data SourceTimeout
= SourceTimeoutSeconds Int
| SourceTimeoutMilliseconds Int
| SourceTimeoutMicroseconds Int
deriving stock (SourceTimeout -> SourceTimeout -> Bool
(SourceTimeout -> SourceTimeout -> Bool)
-> (SourceTimeout -> SourceTimeout -> Bool) -> Eq SourceTimeout
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceTimeout -> SourceTimeout -> Bool
$c/= :: SourceTimeout -> SourceTimeout -> Bool
== :: SourceTimeout -> SourceTimeout -> Bool
$c== :: SourceTimeout -> SourceTimeout -> Bool
Eq, Eq SourceTimeout
Eq SourceTimeout
-> (SourceTimeout -> SourceTimeout -> Ordering)
-> (SourceTimeout -> SourceTimeout -> Bool)
-> (SourceTimeout -> SourceTimeout -> Bool)
-> (SourceTimeout -> SourceTimeout -> Bool)
-> (SourceTimeout -> SourceTimeout -> Bool)
-> (SourceTimeout -> SourceTimeout -> SourceTimeout)
-> (SourceTimeout -> SourceTimeout -> SourceTimeout)
-> Ord SourceTimeout
SourceTimeout -> SourceTimeout -> Bool
SourceTimeout -> SourceTimeout -> Ordering
SourceTimeout -> SourceTimeout -> SourceTimeout
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SourceTimeout -> SourceTimeout -> SourceTimeout
$cmin :: SourceTimeout -> SourceTimeout -> SourceTimeout
max :: SourceTimeout -> SourceTimeout -> SourceTimeout
$cmax :: SourceTimeout -> SourceTimeout -> SourceTimeout
>= :: SourceTimeout -> SourceTimeout -> Bool
$c>= :: SourceTimeout -> SourceTimeout -> Bool
> :: SourceTimeout -> SourceTimeout -> Bool
$c> :: SourceTimeout -> SourceTimeout -> Bool
<= :: SourceTimeout -> SourceTimeout -> Bool
$c<= :: SourceTimeout -> SourceTimeout -> Bool
< :: SourceTimeout -> SourceTimeout -> Bool
$c< :: SourceTimeout -> SourceTimeout -> Bool
compare :: SourceTimeout -> SourceTimeout -> Ordering
$ccompare :: SourceTimeout -> SourceTimeout -> Ordering
$cp1Ord :: Eq SourceTimeout
Ord, Int -> SourceTimeout -> ShowS
[SourceTimeout] -> ShowS
SourceTimeout -> String
(Int -> SourceTimeout -> ShowS)
-> (SourceTimeout -> String)
-> ([SourceTimeout] -> ShowS)
-> Show SourceTimeout
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceTimeout] -> ShowS
$cshowList :: [SourceTimeout] -> ShowS
show :: SourceTimeout -> String
$cshow :: SourceTimeout -> String
showsPrec :: Int -> SourceTimeout -> ShowS
$cshowsPrec :: Int -> SourceTimeout -> ShowS
Show, (forall x. SourceTimeout -> Rep SourceTimeout x)
-> (forall x. Rep SourceTimeout x -> SourceTimeout)
-> Generic SourceTimeout
forall x. Rep SourceTimeout x -> SourceTimeout
forall x. SourceTimeout -> Rep SourceTimeout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceTimeout x -> SourceTimeout
$cfrom :: forall x. SourceTimeout -> Rep SourceTimeout x
Generic)
deriving anyclass (Int -> SourceTimeout -> Int
SourceTimeout -> Int
(Int -> SourceTimeout -> Int)
-> (SourceTimeout -> Int) -> Hashable SourceTimeout
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: SourceTimeout -> Int
$chash :: SourceTimeout -> Int
hashWithSalt :: Int -> SourceTimeout -> Int
$chashWithSalt :: Int -> SourceTimeout -> Int
Hashable, SourceTimeout -> ()
(SourceTimeout -> ()) -> NFData SourceTimeout
forall a. (a -> ()) -> NFData a
rnf :: SourceTimeout -> ()
$crnf :: SourceTimeout -> ()
NFData)
sourceTimeoutMicroseconds :: SourceTimeout -> Int
sourceTimeoutMicroseconds :: SourceTimeout -> Int
sourceTimeoutMicroseconds = \case
SourceTimeoutSeconds Int
s -> Int
s Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
1000000
SourceTimeoutMilliseconds Int
m -> Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
1000
SourceTimeoutMicroseconds Int
u -> Int
u
instance FromJSON SourceTimeout where
parseJSON :: Value -> Parser SourceTimeout
parseJSON = String
-> (Object -> Parser SourceTimeout)
-> Value
-> Parser SourceTimeout
forall a. String -> (Object -> Parser a) -> Value -> Parser a
J.withObject String
"SourceTimeout" \Object
o ->
case Object -> [(Key, Value)]
forall v. KeyMap v -> [(Key, v)]
J.toList Object
o of
[(Key
"seconds", Value
n)] -> Value -> String -> (Int -> SourceTimeout) -> Parser SourceTimeout
forall t a. Integral t => Value -> String -> (t -> a) -> Parser a
convertTimeout Value
n String
"seconds" Int -> SourceTimeout
SourceTimeoutSeconds
[(Key
"milliseconds", Value
n)] -> Value -> String -> (Int -> SourceTimeout) -> Parser SourceTimeout
forall t a. Integral t => Value -> String -> (t -> a) -> Parser a
convertTimeout Value
n String
"milliseconds" Int -> SourceTimeout
SourceTimeoutMilliseconds
[(Key
"microseconds", Value
n)] -> Value -> String -> (Int -> SourceTimeout) -> Parser SourceTimeout
forall t a. Integral t => Value -> String -> (t -> a) -> Parser a
convertTimeout Value
n String
"microseconds" Int -> SourceTimeout
SourceTimeoutMicroseconds
[(Key, Value)]
_ -> String -> Parser SourceTimeout
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Invalid SourceTimeout. Formats include: {seconds: Int}, {milliseconds: Int}, {microseconds: Int}"
where
convertTimeout :: Value -> String -> (t -> a) -> Parser a
convertTimeout Value
n String
l t -> a
m = String -> (Scientific -> Parser a) -> Value -> Parser a
forall a. String -> (Scientific -> Parser a) -> Value -> Parser a
J.withScientific String
l (\Scientific
s -> a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (a -> Parser a) -> a -> Parser a
forall a b. (a -> b) -> a -> b
$ t -> a
m (Scientific -> t
forall a b. (RealFrac a, Integral b) => a -> b
round Scientific
s)) Value
n
instance ToJSON SourceTimeout where
toJSON :: SourceTimeout -> Value
toJSON (SourceTimeoutSeconds Int
t) = [(Key, Value)] -> Value
J.object [Key
"seconds" Key -> Int -> (Key, Value)
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
J..= Int
t]
toJSON (SourceTimeoutMilliseconds Int
t) = [(Key, Value)] -> Value
J.object [Key
"milliseconds" Key -> Int -> (Key, Value)
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
J..= Int
t]
toJSON (SourceTimeoutMicroseconds Int
t) = [(Key, Value)] -> Value
J.object [Key
"microseconds" Key -> Int -> (Key, Value)
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
J..= Int
t]
data SourceConfig = SourceConfig
{ SourceConfig -> BaseUrl
_scEndpoint :: BaseUrl,
SourceConfig -> Config
_scConfig :: API.Config,
SourceConfig -> Maybe Text
_scTemplate :: Maybe Text,
SourceConfig -> Capabilities
_scCapabilities :: API.Capabilities,
SourceConfig -> SchemaResponse
_scSchema :: API.SchemaResponse,
SourceConfig -> Manager
_scManager :: HTTP.Manager,
SourceConfig -> Maybe Int
_scTimeoutMicroseconds :: Maybe Int,
SourceConfig -> DataConnectorName
_scDataConnectorName :: DataConnectorName
}
instance Eq SourceConfig where
SourceConfig BaseUrl
ep1 Config
capabilities1 Maybe Text
config1 Capabilities
template1 SchemaResponse
schema1 Manager
_ Maybe Int
timeout1 DataConnectorName
dcName1 == :: SourceConfig -> SourceConfig -> Bool
== SourceConfig BaseUrl
ep2 Config
capabilities2 Maybe Text
config2 Capabilities
template2 SchemaResponse
schema2 Manager
_ Maybe Int
timeout2 DataConnectorName
dcName2 =
BaseUrl
ep1 BaseUrl -> BaseUrl -> Bool
forall a. Eq a => a -> a -> Bool
== BaseUrl
ep2
Bool -> Bool -> Bool
&& Config
capabilities1 Config -> Config -> Bool
forall a. Eq a => a -> a -> Bool
== Config
capabilities2
Bool -> Bool -> Bool
&& Maybe Text
config1 Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe Text
config2
Bool -> Bool -> Bool
&& Capabilities
template1 Capabilities -> Capabilities -> Bool
forall a. Eq a => a -> a -> Bool
== Capabilities
template2
Bool -> Bool -> Bool
&& SchemaResponse
schema1 SchemaResponse -> SchemaResponse -> Bool
forall a. Eq a => a -> a -> Bool
== SchemaResponse
schema2
Bool -> Bool -> Bool
&& Maybe Int
timeout1 Maybe Int -> Maybe Int -> Bool
forall a. Eq a => a -> a -> Bool
== Maybe Int
timeout2
Bool -> Bool -> Bool
&& DataConnectorName
dcName1 DataConnectorName -> DataConnectorName -> Bool
forall a. Eq a => a -> a -> Bool
== DataConnectorName
dcName2
instance Show SourceConfig where
show :: SourceConfig -> String
show SourceConfig
_ = String
"SourceConfig"
instance J.ToJSON SourceConfig where
toJSON :: SourceConfig -> Value
toJSON SourceConfig
_ = Text -> Value
J.String Text
"SourceConfig"
instance Cacheable SourceConfig where
unchanged :: Accesses -> SourceConfig -> SourceConfig -> Bool
unchanged Accesses
_ = SourceConfig -> SourceConfig -> Bool
forall a. Eq a => a -> a -> Bool
(==)
newtype DataConnectorName = DataConnectorName {DataConnectorName -> NonEmptyText
unDataConnectorName :: NonEmptyText}
deriving stock (DataConnectorName -> DataConnectorName -> Bool
(DataConnectorName -> DataConnectorName -> Bool)
-> (DataConnectorName -> DataConnectorName -> Bool)
-> Eq DataConnectorName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataConnectorName -> DataConnectorName -> Bool
$c/= :: DataConnectorName -> DataConnectorName -> Bool
== :: DataConnectorName -> DataConnectorName -> Bool
$c== :: DataConnectorName -> DataConnectorName -> Bool
Eq, Eq DataConnectorName
Eq DataConnectorName
-> (DataConnectorName -> DataConnectorName -> Ordering)
-> (DataConnectorName -> DataConnectorName -> Bool)
-> (DataConnectorName -> DataConnectorName -> Bool)
-> (DataConnectorName -> DataConnectorName -> Bool)
-> (DataConnectorName -> DataConnectorName -> Bool)
-> (DataConnectorName -> DataConnectorName -> DataConnectorName)
-> (DataConnectorName -> DataConnectorName -> DataConnectorName)
-> Ord DataConnectorName
DataConnectorName -> DataConnectorName -> Bool
DataConnectorName -> DataConnectorName -> Ordering
DataConnectorName -> DataConnectorName -> DataConnectorName
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DataConnectorName -> DataConnectorName -> DataConnectorName
$cmin :: DataConnectorName -> DataConnectorName -> DataConnectorName
max :: DataConnectorName -> DataConnectorName -> DataConnectorName
$cmax :: DataConnectorName -> DataConnectorName -> DataConnectorName
>= :: DataConnectorName -> DataConnectorName -> Bool
$c>= :: DataConnectorName -> DataConnectorName -> Bool
> :: DataConnectorName -> DataConnectorName -> Bool
$c> :: DataConnectorName -> DataConnectorName -> Bool
<= :: DataConnectorName -> DataConnectorName -> Bool
$c<= :: DataConnectorName -> DataConnectorName -> Bool
< :: DataConnectorName -> DataConnectorName -> Bool
$c< :: DataConnectorName -> DataConnectorName -> Bool
compare :: DataConnectorName -> DataConnectorName -> Ordering
$ccompare :: DataConnectorName -> DataConnectorName -> Ordering
$cp1Ord :: Eq DataConnectorName
Ord, Int -> DataConnectorName -> ShowS
[DataConnectorName] -> ShowS
DataConnectorName -> String
(Int -> DataConnectorName -> ShowS)
-> (DataConnectorName -> String)
-> ([DataConnectorName] -> ShowS)
-> Show DataConnectorName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataConnectorName] -> ShowS
$cshowList :: [DataConnectorName] -> ShowS
show :: DataConnectorName -> String
$cshow :: DataConnectorName -> String
showsPrec :: Int -> DataConnectorName -> ShowS
$cshowsPrec :: Int -> DataConnectorName -> ShowS
Show, (forall x. DataConnectorName -> Rep DataConnectorName x)
-> (forall x. Rep DataConnectorName x -> DataConnectorName)
-> Generic DataConnectorName
forall x. Rep DataConnectorName x -> DataConnectorName
forall x. DataConnectorName -> Rep DataConnectorName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataConnectorName x -> DataConnectorName
$cfrom :: forall x. DataConnectorName -> Rep DataConnectorName x
Generic)
deriving newtype (Value -> Parser [DataConnectorName]
Value -> Parser DataConnectorName
(Value -> Parser DataConnectorName)
-> (Value -> Parser [DataConnectorName])
-> FromJSON DataConnectorName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DataConnectorName]
$cparseJSONList :: Value -> Parser [DataConnectorName]
parseJSON :: Value -> Parser DataConnectorName
$cparseJSON :: Value -> Parser DataConnectorName
FromJSON, [DataConnectorName] -> Value
[DataConnectorName] -> Encoding
DataConnectorName -> Value
DataConnectorName -> Encoding
(DataConnectorName -> Value)
-> (DataConnectorName -> Encoding)
-> ([DataConnectorName] -> Value)
-> ([DataConnectorName] -> Encoding)
-> ToJSON DataConnectorName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [DataConnectorName] -> Encoding
$ctoEncodingList :: [DataConnectorName] -> Encoding
toJSONList :: [DataConnectorName] -> Value
$ctoJSONList :: [DataConnectorName] -> Value
toEncoding :: DataConnectorName -> Encoding
$ctoEncoding :: DataConnectorName -> Encoding
toJSON :: DataConnectorName -> Value
$ctoJSON :: DataConnectorName -> Value
ToJSON, FromJSONKeyFunction [DataConnectorName]
FromJSONKeyFunction DataConnectorName
FromJSONKeyFunction DataConnectorName
-> FromJSONKeyFunction [DataConnectorName]
-> FromJSONKey DataConnectorName
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
fromJSONKeyList :: FromJSONKeyFunction [DataConnectorName]
$cfromJSONKeyList :: FromJSONKeyFunction [DataConnectorName]
fromJSONKey :: FromJSONKeyFunction DataConnectorName
$cfromJSONKey :: FromJSONKeyFunction DataConnectorName
FromJSONKey, ToJSONKeyFunction [DataConnectorName]
ToJSONKeyFunction DataConnectorName
ToJSONKeyFunction DataConnectorName
-> ToJSONKeyFunction [DataConnectorName]
-> ToJSONKey DataConnectorName
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
toJSONKeyList :: ToJSONKeyFunction [DataConnectorName]
$ctoJSONKeyList :: ToJSONKeyFunction [DataConnectorName]
toJSONKey :: ToJSONKeyFunction DataConnectorName
$ctoJSONKey :: ToJSONKeyFunction DataConnectorName
ToJSONKey, Int -> DataConnectorName -> Int
DataConnectorName -> Int
(Int -> DataConnectorName -> Int)
-> (DataConnectorName -> Int) -> Hashable DataConnectorName
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: DataConnectorName -> Int
$chash :: DataConnectorName -> Int
hashWithSalt :: Int -> DataConnectorName -> Int
$chashWithSalt :: Int -> DataConnectorName -> Int
Hashable, DataConnectorName -> Text
(DataConnectorName -> Text) -> ToTxt DataConnectorName
forall a. (a -> Text) -> ToTxt a
toTxt :: DataConnectorName -> Text
$ctoTxt :: DataConnectorName -> Text
ToTxt)
deriving anyclass (Eq DataConnectorName
Eq DataConnectorName
-> (Accesses -> DataConnectorName -> DataConnectorName -> Bool)
-> Cacheable DataConnectorName
Accesses -> DataConnectorName -> DataConnectorName -> Bool
forall a. Eq a -> (Accesses -> a -> a -> Bool) -> Cacheable a
unchanged :: Accesses -> DataConnectorName -> DataConnectorName -> Bool
$cunchanged :: Accesses -> DataConnectorName -> DataConnectorName -> Bool
$cp1Cacheable :: Eq DataConnectorName
Cacheable, DataConnectorName -> ()
(DataConnectorName -> ()) -> NFData DataConnectorName
forall a. (a -> ()) -> NFData a
rnf :: DataConnectorName -> ()
$crnf :: DataConnectorName -> ()
NFData)
instance Witch.From DataConnectorName NonEmptyText
data DataConnectorOptions = DataConnectorOptions
{DataConnectorOptions -> BaseUrl
_dcoUri :: BaseUrl}
deriving stock (DataConnectorOptions -> DataConnectorOptions -> Bool
(DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> Eq DataConnectorOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c/= :: DataConnectorOptions -> DataConnectorOptions -> Bool
== :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c== :: DataConnectorOptions -> DataConnectorOptions -> Bool
Eq, Eq DataConnectorOptions
Eq DataConnectorOptions
-> (DataConnectorOptions -> DataConnectorOptions -> Ordering)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions)
-> (DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions)
-> Ord DataConnectorOptions
DataConnectorOptions -> DataConnectorOptions -> Bool
DataConnectorOptions -> DataConnectorOptions -> Ordering
DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
$cmin :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
max :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
$cmax :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
>= :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c>= :: DataConnectorOptions -> DataConnectorOptions -> Bool
> :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c> :: DataConnectorOptions -> DataConnectorOptions -> Bool
<= :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c<= :: DataConnectorOptions -> DataConnectorOptions -> Bool
< :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c< :: DataConnectorOptions -> DataConnectorOptions -> Bool
compare :: DataConnectorOptions -> DataConnectorOptions -> Ordering
$ccompare :: DataConnectorOptions -> DataConnectorOptions -> Ordering
$cp1Ord :: Eq DataConnectorOptions
Ord, Int -> DataConnectorOptions -> ShowS
[DataConnectorOptions] -> ShowS
DataConnectorOptions -> String
(Int -> DataConnectorOptions -> ShowS)
-> (DataConnectorOptions -> String)
-> ([DataConnectorOptions] -> ShowS)
-> Show DataConnectorOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataConnectorOptions] -> ShowS
$cshowList :: [DataConnectorOptions] -> ShowS
show :: DataConnectorOptions -> String
$cshow :: DataConnectorOptions -> String
showsPrec :: Int -> DataConnectorOptions -> ShowS
$cshowsPrec :: Int -> DataConnectorOptions -> ShowS
Show, (forall x. DataConnectorOptions -> Rep DataConnectorOptions x)
-> (forall x. Rep DataConnectorOptions x -> DataConnectorOptions)
-> Generic DataConnectorOptions
forall x. Rep DataConnectorOptions x -> DataConnectorOptions
forall x. DataConnectorOptions -> Rep DataConnectorOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataConnectorOptions x -> DataConnectorOptions
$cfrom :: forall x. DataConnectorOptions -> Rep DataConnectorOptions x
Generic)
deriving anyclass (Eq DataConnectorOptions
Eq DataConnectorOptions
-> (Accesses
-> DataConnectorOptions -> DataConnectorOptions -> Bool)
-> Cacheable DataConnectorOptions
Accesses -> DataConnectorOptions -> DataConnectorOptions -> Bool
forall a. Eq a -> (Accesses -> a -> a -> Bool) -> Cacheable a
unchanged :: Accesses -> DataConnectorOptions -> DataConnectorOptions -> Bool
$cunchanged :: Accesses -> DataConnectorOptions -> DataConnectorOptions -> Bool
$cp1Cacheable :: Eq DataConnectorOptions
Cacheable)
instance FromJSON DataConnectorOptions where
parseJSON :: Value -> Parser DataConnectorOptions
parseJSON = Options -> Value -> Parser DataConnectorOptions
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON Options
hasuraJSON
instance ToJSON DataConnectorOptions where
toJSON :: DataConnectorOptions -> Value
toJSON = Options -> DataConnectorOptions -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
hasuraJSON
data CountType
= StarCount
| ColumnCount (NonEmpty IR.C.Name)
| ColumnDistinctCount (NonEmpty IR.C.Name)
deriving (CountType -> CountType -> Bool
(CountType -> CountType -> Bool)
-> (CountType -> CountType -> Bool) -> Eq CountType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CountType -> CountType -> Bool
$c/= :: CountType -> CountType -> Bool
== :: CountType -> CountType -> Bool
$c== :: CountType -> CountType -> Bool
Eq, Eq CountType
Eq CountType
-> (CountType -> CountType -> Ordering)
-> (CountType -> CountType -> Bool)
-> (CountType -> CountType -> Bool)
-> (CountType -> CountType -> Bool)
-> (CountType -> CountType -> Bool)
-> (CountType -> CountType -> CountType)
-> (CountType -> CountType -> CountType)
-> Ord CountType
CountType -> CountType -> Bool
CountType -> CountType -> Ordering
CountType -> CountType -> CountType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CountType -> CountType -> CountType
$cmin :: CountType -> CountType -> CountType
max :: CountType -> CountType -> CountType
$cmax :: CountType -> CountType -> CountType
>= :: CountType -> CountType -> Bool
$c>= :: CountType -> CountType -> Bool
> :: CountType -> CountType -> Bool
$c> :: CountType -> CountType -> Bool
<= :: CountType -> CountType -> Bool
$c<= :: CountType -> CountType -> Bool
< :: CountType -> CountType -> Bool
$c< :: CountType -> CountType -> Bool
compare :: CountType -> CountType -> Ordering
$ccompare :: CountType -> CountType -> Ordering
$cp1Ord :: Eq CountType
Ord, Int -> CountType -> ShowS
[CountType] -> ShowS
CountType -> String
(Int -> CountType -> ShowS)
-> (CountType -> String)
-> ([CountType] -> ShowS)
-> Show CountType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CountType] -> ShowS
$cshowList :: [CountType] -> ShowS
show :: CountType -> String
$cshow :: CountType -> String
showsPrec :: Int -> CountType -> ShowS
$cshowsPrec :: Int -> CountType -> ShowS
Show, (forall x. CountType -> Rep CountType x)
-> (forall x. Rep CountType x -> CountType) -> Generic CountType
forall x. Rep CountType x -> CountType
forall x. CountType -> Rep CountType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CountType x -> CountType
$cfrom :: forall x. CountType -> Rep CountType x
Generic, Typeable CountType
DataType
Constr
Typeable CountType
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CountType -> c CountType)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CountType)
-> (CountType -> Constr)
-> (CountType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CountType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CountType))
-> ((forall b. Data b => b -> b) -> CountType -> CountType)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r)
-> (forall u. (forall d. Data d => d -> u) -> CountType -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> CountType -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType)
-> Data CountType
CountType -> DataType
CountType -> Constr
(forall b. Data b => b -> b) -> CountType -> CountType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CountType -> c CountType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CountType
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> CountType -> u
forall u. (forall d. Data d => d -> u) -> CountType -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CountType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CountType -> c CountType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CountType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CountType)
$cColumnDistinctCount :: Constr
$cColumnCount :: Constr
$cStarCount :: Constr
$tCountType :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> CountType -> m CountType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType
gmapMp :: (forall d. Data d => d -> m d) -> CountType -> m CountType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType
gmapM :: (forall d. Data d => d -> m d) -> CountType -> m CountType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> CountType -> m CountType
gmapQi :: Int -> (forall d. Data d => d -> u) -> CountType -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> CountType -> u
gmapQ :: (forall d. Data d => d -> u) -> CountType -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> CountType -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CountType -> r
gmapT :: (forall b. Data b => b -> b) -> CountType -> CountType
$cgmapT :: (forall b. Data b => b -> b) -> CountType -> CountType
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CountType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CountType)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CountType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CountType)
dataTypeOf :: CountType -> DataType
$cdataTypeOf :: CountType -> DataType
toConstr :: CountType -> Constr
$ctoConstr :: CountType -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CountType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CountType
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CountType -> c CountType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> CountType -> c CountType
$cp1Data :: Typeable CountType
Data)