Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8460 - Solve circular imports in board collaboration module #5359

Merged
merged 9 commits into from
Nov 27, 2024
10 changes: 5 additions & 5 deletions apps/server/src/apps/board-collaboration.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { install as sourceMapInstall } from 'source-map-support';
// application imports
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { LegacyLogger, Logger } from '@src/core/logger';
import { RedisIoAdapter } from '@src/infra/socketio';
import { BoardCollaborationModule } from '@src/modules/board/board-collaboration.module';
import { enableOpenApiDocs } from '@src/shared/controller/swagger';
import { RedisIoAdapter } from '@infra/socketio';
import { BoardCollaborationModule } from '@modules/board/board-collaboration.app.module';
import { enableOpenApiDocs } from '@shared/controller/swagger';
import express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
import {
addPrometheusMetricsMiddlewaresIfEnabled,
createAndStartPrometheusMetricsAppIfEnabled,
} from '@src/apps/helpers/prometheus-metrics';
import { ExpressAdapter } from '@nestjs/platform-express';
} from './helpers/prometheus-metrics';

async function bootstrap() {
sourceMapInstall();
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/board/board-api.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AuthorizationModule } from '@modules/authorization';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '../room-member';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der Import verlässt das Module und muss mit @modules/room-member geschrieben werden.

