page-service.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type EventEmitter from 'events';
  2. import type {
  3. HasObjectId,
  4. IPageInfo, IPageInfoForEntity, IUser,
  5. } from '@growi/core';
  6. import type { ObjectId } from 'mongoose';
  7. import type { IOptionsForCreate, IOptionsForUpdate } from '~/interfaces/page';
  8. import type { PopulatedGrantedGroup } from '~/interfaces/page-grant';
  9. import type { CurrentPageYjsData } from '~/interfaces/yjs';
  10. import type { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
  11. import type { PageDocument } from '~/server/models/page';
  12. export interface IPageService {
  13. create(path: string, body: string, user: HasObjectId, options: IOptionsForCreate): Promise<PageDocument>,
  14. forceCreateBySystem(path: string, body: string, options: IOptionsForCreate): Promise<PageDocument>,
  15. updatePage(pageData: PageDocument, body: string | null, previousBody: string | null, user: IUser, options: IOptionsForUpdate,): Promise<PageDocument>,
  16. updateDescendantCountOfAncestors: (pageId: ObjectIdLike, inc: number, shouldIncludeTarget: boolean) => Promise<void>,
  17. deleteCompletelyOperation: (pageIds: string[], pagePaths: string[]) => Promise<void>,
  18. getEventEmitter: () => EventEmitter,
  19. deleteMultipleCompletely: (pages: ObjectIdLike[], user: IUser | undefined) => Promise<void>,
  20. findAncestorsChildrenByPathAndViewer(path: string, user, userGroups?): Promise<Record<string, PageDocument[]>>,
  21. findChildrenByParentPathOrIdAndViewer(parentPathOrId: string, user, userGroups?): Promise<PageDocument[]>,
  22. shortBodiesMapByPageIds(pageIds?: ObjectId[], user?): Promise<Record<string, string | null>>,
  23. constructBasicPageInfo(page: PageDocument, isGuestUser?: boolean): IPageInfo | IPageInfoForEntity,
  24. canDelete(page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, isRecursively: boolean): boolean,
  25. canDeleteCompletely(
  26. page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, isRecursively: boolean, userRelatedGroups: PopulatedGrantedGroup[]
  27. ): boolean,
  28. canDeleteCompletelyAsMultiGroupGrantedPage(
  29. page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, userRelatedGroups: PopulatedGrantedGroup[]
  30. ): boolean,
  31. getYjsData(pageId: string, revisionBody?: string): Promise<CurrentPageYjsData>,
  32. }