Răsfoiți Sursa

add type Crowi

Yuki Takei 1 an în urmă
părinte
comite
c8a87bb7e6

+ 3 - 3
apps/app/src/features/questionnaire/server/service/questionnaire-cron.ts

@@ -1,5 +1,6 @@
 import axiosRetry from 'axios-retry';
 
+import type Crowi from '~/server/crowi';
 import { configManager } from '~/server/service/config-manager';
 import loggerFactory from '~/utils/logger';
 import { getRandomIntInRange } from '~/utils/rand';
@@ -28,12 +29,11 @@ axiosRetry(axios, { retries: 3 });
  */
 class QuestionnaireCronService {
 
-  crowi: any;
+  crowi: Crowi;
 
   cronJob: any;
 
-  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }
 

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

@@ -6,6 +6,7 @@ import { body, validationResult } from 'express-validator';
 
 import { SupportedAction } from '~/interfaces/activity';
 import { RegistrationMode } from '~/interfaces/registration-mode';
+import type Crowi from '~/server/crowi';
 import UserRegistrationOrder from '~/server/models/user-registration-order';
 import { configManager } from '~/server/service/config-manager';
 import { growiInfoService } from '~/server/service/growi-info';
@@ -67,7 +68,7 @@ async function sendEmailToAllAdmins(userData, admins, appTitle, mailService, tem
   });
 }
 