import { BoardModule } from './board.module';
import {
BoardController,
Expand All @@ -12,7 +13,6 @@ import {
} from './controller';
import { BoardNodePermissionService } from './service';
import { BoardUc, CardUc, ColumnUc, ElementUc, SubmissionItemUc } from './uc';
import { RoomMemberModule } from '../room-member';

@Module({
imports: [BoardModule, LoggerModule, RoomMemberModule, forwardRef(() => AuthorizationModule)],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AuthGuardModule, AuthGuardOptions } from '@infra/auth-guard';
import { RabbitMQWrapperModule } from '@infra/rabbitmq';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity/all-entities';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { AuthorizationModule } from '../authorization';
import { config } from './board-collaboration.config';
import { BoardWsApiModule } from './board-ws-api.module';
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion apps/server/src/modules/board/board-ws-api.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthorizationModule } from '@modules/authorization';
import { UserModule } from '@modules/user';
import { forwardRef, Module } from '@nestjs/common';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { RoomMemberModule } from '../room-member';
import { BoardModule } from './board.module';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/board.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UserModule } from '@modules/user';
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LoggerModule } from '@src/core/logger';
import { AuthorizationModule } from '../authorization';
import { RoomMemberModule } from '../room-member';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { EntityManager } from '@mikro-orm/mongodb';
import { ServerTestModule } from '@modules/server/server.module';
import { HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { sanitizeRichText } from '@shared/controller';
import { sanitizeRichText } from '@shared/controller/transformer/sanitize-html.transformer';
import { InputFormat } from '@shared/domain/types';
import { cleanupCollections, courseFactory, TestApiClient, UserAndAccountTestFactory } from '@shared/testing';
import { BoardNodeEntity } from '../../repo';
import { BoardExternalReferenceType, ContentElementType } from '../../domain';
import { BoardNodeEntity } from '../../repo';
import {
cardEntityFactory,
columnBoardEntityFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ import { EntityManager } from '@mikro-orm/mongodb';
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';

import { MongoMemoryDatabaseModule } from '@infra/database';
import { MongoIoAdapter } from '@infra/socketio';
import { InputFormat } from '@shared/domain/types';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity/all-entities';
import { InputFormat } from '@shared/domain/types/input-format.types';
import { cleanupCollections, courseFactory, userFactory } from '@shared/testing';
import { getSocketApiClient, waitForEvent } from '@shared/testing/test-socket-api-client';
import { Socket } from 'socket.io-client';
import { BoardCollaborationModule } from '../../board-collaboration.app.module';
import { BoardExternalReferenceType, CardProps, ContentElementType } from '../../domain';
import {
cardEntityFactory,
columnBoardEntityFactory,
columnEntityFactory,
richTextElementEntityFactory,
} from '../../testing';
import { BoardExternalReferenceType, CardProps, ContentElementType } from '../../domain';
import { BoardCollaborationTestingModule } from '../../board-collaboration.testing.module';
import { BoardCollaborationGateway } from '../board-collaboration.gateway';

describe(BoardCollaborationGateway.name, () => {
Expand All @@ -25,7 +28,13 @@ describe(BoardCollaborationGateway.name, () => {

beforeAll(async () => {
const testingModule = await Test.createTestingModule({
imports: [BoardCollaborationTestingModule],
imports: [
BoardCollaborationModule,
MongoMemoryDatabaseModule.forRoot({
...defaultMikroOrmOptions,
entities: ALL_ENTITIES,
}),
],
}).compile();
app = testingModule.createNestApplication();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { ObjectId } from '@mikro-orm/mongodb';
import { Test, TestingModule } from '@nestjs/testing';
import { CourseRepo } from '@shared/repo';
import { courseFactory, groupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { RoomMemberService } from '@src/modules/room-member';
import { roomFactory } from '@src/modules/room/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { CourseRepo } from '@shared/repo/course';
import { courseFactory, groupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { GroupTypes } from '@src/modules/group';
import { RoomMemberService } from '@src/modules/room-member';
import { roomMemberFactory } from '@src/modules/room-member/testing';
import { columnFactory, columnBoardFactory } from '../../testing';
import { roomFactory } from '@src/modules/room/testing';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@modules Zeile 8-10

import { BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';
import { columnBoardFactory, columnFactory } from '../../testing';
import { BoardContextService } from './board-context.service';

describe(`${BoardContextService.name}`, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Permission } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { RoomMemberService } from '@src/modules/room-member';
import { UserWithRoomRoles } from '@src/modules/room-member/do/room-member-authorizable.do';
import { AnyBoardNode, BoardExternalReferenceType, BoardRoles, UserWithBoardRoles } from '../../domain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CopyFileDto } from '@modules/files-storage-client/dto';
import { ContextExternalToolService } from '@modules/tool/context-external-tool';
import { ContextExternalTool } from '@modules/tool/context-external-tool/domain';
import { ToolConfig } from '@modules/tool/tool-config';
import { Injectable } from '@nestjs/common';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { EntityId } from '@shared/domain/types';
import {
Expand Down Expand Up @@ -37,6 +37,7 @@ export interface CopyContext {
export class BoardNodeCopyService {
constructor(
private readonly configService: ConfigService<ToolConfig, true>,
@Inject(forwardRef(() => ContextExternalToolService))
private readonly contextExternalToolService: ContextExternalToolService,
private readonly copyHelperService: CopyHelperService
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StorageLocation } from '@modules/files-storage/interface';
import { UserService } from '@modules/user';
import { Injectable, InternalServerErrorException, NotImplementedException } from '@nestjs/common';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { BoardExternalReference, BoardExternalReferenceType, ColumnBoard, isColumnBoard } from '../../domain';
import { BoardNodeService } from '../board-node.service';
import { BoardNodeCopyContext } from './board-node-copy-context';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/uc/board.uc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb';
import { Action, AuthorizationService } from '@modules/authorization';
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { setupEntities, userFactory } from '@shared/testing';
import { courseFactory } from '@shared/testing/factory';
import { LegacyLogger } from '@src/core/logger';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/board/uc/board.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CopyStatus } from '@modules/copy-helper';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { Permission } from '@shared/domain/interface';
import { EntityId } from '@shared/domain/types';
import { CourseRepo } from '@shared/repo';
import { CourseRepo } from '@shared/repo/course';
import { LegacyLogger } from '@src/core/logger';
import { RoomMemberService } from '@src/modules/room-member';
import { CreateBoardBodyParams } from '../controller/dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { RabbitMQWrapperModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { BoardClientModule } from './common-cartridge-client/board-client';
import { CoursesClientModule } from './common-cartridge-client/course-client';
import { CommonCartridgeExportService } from './service/common-cartridge-export.service';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { UserModule } from '@modules/user';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config';
import { AccountModule } from '@modules/account';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileEntity } from '../files/entity';
import { DeletionClient } from './deletion-client';
import { DeletionQueueConsole } from './deletion-queue.console';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DeepMocked } from '@golevelup/ts-jest';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { DeletionExecutionConsole } from './deletion-execution.console';
import { DeletionExecutionTriggerResultBuilder, TriggerDeletionExecutionOptionsBuilder } from './builder';
import { DeletionExecutionUc } from './uc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ObjectId } from 'bson';
import fs from 'fs';
import { Test, TestingModule } from '@nestjs/testing';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { DeletionQueueConsole } from './deletion-queue.console';
import { PushDeleteRequestsOptionsBuilder } from './builder';
import { BatchDeletionUc } from './uc';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RabbitMQWrapperTestModule } from '@infra/rabbitmq';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileRecord } from './entity';
import { FilesStorageApiModule } from './files-storage-api.module';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FileRecord, FileRecordSecurityCheck } from './entity';
import { s3Config } from './files-storage.config';
import { FileRecordRepo } from './repo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@sr
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { AccountEntity } from '@src/modules/account/domain/entity/account.entity';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FwuLearningContentsController } from './controller/fwu-learning-contents.controller';
import { config, s3Config } from './fwu-learning-contents.config';
import { FwuLearningContentsUc } from './uc/fwu-learning-contents.uc';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/h5p-editor/h5p-editor.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { Logger } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { H5PEditorController } from './controller/h5p-editor.controller';
import { H5PContent, InstalledLibrary } from './entity';
import { authorizationClientConfig, config, s3ConfigContent, s3ConfigLibraries } from './h5p-editor.config';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ObjectId } from 'bson';
import { Test, TestingModule } from '@nestjs/testing';
import { MongoMemoryDatabaseModule } from '@infra/database';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { IdpSyncConsole } from './idp-sync-console';
import { SystemType } from './interface';
import { UsersSyncOptionsBuilder } from '../testing';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { LoggerModule } from '@src/core/logger';
import { ConsoleModule } from 'nestjs-console';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { idpConsoleConfigConfig } from './idp-console.config';
import { IdpSyncConsole, SynchronizationUc } from './api';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MikroOrmModule } from '@mikro-orm/nestjs';
import { DynamicModule, Module } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ManagementModule } from './management.module';

@Module({
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/server/admin-api.server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LoggerModule } from '@src/core/logger';
import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@src/infra/database';
import { EtherpadClientModule } from '@src/infra/etherpad-client';
import { RabbitMQWrapperModule, RabbitMQWrapperTestModule } from '@src/infra/rabbitmq';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { AdminApiRegistrationPinModule } from '../registration-pin/admin-api-registration-pin.module';
import { adminApiServerConfig } from './admin-api-server.config';

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/server/server.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { ALL_ENTITIES } from '@shared/domain/entity';
import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ServerConfigController, ServerController, ServerUc } from './api';
import { SERVER_CONFIG_TOKEN, serverConfig } from './server.config';

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/tldraw/tldraw-api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions, DB_PASSWORD, DB_USERNAME } from '@src/config';
import { CoreModule } from '@src/core';
import { LoggerModule } from '@src/core/logger';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { config, TLDRAW_DB_URL } from './config';
import { TldrawController } from './controller';
import { TldrawDrawing } from './entities';
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/tldraw/tldraw-console.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createConfigModuleOptions, DB_PASSWORD, DB_USERNAME } from '@src/config
import { CoreModule } from '@src/core';
import { Logger, LoggerModule } from '@src/core/logger';
import { ConsoleModule } from 'nestjs-console';
import { defaultMikroOrmOptions } from '@shared/common';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { FilesStorageClientModule } from '../files-storage-client';
import { config, TLDRAW_DB_URL, TldrawConfig, tldrawS3Config } from './config';
import { TldrawDrawing } from './entities';
Expand Down
Loading
Loading