فهرست منبع

Fix event/model typo errors: Replace crowi.event() with crowi.events and crowi.model() with crowi.models

Co-authored-by: yuki-takei <1638767+yuki-takei@users.noreply.github.com>
copilot-swe-agent[bot] 2 ماه پیش
والد
کامیت
dfb3e392d6

+ 1 - 1
apps/app/src/features/external-user-group/server/routes/apiv3/external-user-group.ts

@@ -49,7 +49,7 @@ module.exports = (crowi: Crowi): Router => {
   const adminRequired = require('~/server/middlewares/admin-required')(crowi);
   const addActivity = generateAddActivityMiddleware();
 
-  const activityEvent = crowi.event('activity');
+  const activityEvent = crowi.events.activity;
 
   const isExecutingSync = () => {
     return (

+ 1 - 1
apps/app/src/features/page-bulk-export/server/service/page-bulk-export-job-cron/index.ts

@@ -91,7 +91,7 @@ class PageBulkExportJobCronService
   constructor(crowi: Crowi) {
     super();
     this.crowi = crowi;
-    this.activityEvent = crowi.event('activity');
+    this.activityEvent = crowi.events.activity;
     this.parallelExecLimit = configManager.getConfig(
       'app:pageBulkExportParallelExecLimit',
     );

+ 1 - 1
apps/app/src/pages/[[...path]]/server-side-props.ts

@@ -53,7 +53,7 @@ function emitPageSeenEvent(
     return;
   }
 
-  const pageEvent = crowi.event('page');
+  const pageEvent = crowi.events.page;
   pageEvent.emit('seen', pageId, user);
 }
 

+ 1 - 1
apps/app/src/pages/common-props/commons.ts

@@ -153,7 +153,7 @@ export const getServerSideCommonEachProps = async (
 
   let currentUser: IUserHasId | undefined;
   if (user != null) {
-    const User = crowi.model('User');
+    const User = crowi.models.User;
     const userData = await User.findById(user.id).populate({
       path: 'imageAttachment',
       select: 'filePathProxied',

+ 1 - 1
apps/app/src/server/models/bookmark.ts

@@ -41,7 +41,7 @@ export interface BookmarkModel extends Model<BookmarkDocument> {
 }
 
 const factory = (crowi: Crowi) => {
-  const bookmarkEvent = crowi.event('bookmark');
+  const bookmarkEvent = crowi.events.bookmark;
 
   const bookmarkSchema = new Schema<BookmarkDocument, BookmarkModel>(
     {

+ 2 - 2
apps/app/src/server/routes/apiv3/import.ts

@@ -134,8 +134,8 @@ export default function route(crowi: Crowi): Router {
   const adminRequired = require('../../middlewares/admin-required')(crowi);
   const addActivity = generateAddActivityMiddleware();
 
-  const adminEvent = crowi.event('admin');
-  const activityEvent = crowi.event('activity');
+  const adminEvent = crowi.events.admin;
+  const activityEvent = crowi.events.activity;
 
   // setup event
   adminEvent.on('onProgressForImport', (data) => {

+ 1 - 1
apps/app/src/server/routes/apiv3/installer.ts

@@ -27,7 +27,7 @@ type FormRequest = Request & { form: any; logIn: any };
 module.exports = (crowi: Crowi): Router => {
   const addActivity = generateAddActivityMiddleware();
 
-  const activityEvent = crowi.event('activity');
+  const activityEvent = crowi.events.activity;
 
   const router = express.Router();
 

+ 2 - 2
apps/app/src/server/routes/apiv3/page/create-page.ts

@@ -208,7 +208,7 @@ export const createPageHandlersFactory: CreatePageHandlersFactory = (crowi) => {
     createdPage: PageDocument;
     pageTags: string[];
   }) {
-    const tagEvent = crowi.event('tag');
+    const tagEvent = crowi.events.tag;
     await PageTagRelation.updatePageTags(createdPage.id, pageTags);
     tagEvent.emit('update', createdPage, pageTags);
     return PageTagRelation.listTagNamesByPage(createdPage.id);
@@ -225,7 +225,7 @@ export const createPageHandlersFactory: CreatePageHandlersFactory = (crowi) => {
       target: createdPage,
       action: SupportedAction.ACTION_PAGE_CREATE,
     };
-    const activityEvent = crowi.event('activity');
+    const activityEvent = crowi.events.activity;
     activityEvent.emit('update', res.locals.activity._id, parameters);
 
     // global notification

+ 1 - 1
apps/app/src/server/routes/apiv3/page/index.ts

@@ -97,7 +97,7 @@ module.exports = (crowi: Crowi) => {
   const Page = mongoose.model<IPage, PageModel>('Page');
   const { pageService, pageGrantService } = crowi;
 
-  const activityEvent = crowi.event('activity');
+  const activityEvent = crowi.events.activity;
 
   const validator = {
     getPage: [

+ 1 - 1
apps/app/src/server/routes/apiv3/page/update-page.ts

@@ -127,7 +127,7 @@ export const updatePageHandlersFactory: UpdatePageHandlersFactory = (crowi) => {
       target: updatedPage,
       action: SupportedAction.ACTION_PAGE_UPDATE,
     };
-    const activityEvent = crowi.event('activity');
+    const activityEvent = crowi.events.activity;
     activityEvent.emit(
       'update',
       res.locals.activity._id,

+ 1 - 1
apps/app/src/server/routes/apiv3/personal-setting/delete-access-token.ts

@@ -44,7 +44,7 @@ export const deleteAccessTokenHandlersFactory: DeleteAccessTokenHandlersFactory
     const loginRequiredStrictly =
       require('../../../middlewares/login-required')(crowi);
     const addActivity = generateAddActivityMiddleware();
-    const activityEvent = crowi.event('activity');
+    const activityEvent = crowi.events.activity;
 
     return [
       accessTokenParser([SCOPE.WRITE.USER_SETTINGS.API.ACCESS_TOKEN]),

+ 1 - 1
apps/app/src/server/routes/apiv3/personal-setting/delete-all-access-tokens.ts

@@ -29,7 +29,7 @@ export const deleteAllAccessTokensHandlersFactory: DeleteAllAccessTokensHandlers
     const loginRequiredStrictly =
       require('../../../middlewares/login-required')(crowi);
     const addActivity = generateAddActivityMiddleware();
-    const activityEvent = crowi.event('activity');
+    const activityEvent = crowi.events.activity;
 
     return [
       accessTokenParser([SCOPE.WRITE.USER_SETTINGS.API.ACCESS_TOKEN]),

+ 1 - 1
apps/app/src/server/routes/apiv3/personal-setting/generate-access-token.ts

@@ -78,7 +78,7 @@ export const generateAccessTokenHandlerFactory: GenerateAccessTokenHandlerFactor
   (crowi) => {
     const loginRequiredStrictly =
       require('../../../middlewares/login-required')(crowi);
-    const activityEvent = crowi.event('activity');
+    const activityEvent = crowi.events.activity;
     const addActivity = generateAddActivityMiddleware();
 
     return [

+ 1 - 1
apps/app/src/server/routes/apiv3/user-activation.ts

@@ -122,7 +122,7 @@ export const completeRegistrationAction = (crowi: Crowi) => {
     IUser,
     { isEmailValid; isRegisterable; createUserByEmailAndPassword; findAdmins }
   >('User');
-  const activityEvent = crowi.event('activity');
+  const activityEvent = crowi.events.activity;
   const { aclService, appService, mailService } = crowi;
 
   return async (req, res) => {

+ 1 - 1
apps/app/src/server/service/activity.ts

@@ -37,7 +37,7 @@ class ActivityService {
 
   constructor(crowi: Crowi) {
     this.crowi = crowi;
-    this.activityEvent = crowi.event('activity');
+    this.activityEvent = crowi.events.activity;
 
     this.getAvailableActions = this.getAvailableActions.bind(this);
     this.shoudUpdateActivity = this.shoudUpdateActivity.bind(this);

+ 1 - 1
apps/app/src/server/service/import/import.ts

@@ -63,7 +63,7 @@ export class ImportService {
     this.crowi = crowi;
     this.growiBridgeService = crowi.growiBridgeService;
 
-    this.adminEvent = crowi.event('admin');
+    this.adminEvent = crowi.events.admin;
 
     this.currentProgressingStatus = null;
   }

+ 1 - 1
apps/app/src/server/service/in-app-notification.ts

@@ -32,7 +32,7 @@ export default class InAppNotificationService {
 
   constructor(crowi: Crowi) {
     this.crowi = crowi;
-    this.activityEvent = crowi.event('activity');
+    this.activityEvent = crowi.events.activity;
     this.socketIoService = crowi.socketIoService;
 
     this.emitSocketIo = this.emitSocketIo.bind(this);

+ 3 - 3
apps/app/src/server/service/page/index.ts

@@ -205,9 +205,9 @@ class PageService implements IPageService {
 
   constructor(crowi: Crowi) {
     this.crowi = crowi;
-    this.pageEvent = crowi.event('page');
-    this.tagEvent = crowi.event('tag');
-    this.activityEvent = crowi.event('activity');
+    this.pageEvent = crowi.events.page;
+    this.tagEvent = crowi.events.tag;
+    this.activityEvent = crowi.events.activity;
     this.pageGrantService = crowi.pageGrantService;
 
     // init

+ 6 - 6
apps/app/src/server/service/search.ts

@@ -60,8 +60,8 @@ const normalizeNQName = (nqName: string): string => {
 };
 
 const findPageListByIds = async (pageIds: ObjectIdLike[], crowi: any) => {
-  const Page = crowi.model('Page') as unknown as PageModel;
-  const User = crowi.model('User');
+  const Page = crowi.models.Page as unknown as PageModel;
+  const User = crowi.models.User;
 
   const builder = new Page.PageQueryBuilder(
     Page.find({ _id: { $in: pageIds } }),
@@ -159,7 +159,7 @@ class SearchService implements SearchQueryParser, SearchResolver {
   }
 
   registerUpdateEvent() {
-    const pageEvent = this.crowi.event('page');
+    const pageEvent = this.crowi.events.page;
     pageEvent.on(
       'create',
       this.fullTextSearchDelegator.syncPageUpdated.bind(
@@ -227,7 +227,7 @@ class SearchService implements SearchQueryParser, SearchResolver {
       );
     });
 
-    const bookmarkEvent = this.crowi.event('bookmark');
+    const bookmarkEvent = this.crowi.events.bookmark;
     bookmarkEvent.on(
       'create',
       this.fullTextSearchDelegator.syncBookmarkChanged.bind(
@@ -241,7 +241,7 @@ class SearchService implements SearchQueryParser, SearchResolver {
       ),
     );
 
-    const tagEvent = this.crowi.event('tag');
+    const tagEvent = this.crowi.events.tag;
     tagEvent.on(
       'update',
       this.fullTextSearchDelegator.syncTagChanged.bind(
@@ -549,7 +549,7 @@ class SearchService implements SearchQueryParser, SearchResolver {
     /*
      * Format ElasticSearch result
      */
-    const User = this.crowi.model('User');
+    const User = this.crowi.models.User;
     const result = {} as IFormattedSearchResult;
 
     // get page data

+ 1 - 1
apps/app/src/server/service/slack-event-handler/link-shared.ts

@@ -179,7 +179,7 @@ export class LinkSharedEventHandler
     pages: any,
     isPermalink: boolean,
   ): DataForUnfurl[] {
-    const Page = this.crowi.model('Page');
+    const Page = this.crowi.models.Page;
     const unfurlData: DataForUnfurl[] = [];
 
     for (const page of pages) {

+ 0 - 2
packages/pdf-converter-client/src/index.ts

@@ -12,7 +12,6 @@ import type {
 export type PdfCtrlSyncJobStatus202Status = typeof PdfCtrlSyncJobStatus202Status[keyof typeof PdfCtrlSyncJobStatus202Status];
 
 
-// eslint-disable-next-line @typescript-eslint/no-redeclare
 export const PdfCtrlSyncJobStatus202Status = {
   HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
   HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',
@@ -30,7 +29,6 @@ export type PdfCtrlSyncJobStatus202 = {
 export type PdfCtrlSyncJobStatusBodyStatus = typeof PdfCtrlSyncJobStatusBodyStatus[keyof typeof PdfCtrlSyncJobStatusBodyStatus];
 
 
-// eslint-disable-next-line @typescript-eslint/no-redeclare
 export const PdfCtrlSyncJobStatusBodyStatus = {
   HTML_EXPORT_IN_PROGRESS: 'HTML_EXPORT_IN_PROGRESS',
   HTML_EXPORT_DONE: 'HTML_EXPORT_DONE',