Skip to content

DocumentManager

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/packages/core/src/managers/document-manager.ts

DocumentManager handles document business logic This class is framework-agnostic and can be used in any environment

Methods

MethodSignatureReturns
validatevalidate(doc: Partial<Document>)ValidationResult
canEditcanEdit(user: User, doc: Document)boolean
canPublishcanPublish(user: User, _doc: Document)boolean
canDeletecanDelete(user: User, _doc: Document)boolean
createVersioncreateVersion(doc: Document)Partial<Document>
applyAudienceFilterapplyAudienceFilter(docs: Document[], audience: string)Document[]
applyAudiencesFilterapplyAudiencesFilter(docs: Document[], audiences: string[])Document[]
isOutdatedisOutdated(doc: Document, allVersions: Document[])boolean
getLatestPublishedVersiongetLatestPublishedVersion(slug: string, allVersions: Document[])`Document
canView`canView(user: Usernull, doc: Document)`

Where it refuses work

  • DocumentManager stops the work with an early return when user.role === UserRole.ADMIN || user.role === UserRole.MAINTAINER.
  • DocumentManager stops the work with an early return when user.role === UserRole.CONTRIBUTOR && doc.createdById === user.id.
  • DocumentManager stops the work with an early return when publishedVersions.length === 0.
  • DocumentManager stops the work with an early return when doc.isPublic.
  • DocumentManager stops the work with an early return when !user.

Was this page helpful?

Download as PDF