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
| Method | Signature | Returns |
|---|---|---|
validate | validate(doc: Partial<Document>) | ValidationResult |
canEdit | canEdit(user: User, doc: Document) | boolean |
canPublish | canPublish(user: User, _doc: Document) | boolean |
canDelete | canDelete(user: User, _doc: Document) | boolean |
createVersion | createVersion(doc: Document) | Partial<Document> |
applyAudienceFilter | applyAudienceFilter(docs: Document[], audience: string) | Document[] |
applyAudiencesFilter | applyAudiencesFilter(docs: Document[], audiences: string[]) | Document[] |
isOutdated | isOutdated(doc: Document, allVersions: Document[]) | boolean |
getLatestPublishedVersion | getLatestPublishedVersion(slug: string, allVersions: Document[]) | `Document |
canView | `canView(user: User | null, doc: Document)` |
Where it refuses work
DocumentManagerstops the work with an early return whenuser.role === UserRole.ADMIN || user.role === UserRole.MAINTAINER.DocumentManagerstops the work with an early return whenuser.role === UserRole.CONTRIBUTOR && doc.createdById === user.id.DocumentManagerstops the work with an early return whenpublishedVersions.length === 0.DocumentManagerstops the work with an early return whendoc.isPublic.DocumentManagerstops the work with an early return when!user.
Was this page helpful?