Safe Haskell | None |
---|---|
Language | GHC2024 |
Napkin.Spec.Types.Spec
Contents
Synopsis
- data SpecTarget b
- data TableSpec b = TableSpec {
- table :: SpecTableName
- action :: SpecProgram b
- preHooks :: [Hook b]
- postHooks :: [Hook b]
- update :: [UpdateStrategy]
- tags :: Set TableSpecTag
- type TableSpecTag = Text
- data UpdateStrategy
- type SpecTableMap b = Map SpecTableName (TableSpec b)
- data SpecGlobalHook b
- type GlobalHooks b = Map Text ([SpecTableName], SpecGlobalHook b)
- data Specs b = Specs {}
- newtype Spec b a = Spec {}
- newtype CustomValidator = CustomValidator {
- unCustomValidator :: SpecMetaArgs -> Ref Table -> Maybe FilePath -> Query -> [Text]
- newtype SpecPreprocessorWithArgParser b = SpecPreprocessorWithArgParser (Object -> Parser (SpecProgramArguments, SpecPreprocessor b))
- parserlessPreprocessor :: SpecPreprocessor b -> SpecPreprocessorWithArgParser b
- toRef :: SpecDependency -> Ref Table
- allTasksInSpecsDeps :: SpecsDepsTables -> Set (WithSpecTable SpecDependency)
- allUnmanagedTasksInSpec :: SpecsDepsTables -> Set (WithSpecTable (Ref Table))
- type DepsValidator = (SpecDependency -> Ref Table) -> SpecsDepsTables -> [WithSpecTable 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)
- 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)
- specTagRefMap :: [TableSpec b] -> Map (Maybe TableSpecTag) [SpecTableName]
- specListTags :: forall bk m. MonadIO m => Specs bk -> m ()
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-spec-2.0.0-Ao336UkBpjqJSNowZIZviC" '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) #
data SpecGlobalHook b #
Constructors
PureSpecGlobalHook (PureGlobalHookProgram b) | |
IOSpecGlobalHook (IOGlobalHookProgram b) |
Instances
Generic b => Generic (SpecGlobalHook b) # | |||||
Defined in Napkin.Spec.Types.Spec Associated Types
Methods from :: SpecGlobalHook b -> Rep (SpecGlobalHook b) x # to :: Rep (SpecGlobalHook b) x -> SpecGlobalHook b # | |||||
type Rep (SpecGlobalHook b) # | |||||
Defined in Napkin.Spec.Types.Spec type Rep (SpecGlobalHook b) = D1 ('MetaData "SpecGlobalHook" "Napkin.Spec.Types.Spec" "napkin-spec-2.0.0-Ao336UkBpjqJSNowZIZviC" 'False) (C1 ('MetaCons "PureSpecGlobalHook" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PureGlobalHookProgram b))) :+: C1 ('MetaCons "IOSpecGlobalHook" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (IOGlobalHookProgram b)))) |
type GlobalHooks b = Map Text ([SpecTableName], SpecGlobalHook b) #
Constructors
Specs | |
Fields
|
Instances
Default (Specs b) # | |||||
Defined in Napkin.Spec.Types.Spec | |||||
Generic (Specs b) # | |||||
Defined in Napkin.Spec.Types.Spec Associated Types
| |||||
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-spec-2.0.0-Ao336UkBpjqJSNowZIZviC" '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 | |
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 # | |
Applicative (Spec b) # | |
Functor (Spec b) # | |
Monad (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 | |
Fields
|
Instances
Default CustomValidator # | |
Defined in Napkin.Spec.Types.Spec Methods def :: CustomValidator # |
newtype SpecPreprocessorWithArgParser b #
Constructors
SpecPreprocessorWithArgParser (Object -> Parser (SpecProgramArguments, SpecPreprocessor b)) |
toRef :: SpecDependency -> Ref Table #
allUnmanagedTasksInSpec :: SpecsDepsTables -> Set (WithSpecTable (Ref Table)) #
type DepsValidator = (SpecDependency -> Ref Table) -> SpecsDepsTables -> [WithSpecTable 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) #
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) #
specTagRefMap :: [TableSpec b] -> Map (Maybe TableSpecTag) [SpecTableName] #
create a mapping of TableSpecTag
s to `Ref Table`s for dumping.
specListTags :: forall bk m. MonadIO m => Specs bk -> m () #
Print the result of specTagRefMap'ing a particular spec to terminal.
Orphan instances
Buildable SpecDependency # | |
Methods build :: SpecDependency -> Builder # |