-export const completeRegistrationAction = (crowi) => {
+export const completeRegistrationAction = (crowi: Crowi) => {
   const User = crowi.model('User');
   const activityEvent = crowi.event('activity');
   const {
@@ -207,7 +208,7 @@ export const validateRegisterForm = (req, res, next) => {
   return res.apiv3Err(extractedErrors, 400);
 };
 
-async function makeRegistrationEmailToken(email, crowi) {
+async function makeRegistrationEmailToken(email, crowi: Crowi) {
   const {
     mailService,
     localeDir,
@@ -242,7 +243,7 @@ async function makeRegistrationEmailToken(email, crowi) {
   });
 }
 
-export const registerAction = (crowi) => {
+export const registerAction = (crowi: Crowi) => {
   const User = crowi.model('User');
 
   return async function(req, res) {

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

@@ -12,7 +12,7 @@ const logger = loggerFactory('growi:routes:apiv3:user-ui-settings');
 
 const router = express.Router();
 
-module.exports = (crowi) => {
+module.exports = () => {
 
   const validatorForPut = [
     body('settings').exists().withMessage('The body param \'settings\' is required'),

+ 2 - 1
apps/app/src/server/routes/ogp.ts

@@ -16,6 +16,7 @@ import mongoose from 'mongoose';
 import loggerFactory from '~/utils/logger';
 import { projectRoot } from '~/utils/project-dir-utils';
 
+import type Crowi from '../crowi';
 import { Attachment } from '../models/attachment';
 import type { PageDocument, PageModel } from '../models/page';
 import { configManager } from '../service/config-manager';
@@ -33,7 +34,7 @@ fs.readFile(path.join(projectRoot, DEFAULT_USER_IMAGE_PATH), (err, buffer) => {
 });
 
 
-module.exports = function(crowi) {
+module.exports = function(crowi: Crowi) {
 
   const isUserImageAttachment = (userImageUrlCached: string): boolean => {
     return /^\/attachment\/.+/.test(userImageUrlCached);

+ 2 - 1
apps/app/src/server/routes/search.ts

@@ -2,6 +2,7 @@ import ExternalUserGroupRelation from '~/features/external-user-group/server/mod
 import { SupportedAction } from '~/interfaces/activity';
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import UserGroupRelation from '../models/user-group-relation';
 import { isSearchError } from '../models/vo/search-error';
 
@@ -34,7 +35,7 @@ const logger = loggerFactory('growi:routes:search');
  *                 example: 2
  *
  */
-module.exports = function(crowi, app) {
+module.exports = function(crowi: Crowi, app) {
   const ApiResponse = require('../util/apiResponse');
   const ApiPaginate = require('../util/apiPaginate');
 

+ 3 - 2
apps/app/src/server/service/app.ts

@@ -2,6 +2,7 @@ import { ConfigSource } from '@growi/core/dist/interfaces';
 
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import S2sMessage from '../models/vo/s2s-message';
 
 import { configManager } from './config-manager';
@@ -14,11 +15,11 @@ const logger = loggerFactory('growi:service:AppService');
  */
 export default class AppService implements S2sMessageHandlable {
 
-  crowi!: any;
+  crowi: Crowi;
 
   s2sMessagingService: S2sMessagingService;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.s2sMessagingService = crowi.s2sMessagingService;
   }

+ 4 - 3
apps/app/src/server/service/customize.ts

@@ -8,10 +8,11 @@ import uglifycss from 'uglifycss';
 import { growiPluginService } from '~/features/growi-plugin/server/services';
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import S2sMessage from '../models/vo/s2s-message';
 
 
-import type { ConfigManager } from './config-manager';
+import type { IConfigManagerForApp } from './config-manager';
 import type { S2sMessageHandlable } from './s2s-messaging/handlable';
 
 
@@ -23,7 +24,7 @@ const logger = loggerFactory('growi:service:CustomizeService');
  */
 class CustomizeService implements S2sMessageHandlable {
 
-  configManager: ConfigManager;
+  configManager: IConfigManagerForApp;
 
   s2sMessagingService: any;
 
@@ -41,7 +42,7 @@ class CustomizeService implements S2sMessageHandlable {
 
   forcedColorScheme?: ColorScheme;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.configManager = crowi.configManager;
     this.s2sMessagingService = crowi.s2sMessagingService;
     this.appService = crowi.appService;

+ 5 - 4
apps/app/src/server/service/file-uploader-switch.ts

@@ -1,8 +1,9 @@
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import S2sMessage from '../models/vo/s2s-message';
 
-import type { ConfigManager } from './config-manager';
+import type { IConfigManagerForApp } from './config-manager';
 import type { S2sMessagingService } from './s2s-messaging/base';
 import type { S2sMessageHandlable } from './s2s-messaging/handlable';
 
@@ -10,15 +11,15 @@ const logger = loggerFactory('growi:service:FileUploaderSwitch');
 
 class FileUploaderSwitch implements S2sMessageHandlable {
 
-  crowi: any;
+  crowi: Crowi;
 
-  configManager: ConfigManager;
+  configManager: IConfigManagerForApp;
 
   s2sMessagingService: S2sMessagingService;
 
   lastLoadedAt?: Date;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.configManager = crowi.configManager;
     this.s2sMessagingService = crowi.s2sMessagingService;

+ 2 - 1
apps/app/src/server/service/file-uploader/aws.ts

@@ -14,6 +14,7 @@ import {
 import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
 import urljoin from 'url-join';
 
+import type Crowi from '~/server/crowi';
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
 import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
@@ -257,7 +258,7 @@ class AwsFileUploader extends AbstractFileUploader {
 
 }
 
-module.exports = (crowi) => {
+module.exports = (crowi: Crowi) => {
   const lib = new AwsFileUploader(crowi);
 
   lib.isValidUploadSettings = function() {

+ 2 - 1
apps/app/src/server/service/file-uploader/azure.ts

@@ -18,6 +18,7 @@ import {
   type BlockBlobParallelUploadOptions,
 } from '@azure/storage-blob';
 
+import type Crowi from '~/server/crowi';
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
 import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
@@ -237,7 +238,7 @@ class AzureFileUploader extends AbstractFileUploader {
 
 }
 
-module.exports = (crowi) => {
+module.exports = (crowi: Crowi) => {
   const lib = new AzureFileUploader(crowi);
 
   lib.isValidUploadSettings = function() {

+ 3 - 2
apps/app/src/server/service/file-uploader/file-uploader.ts

@@ -4,6 +4,7 @@ import type { Response } from 'express';
 import { v4 as uuidv4 } from 'uuid';
 
 import type { ICheckLimitResult } from '~/interfaces/attachment';
+import type Crowi from '~/server/crowi';
 import { type RespondOptions, ResponseMode } from '~/server/interfaces/attachment';
 import { Attachment, type IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
@@ -45,9 +46,9 @@ export interface FileUploader {
 
 export abstract class AbstractFileUploader implements FileUploader {
 
-  private crowi;
+  private crowi: Crowi;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }
 

+ 2 - 1
apps/app/src/server/service/file-uploader/gridfs.ts

@@ -5,6 +5,7 @@ import util from 'util';
 import mongoose from 'mongoose';
 import { createModel } from 'mongoose-gridfs';
 
+import type Crowi from '~/server/crowi';
 import type { RespondOptions } from '~/server/interfaces/attachment';
 import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
@@ -101,7 +102,7 @@ class GridfsFileUploader extends AbstractFileUploader {
 }
 
 
-module.exports = function(crowi) {
+module.exports = function(crowi: Crowi) {
   const lib = new GridfsFileUploader(crowi);
 
   // get Collection instance of chunk

+ 2 - 1
apps/app/src/server/service/file-uploader/local.ts

@@ -5,6 +5,7 @@ import { pipeline } from 'stream/promises';
 
 import type { Response } from 'express';
 
+import type Crowi from '~/server/crowi';
 import { ResponseMode, type RespondOptions } from '~/server/interfaces/attachment';
 import type { IAttachmentDocument } from '~/server/models/attachment';
 import loggerFactory from '~/utils/logger';
@@ -103,7 +104,7 @@ class LocalFileUploader extends AbstractFileUploader {
 
 }
 
-module.exports = function(crowi) {
+module.exports = function(crowi: Crowi) {
   const lib = new LocalFileUploader(crowi);
 
   const basePath = path.posix.join(crowi.publicDir, 'uploads');

+ 3 - 2
apps/app/src/server/service/growi-bridge/index.ts

@@ -5,6 +5,7 @@ import { finished } from 'stream/promises';
 
 import unzipStream, { type Entry } from 'unzip-stream';
 
+import type Crowi from '~/server/crowi';
 import loggerFactory from '~/utils/logger';
 
 import { tapStreamDataByPromise } from './unzip-stream-utils';
@@ -18,7 +19,7 @@ const logger = loggerFactory('growi:services:GrowiBridgeService'); // eslint-dis
  */
 class GrowiBridgeService {
 
-  crowi: any;
+  crowi: Crowi;
 
   encoding: string;
 
@@ -26,7 +27,7 @@ class GrowiBridgeService {
 
   baseDir: null;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.encoding = 'utf-8';
     this.metaFileName = 'meta.json';

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

@@ -6,6 +6,7 @@ import type { PageOperationDocument } from '~/server/models/page-operation';
 import PageOperation from '~/server/models/page-operation';
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import type { ObjectIdLike } from '../interfaces/mongoose-utils';
 import { collectAncestorPaths } from '../util/collect-ancestor-paths';
 
@@ -23,9 +24,9 @@ const {
 
 class PageOperationService {
 
-  crowi: any;
+  crowi: Crowi;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }
 

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

@@ -38,6 +38,7 @@ import {
 import { PageActionOnGroupDelete } from '~/interfaces/user-group';
 import { SocketEventName, type PageMigrationErrorData, type UpdateDescCountRawData } from '~/interfaces/websocket';
 import type { CurrentPageYjsData } from '~/interfaces/yjs';
+import type Crowi from '~/server/crowi';
 import type { CreateMethod } from '~/server/models/page';
 import {
   type PageModel, type PageDocument, pushRevision, PageQueryBuilder,
@@ -166,7 +167,7 @@ class PageCursorsForDescendantsFactory {
 
 class PageService implements IPageService {
 
-  crowi: any;
+  crowi: Crowi;
 
   pageEvent: EventEmitter & {
     onCreate,
@@ -180,7 +181,7 @@ class PageService implements IPageService {
 
   pageGrantService: IPageGrantService;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.pageEvent = crowi.event('page');
     this.tagEvent = crowi.event('tag');

+ 2 - 1
apps/app/src/server/service/s2s-messaging/nchan.ts

@@ -5,6 +5,7 @@ import axios from 'axios';
 import ReconnectingWebSocket from 'reconnecting-websocket';
 import WebSocket from 'ws';
 
+import type Crowi from '~/server/crowi';
 import loggerFactory from '~/utils/logger';
 
 import S2sMessage from '../../models/vo/s2s-message';
@@ -175,7 +176,7 @@ class NchanDelegator extends AbstractS2sMessagingService {
 
 }
 
-module.exports = function(crowi) {
+module.exports = function(crowi: Crowi) {
   const { configManager } = crowi;
 
   const uri = configManager.getConfig('app:nchanUri');

+ 2 - 1
apps/app/src/server/service/s2s-messaging/redis.ts

@@ -1,7 +1,8 @@
+import type Crowi from '~/server/crowi';
 import loggerFactory from '~/utils/logger';
 
 const logger = loggerFactory('growi:service:s2s-messaging:redis');
 
-module.exports = function(crowi) {
+module.exports = function(crowi: Crowi) {
   logger.warn('Config pub/sub with Redis has not implemented yet.');
 };

+ 3 - 2
apps/app/src/server/service/search.ts

@@ -9,6 +9,7 @@ import { SearchDelegatorName } from '~/interfaces/named-query';
 import type { IFormattedSearchResult, IPageWithSearchMeta, ISearchResult } from '~/interfaces/search';
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import type { ObjectIdLike } from '../interfaces/mongoose-utils';
 import type {
   SearchDelegator, SearchQueryParser, SearchResolver, ParsedQuery, SearchableData, QueryTerms,
@@ -77,7 +78,7 @@ const findPageListByIds = async(pageIds: ObjectIdLike[], crowi: any) => {
 
 class SearchService implements SearchQueryParser, SearchResolver {
 
-  crowi!: any;
+  crowi: Crowi;
 
   isErrorOccuredOnHealthcheck: boolean | null;
 
@@ -87,7 +88,7 @@ class SearchService implements SearchQueryParser, SearchResolver {
 
   nqDelegators: {[key in SearchDelegatorName]: SearchDelegator};
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
 
     this.isErrorOccuredOnHealthcheck = null;

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

@@ -5,6 +5,7 @@ import type {
 } from '@slack/web-api';
 import urljoin from 'url-join';
 
+import type Crowi from '~/server/crowi';
 import type { EventActionsPermission } from '~/server/interfaces/slack-integration/events';
 import loggerFactory from '~/utils/logger';
 
@@ -19,9 +20,9 @@ const logger = loggerFactory('growi:service:SlackEventHandler:link-shared');
 
 export class LinkSharedEventHandler implements SlackEventHandler<UnfurlRequestEvent> {
 
-  crowi!: any;
+  crowi: Crowi;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }
 

+ 5 - 4
apps/app/src/server/service/slack-integration.ts

@@ -13,12 +13,13 @@ import mongoose from 'mongoose';
 
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import type { EventActionsPermission } from '../interfaces/slack-integration/events';
 import S2sMessage from '../models/vo/s2s-message';
 import { SlackCommandHandlerError } from '../models/vo/slack-command-handler-error';
 import { slackLegacyUtilFactory } from '../util/slack-legacy';
 
-import type { ConfigManager } from './config-manager';
+import type { IConfigManagerForApp } from './config-manager';
 import type { S2sMessagingService } from './s2s-messaging/base';
 import type { S2sMessageHandlable } from './s2s-messaging/handlable';
 import { LinkSharedEventHandler } from './slack-event-handler/link-shared';
@@ -31,9 +32,9 @@ type S2sMessageForSlackIntegration = S2sMessage & { updatedAt: Date };
 
 export class SlackIntegrationService implements S2sMessageHandlable {
 
-  crowi!: any;
+  crowi: Crowi;
 
-  configManager!: ConfigManager;
+  configManager: IConfigManagerForApp;
 
   s2sMessagingService!: S2sMessagingService;
 
@@ -41,7 +42,7 @@ export class SlackIntegrationService implements S2sMessageHandlable {
 
   linkSharedHandler!: LinkSharedEventHandler;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
     this.configManager = crowi.configManager;
     this.s2sMessagingService = crowi.s2sMessagingService;

+ 3 - 2
apps/app/src/server/service/system-events/sync-page-status.ts

@@ -1,3 +1,4 @@
+import type Crowi from '~/server/crowi';
 import loggerFactory from '~/utils/logger';
 
 import { S2cMessagePageUpdated } from '../../models/vo/s2c-message';
@@ -23,7 +24,7 @@ const logger = loggerFactory('growi:service:system-events:SyncPageStatusService'
  */
 class SyncPageStatusService implements S2sMessageHandlable {
 
-  crowi!: any;
+  crowi: Crowi;
 
   s2sMessagingService!: S2sMessagingService;
 
@@ -31,7 +32,7 @@ class SyncPageStatusService implements S2sMessageHandlable {
 
   emitter!: any;
 
-  constructor(crowi, s2sMessagingService, socketIoService) {
+  constructor(crowi: Crowi, s2sMessagingService, socketIoService) {
     this.crowi = crowi;
     this.s2sMessagingService = s2sMessagingService;
     this.socketIoService = socketIoService;

+ 4 - 3
apps/app/src/server/service/user-group.ts

@@ -2,15 +2,16 @@ import type { IUser, IGrantedGroup } from '@growi/core';
 import type { DeleteResult } from 'mongodb';
 import type { Model } from 'mongoose';
 
+import type { PageActionOnGroupDelete } from '~/interfaces/user-group';
 import type { ObjectIdLike } from '~/server/interfaces/mongoose-utils';
 import type { UserGroupDocument, UserGroupModel } from '~/server/models/user-group';
 import UserGroup from '~/server/models/user-group';
 import { excludeTestIdsFromTargetIds, includesObjectIds } from '~/server/util/compare-objectId';
 import loggerFactory from '~/utils/logger';
 
+import type Crowi from '../crowi';
 import type { UserGroupRelationDocument, UserGroupRelationModel } from '../models/user-group-relation';
 import UserGroupRelation from '../models/user-group-relation';
-import { PageActionOnGroupDelete } from '~/interfaces/user-group';
 
 
 const logger = loggerFactory('growi:service:UserGroupService'); // eslint-disable-line no-unused-vars
@@ -27,9 +28,9 @@ export interface IUserGroupService {
  */
 class UserGroupService implements IUserGroupService {
 
-  crowi: any;
+  crowi: Crowi;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }
 

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

@@ -1,5 +1,6 @@
 import type { IRevisionHasId } from '@growi/core';
 
+import type Crowi from '~/server/crowi';
 import { toArrayFromCsv } from '~/utils/to-array-from-csv';
 
 
@@ -14,10 +15,9 @@ import { growiInfoService } from '../growi-info';
  */
 export class UserNotificationService {
 
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  crowi!: any;
+  crowi: Crowi;
 
-  constructor(crowi) {
+  constructor(crowi: Crowi) {
     this.crowi = crowi;
   }