{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}

module Hasura.Backends.DataConnector.Adapter.Types
  ( ConnSourceConfig (..),
    SourceTimeout (),
    sourceTimeoutMicroseconds,
    SourceConfig (..),
    scCapabilities,
    scConfig,
    scDataConnectorName,
    scEndpoint,
    scManager,
    scTemplate,
    scTimeoutMicroseconds,
    scEnvironment,
    DataConnectorOptions (..),
    DataConnectorInfo (..),
    TableName (..),
    ConstraintName (..),
    ColumnName (..),
    FunctionName (..),
    FunctionReturnType (..),
    CountAggregate (..),
    Literal (..),
    OrderDirection (..),
    API.GraphQLType (..),
    ScalarType (..),
    ArgumentExp (..),
    fromGQLType,
    ExtraTableMetadata (..),
    ExtraColumnMetadata (..),
    module Hasura.RQL.Types.DataConnector,
  )
where

import Autodocodec (HasCodec (codec), optionalField', requiredField', requiredFieldWith')
import Autodocodec qualified as AC
import Autodocodec.Extended (baseUrlCodec)
import Control.Lens (makeLenses)
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey, genericParseJSON, genericToJSON)
import Data.Aeson qualified as J
import Data.Aeson.KeyMap qualified as J
import Data.Aeson.Types (parseEither, toJSONKeyText)
import Data.Environment (Environment)
import Data.Has
import Data.HashMap.Strict qualified as HashMap
import Data.List.NonEmpty qualified as NonEmpty
import Data.OpenApi (ToSchema)
import Data.Text qualified as Text
import Data.Text.Extended (ToTxt (..))
import Hasura.Backends.DataConnector.API qualified as API
import Hasura.Base.ErrorValue qualified as ErrorValue
import Hasura.Base.ToErrorValue (ToErrorValue (..))
import Hasura.Prelude
import Hasura.RQL.IR.BoolExp qualified as IR
import Hasura.RQL.Types.Backend (Backend)
import Hasura.RQL.Types.BackendType (BackendType (..))
import Hasura.RQL.Types.DataConnector
import Language.GraphQL.Draft.Syntax qualified as GQL
import Network.HTTP.Client qualified as HTTP
import Servant.Client (BaseUrl)
import Witch qualified

--------------------------------------------------------------------------------

