{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
module Hasura.Table.Metadata
( ComputedFieldMetadata (..),
ComputedFields,
Permissions,
Relationships,
TableMetadata (..),
mkTableMeta,
tmArrayRelationships,
tmComputedFields,
tmConfiguration,
tmDeletePermissions,
tmApolloFederationConfig,
tmEventTriggers,
tmInsertPermissions,
tmIsEnum,
tmLogicalModel,
tmObjectRelationships,
tmRemoteRelationships,
tmSelectPermissions,
tmTable,
tmUpdatePermissions,
)
where
import Autodocodec hiding (object, (.=))
import Autodocodec qualified as AC
import Control.Lens hiding (set, (.=))
import Data.Aeson.KeyMap qualified as KM
import Data.Aeson.Types
import Data.HashMap.Strict.InsOrd.Autodocodec (sortedElemsCodec)
import Data.HashSet qualified as HS
import Data.List.Extended qualified as L
import Data.Text qualified as T
import Data.Text.Extended qualified as T
import Hasura.LogicalModel.Types
import Hasura.Prelude
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.BackendTag (backendPrefix)
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.ComputedField
import Hasura.RQL.Types.EventTrigger
import Hasura.RQL.Types.Permission
import Hasura.RQL.Types.Relationships.Local
import Hasura.RQL.Types.Relationships.Remote
import Hasura.RQL.Types.Roles
import Hasura.Table.Cache (TableConfig (..), emptyTableConfig)
parseListAsMap ::
(Hashable k, T.ToTxt k) =>
Text ->
(a -> k) ->
Parser [a] ->
Parser (InsOrdHashMap k a)
parseListAsMap :: forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
things a -> k
mapFn Parser [a]
listP = do
[a]
list <- Parser [a]
listP
let duplicates :: [k]
duplicates = HashSet k -> [k]
forall a. HashSet a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (HashSet k -> [k]) -> HashSet k -> [k]
forall a b. (a -> b) -> a -> b
$ [k] -> HashSet k
forall a. Hashable a => [a] -> HashSet a
L.duplicates ([k] -> HashSet k) -> [k] -> HashSet k
forall a b. (a -> b) -> a -> b
$ (a -> k) -> [a] -> [k]
forall a b. (a -> b) -> [a] -> [b]
map a -> k
mapFn [a]
list
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([k] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [k]
duplicates)
(Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
(String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack
(Text -> String) -> Text -> String
forall a b. (a -> b) -> a -> b
$ Text
"multiple declarations exist for the following "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
things
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
": "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [k] -> Text
forall t (f :: * -> *). (ToTxt t, Foldable f) => f t -> Text
T.commaSeparated [k]
duplicates
InsOrdHashMap k a -> Parser (InsOrdHashMap k a)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InsOrdHashMap k a -> Parser (InsOrdHashMap k a))
-> InsOrdHashMap k a -> Parser (InsOrdHashMap k a)
forall a b. (a -> b) -> a -> b
$ (a -> k) -> [a] -> InsOrdHashMap k a
forall k a. Hashable k => (a -> k) -> [a] -> InsOrdHashMap k a
oMapFromL a -> k
mapFn [a]
list
data ComputedFieldMetadata b = ComputedFieldMetadata
{ forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmName :: ComputedFieldName,
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldDefinition b
_cfmDefinition :: ComputedFieldDefinition b,
:: Comment
}
deriving ((forall x.
ComputedFieldMetadata b -> Rep (ComputedFieldMetadata b) x)
-> (forall x.
Rep (ComputedFieldMetadata b) x -> ComputedFieldMetadata b)
-> Generic (ComputedFieldMetadata b)
forall x.
Rep (ComputedFieldMetadata b) x -> ComputedFieldMetadata b
forall x.
ComputedFieldMetadata b -> Rep (ComputedFieldMetadata b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (b :: BackendType) x.
Rep (ComputedFieldMetadata b) x -> ComputedFieldMetadata b
forall (b :: BackendType) x.
ComputedFieldMetadata b -> Rep (ComputedFieldMetadata b) x
$cfrom :: forall (b :: BackendType) x.
ComputedFieldMetadata b -> Rep (ComputedFieldMetadata b) x
from :: forall x.
ComputedFieldMetadata b -> Rep (ComputedFieldMetadata b) x
$cto :: forall (b :: BackendType) x.
Rep (ComputedFieldMetadata b) x -> ComputedFieldMetadata b
to :: forall x.
Rep (ComputedFieldMetadata b) x -> ComputedFieldMetadata b
Generic)
deriving instance (Backend b) => Show (ComputedFieldMetadata b)
deriving instance (Backend b) => Eq (ComputedFieldMetadata b)
instance (Backend b) => HasCodec (ComputedFieldMetadata b) where
codec :: JSONCodec (ComputedFieldMetadata b)
codec =
Text
-> ObjectCodec (ComputedFieldMetadata b) (ComputedFieldMetadata b)
-> JSONCodec (ComputedFieldMetadata b)
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object (forall (b :: BackendType). HasTag b => Text
backendPrefix @b Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"ComputedFieldMetadata")
(ObjectCodec (ComputedFieldMetadata b) (ComputedFieldMetadata b)
-> JSONCodec (ComputedFieldMetadata b))
-> ObjectCodec (ComputedFieldMetadata b) (ComputedFieldMetadata b)
-> JSONCodec (ComputedFieldMetadata b)
forall a b. (a -> b) -> a -> b
$ ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b
forall (b :: BackendType).
ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b
ComputedFieldMetadata
(ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
-> Codec Object (ComputedFieldMetadata b) ComputedFieldName
-> Codec
Object
(ComputedFieldMetadata b)
(ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ObjectCodec ComputedFieldName ComputedFieldName
forall output. HasCodec output => Text -> ObjectCodec output output
requiredField' Text
"name"
ObjectCodec ComputedFieldName ComputedFieldName
-> (ComputedFieldMetadata b -> ComputedFieldName)
-> Codec Object (ComputedFieldMetadata b) ComputedFieldName
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ComputedFieldMetadata b -> ComputedFieldName
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmName
Codec
Object
(ComputedFieldMetadata b)
(ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
-> Codec
Object (ComputedFieldMetadata b) (ComputedFieldDefinition b)
-> Codec
Object
(ComputedFieldMetadata b)
(Comment -> ComputedFieldMetadata b)
forall a b.
Codec Object (ComputedFieldMetadata b) (a -> b)
-> Codec Object (ComputedFieldMetadata b) a
-> Codec Object (ComputedFieldMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> ObjectCodec
(ComputedFieldDefinition b) (ComputedFieldDefinition b)
forall output. HasCodec output => Text -> ObjectCodec output output
requiredField' Text
"definition"
ObjectCodec (ComputedFieldDefinition b) (ComputedFieldDefinition b)
-> (ComputedFieldMetadata b -> ComputedFieldDefinition b)
-> Codec
Object (ComputedFieldMetadata b) (ComputedFieldDefinition b)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ComputedFieldMetadata b -> ComputedFieldDefinition b
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldDefinition b
_cfmDefinition
Codec
Object
(ComputedFieldMetadata b)
(Comment -> ComputedFieldMetadata b)
-> Codec Object (ComputedFieldMetadata b) Comment
-> ObjectCodec (ComputedFieldMetadata b) (ComputedFieldMetadata b)
forall a b.
Codec Object (ComputedFieldMetadata b) (a -> b)
-> Codec Object (ComputedFieldMetadata b) a
-> Codec Object (ComputedFieldMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Comment -> ObjectCodec Comment Comment
forall output.
(Eq output, HasCodec output) =>
Text -> output -> ObjectCodec output output
optionalFieldWithOmittedDefault' Text
"comment" Comment
Automatic
ObjectCodec Comment Comment
-> (ComputedFieldMetadata b -> Comment)
-> Codec Object (ComputedFieldMetadata b) Comment
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
AC..= ComputedFieldMetadata b -> Comment
forall (b :: BackendType). ComputedFieldMetadata b -> Comment
_cfmComment
instance (Backend b) => ToJSON (ComputedFieldMetadata b) where
toJSON :: ComputedFieldMetadata b -> Value
toJSON ComputedFieldMetadata {Comment
ComputedFieldName
ComputedFieldDefinition b
_cfmName :: forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmDefinition :: forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldDefinition b
_cfmComment :: forall (b :: BackendType). ComputedFieldMetadata b -> Comment
_cfmName :: ComputedFieldName
_cfmDefinition :: ComputedFieldDefinition b
_cfmComment :: Comment
..} =
[Pair] -> Value
object
([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$ [ Key
"name" Key -> ComputedFieldName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= ComputedFieldName
_cfmName,
Key
"definition" Key -> ComputedFieldDefinition b -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= ComputedFieldDefinition b
_cfmDefinition,
Key
"comment" Key -> Comment -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
.= Comment
_cfmComment
]
instance (Backend b) => FromJSON (ComputedFieldMetadata b) where
parseJSON :: Value -> Parser (ComputedFieldMetadata b)
parseJSON = String
-> (Object -> Parser (ComputedFieldMetadata b))
-> Value
-> Parser (ComputedFieldMetadata b)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ComputedFieldMetadata" ((Object -> Parser (ComputedFieldMetadata b))
-> Value -> Parser (ComputedFieldMetadata b))
-> (Object -> Parser (ComputedFieldMetadata b))
-> Value
-> Parser (ComputedFieldMetadata b)
forall a b. (a -> b) -> a -> b
$ \Object
obj ->
ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b
forall (b :: BackendType).
ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b
ComputedFieldMetadata
(ComputedFieldName
-> ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
-> Parser ComputedFieldName
-> Parser
(ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
obj
Object -> Key -> Parser ComputedFieldName
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
Parser
(ComputedFieldDefinition b -> Comment -> ComputedFieldMetadata b)
-> Parser (ComputedFieldDefinition b)
-> Parser (Comment -> ComputedFieldMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj
Object -> Key -> Parser (ComputedFieldDefinition b)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"definition"
Parser (Comment -> ComputedFieldMetadata b)
-> Parser Comment -> Parser (ComputedFieldMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
obj
Object -> Key -> Parser (Maybe Comment)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"comment"
Parser (Maybe Comment) -> Comment -> Parser Comment
forall a. Parser (Maybe a) -> a -> Parser a
.!= Comment
Automatic
type Relationships a = InsOrdHashMap RelName a
type ComputedFields b = InsOrdHashMap ComputedFieldName (ComputedFieldMetadata b)
type RemoteRelationships = InsOrdHashMap RelName RemoteRelationship
type Permissions a = InsOrdHashMap RoleName a
type EventTriggers b = InsOrdHashMap TriggerName (EventTriggerConf b)
data TableMetadata b = TableMetadata
{ forall (b :: BackendType). TableMetadata b -> TableName b
_tmTable :: TableName b,
forall (b :: BackendType). TableMetadata b -> Bool
_tmIsEnum :: Bool,
forall (b :: BackendType). TableMetadata b -> TableConfig b
_tmConfiguration :: TableConfig b,
forall (b :: BackendType).
TableMetadata b -> Relationships (ObjRelDef b)
_tmObjectRelationships :: Relationships (ObjRelDef b),
forall (b :: BackendType).
TableMetadata b -> Relationships (ArrRelDef b)
_tmArrayRelationships :: Relationships (ArrRelDef b),
forall (b :: BackendType). TableMetadata b -> ComputedFields b
_tmComputedFields :: ComputedFields b,
forall (b :: BackendType). TableMetadata b -> RemoteRelationships
_tmRemoteRelationships :: RemoteRelationships,
forall (b :: BackendType).
TableMetadata b -> Permissions (InsPermDef b)
_tmInsertPermissions :: Permissions (InsPermDef b),
forall (b :: BackendType).
TableMetadata b -> Permissions (SelPermDef b)
_tmSelectPermissions :: Permissions (SelPermDef b),
forall (b :: BackendType).
TableMetadata b -> Permissions (UpdPermDef b)
_tmUpdatePermissions :: Permissions (UpdPermDef b),
forall (b :: BackendType).
TableMetadata b -> Permissions (DelPermDef b)
_tmDeletePermissions :: Permissions (DelPermDef b),
forall (b :: BackendType). TableMetadata b -> EventTriggers b
_tmEventTriggers :: EventTriggers b,
forall (b :: BackendType).
TableMetadata b -> Maybe ApolloFederationConfig
_tmApolloFederationConfig :: Maybe ApolloFederationConfig,
forall (b :: BackendType).
TableMetadata b -> Maybe LogicalModelName
_tmLogicalModel :: Maybe LogicalModelName
}
deriving ((forall x. TableMetadata b -> Rep (TableMetadata b) x)
-> (forall x. Rep (TableMetadata b) x -> TableMetadata b)
-> Generic (TableMetadata b)
forall x. Rep (TableMetadata b) x -> TableMetadata b
forall x. TableMetadata b -> Rep (TableMetadata b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (b :: BackendType) x.
Rep (TableMetadata b) x -> TableMetadata b
forall (b :: BackendType) x.
TableMetadata b -> Rep (TableMetadata b) x
$cfrom :: forall (b :: BackendType) x.
TableMetadata b -> Rep (TableMetadata b) x
from :: forall x. TableMetadata b -> Rep (TableMetadata b) x
$cto :: forall (b :: BackendType) x.
Rep (TableMetadata b) x -> TableMetadata b
to :: forall x. Rep (TableMetadata b) x -> TableMetadata b
Generic)
deriving instance (Backend b) => Show (TableMetadata b)
deriving instance (Backend b) => Eq (TableMetadata b)
instance (Backend b) => ToJSON (TableMetadata b) where
toJSON :: TableMetadata b -> Value
toJSON = Options -> TableMetadata b -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
hasuraJSON
instance (Backend b) => HasCodec (TableMetadata b) where
codec :: JSONCodec (TableMetadata b)
codec =
Text -> JSONCodec (TableMetadata b) -> JSONCodec (TableMetadata b)
forall input output.
Text -> ValueCodec input output -> ValueCodec input output
CommentCodec Text
"Representation of a table in metadata, 'tables.yaml' and 'metadata.json'"
(JSONCodec (TableMetadata b) -> JSONCodec (TableMetadata b))
-> JSONCodec (TableMetadata b) -> JSONCodec (TableMetadata b)
forall a b. (a -> b) -> a -> b
$ Text
-> ObjectCodec (TableMetadata b) (TableMetadata b)
-> JSONCodec (TableMetadata b)
forall input output.
Text -> ObjectCodec input output -> ValueCodec input output
AC.object (forall (b :: BackendType). HasTag b => Text
backendPrefix @b Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"TableMetadata")
(ObjectCodec (TableMetadata b) (TableMetadata b)
-> JSONCodec (TableMetadata b))
-> ObjectCodec (TableMetadata b) (TableMetadata b)
-> JSONCodec (TableMetadata b)
forall a b. (a -> b) -> a -> b
$ TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
forall (b :: BackendType).
TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
TableMetadata
(TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (TableName b)
-> Codec
Object
(TableMetadata b)
(Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ObjectCodec (TableName b) (TableName b)
forall output. HasCodec output => Text -> ObjectCodec output output
requiredField' Text
"table"
ObjectCodec (TableName b) (TableName b)
-> (TableMetadata b -> TableName b)
-> Codec Object (TableMetadata b) (TableName b)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> TableName b
forall (b :: BackendType). TableMetadata b -> TableName b
_tmTable
Codec
Object
(TableMetadata b)
(Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) Bool
-> Codec
Object
(TableMetadata b)
(TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text -> Bool -> ObjectCodec Bool Bool
forall output.
(Eq output, HasCodec output) =>
Text -> output -> ObjectCodec output output
optionalFieldWithOmittedDefault' Text
"is_enum" Bool
False
ObjectCodec Bool Bool
-> (TableMetadata b -> Bool) -> Codec Object (TableMetadata b) Bool
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Bool
forall (b :: BackendType). TableMetadata b -> Bool
_tmIsEnum
Codec
Object
(TableMetadata b)
(TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (TableConfig b)
-> Codec
Object
(TableMetadata b)
(Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> TableConfig b
-> Text
-> ObjectCodec (TableConfig b) (TableConfig b)
forall output.
(Eq output, HasCodec output) =>
Text -> output -> Text -> ObjectCodec output output
optionalFieldWithOmittedDefault Text
"configuration" TableConfig b
forall (b :: BackendType). TableConfig b
emptyTableConfig Text
configDoc
ObjectCodec (TableConfig b) (TableConfig b)
-> (TableMetadata b -> TableConfig b)
-> Codec Object (TableMetadata b) (TableConfig b)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> TableConfig b
forall (b :: BackendType). TableMetadata b -> TableConfig b
_tmConfiguration
Codec
Object
(TableMetadata b)
(Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Relationships (ObjRelDef b))
-> Codec
Object
(TableMetadata b)
(Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ObjRelDef b -> RelName)
-> ObjectCodec
(Relationships (ObjRelDef b)) (Relationships (ObjRelDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"object_relationships" ObjRelDef b -> RelName
forall a. RelDef a -> RelName
_rdName
ObjectCodec
(Relationships (ObjRelDef b)) (Relationships (ObjRelDef b))
-> (TableMetadata b -> Relationships (ObjRelDef b))
-> Codec Object (TableMetadata b) (Relationships (ObjRelDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Relationships (ObjRelDef b)
forall (b :: BackendType).
TableMetadata b -> Relationships (ObjRelDef b)
_tmObjectRelationships
Codec
Object
(TableMetadata b)
(Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Relationships (ArrRelDef b))
-> Codec
Object
(TableMetadata b)
(ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ArrRelDef b -> RelName)
-> ObjectCodec
(Relationships (ArrRelDef b)) (Relationships (ArrRelDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"array_relationships" ArrRelDef b -> RelName
forall a. RelDef a -> RelName
_rdName
ObjectCodec
(Relationships (ArrRelDef b)) (Relationships (ArrRelDef b))
-> (TableMetadata b -> Relationships (ArrRelDef b))
-> Codec Object (TableMetadata b) (Relationships (ArrRelDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Relationships (ArrRelDef b)
forall (b :: BackendType).
TableMetadata b -> Relationships (ArrRelDef b)
_tmArrayRelationships
Codec
Object
(TableMetadata b)
(ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (ComputedFields b)
-> Codec
Object
(TableMetadata b)
(RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ComputedFieldMetadata b -> ComputedFieldName)
-> ObjectCodec (ComputedFields b) (ComputedFields b)
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"computed_fields" ComputedFieldMetadata b -> ComputedFieldName
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmName
ObjectCodec (ComputedFields b) (ComputedFields b)
-> (TableMetadata b -> ComputedFields b)
-> Codec Object (TableMetadata b) (ComputedFields b)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> ComputedFields b
forall (b :: BackendType). TableMetadata b -> ComputedFields b
_tmComputedFields
Codec
Object
(TableMetadata b)
(RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) RemoteRelationships
-> Codec
Object
(TableMetadata b)
(Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (RemoteRelationshipG RemoteRelationshipDefinition -> RelName)
-> ObjectCodec RemoteRelationships RemoteRelationships
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"remote_relationships" RemoteRelationshipG RemoteRelationshipDefinition -> RelName
forall definition. RemoteRelationshipG definition -> RelName
_rrName
ObjectCodec RemoteRelationships RemoteRelationships
-> (TableMetadata b -> RemoteRelationships)
-> Codec Object (TableMetadata b) RemoteRelationships
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> RemoteRelationships
forall (b :: BackendType). TableMetadata b -> RemoteRelationships
_tmRemoteRelationships
Codec
Object
(TableMetadata b)
(Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Permissions (InsPermDef b))
-> Codec
Object
(TableMetadata b)
(Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (InsPermDef b -> RoleName)
-> ObjectCodec
(Permissions (InsPermDef b)) (Permissions (InsPermDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"insert_permissions" InsPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole
ObjectCodec
(Permissions (InsPermDef b)) (Permissions (InsPermDef b))
-> (TableMetadata b -> Permissions (InsPermDef b))
-> Codec Object (TableMetadata b) (Permissions (InsPermDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Permissions (InsPermDef b)
forall (b :: BackendType).
TableMetadata b -> Permissions (InsPermDef b)
_tmInsertPermissions
Codec
Object
(TableMetadata b)
(Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Permissions (SelPermDef b))
-> Codec
Object
(TableMetadata b)
(Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (SelPermDef b -> RoleName)
-> ObjectCodec
(Permissions (SelPermDef b)) (Permissions (SelPermDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"select_permissions" SelPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole
ObjectCodec
(Permissions (SelPermDef b)) (Permissions (SelPermDef b))
-> (TableMetadata b -> Permissions (SelPermDef b))
-> Codec Object (TableMetadata b) (Permissions (SelPermDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Permissions (SelPermDef b)
forall (b :: BackendType).
TableMetadata b -> Permissions (SelPermDef b)
_tmSelectPermissions
Codec
Object
(TableMetadata b)
(Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Permissions (UpdPermDef b))
-> Codec
Object
(TableMetadata b)
(Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (UpdPermDef b -> RoleName)
-> ObjectCodec
(Permissions (UpdPermDef b)) (Permissions (UpdPermDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"update_permissions" UpdPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole
ObjectCodec
(Permissions (UpdPermDef b)) (Permissions (UpdPermDef b))
-> (TableMetadata b -> Permissions (UpdPermDef b))
-> Codec Object (TableMetadata b) (Permissions (UpdPermDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Permissions (UpdPermDef b)
forall (b :: BackendType).
TableMetadata b -> Permissions (UpdPermDef b)
_tmUpdatePermissions
Codec
Object
(TableMetadata b)
(Permissions (DelPermDef b)
-> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec Object (TableMetadata b) (Permissions (DelPermDef b))
-> Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (DelPermDef b -> RoleName)
-> ObjectCodec
(Permissions (DelPermDef b)) (Permissions (DelPermDef b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"delete_permissions" DelPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole
ObjectCodec
(Permissions (DelPermDef b)) (Permissions (DelPermDef b))
-> (TableMetadata b -> Permissions (DelPermDef b))
-> Codec Object (TableMetadata b) (Permissions (DelPermDef b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Permissions (DelPermDef b)
forall (b :: BackendType).
TableMetadata b -> Permissions (DelPermDef b)
_tmDeletePermissions
Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b)
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b))
-> Codec
Object
(TableMetadata b)
(Maybe ApolloFederationConfig
-> Maybe LogicalModelName -> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b))
eventTriggers
Codec
Object
(TableMetadata b)
(Maybe ApolloFederationConfig
-> Maybe LogicalModelName -> TableMetadata b)
-> Codec Object (TableMetadata b) (Maybe ApolloFederationConfig)
-> Codec
Object
(TableMetadata b)
(Maybe LogicalModelName -> TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> ObjectCodec
(Maybe ApolloFederationConfig) (Maybe ApolloFederationConfig)
forall output.
HasCodec output =>
Text -> ObjectCodec (Maybe output) (Maybe output)
optionalFieldOrNull' Text
"apollo_federation_config"
ObjectCodec
(Maybe ApolloFederationConfig) (Maybe ApolloFederationConfig)
-> (TableMetadata b -> Maybe ApolloFederationConfig)
-> Codec Object (TableMetadata b) (Maybe ApolloFederationConfig)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Maybe ApolloFederationConfig
forall (b :: BackendType).
TableMetadata b -> Maybe ApolloFederationConfig
_tmApolloFederationConfig
Codec
Object
(TableMetadata b)
(Maybe LogicalModelName -> TableMetadata b)
-> Codec Object (TableMetadata b) (Maybe LogicalModelName)
-> ObjectCodec (TableMetadata b) (TableMetadata b)
forall a b.
Codec Object (TableMetadata b) (a -> b)
-> Codec Object (TableMetadata b) a
-> Codec Object (TableMetadata b) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> ObjectCodec (Maybe LogicalModelName) (Maybe LogicalModelName)
forall output.
HasCodec output =>
Text -> ObjectCodec (Maybe output) (Maybe output)
optionalFieldOrNull' Text
"logical_model"
ObjectCodec (Maybe LogicalModelName) (Maybe LogicalModelName)
-> (TableMetadata b -> Maybe LogicalModelName)
-> Codec Object (TableMetadata b) (Maybe LogicalModelName)
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> Maybe LogicalModelName
forall (b :: BackendType).
TableMetadata b -> Maybe LogicalModelName
_tmLogicalModel
where
eventTriggers :: Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b))
eventTriggers = case forall (b :: BackendType).
Backend b =>
Maybe (XEventTriggers b, TriggerOnReplication)
defaultTriggerOnReplication @b of
Just (XEventTriggers b, TriggerOnReplication)
_ -> Text
-> (EventTriggerConf b -> TriggerName)
-> ObjectCodec
(InsOrdHashMap TriggerName (EventTriggerConf b))
(InsOrdHashMap TriggerName (EventTriggerConf b))
forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
"event_triggers" EventTriggerConf b -> TriggerName
forall (b :: BackendType). EventTriggerConf b -> TriggerName
etcName ObjectCodec
(InsOrdHashMap TriggerName (EventTriggerConf b))
(InsOrdHashMap TriggerName (EventTriggerConf b))
-> (TableMetadata b
-> InsOrdHashMap TriggerName (EventTriggerConf b))
-> Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b))
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
.== TableMetadata b -> InsOrdHashMap TriggerName (EventTriggerConf b)
forall (b :: BackendType). TableMetadata b -> EventTriggers b
_tmEventTriggers
Maybe (XEventTriggers b, TriggerOnReplication)
Nothing -> InsOrdHashMap TriggerName (EventTriggerConf b)
-> Codec
Object
(TableMetadata b)
(InsOrdHashMap TriggerName (EventTriggerConf b))
forall a. a -> Codec Object (TableMetadata b) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InsOrdHashMap TriggerName (EventTriggerConf b)
forall a. Monoid a => a
mempty
optSortedList ::
(HasCodec a, Eq a, Hashable k, Ord k, T.ToTxt k) =>
Text ->
(a -> k) ->
ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList :: forall a k.
(HasCodec a, Eq a, Hashable k, Ord k, ToTxt k) =>
Text
-> (a -> k) -> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
optSortedList Text
name a -> k
keyForElem =
Text
-> JSONCodec (InsOrdHashMap k a)
-> InsOrdHashMap k a
-> ObjectCodec (InsOrdHashMap k a) (InsOrdHashMap k a)
forall output.
Eq output =>
Text -> JSONCodec output -> output -> ObjectCodec output output
AC.optionalFieldWithOmittedDefaultWith' Text
name ((a -> k) -> JSONCodec (InsOrdHashMap k a)
forall a k.
(HasCodec a, Hashable k, Ord k, ToTxt k) =>
(a -> k) -> JSONCodec (InsOrdHashMap k a)
sortedElemsCodec a -> k
keyForElem) InsOrdHashMap k a
forall a. Monoid a => a
mempty
configDoc :: Text
configDoc =
[Text] -> Text
T.unlines
[ Text
"Configuration for the table/view",
Text
"",
Text
"https://hasura.io/docs/latest/graphql/core/api-reference/schema-metadata-api/table-view.html#table-config"
]
.== :: ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
(.==) = ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
forall oldInput output newInput.
ObjectCodec oldInput output
-> (newInput -> oldInput) -> ObjectCodec newInput output
(AC..=)
$(makeLenses ''TableMetadata)
mkTableMeta :: TableName b -> Bool -> TableConfig b -> TableMetadata b
mkTableMeta :: forall (b :: BackendType).
TableName b -> Bool -> TableConfig b -> TableMetadata b
mkTableMeta TableName b
qt Bool
isEnum TableConfig b
config =
TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
forall (b :: BackendType).
TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
TableMetadata
TableName b
qt
Bool
isEnum
TableConfig b
config
Relationships (ObjRelDef b)
forall a. Monoid a => a
mempty
Relationships (ArrRelDef b)
forall a. Monoid a => a
mempty
ComputedFields b
forall a. Monoid a => a
mempty
RemoteRelationships
forall a. Monoid a => a
mempty
Permissions (InsPermDef b)
forall a. Monoid a => a
mempty
Permissions (SelPermDef b)
forall a. Monoid a => a
mempty
Permissions (UpdPermDef b)
forall a. Monoid a => a
mempty
Permissions (DelPermDef b)
forall a. Monoid a => a
mempty
EventTriggers b
forall a. Monoid a => a
mempty
Maybe ApolloFederationConfig
forall a. Maybe a
Nothing
Maybe LogicalModelName
forall a. Maybe a
Nothing
instance (Backend b) => FromJSON (TableMetadata b) where
parseJSON :: Value -> Parser (TableMetadata b)
parseJSON = String
-> (Object -> Parser (TableMetadata b))
-> Value
-> Parser (TableMetadata b)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Object" ((Object -> Parser (TableMetadata b))
-> Value -> Parser (TableMetadata b))
-> (Object -> Parser (TableMetadata b))
-> Value
-> Parser (TableMetadata b)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
let unexpectedKeys :: HashSet Key
unexpectedKeys = Object -> HashSet Key
getUnexpectedKeys Object
o
Bool -> Parser () -> Parser ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (HashSet Key -> Bool
forall a. HashSet a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null HashSet Key
unexpectedKeys)
(Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
(String -> Parser ()) -> String -> Parser ()
forall a b. (a -> b) -> a -> b
$ String
"unexpected keys when parsing TableMetadata: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Key] -> String
forall a. Show a => a -> String
show (HashSet Key -> [Key]
forall a. HashSet a -> [a]
HS.toList HashSet Key
unexpectedKeys)
TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
forall (b :: BackendType).
TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b
TableMetadata
(TableName b
-> Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (TableName b)
-> Parser
(Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o
Object -> Key -> Parser (TableName b)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
tableKey
Parser
(Bool
-> TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser Bool
-> Parser
(TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
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 Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
isEnumKey
Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
Parser
(TableConfig b
-> Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (TableConfig b)
-> Parser
(Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
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 (TableConfig b))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
configKey
Parser (Maybe (TableConfig b))
-> TableConfig b -> Parser (TableConfig b)
forall a. Parser (Maybe a) -> a -> Parser a
.!= TableConfig b
forall (b :: BackendType). TableConfig b
emptyTableConfig
Parser
(Relationships (ObjRelDef b)
-> Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Relationships (ObjRelDef b))
-> Parser
(Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ObjRelDef b -> RelName)
-> Parser [ObjRelDef b]
-> Parser (Relationships (ObjRelDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"object relationships" ObjRelDef b -> RelName
forall a. RelDef a -> RelName
_rdName (Object
o Object -> Key -> Parser (Maybe [ObjRelDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
orKey Parser (Maybe [ObjRelDef b])
-> [ObjRelDef b] -> Parser [ObjRelDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Relationships (ArrRelDef b)
-> ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Relationships (ArrRelDef b))
-> Parser
(ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ArrRelDef b -> RelName)
-> Parser [ArrRelDef b]
-> Parser (Relationships (ArrRelDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"array relationships" ArrRelDef b -> RelName
forall a. RelDef a -> RelName
_rdName (Object
o Object -> Key -> Parser (Maybe [ArrRelDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
arKey Parser (Maybe [ArrRelDef b])
-> [ArrRelDef b] -> Parser [ArrRelDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(ComputedFields b
-> RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (ComputedFields b)
-> Parser
(RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (ComputedFieldMetadata b -> ComputedFieldName)
-> Parser [ComputedFieldMetadata b]
-> Parser (ComputedFields b)
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"computed fields" ComputedFieldMetadata b -> ComputedFieldName
forall (b :: BackendType).
ComputedFieldMetadata b -> ComputedFieldName
_cfmName (Object
o Object -> Key -> Parser (Maybe [ComputedFieldMetadata b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
cfKey Parser (Maybe [ComputedFieldMetadata b])
-> [ComputedFieldMetadata b] -> Parser [ComputedFieldMetadata b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(RemoteRelationships
-> Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser RemoteRelationships
-> Parser
(Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (RemoteRelationshipG RemoteRelationshipDefinition -> RelName)
-> Parser [RemoteRelationshipG RemoteRelationshipDefinition]
-> Parser RemoteRelationships
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"remote relationships" RemoteRelationshipG RemoteRelationshipDefinition -> RelName
forall definition. RemoteRelationshipG definition -> RelName
_rrName (Object
o Object
-> Key
-> Parser
(Maybe [RemoteRelationshipG RemoteRelationshipDefinition])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
rrKey Parser (Maybe [RemoteRelationshipG RemoteRelationshipDefinition])
-> [RemoteRelationshipG RemoteRelationshipDefinition]
-> Parser [RemoteRelationshipG RemoteRelationshipDefinition]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Permissions (InsPermDef b)
-> Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Permissions (InsPermDef b))
-> Parser
(Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (InsPermDef b -> RoleName)
-> Parser [InsPermDef b]
-> Parser (Permissions (InsPermDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"insert permissions" InsPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole (Object
o Object -> Key -> Parser (Maybe [InsPermDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
ipKey Parser (Maybe [InsPermDef b])
-> [InsPermDef b] -> Parser [InsPermDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Permissions (SelPermDef b)
-> Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Permissions (SelPermDef b))
-> Parser
(Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (SelPermDef b -> RoleName)
-> Parser [SelPermDef b]
-> Parser (Permissions (SelPermDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"select permissions" SelPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole (Object
o Object -> Key -> Parser (Maybe [SelPermDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
spKey Parser (Maybe [SelPermDef b])
-> [SelPermDef b] -> Parser [SelPermDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Permissions (UpdPermDef b)
-> Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Permissions (UpdPermDef b))
-> Parser
(Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (UpdPermDef b -> RoleName)
-> Parser [UpdPermDef b]
-> Parser (Permissions (UpdPermDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"update permissions" UpdPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole (Object
o Object -> Key -> Parser (Maybe [UpdPermDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
upKey Parser (Maybe [UpdPermDef b])
-> [UpdPermDef b] -> Parser [UpdPermDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Permissions (DelPermDef b)
-> EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (Permissions (DelPermDef b))
-> Parser
(EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (DelPermDef b -> RoleName)
-> Parser [DelPermDef b]
-> Parser (Permissions (DelPermDef b))
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"delete permissions" DelPermDef b -> RoleName
forall (b :: BackendType) (perm :: BackendType -> *).
PermDef b perm -> RoleName
_pdRole (Object
o Object -> Key -> Parser (Maybe [DelPermDef b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
dpKey Parser (Maybe [DelPermDef b])
-> [DelPermDef b] -> Parser [DelPermDef b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(EventTriggers b
-> Maybe ApolloFederationConfig
-> Maybe LogicalModelName
-> TableMetadata b)
-> Parser (EventTriggers b)
-> Parser
(Maybe ApolloFederationConfig
-> Maybe LogicalModelName -> TableMetadata b)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Text
-> (EventTriggerConf b -> TriggerName)
-> Parser [EventTriggerConf b]
-> Parser (EventTriggers b)
forall k a.
(Hashable k, ToTxt k) =>
Text -> (a -> k) -> Parser [a] -> Parser (InsOrdHashMap k a)
parseListAsMap Text
"event triggers" EventTriggerConf b -> TriggerName
forall (b :: BackendType). EventTriggerConf b -> TriggerName
etcName (Object
o Object -> Key -> Parser (Maybe [EventTriggerConf b])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
etKey Parser (Maybe [EventTriggerConf b])
-> [EventTriggerConf b] -> Parser [EventTriggerConf b]
forall a. Parser (Maybe a) -> a -> Parser a
.!= [])
Parser
(Maybe ApolloFederationConfig
-> Maybe LogicalModelName -> TableMetadata b)
-> Parser (Maybe ApolloFederationConfig)
-> Parser (Maybe LogicalModelName -> TableMetadata b)
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 ApolloFederationConfig)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
enableAFKey
Parser (Maybe LogicalModelName -> TableMetadata b)
-> Parser (Maybe LogicalModelName) -> Parser (TableMetadata b)
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 LogicalModelName)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
logicalModelKey
where
tableKey :: Key
tableKey = Key
"table"
isEnumKey :: Key
isEnumKey = Key
"is_enum"
configKey :: Key
configKey = Key
"configuration"
orKey :: Key
orKey = Key
"object_relationships"
arKey :: Key
arKey = Key
"array_relationships"
ipKey :: Key
ipKey = Key
"insert_permissions"
spKey :: Key
spKey = Key
"select_permissions"
upKey :: Key
upKey = Key
"update_permissions"
dpKey :: Key
dpKey = Key
"delete_permissions"
etKey :: Key
etKey = Key
"event_triggers"
cfKey :: Key
cfKey = Key
"computed_fields"
rrKey :: Key
rrKey = Key
"remote_relationships"
enableAFKey :: Key
enableAFKey = Key
"apollo_federation_config"
logicalModelKey :: Key
logicalModelKey = Key
"logical_model"
getUnexpectedKeys :: Object -> HashSet Key
getUnexpectedKeys Object
o =
[Key] -> HashSet Key
forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList (Object -> [Key]
forall v. KeyMap v -> [Key]
KM.keys Object
o) HashSet Key -> HashSet Key -> HashSet Key
forall a. (Eq a, Hashable a) => HashSet a -> HashSet a -> HashSet a
`HS.difference` HashSet Key
expectedKeySet
expectedKeySet :: HashSet Key
expectedKeySet =
[Key] -> HashSet Key
forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList
[ Key
tableKey,
Key
isEnumKey,
Key
configKey,
Key
orKey,
Key
arKey,
Key
ipKey,
Key
spKey,
Key
upKey,
Key
dpKey,
Key
etKey,
Key
cfKey,
Key
rrKey,
Key
enableAFKey,
Key
logicalModelKey
]