module Hasura.RQL.DDL.Schema.Cache.Dependencies
( resolveDependencies,
)
where
import Control.Arrow.Extended
import Control.Lens hiding ((.=))
import Data.Aeson
import Data.HashMap.Strict.Extended qualified as M
import Data.HashMap.Strict.InsOrd qualified as OMap
import Data.HashSet qualified as HS
import Data.List (nub)
import Data.Monoid (First)
import Data.Text.Extended
import Hasura.Base.Error
import Hasura.Prelude
import Hasura.RQL.DDL.Network
import Hasura.RQL.DDL.Permission.Internal (permissionIsDefined)
import Hasura.RQL.DDL.Schema.Cache.Common
import Hasura.RQL.Types.Action
import Hasura.RQL.Types.Allowlist
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.Column
import Hasura.RQL.Types.Common
import Hasura.RQL.Types.ComputedField
import Hasura.RQL.Types.Endpoint
import Hasura.RQL.Types.Function
import Hasura.RQL.Types.Metadata
import Hasura.RQL.Types.Metadata.Object
import Hasura.RQL.Types.Permission
import Hasura.RQL.Types.QueryCollection
import Hasura.RQL.Types.Relationships.Local
import Hasura.RQL.Types.SchemaCache
import Hasura.RQL.Types.SchemaCacheTypes
import Hasura.RQL.Types.Source
import Hasura.RQL.Types.Table
import Hasura.SQL.AnyBackend qualified as AB
import Language.GraphQL.Draft.Syntax qualified as G
resolveDependencies ::
(ArrowKleisli m arr, QErrM m) =>
( BuildOutputs,
[(MetadataObject, SchemaObjId, SchemaDependency)]
)
`arr` (BuildOutputs, [InconsistentMetadata], DepMap)
resolveDependencies :: arr
(BuildOutputs, [(MetadataObject, SchemaObjId, SchemaDependency)])
(BuildOutputs, [InconsistentMetadata], DepMap)
resolveDependencies = ((BuildOutputs, [(MetadataObject, SchemaObjId, SchemaDependency)])
-> m (BuildOutputs, [InconsistentMetadata], DepMap))
-> arr
(BuildOutputs, [(MetadataObject, SchemaObjId, SchemaDependency)])
(BuildOutputs, [InconsistentMetadata], DepMap)
forall (m :: * -> *) (arr :: * -> * -> *) a b.
ArrowKleisli m arr =>
(a -> m b) -> arr a b
arrM \(BuildOutputs
cache, [(MetadataObject, SchemaObjId, SchemaDependency)]
dependencies) -> do
let dependencyMap :: HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
dependencyMap =
[(MetadataObject, SchemaObjId, SchemaDependency)]
dependencies
[(MetadataObject, SchemaObjId, SchemaDependency)]
-> ([(MetadataObject, SchemaObjId, SchemaDependency)]
-> HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)])
-> HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)]
forall a b. a -> (a -> b) -> b
& ((MetadataObject, SchemaObjId, SchemaDependency) -> SchemaObjId)
-> [(MetadataObject, SchemaObjId, SchemaDependency)]
-> HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)]
forall k (t :: * -> *) v.
(Eq k, Hashable k, Foldable t) =>
(v -> k) -> t v -> HashMap k [v]
M.groupOn (Getting
SchemaObjId
(MetadataObject, SchemaObjId, SchemaDependency)
SchemaObjId
-> (MetadataObject, SchemaObjId, SchemaDependency) -> SchemaObjId
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
SchemaObjId
(MetadataObject, SchemaObjId, SchemaDependency)
SchemaObjId
forall s t a b. Field2 s t a b => Lens s t a b
_2)
HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)]
-> (HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
forall a b. a -> (a -> b) -> b
& ([(MetadataObject, SchemaObjId, SchemaDependency)]
-> [(MetadataObject, SchemaDependency)])
-> HashMap
SchemaObjId [(MetadataObject, SchemaObjId, SchemaDependency)]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((MetadataObject, SchemaObjId, SchemaDependency)
-> (MetadataObject, SchemaDependency))
-> [(MetadataObject, SchemaObjId, SchemaDependency)]
-> [(MetadataObject, SchemaDependency)]
forall a b. (a -> b) -> [a] -> [b]
map \(MetadataObject
metadataObject, SchemaObjId
_, SchemaDependency
schemaDependency) -> (MetadataObject
metadataObject, SchemaDependency
schemaDependency))
Int
-> BuildOutputs
-> [InconsistentMetadata]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
forall (m :: * -> *).
QErrM m =>
Int
-> BuildOutputs
-> [InconsistentMetadata]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
performIteration Int
0 BuildOutputs
cache [] HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
dependencyMap
performIteration ::
(QErrM m) =>
Int ->
BuildOutputs ->
[InconsistentMetadata] ->
HashMap SchemaObjId [(MetadataObject, SchemaDependency)] ->
m (BuildOutputs, [InconsistentMetadata], DepMap)
performIteration :: Int
-> BuildOutputs
-> [InconsistentMetadata]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
performIteration Int
iterationNumber BuildOutputs
cache [InconsistentMetadata]
inconsistencies HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
dependencies = do
let ([InconsistentMetadata]
newInconsistencies, HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
prunedDependencies) = BuildOutputs
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
pruneDanglingDependents BuildOutputs
cache HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
dependencies
case [InconsistentMetadata]
newInconsistencies of
[] -> (BuildOutputs, [InconsistentMetadata], DepMap)
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BuildOutputs
cache, [InconsistentMetadata]
inconsistencies, [SchemaDependency] -> HashSet SchemaDependency
forall a. (Eq a, Hashable a) => [a] -> HashSet a
HS.fromList ([SchemaDependency] -> HashSet SchemaDependency)
-> ([(MetadataObject, SchemaDependency)] -> [SchemaDependency])
-> [(MetadataObject, SchemaDependency)]
-> HashSet SchemaDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((MetadataObject, SchemaDependency) -> SchemaDependency)
-> [(MetadataObject, SchemaDependency)] -> [SchemaDependency]
forall a b. (a -> b) -> [a] -> [b]
map (MetadataObject, SchemaDependency) -> SchemaDependency
forall a b. (a, b) -> b
snd ([(MetadataObject, SchemaDependency)] -> HashSet SchemaDependency)
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> DepMap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
prunedDependencies)
[InconsistentMetadata]
_
| Int
iterationNumber Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< Int
100 -> do
let inconsistentIds :: [MetadataObjId]
inconsistentIds = [MetadataObjId] -> [MetadataObjId]
forall a. Eq a => [a] -> [a]
nub ([MetadataObjId] -> [MetadataObjId])
-> [MetadataObjId] -> [MetadataObjId]
forall a b. (a -> b) -> a -> b
$ (InconsistentMetadata -> [MetadataObjId])
-> [InconsistentMetadata] -> [MetadataObjId]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap InconsistentMetadata -> [MetadataObjId]
imObjectIds [InconsistentMetadata]
newInconsistencies
prunedCache :: BuildOutputs
prunedCache = (BuildOutputs -> MetadataObjId -> BuildOutputs)
-> BuildOutputs -> [MetadataObjId] -> BuildOutputs
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ((MetadataObjId -> BuildOutputs -> BuildOutputs)
-> BuildOutputs -> MetadataObjId -> BuildOutputs
forall a b c. (a -> b -> c) -> b -> a -> c
flip MetadataObjId -> BuildOutputs -> BuildOutputs
deleteMetadataObject) BuildOutputs
cache [MetadataObjId]
inconsistentIds
allInconsistencies :: [InconsistentMetadata]
allInconsistencies = [InconsistentMetadata]
inconsistencies [InconsistentMetadata]
-> [InconsistentMetadata] -> [InconsistentMetadata]
forall a. Semigroup a => a -> a -> a
<> [InconsistentMetadata]
newInconsistencies
Int
-> BuildOutputs
-> [InconsistentMetadata]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
forall (m :: * -> *).
QErrM m =>
Int
-> BuildOutputs
-> [InconsistentMetadata]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> m (BuildOutputs, [InconsistentMetadata], DepMap)
performIteration (Int
iterationNumber Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) BuildOutputs
prunedCache [InconsistentMetadata]
allInconsistencies HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
prunedDependencies
| Bool
otherwise ->
QErr -> m (BuildOutputs, [InconsistentMetadata], DepMap)
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
(Code -> Text -> QErr
err500 Code
Unexpected Text
"schema dependency resolution failed to terminate")
{ qeInternal :: Maybe QErrExtra
qeInternal =
QErrExtra -> Maybe QErrExtra
forall a. a -> Maybe a
Just (QErrExtra -> Maybe QErrExtra) -> QErrExtra -> Maybe QErrExtra
forall a b. (a -> b) -> a -> b
$
Value -> QErrExtra
ExtraInternal (Value -> QErrExtra) -> Value -> QErrExtra
forall a b. (a -> b) -> a -> b
$
[Pair] -> Value
object
[ Key
"inconsistent_objects"
Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
"old" Key -> [InconsistentMetadata] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [InconsistentMetadata]
inconsistencies,
Key
"new" Key -> [InconsistentMetadata] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [InconsistentMetadata]
newInconsistencies
],
Key
"pruned_dependencies" Key -> HashMap SchemaObjId [SchemaDependency] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (((MetadataObject, SchemaDependency) -> SchemaDependency)
-> [(MetadataObject, SchemaDependency)] -> [SchemaDependency]
forall a b. (a -> b) -> [a] -> [b]
map (MetadataObject, SchemaDependency) -> SchemaDependency
forall a b. (a, b) -> b
snd ([(MetadataObject, SchemaDependency)] -> [SchemaDependency])
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> HashMap SchemaObjId [SchemaDependency]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
prunedDependencies)
]
}
pruneDanglingDependents ::
BuildOutputs ->
HashMap SchemaObjId [(MetadataObject, SchemaDependency)] ->
([InconsistentMetadata], HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
pruneDanglingDependents :: BuildOutputs
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
pruneDanglingDependents BuildOutputs
cache =
(HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (([(MetadataObject, SchemaDependency)] -> Bool)
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
forall v k. (v -> Bool) -> HashMap k v -> HashMap k v
M.filter (Bool -> Bool
not (Bool -> Bool)
-> ([(MetadataObject, SchemaDependency)] -> Bool)
-> [(MetadataObject, SchemaDependency)]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(MetadataObject, SchemaDependency)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null)) (([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)]))
-> (HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)]))
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata], [(MetadataObject, SchemaDependency)]))
-> HashMap SchemaObjId [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata],
HashMap SchemaObjId [(MetadataObject, SchemaDependency)])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse do
[Either InconsistentMetadata (MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata], [(MetadataObject, SchemaDependency)])
forall a b. [Either a b] -> ([a], [b])
partitionEithers ([Either InconsistentMetadata (MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata], [(MetadataObject, SchemaDependency)]))
-> ([(MetadataObject, SchemaDependency)]
-> [Either
InconsistentMetadata (MetadataObject, SchemaDependency)])
-> [(MetadataObject, SchemaDependency)]
-> ([InconsistentMetadata], [(MetadataObject, SchemaDependency)])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((MetadataObject, SchemaDependency)
-> Either InconsistentMetadata (MetadataObject, SchemaDependency))
-> [(MetadataObject, SchemaDependency)]
-> [Either InconsistentMetadata (MetadataObject, SchemaDependency)]
forall a b. (a -> b) -> [a] -> [b]
map \(MetadataObject
metadataObject, SchemaDependency
dependency) -> case SchemaDependency -> Either Text ()
resolveDependency SchemaDependency
dependency of
Right () -> (MetadataObject, SchemaDependency)
-> Either InconsistentMetadata (MetadataObject, SchemaDependency)
forall a b. b -> Either a b
Right (MetadataObject
metadataObject, SchemaDependency
dependency)
Left Text
errorMessage -> InconsistentMetadata
-> Either InconsistentMetadata (MetadataObject, SchemaDependency)
forall a b. a -> Either a b
Left (Text -> Maybe Value -> MetadataObject -> InconsistentMetadata
InconsistentObject Text
errorMessage Maybe Value
forall a. Maybe a
Nothing MetadataObject
metadataObject)
where
resolveDependency :: SchemaDependency -> Either Text ()
resolveDependency :: SchemaDependency -> Either Text ()
resolveDependency (SchemaDependency SchemaObjId
objectId DependencyReason
_) = case SchemaObjId
objectId of
SOSource SourceName
source ->
Either Text BackendSourceInfo -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text BackendSourceInfo -> Either Text ())
-> Either Text BackendSourceInfo -> Either Text ()
forall a b. (a -> b) -> a -> b
$
SourceName
-> HashMap SourceName BackendSourceInfo -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
source (BuildOutputs -> HashMap SourceName BackendSourceInfo
_boSources BuildOutputs
cache)
Maybe BackendSourceInfo
-> Either Text BackendSourceInfo -> Either Text BackendSourceInfo
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text BackendSourceInfo
forall a b. a -> Either a b
Left (Text
"no such source exists: " Text -> SourceName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> SourceName
source)
SORemoteSchema RemoteSchemaName
remoteSchemaName ->
Bool -> Either Text () -> Either Text ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (RemoteSchemaName
remoteSchemaName RemoteSchemaName
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
`M.member` BuildOutputs
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
_boRemoteSchemas BuildOutputs
cache) (Either Text () -> Either Text ())
-> Either Text () -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text -> Either Text ()
forall a b. a -> Either a b
Left (Text -> Either Text ()) -> Text -> Either Text ()
forall a b. (a -> b) -> a -> b
$ Text
"remote schema " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RemoteSchemaName
remoteSchemaName RemoteSchemaName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not found"
SORemoteSchemaPermission RemoteSchemaName
remoteSchemaName RoleName
roleName -> do
(RemoteSchemaCtx, MetadataObject)
remoteSchema <-
Maybe (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (RemoteSchemaName
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup RemoteSchemaName
remoteSchemaName (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$ BuildOutputs
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
_boRemoteSchemas BuildOutputs
cache) (Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject))
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$
Text -> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. a -> Either a b
Left (Text -> Either Text (RemoteSchemaCtx, MetadataObject))
-> Text -> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$ Text
"remote schema " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RemoteSchemaName
remoteSchemaName RemoteSchemaName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not found"
Bool -> Either Text () -> Either Text ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (RoleName
roleName RoleName -> HashMap RoleName IntrospectionResult -> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
`M.member` RemoteSchemaCtx -> HashMap RoleName IntrospectionResult
_rscPermissions ((RemoteSchemaCtx, MetadataObject) -> RemoteSchemaCtx
forall a b. (a, b) -> a
fst (RemoteSchemaCtx, MetadataObject)
remoteSchema)) (Either Text () -> Either Text ())
-> Either Text () -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text -> Either Text ()
forall a b. a -> Either a b
Left (Text -> Either Text ()) -> Text -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text
"no permission defined on remote schema " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RemoteSchemaName
remoteSchemaName
RemoteSchemaName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" for role " Text -> RoleName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> RoleName
roleName
SORemoteSchemaRemoteRelationship RemoteSchemaName
remoteSchemaName Name
typeName RelName
relationshipName -> do
RemoteSchemaCtx
remoteSchema <-
((RemoteSchemaCtx, MetadataObject) -> RemoteSchemaCtx)
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text RemoteSchemaCtx
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (RemoteSchemaCtx, MetadataObject) -> RemoteSchemaCtx
forall a b. (a, b) -> a
fst (Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text RemoteSchemaCtx)
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text RemoteSchemaCtx
forall a b. (a -> b) -> a -> b
$
Maybe (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing (RemoteSchemaName
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup RemoteSchemaName
remoteSchemaName (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Maybe (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$ BuildOutputs
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
_boRemoteSchemas BuildOutputs
cache) (Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject))
-> Either Text (RemoteSchemaCtx, MetadataObject)
-> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$
Text -> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. a -> Either a b
Left (Text -> Either Text (RemoteSchemaCtx, MetadataObject))
-> Text -> Either Text (RemoteSchemaCtx, MetadataObject)
forall a b. (a -> b) -> a -> b
$ Text
"remote schema " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RemoteSchemaName
remoteSchemaName RemoteSchemaName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not found"
Either Text (RemoteFieldInfo Name) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (RemoteFieldInfo Name) -> Either Text ())
-> Either Text (RemoteFieldInfo Name) -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Maybe (RemoteFieldInfo Name)
-> Either Text (RemoteFieldInfo Name)
-> Either Text (RemoteFieldInfo Name)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
onNothing
(Name
-> InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))
-> Maybe (InsOrdHashMap RelName (RemoteFieldInfo Name))
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
OMap.lookup Name
typeName (RemoteSchemaCtx
-> InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))
_rscRemoteRelationships RemoteSchemaCtx
remoteSchema) Maybe (InsOrdHashMap RelName (RemoteFieldInfo Name))
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Maybe (RemoteFieldInfo Name))
-> Maybe (RemoteFieldInfo Name)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= RelName
-> InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Maybe (RemoteFieldInfo Name)
forall k v. (Eq k, Hashable k) => k -> InsOrdHashMap k v -> Maybe v
OMap.lookup RelName
relationshipName)
(Either Text (RemoteFieldInfo Name)
-> Either Text (RemoteFieldInfo Name))
-> Either Text (RemoteFieldInfo Name)
-> Either Text (RemoteFieldInfo Name)
forall a b. (a -> b) -> a -> b
$ Text -> Either Text (RemoteFieldInfo Name)
forall a b. a -> Either a b
Left (Text -> Either Text (RemoteFieldInfo Name))
-> Text -> Either Text (RemoteFieldInfo Name)
forall a b. (a -> b) -> a -> b
$
Text
"remote relationship " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RelName
relationshipName
RelName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" on type " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Name -> Text
G.unName Name
typeName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" on " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RemoteSchemaName
remoteSchemaName
RemoteSchemaName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not found"
SOSourceObj SourceName
source AnyBackend SourceObjId
exists -> do
AnyBackend SourceObjId
-> (forall (b :: BackendType).
Backend b =>
SourceObjId b -> Either Text ())
-> Either Text ()
forall (c :: BackendType -> Constraint) (i :: BackendType -> *) r.
AllBackendsSatisfy c =>
AnyBackend i -> (forall (b :: BackendType). c b => i b -> r) -> r
AB.dispatchAnyBackend @Backend AnyBackend SourceObjId
exists ((forall (b :: BackendType).
Backend b =>
SourceObjId b -> Either Text ())
-> Either Text ())
-> (forall (b :: BackendType).
Backend b =>
SourceObjId b -> Either Text ())
-> Either Text ()
forall a b. (a -> b) -> a -> b
$ \SourceObjId b
sourceObjId -> do
SourceInfo b
sourceInfo <- SourceName -> SourceObjId b -> Either Text (SourceInfo b)
forall (b :: BackendType).
Backend b =>
SourceName -> SourceObjId b -> Either Text (SourceInfo b)
castSourceInfo SourceName
source SourceObjId b
sourceObjId
case SourceObjId b
sourceObjId of
SOITable TableName b
tableName -> do
Either Text (TableInfo b) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (TableInfo b) -> Either Text ())
-> Either Text (TableInfo b) -> Either Text ()
forall a b. (a -> b) -> a -> b
$ SourceInfo b -> TableName b -> Either Text (TableInfo b)
forall (b :: BackendType).
(Eq (TableName b), Hashable (TableName b), ToTxt (TableName b)) =>
SourceInfo b -> TableName b -> Either Text (TableInfo b)
resolveTable SourceInfo b
sourceInfo TableName b
tableName
SOIFunction FunctionName b
functionName ->
Either Text (FunctionInfo b) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (FunctionInfo b) -> Either Text ())
-> Either Text (FunctionInfo b) -> Either Text ()
forall a b. (a -> b) -> a -> b
$
FunctionName b
-> HashMap (FunctionName b) (FunctionInfo b)
-> Maybe (FunctionInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup FunctionName b
functionName (SourceInfo b -> HashMap (FunctionName b) (FunctionInfo b)
forall (b :: BackendType). SourceInfo b -> FunctionCache b
_siFunctions SourceInfo b
sourceInfo)
Maybe (FunctionInfo b)
-> Either Text (FunctionInfo b) -> Either Text (FunctionInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text (FunctionInfo b)
forall a b. a -> Either a b
Left (Text
"function " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FunctionName b
functionName FunctionName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not tracked")
SOITableObj TableName b
tableName TableObjId b
tableObjectId -> do
TableInfo b
tableInfo <- SourceInfo b -> TableName b -> Either Text (TableInfo b)
forall (b :: BackendType).
(Eq (TableName b), Hashable (TableName b), ToTxt (TableName b)) =>
SourceInfo b -> TableName b -> Either Text (TableInfo b)
resolveTable SourceInfo b
sourceInfo TableName b
tableName
case TableObjId b
tableObjectId of
TOCol Column b
columnName ->
Either Text (ColumnInfo b) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (ColumnInfo b) -> Either Text ())
-> Either Text (ColumnInfo b) -> Either Text ()
forall a b. (a -> b) -> a -> b
$ TableInfo b
-> FieldName
-> Getting (First (ColumnInfo b)) (FieldInfo b) (ColumnInfo b)
-> Text
-> Either Text (ColumnInfo b)
forall (b :: BackendType) a.
Backend b =>
TableInfo b
-> FieldName
-> Getting (First a) (FieldInfo b) a
-> Text
-> Either Text a
resolveField TableInfo b
tableInfo (TableInfo b -> Column b -> FieldName
forall (b :: BackendType).
Backend b =>
TableInfo b -> Column b -> FieldName
columnToFieldName TableInfo b
tableInfo Column b
columnName) Getting (First (ColumnInfo b)) (FieldInfo b) (ColumnInfo b)
forall (b :: BackendType). Prism' (FieldInfo b) (ColumnInfo b)
_FIColumn Text
"column"
TORel RelName
relName ->
Either Text (RelInfo b) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (RelInfo b) -> Either Text ())
-> Either Text (RelInfo b) -> Either Text ()
forall a b. (a -> b) -> a -> b
$ TableInfo b
-> FieldName
-> Getting (First (RelInfo b)) (FieldInfo b) (RelInfo b)
-> Text
-> Either Text (RelInfo b)
forall (b :: BackendType) a.
Backend b =>
TableInfo b
-> FieldName
-> Getting (First a) (FieldInfo b) a
-> Text
-> Either Text a
resolveField TableInfo b
tableInfo (RelName -> FieldName
fromRel RelName
relName) Getting (First (RelInfo b)) (FieldInfo b) (RelInfo b)
forall (b :: BackendType). Prism' (FieldInfo b) (RelInfo b)
_FIRelationship Text
"relationship"
TOComputedField ComputedFieldName
fieldName ->
Either Text (ComputedFieldInfo b) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (ComputedFieldInfo b) -> Either Text ())
-> Either Text (ComputedFieldInfo b) -> Either Text ()
forall a b. (a -> b) -> a -> b
$ TableInfo b
-> FieldName
-> Getting
(First (ComputedFieldInfo b)) (FieldInfo b) (ComputedFieldInfo b)
-> Text
-> Either Text (ComputedFieldInfo b)
forall (b :: BackendType) a.
Backend b =>
TableInfo b
-> FieldName
-> Getting (First a) (FieldInfo b) a
-> Text
-> Either Text a
resolveField TableInfo b
tableInfo (ComputedFieldName -> FieldName
fromComputedField ComputedFieldName
fieldName) Getting
(First (ComputedFieldInfo b)) (FieldInfo b) (ComputedFieldInfo b)
forall (b :: BackendType).
Prism' (FieldInfo b) (ComputedFieldInfo b)
_FIComputedField Text
"computed field"
TORemoteRel RelName
fieldName ->
Either Text (RemoteFieldInfo (DBJoinField b)) -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text (RemoteFieldInfo (DBJoinField b)) -> Either Text ())
-> Either Text (RemoteFieldInfo (DBJoinField b)) -> Either Text ()
forall a b. (a -> b) -> a -> b
$ TableInfo b
-> FieldName
-> Getting
(First (RemoteFieldInfo (DBJoinField b)))
(FieldInfo b)
(RemoteFieldInfo (DBJoinField b))
-> Text
-> Either Text (RemoteFieldInfo (DBJoinField b))
forall (b :: BackendType) a.
Backend b =>
TableInfo b
-> FieldName
-> Getting (First a) (FieldInfo b) a
-> Text
-> Either Text a
resolveField TableInfo b
tableInfo (RelName -> FieldName
fromRemoteRelationship RelName
fieldName) Getting
(First (RemoteFieldInfo (DBJoinField b)))
(FieldInfo b)
(RemoteFieldInfo (DBJoinField b))
forall (b :: BackendType).
Prism' (FieldInfo b) (RemoteFieldInfo (DBJoinField b))
_FIRemoteRelationship Text
"remote relationship"
TOForeignKey ConstraintName b
constraintName -> do
let foreignKeys :: HashSet (ForeignKey b)
foreignKeys = TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> HashSet (ForeignKey b)
forall (b :: BackendType) field1 primaryKeyColumn.
TableCoreInfoG b field1 primaryKeyColumn -> HashSet (ForeignKey b)
_tciForeignKeys (TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> HashSet (ForeignKey b))
-> TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
-> HashSet (ForeignKey b)
forall a b. (a -> b) -> a -> b
$ TableInfo b -> TableCoreInfoG b (FieldInfo b) (ColumnInfo b)
forall (b :: BackendType). TableInfo b -> TableCoreInfo b
_tiCoreInfo TableInfo b
tableInfo
Bool -> Either Text () -> Either Text ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Maybe (ForeignKey b) -> Bool
forall a. Maybe a -> Bool
isJust (Maybe (ForeignKey b) -> Bool) -> Maybe (ForeignKey b) -> Bool
forall a b. (a -> b) -> a -> b
$ (ForeignKey b -> Bool)
-> HashSet (ForeignKey b) -> Maybe (ForeignKey b)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((ConstraintName b -> ConstraintName b -> Bool
forall a. Eq a => a -> a -> Bool
== ConstraintName b
constraintName) (ConstraintName b -> Bool)
-> (ForeignKey b -> ConstraintName b) -> ForeignKey b -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Constraint b -> ConstraintName b
forall (b :: BackendType). Constraint b -> ConstraintName b
_cName (Constraint b -> ConstraintName b)
-> (ForeignKey b -> Constraint b)
-> ForeignKey b
-> ConstraintName b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ForeignKey b -> Constraint b
forall (b :: BackendType). ForeignKey b -> Constraint b
_fkConstraint) HashSet (ForeignKey b)
foreignKeys) (Either Text () -> Either Text ())
-> Either Text () -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text -> Either Text ()
forall a b. a -> Either a b
Left (Text -> Either Text ()) -> Text -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text
"no foreign key constraint named " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ConstraintName b
constraintName ConstraintName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"defined for table " Text -> TableName b -> Text
forall t. ToTxt t => Text -> t -> Text
<>> TableName b
tableName
TOPerm RoleName
roleName PermType
permType -> do
Bool -> Either Text () -> Either Text ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Bool -> (RolePermInfo b -> Bool) -> Maybe (RolePermInfo b) -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False (PermType -> RolePermInfo b -> Bool
forall (backend :: BackendType).
PermType -> RolePermInfo backend -> Bool
permissionIsDefined PermType
permType) (TableInfo b
tableInfo TableInfo b
-> Getting (First (RolePermInfo b)) (TableInfo b) (RolePermInfo b)
-> Maybe (RolePermInfo b)
forall s a. s -> Getting (First a) s a -> Maybe a
^? ((RolePermInfoMap b
-> Const (First (RolePermInfo b)) (RolePermInfoMap b))
-> TableInfo b -> Const (First (RolePermInfo b)) (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (RolePermInfoMap b)
tiRolePermInfoMap ((RolePermInfoMap b
-> Const (First (RolePermInfo b)) (RolePermInfoMap b))
-> TableInfo b -> Const (First (RolePermInfo b)) (TableInfo b))
-> ((RolePermInfo b
-> Const (First (RolePermInfo b)) (RolePermInfo b))
-> RolePermInfoMap b
-> Const (First (RolePermInfo b)) (RolePermInfoMap b))
-> Getting (First (RolePermInfo b)) (TableInfo b) (RolePermInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (RolePermInfoMap b)
-> Traversal' (RolePermInfoMap b) (IxValue (RolePermInfoMap b))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (RolePermInfoMap b)
RoleName
roleName))) (Either Text () -> Either Text ())
-> Either Text () -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text -> Either Text ()
forall a b. a -> Either a b
Left (Text -> Either Text ()) -> Text -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text
"no " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> PermType -> Text
permTypeToCode PermType
permType Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" permission defined on table "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" for role " Text -> RoleName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> RoleName
roleName
TOTrigger TriggerName
triggerName ->
Bool -> Either Text () -> Either Text ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (TriggerName -> HashMap TriggerName (EventTriggerInfo b) -> Bool
forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
M.member TriggerName
triggerName (TableInfo b -> HashMap TriggerName (EventTriggerInfo b)
forall (b :: BackendType). TableInfo b -> EventTriggerInfoMap b
_tiEventTriggerInfoMap TableInfo b
tableInfo)) (Either Text () -> Either Text ())
-> Either Text () -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text -> Either Text ()
forall a b. a -> Either a b
Left (Text -> Either Text ()) -> Text -> Either Text ()
forall a b. (a -> b) -> a -> b
$
Text
"no event trigger named " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TriggerName
triggerName TriggerName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is defined for table " Text -> TableName b -> Text
forall t. ToTxt t => Text -> t -> Text
<>> TableName b
tableName
SORole RoleName
roleName ->
Either Text Role -> Either Text ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Either Text Role -> Either Text ())
-> Either Text Role -> Either Text ()
forall a b. (a -> b) -> a -> b
$
(RoleName -> HashMap RoleName Role -> Maybe Role
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup RoleName
roleName (BuildOutputs -> HashMap RoleName Role
_boRoles BuildOutputs
cache))
Maybe Role -> Either Text Role -> Either Text Role
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text Role
forall a b. a -> Either a b
Left (Text
"parent role " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> RoleName
roleName RoleName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" does not exist")
castSourceInfo ::
(Backend b) => SourceName -> SourceObjId b -> Either Text (SourceInfo b)
castSourceInfo :: SourceName -> SourceObjId b -> Either Text (SourceInfo b)
castSourceInfo SourceName
sourceName SourceObjId b
_ =
(SourceName
-> HashMap SourceName BackendSourceInfo -> Maybe BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup SourceName
sourceName (BuildOutputs -> HashMap SourceName BackendSourceInfo
_boSources BuildOutputs
cache) Maybe BackendSourceInfo
-> (BackendSourceInfo -> Maybe (SourceInfo b))
-> Maybe (SourceInfo b)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= BackendSourceInfo -> Maybe (SourceInfo b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (SourceInfo b)
unsafeSourceInfo)
Maybe (SourceInfo b)
-> Either Text (SourceInfo b) -> Either Text (SourceInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text (SourceInfo b)
forall a b. a -> Either a b
Left (Text
"no such source found " Text -> SourceName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> SourceName
sourceName)
resolveTable :: SourceInfo b -> TableName b -> Either Text (TableInfo b)
resolveTable SourceInfo b
sourceInfo TableName b
tableName =
TableName b
-> HashMap (TableName b) (TableInfo b) -> Maybe (TableInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup TableName b
tableName (SourceInfo b -> HashMap (TableName b) (TableInfo b)
forall (b :: BackendType). SourceInfo b -> TableCache b
_siTables SourceInfo b
sourceInfo)
Maybe (TableInfo b)
-> Either Text (TableInfo b) -> Either Text (TableInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text (TableInfo b)
forall a b. a -> Either a b
Left (Text
"table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not tracked")
columnToFieldName :: forall b. (Backend b) => TableInfo b -> Column b -> FieldName
columnToFieldName :: TableInfo b -> Column b -> FieldName
columnToFieldName TableInfo b
_ = Backend b => Column b -> FieldName
forall (b :: BackendType). Backend b => Column b -> FieldName
fromCol @b
resolveField ::
Backend b =>
TableInfo b ->
FieldName ->
Getting (First a) (FieldInfo b) a ->
Text ->
Either Text a
resolveField :: TableInfo b
-> FieldName
-> Getting (First a) (FieldInfo b) a
-> Text
-> Either Text a
resolveField TableInfo b
tableInfo FieldName
fieldName Getting (First a) (FieldInfo b) a
fieldType Text
fieldTypeName = do
let coreInfo :: TableCoreInfo b
coreInfo = TableInfo b -> TableCoreInfo b
forall (b :: BackendType). TableInfo b -> TableCoreInfo b
_tiCoreInfo TableInfo b
tableInfo
tableName :: TableName b
tableName = TableInfo b -> TableName b
forall (b :: BackendType). TableInfo b -> TableName b
tableInfoName TableInfo b
tableInfo
FieldInfo b
fieldInfo <-
FieldName -> HashMap FieldName (FieldInfo b) -> Maybe (FieldInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> Maybe v
M.lookup FieldName
fieldName (TableCoreInfo b -> HashMap FieldName (FieldInfo b)
forall (b :: BackendType) field1 primaryKeyColumn.
TableCoreInfoG b field1 primaryKeyColumn -> FieldInfoMap field1
_tciFieldInfoMap TableCoreInfo b
coreInfo)
Maybe (FieldInfo b)
-> Either Text (FieldInfo b) -> Either Text (FieldInfo b)
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text (FieldInfo b)
forall a b. a -> Either a b
Left
(Text
"table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" has no field named " Text -> FieldName -> Text
forall t. ToTxt t => Text -> t -> Text
<>> FieldName
fieldName)
(FieldInfo b
fieldInfo FieldInfo b -> Getting (First a) (FieldInfo b) a -> Maybe a
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting (First a) (FieldInfo b) a
fieldType)
Maybe a -> Either Text a -> Either Text a
forall (m :: * -> *) a. Applicative m => Maybe a -> m a -> m a
`onNothing` Text -> Either Text a
forall a b. a -> Either a b
Left
(Text
"field " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> FieldName
fieldName FieldName -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
"of table " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> TableName b
tableName TableName b -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
" is not a " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fieldTypeName)
deleteMetadataObject ::
MetadataObjId -> BuildOutputs -> BuildOutputs
deleteMetadataObject :: MetadataObjId -> BuildOutputs -> BuildOutputs
deleteMetadataObject = \case
MOSource SourceName
name -> (HashMap SourceName BackendSourceInfo
-> Identity (HashMap SourceName BackendSourceInfo))
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs (HashMap SourceName BackendSourceInfo)
boSources ((HashMap SourceName BackendSourceInfo
-> Identity (HashMap SourceName BackendSourceInfo))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap SourceName BackendSourceInfo
-> HashMap SourceName BackendSourceInfo)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ SourceName
-> HashMap SourceName BackendSourceInfo
-> HashMap SourceName BackendSourceInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete SourceName
name
MOSourceObjId SourceName
source AnyBackend SourceMetadataObjId
exists -> AnyBackend SourceMetadataObjId
-> (forall (b :: BackendType).
Backend b =>
SourceMetadataObjId b -> BuildOutputs -> BuildOutputs)
-> BuildOutputs
-> BuildOutputs
forall (c :: BackendType -> Constraint) (i :: BackendType -> *) r.
AllBackendsSatisfy c =>
AnyBackend i -> (forall (b :: BackendType). c b => i b -> r) -> r
AB.dispatchAnyBackend @Backend AnyBackend SourceMetadataObjId
exists (\SourceMetadataObjId b
sourceObjId -> (HashMap SourceName BackendSourceInfo
-> Identity (HashMap SourceName BackendSourceInfo))
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs (HashMap SourceName BackendSourceInfo)
boSources ((HashMap SourceName BackendSourceInfo
-> Identity (HashMap SourceName BackendSourceInfo))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap SourceName BackendSourceInfo
-> HashMap SourceName BackendSourceInfo)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (BackendSourceInfo -> BackendSourceInfo)
-> SourceName
-> HashMap SourceName BackendSourceInfo
-> HashMap SourceName BackendSourceInfo
forall k v.
(Eq k, Hashable k) =>
(v -> v) -> k -> HashMap k v -> HashMap k v
M.adjust (SourceMetadataObjId b -> BackendSourceInfo -> BackendSourceInfo
forall (b :: BackendType).
Backend b =>
SourceMetadataObjId b -> BackendSourceInfo -> BackendSourceInfo
deleteObjId SourceMetadataObjId b
sourceObjId) SourceName
source)
MORemoteSchema RemoteSchemaName
name -> (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs
Lens'
BuildOutputs
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
boRemoteSchemas ((HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RemoteSchemaName
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete RemoteSchemaName
name
MORemoteSchemaPermissions RemoteSchemaName
name RoleName
role -> (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs
Lens'
BuildOutputs
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
boRemoteSchemas ((HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs)
-> ((HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> (HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> BuildOutputs
-> Identity BuildOutputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
-> Traversal'
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
(IxValue
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
RemoteSchemaName
name (((RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> ((HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> (HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject)
forall s t a b. Field1 s t a b => Lens s t a b
_1 ((RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> ((HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> RemoteSchemaCtx -> Identity RemoteSchemaCtx
Lens' RemoteSchemaCtx (HashMap RoleName IntrospectionResult)
rscPermissions ((HashMap RoleName IntrospectionResult
-> Identity (HashMap RoleName IntrospectionResult))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap RoleName IntrospectionResult
-> HashMap RoleName IntrospectionResult)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RoleName
-> HashMap RoleName IntrospectionResult
-> HashMap RoleName IntrospectionResult
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete RoleName
role
MORemoteSchemaRemoteRelationship RemoteSchemaName
remoteSchema Name
typeName RelName
relationshipName ->
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs
Lens'
BuildOutputs
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
boRemoteSchemas ((HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> BuildOutputs -> Identity BuildOutputs)
-> ((InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> BuildOutputs
-> Identity BuildOutputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
-> Traversal'
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
(IxValue
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
RemoteSchemaName
remoteSchema (((RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)))
-> ((InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
-> Identity
(HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject)
forall s t a b. Field1 s t a b => Lens s t a b
_1 ((RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject))
-> ((InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> (RemoteSchemaCtx, MetadataObject)
-> Identity (RemoteSchemaCtx, MetadataObject)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name))
-> Identity
(InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))))
-> RemoteSchemaCtx -> Identity RemoteSchemaCtx
Lens'
RemoteSchemaCtx
(InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name)))
rscRemoteRelationships ((InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name))
-> Identity
(InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))))
-> RemoteSchemaCtx -> Identity RemoteSchemaCtx)
-> ((InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))
-> Identity
(InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))))
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> RemoteSchemaCtx
-> Identity RemoteSchemaCtx
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index
(InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> Traversal'
(InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name)))
(IxValue
(InsOrdHashMap
Name (InsOrdHashMap RelName (RemoteFieldInfo Name))))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index
(InsOrdHashMap Name (InsOrdHashMap RelName (RemoteFieldInfo Name)))
Name
typeName ((InsOrdHashMap RelName (RemoteFieldInfo Name)
-> Identity (InsOrdHashMap RelName (RemoteFieldInfo Name)))
-> BuildOutputs -> Identity BuildOutputs)
-> (InsOrdHashMap RelName (RemoteFieldInfo Name)
-> InsOrdHashMap RelName (RemoteFieldInfo Name))
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RelName
-> InsOrdHashMap RelName (RemoteFieldInfo Name)
-> InsOrdHashMap RelName (RemoteFieldInfo Name)
forall k v.
(Eq k, Hashable k) =>
k -> InsOrdHashMap k v -> InsOrdHashMap k v
OMap.delete RelName
relationshipName
MOCronTrigger TriggerName
name -> (HashMap TriggerName CronTriggerInfo
-> Identity (HashMap TriggerName CronTriggerInfo))
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs (HashMap TriggerName CronTriggerInfo)
boCronTriggers ((HashMap TriggerName CronTriggerInfo
-> Identity (HashMap TriggerName CronTriggerInfo))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap TriggerName CronTriggerInfo
-> HashMap TriggerName CronTriggerInfo)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ TriggerName
-> HashMap TriggerName CronTriggerInfo
-> HashMap TriggerName CronTriggerInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete TriggerName
name
MetadataObjId
MOCustomTypes -> (AnnotatedCustomTypes -> Identity AnnotatedCustomTypes)
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs AnnotatedCustomTypes
boCustomTypes ((AnnotatedCustomTypes -> Identity AnnotatedCustomTypes)
-> BuildOutputs -> Identity BuildOutputs)
-> (AnnotatedCustomTypes -> AnnotatedCustomTypes)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ AnnotatedCustomTypes
-> AnnotatedCustomTypes -> AnnotatedCustomTypes
forall a b. a -> b -> a
const AnnotatedCustomTypes
forall a. Monoid a => a
mempty
MOAction ActionName
name -> (ActionCache -> Identity ActionCache)
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs ActionCache
boActions ((ActionCache -> Identity ActionCache)
-> BuildOutputs -> Identity BuildOutputs)
-> (ActionCache -> ActionCache) -> BuildOutputs -> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ ActionName -> ActionCache -> ActionCache
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete ActionName
name
MOEndpoint EndpointName
name -> (HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> Identity
(HashMap EndpointName (EndpointMetadata GQLQueryWithText)))
-> BuildOutputs -> Identity BuildOutputs
Lens'
BuildOutputs
(HashMap EndpointName (EndpointMetadata GQLQueryWithText))
boEndpoints ((HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> Identity
(HashMap EndpointName (EndpointMetadata GQLQueryWithText)))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText))
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ EndpointName
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete EndpointName
name
MOActionPermission ActionName
name RoleName
role -> (ActionCache -> Identity ActionCache)
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs ActionCache
boActions ((ActionCache -> Identity ActionCache)
-> BuildOutputs -> Identity BuildOutputs)
-> ((HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> ActionCache -> Identity ActionCache)
-> (HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> BuildOutputs
-> Identity BuildOutputs
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index ActionCache -> Traversal' ActionCache (IxValue ActionCache)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index ActionCache
ActionName
name ((ActionInfo -> Identity ActionInfo)
-> ActionCache -> Identity ActionCache)
-> ((HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> ActionInfo -> Identity ActionInfo)
-> (HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> ActionCache
-> Identity ActionCache
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> ActionInfo -> Identity ActionInfo
Lens' ActionInfo (HashMap RoleName ActionPermissionInfo)
aiPermissions ((HashMap RoleName ActionPermissionInfo
-> Identity (HashMap RoleName ActionPermissionInfo))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap RoleName ActionPermissionInfo
-> HashMap RoleName ActionPermissionInfo)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RoleName
-> HashMap RoleName ActionPermissionInfo
-> HashMap RoleName ActionPermissionInfo
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete RoleName
role
MOInheritedRole RoleName
name -> (HashMap RoleName Role -> Identity (HashMap RoleName Role))
-> BuildOutputs -> Identity BuildOutputs
Lens' BuildOutputs (HashMap RoleName Role)
boRoles ((HashMap RoleName Role -> Identity (HashMap RoleName Role))
-> BuildOutputs -> Identity BuildOutputs)
-> (HashMap RoleName Role -> HashMap RoleName Role)
-> BuildOutputs
-> BuildOutputs
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RoleName -> HashMap RoleName Role -> HashMap RoleName Role
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete RoleName
name
MOHostTlsAllowlist String
host -> String -> BuildOutputs -> BuildOutputs
removeHostFromAllowList String
host
MOQueryCollectionsQuery CollectionName
cName ListedQuery
lq -> \bo :: BuildOutputs
bo@BuildOutputs {[TlsAllow]
HashMap RoleName Role
HashMap EndpointName (EndpointMetadata GQLQueryWithText)
HashMap SourceName BackendSourceInfo
HashMap TriggerName CronTriggerInfo
HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
ActionCache
QueryCollections
ApiLimit
InlinedAllowlist
MetricsConfig
AnnotatedCustomTypes
_boQueryCollections :: BuildOutputs -> QueryCollections
_boTlsAllowlist :: BuildOutputs -> [TlsAllow]
_boMetricsConfig :: BuildOutputs -> MetricsConfig
_boApiLimits :: BuildOutputs -> ApiLimit
_boEndpoints :: BuildOutputs
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
_boCronTriggers :: BuildOutputs -> HashMap TriggerName CronTriggerInfo
_boCustomTypes :: BuildOutputs -> AnnotatedCustomTypes
_boAllowlist :: BuildOutputs -> InlinedAllowlist
_boActions :: BuildOutputs -> ActionCache
_boQueryCollections :: QueryCollections
_boTlsAllowlist :: [TlsAllow]
_boRoles :: HashMap RoleName Role
_boMetricsConfig :: MetricsConfig
_boApiLimits :: ApiLimit
_boEndpoints :: HashMap EndpointName (EndpointMetadata GQLQueryWithText)
_boCronTriggers :: HashMap TriggerName CronTriggerInfo
_boCustomTypes :: AnnotatedCustomTypes
_boAllowlist :: InlinedAllowlist
_boRemoteSchemas :: HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
_boActions :: ActionCache
_boSources :: HashMap SourceName BackendSourceInfo
_boRoles :: BuildOutputs -> HashMap RoleName Role
_boRemoteSchemas :: BuildOutputs
-> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject)
_boSources :: BuildOutputs -> HashMap SourceName BackendSourceInfo
..} ->
BuildOutputs
bo
{ _boEndpoints :: HashMap EndpointName (EndpointMetadata GQLQueryWithText)
_boEndpoints = ListedQuery
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
removeEndpointsUsingQueryCollection ListedQuery
lq HashMap EndpointName (EndpointMetadata GQLQueryWithText)
_boEndpoints,
_boAllowlist :: InlinedAllowlist
_boAllowlist = ListedQuery -> InlinedAllowlist -> InlinedAllowlist
removeFromAllowList ListedQuery
lq InlinedAllowlist
_boAllowlist,
_boQueryCollections :: QueryCollections
_boQueryCollections = CollectionName
-> ListedQuery -> QueryCollections -> QueryCollections
removeFromQueryCollections CollectionName
cName ListedQuery
lq QueryCollections
_boQueryCollections
}
where
removeHostFromAllowList :: String -> BuildOutputs -> BuildOutputs
removeHostFromAllowList String
hst BuildOutputs
bo =
BuildOutputs
bo
{ _boTlsAllowlist :: [TlsAllow]
_boTlsAllowlist = (TlsAllow -> Bool) -> [TlsAllow] -> [TlsAllow]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (TlsAllow -> Bool) -> TlsAllow -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> TlsAllow -> Bool
checkForHostnameInAllowlistObject String
hst) (BuildOutputs -> [TlsAllow]
_boTlsAllowlist BuildOutputs
bo)
}
deleteObjId :: forall b. (Backend b) => SourceMetadataObjId b -> BackendSourceInfo -> BackendSourceInfo
deleteObjId :: SourceMetadataObjId b -> BackendSourceInfo -> BackendSourceInfo
deleteObjId SourceMetadataObjId b
sourceObjId BackendSourceInfo
sourceInfo =
BackendSourceInfo
-> (SourceInfo b -> BackendSourceInfo)
-> Maybe (SourceInfo b)
-> BackendSourceInfo
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
BackendSourceInfo
sourceInfo
(SourceInfo b -> BackendSourceInfo
forall (b :: BackendType) (i :: BackendType -> *).
HasTag b =>
i b -> AnyBackend i
AB.mkAnyBackend (SourceInfo b -> BackendSourceInfo)
-> (SourceInfo b -> SourceInfo b)
-> SourceInfo b
-> BackendSourceInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceMetadataObjId b -> SourceInfo b -> SourceInfo b
forall (b :: BackendType).
Backend b =>
SourceMetadataObjId b -> SourceInfo b -> SourceInfo b
deleteObjFn SourceMetadataObjId b
sourceObjId)
(Maybe (SourceInfo b) -> BackendSourceInfo)
-> Maybe (SourceInfo b) -> BackendSourceInfo
forall a b. (a -> b) -> a -> b
$ BackendSourceInfo -> Maybe (SourceInfo b)
forall (b :: BackendType).
HasTag b =>
BackendSourceInfo -> Maybe (SourceInfo b)
unsafeSourceInfo BackendSourceInfo
sourceInfo
deleteObjFn :: (Backend b) => SourceMetadataObjId b -> SourceInfo b -> SourceInfo b
deleteObjFn :: SourceMetadataObjId b -> SourceInfo b -> SourceInfo b
deleteObjFn = \case
SMOTable TableName b
name -> (HashMap (TableName b) (TableInfo b)
-> Identity (HashMap (TableName b) (TableInfo b)))
-> SourceInfo b -> Identity (SourceInfo b)
forall (b :: BackendType). Lens' (SourceInfo b) (TableCache b)
siTables ((HashMap (TableName b) (TableInfo b)
-> Identity (HashMap (TableName b) (TableInfo b)))
-> SourceInfo b -> Identity (SourceInfo b))
-> (HashMap (TableName b) (TableInfo b)
-> HashMap (TableName b) (TableInfo b))
-> SourceInfo b
-> SourceInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ TableName b
-> HashMap (TableName b) (TableInfo b)
-> HashMap (TableName b) (TableInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete TableName b
name
SMOFunction FunctionName b
name -> (HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> SourceInfo b -> Identity (SourceInfo b)
forall (b :: BackendType). Lens' (SourceInfo b) (FunctionCache b)
siFunctions ((HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> SourceInfo b -> Identity (SourceInfo b))
-> (HashMap (FunctionName b) (FunctionInfo b)
-> HashMap (FunctionName b) (FunctionInfo b))
-> SourceInfo b
-> SourceInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ FunctionName b
-> HashMap (FunctionName b) (FunctionInfo b)
-> HashMap (FunctionName b) (FunctionInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete FunctionName b
name
SMOFunctionPermission FunctionName b
functionName RoleName
role ->
(HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> SourceInfo b -> Identity (SourceInfo b)
forall (b :: BackendType). Lens' (SourceInfo b) (FunctionCache b)
siFunctions ((HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> SourceInfo b -> Identity (SourceInfo b))
-> ((FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> (FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> SourceInfo b
-> Identity (SourceInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (HashMap (FunctionName b) (FunctionInfo b))
-> Traversal'
(HashMap (FunctionName b) (FunctionInfo b))
(IxValue (HashMap (FunctionName b) (FunctionInfo b)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (HashMap (FunctionName b) (FunctionInfo b))
FunctionName b
functionName ((FunctionInfo b -> Identity (FunctionInfo b))
-> HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b)))
-> ((FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> FunctionInfo b -> Identity (FunctionInfo b))
-> (FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> HashMap (FunctionName b) (FunctionInfo b)
-> Identity (HashMap (FunctionName b) (FunctionInfo b))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> FunctionInfo b -> Identity (FunctionInfo b)
forall (b :: BackendType).
Lens' (FunctionInfo b) FunctionPermissionsMap
fiPermissions ((FunctionPermissionsMap -> Identity FunctionPermissionsMap)
-> SourceInfo b -> Identity (SourceInfo b))
-> (FunctionPermissionsMap -> FunctionPermissionsMap)
-> SourceInfo b
-> SourceInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ RoleName -> FunctionPermissionsMap -> FunctionPermissionsMap
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete RoleName
role
SMOTableObj TableName b
tableName TableMetadataObjId
tableObjectId ->
(HashMap (TableName b) (TableInfo b)
-> Identity (HashMap (TableName b) (TableInfo b)))
-> SourceInfo b -> Identity (SourceInfo b)
forall (b :: BackendType). Lens' (SourceInfo b) (TableCache b)
siTables ((HashMap (TableName b) (TableInfo b)
-> Identity (HashMap (TableName b) (TableInfo b)))
-> SourceInfo b -> Identity (SourceInfo b))
-> ((TableInfo b -> Identity (TableInfo b))
-> HashMap (TableName b) (TableInfo b)
-> Identity (HashMap (TableName b) (TableInfo b)))
-> (TableInfo b -> Identity (TableInfo b))
-> SourceInfo b
-> Identity (SourceInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (HashMap (TableName b) (TableInfo b))
-> Traversal'
(HashMap (TableName b) (TableInfo b))
(IxValue (HashMap (TableName b) (TableInfo b)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (HashMap (TableName b) (TableInfo b))
TableName b
tableName ((TableInfo b -> Identity (TableInfo b))
-> SourceInfo b -> Identity (SourceInfo b))
-> (TableInfo b -> TableInfo b) -> SourceInfo b -> SourceInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ case TableMetadataObjId
tableObjectId of
MTORel RelName
name RelType
_ -> (TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (TableCoreInfo b)
tiCoreInfo ((TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b))
-> ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b))
-> (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b)
forall (b :: BackendType) field1 primaryKeyColumn field2.
Lens
(TableCoreInfoG b field1 primaryKeyColumn)
(TableCoreInfoG b field2 primaryKeyColumn)
(FieldInfoMap field1)
(FieldInfoMap field2)
tciFieldInfoMap ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> (FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b))
-> TableInfo b
-> TableInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ FieldName
-> FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete (RelName -> FieldName
fromRel RelName
name)
MTOComputedField ComputedFieldName
name -> (TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (TableCoreInfo b)
tiCoreInfo ((TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b))
-> ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b))
-> (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b)
forall (b :: BackendType) field1 primaryKeyColumn field2.
Lens
(TableCoreInfoG b field1 primaryKeyColumn)
(TableCoreInfoG b field2 primaryKeyColumn)
(FieldInfoMap field1)
(FieldInfoMap field2)
tciFieldInfoMap ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> (FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b))
-> TableInfo b
-> TableInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ FieldName
-> FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete (ComputedFieldName -> FieldName
fromComputedField ComputedFieldName
name)
MTORemoteRelationship RelName
name -> (TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (TableCoreInfo b)
tiCoreInfo ((TableCoreInfo b -> Identity (TableCoreInfo b))
-> TableInfo b -> Identity (TableInfo b))
-> ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b))
-> (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableCoreInfo b -> Identity (TableCoreInfo b)
forall (b :: BackendType) field1 primaryKeyColumn field2.
Lens
(TableCoreInfoG b field1 primaryKeyColumn)
(TableCoreInfoG b field2 primaryKeyColumn)
(FieldInfoMap field1)
(FieldInfoMap field2)
tciFieldInfoMap ((FieldInfoMap (FieldInfo b)
-> Identity (FieldInfoMap (FieldInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> (FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b))
-> TableInfo b
-> TableInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ FieldName
-> FieldInfoMap (FieldInfo b) -> FieldInfoMap (FieldInfo b)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete (RelName -> FieldName
fromRemoteRelationship RelName
name)
MTOTrigger TriggerName
name -> (EventTriggerInfoMap b -> Identity (EventTriggerInfoMap b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType).
Lens' (TableInfo b) (EventTriggerInfoMap b)
tiEventTriggerInfoMap ((EventTriggerInfoMap b -> Identity (EventTriggerInfoMap b))
-> TableInfo b -> Identity (TableInfo b))
-> (EventTriggerInfoMap b -> EventTriggerInfoMap b)
-> TableInfo b
-> TableInfo b
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ TriggerName -> EventTriggerInfoMap b -> EventTriggerInfoMap b
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete TriggerName
name
MTOPerm RoleName
roleName PermType
PTSelect -> (RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (RolePermInfoMap b)
tiRolePermInfoMap ((RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b))
-> ((Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> (Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (RolePermInfoMap b)
-> Traversal' (RolePermInfoMap b) (IxValue (RolePermInfoMap b))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (RolePermInfoMap b)
RoleName
roleName ((RolePermInfo b -> Identity (RolePermInfo b))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> ((Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b))
-> (Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> RolePermInfoMap b
-> Identity (RolePermInfoMap b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b)
forall (b :: BackendType).
Lens' (RolePermInfo b) (Maybe (SelPermInfo b))
permSel ((Maybe (SelPermInfo b) -> Identity (Maybe (SelPermInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> Maybe (SelPermInfo b) -> TableInfo b -> TableInfo b
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe (SelPermInfo b)
forall a. Maybe a
Nothing
MTOPerm RoleName
roleName PermType
PTInsert -> (RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (RolePermInfoMap b)
tiRolePermInfoMap ((RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b))
-> ((Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> (Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (RolePermInfoMap b)
-> Traversal' (RolePermInfoMap b) (IxValue (RolePermInfoMap b))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (RolePermInfoMap b)
RoleName
roleName ((RolePermInfo b -> Identity (RolePermInfo b))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> ((Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b))
-> (Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> RolePermInfoMap b
-> Identity (RolePermInfoMap b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b)
forall (b :: BackendType).
Lens' (RolePermInfo b) (Maybe (InsPermInfo b))
permIns ((Maybe (InsPermInfo b) -> Identity (Maybe (InsPermInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> Maybe (InsPermInfo b) -> TableInfo b -> TableInfo b
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe (InsPermInfo b)
forall a. Maybe a
Nothing
MTOPerm RoleName
roleName PermType
PTUpdate -> (RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (RolePermInfoMap b)
tiRolePermInfoMap ((RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b))
-> ((Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> (Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (RolePermInfoMap b)
-> Traversal' (RolePermInfoMap b) (IxValue (RolePermInfoMap b))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (RolePermInfoMap b)
RoleName
roleName ((RolePermInfo b -> Identity (RolePermInfo b))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> ((Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b))
-> (Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> RolePermInfoMap b
-> Identity (RolePermInfoMap b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b)
forall (b :: BackendType).
Lens' (RolePermInfo b) (Maybe (UpdPermInfo b))
permUpd ((Maybe (UpdPermInfo b) -> Identity (Maybe (UpdPermInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> Maybe (UpdPermInfo b) -> TableInfo b -> TableInfo b
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe (UpdPermInfo b)
forall a. Maybe a
Nothing
MTOPerm RoleName
roleName PermType
PTDelete -> (RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b)
forall (b :: BackendType). Lens' (TableInfo b) (RolePermInfoMap b)
tiRolePermInfoMap ((RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> TableInfo b -> Identity (TableInfo b))
-> ((Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> (Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> TableInfo b
-> Identity (TableInfo b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (RolePermInfoMap b)
-> Traversal' (RolePermInfoMap b) (IxValue (RolePermInfoMap b))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index (RolePermInfoMap b)
RoleName
roleName ((RolePermInfo b -> Identity (RolePermInfo b))
-> RolePermInfoMap b -> Identity (RolePermInfoMap b))
-> ((Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b))
-> (Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> RolePermInfoMap b
-> Identity (RolePermInfoMap b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> RolePermInfo b -> Identity (RolePermInfo b)
forall (b :: BackendType).
Lens' (RolePermInfo b) (Maybe (DelPermInfo b))
permDel ((Maybe (DelPermInfo b) -> Identity (Maybe (DelPermInfo b)))
-> TableInfo b -> Identity (TableInfo b))
-> Maybe (DelPermInfo b) -> TableInfo b -> TableInfo b
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe (DelPermInfo b)
forall a. Maybe a
Nothing
removeFromQueryCollections :: CollectionName -> ListedQuery -> QueryCollections -> QueryCollections
removeFromQueryCollections :: CollectionName
-> ListedQuery -> QueryCollections -> QueryCollections
removeFromQueryCollections CollectionName
cName ListedQuery
lq QueryCollections
qc =
let collectionModifier :: CreateCollection -> CreateCollection
collectionModifier :: CreateCollection -> CreateCollection
collectionModifier cc :: CreateCollection
cc@CreateCollection {Maybe Text
CollectionName
CollectionDef
_ccComment :: CreateCollection -> Maybe Text
_ccDefinition :: CreateCollection -> CollectionDef
_ccName :: CreateCollection -> CollectionName
_ccComment :: Maybe Text
_ccDefinition :: CollectionDef
_ccName :: CollectionName
..} =
CreateCollection
cc
{ _ccDefinition :: CollectionDef
_ccDefinition =
let oldQueries :: [ListedQuery]
oldQueries = CollectionDef -> [ListedQuery]
_cdQueries CollectionDef
_ccDefinition
in CollectionDef
_ccDefinition
{ _cdQueries :: [ListedQuery]
_cdQueries = (ListedQuery -> Bool) -> [ListedQuery] -> [ListedQuery]
forall a. (a -> Bool) -> [a] -> [a]
filter (ListedQuery -> ListedQuery -> Bool
forall a. Eq a => a -> a -> Bool
/= ListedQuery
lq) [ListedQuery]
oldQueries
}
}
in (CreateCollection -> CreateCollection)
-> CollectionName -> QueryCollections -> QueryCollections
forall k v.
(Eq k, Hashable k) =>
(v -> v) -> k -> InsOrdHashMap k v -> InsOrdHashMap k v
OMap.adjust CreateCollection -> CreateCollection
collectionModifier CollectionName
cName QueryCollections
qc
removeEndpointsUsingQueryCollection :: ListedQuery -> HashMap EndpointName (EndpointMetadata GQLQueryWithText) -> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
removeEndpointsUsingQueryCollection :: ListedQuery
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
removeEndpointsUsingQueryCollection ListedQuery
lq HashMap EndpointName (EndpointMetadata GQLQueryWithText)
endpointMap =
case Maybe (EndpointName, EndpointMetadata GQLQueryWithText)
maybeEndpoint of
Just (EndpointName
n, EndpointMetadata GQLQueryWithText
_) -> EndpointName
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
forall k v. (Eq k, Hashable k) => k -> HashMap k v -> HashMap k v
M.delete EndpointName
n HashMap EndpointName (EndpointMetadata GQLQueryWithText)
endpointMap
Maybe (EndpointName, EndpointMetadata GQLQueryWithText)
Nothing -> HashMap EndpointName (EndpointMetadata GQLQueryWithText)
endpointMap
where
q :: GQLQueryWithText
q = ListedQuery -> GQLQueryWithText
_lqQuery ListedQuery
lq
maybeEndpoint :: Maybe (EndpointName, EndpointMetadata GQLQueryWithText)
maybeEndpoint = ((EndpointName, EndpointMetadata GQLQueryWithText) -> Bool)
-> [(EndpointName, EndpointMetadata GQLQueryWithText)]
-> Maybe (EndpointName, EndpointMetadata GQLQueryWithText)
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find (\(EndpointName
_, EndpointMetadata GQLQueryWithText
def) -> (EndpointDef GQLQueryWithText -> GQLQueryWithText
forall query. EndpointDef query -> query
_edQuery (EndpointDef GQLQueryWithText -> GQLQueryWithText)
-> (EndpointMetadata GQLQueryWithText
-> EndpointDef GQLQueryWithText)
-> EndpointMetadata GQLQueryWithText
-> GQLQueryWithText
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EndpointMetadata GQLQueryWithText -> EndpointDef GQLQueryWithText
forall query. EndpointMetadata query -> EndpointDef query
_ceDefinition) EndpointMetadata GQLQueryWithText
def GQLQueryWithText -> GQLQueryWithText -> Bool
forall a. Eq a => a -> a -> Bool
== GQLQueryWithText
q) (HashMap EndpointName (EndpointMetadata GQLQueryWithText)
-> [(EndpointName, EndpointMetadata GQLQueryWithText)]
forall k v. HashMap k v -> [(k, v)]
M.toList HashMap EndpointName (EndpointMetadata GQLQueryWithText)
endpointMap)
removeFromAllowList :: ListedQuery -> InlinedAllowlist -> InlinedAllowlist
removeFromAllowList :: ListedQuery -> InlinedAllowlist -> InlinedAllowlist
removeFromAllowList ListedQuery
lq InlinedAllowlist
aList =
let oldAList :: HashSet NormalizedQuery
oldAList = InlinedAllowlist -> HashSet NormalizedQuery
iaGlobal InlinedAllowlist
aList
gqlQry :: NormalizedQuery
gqlQry = ExecutableDocument Name -> NormalizedQuery
NormalizedQuery (ExecutableDocument Name -> NormalizedQuery)
-> (ListedQuery -> ExecutableDocument Name)
-> ListedQuery
-> NormalizedQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GQLQuery -> ExecutableDocument Name
unGQLQuery (GQLQuery -> ExecutableDocument Name)
-> (ListedQuery -> GQLQuery)
-> ListedQuery
-> ExecutableDocument Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GQLQueryWithText -> GQLQuery
getGQLQuery (GQLQueryWithText -> GQLQuery)
-> (ListedQuery -> GQLQueryWithText) -> ListedQuery -> GQLQuery
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ListedQuery -> GQLQueryWithText
_lqQuery (ListedQuery -> NormalizedQuery) -> ListedQuery -> NormalizedQuery
forall a b. (a -> b) -> a -> b
$ ListedQuery
lq
newAList :: HashSet NormalizedQuery
newAList = NormalizedQuery
-> HashSet NormalizedQuery -> HashSet NormalizedQuery
forall a. (Eq a, Hashable a) => a -> HashSet a -> HashSet a
HS.delete NormalizedQuery
gqlQry HashSet NormalizedQuery
oldAList
in InlinedAllowlist
aList
{ iaGlobal :: HashSet NormalizedQuery
iaGlobal = HashSet NormalizedQuery
newAList
}