data ConnSourceConfig = ConnSourceConfig
  { -- | An arbitrary JSON payload to be passed to the agent in a
    -- header. HGE validates this against the OpenAPI Spec provided by
    -- the agent.
    ConnSourceConfig -> Config
value :: API.Config,
    -- | Kriti Template for transforming the supplied 'API.Config' value.
    ConnSourceConfig -> Maybe Text
template :: Maybe Text,
    -- | Timeout setting for HTTP requests to the agent. -- TODO: verify with lyndon
    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
$c== :: ConnSourceConfig -> ConnSourceConfig -> Bool
== :: ConnSourceConfig -> ConnSourceConfig -> Bool
$c/= :: ConnSourceConfig -> ConnSourceConfig -> Bool
/= :: 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
$ccompare :: ConnSourceConfig -> ConnSourceConfig -> Ordering
compare :: ConnSourceConfig -> ConnSourceConfig -> Ordering
$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
>= :: ConnSourceConfig -> ConnSourceConfig -> Bool
$cmax :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
max :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
$cmin :: ConnSourceConfig -> ConnSourceConfig -> ConnSourceConfig
min :: ConnSourceConfig -> ConnSourceConfig -> 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
$cshowsPrec :: Int -> ConnSourceConfig -> ShowS
showsPrec :: Int -> ConnSourceConfig -> ShowS
$cshow :: ConnSourceConfig -> String
show :: ConnSourceConfig -> String
$cshowList :: [ConnSourceConfig] -> ShowS
showList :: [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
$cfrom :: forall x. ConnSourceConfig -> Rep ConnSourceConfig x
from :: forall x. ConnSourceConfig -> Rep ConnSourceConfig x
$cto :: forall x. Rep ConnSourceConfig x -> ConnSourceConfig
to :: forall x. Rep ConnSourceConfig x -> ConnSourceConfig
Generic)
  deriving anyclass (Eq ConnSourceConfig
Eq ConnSourceConfig
-> (Int -> ConnSourceConfig -> Int)
-> (ConnSourceConfig -> Int)
-> Hashable ConnSourceConfig
Int -> ConnSourceConfig -> Int
ConnSourceConfig -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ConnSourceConfig -> Int
hashWithSalt :: Int -> ConnSourceConfig -> Int
$chash :: ConnSourceConfig -> Int
hash :: ConnSourceConfig -> Int
Hashable, ConnSourceConfig -> ()
(ConnSourceConfig -> ()) -> NFData ConnSourceConfig
forall a. (a -> ()) -> NFData a
$crnf :: ConnSourceConfig -> ()
rnf :: 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
$ctoJSON :: ConnSourceConfig -> Value
toJSON :: ConnSourceConfig -> Value
$ctoEncoding :: ConnSourceConfig -> Encoding
toEncoding :: ConnSourceConfig -> Encoding
$ctoJSONList :: [ConnSourceConfig] -> Value
toJSONList :: [ConnSourceConfig] -> Value
$ctoEncodingList :: [ConnSourceConfig] -> Encoding
toEncodingList :: [ConnSourceConfig] -> Encoding
ToJSON)

-- Default to the old style of ConnSourceConfig if a "value" field isn't present.
-- This will prevent existing configurations from breaking.
-- NOTE: This is planned to be deprecated in future once tooling is migrated.
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 a b. Parser (a -> b) -> Parser a -> Parser b
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 a b. Parser (a -> b) -> Parser a -> Parser b
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 = (Either ConnSourceConfig Config -> Either String ConnSourceConfig)
-> (ConnSourceConfig -> Either ConnSourceConfig Config)
-> Codec
     Value
     (Either ConnSourceConfig Config)
     (Either ConnSourceConfig Config)
-> JSONCodec ConnSourceConfig
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> Either String newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.bimapCodec Either ConnSourceConfig Config -> Either String ConnSourceConfig
dec ConnSourceConfig -> Either ConnSourceConfig Config
forall {a} {b}. a -> Either a b
enc (Codec
   Value
   (Either ConnSourceConfig Config)
   (Either ConnSourceConfig Config)
 -> JSONCodec ConnSourceConfig)
-> Codec
     Value
     (Either ConnSourceConfig Config)
     (Either ConnSourceConfig Config)
-> JSONCodec ConnSourceConfig
forall a b. (a -> b) -> a -> b
$ JSONCodec ConnSourceConfig
-> Codec Value Config Config
-> Codec
     Value
     (Either ConnSourceConfig Config)
     (Either ConnSourceConfig Config)
forall context input1 output1 input2 output2.
Codec context input1 output1
-> Codec context input2 output2
-> Codec context (Either input1 input2) (Either output1 output2)
AC.possiblyJointEitherCodec JSONCodec ConnSourceConfig
withValueProp Codec Value Config Config
inlineConfig
    where
      withValueProp :: JSONCodec ConnSourceConfig
withValueProp =
        Text
-> ObjectCodec ConnSourceConfig ConnSourceConfig
-> JSONCodec ConnSourceConfig
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"DataConnectorConnSourceConfig"
          (ObjectCodec ConnSourceConfig ConnSourceConfig
 -> JSONCodec ConnSourceConfig)
-> ObjectCodec ConnSourceConfig ConnSourceConfig
-> JSONCodec ConnSourceConfig
forall a b. (a -> b) -> a -> b
$ Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig
ConnSourceConfig
          (Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
-> Codec Object ConnSourceConfig Config
-> Codec
     Object
     ConnSourceConfig
     (Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ObjectCodec Config Config
forall output. HasCodec output => Text -> ObjectCodec output output
requiredField' Text
"value"
          ObjectCodec Config Config
-> (ConnSourceConfig -> Config)
-> Codec Object ConnSourceConfig Config
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ConnSourceConfig -> Config
value
            Codec
  Object
  ConnSourceConfig
  (Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig)
-> Codec Object ConnSourceConfig (Maybe Text)
-> Codec
     Object ConnSourceConfig (Maybe SourceTimeout -> ConnSourceConfig)
forall a b.
Codec Object ConnSourceConfig (a -> b)
-> Codec Object ConnSourceConfig a
-> Codec Object ConnSourceConfig b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> ObjectCodec (Maybe Text) (Maybe Text)
forall output.
HasCodec output =>
Text -> ObjectCodec (Maybe output) (Maybe output)
optionalField' Text
"template"
          ObjectCodec (Maybe Text) (Maybe Text)
-> (ConnSourceConfig -> Maybe Text)
-> Codec Object ConnSourceConfig (Maybe Text)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ConnSourceConfig -> Maybe Text
template
            Codec
  Object ConnSourceConfig (Maybe SourceTimeout -> ConnSourceConfig)
-> Codec Object ConnSourceConfig (Maybe SourceTimeout)
-> ObjectCodec ConnSourceConfig ConnSourceConfig
forall a b.
Codec Object ConnSourceConfig (a -> b)
-> Codec Object ConnSourceConfig a
-> Codec Object ConnSourceConfig b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> ObjectCodec (Maybe SourceTimeout) (Maybe SourceTimeout)
forall output.
HasCodec output =>
Text -> ObjectCodec (Maybe output) (Maybe output)
optionalField' Text
"timeout"
          ObjectCodec (Maybe SourceTimeout) (Maybe SourceTimeout)
-> (ConnSourceConfig -> Maybe SourceTimeout)
-> Codec Object ConnSourceConfig (Maybe SourceTimeout)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ConnSourceConfig -> Maybe SourceTimeout
timeout
      inlineConfig :: Codec Value Config Config
inlineConfig = forall value. HasCodec value => JSONCodec value
codec @API.Config

      dec :: Either ConnSourceConfig Config -> Either String ConnSourceConfig
dec (Left ConnSourceConfig
config) = ConnSourceConfig -> Either String ConnSourceConfig
forall a b. b -> Either a b
Right ConnSourceConfig
config
      dec (Right config :: Config
config@(API.Config Object
jsonObj)) =
        (Object -> Parser ConnSourceConfig)
-> Object -> Either String ConnSourceConfig
forall a b. (a -> Parser b) -> a -> Either String b
parseEither (\Object
o -> Config -> Maybe Text -> Maybe SourceTimeout -> ConnSourceConfig
ConnSourceConfig Config
config 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")) Object
jsonObj

      enc :: a -> Either a b
enc = a -> Either a b
forall {a} {b}. a -> Either a b
Left

--------------------------------------------------------------------------------

-- NOTE: There may be a time type with units datatype already available somewhere
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
$c== :: SourceTimeout -> SourceTimeout -> Bool
== :: SourceTimeout -> SourceTimeout -> Bool
$c/= :: SourceTimeout -> SourceTimeout -> Bool
/= :: 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
$ccompare :: SourceTimeout -> SourceTimeout -> Ordering
compare :: SourceTimeout -> SourceTimeout -> Ordering
$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
>= :: SourceTimeout -> SourceTimeout -> Bool
$cmax :: SourceTimeout -> SourceTimeout -> SourceTimeout
max :: SourceTimeout -> SourceTimeout -> SourceTimeout
$cmin :: SourceTimeout -> SourceTimeout -> SourceTimeout
min :: SourceTimeout -> SourceTimeout -> 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
$cshowsPrec :: Int -> SourceTimeout -> ShowS
showsPrec :: Int -> SourceTimeout -> ShowS
$cshow :: SourceTimeout -> String
show :: SourceTimeout -> String
$cshowList :: [SourceTimeout] -> ShowS
showList :: [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
$cfrom :: forall x. SourceTimeout -> Rep SourceTimeout x
from :: forall x. SourceTimeout -> Rep SourceTimeout x
$cto :: forall x. Rep SourceTimeout x -> SourceTimeout
to :: forall x. Rep SourceTimeout x -> SourceTimeout
Generic)
  deriving anyclass (Eq SourceTimeout
Eq SourceTimeout
-> (Int -> SourceTimeout -> Int)
-> (SourceTimeout -> Int)
-> Hashable SourceTimeout
Int -> SourceTimeout -> Int
SourceTimeout -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> SourceTimeout -> Int
hashWithSalt :: Int -> SourceTimeout -> Int
$chash :: SourceTimeout -> Int
hash :: SourceTimeout -> Int
Hashable, SourceTimeout -> ()
(SourceTimeout -> ()) -> NFData SourceTimeout
forall a. (a -> ()) -> NFData a
$crnf :: SourceTimeout -> ()
rnf :: 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 HasCodec SourceTimeout where
  codec :: JSONCodec SourceTimeout
codec =
    (Either Scientific (Either Scientific Scientific) -> SourceTimeout)
-> (SourceTimeout
    -> Either Scientific (Either Scientific Scientific))
-> Codec
     Value
     (Either Scientific (Either Scientific Scientific))
     (Either Scientific (Either Scientific Scientific))
-> JSONCodec SourceTimeout
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.dimapCodec Either Scientific (Either Scientific Scientific) -> SourceTimeout
forall {a} {a} {a}.
(RealFrac a, RealFrac a, RealFrac a) =>
Either a (Either a a) -> SourceTimeout
dec SourceTimeout -> Either Scientific (Either Scientific Scientific)
forall {a} {a} {b}.
(Num a, Num a, Num b) =>
SourceTimeout -> Either a (Either a b)
enc
      (Codec
   Value
   (Either Scientific (Either Scientific Scientific))
   (Either Scientific (Either Scientific Scientific))
 -> JSONCodec SourceTimeout)
-> Codec
     Value
     (Either Scientific (Either Scientific Scientific))
     (Either Scientific (Either Scientific Scientific))
-> JSONCodec SourceTimeout
forall a b. (a -> b) -> a -> b
$ Codec Value Scientific Scientific
-> Codec
     Value (Either Scientific Scientific) (Either Scientific Scientific)
-> Codec
     Value
     (Either Scientific (Either Scientific Scientific))
     (Either Scientific (Either Scientific Scientific))
forall context input1 output1 input2 output2.
Codec context input1 output1
-> Codec context input2 output2
-> Codec context (Either input1 input2) (Either output1 output2)
AC.disjointEitherCodec Codec Value Scientific Scientific
secondsCodec
      (Codec
   Value (Either Scientific Scientific) (Either Scientific Scientific)
 -> Codec
      Value
      (Either Scientific (Either Scientific Scientific))
      (Either Scientific (Either Scientific Scientific)))
-> Codec
     Value (Either Scientific Scientific) (Either Scientific Scientific)
-> Codec
     Value
     (Either Scientific (Either Scientific Scientific))
     (Either Scientific (Either Scientific Scientific))
forall a b. (a -> b) -> a -> b
$ Codec Value Scientific Scientific
-> Codec Value Scientific Scientific
-> Codec
     Value (Either Scientific Scientific) (Either Scientific Scientific)
forall context input1 output1 input2 output2.
Codec context input1 output1
-> Codec context input2 output2
-> Codec context (Either input1 input2) (Either output1 output2)
AC.disjointEitherCodec Codec Value Scientific Scientific
millisecondsCodec Codec Value Scientific Scientific
microsecondsCodec
    where
      secondsCodec :: Codec Value Scientific Scientific
secondsCodec = Text
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"DataConnectorSourceTimeoutSeconds" (ObjectCodec Scientific Scientific
 -> Codec Value Scientific Scientific)
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall a b. (a -> b) -> a -> b
$ Text
-> Codec Value Scientific Scientific
-> ObjectCodec Scientific Scientific
forall input output.
Text -> ValueCodec input output -> ObjectCodec input output
requiredFieldWith' Text
"seconds" Codec Value Scientific Scientific
AC.scientificCodec
      millisecondsCodec :: Codec Value Scientific Scientific
millisecondsCodec = Text
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"DataConnectorSourceTimeoutMilliseconds" (ObjectCodec Scientific Scientific
 -> Codec Value Scientific Scientific)
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall a b. (a -> b) -> a -> b
$ Text
-> Codec Value Scientific Scientific
-> ObjectCodec Scientific Scientific
forall input output.
Text -> ValueCodec input output -> ObjectCodec input output
requiredFieldWith' Text
"milliseconds" Codec Value Scientific Scientific
AC.scientificCodec
      microsecondsCodec :: Codec Value Scientific Scientific
microsecondsCodec = Text
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"DataConnectorSourceTimeoutMicroseconds" (ObjectCodec Scientific Scientific
 -> Codec Value Scientific Scientific)
-> ObjectCodec Scientific Scientific
-> Codec Value Scientific Scientific
forall a b. (a -> b) -> a -> b
$ Text
-> Codec Value Scientific Scientific
-> ObjectCodec Scientific Scientific
forall input output.
Text -> ValueCodec input output -> ObjectCodec input output
requiredFieldWith' Text
"microseconds" Codec Value Scientific Scientific
AC.scientificCodec

      dec :: Either a (Either a a) -> SourceTimeout
dec (Left a
n) = Int -> SourceTimeout
SourceTimeoutSeconds (Int -> SourceTimeout) -> Int -> SourceTimeout
forall a b. (a -> b) -> a -> b
$ a -> Int
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
round a
n
      dec (Right (Left a
n)) = Int -> SourceTimeout
SourceTimeoutMilliseconds (Int -> SourceTimeout) -> Int -> SourceTimeout
forall a b. (a -> b) -> a -> b
$ a -> Int
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
round a
n
      dec (Right (Right a
n)) = Int -> SourceTimeout
SourceTimeoutMicroseconds (Int -> SourceTimeout) -> Int -> SourceTimeout
forall a b. (a -> b) -> a -> b
$ a -> Int
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
round a
n

      enc :: SourceTimeout -> Either a (Either a b)
enc (SourceTimeoutSeconds Int
n) = a -> Either a (Either a b)
forall {a} {b}. a -> Either a b
Left (a -> Either a (Either a b)) -> a -> Either a (Either a b)
forall a b. (a -> b) -> a -> b
$ Int -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n
      enc (SourceTimeoutMilliseconds Int
n) = Either a b -> Either a (Either a b)
forall a b. b -> Either a b
Right (Either a b -> Either a (Either a b))
-> Either a b -> Either a (Either a b)
forall a b. (a -> b) -> a -> b
$ a -> Either a b
forall {a} {b}. a -> Either a b
Left (a -> Either a b) -> a -> Either a b
forall a b. (a -> b) -> a -> b
$ Int -> a
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n
      enc (SourceTimeoutMicroseconds Int
n) = Either a b -> Either a (Either a b)
forall a b. b -> Either a b
Right (Either a b -> Either a (Either a b))
-> Either a b -> Either a (Either a b)
forall a b. (a -> b) -> a -> b
$ b -> Either a b
forall a b. b -> Either a b
Right (b -> Either a b) -> b -> Either a b
forall a b. (a -> b) -> a -> b
$ Int -> b
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
n

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 -> [Pair]
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
      [Pair]
_ -> String -> Parser SourceTimeout
forall a. String -> Parser a
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 a. 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 b. Integral b => Scientific -> b
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) = [Pair] -> Value
J.object [Key
"seconds" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
J..= Int
t]
  toJSON (SourceTimeoutMilliseconds Int
t) = [Pair] -> Value
J.object [Key
"milliseconds" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
J..= Int
t]
  toJSON (SourceTimeoutMicroseconds Int
t) = [Pair] -> Value
J.object [Key
"microseconds" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
J..= Int
t]

--------------------------------------------------------------------------------

data SourceConfig = SourceConfig
  { SourceConfig -> BaseUrl
_scEndpoint :: BaseUrl,
    SourceConfig -> Config
_scConfig :: API.Config,
    SourceConfig -> Maybe Text
_scTemplate :: Maybe Text, -- TODO: Use Parsed Kriti Template, specify template language
    SourceConfig -> Capabilities
_scCapabilities :: API.Capabilities,
    SourceConfig -> Manager
_scManager :: HTTP.Manager,
    SourceConfig -> Maybe Int
_scTimeoutMicroseconds :: Maybe Int,
    SourceConfig -> DataConnectorName
_scDataConnectorName :: DataConnectorName,
    SourceConfig -> Environment
_scEnvironment :: Environment
  }

instance Eq SourceConfig where
  SourceConfig BaseUrl
ep1 Config
capabilities1 Maybe Text
config1 Capabilities
template1 Manager
_ Maybe Int
timeout1 DataConnectorName
dcName1 Environment
env1 == :: SourceConfig -> SourceConfig -> Bool
== SourceConfig BaseUrl
ep2 Config
capabilities2 Maybe Text
config2 Capabilities
template2 Manager
_ Maybe Int
timeout2 DataConnectorName
dcName2 Environment
env2 =
    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
&& 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
      Bool -> Bool -> Bool
&& Environment
env1
      Environment -> Environment -> Bool
forall a. Eq a => a -> a -> Bool
== Environment
env2

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"

--------------------------------------------------------------------------------

-- | This represents what information can be known about the return type of a user-defined function.
--   For now, either the return type will be the name of a table that exists in the schema,
--   or "Unknown" - implying that this information can be derived from another source,
--   or if there is no other source, then it is an error.
--   In future, this type may be extended with additional constructors including scalar and row types
--   from the Logical Models feature.
--
--   Note: This is very similar to ComputedFieldReturnType defined above.
--         The two types may be unified in future.
data FunctionReturnType
  = FunctionReturnsTable TableName
  | FunctionReturnsUnknown
  deriving (Int -> FunctionReturnType -> ShowS
[FunctionReturnType] -> ShowS
FunctionReturnType -> String
(Int -> FunctionReturnType -> ShowS)
-> (FunctionReturnType -> String)
-> ([FunctionReturnType] -> ShowS)
-> Show FunctionReturnType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FunctionReturnType -> ShowS
showsPrec :: Int -> FunctionReturnType -> ShowS
$cshow :: FunctionReturnType -> String
show :: FunctionReturnType -> String
$cshowList :: [FunctionReturnType] -> ShowS
showList :: [FunctionReturnType] -> ShowS
Show, FunctionReturnType -> FunctionReturnType -> Bool
(FunctionReturnType -> FunctionReturnType -> Bool)
-> (FunctionReturnType -> FunctionReturnType -> Bool)
-> Eq FunctionReturnType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FunctionReturnType -> FunctionReturnType -> Bool
== :: FunctionReturnType -> FunctionReturnType -> Bool
$c/= :: FunctionReturnType -> FunctionReturnType -> Bool
/= :: FunctionReturnType -> FunctionReturnType -> Bool
Eq, FunctionReturnType -> ()
(FunctionReturnType -> ()) -> NFData FunctionReturnType
forall a. (a -> ()) -> NFData a
$crnf :: FunctionReturnType -> ()
rnf :: FunctionReturnType -> ()
NFData, Eq FunctionReturnType
Eq FunctionReturnType
-> (Int -> FunctionReturnType -> Int)
-> (FunctionReturnType -> Int)
-> Hashable FunctionReturnType
Int -> FunctionReturnType -> Int
FunctionReturnType -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FunctionReturnType -> Int
hashWithSalt :: Int -> FunctionReturnType -> Int
$chash :: FunctionReturnType -> Int
hash :: FunctionReturnType -> Int
Hashable, (forall x. FunctionReturnType -> Rep FunctionReturnType x)
-> (forall x. Rep FunctionReturnType x -> FunctionReturnType)
-> Generic FunctionReturnType
forall x. Rep FunctionReturnType x -> FunctionReturnType
forall x. FunctionReturnType -> Rep FunctionReturnType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FunctionReturnType -> Rep FunctionReturnType x
from :: forall x. FunctionReturnType -> Rep FunctionReturnType x
$cto :: forall x. Rep FunctionReturnType x -> FunctionReturnType
to :: forall x. Rep FunctionReturnType x -> FunctionReturnType
Generic)
  deriving (Typeable FunctionReturnType
Typeable FunctionReturnType
-> (Proxy FunctionReturnType
    -> Declare (Definitions Schema) NamedSchema)
-> ToSchema FunctionReturnType
Proxy FunctionReturnType
-> Declare (Definitions Schema) NamedSchema
forall a.
Typeable a
-> (Proxy a -> Declare (Definitions Schema) NamedSchema)
-> ToSchema a
$cdeclareNamedSchema :: Proxy FunctionReturnType
-> Declare (Definitions Schema) NamedSchema
declareNamedSchema :: Proxy FunctionReturnType
-> Declare (Definitions Schema) NamedSchema
ToSchema, [FunctionReturnType] -> Value
[FunctionReturnType] -> Encoding
FunctionReturnType -> Value
FunctionReturnType -> Encoding
(FunctionReturnType -> Value)
-> (FunctionReturnType -> Encoding)
-> ([FunctionReturnType] -> Value)
-> ([FunctionReturnType] -> Encoding)
-> ToJSON FunctionReturnType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: FunctionReturnType -> Value
toJSON :: FunctionReturnType -> Value
$ctoEncoding :: FunctionReturnType -> Encoding
toEncoding :: FunctionReturnType -> Encoding
$ctoJSONList :: [FunctionReturnType] -> Value
toJSONList :: [FunctionReturnType] -> Value
$ctoEncodingList :: [FunctionReturnType] -> Encoding
toEncodingList :: [FunctionReturnType] -> Encoding
ToJSON, Value -> Parser [FunctionReturnType]
Value -> Parser FunctionReturnType
(Value -> Parser FunctionReturnType)
-> (Value -> Parser [FunctionReturnType])
-> FromJSON FunctionReturnType
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser FunctionReturnType
parseJSON :: Value -> Parser FunctionReturnType
$cparseJSONList :: Value -> Parser [FunctionReturnType]
parseJSONList :: Value -> Parser [FunctionReturnType]
FromJSON) via AC.Autodocodec FunctionReturnType

instance AC.HasCodec FunctionReturnType where
  codec :: JSONCodec FunctionReturnType
codec =
    Text
-> JSONCodec FunctionReturnType -> JSONCodec FunctionReturnType
forall input output.
Text -> ValueCodec input output -> ValueCodec input output
AC.named Text
"FunctionReturnType"
      (JSONCodec FunctionReturnType -> JSONCodec FunctionReturnType)
-> JSONCodec FunctionReturnType -> JSONCodec FunctionReturnType
forall a b. (a -> b) -> a -> b
$ Text
-> ObjectCodec FunctionReturnType FunctionReturnType
-> JSONCodec FunctionReturnType
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"FunctionReturnType"
      (ObjectCodec FunctionReturnType FunctionReturnType
 -> JSONCodec FunctionReturnType)
-> ObjectCodec FunctionReturnType FunctionReturnType
-> JSONCodec FunctionReturnType
forall a b. (a -> b) -> a -> b
$ Text
-> (FunctionReturnType
    -> (Text, ObjectCodec FunctionReturnType ()))
-> HashMap Text (Text, ObjectCodec Void FunctionReturnType)
-> ObjectCodec FunctionReturnType FunctionReturnType
forall input output.
Text
-> (input -> (Text, ObjectCodec input ()))
-> HashMap Text (Text, ObjectCodec Void output)
-> ObjectCodec input output
AC.discriminatedUnionCodec Text
"type" FunctionReturnType -> (Text, ObjectCodec FunctionReturnType ())
enc HashMap Text (Text, ObjectCodec Void FunctionReturnType)
dec
    where
      typeField :: Codec Object () ()
typeField = () -> Codec Object () ()
forall a. a -> Codec Object () a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
      tableField :: ObjectCodec TableName TableName
tableField = Text -> ObjectCodec TableName TableName
forall output. HasCodec output => Text -> ObjectCodec output output
AC.requiredField' Text
"table"
      enc :: FunctionReturnType -> (Text, ObjectCodec FunctionReturnType ())
enc = \case
        FunctionReturnsTable TableName
rt -> (Text
"table", TableName
-> ObjectCodec TableName TableName
-> ObjectCodec FunctionReturnType ()
forall b context any a.
b -> Codec context b any -> Codec context a ()
AC.mapToEncoder TableName
rt ObjectCodec TableName TableName
tableField)
        FunctionReturnType
FunctionReturnsUnknown -> (Text
"inferred", () -> Codec Object () () -> ObjectCodec FunctionReturnType ()
forall b context any a.
b -> Codec context b any -> Codec context a ()
AC.mapToEncoder () Codec Object () ()
typeField) -- We hook into the type field because it's madatory
      dec :: HashMap Text (Text, ObjectCodec Void FunctionReturnType)
dec =
        [(Text, (Text, ObjectCodec Void FunctionReturnType))]
-> HashMap Text (Text, ObjectCodec Void FunctionReturnType)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList
          [ (Text
"table", (Text
"TableFunctionResponse", (TableName -> FunctionReturnType)
-> ObjectCodec TableName TableName
-> ObjectCodec Void FunctionReturnType
forall b a context any.
(b -> a) -> Codec context any b -> Codec context Void a
AC.mapToDecoder TableName -> FunctionReturnType
FunctionReturnsTable ObjectCodec TableName TableName
tableField)),
            (Text
"inferred", (Text
"InferredFunctionResponse", (() -> FunctionReturnType)
-> Codec Object () () -> ObjectCodec Void FunctionReturnType
forall b a context any.
(b -> a) -> Codec context any b -> Codec context Void a
AC.mapToDecoder (FunctionReturnType -> () -> FunctionReturnType
forall a b. a -> b -> a
const FunctionReturnType
FunctionReturnsUnknown) Codec Object () ()
typeField))
          ]

------------

data DataConnectorOptions = DataConnectorOptions
  { DataConnectorOptions -> BaseUrl
_dcoUri :: BaseUrl,
    DataConnectorOptions -> Maybe Text
_dcoDisplayName :: Maybe Text
  }
  deriving stock (DataConnectorOptions -> DataConnectorOptions -> Bool
(DataConnectorOptions -> DataConnectorOptions -> Bool)
-> (DataConnectorOptions -> DataConnectorOptions -> Bool)
-> Eq DataConnectorOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataConnectorOptions -> DataConnectorOptions -> Bool
== :: DataConnectorOptions -> DataConnectorOptions -> Bool
$c/= :: DataConnectorOptions -> DataConnectorOptions -> Bool
/= :: 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
$ccompare :: DataConnectorOptions -> DataConnectorOptions -> Ordering
compare :: DataConnectorOptions -> DataConnectorOptions -> Ordering
$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
>= :: DataConnectorOptions -> DataConnectorOptions -> Bool
$cmax :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
max :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
$cmin :: DataConnectorOptions
-> DataConnectorOptions -> DataConnectorOptions
min :: DataConnectorOptions
-> DataConnectorOptions -> 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
$cshowsPrec :: Int -> DataConnectorOptions -> ShowS
showsPrec :: Int -> DataConnectorOptions -> ShowS
$cshow :: DataConnectorOptions -> String
show :: DataConnectorOptions -> String
$cshowList :: [DataConnectorOptions] -> ShowS
showList :: [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
$cfrom :: forall x. DataConnectorOptions -> Rep DataConnectorOptions x
from :: forall x. DataConnectorOptions -> Rep DataConnectorOptions x
$cto :: forall x. Rep DataConnectorOptions x -> DataConnectorOptions
to :: forall x. Rep DataConnectorOptions x -> DataConnectorOptions
Generic)

instance HasCodec DataConnectorOptions where
  codec :: JSONCodec DataConnectorOptions
codec =
    Text
-> ObjectCodec DataConnectorOptions DataConnectorOptions
-> JSONCodec DataConnectorOptions
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object Text
"DataConnectorOptions"
      (ObjectCodec DataConnectorOptions DataConnectorOptions
 -> JSONCodec DataConnectorOptions)
-> ObjectCodec DataConnectorOptions DataConnectorOptions
-> JSONCodec DataConnectorOptions
forall a b. (a -> b) -> a -> b
$ BaseUrl -> Maybe Text -> DataConnectorOptions
DataConnectorOptions
      (BaseUrl -> Maybe Text -> DataConnectorOptions)
-> Codec Object DataConnectorOptions BaseUrl
-> Codec
     Object DataConnectorOptions (Maybe Text -> DataConnectorOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ValueCodec BaseUrl BaseUrl -> ObjectCodec BaseUrl BaseUrl
forall input output.
Text -> ValueCodec input output -> ObjectCodec input output
requiredFieldWith' Text
"uri" ValueCodec BaseUrl BaseUrl
baseUrlCodec
      ObjectCodec BaseUrl BaseUrl
-> (DataConnectorOptions -> BaseUrl)
-> Codec Object DataConnectorOptions BaseUrl
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= DataConnectorOptions -> BaseUrl
_dcoUri
        Codec
  Object DataConnectorOptions (Maybe Text -> DataConnectorOptions)
-> Codec Object DataConnectorOptions (Maybe Text)
-> ObjectCodec DataConnectorOptions DataConnectorOptions
forall a b.
Codec Object DataConnectorOptions (a -> b)
-> Codec Object DataConnectorOptions a
-> Codec Object DataConnectorOptions b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> ObjectCodec (Maybe Text) (Maybe Text)
forall output.
HasCodec output =>
Text -> ObjectCodec (Maybe output) (Maybe output)
optionalField' Text
"display_name"
      ObjectCodec (Maybe Text) (Maybe Text)
-> (DataConnectorOptions -> Maybe Text)
-> Codec Object DataConnectorOptions (Maybe Text)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= DataConnectorOptions -> Maybe Text
_dcoDisplayName

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 {omitNothingFields :: Bool
J.omitNothingFields = Bool
True}

--------------------------------------------------------------------------------

data DataConnectorInfo = DataConnectorInfo
  { DataConnectorInfo -> DataConnectorOptions
_dciOptions :: DataConnectorOptions,
    DataConnectorInfo -> Capabilities
_dciCapabilities :: API.Capabilities,
    DataConnectorInfo -> ConfigSchemaResponse
_dciConfigSchemaResponse :: API.ConfigSchemaResponse,
    DataConnectorInfo -> Maybe Text
_dciDisplayName :: Maybe Text,
    DataConnectorInfo -> Maybe Text
_dciReleaseName :: Maybe Text
  }
  deriving stock (DataConnectorInfo -> DataConnectorInfo -> Bool
(DataConnectorInfo -> DataConnectorInfo -> Bool)
-> (DataConnectorInfo -> DataConnectorInfo -> Bool)
-> Eq DataConnectorInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DataConnectorInfo -> DataConnectorInfo -> Bool
== :: DataConnectorInfo -> DataConnectorInfo -> Bool
$c/= :: DataConnectorInfo -> DataConnectorInfo -> Bool
/= :: DataConnectorInfo -> DataConnectorInfo -> Bool
Eq, Int -> DataConnectorInfo -> ShowS
[DataConnectorInfo] -> ShowS
DataConnectorInfo -> String
(Int -> DataConnectorInfo -> ShowS)
-> (DataConnectorInfo -> String)
-> ([DataConnectorInfo] -> ShowS)
-> Show DataConnectorInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DataConnectorInfo -> ShowS
showsPrec :: Int -> DataConnectorInfo -> ShowS
$cshow :: DataConnectorInfo -> String
show :: DataConnectorInfo -> String
$cshowList :: [DataConnectorInfo] -> ShowS
showList :: [DataConnectorInfo] -> ShowS
Show, (forall x. DataConnectorInfo -> Rep DataConnectorInfo x)
-> (forall x. Rep DataConnectorInfo x -> DataConnectorInfo)
-> Generic DataConnectorInfo
forall x. Rep DataConnectorInfo x -> DataConnectorInfo
forall x. DataConnectorInfo -> Rep DataConnectorInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DataConnectorInfo -> Rep DataConnectorInfo x
from :: forall x. DataConnectorInfo -> Rep DataConnectorInfo x
$cto :: forall x. Rep DataConnectorInfo x -> DataConnectorInfo
to :: forall x. Rep DataConnectorInfo x -> DataConnectorInfo
Generic)

instance FromJSON DataConnectorInfo where
  parseJSON :: Value -> Parser DataConnectorInfo
parseJSON = Options -> Value -> Parser DataConnectorInfo
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Options -> Value -> Parser a
genericParseJSON Options
hasuraJSON

instance ToJSON DataConnectorInfo where
  toJSON :: DataConnectorInfo -> Value
toJSON = Options -> DataConnectorInfo -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
hasuraJSON {omitNothingFields :: Bool
J.omitNothingFields = Bool
True}

--------------------------------------------------------------------------------

-- | The fully qualified name of a table. The last element in the list is the table name
-- and all other elements represent namespacing of the table name.
-- For example, for a database that has schemas, the name would be '[<schema>,<table name>]'
newtype TableName = TableName {TableName -> NonEmpty Text
unTableName :: NonEmpty Text}
  deriving stock (Typeable TableName
Typeable TableName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> TableName -> c TableName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c TableName)
-> (TableName -> Constr)
-> (TableName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c TableName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TableName))
-> ((forall b. Data b => b -> b) -> TableName -> TableName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> TableName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> TableName -> r)
-> (forall u. (forall d. Data d => d -> u) -> TableName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> TableName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> TableName -> m TableName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TableName -> m TableName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> TableName -> m TableName)
-> Data TableName
TableName -> Constr
TableName -> DataType
(forall b. Data b => b -> b) -> TableName -> TableName
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) -> TableName -> u
forall u. (forall d. Data d => d -> u) -> TableName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TableName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TableName -> c TableName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TableName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TableName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TableName -> c TableName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> TableName -> c TableName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TableName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TableName
$ctoConstr :: TableName -> Constr
toConstr :: TableName -> Constr
$cdataTypeOf :: TableName -> DataType
dataTypeOf :: TableName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TableName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c TableName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TableName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TableName)
$cgmapT :: (forall b. Data b => b -> b) -> TableName -> TableName
gmapT :: (forall b. Data b => b -> b) -> TableName -> TableName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> TableName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> TableName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> TableName -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TableName -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> TableName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> TableName -> m TableName
Data, TableName -> TableName -> Bool
(TableName -> TableName -> Bool)
-> (TableName -> TableName -> Bool) -> Eq TableName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TableName -> TableName -> Bool
== :: TableName -> TableName -> Bool
$c/= :: TableName -> TableName -> Bool
/= :: TableName -> TableName -> Bool
Eq, (forall x. TableName -> Rep TableName x)
-> (forall x. Rep TableName x -> TableName) -> Generic TableName
forall x. Rep TableName x -> TableName
forall x. TableName -> Rep TableName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TableName -> Rep TableName x
from :: forall x. TableName -> Rep TableName x
$cto :: forall x. Rep TableName x -> TableName
to :: forall x. Rep TableName x -> TableName
Generic, Eq TableName
Eq TableName
-> (TableName -> TableName -> Ordering)
-> (TableName -> TableName -> Bool)
-> (TableName -> TableName -> Bool)
-> (TableName -> TableName -> Bool)
-> (TableName -> TableName -> Bool)
-> (TableName -> TableName -> TableName)
-> (TableName -> TableName -> TableName)
-> Ord TableName
TableName -> TableName -> Bool
TableName -> TableName -> Ordering
TableName -> TableName -> TableName
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
$ccompare :: TableName -> TableName -> Ordering
compare :: TableName -> TableName -> Ordering
$c< :: TableName -> TableName -> Bool
< :: TableName -> TableName -> Bool
$c<= :: TableName -> TableName -> Bool
<= :: TableName -> TableName -> Bool
$c> :: TableName -> TableName -> Bool
> :: TableName -> TableName -> Bool
$c>= :: TableName -> TableName -> Bool
>= :: TableName -> TableName -> Bool
$cmax :: TableName -> TableName -> TableName
max :: TableName -> TableName -> TableName
$cmin :: TableName -> TableName -> TableName
min :: TableName -> TableName -> TableName
Ord, Int -> TableName -> ShowS
[TableName] -> ShowS
TableName -> String
(Int -> TableName -> ShowS)
-> (TableName -> String)
-> ([TableName] -> ShowS)
-> Show TableName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TableName -> ShowS
showsPrec :: Int -> TableName -> ShowS
$cshow :: TableName -> String
show :: TableName -> String
$cshowList :: [TableName] -> ShowS
showList :: [TableName] -> ShowS
Show)
  deriving newtype (Eq TableName
Eq TableName
-> (Int -> TableName -> Int)
-> (TableName -> Int)
-> Hashable TableName
Int -> TableName -> Int
TableName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> TableName -> Int
hashWithSalt :: Int -> TableName -> Int
$chash :: TableName -> Int
hash :: TableName -> Int
Hashable, TableName -> ()
(TableName -> ()) -> NFData TableName
forall a. (a -> ()) -> NFData a
$crnf :: TableName -> ()
rnf :: TableName -> ()
NFData, [TableName] -> Value
[TableName] -> Encoding
TableName -> Value
TableName -> Encoding
(TableName -> Value)
-> (TableName -> Encoding)
-> ([TableName] -> Value)
-> ([TableName] -> Encoding)
-> ToJSON TableName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: TableName -> Value
toJSON :: TableName -> Value
$ctoEncoding :: TableName -> Encoding
toEncoding :: TableName -> Encoding
$ctoJSONList :: [TableName] -> Value
toJSONList :: [TableName] -> Value
$ctoEncodingList :: [TableName] -> Encoding
toEncodingList :: [TableName] -> Encoding
ToJSON)

instance HasCodec TableName where
  codec :: JSONCodec TableName
codec = (NonEmpty Text -> TableName)
-> (TableName -> NonEmpty Text)
-> Codec Value (NonEmpty Text) (NonEmpty Text)
-> JSONCodec TableName
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.dimapCodec NonEmpty Text -> TableName
TableName TableName -> NonEmpty Text
unTableName Codec Value (NonEmpty Text) (NonEmpty Text)
forall value. HasCodec value => JSONCodec value
codec

instance FromJSON TableName where
  parseJSON :: Value -> Parser TableName
parseJSON Value
value =
    NonEmpty Text -> TableName
TableName
      (NonEmpty Text -> TableName)
-> Parser (NonEmpty Text) -> Parser TableName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (NonEmpty Text)
forall a. FromJSON a => Value -> Parser a
J.parseJSON Value
value
      -- Fallback parsing of a single string to support older metadata
      Parser TableName -> Parser TableName -> Parser TableName
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> String -> (Text -> Parser TableName) -> Value -> Parser TableName
forall a. String -> (Text -> Parser a) -> Value -> Parser a
J.withText String
"TableName" (\Text
text -> TableName -> Parser TableName
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TableName -> Parser TableName)
-> (NonEmpty Text -> TableName)
-> NonEmpty Text
-> Parser TableName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty Text -> TableName
TableName (NonEmpty Text -> Parser TableName)
-> NonEmpty Text -> Parser TableName
forall a b. (a -> b) -> a -> b
$ Text
text Text -> [Text] -> NonEmpty Text
forall a. a -> [a] -> NonEmpty a
:| []) Value
value

instance ToJSONKey TableName where
  toJSONKey :: ToJSONKeyFunction TableName
toJSONKey = (TableName -> Text) -> ToJSONKeyFunction TableName
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText TableName -> Text
forall a. ToTxt a => a -> Text
toTxt

instance Witch.From API.TableName TableName where
  from :: TableName -> TableName
from (API.TableName NonEmpty Text
n) = NonEmpty Text -> TableName
TableName NonEmpty Text
n

instance Witch.From TableName API.TableName where
  from :: TableName -> TableName
from (TableName NonEmpty Text
n) = NonEmpty Text -> TableName
API.TableName NonEmpty Text
n

instance ToTxt TableName where
  toTxt :: TableName -> Text
toTxt = Text -> [Text] -> Text
Text.intercalate Text
"." ([Text] -> Text) -> (TableName -> [Text]) -> TableName -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty Text -> [Text]
forall a. NonEmpty a -> [a]
NonEmpty.toList (NonEmpty Text -> [Text])
-> (TableName -> NonEmpty Text) -> TableName -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName -> NonEmpty Text
unTableName

instance ToErrorValue TableName where
  toErrorValue :: TableName -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (TableName -> Text) -> TableName -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TableName -> Text
forall a. ToTxt a => a -> Text
toTxt

--------------------------------------------------------------------------------

newtype ConstraintName = ConstraintName {ConstraintName -> Text
unConstraintName :: Text}
  deriving stock (ConstraintName -> ConstraintName -> Bool
(ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool) -> Eq ConstraintName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConstraintName -> ConstraintName -> Bool
== :: ConstraintName -> ConstraintName -> Bool
$c/= :: ConstraintName -> ConstraintName -> Bool
/= :: ConstraintName -> ConstraintName -> Bool
Eq, Eq ConstraintName
Eq ConstraintName
-> (ConstraintName -> ConstraintName -> Ordering)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> ConstraintName)
-> (ConstraintName -> ConstraintName -> ConstraintName)
-> Ord ConstraintName
ConstraintName -> ConstraintName -> Bool
ConstraintName -> ConstraintName -> Ordering
ConstraintName -> ConstraintName -> ConstraintName
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
$ccompare :: ConstraintName -> ConstraintName -> Ordering
compare :: ConstraintName -> ConstraintName -> Ordering
$c< :: ConstraintName -> ConstraintName -> Bool
< :: ConstraintName -> ConstraintName -> Bool
$c<= :: ConstraintName -> ConstraintName -> Bool
<= :: ConstraintName -> ConstraintName -> Bool
$c> :: ConstraintName -> ConstraintName -> Bool
> :: ConstraintName -> ConstraintName -> Bool
$c>= :: ConstraintName -> ConstraintName -> Bool
>= :: ConstraintName -> ConstraintName -> Bool
$cmax :: ConstraintName -> ConstraintName -> ConstraintName
max :: ConstraintName -> ConstraintName -> ConstraintName
$cmin :: ConstraintName -> ConstraintName -> ConstraintName
min :: ConstraintName -> ConstraintName -> ConstraintName
Ord, Int -> ConstraintName -> ShowS
[ConstraintName] -> ShowS
ConstraintName -> String
(Int -> ConstraintName -> ShowS)
-> (ConstraintName -> String)
-> ([ConstraintName] -> ShowS)
-> Show ConstraintName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConstraintName -> ShowS
showsPrec :: Int -> ConstraintName -> ShowS
$cshow :: ConstraintName -> String
show :: ConstraintName -> String
$cshowList :: [ConstraintName] -> ShowS
showList :: [ConstraintName] -> ShowS
Show, (forall x. ConstraintName -> Rep ConstraintName x)
-> (forall x. Rep ConstraintName x -> ConstraintName)
-> Generic ConstraintName
forall x. Rep ConstraintName x -> ConstraintName
forall x. ConstraintName -> Rep ConstraintName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ConstraintName -> Rep ConstraintName x
from :: forall x. ConstraintName -> Rep ConstraintName x
$cto :: forall x. Rep ConstraintName x -> ConstraintName
to :: forall x. Rep ConstraintName x -> ConstraintName
Generic, Typeable ConstraintName
Typeable ConstraintName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ConstraintName -> c ConstraintName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ConstraintName)
-> (ConstraintName -> Constr)
-> (ConstraintName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ConstraintName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ConstraintName))
-> ((forall b. Data b => b -> b)
    -> ConstraintName -> ConstraintName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstraintName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstraintName -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ConstraintName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ConstraintName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> Data ConstraintName
ConstraintName -> Constr
ConstraintName -> DataType
(forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
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) -> ConstraintName -> u
forall u. (forall d. Data d => d -> u) -> ConstraintName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
$ctoConstr :: ConstraintName -> Constr
toConstr :: ConstraintName -> Constr
$cdataTypeOf :: ConstraintName -> DataType
dataTypeOf :: ConstraintName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
$cgmapT :: (forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
gmapT :: (forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ConstraintName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ConstraintName -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ConstraintName -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ConstraintName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
Data)
  deriving newtype (ConstraintName -> ()
(ConstraintName -> ()) -> NFData ConstraintName
forall a. (a -> ()) -> NFData a
$crnf :: ConstraintName -> ()
rnf :: ConstraintName -> ()
NFData, Eq ConstraintName
Eq ConstraintName
-> (Int -> ConstraintName -> Int)
-> (ConstraintName -> Int)
-> Hashable ConstraintName
Int -> ConstraintName -> Int
ConstraintName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ConstraintName -> Int
hashWithSalt :: Int -> ConstraintName -> Int
$chash :: ConstraintName -> Int
hash :: ConstraintName -> Int
Hashable, Value -> Parser [ConstraintName]
Value -> Parser ConstraintName
(Value -> Parser ConstraintName)
-> (Value -> Parser [ConstraintName]) -> FromJSON ConstraintName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ConstraintName
parseJSON :: Value -> Parser ConstraintName
$cparseJSONList :: Value -> Parser [ConstraintName]
parseJSONList :: Value -> Parser [ConstraintName]
FromJSON, [ConstraintName] -> Value
[ConstraintName] -> Encoding
ConstraintName -> Value
ConstraintName -> Encoding
(ConstraintName -> Value)
-> (ConstraintName -> Encoding)
-> ([ConstraintName] -> Value)
-> ([ConstraintName] -> Encoding)
-> ToJSON ConstraintName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ConstraintName -> Value
toJSON :: ConstraintName -> Value
$ctoEncoding :: ConstraintName -> Encoding
toEncoding :: ConstraintName -> Encoding
$ctoJSONList :: [ConstraintName] -> Value
toJSONList :: [ConstraintName] -> Value
$ctoEncodingList :: [ConstraintName] -> Encoding
toEncodingList :: [ConstraintName] -> Encoding
ToJSON, FromJSONKeyFunction [ConstraintName]
FromJSONKeyFunction ConstraintName
FromJSONKeyFunction ConstraintName
-> FromJSONKeyFunction [ConstraintName]
-> FromJSONKey ConstraintName
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
$cfromJSONKey :: FromJSONKeyFunction ConstraintName
fromJSONKey :: FromJSONKeyFunction ConstraintName
$cfromJSONKeyList :: FromJSONKeyFunction [ConstraintName]
fromJSONKeyList :: FromJSONKeyFunction [ConstraintName]
FromJSONKey, ToJSONKeyFunction [ConstraintName]
ToJSONKeyFunction ConstraintName
ToJSONKeyFunction ConstraintName
-> ToJSONKeyFunction [ConstraintName] -> ToJSONKey ConstraintName
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
$ctoJSONKey :: ToJSONKeyFunction ConstraintName
toJSONKey :: ToJSONKeyFunction ConstraintName
$ctoJSONKeyList :: ToJSONKeyFunction [ConstraintName]
toJSONKeyList :: ToJSONKeyFunction [ConstraintName]
ToJSONKey)

instance Witch.From API.ConstraintName ConstraintName where
  from :: ConstraintName -> ConstraintName
from (API.ConstraintName Text
n) = Text -> ConstraintName
ConstraintName Text
n

instance Witch.From ConstraintName API.ConstraintName where
  from :: ConstraintName -> ConstraintName
from (ConstraintName Text
n) = Text -> ConstraintName
API.ConstraintName Text
n

instance ToTxt ConstraintName where
  toTxt :: ConstraintName -> Text
toTxt = ConstraintName -> Text
unConstraintName

instance ToErrorValue ConstraintName where
  toErrorValue :: ConstraintName -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (ConstraintName -> Text) -> ConstraintName -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConstraintName -> Text
unConstraintName

--------------------------------------------------------------------------------

newtype ColumnName = ColumnName {ColumnName -> Text
unColumnName :: Text}
  deriving stock (ColumnName -> ColumnName -> Bool
(ColumnName -> ColumnName -> Bool)
-> (ColumnName -> ColumnName -> Bool) -> Eq ColumnName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ColumnName -> ColumnName -> Bool
== :: ColumnName -> ColumnName -> Bool
$c/= :: ColumnName -> ColumnName -> Bool
/= :: ColumnName -> ColumnName -> Bool
Eq, Eq ColumnName
Eq ColumnName
-> (ColumnName -> ColumnName -> Ordering)
-> (ColumnName -> ColumnName -> Bool)
-> (ColumnName -> ColumnName -> Bool)
-> (ColumnName -> ColumnName -> Bool)
-> (ColumnName -> ColumnName -> Bool)
-> (ColumnName -> ColumnName -> ColumnName)
-> (ColumnName -> ColumnName -> ColumnName)
-> Ord ColumnName
ColumnName -> ColumnName -> Bool
ColumnName -> ColumnName -> Ordering
ColumnName -> ColumnName -> ColumnName
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
$ccompare :: ColumnName -> ColumnName -> Ordering
compare :: ColumnName -> ColumnName -> Ordering
$c< :: ColumnName -> ColumnName -> Bool
< :: ColumnName -> ColumnName -> Bool
$c<= :: ColumnName -> ColumnName -> Bool
<= :: ColumnName -> ColumnName -> Bool
$c> :: ColumnName -> ColumnName -> Bool
> :: ColumnName -> ColumnName -> Bool
$c>= :: ColumnName -> ColumnName -> Bool
>= :: ColumnName -> ColumnName -> Bool
$cmax :: ColumnName -> ColumnName -> ColumnName
max :: ColumnName -> ColumnName -> ColumnName
$cmin :: ColumnName -> ColumnName -> ColumnName
min :: ColumnName -> ColumnName -> ColumnName
Ord, Int -> ColumnName -> ShowS
[ColumnName] -> ShowS
ColumnName -> String
(Int -> ColumnName -> ShowS)
-> (ColumnName -> String)
-> ([ColumnName] -> ShowS)
-> Show ColumnName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ColumnName -> ShowS
showsPrec :: Int -> ColumnName -> ShowS
$cshow :: ColumnName -> String
show :: ColumnName -> String
$cshowList :: [ColumnName] -> ShowS
showList :: [ColumnName] -> ShowS
Show, (forall x. ColumnName -> Rep ColumnName x)
-> (forall x. Rep ColumnName x -> ColumnName) -> Generic ColumnName
forall x. Rep ColumnName x -> ColumnName
forall x. ColumnName -> Rep ColumnName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ColumnName -> Rep ColumnName x
from :: forall x. ColumnName -> Rep ColumnName x
$cto :: forall x. Rep ColumnName x -> ColumnName
to :: forall x. Rep ColumnName x -> ColumnName
Generic, Typeable ColumnName
Typeable ColumnName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ColumnName -> c ColumnName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ColumnName)
-> (ColumnName -> Constr)
-> (ColumnName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ColumnName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ColumnName))
-> ((forall b. Data b => b -> b) -> ColumnName -> ColumnName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ColumnName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ColumnName -> r)
-> (forall u. (forall d. Data d => d -> u) -> ColumnName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ColumnName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ColumnName -> m ColumnName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ColumnName -> m ColumnName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ColumnName -> m ColumnName)
-> Data ColumnName
ColumnName -> Constr
ColumnName -> DataType
(forall b. Data b => b -> b) -> ColumnName -> ColumnName
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) -> ColumnName -> u
forall u. (forall d. Data d => d -> u) -> ColumnName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ColumnName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ColumnName -> c ColumnName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ColumnName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ColumnName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ColumnName -> c ColumnName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ColumnName -> c ColumnName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ColumnName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ColumnName
$ctoConstr :: ColumnName -> Constr
toConstr :: ColumnName -> Constr
$cdataTypeOf :: ColumnName -> DataType
dataTypeOf :: ColumnName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ColumnName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ColumnName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ColumnName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ColumnName)
$cgmapT :: (forall b. Data b => b -> b) -> ColumnName -> ColumnName
gmapT :: (forall b. Data b => b -> b) -> ColumnName -> ColumnName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ColumnName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ColumnName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ColumnName -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ColumnName -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ColumnName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ColumnName -> m ColumnName
Data)
  deriving newtype (ColumnName -> ()
(ColumnName -> ()) -> NFData ColumnName
forall a. (a -> ()) -> NFData a
$crnf :: ColumnName -> ()
rnf :: ColumnName -> ()
NFData, Eq ColumnName
Eq ColumnName
-> (Int -> ColumnName -> Int)
-> (ColumnName -> Int)
-> Hashable ColumnName
Int -> ColumnName -> Int
ColumnName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ColumnName -> Int
hashWithSalt :: Int -> ColumnName -> Int
$chash :: ColumnName -> Int
hash :: ColumnName -> Int
Hashable, Value -> Parser [ColumnName]
Value -> Parser ColumnName
(Value -> Parser ColumnName)
-> (Value -> Parser [ColumnName]) -> FromJSON ColumnName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ColumnName
parseJSON :: Value -> Parser ColumnName
$cparseJSONList :: Value -> Parser [ColumnName]
parseJSONList :: Value -> Parser [ColumnName]
FromJSON, [ColumnName] -> Value
[ColumnName] -> Encoding
ColumnName -> Value
ColumnName -> Encoding
(ColumnName -> Value)
-> (ColumnName -> Encoding)
-> ([ColumnName] -> Value)
-> ([ColumnName] -> Encoding)
-> ToJSON ColumnName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ColumnName -> Value
toJSON :: ColumnName -> Value
$ctoEncoding :: ColumnName -> Encoding
toEncoding :: ColumnName -> Encoding
$ctoJSONList :: [ColumnName] -> Value
toJSONList :: [ColumnName] -> Value
$ctoEncodingList :: [ColumnName] -> Encoding
toEncodingList :: [ColumnName] -> Encoding
ToJSON, ToJSONKeyFunction [ColumnName]
ToJSONKeyFunction ColumnName
ToJSONKeyFunction ColumnName
-> ToJSONKeyFunction [ColumnName] -> ToJSONKey ColumnName
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
$ctoJSONKey :: ToJSONKeyFunction ColumnName
toJSONKey :: ToJSONKeyFunction ColumnName
$ctoJSONKeyList :: ToJSONKeyFunction [ColumnName]
toJSONKeyList :: ToJSONKeyFunction [ColumnName]
ToJSONKey, FromJSONKeyFunction [ColumnName]
FromJSONKeyFunction ColumnName
FromJSONKeyFunction ColumnName
-> FromJSONKeyFunction [ColumnName] -> FromJSONKey ColumnName
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
$cfromJSONKey :: FromJSONKeyFunction ColumnName
fromJSONKey :: FromJSONKeyFunction ColumnName
$cfromJSONKeyList :: FromJSONKeyFunction [ColumnName]
fromJSONKeyList :: FromJSONKeyFunction [ColumnName]
FromJSONKey)

