backend-0.1.0.0
LicenseAGPL-3
Maintainerstu235271@mail.uni-kiel.de stu236925@mail.uni-kiel.de
Safe HaskellNone
LanguageHaskell2010

Docs.Database

Description

This module provides an implementation-agnostic database abstraction. An implementation for a PostreSQL Database is Docs.Hasql.Database.

Documentation

class Monad m => HasNow (m :: Type -> Type) where Source #

Methods

now :: m UTCTime Source #

Get the current time.

Instances

Instances details
HasNow HasqlTransaction Source # 
Instance details

Defined in Docs.Hasql.Database

class Monad m => HasRollback (m :: Type -> Type) where Source #

Methods

rollback :: m () Source #

Rollback all database actions performed so far.

Instances

Instances details
HasRollback HasqlTransaction Source # 
Instance details

Defined in Docs.Hasql.Database

class HasIsSuperAdmin m => HasCheckPermission (m :: Type -> Type) where Source #

Methods

checkDocumentPermission :: UserID -> DocumentID -> Permission -> m Bool Source #

Check if a user has a specific permission on a document.

class HasIsSuperAdmin m => HasIsGroupAdmin (m :: Type -> Type) where Source #

Methods

isGroupAdmin :: UserID -> GroupID -> m Bool Source #

Check whether a user is andmin in a group.

class Monad m => HasIsSuperAdmin (m :: Type -> Type) where Source #

Methods

isSuperAdmin :: UserID -> m Bool Source #

Check whether a user is a super admin.

class Monad m => HasExistsDocument (m :: Type -> Type) where Source #

Methods

existsDocument :: DocumentID -> m Bool Source #

Check whether a Document exists in the database.

class HasExistsDocument m => HasExistsTextElement (m :: Type -> Type) where Source #

Methods

existsTextElement :: TextElementRef -> m Bool Source #

Check whether a TextElement exists in the database.

class HasExistsTextElement m => HasExistsTextRevision (m :: Type -> Type) where Source #

Methods

existsTextRevision :: TextRevisionRef -> m Bool Source #

Check whether a TextRevision exists in the database.

class HasExistsDocument m => HasExistsTreeRevision (m :: Type -> Type) where Source #

Methods

existsTreeRevision :: TreeRevisionRef -> m Bool Source #

Check whether a TreeRevision exists in the database.

class HasCheckPermission m => HasGetTextElement (m :: Type -> Type) where Source #

Methods

getTextElement :: TextElementID -> m (Maybe TextElement) Source #

Get a TextElement from the database.

class (HasCheckPermission m, HasIsGroupAdmin m, HasIsSuperAdmin m) => HasGetDocument (m :: Type -> Type) where Source #

Methods

getDocument :: DocumentID -> m (Maybe Document) Source #

Get a Document from the database by id.

getDocuments :: UserID -> m (Vector Document) Source #

Get all Documents from the database visible by the user.

getDocumentsBy :: Maybe UserID -> Maybe GroupID -> m (Vector Document) Source #

Get all Documents from the database meeting the given constraints.

class (HasCheckPermission m, HasExistsTextElement m) => HasGetTextHistory (m :: Type -> Type) where Source #

Methods

getTextHistory Source #

Arguments

:: TextElementRef

the text element

-> Maybe UTCTime

time frame begin

-> Maybe UTCTime

time frame end

-> Int64

limit

-> m TextRevisionHistory

chronological overview of revisions

Get a chronological overview of TextElement revisions within the specified time frame.

class (HasCheckPermission m, HasExistsDocument m) => HasGetTreeHistory (m :: Type -> Type) where Source #

Methods

getTreeHistory Source #

Arguments

:: DocumentID

the document

-> Maybe UTCTime

time frame end

-> Int64

limit

-> m TreeRevisionHistory

chronological overview of revisions

Get a chronological overview of Tree revisions within the specified time frame.

TODO: take same parameters as "Docs.Database.getTextHistory"

class (HasCheckPermission m, HasExistsDocument m) => HasGetDocumentHistory (m :: Type -> Type) where Source #

Methods

getDocumentHistory Source #

Arguments

:: DocumentID

the document

-> Maybe UTCTime

time frame end

-> Int64

limit

-> m DocumentHistory

chronological overview of revisions

Get a chronological overview of revisions of both kinds (Tree and TextElement) for a document within the specified time frame.

TODO: take same parameters as "Docs.Database.getTextHistory"

class HasIsGroupAdmin m => HasCreateDocument (m :: Type -> Type) where Source #

Methods

createDocument :: Text -> GroupID -> UserID -> m Document Source #

Create a new Document in the database.

class (HasCheckPermission m, HasExistsTextElement m, HasNow m) => HasCreateTextRevision (m :: Type -> Type) where Source #

Methods

updateTextRevision Source #

Arguments

:: TextRevisionID

id of the text revision

-> Text

new text

-> Vector CommentAnchor

new comment anchors

-> m TextRevision

