Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module abstracts the storage engine and provides functions to manipulate objects stored in it.
- requireResult :: AversError -> Maybe a -> Avers a
- objectsTable :: Exp Table
- blobsTable :: Exp Table
- secretsTable :: Exp Table
- patchesTable :: Exp Table
- snapshotsTable :: Exp Table
- sessionsTable :: Exp Table
- trace :: String -> Avers a -> Avers a
- exists :: ObjId -> Avers Bool
- lookupObject :: ObjId -> Avers Object
- createObject :: ToJSON a => ObjectType a -> ObjId -> a -> Avers ObjId
- deleteObject :: ObjId -> Avers ()
- pruneObject :: ObjId -> Avers ()
- objectContent :: FromJSON a => ObjectId -> Avers a
- lookupLatestSnapshot :: ObjectId -> Avers Snapshot
- applyPatchToSnapshot :: Snapshot -> Patch -> Avers Snapshot
- applyPatches :: Snapshot -> [Patch] -> Avers Snapshot
- lookupRecentRevision :: ObjectId -> Avers (Maybe RevId)
- updateRecentRevision :: ObjectId -> RevId -> Avers ()
- newestSnapshot :: ObjectId -> Avers Snapshot
- lookupSnapshot :: ObjectId -> RevId -> Avers Snapshot
- savePatch :: Patch -> Avers ()
- saveSnapshot :: Snapshot -> Avers ()
- updateSecret :: SecretId -> Text -> Avers ()
- verifySecret :: SecretId -> Text -> Avers ()
- saveSecretValue :: SecretId -> EncryptedPass -> Avers ()
- patchesAfterRevision :: ObjectId -> RevId -> Avers [Patch]
- lookupPatch :: ObjectId -> RevId -> Avers Patch
- lookupObjectType :: Text -> Avers SomeObjectType
- applyObjectUpdates :: ObjectId -> RevId -> ObjId -> [Operation] -> Bool -> Avers ([Patch], Int, [Patch])
- data PatchState a = PatchState {}
- type AversPatch a b = StateT (PatchState a) Avers b
- patchHandler :: FromJSON a => Bool -> AversPatch a Snapshot
- existsBlob :: BlobId -> Avers Bool
- lookupBlob :: BlobId -> Avers Blob
- insertBlob :: Blob -> Avers ()
- saveBlobContent :: Blob -> ByteString -> Avers ()
- saveSession :: Session -> Avers ()
- lookupSession :: SessionId -> Avers Session
- dropSession :: SessionId -> Avers ()
- newId :: Int -> IO Text
- validateObject :: Text -> Value -> Avers ()
- validateWithType :: FromJSON a => ObjectType a -> Value -> Avers ()
- lookupRelease :: ObjId -> RevId -> Avers Release
- createRelease :: ObjId -> RevId -> Avers ()
- lookupLatestRelease :: ObjId -> Avers (Maybe RevId)
- createBlob :: ByteString -> Text -> Avers Blob
- objectsOfType :: ObjectType a -> Avers (Vector ObjId)
- allObjectsOfType :: ObjectType a -> Avers (Vector ObjId)
- isNotDeleted :: Exp Object -> Exp Bool
- mapId :: Exp Object -> Exp Text
Documentation
requireResult :: AversError -> Maybe a -> Avers a Source
blobsTable :: Exp Table Source
lookupObject :: ObjId -> Avers Object Source
Lookup an Object
by its ObjId
. Throws ObjectNotFound
if the object
doesn't exist.
createObject :: ToJSON a => ObjectType a -> ObjId -> a -> Avers ObjId Source
Create a new object of the given type. An initial snapshot (RevId
0)
is created from the supplied content.
deleteObject :: ObjId -> Avers () Source
Mark the object as deleted.
pruneObject :: ObjId -> Avers () Source
Prune the object from the database. This is only allowed if the object is marked as deleted. Note that this is a very dangerous operation, it can not be undone.
objectContent :: FromJSON a => ObjectId -> Avers a Source
Fetch the content of the object and try to parse it.
This function will fail with a ParseError
if the content can not be
decoded into the desired type.
lookupLatestSnapshot :: ObjectId -> Avers Snapshot Source
Get the snapshot of the newest revision of the given object.
updateRecentRevision :: ObjectId -> RevId -> Avers () Source
newestSnapshot :: ObjectId -> Avers Snapshot Source
Get the newest snapshot which is stored in the database. The object may be at a higher revision if the later snapshots are missing from the database.
This is an internal function. If you want the latest snapshot, you should
use lookupLatestSnapshot
.
saveSnapshot :: Snapshot -> Avers () Source
updateSecret :: SecretId -> Text -> Avers () Source
verifySecret :: SecretId -> Text -> Avers () Source
Verify the value against the secret. If that fails, then this function throws an error.
This function automatically updates the secret in the database if the scrypt params have changed.
saveSecretValue :: SecretId -> EncryptedPass -> Avers () Source
Internal function which actually saves a secret in the database.
lookupObjectType :: Text -> Avers SomeObjectType Source
Lookup an object type which is registered in the Avers monad.
data PatchState a Source
PatchState | |
|
type AversPatch a b = StateT (PatchState a) Avers b Source
patchHandler :: FromJSON a => Bool -> AversPatch a Snapshot Source
existsBlob :: BlobId -> Avers Bool Source
lookupBlob :: BlobId -> Avers Blob Source
insertBlob :: Blob -> Avers () Source
saveBlobContent :: Blob -> ByteString -> Avers () Source
saveSession :: Session -> Avers () Source
lookupSession :: SessionId -> Avers Session Source
dropSession :: SessionId -> Avers () Source
validateObject :: Text -> Value -> Avers () Source
validateWithType :: FromJSON a => ObjectType a -> Value -> Avers () Source
createRelease :: ObjId -> RevId -> Avers () Source
Create a new release of the given revision. If the object doesn't exist,
it will fail with ObjectNotFound
.
createBlob :: ByteString -> Text -> Avers Blob Source
objectsOfType :: ObjectType a -> Avers (Vector ObjId) Source
allObjectsOfType :: ObjectType a -> Avers (Vector ObjId) Source