instance HasCodec ColumnName where
  codec :: JSONCodec ColumnName
codec = (Text -> ColumnName)
-> (ColumnName -> Text)
-> Codec Value Text Text
-> JSONCodec ColumnName
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.dimapCodec Text -> ColumnName
ColumnName ColumnName -> Text
unColumnName Codec Value Text Text
forall value. HasCodec value => JSONCodec value
codec

instance Witch.From API.ColumnName ColumnName where
  from :: ColumnName -> ColumnName
from (API.ColumnName Text
n) = Text -> ColumnName
ColumnName Text
n

instance Witch.From ColumnName API.ColumnName where
  from :: ColumnName -> ColumnName
from (ColumnName Text
n) = Text -> ColumnName
API.ColumnName Text
n

instance ToTxt ColumnName where
  toTxt :: ColumnName -> Text
toTxt = ColumnName -> Text
unColumnName

instance ToErrorValue ColumnName where
  toErrorValue :: ColumnName -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (ColumnName -> Text) -> ColumnName -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ColumnName -> Text
unColumnName

--------------------------------------------------------------------------------

newtype FunctionName = FunctionName {FunctionName -> NonEmpty Text
unFunctionName :: NonEmpty Text}
  deriving stock (Typeable FunctionName
Typeable FunctionName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> FunctionName -> c FunctionName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c FunctionName)
-> (FunctionName -> Constr)
-> (FunctionName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c FunctionName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c FunctionName))
-> ((forall b. Data b => b -> b) -> FunctionName -> FunctionName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> FunctionName -> r)
-> (forall u. (forall d. Data d => d -> u) -> FunctionName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> FunctionName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> FunctionName -> m FunctionName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FunctionName -> m FunctionName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> FunctionName -> m FunctionName)
-> Data FunctionName
FunctionName -> Constr
FunctionName -> DataType
(forall b. Data b => b -> b) -> FunctionName -> FunctionName
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) -> FunctionName -> u
forall u. (forall d. Data d => d -> u) -> FunctionName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionName -> c FunctionName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunctionName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionName)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionName -> c FunctionName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FunctionName -> c FunctionName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionName
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FunctionName
$ctoConstr :: FunctionName -> Constr
toConstr :: FunctionName -> Constr
$cdataTypeOf :: FunctionName -> DataType
dataTypeOf :: FunctionName -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunctionName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FunctionName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionName)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FunctionName)
$cgmapT :: (forall b. Data b => b -> b) -> FunctionName -> FunctionName
gmapT :: (forall b. Data b => b -> b) -> FunctionName -> FunctionName
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FunctionName -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FunctionName -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FunctionName -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FunctionName -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> FunctionName -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> FunctionName -> m FunctionName
Data, FunctionName -> FunctionName -> Bool
(FunctionName -> FunctionName -> Bool)
-> (FunctionName -> FunctionName -> Bool) -> Eq FunctionName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FunctionName -> FunctionName -> Bool
== :: FunctionName -> FunctionName -> Bool
$c/= :: FunctionName -> FunctionName -> Bool
/= :: FunctionName -> FunctionName -> Bool
Eq, (forall x. FunctionName -> Rep FunctionName x)
-> (forall x. Rep FunctionName x -> FunctionName)
-> Generic FunctionName
forall x. Rep FunctionName x -> FunctionName
forall x. FunctionName -> Rep FunctionName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FunctionName -> Rep FunctionName x
from :: forall x. FunctionName -> Rep FunctionName x
$cto :: forall x. Rep FunctionName x -> FunctionName
to :: forall x. Rep FunctionName x -> FunctionName
Generic, Eq FunctionName
Eq FunctionName
-> (FunctionName -> FunctionName -> Ordering)
-> (FunctionName -> FunctionName -> Bool)
-> (FunctionName -> FunctionName -> Bool)
-> (FunctionName -> FunctionName -> Bool)
-> (FunctionName -> FunctionName -> Bool)
-> (FunctionName -> FunctionName -> FunctionName)
-> (FunctionName -> FunctionName -> FunctionName)
-> Ord FunctionName
FunctionName -> FunctionName -> Bool
FunctionName -> FunctionName -> Ordering
FunctionName -> FunctionName -> FunctionName
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
$ccompare :: FunctionName -> FunctionName -> Ordering
compare :: FunctionName -> FunctionName -> Ordering
$c< :: FunctionName -> FunctionName -> Bool
< :: FunctionName -> FunctionName -> Bool
$c<= :: FunctionName -> FunctionName -> Bool
<= :: FunctionName -> FunctionName -> Bool
$c> :: FunctionName -> FunctionName -> Bool
> :: FunctionName -> FunctionName -> Bool
$c>= :: FunctionName -> FunctionName -> Bool
>= :: FunctionName -> FunctionName -> Bool
$cmax :: FunctionName -> FunctionName -> FunctionName
max :: FunctionName -> FunctionName -> FunctionName
$cmin :: FunctionName -> FunctionName -> FunctionName
min :: FunctionName -> FunctionName -> FunctionName
Ord, Int -> FunctionName -> ShowS
[FunctionName] -> ShowS
FunctionName -> String
(Int -> FunctionName -> ShowS)
-> (FunctionName -> String)
-> ([FunctionName] -> ShowS)
-> Show FunctionName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FunctionName -> ShowS
showsPrec :: Int -> FunctionName -> ShowS
$cshow :: FunctionName -> String
show :: FunctionName -> String
$cshowList :: [FunctionName] -> ShowS
showList :: [FunctionName] -> ShowS
Show)
  deriving newtype (Value -> Parser [FunctionName]
Value -> Parser FunctionName
(Value -> Parser FunctionName)
-> (Value -> Parser [FunctionName]) -> FromJSON FunctionName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser FunctionName
parseJSON :: Value -> Parser FunctionName
$cparseJSONList :: Value -> Parser [FunctionName]
parseJSONList :: Value -> Parser [FunctionName]
FromJSON, Eq FunctionName
Eq FunctionName
-> (Int -> FunctionName -> Int)
-> (FunctionName -> Int)
-> Hashable FunctionName
Int -> FunctionName -> Int
FunctionName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> FunctionName -> Int
hashWithSalt :: Int -> FunctionName -> Int
$chash :: FunctionName -> Int
hash :: FunctionName -> Int
Hashable, FunctionName -> ()
(FunctionName -> ()) -> NFData FunctionName
forall a. (a -> ()) -> NFData a
$crnf :: FunctionName -> ()
rnf :: FunctionName -> ()
NFData, [FunctionName] -> Value
[FunctionName] -> Encoding
FunctionName -> Value
FunctionName -> Encoding
(FunctionName -> Value)
-> (FunctionName -> Encoding)
-> ([FunctionName] -> Value)
-> ([FunctionName] -> Encoding)
-> ToJSON FunctionName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: FunctionName -> Value
toJSON :: FunctionName -> Value
$ctoEncoding :: FunctionName -> Encoding
toEncoding :: FunctionName -> Encoding
$ctoJSONList :: [FunctionName] -> Value
toJSONList :: [FunctionName] -> Value
$ctoEncodingList :: [FunctionName] -> Encoding
toEncodingList :: [FunctionName] -> Encoding
ToJSON)