updated text revision

Update text and CommentAnchors for a TextRevision.

createTextRevision Source #

Arguments

:: UserID

the user who should own the new revision

-> TextElementRef

the text element

-> Text

the content of the new revision

-> Vector CommentAnchor

comment anchors for the revision

-> m TextRevision

the newly created TextRevision

Create a new TextRevision in the database.

getLatestTextRevisionID :: TextElementRef -> m (Maybe TextRevisionID) Source #

Get the id of the latest TextElement revision.

updateLatestTitle :: TextElementID -> Text -> m () Source #

currently only intended as a temporary solution

TODO: Kann das weg? Ich glaub, das kann weg.

class (HasCheckPermission m, HasExistsDocument m) => HasCreateTreeRevision (m :: Type -> Type) where Source #

Methods

createTreeRevision Source #

Arguments

:: UserID

the user who should own the new revision

-> DocumentID

the document the revision belongs to

-> Node TextElementID

the root node for the tree of the new revision

-> m (TreeRevision TextElementID)

the newly created revision

Create a new TreeRevision in the database.

existsTextElementInDocument Source #

Arguments

:: DocumentID

the document to check whether a TextElementID belongs to it

-> m (TextElementID -> Bool)

the function to check the existence of the TextElementID int the prior specified document

Obtains a function to check whether a TextElementID belongs to the document.

class (HasCheckPermission m, HasExistsDocument m, HasExistsTextElement m) => HasGetComments (m :: Type -> Type) where Source #

Methods

getComments :: TextElementRef -> m (Vector Comment) Source #

Get all Comments for a TextElement.

Instances

Instances details
HasGetComments HasqlSession Source # 
Instance details

Defined in Docs.Hasql.Database

class (HasCheckPermission m, HasExistsComment m) => HasCreateComment (m :: Type -> Type) where Source #

Methods

createComment Source #

Arguments

:: UserID

the user who intends to create the Comment

-> TextElementID

the id of the TextElement the comment should belong to

-> Text

the content of the Comments message

-> m Comment

the newly created Comment

Creats a new Comment in the database.

resolveComment :: CommentID -> m () Source #

Mark a Comment as resolved.

createReply Source #

Arguments

:: UserID

the user who intends to create the reply

-> CommentID

the id of the Comment to reply to

-> Text

the content of the replys message

-> m Message

the newly created reply's Message

Create a new reply to an existing Comment.

class HasExistsTextElement m => HasExistsComment (m :: Type -> Type) where Source #

Methods

existsComment :: CommentRef -> m Bool Source #

Check whether a Comment exists in the database.

Instances

Instances details
HasExistsComment HasqlTransaction Source # 
Instance details

Defined in Docs.Hasql.Database

class HasIsSuperAdmin m => HasGetLogs (m :: Type -> Type) where Source #

Methods

getLogs Source #

Arguments

:: Maybe UTCTime

offset

-> Int64

limit

-> m (Vector LogMessage)

log messages

Get all log messages within the specified time frame.

Instances

Instances details
HasGetLogs HasqlSession Source # 
Instance details

Defined in Docs.Hasql.Database

class Monad m => HasLogMessage (m :: Type -> Type) where Source #

Methods

logMessage Source #

Arguments

:: ToJSON v 
=> Severity

the severity of the event

-> Maybe UserID

the user who caused the event

-> Scope

the scope the event occured in

-> v

the content of the message

-> m LogMessage

the logged message

Log a message to the database.

Instances

Instances details
HasLogMessage HasqlSession Source # 
Instance details

Defined in Docs.Hasql.Database

Methods

logMessage :: ToJSON v => Severity -> Maybe UserID -> Scope -> v -> HasqlSession LogMessage Source #

HasLogMessage HasqlTransaction Source # 
Instance details

Defined in Docs.Hasql.Database

class HasExistsDocument m => HasGetRevisionKey (m :: Type -> Type) where Source #

Methods

getRevisionKey :: RevisionRef -> m (Maybe RevisionKey) Source #

Get the RevisionKey for a RevisionRef. The RevisionKey is a RevisionRef with additional information on whether the referenced revision is a TextElement revision or a Tree revision.

class (HasCheckPermission m, HasExistsTextElement m) => HasDraftTextRevision (m :: Type -> Type) where Source #

Methods

createDraftTextRevision Source #

Arguments

:: UserID

the user who should own the draft

-> TextElementRef

the TextElement the new draft should belong to

-> TextRevisionID

the TextRevision this draft builds upon

-> Text

the content of the creaft in statu nascendi

-> Vector CommentAnchor

comment anchors for the draft

-> m DraftRevision

the newly created draft

Create a new text revision draft in the database.

getDraftTextRevision :: UserID -> TextElementRef -> m (Maybe DraftRevision) Source #

Get a users DraftRevision for a TextElement if it exists.

deleteDraftTextRevision :: UserID -> TextElementRef -> m () Source #

Delete a users DraftRevision for a TextElement.