Copyright | (c) Soostone Inc 2020 |
---|---|
License | AllRightsReserved |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Napkin.Spec.Types.Spec
Description
Synopsis
- data SpecTarget b
- data TableSpec b = TableSpec {
- _specTable :: Ref Table
- _specAction :: SpecProgram b
- _specPreHooks :: [HookProgram b]
- _specPostHooks :: [HookProgram b]
- _specUpdate :: [UpdateStrategy]
- _specGrants :: [([Privilege], [Actor])]
- _specTags :: [TableSpecTag]
- type TableSpecTag = Text
- data UpdateStrategy
- type SpecTableMap b = Map (Ref Table) (TableSpec b)
- data Specs b = Specs {
- _specsTables :: SpecTableMap b
- _specsHooks :: [([Ref Table], HookProgram b)]
- _specsMetaArgs :: SpecMetaArgs
- _specsTransformer :: QueryTransformer
- newtype Spec b a = Spec {}
- newtype CustomValidator = CustomValidator (SpecMetaArgs -> Ref Table -> Maybe FilePath -> Query -> [Text])
- newtype ExternMacros = ExternMacros (Map (Ref Function) (ExternFun -> SExp))
- newtype SpecPreprocessorWithArgParser b = SpecPreprocessorWithArgParser (Object -> Parser (SpecPreprocessor b))
- type SpecPreprocessor b = Sem [Input SpecPaths, Input MetaArguments, State (Specs b), FatalError, Embed IO, Log] ()
- type SpecPreprocessorFunc bk = SpecMetaArgs -> Specs bk -> Specs bk
- pattern NapkinTablePrefix :: (Eq a, IsString a) => a
- isTemporaryTable :: Ref Table -> Bool
- runSpec :: Spec b a -> IO (Specs b)
- runSpecE :: ExceptT e (Spec b) a -> IO (Either e (Specs b))
- specUpdate :: forall b. Lens' (TableSpec b) [UpdateStrategy]
- specTags :: forall b. Lens' (TableSpec b) [TableSpecTag]
- specTable :: forall b. Lens' (TableSpec b) (Ref Table)
- specPreHooks :: forall b. Lens' (TableSpec b) [HookProgram b]
- specPostHooks :: forall b. Lens' (TableSpec b) [HookProgram b]
- specGrants :: forall b. Lens' (TableSpec b) [([Privilege], [Actor])]
- specAction :: forall b. Lens' (TableSpec b) (SpecProgram b)
- specsTransformer :: forall b. Lens' (Specs b) QueryTransformer
- specsTables :: forall b. Lens' (Specs b) (SpecTableMap b)
- specsMetaArgs :: forall b. Lens' (Specs b) SpecMetaArgs
- specsHooks :: forall b. Lens' (Specs b) [([Ref Table], HookProgram b)]
- allSpecsTables :: Specs b -> Set (Ref Table)
- defineTable :: TableSpec b -> Spec b ()
- setAllTableGrants :: MonadState (Specs b) m => [([Privilege], [Actor])] -> m ()
Documentation
data SpecTarget b #
Constructors
SpecTable (BackendTableMeta b) | |
SpecView (BackendViewMeta b) | |
SpecMaterializedView (BackendMaterializedViewMeta b) |
Constructors
TableSpec | |
Fields
|
Instances
ToJSON (TableSpec b) # | |
Defined in Napkin.Spec.Types.Spec | |
ToObject (TableSpec b) # | |
Defined in Napkin.Spec.Types.Spec | |
LogItem (TableSpec b) # | |
Defined in Napkin.Spec.Types.Spec Methods payloadKeys :: Verbosity -> TableSpec b -> PayloadSelection # | |
AsRelation (TableSpec b) # | |
Defined in Napkin.Spec.Types.Spec Methods asRelation :: TableSpec b -> Relation # | |
TableRef (TableSpec b) # | |
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.
Instances
Constructors
Specs | |
Fields
|
Instances
Generic (Specs b) # | |
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-0.5.13-8705pBGlgyp7AIaYGNE2fM" 'False) (C1 ('MetaCons "Specs" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_specsTables") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SpecTableMap b)) :*: S1 ('MetaSel ('Just "_specsHooks") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [([Ref Table], HookProgram b)])) :*: (S1 ('MetaSel ('Just "_specsMetaArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SpecMetaArgs) :*: S1 ('MetaSel ('Just "_specsTransformer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 QueryTransformer)))) |
Instances
Monad (Spec b) # | |
Functor (Spec b) # | |
Applicative (Spec b) # | |
MonadIO (Spec b) # | |
Defined in Napkin.Spec.Types.Spec | |
MonadThrow (Spec b) # | |
Defined in Napkin.Spec.Types.Spec | |
MonadCatch (Spec b) # | |
MonadMask (Spec b) # | |
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 (SpecMetaArgs -> Ref Table -> Maybe FilePath -> Query -> [Text]) |
Instances
Default CustomValidator # | |
Defined in Napkin.Spec.Types.Spec Methods def :: CustomValidator # |
newtype ExternMacros #
Instances
IsList ExternMacros # | |
Defined in Napkin.Spec.Types.Spec Associated Types type Item ExternMacros # Methods fromList :: [Item ExternMacros] -> ExternMacros # fromListN :: Int -> [Item ExternMacros] -> ExternMacros # toList :: ExternMacros -> [Item ExternMacros] # | |
Semigroup ExternMacros # | |
Defined in Napkin.Spec.Types.Spec Methods (<>) :: ExternMacros -> ExternMacros -> ExternMacros # sconcat :: NonEmpty ExternMacros -> ExternMacros # stimes :: Integral b => b -> ExternMacros -> ExternMacros # | |
Monoid ExternMacros # | |
Defined in Napkin.Spec.Types.Spec Methods mempty :: ExternMacros # mappend :: ExternMacros -> ExternMacros -> ExternMacros # mconcat :: [ExternMacros] -> 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 (SpecPreprocessor b)) |
type SpecPreprocessor b = Sem [Input SpecPaths, Input MetaArguments, State (Specs b), FatalError, Embed IO, Log] () #
type SpecPreprocessorFunc bk = SpecMetaArgs -> Specs bk -> Specs bk #
pattern NapkinTablePrefix :: (Eq a, IsString a) => a #
isTemporaryTable :: Ref Table -> Bool #
specUpdate :: forall b. Lens' (TableSpec b) [UpdateStrategy] #
specTags :: forall b. Lens' (TableSpec b) [TableSpecTag] #
specPreHooks :: forall b. Lens' (TableSpec b) [HookProgram b] #
specPostHooks :: forall b. Lens' (TableSpec b) [HookProgram b] #
specAction :: forall b. Lens' (TableSpec b) (SpecProgram b) #
specsTransformer :: forall b. Lens' (Specs b) QueryTransformer #
specsTables :: forall b. Lens' (Specs b) (SpecTableMap b) #
specsMetaArgs :: forall b. Lens' (Specs b) SpecMetaArgs #
specsHooks :: forall b. Lens' (Specs b) [([Ref Table], HookProgram b)] #
allSpecsTables :: Specs b -> Set (Ref Table) #
All tables that are being created/managed as part of this spec.
defineTable :: TableSpec b -> Spec b () #
setAllTableGrants :: MonadState (Specs b) m => [([Privilege], [Actor])] -> m () #
Set the same Grant
permissions for all tables defined in the
spec at once. Convenience function for a common use case. Acts
monadically, so it will apply to all specs so far defined in the
Spec
block.