instance Witch.From FunctionName API.FunctionName

instance Witch.From API.FunctionName FunctionName

instance Witch.From (NonEmpty Text) FunctionName

instance HasCodec FunctionName where
  codec :: JSONCodec FunctionName
codec = (NonEmpty Text -> FunctionName)
-> (FunctionName -> NonEmpty Text)
-> Codec Value (NonEmpty Text) (NonEmpty Text)
-> JSONCodec FunctionName
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.dimapCodec NonEmpty Text -> FunctionName
FunctionName FunctionName -> NonEmpty Text
unFunctionName Codec Value (NonEmpty Text) (NonEmpty Text)
forall value. HasCodec value => JSONCodec value
codec

instance ToJSONKey FunctionName where
  toJSONKey :: ToJSONKeyFunction FunctionName
toJSONKey = (FunctionName -> Text) -> ToJSONKeyFunction FunctionName
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText FunctionName -> Text
forall a. ToTxt a => a -> Text
toTxt

instance ToTxt FunctionName where
  toTxt :: FunctionName -> Text
toTxt = Text -> [Text] -> Text
Text.intercalate Text
"." ([Text] -> Text)
-> (FunctionName -> [Text]) -> FunctionName -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty Text -> [Text]
forall a. NonEmpty a -> [a]
NonEmpty.toList (NonEmpty Text -> [Text])
-> (FunctionName -> NonEmpty Text) -> FunctionName -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FunctionName -> NonEmpty Text
unFunctionName

