Skip to content

Commit

Permalink
Add type to queryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
miya committed Aug 26, 2024
1 parent c57e00d commit fe24ca1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/app/src/server/models/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ type PaginatedPages = {
offset: number
}

export type FindRecentUpdatedPagesOption = {
offset: number,
limit: number,
includeWipPage: boolean,
includeTrashed: boolean,
isRegExpEscapedFromPath: boolean,
sort: 'updatedAt'
desc: number
hideRestrictedByOwner: boolean,
hideRestrictedByGroup: boolean,
}

export type CreateMethod = (path: string, body: string, user, options: IOptionsForCreate) => Promise<HydratedDocument<PageDocument>>

export interface PageModel extends Model<PageDocument> {
Expand All @@ -79,7 +91,7 @@ export interface PageModel extends Model<PageDocument> {
countByPathAndViewer(path: string | null, user, userGroups?, includeEmpty?:boolean): Promise<number>
findParentByPath(path: string | null): Promise<HydratedDocument<PageDocument> | null>
findTargetAndAncestorsByPathOrId(pathOrId: string): Promise<TargetAndAncestorsResult>
findRecentUpdatedPages(path: string, user, option, includeEmpty?: boolean): Promise<PaginatedPages>
findRecentUpdatedPages(path: string, user, option: FindRecentUpdatedPagesOption, includeEmpty?: boolean): Promise<PaginatedPages>
generateGrantCondition(
user, userGroups: ObjectIdLike[] | null, includeAnyoneWithTheLink?: boolean, showPagesRestrictedByOwner?: boolean, showPagesRestrictedByGroup?: boolean,
): { $or: any[] }
Expand Down Expand Up @@ -670,7 +682,7 @@ schema.statics.countByPathAndViewer = async function(path: string | null, user,
};

schema.statics.findRecentUpdatedPages = async function(
path: string, user, options, includeEmpty = false,
path: string, user, options: FindRecentUpdatedPagesOption, includeEmpty = false,
): Promise<PaginatedPages> {

const sortOpt = {};
Expand Down
3 changes: 3 additions & 0 deletions apps/app/src/server/routes/apiv3/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ module.exports = (crowi) => {
const hideRestrictedByOwner = await crowi.configManager.getConfig('crowi', 'security:list-policy:hideRestrictedByOwner');
const hideRestrictedByGroup = await crowi.configManager.getConfig('crowi', 'security:list-policy:hideRestrictedByGroup');

/**
* @type {import('~/server/models/page').FindRecentUpdatedPagesOption}
*/
const queryOptions = {
offset,
limit,
Expand Down

0 comments on commit fe24ca1

Please sign in to comment.