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

Docs

Description

This module provides a high level api wrapper around Docs.Database to interact with the document control and version management, e.g., to create, view, edit, manage, discuss and version documents.

All Docs api actions are abstracted over specific classes defined in Docs.Database. A specific implementation for PostgreSQL databases are HasqlSession and HasqlTransaction in Docs.Hasql.Database. These must be used together, as some Database Operations require to be executed in a transactional context. The PostgreSQL implementation can be used with the functions run and runTransaction in Docs.Hasql.Database.

Synopsis

Documentation

data Error Source #

Represents an error of the docs api

Instances

Instances details
FromJSON Error Source # 
Instance details

Defined in Docs

Methods

parseJSON :: Value -> Parser Error

parseJSONList :: Value -> Parser [Error]

omittedField :: Maybe Error

ToJSON Error Source # 
Instance details

Defined in Docs

Methods

toJSON :: Error -> Value

toEncoding :: Error -> Encoding

toJSONList :: [Error] -> Value

toEncodingList :: [Error] -> Encoding

omitField :: Error -> Bool

Generic Error Source # 
Instance details

Defined in Docs

Associated Types

type Rep Error 
Instance details

Defined in Docs

type Rep Error = D1 ('MetaData "Error" "Docs" "backend-0.1.0.0-2H73EnUlGVcEtlIi2XNQz3" 'False) (((C1 ('MetaCons "NoPermission" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DocumentID) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Permission)) :+: (C1 ('MetaCons "NoPermissionForUser" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserID)) :+: C1 ('MetaCons "NoPermissionInGroup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GroupID)))) :+: (C1 ('MetaCons "SuperAdminOnly" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DocumentNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DocumentID)) :+: C1 ('MetaCons "RevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RevisionRef))))) :+: ((C1 ('MetaCons "TextElementNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TextElementRef)) :+: (C1 ('MetaCons "TextRevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TextRevisionRef)) :+: C1 ('MetaCons "TreeRevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TreeRevisionRef)))) :+: ((C1 ('MetaCons "CommentNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CommentRef)) :+: C1 ('MetaCons "PDFError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "ZipHTMLError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Custom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))))

Methods

from :: Error -> Rep Error x #

to :: Rep Error x -> Error #

ToSchema Error Source # 
Instance details

Defined in Docs

Methods

declareNamedSchema :: Proxy Error -> Declare (Definitions Schema) NamedSchema

type Rep Error Source # 
Instance details

Defined in Docs

type Rep Error = D1 ('MetaData "Error" "Docs" "backend-0.1.0.0-2H73EnUlGVcEtlIi2XNQz3" 'False) (((C1 ('MetaCons "NoPermission" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DocumentID) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Permission)) :+: (C1 ('MetaCons "NoPermissionForUser" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UserID)) :+: C1 ('MetaCons "NoPermissionInGroup" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 GroupID)))) :+: (C1 ('MetaCons "SuperAdminOnly" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DocumentNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DocumentID)) :+: C1 ('MetaCons "RevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RevisionRef))))) :+: ((C1 ('MetaCons "TextElementNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TextElementRef)) :+: (C1 ('MetaCons "TextRevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TextRevisionRef)) :+: C1 ('MetaCons "TreeRevisionNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TreeRevisionRef)))) :+: ((C1 ('MetaCons "CommentNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CommentRef)) :+: C1 ('MetaCons "PDFError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "ZipHTMLError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Custom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))))

logMessage :: (HasLogMessage m, ToJSON v) => Severity -> Maybe UserID -> Scope -> v -> m LogMessage Source #

Logs a message

createDocument :: (HasCreateDocument m, HasLogMessage m) => UserID -> GroupID -> Text -> m (Result Document) Source #

Create a new document

getDocuments :: (HasGetDocument m, HasLogMessage m) => UserID -> Maybe UserID -> Maybe GroupID -> m (Result (Vector Document)) Source #

Gets all documents visible by the user OR all documents by the specified group and / or user

createTextRevision :: (HasCreateTextRevision m, HasGetTextElementRevision m, HasExistsComment m, HasLogMessage m, HasGetTreeRevision m, HasGetRevisionKey m, HasGetDocument m, HasDraftTextRevision m) => UserID -> NewTextRevision -> m (Result (Rendered ConflictStatus)) Source #

Create a new TextRevision in the Database.

Updates the latest revision instead of creating a new one, if - the latest revision is created by the same author, - the latest revision is no older than a set threshold. In case of an update, the revision id is increased nevertheless to prevent lost update scenarios.

getLogs :: (HasGetLogs m, HasLogMessage m) => UserID -> Maybe UTCTime -> Int64 -> m (Result (Vector LogMessage)) Source #

Obtain log messages

getDraftTextRevision :: (HasDraftTextRevision m, HasLogMessage m, HasGetTreeRevision m, HasGetTextElementRevision m, HasGetRevisionKey m, HasGetDocument m) => UserID -> TextElementRef -> m (Result (Maybe (Rendered DraftRevision))) Source #

Get draft text revision for a user and text element. Returns Nothing if no draft exists for this user/element combination. Drafts are user-specific and element-specific (one draft per user per text element).

publishDraftTextRevision :: (HasDraftTextRevision m, HasCreateTextRevision m, HasGetTextElementRevision m, HasExistsComment m, HasGetRevisionKey m, HasGetDocument m, HasGetTreeRevision m, HasLogMessage m) => UserID -> TextElementRef -> m (Result (Rendered ConflictStatus)) Source #

Publish a draft text revision to the main revision tree. This attempts to create a regular text revision from the draft content. If conflicts occur, they are handled as errors (since publishing is explicit, not auto-save). On successful publish, the draft is automatically discarded.

discardDraftTextRevision :: (HasDraftTextRevision m, HasLogMessage m) => UserID -> TextElementRef -> m (Result ()) Source #

Discard a draft text revision, permanently deleting all unsaved changes. This operation cannot be undone. The draft is completely removed from storage.