Safe Haskell | None |
---|---|
Language | GHC2021 |
Napkin.Spec.Types.Spec
Synopsis
- data SpecTarget b
- data TableSpec b = TableSpec {
- table :: SpecTableName
- action :: SpecProgram b
- preHooks :: [Hook b]
- postHooks :: [Hook b]
- update :: [UpdateStrategy]
- grants :: [([Privilege], [Actor])]
- tags :: Set TableSpecTag
- type TableSpecTag = Text
- data UpdateStrategy
- type SpecTableMap b = Map SpecTableName (TableSpec b)
- type GlobalHooks b = Map Text ([SpecTableName], GlobalHookProgram b)
- data Specs b = Specs {}
- newtype Spec b a = Spec {}
- newtype CustomValidator = CustomValidator {
- unCustomValidator :: SpecMetaArgs -> Ref Table -> Maybe FilePath -> Query -> [Text]
- newtype ExternMacros = ExternMacros (Map (Ref Function) (ExternFun -> SExp))
- newtype SpecPreprocessorWithArgParser b = SpecPreprocessorWithArgParser (Object -> Parser (SpecProgramArguments, SpecPreprocessor b))
- parserlessPreprocessor :: SpecPreprocessor b -> SpecPreprocessorWithArgParser b
- data SpecDependency
- toRef :: SpecDependency -> Ref Table
- toSpecTable :: SpecDependency -> Maybe SpecTableName
- isManaged :: SpecDependency -> Bool
- type SpecsDeps = Map SpecTableName (Set SpecDependency)
- type DepsValidator = (SpecDependency -> Ref Table) -> SpecsDeps -> [Text]
- type SpecPreprocessor b = Sem '[Input SpecPaths :: (Type -> Type) -> Type -> Type, Input MetaArguments :: (Type -> Type) -> Type -> Type, State (Specs b) :: (Type -> Type) -> Type -> Type, Output DepsValidator :: (Type -> Type) -> Type -> Type, FatalError :: (Type -> Type) -> Type -> Type, Embed IO, Log :: (Type -> Type) -> Type -> Type] ()
- type SpecPreprocessorFunc bk = SpecMetaArgs -> Specs bk -> Specs bk
- runSpec :: SpecPaths -> Spec b a -> IO (Specs b)
- runSpecE :: SpecPaths -> ExceptT e (Spec b) a -> IO (Either e (Specs b))
- runSpecE' :: SpecPaths -> Specs b -> ExceptT e (Spec b) a -> IO (Either e (a, Specs b))
- specAddPreHooks :: [HookProgram b] -> TableSpec b -> TableSpec b
- specAddPostHooks :: [HookProgram b] -> TableSpec b -> TableSpec b
- specAddAsyncPreHooks :: [HookProgram b] -> TableSpec b -> TableSpec b
- specAddAsyncPostHooks :: [HookProgram b] -> TableSpec b -> TableSpec b
- allSpecsTables :: Specs b -> Set SpecTableName
- defineTable :: TableSpec b -> Spec b ()
- specTable :: forall b f. Functor f => (SpecTableName -> f SpecTableName) -> TableSpec b -> f (TableSpec b)
- specAction :: forall b f. Functor f => (SpecProgram b -> f (SpecProgram b)) -> TableSpec b -> f (TableSpec b)
- specUpdate :: forall b f. Functor f => ([UpdateStrategy] -> f [UpdateStrategy]) -> TableSpec b -> f (TableSpec b)
- specGrants :: forall b f. Functor f => ([([Privilege], [Actor])] -> f [([Privilege], [Actor])]) -> TableSpec b -> f (TableSpec b)
- specTags :: forall b f. Functor f => (Set TableSpecTag -> f (Set TableSpecTag)) -> TableSpec b -> f (TableSpec b)
- specsTables :: forall b f. Functor f => (SpecTableMap b -> f (SpecTableMap b)) -> Specs b -> f (Specs b)
- specsHooks :: forall b f. Functor f => (GlobalHooks b -> f (GlobalHooks b)) -> Specs b -> f (Specs b)
- specsMetaArgs :: forall b f. Functor f => (SpecMetaArgs -> f SpecMetaArgs) -> Specs b -> f (Specs b)
- specsTransformer :: forall b f. Functor f => (QueryTransformer -> f QueryTransformer) -> Specs b -> f (Specs b)
Documentation
data SpecTarget b #
Constructors
SpecTable (BackendTableMeta b) | |
SpecView (BackendViewMeta b) | |
SpecMaterializedView (BackendMaterializedViewMeta b) |
Constructors
TableSpec | |
Fields
|
Instances
type TableSpecTag = Text #
data UpdateStrategy #
Each strategy acts independently. For example, if you have only UpdateWithDependency, it wouldn't update even if the table were missing. You need to specify each strategy in the list.
Constructors
UpdateAlways | |
UpdatePeriodically NominalDiffTime | |
UpdateWithDependency | |
UpdateIfMissing | |
UpdateIfErroredLastRun |
Instances
Data UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UpdateStrategy -> c UpdateStrategy # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UpdateStrategy # toConstr :: UpdateStrategy -> Constr # dataTypeOf :: UpdateStrategy -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UpdateStrategy) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UpdateStrategy) # gmapT :: (forall b. Data b => b -> b) -> UpdateStrategy -> UpdateStrategy # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UpdateStrategy -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UpdateStrategy -> r # gmapQ :: (forall d. Data d => d -> u) -> UpdateStrategy -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> UpdateStrategy -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UpdateStrategy -> m UpdateStrategy # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UpdateStrategy -> m UpdateStrategy # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UpdateStrategy -> m UpdateStrategy # | |||||
Generic UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec Associated Types
Methods from :: UpdateStrategy -> Rep UpdateStrategy x # to :: Rep UpdateStrategy x -> UpdateStrategy # | |||||
Show UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec Methods showsPrec :: Int -> UpdateStrategy -> ShowS # show :: UpdateStrategy -> String # showList :: [UpdateStrategy] -> ShowS # | |||||
Eq UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec Methods (==) :: UpdateStrategy -> UpdateStrategy -> Bool # (/=) :: UpdateStrategy -> UpdateStrategy -> Bool # | |||||
Ord UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec Methods compare :: UpdateStrategy -> UpdateStrategy -> Ordering # (<) :: UpdateStrategy -> UpdateStrategy -> Bool # (<=) :: UpdateStrategy -> UpdateStrategy -> Bool # (>) :: UpdateStrategy -> UpdateStrategy -> Bool # (>=) :: UpdateStrategy -> UpdateStrategy -> Bool # max :: UpdateStrategy -> UpdateStrategy -> UpdateStrategy # min :: UpdateStrategy -> UpdateStrategy -> UpdateStrategy # | |||||
type Rep UpdateStrategy # | |||||
Defined in Napkin.Spec.Types.Spec type Rep UpdateStrategy = D1 ('MetaData "UpdateStrategy" "Napkin.Spec.Types.Spec" "napkin-1.0.0-5YkWAC9Wc776PT0LDghaFb" 'False) ((C1 ('MetaCons "UpdateAlways" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UpdatePeriodically" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NominalDiffTime))) :+: (C1 ('MetaCons "UpdateWithDependency" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "UpdateIfMissing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UpdateIfErroredLastRun" 'PrefixI 'False) (U1 :: Type -> Type)))) |
type SpecTableMap b = Map SpecTableName (TableSpec b) #
type GlobalHooks b = Map Text ([SpecTableName], GlobalHookProgram b) #
Constructors
Specs | |
Fields
|
Instances
Generic (Specs b) # | |||||
Defined in Napkin.Spec.Types.Spec Associated Types
| |||||
Default (Specs b) # | |||||
Defined in Napkin.Spec.Types.Spec | |||||
MonadState (Specs b) (Spec b) # | |||||
type Rep (Specs b) # | |||||
Defined in Napkin.Spec.Types.Spec type Rep (Specs b) = D1 ('MetaData "Specs" "Napkin.Spec.Types.Spec" "napkin-1.0.0-5YkWAC9Wc776PT0LDghaFb" 'False) (C1 ('MetaCons "Specs" 'PrefixI 'True) ((S1 ('MetaSel ('Just "tables") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SpecTableMap b)) :*: S1 ('MetaSel ('Just "hooks") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (GlobalHooks b))) :*: (S1 ('MetaSel ('Just "metaArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SpecMetaArgs) :*: S1 ('MetaSel ('Just "transformer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QueryTransformer)))) |
Instances
MonadReader SpecPaths (Spec b) # | |
MonadIO (Spec b) # | |
Defined in Napkin.Spec.Types.Spec | |
Applicative (Spec b) # | |
Functor (Spec b) # | |
Monad (Spec b) # | |
MonadCatch (Spec b) # | |
Defined in Napkin.Spec.Types.Spec | |
MonadMask (Spec b) # | |
Defined in Napkin.Spec.Types.Spec Methods mask :: HasCallStack => ((forall a. Spec b a -> Spec b a) -> Spec b b0) -> Spec b b0 # uninterruptibleMask :: HasCallStack => ((forall a. Spec b a -> Spec b a) -> Spec b b0) -> Spec b b0 # generalBracket :: HasCallStack => Spec b a -> (a -> ExitCase b0 -> Spec b c) -> (a -> Spec b b0) -> Spec b (b0, c) # | |
MonadThrow (Spec b) # | |
Defined in Napkin.Spec.Types.Spec Methods throwM :: (HasCallStack, Exception e) => e -> Spec b a # | |
MonadState (Specs b) (Spec b) # | |
newtype CustomValidator #
CustomValidator
s are run before namespacing and return a list of errors in the incoming Spec.
TODO. I find this outmoded - it's a very restrictive form of doing custom validations. The new effect machinery is much richer in being able to introspect different types of database interactions under the SqlBackend type. Keeping this for legacy compatibility for now.
Constructors
CustomValidator | |
Fields
|
Instances
Default CustomValidator # | |
Defined in Napkin.Spec.Types.Spec Methods def :: CustomValidator # |
newtype ExternMacros #
Instances
Monoid ExternMacros # | |||||
Defined in Napkin.Spec.Types.Spec Methods mempty :: ExternMacros # mappend :: ExternMacros -> ExternMacros -> ExternMacros # mconcat :: [ExternMacros] -> ExternMacros # | |||||
Semigroup ExternMacros # | |||||
Defined in Napkin.Spec.Types.Spec Methods (<>) :: ExternMacros -> ExternMacros -> ExternMacros # sconcat :: NonEmpty ExternMacros -> ExternMacros # stimes :: Integral b => b -> ExternMacros -> ExternMacros # | |||||
IsList ExternMacros # | |||||
Defined in Napkin.Spec.Types.Spec Associated Types
Methods fromList :: [Item ExternMacros] -> ExternMacros # fromListN :: Int -> [Item ExternMacros] -> ExternMacros # toList :: ExternMacros -> [Item ExternMacros] # | |||||
Default ExternMacros # | |||||
Defined in Napkin.Spec.Types.Spec Methods def :: ExternMacros # | |||||
type Item ExternMacros # | |||||
Defined in Napkin.Spec.Types.Spec |
newtype SpecPreprocessorWithArgParser b #
Constructors
SpecPreprocessorWithArgParser (Object -> Parser (SpecProgramArguments, SpecPreprocessor b)) |
data SpecDependency #
Constructors
Managed SpecTableName | |
UnManaged (Ref Table) |
Instances
Show SpecDependency # | |
Defined in Napkin.Spec.Types.Spec Methods showsPrec :: Int -> SpecDependency -> ShowS # show :: SpecDependency -> String # showList :: [SpecDependency] -> ShowS # | |
Buildable SpecDependency # | |
Defined in Napkin.Spec.Types.Spec Methods build :: SpecDependency -> Builder # | |
Eq SpecDependency # | |
Defined in Napkin.Spec.Types.Spec Methods (==) :: SpecDependency -> SpecDependency -> Bool # (/=) :: SpecDependency -> SpecDependency -> Bool # | |
Ord SpecDependency # | |
Defined in Napkin.Spec.Types.Spec Methods compare :: SpecDependency -> SpecDependency -> Ordering # (<) :: SpecDependency -> SpecDependency -> Bool # (<=) :: SpecDependency -> SpecDependency -> Bool # (>) :: SpecDependency -> SpecDependency -> Bool # (>=) :: SpecDependency -> SpecDependency -> Bool # max :: SpecDependency -> SpecDependency -> SpecDependency # min :: SpecDependency -> SpecDependency -> SpecDependency # |
toRef :: SpecDependency -> Ref Table #
isManaged :: SpecDependency -> Bool #
type SpecsDeps = Map SpecTableName (Set SpecDependency) #
type DepsValidator = (SpecDependency -> Ref Table) -> SpecsDeps -> [Text] #
type SpecPreprocessor b = Sem '[Input SpecPaths :: (Type -> Type) -> Type -> Type, Input MetaArguments :: (Type -> Type) -> Type -> Type, State (Specs b) :: (Type -> Type) -> Type -> Type, Output DepsValidator :: (Type -> Type) -> Type -> Type, FatalError :: (Type -> Type) -> Type -> Type, Embed IO, Log :: (Type -> Type) -> Type -> Type] () #
type SpecPreprocessorFunc bk = SpecMetaArgs -> Specs bk -> Specs bk #
specAddPreHooks :: [HookProgram b] -> TableSpec b -> TableSpec b #
specAddPostHooks :: [HookProgram b] -> TableSpec b -> TableSpec b #
specAddAsyncPreHooks :: [HookProgram b] -> TableSpec b -> TableSpec b #
specAddAsyncPostHooks :: [HookProgram b] -> TableSpec b -> TableSpec b #
allSpecsTables :: Specs b -> Set SpecTableName #
All tables that are being created/managed as part of this spec.
defineTable :: TableSpec b -> Spec b () #
specTable :: forall b f. Functor f => (SpecTableName -> f SpecTableName) -> TableSpec b -> f (TableSpec b) #
specAction :: forall b f. Functor f => (SpecProgram b -> f (SpecProgram b)) -> TableSpec b -> f (TableSpec b) #
specUpdate :: forall b f. Functor f => ([UpdateStrategy] -> f [UpdateStrategy]) -> TableSpec b -> f (TableSpec b) #
specGrants :: forall b f. Functor f => ([([Privilege], [Actor])] -> f [([Privilege], [Actor])]) -> TableSpec b -> f (TableSpec b) #
specTags :: forall b f. Functor f => (Set TableSpecTag -> f (Set TableSpecTag)) -> TableSpec b -> f (TableSpec b) #
specsTables :: forall b f. Functor f => (SpecTableMap b -> f (SpecTableMap b)) -> Specs b -> f (Specs b) #
specsHooks :: forall b f. Functor f => (GlobalHooks b -> f (GlobalHooks b)) -> Specs b -> f (Specs b) #
specsMetaArgs :: forall b f. Functor f => (SpecMetaArgs -> f SpecMetaArgs) -> Specs b -> f (Specs b) #
specsTransformer :: forall b f. Functor f => (QueryTransformer -> f QueryTransformer) -> Specs b -> f (Specs b) #