instance ToErrorValue FunctionName where
  toErrorValue :: FunctionName -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (FunctionName -> Text) -> FunctionName -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FunctionName -> Text
forall a. ToTxt a => a -> Text
toTxt

-- Modified from Hasura.Backends.Postgres.Types.Function
-- Initially just handles literal input arguments.
data ArgumentExp a
  = -- | Table row accessor
    --   AETableRow
    -- | -- | Hardcoded reference to @hdb_catalog.hdb_action_log.response_payload@
    --   AEActionResponsePayload
    -- | -- | JSON/JSONB hasura session variable object
    --   AESession a
    -- |
    AEInput a
  deriving stock (ArgumentExp a -> ArgumentExp a -> Bool
(ArgumentExp a -> ArgumentExp a -> Bool)
-> (ArgumentExp a -> ArgumentExp a -> Bool) -> Eq (ArgumentExp a)
forall a. Eq a => ArgumentExp a -> ArgumentExp a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => ArgumentExp a -> ArgumentExp a -> Bool
== :: ArgumentExp a -> ArgumentExp a -> Bool
$c/= :: forall a. Eq a => ArgumentExp a -> ArgumentExp a -> Bool
/= :: ArgumentExp a -> ArgumentExp a -> Bool
Eq, Int -> ArgumentExp a -> ShowS
[ArgumentExp a] -> ShowS
ArgumentExp a -> String
(Int -> ArgumentExp a -> ShowS)
-> (ArgumentExp a -> String)
-> ([ArgumentExp a] -> ShowS)
-> Show (ArgumentExp a)
forall a. Show a => Int -> ArgumentExp a -> ShowS
forall a. Show a => [ArgumentExp a] -> ShowS
forall a. Show a => ArgumentExp a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> ArgumentExp a -> ShowS
showsPrec :: Int -> ArgumentExp a -> ShowS
$cshow :: forall a. Show a => ArgumentExp a -> String
show :: ArgumentExp a -> String
$cshowList :: forall a. Show a => [ArgumentExp a] -> ShowS
showList :: [ArgumentExp a] -> ShowS
Show, (forall a b. (a -> b) -> ArgumentExp a -> ArgumentExp b)
-> (forall a b. a -> ArgumentExp b -> ArgumentExp a)
-> Functor ArgumentExp
forall a b. a -> ArgumentExp b -> ArgumentExp a
forall a b. (a -> b) -> ArgumentExp a -> ArgumentExp b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> ArgumentExp a -> ArgumentExp b
fmap :: forall a b. (a -> b) -> ArgumentExp a -> ArgumentExp b
$c<$ :: forall a b. a -> ArgumentExp b -> ArgumentExp a
<$ :: forall a b. a -> ArgumentExp b -> ArgumentExp a
Functor, (forall m. Monoid m => ArgumentExp m -> m)
-> (forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m)
-> (forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m)
-> (forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b)
-> (forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b)
-> (forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b)
-> (forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b)
-> (forall a. (a -> a -> a) -> ArgumentExp a -> a)
-> (forall a. (a -> a -> a) -> ArgumentExp a -> a)
-> (forall a. ArgumentExp a -> [a])
-> (forall a. ArgumentExp a -> Bool)
-> (forall a. ArgumentExp a -> Int)
-> (forall a. Eq a => a -> ArgumentExp a -> Bool)
-> (forall a. Ord a => ArgumentExp a -> a)
-> (forall a. Ord a => ArgumentExp a -> a)
-> (forall a. Num a => ArgumentExp a -> a)
-> (forall a. Num a => ArgumentExp a -> a)
-> Foldable ArgumentExp
forall a. Eq a => a -> ArgumentExp a -> Bool
forall a. Num a => ArgumentExp a -> a
forall a. Ord a => ArgumentExp a -> a
forall m. Monoid m => ArgumentExp m -> m
forall a. ArgumentExp a -> Bool
forall a. ArgumentExp a -> Int
forall a. ArgumentExp a -> [a]
forall a. (a -> a -> a) -> ArgumentExp a -> a
forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m
forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b
forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => ArgumentExp m -> m
fold :: forall m. Monoid m => ArgumentExp m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> ArgumentExp a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ArgumentExp a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> ArgumentExp a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> ArgumentExp a -> a
foldr1 :: forall a. (a -> a -> a) -> ArgumentExp a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> ArgumentExp a -> a
foldl1 :: forall a. (a -> a -> a) -> ArgumentExp a -> a
$ctoList :: forall a. ArgumentExp a -> [a]
toList :: forall a. ArgumentExp a -> [a]
$cnull :: forall a. ArgumentExp a -> Bool
null :: forall a. ArgumentExp a -> Bool
$clength :: forall a. ArgumentExp a -> Int
length :: forall a. ArgumentExp a -> Int
$celem :: forall a. Eq a => a -> ArgumentExp a -> Bool
elem :: forall a. Eq a => a -> ArgumentExp a -> Bool
$cmaximum :: forall a. Ord a => ArgumentExp a -> a
maximum :: forall a. Ord a => ArgumentExp a -> a
$cminimum :: forall a. Ord a => ArgumentExp a -> a
minimum :: forall a. Ord a => ArgumentExp a -> a
$csum :: forall a. Num a => ArgumentExp a -> a
sum :: forall a. Num a => ArgumentExp a -> a
$cproduct :: forall a. Num a => ArgumentExp a -> a
product :: forall a. Num a => ArgumentExp a -> a
Foldable, Functor ArgumentExp
Foldable ArgumentExp
Functor ArgumentExp
-> Foldable ArgumentExp
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> ArgumentExp a -> f (ArgumentExp b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    ArgumentExp (f a) -> f (ArgumentExp a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> ArgumentExp a -> m (ArgumentExp b))
-> (forall (m :: * -> *) a.
    Monad m =>
    ArgumentExp (m a) -> m (ArgumentExp a))
-> Traversable ArgumentExp
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
ArgumentExp (m a) -> m (ArgumentExp a)
forall (f :: * -> *) a.
Applicative f =>
ArgumentExp (f a) -> f (ArgumentExp a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArgumentExp a -> m (ArgumentExp b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArgumentExp a -> f (ArgumentExp b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArgumentExp a -> f (ArgumentExp b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArgumentExp a -> f (ArgumentExp b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArgumentExp (f a) -> f (ArgumentExp a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArgumentExp (f a) -> f (ArgumentExp a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArgumentExp a -> m (ArgumentExp b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArgumentExp a -> m (ArgumentExp b)
$csequence :: forall (m :: * -> *) a.
Monad m =>
ArgumentExp (m a) -> m (ArgumentExp a)
sequence :: forall (m :: * -> *) a.
Monad m =>
ArgumentExp (m a) -> m (ArgumentExp a)
Traversable, (forall x. ArgumentExp a -> Rep (ArgumentExp a) x)
-> (forall x. Rep (ArgumentExp a) x -> ArgumentExp a)
-> Generic (ArgumentExp a)
forall x. Rep (ArgumentExp a) x -> ArgumentExp a
forall x. ArgumentExp a -> Rep (ArgumentExp a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (ArgumentExp a) x -> ArgumentExp a
forall a x. ArgumentExp a -> Rep (ArgumentExp a) x
$cfrom :: forall a x. ArgumentExp a -> Rep (ArgumentExp a) x
from :: forall x. ArgumentExp a -> Rep (ArgumentExp a) x
$cto :: forall a x. Rep (ArgumentExp a) x -> ArgumentExp a
to :: forall x. Rep (ArgumentExp a) x -> ArgumentExp a
Generic)

instance (Hashable a) => Hashable (ArgumentExp a)

--------------------------------------------------------------------------------

data CountAggregate v
  = StarCount
  | ColumnCount (ColumnName, IR.AnnRedactionExp 'DataConnector v)
  | ColumnDistinctCount (ColumnName, IR.AnnRedactionExp 'DataConnector v)
  deriving ((forall x. CountAggregate v -> Rep (CountAggregate v) x)
-> (forall x. Rep (CountAggregate v) x -> CountAggregate v)
-> Generic (CountAggregate v)
forall x. Rep (CountAggregate v) x -> CountAggregate v
forall x. CountAggregate v -> Rep (CountAggregate v) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall v x. Rep (CountAggregate v) x -> CountAggregate v
forall v x. CountAggregate v -> Rep (CountAggregate v) x
$cfrom :: forall v x. CountAggregate v -> Rep (CountAggregate v) x
from :: forall x. CountAggregate v -> Rep (CountAggregate v) x
$cto :: forall v x. Rep (CountAggregate v) x -> CountAggregate v
to :: forall x. Rep (CountAggregate v) x -> CountAggregate v
Generic)

deriving stock instance
  (Backend 'DataConnector, Show (IR.AnnRedactionExp 'DataConnector v), Show v) =>
  Show (CountAggregate v)

deriving stock instance (Backend 'DataConnector) => Functor CountAggregate

deriving stock instance (Backend 'DataConnector) => Foldable CountAggregate

deriving stock instance (Backend 'DataConnector) => Traversable CountAggregate

deriving stock instance
  (Backend 'DataConnector, Eq (IR.AnnRedactionExp 'DataConnector v), Eq v) =>
  Eq (CountAggregate v)

deriving stock instance
  (Backend 'DataConnector, Data (IR.AnnRedactionExp 'DataConnector v), Data v) =>
  Data (CountAggregate v)

--------------------------------------------------------------------------------

data Literal
  = ValueLiteral ScalarType J.Value
  | ArrayLiteral ScalarType [J.Value]
  deriving stock (Literal -> Literal -> Bool
(Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool) -> Eq Literal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Literal -> Literal -> Bool
== :: Literal -> Literal -> Bool
$c/= :: Literal -> Literal -> Bool
/= :: Literal -> Literal -> Bool
Eq, Int -> Literal -> ShowS
[Literal] -> ShowS
Literal -> String
(Int -> Literal -> ShowS)
-> (Literal -> String) -> ([Literal] -> ShowS) -> Show Literal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Literal -> ShowS
showsPrec :: Int -> Literal -> ShowS
$cshow :: Literal -> String
show :: Literal -> String
$cshowList :: [Literal] -> ShowS
showList :: [Literal] -> ShowS
Show, (forall x. Literal -> Rep Literal x)
-> (forall x. Rep Literal x -> Literal) -> Generic Literal
forall x. Rep Literal x -> Literal
forall x. Literal -> Rep Literal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Literal -> Rep Literal x
from :: forall x. Literal -> Rep Literal x
$cto :: forall x. Rep Literal x -> Literal
to :: forall x. Rep Literal x -> Literal
Generic, Eq Literal
Eq Literal
-> (Literal -> Literal -> Ordering)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Literal)
-> (Literal -> Literal -> Literal)
-> Ord Literal
Literal -> Literal -> Bool
Literal -> Literal -> Ordering
Literal -> Literal -> Literal
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
$ccompare :: Literal -> Literal -> Ordering
compare :: Literal -> Literal -> Ordering
$c< :: Literal -> Literal -> Bool
< :: Literal -> Literal -> Bool
$c<= :: Literal -> Literal -> Bool
<= :: Literal -> Literal -> Bool
$c> :: Literal -> Literal -> Bool
> :: Literal -> Literal -> Bool
$c>= :: Literal -> Literal -> Bool
>= :: Literal -> Literal -> Bool
$cmax :: Literal -> Literal -> Literal
max :: Literal -> Literal -> Literal
$cmin :: Literal -> Literal -> Literal
min :: Literal -> Literal -> Literal
Ord)
  deriving anyclass (Eq Literal
Eq Literal
-> (Int -> Literal -> Int) -> (Literal -> Int) -> Hashable Literal
Int -> Literal -> Int
Literal -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Literal -> Int
hashWithSalt :: Int -> Literal -> Int
$chash :: Literal -> Int
hash :: Literal -> Int
Hashable, Literal -> ()
(Literal -> ()) -> NFData Literal
forall a. (a -> ()) -> NFData a
$crnf :: Literal -> ()
rnf :: Literal -> ()
NFData, [Literal] -> Value
[Literal] -> Encoding
Literal -> Value
Literal -> Encoding
(Literal -> Value)
-> (Literal -> Encoding)
-> ([Literal] -> Value)
-> ([Literal] -> Encoding)
-> ToJSON Literal
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Literal -> Value
toJSON :: Literal -> Value
$ctoEncoding :: Literal -> Encoding
toEncoding :: Literal -> Encoding
$ctoJSONList :: [Literal] -> Value
toJSONList :: [Literal] -> Value
$ctoEncodingList :: [Literal] -> Encoding
toEncodingList :: [Literal] -> Encoding
ToJSON)

--------------------------------------------------------------------------------

data OrderDirection
  = Ascending
  | Descending
  deriving stock (Typeable OrderDirection
Typeable OrderDirection
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OrderDirection -> c OrderDirection)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OrderDirection)
-> (OrderDirection -> Constr)
-> (OrderDirection -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OrderDirection))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c OrderDirection))
-> ((forall b. Data b => b -> b)
    -> OrderDirection -> OrderDirection)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> OrderDirection -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> OrderDirection -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> OrderDirection -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> OrderDirection -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> OrderDirection -> m OrderDirection)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> OrderDirection -> m OrderDirection)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> OrderDirection -> m OrderDirection)
-> Data OrderDirection
OrderDirection -> Constr
OrderDirection -> DataType
(forall b. Data b => b -> b) -> OrderDirection -> OrderDirection
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) -> OrderDirection -> u
forall u. (forall d. Data d => d -> u) -> OrderDirection -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OrderDirection
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OrderDirection -> c OrderDirection
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OrderDirection)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c OrderDirection)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OrderDirection -> c OrderDirection
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OrderDirection -> c OrderDirection
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OrderDirection
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OrderDirection
$ctoConstr :: OrderDirection -> Constr
toConstr :: OrderDirection -> Constr
$cdataTypeOf :: OrderDirection -> DataType
dataTypeOf :: OrderDirection -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OrderDirection)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OrderDirection)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c OrderDirection)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c OrderDirection)
$cgmapT :: (forall b. Data b => b -> b) -> OrderDirection -> OrderDirection
gmapT :: (forall b. Data b => b -> b) -> OrderDirection -> OrderDirection
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> OrderDirection -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> OrderDirection -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> OrderDirection -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> OrderDirection -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> OrderDirection -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> OrderDirection -> m OrderDirection
Data, OrderDirection -> OrderDirection -> Bool
(OrderDirection -> OrderDirection -> Bool)
-> (OrderDirection -> OrderDirection -> Bool) -> Eq OrderDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OrderDirection -> OrderDirection -> Bool
== :: OrderDirection -> OrderDirection -> Bool
$c/= :: OrderDirection -> OrderDirection -> Bool
/= :: OrderDirection -> OrderDirection -> Bool
Eq, (forall x. OrderDirection -> Rep OrderDirection x)
-> (forall x. Rep OrderDirection x -> OrderDirection)
-> Generic OrderDirection
forall x. Rep OrderDirection x -> OrderDirection
forall x. OrderDirection -> Rep OrderDirection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. OrderDirection -> Rep OrderDirection x
from :: forall x. OrderDirection -> Rep OrderDirection x
$cto :: forall x. Rep OrderDirection x -> OrderDirection
to :: forall x. Rep OrderDirection x -> OrderDirection
Generic, Eq OrderDirection
Eq OrderDirection
-> (OrderDirection -> OrderDirection -> Ordering)
-> (OrderDirection -> OrderDirection -> Bool)
-> (OrderDirection -> OrderDirection -> Bool)
-> (OrderDirection -> OrderDirection -> Bool)
-> (OrderDirection -> OrderDirection -> Bool)
-> (OrderDirection -> OrderDirection -> OrderDirection)
-> (OrderDirection -> OrderDirection -> OrderDirection)
-> Ord OrderDirection
OrderDirection -> OrderDirection -> Bool
OrderDirection -> OrderDirection -> Ordering
OrderDirection -> OrderDirection -> OrderDirection
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
$ccompare :: OrderDirection -> OrderDirection -> Ordering
compare :: OrderDirection -> OrderDirection -> Ordering
$c< :: OrderDirection -> OrderDirection -> Bool
< :: OrderDirection -> OrderDirection -> Bool
$c<= :: OrderDirection -> OrderDirection -> Bool
<= :: OrderDirection -> OrderDirection -> Bool
$c> :: OrderDirection -> OrderDirection -> Bool
> :: OrderDirection -> OrderDirection -> Bool
$c>= :: OrderDirection -> OrderDirection -> Bool
>= :: OrderDirection -> OrderDirection -> Bool
$cmax :: OrderDirection -> OrderDirection -> OrderDirection
max :: OrderDirection -> OrderDirection -> OrderDirection
$cmin :: OrderDirection -> OrderDirection -> OrderDirection
min :: OrderDirection -> OrderDirection -> OrderDirection
Ord, Int -> OrderDirection -> ShowS
[OrderDirection] -> ShowS
OrderDirection -> String
(Int -> OrderDirection -> ShowS)
-> (OrderDirection -> String)
-> ([OrderDirection] -> ShowS)
-> Show OrderDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OrderDirection -> ShowS
showsPrec :: Int -> OrderDirection -> ShowS
$cshow :: OrderDirection -> String
show :: OrderDirection -> String
$cshowList :: [OrderDirection] -> ShowS
showList :: [OrderDirection] -> ShowS
Show)
  deriving anyclass (Eq OrderDirection
Eq OrderDirection
-> (Int -> OrderDirection -> Int)
-> (OrderDirection -> Int)
-> Hashable OrderDirection
Int -> OrderDirection -> Int
OrderDirection -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> OrderDirection -> Int
hashWithSalt :: Int -> OrderDirection -> Int
$chash :: OrderDirection -> Int
hash :: OrderDirection -> Int
Hashable, OrderDirection -> ()
(OrderDirection -> ()) -> NFData OrderDirection
forall a. (a -> ()) -> NFData a
$crnf :: OrderDirection -> ()
rnf :: OrderDirection -> ()
NFData)

