|
@@ -1,10 +1,16 @@
|
|
|
-import type EventEmitter from 'events';
|
|
|
|
|
-
|
|
|
|
|
|
|
+import type { EventEmitter } from 'node:events';
|
|
|
import type {
|
|
import type {
|
|
|
HasObjectId,
|
|
HasObjectId,
|
|
|
IDataWithRequiredMeta,
|
|
IDataWithRequiredMeta,
|
|
|
IGrantedGroup,
|
|
IGrantedGroup,
|
|
|
- IPageInfoForEntity, IPageNotFoundInfo, IUser, IPageInfoExt, IPage, PageGrant, IUserHasId, IPageInfoForEmpty,
|
|
|
|
|
|
|
+ IPage,
|
|
|
|
|
+ IPageInfoExt,
|
|
|
|
|
+ IPageInfoForEmpty,
|
|
|
|
|
+ IPageInfoForEntity,
|
|
|
|
|
+ IPageNotFoundInfo,
|
|
|
|
|
+ IUser,
|
|
|
|
|
+ IUserHasId,
|
|
|
|
|
+ PageGrant,
|
|
|
} from '@growi/core/dist/interfaces';
|
|
} from '@growi/core/dist/interfaces';
|
|
|
import type { HydratedDocument, Types } from 'mongoose';
|
|
import type { HydratedDocument, Types } from 'mongoose';
|
|
|
|
|
|
|
@@ -19,61 +25,191 @@ import type { PageOperationDocument } from '~/server/models/page-operation';
|
|
|
import type { UserGroupDocument } from '~/server/models/user-group';
|
|
import type { UserGroupDocument } from '~/server/models/user-group';
|
|
|
|
|
|
|
|
export interface IPageService {
|
|
export interface IPageService {
|
|
|
- create(path: string, body: string, user: HasObjectId, options: IOptionsForCreate): Promise<HydratedDocument<PageDocument>>,
|
|
|
|
|
- forceCreateBySystem(path: string, body: string, options: IOptionsForCreate): Promise<PageDocument>,
|
|
|
|
|
|
|
+ create(
|
|
|
|
|
+ path: string,
|
|
|
|
|
+ body: string,
|
|
|
|
|
+ user: HasObjectId,
|
|
|
|
|
+ options: IOptionsForCreate,
|
|
|
|
|
+ ): Promise<HydratedDocument<PageDocument>>;
|
|
|
|
|
+ forceCreateBySystem(
|
|
|
|
|
+ path: string,
|
|
|
|
|
+ body: string,
|
|
|
|
|
+ options: IOptionsForCreate,
|
|
|
|
|
+ ): Promise<PageDocument>;
|
|
|
updatePage(
|
|
updatePage(
|
|
|
- pageData: HydratedDocument<PageDocument>, body: string | null, previousBody: string | null, user: IUser, options: IOptionsForUpdate
|
|
|
|
|
- ): Promise<HydratedDocument<PageDocument>>,
|
|
|
|
|
- updateDescendantCountOfAncestors: (pageId: ObjectIdLike, inc: number, shouldIncludeTarget: boolean) => Promise<void>,
|
|
|
|
|
|
|
+ pageData: HydratedDocument<PageDocument>,
|
|
|
|
|
+ body: string | null,
|
|
|
|
|
+ previousBody: string | null,
|
|
|
|
|
+ user: IUser,
|
|
|
|
|
+ options: IOptionsForUpdate,
|
|
|
|
|
+ ): Promise<HydratedDocument<PageDocument>>;
|
|
|
|
|
+ updateDescendantCountOfAncestors: (
|
|
|
|
|
+ pageId: ObjectIdLike,
|
|
|
|
|
+ inc: number,
|
|
|
|
|
+ shouldIncludeTarget: boolean,
|
|
|
|
|
+ ) => Promise<void>;
|
|
|
updateGrant(
|
|
updateGrant(
|
|
|
- page: HydratedDocument<PageDocument>, user: IUserHasId, grantData: {grant: PageGrant, userRelatedGrantedGroups: IGrantedGroup[]},
|
|
|
|
|
- ): Promise<PageDocument>,
|
|
|
|
|
- deleteCompletelyOperation: (pageIds: ObjectIdLike[], pagePaths: string[]) => Promise<void>,
|
|
|
|
|
- getEventEmitter: () => EventEmitter,
|
|
|
|
|
- deleteMultipleCompletely: (pages: ObjectIdLike[], user: IUser | undefined) => Promise<void>,
|
|
|
|
|
|
|
+ page: HydratedDocument<PageDocument>,
|
|
|
|
|
+ user: IUserHasId,
|
|
|
|
|
+ grantData: { grant: PageGrant; userRelatedGrantedGroups: IGrantedGroup[] },
|
|
|
|
|
+ ): Promise<PageDocument>;
|
|
|
|
|
+ deleteCompletelyOperation: (
|
|
|
|
|
+ pageIds: ObjectIdLike[],
|
|
|
|
|
+ pagePaths: string[],
|
|
|
|
|
+ ) => Promise<void>;
|
|
|
|
|
+ getEventEmitter: () => EventEmitter;
|
|
|
|
|
+ deleteMultipleCompletely: (
|
|
|
|
|
+ pages: ObjectIdLike[],
|
|
|
|
|
+ user: IUser | undefined,
|
|
|
|
|
+ ) => Promise<void>;
|
|
|
findPageAndMetaDataByViewer(
|
|
findPageAndMetaDataByViewer(
|
|
|
- pageId: string, path: string | null, user?: HydratedDocument<IUser>, isSharedPage?: boolean,
|
|
|
|
|
- ): Promise<IDataWithRequiredMeta<HydratedDocument<PageDocument>, IPageInfoExt> | IDataWithRequiredMeta<null, IPageNotFoundInfo>>
|
|
|
|
|
|
|
+ pageId: string,
|
|
|
|
|
+ path: string | null,
|
|
|
|
|
+ user?: HydratedDocument<IUser>,
|
|
|
|
|
+ isSharedPage?: boolean,
|
|
|
|
|
+ ): Promise<
|
|
|
|
|
+ | IDataWithRequiredMeta<HydratedDocument<PageDocument>, IPageInfoExt>
|
|
|
|
|
+ | IDataWithRequiredMeta<null, IPageNotFoundInfo>
|
|
|
|
|
+ >;
|
|
|
findPageAndMetaDataByViewer(
|
|
findPageAndMetaDataByViewer(
|
|
|
- pageId: string | null, path: string, user?: HydratedDocument<IUser>, isSharedPage?: boolean,
|
|
|
|
|
- ): Promise<IDataWithRequiredMeta<HydratedDocument<PageDocument>, IPageInfoExt> | IDataWithRequiredMeta<null, IPageNotFoundInfo>>
|
|
|
|
|
- resumeRenameSubOperation(renamedPage: PageDocument, pageOp: PageOperationDocument, activity?): Promise<void>
|
|
|
|
|
|
|
+ pageId: string | null,
|
|
|
|
|
+ path: string,
|
|
|
|
|
+ user?: HydratedDocument<IUser>,
|
|
|
|
|
+ isSharedPage?: boolean,
|
|
|
|
|
+ ): Promise<
|
|
|
|
|
+ | IDataWithRequiredMeta<HydratedDocument<PageDocument>, IPageInfoExt>
|
|
|
|
|
+ | IDataWithRequiredMeta<null, IPageNotFoundInfo>
|
|
|
|
|
+ >;
|
|
|
|
|
+ resumeRenameSubOperation(
|
|
|
|
|
+ renamedPage: PageDocument,
|
|
|
|
|
+ pageOp: PageOperationDocument,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
handlePrivatePagesForGroupsToDelete(
|
|
handlePrivatePagesForGroupsToDelete(
|
|
|
groupsToDelete: UserGroupDocument[] | ExternalUserGroupDocument[],
|
|
groupsToDelete: UserGroupDocument[] | ExternalUserGroupDocument[],
|
|
|
action: PageActionOnGroupDelete,
|
|
action: PageActionOnGroupDelete,
|
|
|
transferToUserGroup: IGrantedGroup | undefined,
|
|
transferToUserGroup: IGrantedGroup | undefined,
|
|
|
user: IUser,
|
|
user: IUser,
|
|
|
-): Promise<void>
|
|
|
|
|
- shortBodiesMapByPageIds(pageIds?: Types.ObjectId[], user?): Promise<Record<string, string | null>>,
|
|
|
|
|
- constructBasicPageInfo(page: HydratedDocument<PageDocument>, isGuestUser?: boolean): |
|
|
|
|
|
- Omit<IPageInfoForEmpty, 'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely'> |
|
|
|
|
|
- Omit<IPageInfoForEntity, 'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely'>,
|
|
|
|
|
- normalizeAllPublicPages(): Promise<void>,
|
|
|
|
|
- canDelete(page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, isRecursively: boolean): boolean,
|
|
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ shortBodiesMapByPageIds(
|
|
|
|
|
+ pageIds?: Types.ObjectId[],
|
|
|
|
|
+ user?,
|
|
|
|
|
+ ): Promise<Record<string, string | null>>;
|
|
|
|
|
+ constructBasicPageInfo(
|
|
|
|
|
+ page: HydratedDocument<PageDocument>,
|
|
|
|
|
+ isGuestUser?: boolean,
|
|
|
|
|
+ ):
|
|
|
|
|
+ | Omit<
|
|
|
|
|
+ IPageInfoForEmpty,
|
|
|
|
|
+ 'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely'
|
|
|
|
|
+ >
|
|
|
|
|
+ | Omit<
|
|
|
|
|
+ IPageInfoForEntity,
|
|
|
|
|
+ 'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely'
|
|
|
|
|
+ >;
|
|
|
|
|
+ normalizeAllPublicPages(): Promise<void>;
|
|
|
|
|
+ canDelete(
|
|
|
|
|
+ page: PageDocument,
|
|
|
|
|
+ creatorId: ObjectIdLike | null,
|
|
|
|
|
+ operator: any | null,
|
|
|
|
|
+ isRecursively: boolean,
|
|
|
|
|
+ ): boolean;
|
|
|
canDeleteCompletely(
|
|
canDeleteCompletely(
|
|
|
- page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, isRecursively: boolean, userRelatedGroups: PopulatedGrantedGroup[]
|
|
|
|
|
- ): boolean,
|
|
|
|
|
|
|
+ page: PageDocument,
|
|
|
|
|
+ creatorId: ObjectIdLike | null,
|
|
|
|
|
+ operator: any | null,
|
|
|
|
|
+ isRecursively: boolean,
|
|
|
|
|
+ userRelatedGroups: PopulatedGrantedGroup[],
|
|
|
|
|
+ ): boolean;
|
|
|
canDeleteCompletelyAsMultiGroupGrantedPage(
|
|
canDeleteCompletelyAsMultiGroupGrantedPage(
|
|
|
- page: PageDocument, creatorId: ObjectIdLike | null, operator: any | null, userRelatedGroups: PopulatedGrantedGroup[]
|
|
|
|
|
- ): boolean,
|
|
|
|
|
- getYjsData(pageId: string, revisionBody?: string): Promise<CurrentPageYjsData>,
|
|
|
|
|
- updateDescendantCountOfPagesWithPaths(paths: string[]): Promise<void>,
|
|
|
|
|
- revertRecursivelyMainOperation(page, user, options, pageOpId: ObjectIdLike, activity?): Promise<void>,
|
|
|
|
|
- revertDeletedPage(page, user, options, isRecursively: boolean, activityParameters?),
|
|
|
|
|
- deleteCompletelyRecursivelyMainOperation(page, user, options, pageOpId: ObjectIdLike, activity?): Promise<void>,
|
|
|
|
|
- deleteCompletely(page, user, options, isRecursively: boolean, preventEmitting: boolean, activityParameters),
|
|
|
|
|
- deleteRecursivelyMainOperation(page, user, pageOpId: ObjectIdLike, activity?): Promise<void>,
|
|
|
|
|
- deletePage(page, user, options, isRecursively: boolean, activityParameters),
|
|
|
|
|
|
|
+ page: PageDocument,
|
|
|
|
|
+ creatorId: ObjectIdLike | null,
|
|
|
|
|
+ operator: any | null,
|
|
|
|
|
+ userRelatedGroups: PopulatedGrantedGroup[],
|
|
|
|
|
+ ): boolean;
|
|
|
|
|
+ getYjsData(
|
|
|
|
|
+ pageId: string,
|
|
|
|
|
+ revisionBody?: string,
|
|
|
|
|
+ ): Promise<CurrentPageYjsData>;
|
|
|
|
|
+ updateDescendantCountOfPagesWithPaths(paths: string[]): Promise<void>;
|
|
|
|
|
+ revertRecursivelyMainOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ revertDeletedPage(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ isRecursively: boolean,
|
|
|
|
|
+ activityParameters?,
|
|
|
|
|
+ );
|
|
|
|
|
+ deleteCompletelyRecursivelyMainOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ deleteCompletely(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ isRecursively: boolean,
|
|
|
|
|
+ preventEmitting: boolean,
|
|
|
|
|
+ activityParameters,
|
|
|
|
|
+ );
|
|
|
|
|
+ deleteRecursivelyMainOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ deletePage(page, user, options, isRecursively: boolean, activityParameters);
|
|
|
duplicateRecursivelyMainOperation(
|
|
duplicateRecursivelyMainOperation(
|
|
|
page: PageDocument,
|
|
page: PageDocument,
|
|
|
newPagePath: string,
|
|
newPagePath: string,
|
|
|
user,
|
|
user,
|
|
|
pageOpId: ObjectIdLike,
|
|
pageOpId: ObjectIdLike,
|
|
|
onlyDuplicateUserRelatedResources: boolean,
|
|
onlyDuplicateUserRelatedResources: boolean,
|
|
|
- ): Promise<void>,
|
|
|
|
|
- duplicate(page: PageDocument, newPagePath: string, user, isRecursively: boolean, onlyDuplicateUserRelatedResources: boolean),
|
|
|
|
|
- renameSubOperation(page, newPagePath: string, user, options, renamedPage, pageOpId: ObjectIdLike, activity?): Promise<void>,
|
|
|
|
|
- renamePage(page: IPage, newPagePath, user, options, activityParameters): Promise<PageDocument | null>,
|
|
|
|
|
- renameMainOperation(page, newPagePath: string, user, options, pageOpId: ObjectIdLike, activity?): Promise<PageDocument | null>,
|
|
|
|
|
- createSubOperation(page, user, options: IOptionsForCreate, pageOpId: ObjectIdLike): Promise<void>,
|
|
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ duplicate(
|
|
|
|
|
+ page: PageDocument,
|
|
|
|
|
+ newPagePath: string,
|
|
|
|
|
+ user,
|
|
|
|
|
+ isRecursively: boolean,
|
|
|
|
|
+ onlyDuplicateUserRelatedResources: boolean,
|
|
|
|
|
+ );
|
|
|
|
|
+ renameSubOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ newPagePath: string,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ renamedPage,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
|
|
+ renamePage(
|
|
|
|
|
+ page: IPage,
|
|
|
|
|
+ newPagePath,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ activityParameters,
|
|
|
|
|
+ ): Promise<PageDocument | null>;
|
|
|
|
|
+ renameMainOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ newPagePath: string,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ activity?,
|
|
|
|
|
+ ): Promise<PageDocument | null>;
|
|
|
|
|
+ createSubOperation(
|
|
|
|
|
+ page,
|
|
|
|
|
+ user,
|
|
|
|
|
+ options: IOptionsForCreate,
|
|
|
|
|
+ pageOpId: ObjectIdLike,
|
|
|
|
|
+ ): Promise<void>;
|
|
|
}
|
|
}
|