|
@@ -1,27 +1,32 @@
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
|
|
|
|
|
+import nodePath from 'path';
|
|
|
|
|
+
|
|
|
|
|
+import { getOrCreateModel, pagePathUtils, pathUtils } from '@growi/core';
|
|
|
|
|
+import escapeStringRegexp from 'escape-string-regexp';
|
|
|
import mongoose, {
|
|
import mongoose, {
|
|
|
Schema, Model, Document, AnyObject,
|
|
Schema, Model, Document, AnyObject,
|
|
|
} from 'mongoose';
|
|
} from 'mongoose';
|
|
|
import mongoosePaginate from 'mongoose-paginate-v2';
|
|
import mongoosePaginate from 'mongoose-paginate-v2';
|
|
|
import uniqueValidator from 'mongoose-unique-validator';
|
|
import uniqueValidator from 'mongoose-unique-validator';
|
|
|
-import escapeStringRegexp from 'escape-string-regexp';
|
|
|
|
|
-import nodePath from 'path';
|
|
|
|
|
-import { getOrCreateModel, pagePathUtils, pathUtils } from '@growi/core';
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+import { IUserHasId } from '~/interfaces/user';
|
|
|
|
|
+import { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
|
|
|
|
|
+
|
|
|
|
|
+import { IPage, IPageHasId } from '../../interfaces/page';
|
|
|
import loggerFactory from '../../utils/logger';
|
|
import loggerFactory from '../../utils/logger';
|
|
|
import Crowi from '../crowi';
|
|
import Crowi from '../crowi';
|
|
|
-import { IPage, IPageHasId } from '../../interfaces/page';
|
|
|
|
|
|
|
+
|
|
|
import { getPageSchema, extractToAncestorsPaths, populateDataToShowRevision } from './obsolete-page';
|
|
import { getPageSchema, extractToAncestorsPaths, populateDataToShowRevision } from './obsolete-page';
|
|
|
-import { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
|
|
|
|
|
import { PageRedirectModel } from './page-redirect';
|
|
import { PageRedirectModel } from './page-redirect';
|
|
|
-import { IUserHasId } from '~/interfaces/user';
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const { addTrailingSlash } = pathUtils;
|
|
const { addTrailingSlash } = pathUtils;
|
|
|
const { isTopPage, collectAncestorPaths } = pagePathUtils;
|
|
const { isTopPage, collectAncestorPaths } = pagePathUtils;
|
|
|
-const logger = loggerFactory('growi:models:page');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+const logger = loggerFactory('growi:models:page');
|
|
|
/*
|
|
/*
|
|
|
* define schema
|
|
* define schema
|
|
|
*/
|
|
*/
|
|
@@ -34,7 +39,7 @@ const PAGE_GRANT_ERROR = 1;
|
|
|
const STATUS_PUBLISHED = 'published';
|
|
const STATUS_PUBLISHED = 'published';
|
|
|
const STATUS_DELETED = 'deleted';
|
|
const STATUS_DELETED = 'deleted';
|
|
|
|
|
|
|
|
-export interface PageDocument extends IPage, Document {}
|
|
|
|
|
|
|
+export interface PageDocument extends IPage, Document { }
|
|
|
|
|
|
|
|
|
|
|
|
|
type TargetAndAncestorsResult = {
|
|
type TargetAndAncestorsResult = {
|
|
@@ -729,7 +734,7 @@ schema.statics.findAncestorsChildrenByPathAndViewer = async function(path: strin
|
|
|
.lean()
|
|
.lean()
|
|
|
.exec();
|
|
.exec();
|
|
|
// mark target
|
|
// mark target
|
|
|
- const pages = _pages.map((page: PageDocument & {isTarget?: boolean}) => {
|
|
|
|
|
|
|
+ const pages = _pages.map((page: PageDocument & { isTarget?: boolean }) => {
|
|
|
if (page.path === path) {
|
|
if (page.path === path) {
|
|
|
page.isTarget = true;
|
|
page.isTarget = true;
|
|
|
}
|
|
}
|
|
@@ -777,7 +782,7 @@ schema.statics.incrementDescendantCountOfPageIds = async function(pageIds: Objec
|
|
|
/**
|
|
/**
|
|
|
* recount descendantCount of a page with the provided id and return it
|
|
* recount descendantCount of a page with the provided id and return it
|
|
|
*/
|
|
*/
|
|
|
-schema.statics.recountDescendantCount = async function(id: ObjectIdLike):Promise<number> {
|
|
|
|
|
|
|
+schema.statics.recountDescendantCount = async function(id: ObjectIdLike): Promise<number> {
|
|
|
const res = await this.aggregate(
|
|
const res = await this.aggregate(
|
|
|
[
|
|
[
|
|
|
{
|
|
{
|
|
@@ -1086,7 +1091,7 @@ export default (crowi: Crowi): any => {
|
|
|
return savedPage;
|
|
return savedPage;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const shouldUseUpdatePageV4 = (grant:number, isV5Compatible:boolean, isOnTree:boolean): boolean => {
|
|
|
|
|
|
|
+ const shouldUseUpdatePageV4 = (grant: number, isV5Compatible: boolean, isOnTree: boolean): boolean => {
|
|
|
const isRestricted = grant === GRANT_RESTRICTED;
|
|
const isRestricted = grant === GRANT_RESTRICTED;
|
|
|
return !isRestricted && (!isV5Compatible || !isOnTree);
|
|
return !isRestricted && (!isV5Compatible || !isOnTree);
|
|
|
};
|
|
};
|