instance ToJSON OrderDirection where
  toJSON :: OrderDirection -> Value
toJSON = Options -> OrderDirection -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
J.genericToJSON Options
J.defaultOptions

instance Witch.From API.OrderDirection OrderDirection where
  from :: OrderDirection -> OrderDirection
from OrderDirection
API.Ascending = OrderDirection
Ascending
  from OrderDirection
API.Descending = OrderDirection
Descending

instance Witch.From OrderDirection API.OrderDirection where
  from :: OrderDirection -> OrderDirection
from OrderDirection
Ascending = OrderDirection
API.Ascending
  from OrderDirection
Descending = OrderDirection
API.Descending

--------------------------------------------------------------------------------

newtype ScalarType = ScalarType {ScalarType -> Text
unScalarType :: Text}
  deriving stock (ScalarType -> ScalarType -> Bool
(ScalarType -> ScalarType -> Bool)
-> (ScalarType -> ScalarType -> Bool) -> Eq ScalarType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScalarType -> ScalarType -> Bool
== :: ScalarType -> ScalarType -> Bool
$c/= :: ScalarType -> ScalarType -> Bool
/= :: ScalarType -> ScalarType -> Bool
Eq, (forall x. ScalarType -> Rep ScalarType x)
-> (forall x. Rep ScalarType x -> ScalarType) -> Generic ScalarType
forall x. Rep ScalarType x -> ScalarType
forall x. ScalarType -> Rep ScalarType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScalarType -> Rep ScalarType x
from :: forall x. ScalarType -> Rep ScalarType x
$cto :: forall x. Rep ScalarType x -> ScalarType
to :: forall x. Rep ScalarType x -> ScalarType
Generic, Eq ScalarType
Eq ScalarType
-> (ScalarType -> ScalarType -> Ordering)
-> (ScalarType -> ScalarType -> Bool)
-> (ScalarType -> ScalarType -> Bool)
-> (ScalarType -> ScalarType -> Bool)
-> (ScalarType -> ScalarType -> Bool)
-> (ScalarType -> ScalarType -> ScalarType)
-> (ScalarType -> ScalarType -> ScalarType)
-> Ord ScalarType
ScalarType -> ScalarType -> Bool
ScalarType -> ScalarType -> Ordering
ScalarType -> ScalarType -> ScalarType
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
$ccompare :: ScalarType -> ScalarType -> Ordering
compare :: ScalarType -> ScalarType -> Ordering
$c< :: ScalarType -> ScalarType -> Bool
< :: ScalarType -> ScalarType -> Bool
$c<= :: ScalarType -> ScalarType -> Bool
<= :: ScalarType -> ScalarType -> Bool
$c> :: ScalarType -> ScalarType -> Bool
> :: ScalarType -> ScalarType -> Bool
$c>= :: ScalarType -> ScalarType -> Bool
>= :: ScalarType -> ScalarType -> Bool
$cmax :: ScalarType -> ScalarType -> ScalarType
max :: ScalarType -> ScalarType -> ScalarType
$cmin :: ScalarType -> ScalarType -> ScalarType
min :: ScalarType -> ScalarType -> ScalarType
Ord, Int -> ScalarType -> ShowS
[ScalarType] -> ShowS
ScalarType -> String
(Int -> ScalarType -> ShowS)
-> (ScalarType -> String)
-> ([ScalarType] -> ShowS)
-> Show ScalarType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScalarType -> ShowS
showsPrec :: Int -> ScalarType -> ShowS
$cshow :: ScalarType -> String
show :: ScalarType -> String
$cshowList :: [ScalarType] -> ShowS
showList :: [ScalarType] -> ShowS
Show)
  deriving anyclass (Eq ScalarType
Eq ScalarType
-> (Int -> ScalarType -> Int)
-> (ScalarType -> Int)
-> Hashable ScalarType
Int -> ScalarType -> Int
ScalarType -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ScalarType -> Int
hashWithSalt :: Int -> ScalarType -> Int
$chash :: ScalarType -> Int
hash :: ScalarType -> Int
Hashable, ScalarType -> ()
(ScalarType -> ()) -> NFData ScalarType
forall a. (a -> ()) -> NFData a
$crnf :: ScalarType -> ()
rnf :: ScalarType -> ()
NFData)
  deriving newtype (FromJSONKeyFunction [ScalarType]
FromJSONKeyFunction ScalarType
FromJSONKeyFunction ScalarType
-> FromJSONKeyFunction [ScalarType] -> FromJSONKey ScalarType
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
$cfromJSONKey :: FromJSONKeyFunction ScalarType
fromJSONKey :: FromJSONKeyFunction ScalarType
$cfromJSONKeyList :: FromJSONKeyFunction [ScalarType]
fromJSONKeyList :: FromJSONKeyFunction [ScalarType]
FromJSONKey, ToJSONKeyFunction [ScalarType]
ToJSONKeyFunction ScalarType
ToJSONKeyFunction ScalarType
-> ToJSONKeyFunction [ScalarType] -> ToJSONKey ScalarType
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
$ctoJSONKey :: ToJSONKeyFunction ScalarType
toJSONKey :: ToJSONKeyFunction ScalarType
$ctoJSONKeyList :: ToJSONKeyFunction [ScalarType]
toJSONKeyList :: ToJSONKeyFunction [ScalarType]
ToJSONKey)
  deriving (Value -> Parser [ScalarType]
Value -> Parser ScalarType
(Value -> Parser ScalarType)
-> (Value -> Parser [ScalarType]) -> FromJSON ScalarType
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ScalarType
parseJSON :: Value -> Parser ScalarType
$cparseJSONList :: Value -> Parser [ScalarType]
parseJSONList :: Value -> Parser [ScalarType]
FromJSON, [ScalarType] -> Value
[ScalarType] -> Encoding
ScalarType -> Value
ScalarType -> Encoding
(ScalarType -> Value)
-> (ScalarType -> Encoding)
-> ([ScalarType] -> Value)
-> ([ScalarType] -> Encoding)
-> ToJSON ScalarType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ScalarType -> Value
toJSON :: ScalarType -> Value
$ctoEncoding :: ScalarType -> Encoding
toEncoding :: ScalarType -> Encoding
$ctoJSONList :: [ScalarType] -> Value
toJSONList :: [ScalarType] -> Value
$ctoEncodingList :: [ScalarType] -> Encoding
toEncodingList :: [ScalarType] -> Encoding
ToJSON) via AC.Autodocodec ScalarType

