module Hasura.RemoteSchema.Metadata.Base
( RemoteSchemaName (..),
)
where
import Autodocodec (HasCodec (codec), dimapCodec)
import Data.Aeson qualified as J
import Data.Text.Extended
import Data.Text.NonEmpty
import Database.PG.Query qualified as PG
import Hasura.Prelude
newtype RemoteSchemaName = RemoteSchemaName
{RemoteSchemaName -> NonEmptyText
unRemoteSchemaName :: NonEmptyText}
deriving
( Int -> RemoteSchemaName -> ShowS
[RemoteSchemaName] -> ShowS
RemoteSchemaName -> String
(Int -> RemoteSchemaName -> ShowS)
-> (RemoteSchemaName -> String)
-> ([RemoteSchemaName] -> ShowS)
-> Show RemoteSchemaName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RemoteSchemaName -> ShowS
showsPrec :: Int -> RemoteSchemaName -> ShowS
$cshow :: RemoteSchemaName -> String
show :: RemoteSchemaName -> String
$cshowList :: [RemoteSchemaName] -> ShowS
showList :: [RemoteSchemaName] -> ShowS
Show,
RemoteSchemaName -> RemoteSchemaName -> Bool
(RemoteSchemaName -> RemoteSchemaName -> Bool)
-> (RemoteSchemaName -> RemoteSchemaName -> Bool)
-> Eq RemoteSchemaName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RemoteSchemaName -> RemoteSchemaName -> Bool
== :: RemoteSchemaName -> RemoteSchemaName -> Bool
$c/= :: RemoteSchemaName -> RemoteSchemaName -> Bool
/= :: RemoteSchemaName -> RemoteSchemaName -> Bool
Eq,
Eq RemoteSchemaName
Eq RemoteSchemaName
-> (RemoteSchemaName -> RemoteSchemaName -> Ordering)
-> (RemoteSchemaName -> RemoteSchemaName -> Bool)
-> (RemoteSchemaName -> RemoteSchemaName -> Bool)
-> (RemoteSchemaName -> RemoteSchemaName -> Bool)
-> (RemoteSchemaName -> RemoteSchemaName -> Bool)
-> (RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName)
-> (RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName)
-> Ord RemoteSchemaName
RemoteSchemaName -> RemoteSchemaName -> Bool
RemoteSchemaName -> RemoteSchemaName -> Ordering
RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName
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 :: RemoteSchemaName -> RemoteSchemaName -> Ordering
compare :: RemoteSchemaName -> RemoteSchemaName -> Ordering
$c< :: RemoteSchemaName -> RemoteSchemaName -> Bool
< :: RemoteSchemaName -> RemoteSchemaName -> Bool
$c<= :: RemoteSchemaName -> RemoteSchemaName -> Bool
<= :: RemoteSchemaName -> RemoteSchemaName -> Bool
$c> :: RemoteSchemaName -> RemoteSchemaName -> Bool
> :: RemoteSchemaName -> RemoteSchemaName -> Bool
$c>= :: RemoteSchemaName -> RemoteSchemaName -> Bool
>= :: RemoteSchemaName -> RemoteSchemaName -> Bool
$cmax :: RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName
max :: RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName
$cmin :: RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName
min :: RemoteSchemaName -> RemoteSchemaName -> RemoteSchemaName
Ord,
Eq RemoteSchemaName
Eq RemoteSchemaName
-> (Int -> RemoteSchemaName -> Int)
-> (RemoteSchemaName -> Int)
-> Hashable RemoteSchemaName
Int -> RemoteSchemaName -> Int
RemoteSchemaName -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> RemoteSchemaName -> Int
hashWithSalt :: Int -> RemoteSchemaName -> Int
$chash :: RemoteSchemaName -> Int
hash :: RemoteSchemaName -> Int
Hashable,
[RemoteSchemaName] -> Value
[RemoteSchemaName] -> Encoding
RemoteSchemaName -> Value
RemoteSchemaName -> Encoding
(RemoteSchemaName -> Value)
-> (RemoteSchemaName -> Encoding)
-> ([RemoteSchemaName] -> Value)
-> ([RemoteSchemaName] -> Encoding)
-> ToJSON RemoteSchemaName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: RemoteSchemaName -> Value
toJSON :: RemoteSchemaName -> Value
$ctoEncoding :: RemoteSchemaName -> Encoding
toEncoding :: RemoteSchemaName -> Encoding
$ctoJSONList :: [RemoteSchemaName] -> Value
toJSONList :: [RemoteSchemaName] -> Value
$ctoEncodingList :: [RemoteSchemaName] -> Encoding
toEncodingList :: [RemoteSchemaName] -> Encoding
J.ToJSON,
ToJSONKeyFunction [RemoteSchemaName]
ToJSONKeyFunction RemoteSchemaName
ToJSONKeyFunction RemoteSchemaName
-> ToJSONKeyFunction [RemoteSchemaName]
-> ToJSONKey RemoteSchemaName
forall a.
ToJSONKeyFunction a -> ToJSONKeyFunction [a] -> ToJSONKey a
$ctoJSONKey :: ToJSONKeyFunction RemoteSchemaName
toJSONKey :: ToJSONKeyFunction RemoteSchemaName
$ctoJSONKeyList :: ToJSONKeyFunction [RemoteSchemaName]
toJSONKeyList :: ToJSONKeyFunction [RemoteSchemaName]
J.ToJSONKey,
Value -> Parser [RemoteSchemaName]
Value -> Parser RemoteSchemaName
(Value -> Parser RemoteSchemaName)
-> (Value -> Parser [RemoteSchemaName])
-> FromJSON RemoteSchemaName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser RemoteSchemaName
parseJSON :: Value -> Parser RemoteSchemaName
$cparseJSONList :: Value -> Parser [RemoteSchemaName]
parseJSONList :: Value -> Parser [RemoteSchemaName]
J.FromJSON,
FromJSONKeyFunction [RemoteSchemaName]
FromJSONKeyFunction RemoteSchemaName
FromJSONKeyFunction RemoteSchemaName
-> FromJSONKeyFunction [RemoteSchemaName]
-> FromJSONKey RemoteSchemaName
forall a.
FromJSONKeyFunction a -> FromJSONKeyFunction [a] -> FromJSONKey a
$cfromJSONKey :: FromJSONKeyFunction RemoteSchemaName
fromJSONKey :: FromJSONKeyFunction RemoteSchemaName
$cfromJSONKeyList :: FromJSONKeyFunction [RemoteSchemaName]
fromJSONKeyList :: FromJSONKeyFunction [RemoteSchemaName]
J.FromJSONKey,
RemoteSchemaName -> PrepArg
(RemoteSchemaName -> PrepArg) -> ToPrepArg RemoteSchemaName
forall a. (a -> PrepArg) -> ToPrepArg a
$ctoPrepVal :: RemoteSchemaName -> PrepArg
toPrepVal :: RemoteSchemaName -> PrepArg
PG.ToPrepArg,
Maybe ByteString -> Either Text RemoteSchemaName
(Maybe ByteString -> Either Text RemoteSchemaName)
-> FromCol RemoteSchemaName
forall a. (Maybe ByteString -> Either Text a) -> FromCol a
$cfromCol :: Maybe ByteString -> Either Text RemoteSchemaName
fromCol :: Maybe ByteString -> Either Text RemoteSchemaName
PG.FromCol,
RemoteSchemaName -> Text
(RemoteSchemaName -> Text) -> ToTxt RemoteSchemaName
forall a. (a -> Text) -> ToTxt a
$ctoTxt :: RemoteSchemaName -> Text
toTxt :: RemoteSchemaName -> Text
ToTxt,
RemoteSchemaName -> ()
(RemoteSchemaName -> ()) -> NFData RemoteSchemaName
forall a. (a -> ()) -> NFData a
$crnf :: RemoteSchemaName -> ()
rnf :: RemoteSchemaName -> ()
NFData,
(forall x. RemoteSchemaName -> Rep RemoteSchemaName x)
-> (forall x. Rep RemoteSchemaName x -> RemoteSchemaName)
-> Generic RemoteSchemaName
forall x. Rep RemoteSchemaName x -> RemoteSchemaName
forall x. RemoteSchemaName -> Rep RemoteSchemaName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RemoteSchemaName -> Rep RemoteSchemaName x
from :: forall x. RemoteSchemaName -> Rep RemoteSchemaName x
$cto :: forall x. Rep RemoteSchemaName x -> RemoteSchemaName
to :: forall x. Rep RemoteSchemaName x -> RemoteSchemaName
Generic
)
instance HasCodec RemoteSchemaName where
codec :: JSONCodec RemoteSchemaName
codec = (NonEmptyText -> RemoteSchemaName)
-> (RemoteSchemaName -> NonEmptyText)
-> Codec Value NonEmptyText NonEmptyText
-> JSONCodec RemoteSchemaName
forall oldOutput newOutput newInput oldInput context.
(oldOutput -> newOutput)
-> (newInput -> oldInput)
-> Codec context oldInput oldOutput
-> Codec context newInput newOutput
dimapCodec NonEmptyText -> RemoteSchemaName
RemoteSchemaName RemoteSchemaName -> NonEmptyText
unRemoteSchemaName Codec Value NonEmptyText NonEmptyText
forall value. HasCodec value => JSONCodec value
codec