instance HasCodec ScalarType where
  codec :: JSONCodec ScalarType
codec = Text -> JSONCodec ScalarType -> JSONCodec ScalarType
forall input output.
Text -> ValueCodec input output -> ValueCodec input output
AC.named Text
"ScalarType" (JSONCodec ScalarType -> JSONCodec ScalarType)
-> JSONCodec ScalarType -> JSONCodec ScalarType
forall a b. (a -> b) -> a -> b
$ (Text -> ScalarType)
-> (ScalarType -> Text)
-> Codec Value Text Text
-> JSONCodec ScalarType
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
AC.dimapCodec Text -> ScalarType
ScalarType ScalarType -> Text
unScalarType Codec Value Text Text
forall value. HasCodec value => JSONCodec value
codec

instance ToTxt ScalarType where
  toTxt :: ScalarType -> Text
toTxt (ScalarType Text
name) = Text
name

instance ToErrorValue ScalarType where
  toErrorValue :: ScalarType -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (ScalarType -> Text) -> ScalarType -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ScalarType -> Text
forall a. ToTxt a => a -> Text
toTxt

instance Witch.From ScalarType API.ScalarType where
  from :: ScalarType -> ScalarType
from (ScalarType Text
name) = Text -> ScalarType
API.ScalarType Text
name

instance Witch.From API.ScalarType ScalarType where
  from :: ScalarType -> ScalarType
from (API.ScalarType Text
name) = Text -> ScalarType
ScalarType Text
name

fromGQLType :: GQL.Name -> API.ScalarType
fromGQLType :: Name -> ScalarType
fromGQLType Name
typeName =
  Text -> ScalarType
API.ScalarType (Text -> ScalarType) -> Text -> ScalarType
forall a b. (a -> b) -> a -> b
$ Name -> Text
GQL.unName Name
typeName

--------------------------------------------------------------------------------

-- | This type captures backend-specific "extra" information about tables
-- and is used on types like 'DBTableMetadata'
data ExtraTableMetadata = ExtraTableMetadata
  { ExtraTableMetadata -> TableType
_etmTableType :: API.TableType,
    ExtraTableMetadata -> HashMap ColumnName ExtraColumnMetadata
_etmExtraColumnMetadata :: HashMap ColumnName ExtraColumnMetadata
  }
  deriving stock (ExtraTableMetadata -> ExtraTableMetadata -> Bool
(ExtraTableMetadata -> ExtraTableMetadata -> Bool)
-> (ExtraTableMetadata -> ExtraTableMetadata -> Bool)
-> Eq ExtraTableMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExtraTableMetadata -> ExtraTableMetadata -> Bool
== :: ExtraTableMetadata -> ExtraTableMetadata -> Bool
$c/= :: ExtraTableMetadata -> ExtraTableMetadata -> Bool
/= :: ExtraTableMetadata -> ExtraTableMetadata -> Bool
Eq, Int -> ExtraTableMetadata -> ShowS
[ExtraTableMetadata] -> ShowS
ExtraTableMetadata -> String
(Int -> ExtraTableMetadata -> ShowS)
-> (ExtraTableMetadata -> String)
-> ([ExtraTableMetadata] -> ShowS)
-> Show ExtraTableMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExtraTableMetadata -> ShowS
showsPrec :: Int -> ExtraTableMetadata -> ShowS
$cshow :: ExtraTableMetadata -> String
show :: ExtraTableMetadata -> String
$cshowList :: [ExtraTableMetadata] -> ShowS
showList :: [ExtraTableMetadata] -> ShowS
Show, (forall x. ExtraTableMetadata -> Rep ExtraTableMetadata x)
-> (forall x. Rep ExtraTableMetadata x -> ExtraTableMetadata)
-> Generic ExtraTableMetadata
forall x. Rep ExtraTableMetadata x -> ExtraTableMetadata
forall x. ExtraTableMetadata -> Rep ExtraTableMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ExtraTableMetadata -> Rep ExtraTableMetadata x
from :: forall x. ExtraTableMetadata -> Rep ExtraTableMetadata x
$cto :: forall x. Rep ExtraTableMetadata x -> ExtraTableMetadata
to :: forall x. Rep ExtraTableMetadata x -> ExtraTableMetadata
Generic)
  deriving anyclass (Value -> Parser [ExtraTableMetadata]
Value -> Parser ExtraTableMetadata
(Value -> Parser ExtraTableMetadata)
-> (Value -> Parser [ExtraTableMetadata])
-> FromJSON ExtraTableMetadata
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ExtraTableMetadata
parseJSON :: Value -> Parser ExtraTableMetadata
$cparseJSONList :: Value -> Parser [ExtraTableMetadata]
parseJSONList :: Value -> Parser [ExtraTableMetadata]
FromJSON, Eq ExtraTableMetadata
Eq ExtraTableMetadata
-> (Int -> ExtraTableMetadata -> Int)
-> (ExtraTableMetadata -> Int)
-> Hashable ExtraTableMetadata
Int -> ExtraTableMetadata -> Int
ExtraTableMetadata -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ExtraTableMetadata -> Int
hashWithSalt :: Int -> ExtraTableMetadata -> Int
$chash :: ExtraTableMetadata -> Int
hash :: ExtraTableMetadata -> Int
Hashable, ExtraTableMetadata -> ()
(ExtraTableMetadata -> ()) -> NFData ExtraTableMetadata
forall a. (a -> ()) -> NFData a
$crnf :: ExtraTableMetadata -> ()
rnf :: ExtraTableMetadata -> ()
NFData, [ExtraTableMetadata] -> Value
[ExtraTableMetadata] -> Encoding
ExtraTableMetadata -> Value
ExtraTableMetadata -> Encoding
(ExtraTableMetadata -> Value)
-> (ExtraTableMetadata -> Encoding)
-> ([ExtraTableMetadata] -> Value)
-> ([ExtraTableMetadata] -> Encoding)
-> ToJSON ExtraTableMetadata
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ExtraTableMetadata -> Value
toJSON :: ExtraTableMetadata -> Value
$ctoEncoding :: ExtraTableMetadata -> Encoding
toEncoding :: ExtraTableMetadata -> Encoding
$ctoJSONList :: [ExtraTableMetadata] -> Value
toJSONList :: [ExtraTableMetadata] -> Value
$ctoEncodingList :: [ExtraTableMetadata] -> Encoding
toEncodingList :: [ExtraTableMetadata] -> Encoding
ToJSON)

data ExtraColumnMetadata = ExtraColumnMetadata
  {ExtraColumnMetadata -> Maybe ColumnValueGenerationStrategy
_ecmValueGenerated :: Maybe API.ColumnValueGenerationStrategy}
  deriving stock (ExtraColumnMetadata -> ExtraColumnMetadata -> Bool
(ExtraColumnMetadata -> ExtraColumnMetadata -> Bool)
-> (ExtraColumnMetadata -> ExtraColumnMetadata -> Bool)
-> Eq ExtraColumnMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ExtraColumnMetadata -> ExtraColumnMetadata -> Bool
== :: ExtraColumnMetadata -> ExtraColumnMetadata -> Bool
$c/= :: ExtraColumnMetadata -> ExtraColumnMetadata -> Bool
/= :: ExtraColumnMetadata -> ExtraColumnMetadata -> Bool
Eq, Int -> ExtraColumnMetadata -> ShowS
[ExtraColumnMetadata] -> ShowS
ExtraColumnMetadata -> String
(Int -> ExtraColumnMetadata -> ShowS)
-> (ExtraColumnMetadata -> String)
-> ([ExtraColumnMetadata] -> ShowS)
-> Show ExtraColumnMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExtraColumnMetadata -> ShowS
showsPrec :: Int -> ExtraColumnMetadata -> ShowS
$cshow :: ExtraColumnMetadata -> String
show :: ExtraColumnMetadata -> String
$cshowList :: [ExtraColumnMetadata] -> ShowS
showList :: [ExtraColumnMetadata] -> ShowS
Show, (forall x. ExtraColumnMetadata -> Rep ExtraColumnMetadata x)
-> (forall x. Rep ExtraColumnMetadata x -> ExtraColumnMetadata)
-> Generic ExtraColumnMetadata
forall x. Rep ExtraColumnMetadata x -> ExtraColumnMetadata
forall x. ExtraColumnMetadata -> Rep ExtraColumnMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ExtraColumnMetadata -> Rep ExtraColumnMetadata x
from :: forall x. ExtraColumnMetadata -> Rep ExtraColumnMetadata x
$cto :: forall x. Rep ExtraColumnMetadata x -> ExtraColumnMetadata
to :: forall x. Rep ExtraColumnMetadata x -> ExtraColumnMetadata
Generic)
  deriving anyclass (Value -> Parser [ExtraColumnMetadata]
Value -> Parser ExtraColumnMetadata
(Value -> Parser ExtraColumnMetadata)
-> (Value -> Parser [ExtraColumnMetadata])
-> FromJSON ExtraColumnMetadata
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser ExtraColumnMetadata
parseJSON :: Value -> Parser ExtraColumnMetadata
$cparseJSONList :: Value -> Parser [ExtraColumnMetadata]
parseJSONList :: Value -> Parser [ExtraColumnMetadata]
FromJSON, Eq ExtraColumnMetadata
Eq ExtraColumnMetadata
-> (Int -> ExtraColumnMetadata -> Int)
-> (ExtraColumnMetadata -> Int)
-> Hashable ExtraColumnMetadata
Int -> ExtraColumnMetadata -> Int
ExtraColumnMetadata -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> ExtraColumnMetadata -> Int
hashWithSalt :: Int -> ExtraColumnMetadata -> Int
$chash :: ExtraColumnMetadata -> Int
hash :: ExtraColumnMetadata -> Int
Hashable, ExtraColumnMetadata -> ()
(ExtraColumnMetadata -> ()) -> NFData ExtraColumnMetadata
forall a. (a -> ()) -> NFData a
$crnf :: ExtraColumnMetadata -> ()
rnf :: ExtraColumnMetadata -> ()
NFData, [ExtraColumnMetadata] -> Value
[ExtraColumnMetadata] -> Encoding
ExtraColumnMetadata -> Value
ExtraColumnMetadata -> Encoding
(ExtraColumnMetadata -> Value)
-> (ExtraColumnMetadata -> Encoding)
-> ([ExtraColumnMetadata] -> Value)
-> ([ExtraColumnMetadata] -> Encoding)
-> ToJSON ExtraColumnMetadata
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: ExtraColumnMetadata -> Value
toJSON :: ExtraColumnMetadata -> Value
$ctoEncoding :: ExtraColumnMetadata -> Encoding
toEncoding :: ExtraColumnMetadata -> Encoding
$ctoJSONList :: [ExtraColumnMetadata] -> Value
toJSONList :: [ExtraColumnMetadata] -> Value
$ctoEncodingList :: [ExtraColumnMetadata] -> Encoding
toEncodingList :: [ExtraColumnMetadata] -> Encoding
ToJSON)

--------------------------------------------------------------------------------

$(makeLenses ''SourceConfig)

instance Has API.ScalarTypesCapabilities SourceConfig where
  hasLens :: Lens SourceConfig ScalarTypesCapabilities
hasLens = (Capabilities -> f Capabilities) -> SourceConfig -> f SourceConfig
Lens' SourceConfig Capabilities
scCapabilities ((Capabilities -> f Capabilities)
 -> SourceConfig -> f SourceConfig)
-> ((ScalarTypesCapabilities -> f ScalarTypesCapabilities)
    -> Capabilities -> f Capabilities)
-> (ScalarTypesCapabilities -> f ScalarTypesCapabilities)
-> SourceConfig
-> f SourceConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ScalarTypesCapabilities -> f ScalarTypesCapabilities)
-> Capabilities -> f Capabilities
Lens' Capabilities ScalarTypesCapabilities
API.cScalarTypes