diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c042be2c2a9..a5688568696 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -172,7 +172,7 @@ jobs: uses: github/codeql-action/upload-sarif@v2 with: sarif_file: 'trivy-results.sarif' - + end-to-end-tests: needs: - build_and_push diff --git a/apps/server/doc/summary.json b/apps/server/doc/summary.json index 834b92cb5f4..2c7489c537a 100644 --- a/apps/server/doc/summary.json +++ b/apps/server/doc/summary.json @@ -61,7 +61,7 @@ }, { "title": "S3ClientModule", - "file": "../src/shared/infra/s3-client/README.md" + "file": "../src/infra/s3-client/README.md" } ] } diff --git a/apps/server/src/apps/helpers/prometheus-metrics.spec.ts b/apps/server/src/apps/helpers/prometheus-metrics.spec.ts index 0c4530f99b8..396fc4865b6 100644 --- a/apps/server/src/apps/helpers/prometheus-metrics.spec.ts +++ b/apps/server/src/apps/helpers/prometheus-metrics.spec.ts @@ -5,7 +5,7 @@ import { PrometheusMetricsConfig, createAPIResponseTimeMetricMiddleware, createPrometheusMetricsApp, -} from '@shared/infra/metrics'; +} from '@infra/metrics'; import { Logger } from '@src/core/logger'; import express, { Express, NextFunction, Request, RequestHandler, Response } from 'express'; import { @@ -15,9 +15,9 @@ import { createAndStartPrometheusMetricsAppIfEnabled, } from './prometheus-metrics'; -jest.mock('@shared/infra/metrics', () => { +jest.mock('@infra/metrics', () => { const moduleMock: unknown = { - ...jest.requireActual('@shared/infra/metrics'), + ...jest.requireActual('@infra/metrics'), createAPIResponseTimeMetricMiddleware: jest.fn(), createPrometheusMetricsApp: jest.fn(), }; diff --git a/apps/server/src/apps/helpers/prometheus-metrics.ts b/apps/server/src/apps/helpers/prometheus-metrics.ts index 751cada4c2f..56d04b85d89 100644 --- a/apps/server/src/apps/helpers/prometheus-metrics.ts +++ b/apps/server/src/apps/helpers/prometheus-metrics.ts @@ -4,7 +4,7 @@ import { PrometheusMetricsConfig, createAPIResponseTimeMetricMiddleware, createPrometheusMetricsApp, -} from '@shared/infra/metrics'; +} from '@infra/metrics'; import { LogMessage, Loggable, Logger } from '@src/core/logger'; import { AppStartLoggable } from './app-start-loggable'; diff --git a/apps/server/src/apps/server.app.ts b/apps/server/src/apps/server.app.ts index bd235d5261f..9538d6c8515 100644 --- a/apps/server/src/apps/server.app.ts +++ b/apps/server/src/apps/server.app.ts @@ -5,7 +5,7 @@ import { MikroORM } from '@mikro-orm/core'; import { NestFactory } from '@nestjs/core'; import { ExpressAdapter } from '@nestjs/platform-express'; import { enableOpenApiDocs } from '@shared/controller/swagger'; -import { Mail, MailService } from '@shared/infra/mail'; +import { Mail, MailService } from '@infra/mail'; import { LegacyLogger, Logger } from '@src/core/logger'; import { AccountService } from '@modules/account/services/account.service'; import { TeamService } from '@modules/teams/service/team.service'; diff --git a/apps/server/src/console/api-test/database-management.console.api.spec.ts b/apps/server/src/console/api-test/database-management.console.api.spec.ts index 6a2a8de7e7f..ea3cc340616 100644 --- a/apps/server/src/console/api-test/database-management.console.api.spec.ts +++ b/apps/server/src/console/api-test/database-management.console.api.spec.ts @@ -1,5 +1,5 @@ import { INestApplicationContext } from '@nestjs/common'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { ServerConsoleModule } from '@src/console/console.module'; import { CommanderError } from 'commander'; import { BootstrapConsole, ConsoleService } from 'nestjs-console'; diff --git a/apps/server/src/console/api-test/server-console.api.spec.ts b/apps/server/src/console/api-test/server-console.api.spec.ts index 0621a809c36..d9b71bd2fbc 100644 --- a/apps/server/src/console/api-test/server-console.api.spec.ts +++ b/apps/server/src/console/api-test/server-console.api.spec.ts @@ -2,7 +2,7 @@ import { INestApplicationContext } from '@nestjs/common'; import { BootstrapConsole, ConsoleService } from 'nestjs-console'; import { ServerConsoleModule } from '@src/console/console.module'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { execute, TestBootstrapConsole } from './test-bootstrap.console'; describe('ServerConsole (API)', () => { diff --git a/apps/server/src/console/api-test/test-bootstrap.console.ts b/apps/server/src/console/api-test/test-bootstrap.console.ts index edb196b6a54..f346720bd22 100644 --- a/apps/server/src/console/api-test/test-bootstrap.console.ts +++ b/apps/server/src/console/api-test/test-bootstrap.console.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { DatabaseManagementUc } from '@modules/management/uc/database-management.uc'; import { AbstractBootstrapConsole, BootstrapConsole } from 'nestjs-console'; diff --git a/apps/server/src/console/console.module.ts b/apps/server/src/console/console.module.ts index 2cad08943eb..9d30db8fedb 100644 --- a/apps/server/src/console/console.module.ts +++ b/apps/server/src/console/console.module.ts @@ -4,8 +4,8 @@ import { MikroOrmModule } from '@mikro-orm/nestjs'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ALL_ENTITIES } from '@shared/domain'; -import { ConsoleWriterModule } from '@shared/infra/console/console-writer/console-writer.module'; -import { KeycloakModule } from '@shared/infra/identity-management/keycloak/keycloak.module'; +import { ConsoleWriterModule } from '@infra/console/console-writer/console-writer.module'; +import { KeycloakModule } from '@infra/identity-management/keycloak/keycloak.module'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; import { FilesModule } from '@modules/files'; import { FileEntity } from '@modules/files/entity'; diff --git a/apps/server/src/console/server.console.spec.ts b/apps/server/src/console/server.console.spec.ts index 60efe0c962f..46ba3fff065 100644 --- a/apps/server/src/console/server.console.spec.ts +++ b/apps/server/src/console/server.console.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { ServerConsoleModule } from './console.module'; import { ServerConsole } from './server.console'; diff --git a/apps/server/src/console/server.console.ts b/apps/server/src/console/server.console.ts index 0b0d0b45c4a..32ff8182241 100644 --- a/apps/server/src/console/server.console.ts +++ b/apps/server/src/console/server.console.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { Command, Console } from 'nestjs-console'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; @Console({ command: 'server', description: 'sample server console' }) export class ServerConsole { diff --git a/apps/server/src/core/error/filter/global-error.filter.ts b/apps/server/src/core/error/filter/global-error.filter.ts index 56760b18dd9..314c8247d18 100644 --- a/apps/server/src/core/error/filter/global-error.filter.ts +++ b/apps/server/src/core/error/filter/global-error.filter.ts @@ -1,6 +1,6 @@ import { ArgumentsHost, Catch, ExceptionFilter, HttpException, InternalServerErrorException } from '@nestjs/common'; import { ApiValidationError, BusinessError } from '@shared/common'; -import { IError, RpcMessage } from '@shared/infra/rabbitmq/rpc-message'; +import { IError, RpcMessage } from '@infra/rabbitmq/rpc-message'; import { ErrorLogger, Loggable } from '@src/core/logger'; import { LoggingUtils } from '@src/core/logger/logging.utils'; import { Response } from 'express'; diff --git a/apps/server/src/shared/infra/antivirus/antivirus.module.spec.ts b/apps/server/src/infra/antivirus/antivirus.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/antivirus.module.spec.ts rename to apps/server/src/infra/antivirus/antivirus.module.spec.ts diff --git a/apps/server/src/shared/infra/antivirus/antivirus.module.ts b/apps/server/src/infra/antivirus/antivirus.module.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/antivirus.module.ts rename to apps/server/src/infra/antivirus/antivirus.module.ts diff --git a/apps/server/src/shared/infra/antivirus/antivirus.service.spec.ts b/apps/server/src/infra/antivirus/antivirus.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/antivirus.service.spec.ts rename to apps/server/src/infra/antivirus/antivirus.service.spec.ts diff --git a/apps/server/src/shared/infra/antivirus/antivirus.service.ts b/apps/server/src/infra/antivirus/antivirus.service.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/antivirus.service.ts rename to apps/server/src/infra/antivirus/antivirus.service.ts diff --git a/apps/server/src/shared/infra/antivirus/index.ts b/apps/server/src/infra/antivirus/index.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/index.ts rename to apps/server/src/infra/antivirus/index.ts diff --git a/apps/server/src/shared/infra/antivirus/interfaces/antivirus.ts b/apps/server/src/infra/antivirus/interfaces/antivirus.ts similarity index 100% rename from apps/server/src/shared/infra/antivirus/interfaces/antivirus.ts rename to apps/server/src/infra/antivirus/interfaces/antivirus.ts diff --git a/apps/server/src/shared/infra/antivirus/interfaces/index.ts b/apps/server/src/infra/antivirus/interfaces/index.ts similarity index 96% rename from apps/server/src/shared/infra/antivirus/interfaces/index.ts rename to apps/server/src/infra/antivirus/interfaces/index.ts index 6c4771f9cd5..b41764286b4 100644 --- a/apps/server/src/shared/infra/antivirus/interfaces/index.ts +++ b/apps/server/src/infra/antivirus/interfaces/index.ts @@ -1 +1 @@ -export * from './antivirus'; +export * from './antivirus'; diff --git a/apps/server/src/shared/infra/cache/cache.module.ts b/apps/server/src/infra/cache/cache.module.ts similarity index 100% rename from apps/server/src/shared/infra/cache/cache.module.ts rename to apps/server/src/infra/cache/cache.module.ts diff --git a/apps/server/src/shared/infra/cache/index.ts b/apps/server/src/infra/cache/index.ts similarity index 100% rename from apps/server/src/shared/infra/cache/index.ts rename to apps/server/src/infra/cache/index.ts diff --git a/apps/server/src/shared/infra/cache/interface/cache-store-type.enum.ts b/apps/server/src/infra/cache/interface/cache-store-type.enum.ts similarity index 100% rename from apps/server/src/shared/infra/cache/interface/cache-store-type.enum.ts rename to apps/server/src/infra/cache/interface/cache-store-type.enum.ts diff --git a/apps/server/src/shared/infra/cache/interface/index.ts b/apps/server/src/infra/cache/interface/index.ts similarity index 100% rename from apps/server/src/shared/infra/cache/interface/index.ts rename to apps/server/src/infra/cache/interface/index.ts diff --git a/apps/server/src/shared/infra/cache/service/cache.service.ts b/apps/server/src/infra/cache/service/cache.service.ts similarity index 100% rename from apps/server/src/shared/infra/cache/service/cache.service.ts rename to apps/server/src/infra/cache/service/cache.service.ts diff --git a/apps/server/src/shared/infra/calendar/calendar.module.ts b/apps/server/src/infra/calendar/calendar.module.ts similarity index 58% rename from apps/server/src/shared/infra/calendar/calendar.module.ts rename to apps/server/src/infra/calendar/calendar.module.ts index feb0611fcdc..b4eddacef92 100644 --- a/apps/server/src/shared/infra/calendar/calendar.module.ts +++ b/apps/server/src/infra/calendar/calendar.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; -import { CalendarService } from '@shared/infra/calendar/service/calendar.service'; -import { CalendarMapper } from '@shared/infra/calendar/mapper/calendar.mapper'; +import { CalendarService } from './service/calendar.service'; +import { CalendarMapper } from './mapper/calendar.mapper'; @Module({ imports: [HttpModule], diff --git a/apps/server/src/shared/infra/calendar/dto/calendar-event.dto.ts b/apps/server/src/infra/calendar/dto/calendar-event.dto.ts similarity index 100% rename from apps/server/src/shared/infra/calendar/dto/calendar-event.dto.ts rename to apps/server/src/infra/calendar/dto/calendar-event.dto.ts diff --git a/apps/server/src/shared/infra/calendar/index.ts b/apps/server/src/infra/calendar/index.ts similarity index 100% rename from apps/server/src/shared/infra/calendar/index.ts rename to apps/server/src/infra/calendar/index.ts diff --git a/apps/server/src/shared/infra/calendar/interface/calendar-event.interface.ts b/apps/server/src/infra/calendar/interface/calendar-event.interface.ts similarity index 100% rename from apps/server/src/shared/infra/calendar/interface/calendar-event.interface.ts rename to apps/server/src/infra/calendar/interface/calendar-event.interface.ts diff --git a/apps/server/src/shared/infra/calendar/mapper/calendar.mapper.spec.ts b/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts similarity index 80% rename from apps/server/src/shared/infra/calendar/mapper/calendar.mapper.spec.ts rename to apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts index 512173c8ccb..9679ce0a4fa 100644 --- a/apps/server/src/shared/infra/calendar/mapper/calendar.mapper.spec.ts +++ b/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts @@ -1,6 +1,6 @@ -import { ICalendarEvent } from '@shared/infra/calendar/interface/calendar-event.interface'; +import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; import { Test, TestingModule } from '@nestjs/testing'; -import { CalendarMapper } from '@shared/infra/calendar/mapper/calendar.mapper'; +import { CalendarMapper } from './calendar.mapper'; describe('CalendarMapper', () => { let module: TestingModule; diff --git a/apps/server/src/shared/infra/calendar/mapper/calendar.mapper.ts b/apps/server/src/infra/calendar/mapper/calendar.mapper.ts similarity index 62% rename from apps/server/src/shared/infra/calendar/mapper/calendar.mapper.ts rename to apps/server/src/infra/calendar/mapper/calendar.mapper.ts index 8a71dbcb75f..a75ff01eae6 100644 --- a/apps/server/src/shared/infra/calendar/mapper/calendar.mapper.ts +++ b/apps/server/src/infra/calendar/mapper/calendar.mapper.ts @@ -1,6 +1,6 @@ -import { ICalendarEvent } from '@shared/infra/calendar/interface/calendar-event.interface'; +import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; import { Injectable } from '@nestjs/common'; -import { CalendarEventDto } from '@shared/infra/calendar/dto/calendar-event.dto'; +import { CalendarEventDto } from '../dto/calendar-event.dto'; @Injectable() export class CalendarMapper { diff --git a/apps/server/src/shared/infra/calendar/service/calendar.service.spec.ts b/apps/server/src/infra/calendar/service/calendar.service.spec.ts similarity index 90% rename from apps/server/src/shared/infra/calendar/service/calendar.service.spec.ts rename to apps/server/src/infra/calendar/service/calendar.service.spec.ts index 43ca5ad06d4..ed6bb4620bc 100644 --- a/apps/server/src/shared/infra/calendar/service/calendar.service.spec.ts +++ b/apps/server/src/infra/calendar/service/calendar.service.spec.ts @@ -3,12 +3,12 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { HttpService } from '@nestjs/axios'; import { InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { CalendarEventDto, CalendarService } from '@shared/infra/calendar'; -import { ICalendarEvent } from '@shared/infra/calendar/interface/calendar-event.interface'; -import { CalendarMapper } from '@shared/infra/calendar/mapper/calendar.mapper'; +import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { axiosResponseFactory } from '@shared/testing'; import { AxiosResponse } from 'axios'; import { of, throwError } from 'rxjs'; +import { CalendarMapper } from '../mapper/calendar.mapper'; +import { ICalendarEvent } from '../interface/calendar-event.interface'; describe('CalendarServiceSpec', () => { let module: TestingModule; diff --git a/apps/server/src/shared/infra/calendar/service/calendar.service.ts b/apps/server/src/infra/calendar/service/calendar.service.ts similarity index 91% rename from apps/server/src/shared/infra/calendar/service/calendar.service.ts rename to apps/server/src/infra/calendar/service/calendar.service.ts index b79564634a5..3bf2a6576be 100644 --- a/apps/server/src/shared/infra/calendar/service/calendar.service.ts +++ b/apps/server/src/infra/calendar/service/calendar.service.ts @@ -2,12 +2,12 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { HttpService } from '@nestjs/axios'; import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { EntityId } from '@shared/domain'; -import { CalendarEventDto } from '@shared/infra/calendar/dto/calendar-event.dto'; -import { CalendarMapper } from '@shared/infra/calendar/mapper/calendar.mapper'; import { ErrorUtils } from '@src/core/error/utils'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; import { Observable, firstValueFrom } from 'rxjs'; import { URL, URLSearchParams } from 'url'; +import { CalendarMapper } from '../mapper/calendar.mapper'; +import { CalendarEventDto } from '../dto/calendar-event.dto'; import { ICalendarEvent } from '../interface/calendar-event.interface'; @Injectable() diff --git a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage-adapter.module.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts similarity index 75% rename from apps/server/src/shared/infra/collaborative-storage/collaborative-storage-adapter.module.ts rename to apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts index 84e4f4596d6..f60ff664654 100644 --- a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage-adapter.module.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts @@ -1,14 +1,14 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { HttpModule } from '@nestjs/axios'; import { Module, Provider } from '@nestjs/common'; -import { CollaborativeStorageAdapterMapper } from '@shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper'; -import { NextcloudClient } from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client'; -import { NextcloudStrategy } from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy'; import { LtiToolRepo } from '@shared/repo/ltitool/'; import { LoggerModule } from '@src/core/logger'; import { ToolModule } from '@modules/tool'; import { PseudonymModule } from '@modules/pseudonym'; import { UserModule } from '@modules/user'; +import { NextcloudStrategy } from './strategy/nextcloud/nextcloud.strategy'; +import { NextcloudClient } from './strategy/nextcloud/nextcloud.client'; +import { CollaborativeStorageAdapterMapper } from './mapper'; import { CollaborativeStorageAdapter } from './collaborative-storage.adapter'; const storageStrategy: Provider = { diff --git a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.spec.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts similarity index 89% rename from apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.spec.ts rename to apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts index c33f9be282a..3b9ba2175e6 100644 --- a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.spec.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts @@ -2,11 +2,11 @@ import { createMock } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { RoleName } from '@shared/domain'; -import { CollaborativeStorageAdapter } from '@shared/infra/collaborative-storage/collaborative-storage.adapter'; -import { CollaborativeStorageAdapterMapper } from '@shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper'; -import { ICollaborativeStorageStrategy } from '@shared/infra/collaborative-storage/strategy/base.interface.strategy'; import { LegacyLogger } from '@src/core/logger'; -import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; +import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; // invalid import please fix +import { CollaborativeStorageAdapter } from './collaborative-storage.adapter'; +import { CollaborativeStorageAdapterMapper } from './mapper/collaborative-storage-adapter.mapper'; +import { ICollaborativeStorageStrategy } from './strategy/base.interface.strategy'; class TestStrategy implements ICollaborativeStorageStrategy { baseURL: string; diff --git a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.ts similarity index 88% rename from apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.ts rename to apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.ts index 9edcafbdc12..b50657f393e 100644 --- a/apps/server/src/shared/infra/collaborative-storage/collaborative-storage.adapter.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.ts @@ -1,10 +1,10 @@ import { TeamPermissionsDto } from '@modules/collaborative-storage/services/dto/team-permissions.dto'; import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; -import { ICollaborativeStorageStrategy } from '@shared/infra/collaborative-storage/strategy/base.interface.strategy'; import { Inject, Injectable } from '@nestjs/common'; -import { CollaborativeStorageAdapterMapper } from '@shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper'; import { LegacyLogger } from '@src/core/logger'; import { RoleDto } from '@modules/role/service/dto/role.dto'; +import { CollaborativeStorageAdapterMapper } from './mapper/collaborative-storage-adapter.mapper'; +import { ICollaborativeStorageStrategy } from './strategy/base.interface.strategy'; /** * Provides an Adapter to an external collaborative storage. diff --git a/apps/server/src/shared/infra/collaborative-storage/dto/team-role-permissions.dto.ts b/apps/server/src/infra/collaborative-storage/dto/team-role-permissions.dto.ts similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/dto/team-role-permissions.dto.ts rename to apps/server/src/infra/collaborative-storage/dto/team-role-permissions.dto.ts diff --git a/apps/server/src/infra/collaborative-storage/index.ts b/apps/server/src/infra/collaborative-storage/index.ts new file mode 100644 index 00000000000..49dea4522b3 --- /dev/null +++ b/apps/server/src/infra/collaborative-storage/index.ts @@ -0,0 +1,2 @@ +export { CollaborativeStorageAdapter } from './collaborative-storage.adapter'; +export { CollaborativeStorageAdapterModule } from './collaborative-storage-adapter.module'; diff --git a/apps/server/src/shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts b/apps/server/src/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts similarity index 89% rename from apps/server/src/shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts rename to apps/server/src/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts index cba6ef365c2..bea98c50ebe 100644 --- a/apps/server/src/shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts +++ b/apps/server/src/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { RoleName } from '@shared/domain'; -import { CollaborativeStorageAdapterMapper } from '@shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper'; +import { CollaborativeStorageAdapterMapper } from '@infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper'; describe('TeamStorage Mapper', () => { let module: TestingModule; diff --git a/apps/server/src/shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.ts b/apps/server/src/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.ts similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.ts rename to apps/server/src/infra/collaborative-storage/mapper/collaborative-storage-adapter.mapper.ts diff --git a/apps/server/src/infra/collaborative-storage/mapper/index.ts b/apps/server/src/infra/collaborative-storage/mapper/index.ts new file mode 100644 index 00000000000..08f05350be2 --- /dev/null +++ b/apps/server/src/infra/collaborative-storage/mapper/index.ts @@ -0,0 +1 @@ +export * from './collaborative-storage-adapter.mapper'; diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/base.interface.strategy.ts b/apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/strategy/base.interface.strategy.ts rename to apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/httpRequests/NextcloudGroups.http b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/httpRequests/NextcloudGroups.http similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/httpRequests/NextcloudGroups.http rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/httpRequests/NextcloudGroups.http diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts similarity index 99% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts index 5aa4cb8b09d..225ddac258d 100644 --- a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts +++ b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.spec.ts @@ -3,11 +3,11 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { NotFoundException, NotImplementedException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { NextcloudClient } from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client'; import { axiosResponseFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AxiosResponse } from 'axios'; import { Observable, of } from 'rxjs'; +import { NextcloudClient } from './nextcloud.client'; import { GroupUsers, GroupfoldersCreated, diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts similarity index 99% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts index 75caf1bc0e4..ab4a139224c 100644 --- a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts +++ b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.client.ts @@ -15,7 +15,7 @@ import { NextcloudGroups, OcsResponse, SuccessfulRes, -} from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.interface'; +} from '@infra/collaborative-storage/strategy/nextcloud/nextcloud.interface'; import { ErrorUtils } from '@src/core/error/utils'; import { LegacyLogger } from '@src/core/logger'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.interface.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.interface.ts similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.interface.ts rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.interface.ts diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts similarity index 98% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts index 7684b14dbb0..706e360b700 100644 --- a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts +++ b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.spec.ts @@ -3,9 +3,6 @@ import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LtiPrivacyPermission, LtiRoleType, Pseudonym, RoleName, User, UserDO } from '@shared/domain'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; -import { TeamRolePermissionsDto } from '@shared/infra/collaborative-storage/dto/team-role-permissions.dto'; -import { NextcloudClient } from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.client'; -import { NextcloudStrategy } from '@shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy'; import { LtiToolRepo } from '@shared/repo'; import { ltiToolDOFactory, pseudonymFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; @@ -13,6 +10,9 @@ import { TeamDto, TeamUserDto } from '@modules/collaborative-storage/services/dt import { PseudonymService } from '@modules/pseudonym'; import { ExternalToolService } from '@modules/tool/external-tool/service'; import { UserService } from '@modules/user'; +import { NextcloudStrategy } from './nextcloud.strategy'; +import { NextcloudClient } from './nextcloud.client'; +import { TeamRolePermissionsDto } from '../../dto/team-role-permissions.dto'; class NextcloudStrategySpec extends NextcloudStrategy { static specGenerateGroupId(dto: TeamRolePermissionsDto): string { diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts diff --git a/apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/test.json b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/test.json similarity index 100% rename from apps/server/src/shared/infra/collaborative-storage/strategy/nextcloud/test.json rename to apps/server/src/infra/collaborative-storage/strategy/nextcloud/test.json diff --git a/apps/server/src/shared/infra/console/console-writer/console-writer.module.spec.ts b/apps/server/src/infra/console/console-writer/console-writer.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/console/console-writer/console-writer.module.spec.ts rename to apps/server/src/infra/console/console-writer/console-writer.module.spec.ts diff --git a/apps/server/src/shared/infra/console/console-writer/console-writer.module.ts b/apps/server/src/infra/console/console-writer/console-writer.module.ts similarity index 100% rename from apps/server/src/shared/infra/console/console-writer/console-writer.module.ts rename to apps/server/src/infra/console/console-writer/console-writer.module.ts diff --git a/apps/server/src/shared/infra/console/console-writer/console-writer.service.spec.ts b/apps/server/src/infra/console/console-writer/console-writer.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/console/console-writer/console-writer.service.spec.ts rename to apps/server/src/infra/console/console-writer/console-writer.service.spec.ts diff --git a/apps/server/src/shared/infra/console/console-writer/console-writer.service.ts b/apps/server/src/infra/console/console-writer/console-writer.service.ts similarity index 100% rename from apps/server/src/shared/infra/console/console-writer/console-writer.service.ts rename to apps/server/src/infra/console/console-writer/console-writer.service.ts diff --git a/apps/server/src/shared/infra/console/console-writer/index.ts b/apps/server/src/infra/console/console-writer/index.ts similarity index 100% rename from apps/server/src/shared/infra/console/console-writer/index.ts rename to apps/server/src/infra/console/console-writer/index.ts diff --git a/apps/server/src/shared/infra/console/index.ts b/apps/server/src/infra/console/index.ts similarity index 100% rename from apps/server/src/shared/infra/console/index.ts rename to apps/server/src/infra/console/index.ts diff --git a/apps/server/src/shared/infra/database/index.ts b/apps/server/src/infra/database/index.ts similarity index 100% rename from apps/server/src/shared/infra/database/index.ts rename to apps/server/src/infra/database/index.ts diff --git a/apps/server/src/shared/infra/database/management/database-management.module.spec.ts b/apps/server/src/infra/database/management/database-management.module.spec.ts similarity index 90% rename from apps/server/src/shared/infra/database/management/database-management.module.spec.ts rename to apps/server/src/infra/database/management/database-management.module.spec.ts index 2ea05d7a121..1f80c58b5d4 100644 --- a/apps/server/src/shared/infra/database/management/database-management.module.spec.ts +++ b/apps/server/src/infra/database/management/database-management.module.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { DatabaseManagementModule } from './database-management.module'; import { DatabaseManagementService } from './database-management.service'; diff --git a/apps/server/src/shared/infra/database/management/database-management.module.ts b/apps/server/src/infra/database/management/database-management.module.ts similarity index 100% rename from apps/server/src/shared/infra/database/management/database-management.module.ts rename to apps/server/src/infra/database/management/database-management.module.ts diff --git a/apps/server/src/shared/infra/database/management/database-management.service.spec.ts b/apps/server/src/infra/database/management/database-management.service.spec.ts similarity index 97% rename from apps/server/src/shared/infra/database/management/database-management.service.spec.ts rename to apps/server/src/infra/database/management/database-management.service.spec.ts index 2487fda1280..7bbe7bdc5e3 100644 --- a/apps/server/src/shared/infra/database/management/database-management.service.spec.ts +++ b/apps/server/src/infra/database/management/database-management.service.spec.ts @@ -1,6 +1,6 @@ import { MikroORM } from '@mikro-orm/core'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ObjectId } from 'mongodb'; import { DatabaseManagementService } from './database-management.service'; diff --git a/apps/server/src/shared/infra/database/management/database-management.service.ts b/apps/server/src/infra/database/management/database-management.service.ts similarity index 100% rename from apps/server/src/shared/infra/database/management/database-management.service.ts rename to apps/server/src/infra/database/management/database-management.service.ts diff --git a/apps/server/src/shared/infra/database/management/index.ts b/apps/server/src/infra/database/management/index.ts similarity index 100% rename from apps/server/src/shared/infra/database/management/index.ts rename to apps/server/src/infra/database/management/index.ts diff --git a/apps/server/src/shared/infra/database/mongo-memory-database/index.ts b/apps/server/src/infra/database/mongo-memory-database/index.ts similarity index 100% rename from apps/server/src/shared/infra/database/mongo-memory-database/index.ts rename to apps/server/src/infra/database/mongo-memory-database/index.ts diff --git a/apps/server/src/shared/infra/database/mongo-memory-database/mongo-memory-database.module.ts b/apps/server/src/infra/database/mongo-memory-database/mongo-memory-database.module.ts similarity index 100% rename from apps/server/src/shared/infra/database/mongo-memory-database/mongo-memory-database.module.ts rename to apps/server/src/infra/database/mongo-memory-database/mongo-memory-database.module.ts diff --git a/apps/server/src/shared/infra/database/mongo-memory-database/types.ts b/apps/server/src/infra/database/mongo-memory-database/types.ts similarity index 100% rename from apps/server/src/shared/infra/database/mongo-memory-database/types.ts rename to apps/server/src/infra/database/mongo-memory-database/types.ts diff --git a/apps/server/src/shared/infra/encryption/encryption.interface.ts b/apps/server/src/infra/encryption/encryption.interface.ts similarity index 100% rename from apps/server/src/shared/infra/encryption/encryption.interface.ts rename to apps/server/src/infra/encryption/encryption.interface.ts diff --git a/apps/server/src/shared/infra/encryption/encryption.module.spec.ts b/apps/server/src/infra/encryption/encryption.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/encryption/encryption.module.spec.ts rename to apps/server/src/infra/encryption/encryption.module.spec.ts diff --git a/apps/server/src/shared/infra/encryption/encryption.module.ts b/apps/server/src/infra/encryption/encryption.module.ts similarity index 100% rename from apps/server/src/shared/infra/encryption/encryption.module.ts rename to apps/server/src/infra/encryption/encryption.module.ts diff --git a/apps/server/src/shared/infra/encryption/encryption.service.spec.ts b/apps/server/src/infra/encryption/encryption.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/encryption/encryption.service.spec.ts rename to apps/server/src/infra/encryption/encryption.service.spec.ts diff --git a/apps/server/src/shared/infra/encryption/encryption.service.ts b/apps/server/src/infra/encryption/encryption.service.ts similarity index 100% rename from apps/server/src/shared/infra/encryption/encryption.service.ts rename to apps/server/src/infra/encryption/encryption.service.ts diff --git a/apps/server/src/shared/infra/encryption/index.ts b/apps/server/src/infra/encryption/index.ts similarity index 97% rename from apps/server/src/shared/infra/encryption/index.ts rename to apps/server/src/infra/encryption/index.ts index 201f12060e4..39019741bd0 100644 --- a/apps/server/src/shared/infra/encryption/index.ts +++ b/apps/server/src/infra/encryption/index.ts @@ -1,3 +1,3 @@ -export * from './encryption.module'; -export * from './encryption.interface'; -export * from './encryption.service'; +export * from './encryption.module'; +export * from './encryption.interface'; +export * from './encryption.service'; diff --git a/apps/server/src/shared/infra/feathers/feathers-service.provider.spec.ts b/apps/server/src/infra/feathers/feathers-service.provider.spec.ts similarity index 100% rename from apps/server/src/shared/infra/feathers/feathers-service.provider.spec.ts rename to apps/server/src/infra/feathers/feathers-service.provider.spec.ts diff --git a/apps/server/src/shared/infra/feathers/feathers-service.provider.ts b/apps/server/src/infra/feathers/feathers-service.provider.ts similarity index 100% rename from apps/server/src/shared/infra/feathers/feathers-service.provider.ts rename to apps/server/src/infra/feathers/feathers-service.provider.ts diff --git a/apps/server/src/shared/infra/feathers/feathers.module.ts b/apps/server/src/infra/feathers/feathers.module.ts similarity index 100% rename from apps/server/src/shared/infra/feathers/feathers.module.ts rename to apps/server/src/infra/feathers/feathers.module.ts diff --git a/apps/server/src/shared/infra/feathers/index.ts b/apps/server/src/infra/feathers/index.ts similarity index 100% rename from apps/server/src/shared/infra/feathers/index.ts rename to apps/server/src/infra/feathers/index.ts diff --git a/apps/server/src/shared/infra/file-system/file-system.adapter.spec.ts b/apps/server/src/infra/file-system/file-system.adapter.spec.ts similarity index 100% rename from apps/server/src/shared/infra/file-system/file-system.adapter.spec.ts rename to apps/server/src/infra/file-system/file-system.adapter.spec.ts diff --git a/apps/server/src/shared/infra/file-system/file-system.adapter.ts b/apps/server/src/infra/file-system/file-system.adapter.ts similarity index 100% rename from apps/server/src/shared/infra/file-system/file-system.adapter.ts rename to apps/server/src/infra/file-system/file-system.adapter.ts diff --git a/apps/server/src/shared/infra/file-system/file-system.module.spec.ts b/apps/server/src/infra/file-system/file-system.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/file-system/file-system.module.spec.ts rename to apps/server/src/infra/file-system/file-system.module.spec.ts diff --git a/apps/server/src/shared/infra/file-system/file-system.module.ts b/apps/server/src/infra/file-system/file-system.module.ts similarity index 100% rename from apps/server/src/shared/infra/file-system/file-system.module.ts rename to apps/server/src/infra/file-system/file-system.module.ts diff --git a/apps/server/src/shared/infra/file-system/index.ts b/apps/server/src/infra/file-system/index.ts similarity index 100% rename from apps/server/src/shared/infra/file-system/index.ts rename to apps/server/src/infra/file-system/index.ts diff --git a/apps/server/src/shared/infra/file-system/utf-8-test-file.txt b/apps/server/src/infra/file-system/utf-8-test-file.txt similarity index 100% rename from apps/server/src/shared/infra/file-system/utf-8-test-file.txt rename to apps/server/src/infra/file-system/utf-8-test-file.txt diff --git a/apps/server/src/shared/infra/identity-management/identity-management-oauth.service.ts b/apps/server/src/infra/identity-management/identity-management-oauth.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/identity-management-oauth.service.ts rename to apps/server/src/infra/identity-management/identity-management-oauth.service.ts diff --git a/apps/server/src/shared/infra/identity-management/identity-management.config.ts b/apps/server/src/infra/identity-management/identity-management.config.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/identity-management.config.ts rename to apps/server/src/infra/identity-management/identity-management.config.ts diff --git a/apps/server/src/shared/infra/identity-management/identity-management.module.spec.ts b/apps/server/src/infra/identity-management/identity-management.module.spec.ts similarity index 92% rename from apps/server/src/shared/infra/identity-management/identity-management.module.spec.ts rename to apps/server/src/infra/identity-management/identity-management.module.spec.ts index 9bbfe6d1f93..e81186d7562 100644 --- a/apps/server/src/shared/infra/identity-management/identity-management.module.spec.ts +++ b/apps/server/src/infra/identity-management/identity-management.module.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ConfigModule } from '@nestjs/config'; import { IdentityManagementService } from './identity-management.service'; import { IdentityManagementModule } from './identity-management.module'; diff --git a/apps/server/src/shared/infra/identity-management/identity-management.module.ts b/apps/server/src/infra/identity-management/identity-management.module.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/identity-management.module.ts rename to apps/server/src/infra/identity-management/identity-management.module.ts diff --git a/apps/server/src/shared/infra/identity-management/identity-management.service.ts b/apps/server/src/infra/identity-management/identity-management.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/identity-management.service.ts rename to apps/server/src/infra/identity-management/identity-management.service.ts diff --git a/apps/server/src/shared/infra/identity-management/index.ts b/apps/server/src/infra/identity-management/index.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/index.ts rename to apps/server/src/infra/identity-management/index.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts b/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts rename to apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-administration.module.spec.ts b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-administration.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-administration.module.spec.ts rename to apps/server/src/infra/identity-management/keycloak-administration/keycloak-administration.module.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-administration.module.ts b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-administration.module.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-administration.module.ts rename to apps/server/src/infra/identity-management/keycloak-administration/keycloak-administration.module.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/keycloak-config.ts rename to apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service.spec.ts b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts rename to apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts similarity index 98% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts index 16c5c9c2d1a..9b3120b8b8c 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { LegacyLogger } from '@src/core/logger'; import { KeycloakConfigurationUc } from '../uc/keycloak-configuration.uc'; import { KeycloakConsole } from './keycloak-configuration.console'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts similarity index 98% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts index 1d597e7020a..85d3f7a5a3c 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts @@ -1,4 +1,4 @@ -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { LegacyLogger } from '@src/core/logger'; import { Command, CommandOption, Console } from 'nestjs-console'; import { KeycloakConfigurationUc } from '../uc/keycloak-configuration.uc'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.ts b/apps/server/src/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/controller/keycloak-configuration.controller.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/keycloak-configuration-input-files.interface.ts b/apps/server/src/infra/identity-management/keycloak-configuration/interface/keycloak-configuration-input-files.interface.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/interface/keycloak-configuration-input-files.interface.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/interface/keycloak-configuration-input-files.interface.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-config.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts similarity index 94% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts index 3e31e5dcb08..f1d0ee3808e 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ConfigModule } from '@nestjs/config'; import { KeycloakConfigurationModule } from './keycloak-configuration.module'; import { KeycloakConsole } from './console/keycloak-configuration.console'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts similarity index 93% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts index 2012dad00a5..4e570b30dcf 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-configuration.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; import { LoggerModule } from '@src/core/logger'; -import { EncryptionModule } from '@shared/infra/encryption'; -import { ConsoleWriterModule } from '@shared/infra/console'; +import { EncryptionModule } from '@infra/encryption'; +import { ConsoleWriterModule } from '@infra/console'; import { AccountModule } from '@modules/account'; import { SystemModule } from '@modules/system'; import { KeycloakAdministrationModule } from '../keycloak-administration/keycloak-administration.module'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts similarity index 98% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts index b28d74ca3d5..94ef9c042a4 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.spec.ts @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import IdentityProviderRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { DefaultEncryptionService, SymetricKeyEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; import { OidcConfigDto } from '@modules/system/service'; import { OidcIdentityProviderMapper } from './identity-provider.mapper'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts b/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts similarity index 92% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts index 75737263cac..6573ed35a5b 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts @@ -1,6 +1,6 @@ import IdentityProviderRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation'; import { Inject } from '@nestjs/common'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; import { OidcConfigDto } from '@modules/system/service'; export class OidcIdentityProviderMapper { diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts similarity index 98% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts index ad5af6a1d75..98ed3552918 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.integration.spec.ts @@ -4,7 +4,7 @@ import AuthenticationExecutionExportRepresentation from '@keycloak/keycloak-admi import AuthenticationFlowRepresentation from '@keycloak/keycloak-admin-client/lib/defs/authenticationFlowRepresentation'; import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { SystemRepo } from '@shared/repo/system/system.repo'; import { systemFactory } from '@shared/testing/factory'; import { LoggerModule } from '@src/core/logger'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts similarity index 99% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts index 1388392995e..61e475fe3e3 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.spec.ts @@ -10,7 +10,7 @@ import { HttpService } from '@nestjs/axios'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { SystemEntity, SystemTypeEnum } from '@shared/domain'; -import { SymetricKeyEncryptionService } from '@shared/infra/encryption'; +import { SymetricKeyEncryptionService } from '@infra/encryption'; import { systemFactory } from '@shared/testing'; import { SystemOidcMapper } from '@modules/system/mapper/system-oidc.mapper'; import { SystemOidcService } from '@modules/system/service/system-oidc.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts similarity index 98% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts index baf86c58ccf..eba5e20fcd0 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.integration.spec.ts @@ -3,7 +3,7 @@ import KeycloakAdminClient from '@keycloak/keycloak-admin-client'; import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { Account } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { accountFactory, cleanupCollections } from '@shared/testing'; import { LoggerModule } from '@src/core/logger'; import { v1 } from 'uuid'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-migration.service.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts similarity index 97% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts index 87f28a28d76..11858b56a2b 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.integration.spec.ts @@ -2,7 +2,7 @@ import KeycloakAdminClient from '@keycloak/keycloak-admin-client'; import { faker } from '@faker-js/faker'; import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { LoggerModule } from '@src/core/logger'; import { v1 } from 'uuid'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.spec.ts b/apps/server/src/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.spec.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.uc.ts b/apps/server/src/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.uc.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.uc.ts rename to apps/server/src/infra/identity-management/keycloak-configuration/uc/keycloak-configuration.uc.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.spec.ts b/apps/server/src/infra/identity-management/keycloak/keycloak.module.spec.ts similarity index 94% rename from apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.spec.ts rename to apps/server/src/infra/identity-management/keycloak/keycloak.module.spec.ts index 6bed42efdd6..282d6dd0e40 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak/keycloak.module.spec.ts @@ -1,6 +1,6 @@ import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { KeycloakModule } from './keycloak.module'; import { KeycloakIdentityManagementService } from './service/keycloak-identity-management.service'; import { KeycloakIdentityManagementOauthService } from './service/keycloak-identity-management-oauth.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.ts b/apps/server/src/infra/identity-management/keycloak/keycloak.module.ts similarity index 92% rename from apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.ts rename to apps/server/src/infra/identity-management/keycloak/keycloak.module.ts index 4f7407f80c9..c2fd27be29e 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/keycloak.module.ts +++ b/apps/server/src/infra/identity-management/keycloak/keycloak.module.ts @@ -1,6 +1,6 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { EncryptionModule } from '@shared/infra/encryption'; +import { EncryptionModule } from '@infra/encryption'; import { LoggerModule } from '@src/core/logger'; import { KeycloakAdministrationModule } from '../keycloak-administration/keycloak-administration.module'; import { KeycloakIdentityManagementOauthService } from './service/keycloak-identity-management-oauth.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts similarity index 96% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts index 9e4cf5567c1..40456bbb184 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.integration.spec.ts @@ -1,7 +1,7 @@ import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { KeycloakModule } from '@shared/infra/identity-management/keycloak/keycloak.module'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { KeycloakModule } from '@infra/identity-management/keycloak/keycloak.module'; import { LoggerModule } from '@src/core/logger'; import { v1 } from 'uuid'; import { KeycloakAdministrationModule } from '../../keycloak-administration/keycloak-administration.module'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts similarity index 99% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts index f9c3745ce64..9ccd20b6f99 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.spec.ts @@ -3,7 +3,7 @@ import KeycloakAdminClient from '@keycloak/keycloak-admin-client'; import { HttpService } from '@nestjs/axios'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { DefaultEncryptionService, IEncryptionService, SymetricKeyEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; import { AxiosResponse } from 'axios'; import { of } from 'rxjs'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts similarity index 97% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts index 7e10179b2cd..9eab3a4f60a 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts +++ b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management-oauth.service.ts @@ -1,7 +1,7 @@ import { HttpService } from '@nestjs/axios'; import { Inject, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; import { OauthConfigDto } from '@modules/system/service'; import qs from 'qs'; import { lastValueFrom } from 'rxjs'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts similarity index 96% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts index fd66603f730..c5f83c35f17 100644 --- a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts +++ b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.integration.spec.ts @@ -4,8 +4,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { HttpModule } from '@nestjs/axios'; import { Test, TestingModule } from '@nestjs/testing'; import { IdmAccount, IdmAccountUpdate } from '@shared/domain'; -import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service'; -import { KeycloakModule } from '@shared/infra/identity-management/keycloak/keycloak.module'; +import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; +import { KeycloakModule } from '@infra/identity-management/keycloak/keycloak.module'; import { ServerModule } from '@modules/server'; import { v1 } from 'uuid'; import { IdentityManagementService } from '../../identity-management.service'; diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.spec.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.spec.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.spec.ts diff --git a/apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.ts b/apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.ts similarity index 100% rename from apps/server/src/shared/infra/identity-management/keycloak/service/keycloak-identity-management.service.ts rename to apps/server/src/infra/identity-management/keycloak/service/keycloak-identity-management.service.ts diff --git a/apps/server/src/shared/infra/index.ts b/apps/server/src/infra/index.ts similarity index 100% rename from apps/server/src/shared/infra/index.ts rename to apps/server/src/infra/index.ts diff --git a/apps/server/src/shared/infra/mail/index.ts b/apps/server/src/infra/mail/index.ts similarity index 100% rename from apps/server/src/shared/infra/mail/index.ts rename to apps/server/src/infra/mail/index.ts diff --git a/apps/server/src/shared/infra/mail/mail.interface.ts b/apps/server/src/infra/mail/mail.interface.ts similarity index 100% rename from apps/server/src/shared/infra/mail/mail.interface.ts rename to apps/server/src/infra/mail/mail.interface.ts diff --git a/apps/server/src/shared/infra/mail/mail.module.spec.ts b/apps/server/src/infra/mail/mail.module.spec.ts similarity index 90% rename from apps/server/src/shared/infra/mail/mail.module.spec.ts rename to apps/server/src/infra/mail/mail.module.spec.ts index 09cd1b6a9cc..3514b0e1043 100644 --- a/apps/server/src/shared/infra/mail/mail.module.spec.ts +++ b/apps/server/src/infra/mail/mail.module.spec.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { Test, TestingModule } from '@nestjs/testing'; -import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq/rabbitmq.module'; +import { RabbitMQWrapperTestModule } from '@infra/rabbitmq'; import { MailModule } from './mail.module'; import { MailService } from './mail.service'; diff --git a/apps/server/src/shared/infra/mail/mail.module.ts b/apps/server/src/infra/mail/mail.module.ts similarity index 100% rename from apps/server/src/shared/infra/mail/mail.module.ts rename to apps/server/src/infra/mail/mail.module.ts diff --git a/apps/server/src/shared/infra/mail/mail.service.spec.ts b/apps/server/src/infra/mail/mail.service.spec.ts similarity index 100% rename from apps/server/src/shared/infra/mail/mail.service.spec.ts rename to apps/server/src/infra/mail/mail.service.spec.ts diff --git a/apps/server/src/shared/infra/mail/mail.service.ts b/apps/server/src/infra/mail/mail.service.ts similarity index 100% rename from apps/server/src/shared/infra/mail/mail.service.ts rename to apps/server/src/infra/mail/mail.service.ts diff --git a/apps/server/src/shared/infra/metrics/index.ts b/apps/server/src/infra/metrics/index.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/index.ts rename to apps/server/src/infra/metrics/index.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/app.spec.ts b/apps/server/src/infra/metrics/prometheus/app.spec.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/app.spec.ts rename to apps/server/src/infra/metrics/prometheus/app.spec.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/app.ts b/apps/server/src/infra/metrics/prometheus/app.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/app.ts rename to apps/server/src/infra/metrics/prometheus/app.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/config.spec.ts b/apps/server/src/infra/metrics/prometheus/config.spec.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/config.spec.ts rename to apps/server/src/infra/metrics/prometheus/config.spec.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/config.ts b/apps/server/src/infra/metrics/prometheus/config.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/config.ts rename to apps/server/src/infra/metrics/prometheus/config.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/handler.spec.ts b/apps/server/src/infra/metrics/prometheus/handler.spec.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/handler.spec.ts rename to apps/server/src/infra/metrics/prometheus/handler.spec.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/handler.ts b/apps/server/src/infra/metrics/prometheus/handler.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/handler.ts rename to apps/server/src/infra/metrics/prometheus/handler.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/index.ts b/apps/server/src/infra/metrics/prometheus/index.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/index.ts rename to apps/server/src/infra/metrics/prometheus/index.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/middleware.spec.ts b/apps/server/src/infra/metrics/prometheus/middleware.spec.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/middleware.spec.ts rename to apps/server/src/infra/metrics/prometheus/middleware.spec.ts diff --git a/apps/server/src/shared/infra/metrics/prometheus/middleware.ts b/apps/server/src/infra/metrics/prometheus/middleware.ts similarity index 100% rename from apps/server/src/shared/infra/metrics/prometheus/middleware.ts rename to apps/server/src/infra/metrics/prometheus/middleware.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/index.ts b/apps/server/src/infra/oauth-provider/dto/index.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/index.ts rename to apps/server/src/infra/oauth-provider/dto/index.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/interface/oauth-client.interface.ts b/apps/server/src/infra/oauth-provider/dto/interface/oauth-client.interface.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/interface/oauth-client.interface.ts rename to apps/server/src/infra/oauth-provider/dto/interface/oauth-client.interface.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/interface/oidc-context.interface.ts b/apps/server/src/infra/oauth-provider/dto/interface/oidc-context.interface.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/interface/oidc-context.interface.ts rename to apps/server/src/infra/oauth-provider/dto/interface/oidc-context.interface.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/request/accept-consent-request.body.ts b/apps/server/src/infra/oauth-provider/dto/request/accept-consent-request.body.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/request/accept-consent-request.body.ts rename to apps/server/src/infra/oauth-provider/dto/request/accept-consent-request.body.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/request/accept-login-request.body.ts b/apps/server/src/infra/oauth-provider/dto/request/accept-login-request.body.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/request/accept-login-request.body.ts rename to apps/server/src/infra/oauth-provider/dto/request/accept-login-request.body.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/request/reject-request.body.ts b/apps/server/src/infra/oauth-provider/dto/request/reject-request.body.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/request/reject-request.body.ts rename to apps/server/src/infra/oauth-provider/dto/request/reject-request.body.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/response/consent-session.response.ts b/apps/server/src/infra/oauth-provider/dto/response/consent-session.response.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/response/consent-session.response.ts rename to apps/server/src/infra/oauth-provider/dto/response/consent-session.response.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/response/consent.response.ts b/apps/server/src/infra/oauth-provider/dto/response/consent.response.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/response/consent.response.ts rename to apps/server/src/infra/oauth-provider/dto/response/consent.response.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/response/introspect.response.ts b/apps/server/src/infra/oauth-provider/dto/response/introspect.response.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/response/introspect.response.ts rename to apps/server/src/infra/oauth-provider/dto/response/introspect.response.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/response/login.response.ts b/apps/server/src/infra/oauth-provider/dto/response/login.response.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/response/login.response.ts rename to apps/server/src/infra/oauth-provider/dto/response/login.response.ts diff --git a/apps/server/src/shared/infra/oauth-provider/dto/response/redirect.response.ts b/apps/server/src/infra/oauth-provider/dto/response/redirect.response.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/dto/response/redirect.response.ts rename to apps/server/src/infra/oauth-provider/dto/response/redirect.response.ts diff --git a/apps/server/src/shared/infra/oauth-provider/hydra/hydra.adapter.spec.ts b/apps/server/src/infra/oauth-provider/hydra/hydra.adapter.spec.ts similarity index 98% rename from apps/server/src/shared/infra/oauth-provider/hydra/hydra.adapter.spec.ts rename to apps/server/src/infra/oauth-provider/hydra/hydra.adapter.spec.ts index 0e244b37d16..7e30c5668c7 100644 --- a/apps/server/src/shared/infra/oauth-provider/hydra/hydra.adapter.spec.ts +++ b/apps/server/src/infra/oauth-provider/hydra/hydra.adapter.spec.ts @@ -11,12 +11,12 @@ import { ProviderOauthClient, ProviderRedirectResponse, RejectRequestBody, -} from '@shared/infra/oauth-provider/dto'; -import { ProviderConsentSessionResponse } from '@shared/infra/oauth-provider/dto/response/consent-session.response'; -import { HydraAdapter } from '@shared/infra/oauth-provider/hydra/hydra.adapter'; +} from '@infra/oauth-provider/dto'; import { axiosResponseFactory } from '@shared/testing'; import { AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios'; import { of } from 'rxjs'; +import { HydraAdapter } from './hydra.adapter'; +import { ProviderConsentSessionResponse } from '../dto/response/consent-session.response'; import resetAllMocks = jest.resetAllMocks; class HydraAdapterSpec extends HydraAdapter { diff --git a/apps/server/src/shared/infra/oauth-provider/hydra/hydra.adapter.ts b/apps/server/src/infra/oauth-provider/hydra/hydra.adapter.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/hydra/hydra.adapter.ts rename to apps/server/src/infra/oauth-provider/hydra/hydra.adapter.ts diff --git a/apps/server/src/shared/infra/oauth-provider/index.ts b/apps/server/src/infra/oauth-provider/index.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/index.ts rename to apps/server/src/infra/oauth-provider/index.ts diff --git a/apps/server/src/shared/infra/oauth-provider/oauth-provider-service.module.ts b/apps/server/src/infra/oauth-provider/oauth-provider-service.module.ts similarity index 61% rename from apps/server/src/shared/infra/oauth-provider/oauth-provider-service.module.ts rename to apps/server/src/infra/oauth-provider/oauth-provider-service.module.ts index 646ad228245..521f9216050 100644 --- a/apps/server/src/shared/infra/oauth-provider/oauth-provider-service.module.ts +++ b/apps/server/src/infra/oauth-provider/oauth-provider-service.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; -import { OauthProviderService } from '@shared/infra/oauth-provider/oauth-provider.service'; -import { HydraAdapter } from '@shared/infra/oauth-provider/hydra/hydra.adapter'; import { HttpModule } from '@nestjs/axios'; +import { OauthProviderService } from './oauth-provider.service'; +import { HydraAdapter } from './hydra/hydra.adapter'; @Module({ imports: [HttpModule], diff --git a/apps/server/src/shared/infra/oauth-provider/oauth-provider.service.ts b/apps/server/src/infra/oauth-provider/oauth-provider.service.ts similarity index 100% rename from apps/server/src/shared/infra/oauth-provider/oauth-provider.service.ts rename to apps/server/src/infra/oauth-provider/oauth-provider.service.ts diff --git a/apps/server/src/shared/infra/preview-generator/index.ts b/apps/server/src/infra/preview-generator/index.ts similarity index 97% rename from apps/server/src/shared/infra/preview-generator/index.ts rename to apps/server/src/infra/preview-generator/index.ts index 570b38cc9bd..c5d413789be 100644 --- a/apps/server/src/shared/infra/preview-generator/index.ts +++ b/apps/server/src/infra/preview-generator/index.ts @@ -1,4 +1,4 @@ -export * from './interface'; -export * from './preview-generator-consumer.module'; -export * from './preview-generator-producer.module'; -export * from './preview.producer'; +export * from './interface'; +export * from './preview-generator-consumer.module'; +export * from './preview-generator-producer.module'; +export * from './preview.producer'; diff --git a/apps/server/src/shared/infra/preview-generator/interface/index.ts b/apps/server/src/infra/preview-generator/interface/index.ts similarity index 96% rename from apps/server/src/shared/infra/preview-generator/interface/index.ts rename to apps/server/src/infra/preview-generator/interface/index.ts index 37aae418ee2..45799160cd5 100644 --- a/apps/server/src/shared/infra/preview-generator/interface/index.ts +++ b/apps/server/src/infra/preview-generator/interface/index.ts @@ -1 +1 @@ -export * from './preview'; +export * from './preview'; diff --git a/apps/server/src/shared/infra/preview-generator/interface/preview-consumer-config.ts b/apps/server/src/infra/preview-generator/interface/preview-consumer-config.ts similarity index 79% rename from apps/server/src/shared/infra/preview-generator/interface/preview-consumer-config.ts rename to apps/server/src/infra/preview-generator/interface/preview-consumer-config.ts index 2924fc945bc..3e08b89075c 100644 --- a/apps/server/src/shared/infra/preview-generator/interface/preview-consumer-config.ts +++ b/apps/server/src/infra/preview-generator/interface/preview-consumer-config.ts @@ -1,4 +1,4 @@ -import { S3Config } from '@shared/infra/s3-client'; +import { S3Config } from '@infra/s3-client'; export interface PreviewModuleConfig { NEST_LOG_LEVEL: string; diff --git a/apps/server/src/shared/infra/preview-generator/interface/preview.ts b/apps/server/src/infra/preview-generator/interface/preview.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/interface/preview.ts rename to apps/server/src/infra/preview-generator/interface/preview.ts diff --git a/apps/server/src/shared/infra/preview-generator/loggable/preview-actions.loggable.spec.ts b/apps/server/src/infra/preview-generator/loggable/preview-actions.loggable.spec.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/loggable/preview-actions.loggable.spec.ts rename to apps/server/src/infra/preview-generator/loggable/preview-actions.loggable.spec.ts diff --git a/apps/server/src/shared/infra/preview-generator/loggable/preview-actions.loggable.ts b/apps/server/src/infra/preview-generator/loggable/preview-actions.loggable.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/loggable/preview-actions.loggable.ts rename to apps/server/src/infra/preview-generator/loggable/preview-actions.loggable.ts diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator-consumer.module.ts b/apps/server/src/infra/preview-generator/preview-generator-consumer.module.ts similarity index 89% rename from apps/server/src/shared/infra/preview-generator/preview-generator-consumer.module.ts rename to apps/server/src/infra/preview-generator/preview-generator-consumer.module.ts index 9d352b81d9d..ca4df0d074c 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator-consumer.module.ts +++ b/apps/server/src/infra/preview-generator/preview-generator-consumer.module.ts @@ -1,7 +1,7 @@ import { DynamicModule, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq'; -import { S3ClientAdapter, S3ClientModule } from '@shared/infra/s3-client'; +import { RabbitMQWrapperModule } from '@infra/rabbitmq'; +import { S3ClientAdapter, S3ClientModule } from '@infra/s3-client'; import { createConfigModuleOptions } from '@src/config'; import { Logger, LoggerModule } from '@src/core/logger'; import { PreviewConfig } from './interface/preview-consumer-config'; diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator-producer.module.ts b/apps/server/src/infra/preview-generator/preview-generator-producer.module.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/preview-generator-producer.module.ts rename to apps/server/src/infra/preview-generator/preview-generator-producer.module.ts diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.builder.spec.ts b/apps/server/src/infra/preview-generator/preview-generator.builder.spec.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/preview-generator.builder.spec.ts rename to apps/server/src/infra/preview-generator/preview-generator.builder.spec.ts diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.builder.ts b/apps/server/src/infra/preview-generator/preview-generator.builder.ts similarity index 87% rename from apps/server/src/shared/infra/preview-generator/preview-generator.builder.ts rename to apps/server/src/infra/preview-generator/preview-generator.builder.ts index 4c5561ed089..088f9e7ab08 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator.builder.ts +++ b/apps/server/src/infra/preview-generator/preview-generator.builder.ts @@ -1,4 +1,4 @@ -import { File } from '@shared/infra/s3-client'; +import { File } from '@infra/s3-client'; import { PassThrough } from 'stream'; import { PreviewOptions } from './interface'; diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.consumer.spec.ts b/apps/server/src/infra/preview-generator/preview-generator.consumer.spec.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/preview-generator.consumer.spec.ts rename to apps/server/src/infra/preview-generator/preview-generator.consumer.spec.ts diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.consumer.ts b/apps/server/src/infra/preview-generator/preview-generator.consumer.ts similarity index 92% rename from apps/server/src/shared/infra/preview-generator/preview-generator.consumer.ts rename to apps/server/src/infra/preview-generator/preview-generator.consumer.ts index 8fc08d261f3..d34fc8bc37c 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator.consumer.ts +++ b/apps/server/src/infra/preview-generator/preview-generator.consumer.ts @@ -1,7 +1,7 @@ import { RabbitPayload, RabbitRPC } from '@golevelup/nestjs-rabbitmq'; import { Injectable } from '@nestjs/common'; import { Logger } from '@src/core/logger'; -import { FilesPreviewEvents, FilesPreviewExchange } from '@src/shared/infra/rabbitmq'; +import { FilesPreviewEvents, FilesPreviewExchange } from '@infra/rabbitmq'; import { PreviewFileOptions } from './interface'; import { PreviewActionsLoggable } from './loggable/preview-actions.loggable'; import { PreviewGeneratorService } from './preview-generator.service'; diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.service.spec.ts b/apps/server/src/infra/preview-generator/preview-generator.service.spec.ts similarity index 98% rename from apps/server/src/shared/infra/preview-generator/preview-generator.service.spec.ts rename to apps/server/src/infra/preview-generator/preview-generator.service.spec.ts index b8eeea612f5..016c261b122 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator.service.spec.ts +++ b/apps/server/src/infra/preview-generator/preview-generator.service.spec.ts @@ -1,6 +1,6 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { GetFile, S3ClientAdapter } from '@shared/infra/s3-client'; +import { GetFile, S3ClientAdapter } from '@infra/s3-client'; import { Logger } from '@src/core/logger'; import { Readable } from 'node:stream'; import { PreviewGeneratorService } from './preview-generator.service'; diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts b/apps/server/src/infra/preview-generator/preview-generator.service.ts similarity index 96% rename from apps/server/src/shared/infra/preview-generator/preview-generator.service.ts rename to apps/server/src/infra/preview-generator/preview-generator.service.ts index 72dac25f076..83dca461a2f 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts +++ b/apps/server/src/infra/preview-generator/preview-generator.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { GetFile, S3ClientAdapter } from '@shared/infra/s3-client'; +import { GetFile, S3ClientAdapter } from '@infra/s3-client'; import { Logger } from '@src/core/logger'; import { subClass } from 'gm'; import { PassThrough } from 'stream'; diff --git a/apps/server/src/shared/infra/preview-generator/preview.producer.spec.ts b/apps/server/src/infra/preview-generator/preview.producer.spec.ts similarity index 100% rename from apps/server/src/shared/infra/preview-generator/preview.producer.spec.ts rename to apps/server/src/infra/preview-generator/preview.producer.spec.ts diff --git a/apps/server/src/shared/infra/preview-generator/preview.producer.ts b/apps/server/src/infra/preview-generator/preview.producer.ts similarity index 97% rename from apps/server/src/shared/infra/preview-generator/preview.producer.ts rename to apps/server/src/infra/preview-generator/preview.producer.ts index 602e2503185..28cf6930830 100644 --- a/apps/server/src/shared/infra/preview-generator/preview.producer.ts +++ b/apps/server/src/infra/preview-generator/preview.producer.ts @@ -1,7 +1,7 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { FilesPreviewEvents, FilesPreviewExchange, RpcMessageProducer } from '@shared/infra/rabbitmq'; +import { FilesPreviewEvents, FilesPreviewExchange, RpcMessageProducer } from '@infra/rabbitmq'; import { Logger } from '@src/core/logger'; import { PreviewFileOptions, PreviewResponseMessage } from './interface'; import { PreviewModuleConfig } from './interface/preview-consumer-config'; diff --git a/apps/server/src/shared/infra/rabbitmq/error.mapper.spec.ts b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts similarity index 97% rename from apps/server/src/shared/infra/rabbitmq/error.mapper.spec.ts rename to apps/server/src/infra/rabbitmq/error.mapper.spec.ts index c3cf506e541..884dfb35158 100644 --- a/apps/server/src/shared/infra/rabbitmq/error.mapper.spec.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts @@ -4,7 +4,7 @@ import { ForbiddenException, InternalServerErrorException, } from '@nestjs/common'; -import { IError } from '@shared/infra/rabbitmq'; +import { IError } from '@infra/rabbitmq'; import _ from 'lodash'; import { ErrorMapper } from './error.mapper'; diff --git a/apps/server/src/shared/infra/rabbitmq/error.mapper.ts b/apps/server/src/infra/rabbitmq/error.mapper.ts similarity index 94% rename from apps/server/src/shared/infra/rabbitmq/error.mapper.ts rename to apps/server/src/infra/rabbitmq/error.mapper.ts index 60f2e73795e..6f7083d3ad9 100644 --- a/apps/server/src/shared/infra/rabbitmq/error.mapper.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.ts @@ -1,6 +1,6 @@ import { BadRequestException, ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { ErrorUtils } from '@src/core/error/utils'; -import { IError } from '@shared/infra/rabbitmq'; +import { IError } from '@infra/rabbitmq'; export class ErrorMapper { static mapRpcErrorResponseToDomainError( diff --git a/apps/server/src/shared/infra/rabbitmq/exchange/files-preview.ts b/apps/server/src/infra/rabbitmq/exchange/files-preview.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/exchange/files-preview.ts rename to apps/server/src/infra/rabbitmq/exchange/files-preview.ts diff --git a/apps/server/src/shared/infra/rabbitmq/exchange/files-storage.ts b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/exchange/files-storage.ts rename to apps/server/src/infra/rabbitmq/exchange/files-storage.ts diff --git a/apps/server/src/shared/infra/rabbitmq/exchange/index.ts b/apps/server/src/infra/rabbitmq/exchange/index.ts similarity index 97% rename from apps/server/src/shared/infra/rabbitmq/exchange/index.ts rename to apps/server/src/infra/rabbitmq/exchange/index.ts index 0cf6bd00d13..48658a3f0a7 100644 --- a/apps/server/src/shared/infra/rabbitmq/exchange/index.ts +++ b/apps/server/src/infra/rabbitmq/exchange/index.ts @@ -1,2 +1,2 @@ -export * from './files-preview'; -export * from './files-storage'; +export * from './files-preview'; +export * from './files-storage'; diff --git a/apps/server/src/shared/infra/rabbitmq/index.ts b/apps/server/src/infra/rabbitmq/index.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/index.ts rename to apps/server/src/infra/rabbitmq/index.ts diff --git a/apps/server/src/shared/infra/rabbitmq/rabbitmq.module.ts b/apps/server/src/infra/rabbitmq/rabbitmq.module.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/rabbitmq.module.ts rename to apps/server/src/infra/rabbitmq/rabbitmq.module.ts diff --git a/apps/server/src/shared/infra/rabbitmq/rpc-message-producer.spec.ts b/apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/rpc-message-producer.spec.ts rename to apps/server/src/infra/rabbitmq/rpc-message-producer.spec.ts diff --git a/apps/server/src/shared/infra/rabbitmq/rpc-message-producer.ts b/apps/server/src/infra/rabbitmq/rpc-message-producer.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/rpc-message-producer.ts rename to apps/server/src/infra/rabbitmq/rpc-message-producer.ts diff --git a/apps/server/src/shared/infra/rabbitmq/rpc-message.ts b/apps/server/src/infra/rabbitmq/rpc-message.ts similarity index 100% rename from apps/server/src/shared/infra/rabbitmq/rpc-message.ts rename to apps/server/src/infra/rabbitmq/rpc-message.ts diff --git a/apps/server/src/shared/infra/redis/index.ts b/apps/server/src/infra/redis/index.ts similarity index 100% rename from apps/server/src/shared/infra/redis/index.ts rename to apps/server/src/infra/redis/index.ts diff --git a/apps/server/src/shared/infra/redis/interface/redis.constants.ts b/apps/server/src/infra/redis/interface/redis.constants.ts similarity index 100% rename from apps/server/src/shared/infra/redis/interface/redis.constants.ts rename to apps/server/src/infra/redis/interface/redis.constants.ts diff --git a/apps/server/src/shared/infra/redis/redis.module.ts b/apps/server/src/infra/redis/redis.module.ts similarity index 100% rename from apps/server/src/shared/infra/redis/redis.module.ts rename to apps/server/src/infra/redis/redis.module.ts diff --git a/apps/server/src/shared/infra/s3-client/README.md b/apps/server/src/infra/s3-client/README.md similarity index 100% rename from apps/server/src/shared/infra/s3-client/README.md rename to apps/server/src/infra/s3-client/README.md diff --git a/apps/server/src/shared/infra/s3-client/constants.ts b/apps/server/src/infra/s3-client/constants.ts similarity index 100% rename from apps/server/src/shared/infra/s3-client/constants.ts rename to apps/server/src/infra/s3-client/constants.ts diff --git a/apps/server/src/shared/infra/s3-client/index.ts b/apps/server/src/infra/s3-client/index.ts similarity index 97% rename from apps/server/src/shared/infra/s3-client/index.ts rename to apps/server/src/infra/s3-client/index.ts index a2bfb7428c3..89943618d9e 100644 --- a/apps/server/src/shared/infra/s3-client/index.ts +++ b/apps/server/src/infra/s3-client/index.ts @@ -1,3 +1,3 @@ -export * from './interface'; -export * from './s3-client.adapter'; -export * from './s3-client.module'; +export * from './interface'; +export * from './s3-client.adapter'; +export * from './s3-client.module'; diff --git a/apps/server/src/shared/infra/s3-client/interface/index.ts b/apps/server/src/infra/s3-client/interface/index.ts similarity index 100% rename from apps/server/src/shared/infra/s3-client/interface/index.ts rename to apps/server/src/infra/s3-client/interface/index.ts diff --git a/apps/server/src/shared/infra/s3-client/s3-client.adapter.spec.ts b/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts similarity index 99% rename from apps/server/src/shared/infra/s3-client/s3-client.adapter.spec.ts rename to apps/server/src/infra/s3-client/s3-client.adapter.spec.ts index 87de7afb1c3..7986e692ca9 100644 --- a/apps/server/src/shared/infra/s3-client/s3-client.adapter.spec.ts +++ b/apps/server/src/infra/s3-client/s3-client.adapter.spec.ts @@ -6,9 +6,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ErrorUtils } from '@src/core/error/utils'; import { LegacyLogger } from '@src/core/logger'; import { Readable } from 'node:stream'; -import { FileDto } from '../../../modules/files-storage/dto'; import { S3_CLIENT, S3_CONFIG } from './constants'; -import { S3Config } from './interface'; +import { File, S3Config } from './interface'; import { S3ClientAdapter } from './s3-client.adapter'; const createParameter = () => { @@ -190,11 +189,10 @@ describe('S3ClientAdapter', () => { describe('create', () => { const createFile = () => { const readable = Readable.from('ddd'); - const file = new FileDto({ + const file: File = { data: readable, - name: 'test.txt', mimeType: 'text/plain', - }); + }; return { file }; }; diff --git a/apps/server/src/shared/infra/s3-client/s3-client.adapter.ts b/apps/server/src/infra/s3-client/s3-client.adapter.ts similarity index 100% rename from apps/server/src/shared/infra/s3-client/s3-client.adapter.ts rename to apps/server/src/infra/s3-client/s3-client.adapter.ts diff --git a/apps/server/src/shared/infra/s3-client/s3-client.module.spec.ts b/apps/server/src/infra/s3-client/s3-client.module.spec.ts similarity index 100% rename from apps/server/src/shared/infra/s3-client/s3-client.module.spec.ts rename to apps/server/src/infra/s3-client/s3-client.module.spec.ts diff --git a/apps/server/src/shared/infra/s3-client/s3-client.module.ts b/apps/server/src/infra/s3-client/s3-client.module.ts similarity index 100% rename from apps/server/src/shared/infra/s3-client/s3-client.module.ts rename to apps/server/src/infra/s3-client/s3-client.module.ts diff --git a/apps/server/src/modules/account/account.module.spec.ts b/apps/server/src/modules/account/account.module.spec.ts index 74a8d25568b..8acbff04090 100644 --- a/apps/server/src/modules/account/account.module.spec.ts +++ b/apps/server/src/modules/account/account.module.spec.ts @@ -1,6 +1,6 @@ import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { AccountModule } from './account.module'; import { AccountIdmToDtoMapper, AccountIdmToDtoMapperDb, AccountIdmToDtoMapperIdm } from './mapper'; import { AccountService } from './services/account.service'; diff --git a/apps/server/src/modules/account/account.module.ts b/apps/server/src/modules/account/account.module.ts index 6c98d7f76e3..2e11af11c6d 100644 --- a/apps/server/src/modules/account/account.module.ts +++ b/apps/server/src/modules/account/account.module.ts @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PermissionService } from '@shared/domain'; import { SystemRepo, UserRepo } from '@shared/repo'; -import { IdentityManagementModule } from '@shared/infra/identity-management'; +import { IdentityManagementModule } from '@infra/identity-management'; import { LoggerModule } from '@src/core/logger/logger.module'; import { AccountRepo } from './repo/account.repo'; import { AccountService } from './services/account.service'; diff --git a/apps/server/src/modules/account/repo/account.repo.integration.spec.ts b/apps/server/src/modules/account/repo/account.repo.integration.spec.ts index bf4a44119fe..77acc53a3b1 100644 --- a/apps/server/src/modules/account/repo/account.repo.integration.spec.ts +++ b/apps/server/src/modules/account/repo/account.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Account, User } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { accountFactory, cleanupCollections, userFactory } from '@shared/testing'; import { AccountRepo } from './account.repo'; diff --git a/apps/server/src/modules/account/repo/account.repo.ts b/apps/server/src/modules/account/repo/account.repo.ts index fb68f0a759b..f8c1f5677ec 100644 --- a/apps/server/src/modules/account/repo/account.repo.ts +++ b/apps/server/src/modules/account/repo/account.repo.ts @@ -1,7 +1,7 @@ import { AnyEntity, EntityName, Primary } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; -import { EntityId } from '@shared/domain'; +import { EntityId, SortOrder } from '@shared/domain'; import { Account } from '@shared/domain/entity/account.entity'; import { BaseRepo } from '@shared/repo/base.repo'; @@ -71,7 +71,9 @@ export class AccountRepo extends BaseRepo { * @deprecated For migration purpose only */ async findMany(offset = 0, limit = 100): Promise { - return this._em.find(this.entityName, {}, { offset, limit }); + const result = await this._em.find(this.entityName, {}, { offset, limit, orderBy: { _id: SortOrder.asc } }); + this._em.clear(); + return result; } private async searchByUsername( diff --git a/apps/server/src/modules/account/services/account-db.service.spec.ts b/apps/server/src/modules/account/services/account-db.service.spec.ts index 64075bcb40c..107273797f9 100644 --- a/apps/server/src/modules/account/services/account-db.service.spec.ts +++ b/apps/server/src/modules/account/services/account-db.service.spec.ts @@ -4,7 +4,7 @@ import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { Account, EntityId, Permission, Role, RoleName, SchoolEntity, User } from '@shared/domain'; -import { IdentityManagementService } from '@shared/infra/identity-management/identity-management.service'; +import { IdentityManagementService } from '@infra/identity-management/identity-management.service'; import { accountFactory, schoolFactory, setupEntities, userFactory } from '@shared/testing'; import { AccountEntityToDtoMapper } from '@modules/account/mapper'; import { AccountDto } from '@modules/account/services/dto'; diff --git a/apps/server/src/modules/account/services/account-idm.service.integration.spec.ts b/apps/server/src/modules/account/services/account-idm.service.integration.spec.ts index 4761bbd80ca..06ad0943c22 100644 --- a/apps/server/src/modules/account/services/account-idm.service.integration.spec.ts +++ b/apps/server/src/modules/account/services/account-idm.service.integration.spec.ts @@ -4,11 +4,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { IdmAccount } from '@shared/domain'; -import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service'; +import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; import { AccountSaveDto } from '@modules/account/services/dto'; import { LoggerModule } from '@src/core/logger'; -import { IdentityManagementModule } from '@shared/infra/identity-management'; -import { IdentityManagementService } from '../../../shared/infra/identity-management/identity-management.service'; +import { IdentityManagementModule, IdentityManagementService } from '@infra/identity-management'; import { AccountIdmToDtoMapper, AccountIdmToDtoMapperDb } from '../mapper'; import { AccountServiceIdm } from './account-idm.service'; import { AbstractAccountService } from './account.service.abstract'; diff --git a/apps/server/src/modules/account/services/account-idm.service.spec.ts b/apps/server/src/modules/account/services/account-idm.service.spec.ts index 4b997d1b3fe..9b8705089b3 100644 --- a/apps/server/src/modules/account/services/account-idm.service.spec.ts +++ b/apps/server/src/modules/account/services/account-idm.service.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { IdmAccount } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { IdentityManagementOauthService, IdentityManagementService } from '@shared/infra/identity-management'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { IdentityManagementOauthService, IdentityManagementService } from '@infra/identity-management'; import { NotImplementedException } from '@nestjs/common'; import { LoggerModule } from '@src/core/logger'; import { ConfigModule } from '@nestjs/config'; diff --git a/apps/server/src/modules/account/services/account-idm.service.ts b/apps/server/src/modules/account/services/account-idm.service.ts index 68bcfb42bae..2136326e038 100644 --- a/apps/server/src/modules/account/services/account-idm.service.ts +++ b/apps/server/src/modules/account/services/account-idm.service.ts @@ -2,7 +2,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { Injectable, NotImplementedException } from '@nestjs/common'; import { EntityNotFoundError } from '@shared/common'; import { Counted, EntityId, IdmAccount, IdmAccountUpdate } from '@shared/domain'; -import { IdentityManagementService, IdentityManagementOauthService } from '@shared/infra/identity-management'; +import { IdentityManagementService, IdentityManagementOauthService } from '@infra/identity-management'; import { LegacyLogger } from '@src/core/logger'; import { AccountIdmToDtoMapper } from '../mapper'; import { AbstractAccountService } from './account.service.abstract'; diff --git a/apps/server/src/modules/account/services/account-lookup.service.spec.ts b/apps/server/src/modules/account/services/account-lookup.service.spec.ts index cfef246d3e3..c3351a6b0c3 100644 --- a/apps/server/src/modules/account/services/account-lookup.service.spec.ts +++ b/apps/server/src/modules/account/services/account-lookup.service.spec.ts @@ -4,7 +4,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { IdmAccount } from '@shared/domain'; -import { IdentityManagementService } from '@shared/infra/identity-management'; +import { IdentityManagementService } from '@infra/identity-management'; import { AccountLookupService } from './account-lookup.service'; describe('AccountLookupService', () => { diff --git a/apps/server/src/modules/account/services/account-lookup.service.ts b/apps/server/src/modules/account/services/account-lookup.service.ts index b1549590c5b..ed67d03232d 100644 --- a/apps/server/src/modules/account/services/account-lookup.service.ts +++ b/apps/server/src/modules/account/services/account-lookup.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { EntityId } from '@shared/domain'; -import { IdentityManagementService } from '@shared/infra/identity-management'; +import { IdentityManagementService } from '@infra/identity-management'; import { IServerConfig } from '@modules/server/server.config'; import { ObjectId } from 'bson'; diff --git a/apps/server/src/modules/account/services/account.service.integration.spec.ts b/apps/server/src/modules/account/services/account.service.integration.spec.ts index d001925000b..ccaf450ffed 100644 --- a/apps/server/src/modules/account/services/account.service.integration.spec.ts +++ b/apps/server/src/modules/account/services/account.service.integration.spec.ts @@ -4,10 +4,10 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { Account, IdmAccount } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { IdentityManagementModule } from '@shared/infra/identity-management'; -import { IdentityManagementService } from '@shared/infra/identity-management/identity-management.service'; -import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { IdentityManagementModule } from '@infra/identity-management'; +import { IdentityManagementService } from '@infra/identity-management/identity-management.service'; +import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; import { UserRepo } from '@shared/repo'; import { accountFactory, cleanupCollections } from '@shared/testing'; import { ObjectId } from 'bson'; diff --git a/apps/server/src/modules/authentication/authentication.module.ts b/apps/server/src/modules/authentication/authentication.module.ts index 26d20a4dfc8..8f2bdcd3b0d 100644 --- a/apps/server/src/modules/authentication/authentication.module.ts +++ b/apps/server/src/modules/authentication/authentication.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { JwtModule, JwtModuleOptions } from '@nestjs/jwt'; import { PassportModule } from '@nestjs/passport'; -import { CacheWrapperModule } from '@shared/infra/cache'; -import { IdentityManagementModule } from '@shared/infra/identity-management'; +import { CacheWrapperModule } from '@infra/cache'; +import { IdentityManagementModule } from '@infra/identity-management'; import { LegacySchoolRepo, SystemRepo, UserRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { AccountModule } from '@modules/account'; diff --git a/apps/server/src/modules/authentication/controllers/api-test/login.api.spec.ts b/apps/server/src/modules/authentication/controllers/api-test/login.api.spec.ts index 7da3c21eab9..04683e182a8 100644 --- a/apps/server/src/modules/authentication/controllers/api-test/login.api.spec.ts +++ b/apps/server/src/modules/authentication/controllers/api-test/login.api.spec.ts @@ -192,6 +192,7 @@ describe('Login Controller (api)', () => { expect(decodedToken).toHaveProperty('accountId'); expect(decodedToken).toHaveProperty('schoolId'); expect(decodedToken).toHaveProperty('roles'); + expect(decodedToken).toHaveProperty('isExternalUser'); expect(decodedToken).not.toHaveProperty('externalIdToken'); }); }); @@ -287,7 +288,7 @@ describe('Login Controller (api)', () => { roles: [studentRole.id], schoolId: school.id, accountId: account.id, - isExternalUser: false, + isExternalUser: true, }); expect(decodedToken).not.toHaveProperty('externalIdToken'); }); diff --git a/apps/server/src/modules/authentication/index.ts b/apps/server/src/modules/authentication/index.ts index 904c64ff97b..59e749c7abc 100644 --- a/apps/server/src/modules/authentication/index.ts +++ b/apps/server/src/modules/authentication/index.ts @@ -1,2 +1,3 @@ export { ICurrentUser } from './interface'; export { JWT, CurrentUser, Authenticate } from './decorator'; +export { AuthenticationModule } from './authentication.module'; diff --git a/apps/server/src/modules/authentication/interface/index.ts b/apps/server/src/modules/authentication/interface/index.ts index e5abc856509..a9de8109a5b 100644 --- a/apps/server/src/modules/authentication/interface/index.ts +++ b/apps/server/src/modules/authentication/interface/index.ts @@ -1 +1,2 @@ export * from './user'; +export * from './oauth-current-user'; diff --git a/apps/server/src/modules/authentication/interface/oauth-current-user.ts b/apps/server/src/modules/authentication/interface/oauth-current-user.ts new file mode 100644 index 00000000000..ddf15e1ca5d --- /dev/null +++ b/apps/server/src/modules/authentication/interface/oauth-current-user.ts @@ -0,0 +1,6 @@ +import { ICurrentUser } from './user'; + +export interface OauthCurrentUser extends ICurrentUser { + /** Contains the idToken of the external idp. Will be set during oAuth2 login and used for rp initiated logout */ + externalIdToken?: string; +} diff --git a/apps/server/src/modules/authentication/interface/user.ts b/apps/server/src/modules/authentication/interface/user.ts index cc8423f69b7..82b6d292d50 100644 --- a/apps/server/src/modules/authentication/interface/user.ts +++ b/apps/server/src/modules/authentication/interface/user.ts @@ -16,11 +16,6 @@ export interface ICurrentUser { /** True if a support member impersonates the user */ impersonated?: boolean; - /** True if the user is an external user e.g. an oauth user */ + /** True if the user is an external user e.g. an oauth user or ldap user */ isExternalUser: boolean; } - -export interface OauthCurrentUser extends ICurrentUser { - /** Contains the idToken of the external idp. Will be set during oAuth2 login and used for rp initiated logout */ - externalIdToken?: string; -} diff --git a/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts b/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts index d06bea6d080..104ca1219a4 100644 --- a/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts +++ b/apps/server/src/modules/authentication/mapper/current-user.mapper.spec.ts @@ -15,42 +15,78 @@ describe('CurrentUserMapper', () => { describe('userToICurrentUser', () => { describe('when mapping from a user entity to the current user object', () => { - it('should map with roles', () => { - const teacherRole = roleFactory.buildWithId({ name: RoleName.TEACHER, permissions: [Permission.STUDENT_EDIT] }); - const user = userFactory.buildWithId({ - roles: [teacherRole], - }); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user); - expect(currentUser).toMatchObject({ - accountId, - systemId: undefined, - roles: [teacherRole.id], - schoolId: null, + describe('when user has roles', () => { + const setup = () => { + const teacherRole = roleFactory.buildWithId({ + name: RoleName.TEACHER, + permissions: [Permission.STUDENT_EDIT], + }); + const user = userFactory.buildWithId({ + roles: [teacherRole], + }); + + return { + teacherRole, + user, + }; + }; + + it('should map with roles', () => { + const { teacherRole, user } = setup(); + + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false); + + expect(currentUser).toMatchObject({ + accountId, + systemId: undefined, + roles: [teacherRole.id], + schoolId: null, + isExternalUser: false, + }); }); }); - it('should map without roles', () => { - const user = userFactory.buildWithId(); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user); - expect(currentUser).toMatchObject({ - accountId, - systemId: undefined, - roles: [], - schoolId: null, + describe('when user has no roles', () => { + it('should map without roles', () => { + const user = userFactory.buildWithId(); + + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, true); + + expect(currentUser).toMatchObject({ + accountId, + systemId: undefined, + roles: [], + schoolId: null, + isExternalUser: true, + }); }); }); - it('should map system and school', () => { - const user = userFactory.buildWithId({ - school: schoolFactory.buildWithId(), - }); - const systemId = 'mockSystemId'; - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, systemId); - expect(currentUser).toMatchObject({ - accountId, - systemId, - roles: [], - schoolId: user.school.id, + describe('when systemId is provided', () => { + const setup = () => { + const user = userFactory.buildWithId({ + school: schoolFactory.buildWithId(), + }); + const systemId = 'mockSystemId'; + + return { + user, + systemId, + }; + }; + + it('should map system and school', () => { + const { user, systemId } = setup(); + + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false, systemId); + + expect(currentUser).toMatchObject({ + accountId, + systemId, + roles: [], + schoolId: user.school.id, + isExternalUser: false, + }); }); }); }); diff --git a/apps/server/src/modules/authentication/mapper/current-user.mapper.ts b/apps/server/src/modules/authentication/mapper/current-user.mapper.ts index ab832b70d8c..35dd6c5fe7c 100644 --- a/apps/server/src/modules/authentication/mapper/current-user.mapper.ts +++ b/apps/server/src/modules/authentication/mapper/current-user.mapper.ts @@ -6,14 +6,14 @@ import { ICurrentUser, OauthCurrentUser } from '../interface'; import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload'; export class CurrentUserMapper { - static userToICurrentUser(accountId: string, user: User, systemId?: string): ICurrentUser { + static userToICurrentUser(accountId: string, user: User, isExternalUser: boolean, systemId?: string): ICurrentUser { return { accountId, systemId, roles: user.roles.getItems().map((role: Role) => role.id), schoolId: user.school.id, userId: user.id, - isExternalUser: false, + isExternalUser, }; } diff --git a/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts b/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts index 936deb866e4..6638e0470b2 100644 --- a/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts +++ b/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Test, TestingModule } from '@nestjs/testing'; -import { CacheService } from '@shared/infra/cache'; -import { CacheStoreType } from '@shared/infra/cache/interface/cache-store-type.enum'; +import { CacheService } from '@infra/cache'; +import { CacheStoreType } from '@infra/cache/interface/cache-store-type.enum'; import { feathersRedis } from '@src/imports-from-feathers'; import { Cache } from 'cache-manager'; import { JwtValidationAdapter } from './jwt-validation.adapter'; diff --git a/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts b/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts index 3af5db2061b..dee98747c46 100644 --- a/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts +++ b/apps/server/src/modules/authentication/strategy/jwt-validation.adapter.ts @@ -1,7 +1,7 @@ import { CACHE_MANAGER } from '@nestjs/cache-manager'; import { Inject, Injectable } from '@nestjs/common'; -import { CacheService } from '@shared/infra/cache'; -import { CacheStoreType } from '@shared/infra/cache/interface/cache-store-type.enum'; +import { CacheService } from '@infra/cache'; +import { CacheStoreType } from '@infra/cache/interface/cache-store-type.enum'; import { addTokenToWhitelist, createRedisIdentifierFromJwtData, diff --git a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts index 78f445ce5b0..5b23be9eb74 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts @@ -436,7 +436,7 @@ describe('LdapStrategy', () => { schoolId: school.id, systemId: system.id, accountId: account.id, - isExternalUser: false, + isExternalUser: true, }); }); }); @@ -501,7 +501,7 @@ describe('LdapStrategy', () => { schoolId: school.id, systemId: system.id, accountId: account.id, - isExternalUser: false, + isExternalUser: true, }); }); }); diff --git a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts index 1622e434310..6f33e92f21a 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts @@ -1,10 +1,10 @@ +import { AccountDto } from '@modules/account/services/dto'; import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { LegacySchoolDo, SystemEntity, User } from '@shared/domain'; import { LegacySchoolRepo, SystemRepo, UserRepo } from '@shared/repo'; import { ErrorLoggable } from '@src/core/error/loggable/error.loggable'; import { Logger } from '@src/core/logger'; -import { AccountDto } from '@modules/account/services/dto'; import { Strategy } from 'passport-custom'; import { LdapAuthorizationBodyParams } from '../controllers/dto'; import { ICurrentUser } from '../interface'; @@ -48,7 +48,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { await this.checkCredentials(account, system, ldapDn, password); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(account.id, user, systemId); + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(account.id, user, true, systemId); return currentUser; } diff --git a/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts index d1330270fb7..121d2874fe9 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { RoleName, User } from '@shared/domain'; -import { IdentityManagementOauthService } from '@shared/infra/identity-management'; +import { IdentityManagementOauthService } from '@infra/identity-management'; import { UserRepo } from '@shared/repo'; import { accountFactory, setupEntities, userFactory } from '@shared/testing'; import { AccountEntityToDtoMapper } from '@modules/account/mapper'; diff --git a/apps/server/src/modules/authentication/strategy/local.strategy.ts b/apps/server/src/modules/authentication/strategy/local.strategy.ts index 7963a5166e7..1d31a86d833 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.ts @@ -6,7 +6,7 @@ import bcrypt from 'bcryptjs'; import { UserRepo } from '@shared/repo'; import { AccountDto } from '@modules/account/services/dto'; import { GuardAgainst } from '@shared/common/utils/guard-against'; -import { IdentityManagementOauthService, IIdentityManagementConfig } from '@shared/infra/identity-management'; +import { IdentityManagementOauthService, IIdentityManagementConfig } from '@infra/identity-management'; import { CurrentUserMapper } from '../mapper'; import { ICurrentUser } from '../interface'; import { AuthenticationService } from '../services/authentication.service'; @@ -39,7 +39,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) { new Error(`login failing, because account ${account.id} has no userId`) ); const user = await this.userRepo.findById(accountUserId, true); - const currentUser = CurrentUserMapper.userToICurrentUser(account.id, user); + const currentUser = CurrentUserMapper.userToICurrentUser(account.id, user, false); return currentUser; } diff --git a/apps/server/src/modules/authorization/authorization.module.ts b/apps/server/src/modules/authorization/authorization.module.ts index c555f13dc7b..d01cd9363f4 100644 --- a/apps/server/src/modules/authorization/authorization.module.ts +++ b/apps/server/src/modules/authorization/authorization.module.ts @@ -1,7 +1,7 @@ import { Module } from '@nestjs/common'; import { UserRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; -import { FeathersModule } from '@shared/infra/feathers'; +import { FeathersModule } from '@infra/feathers'; import { BoardDoRule, ContextExternalToolRule, diff --git a/apps/server/src/modules/authorization/feathers/feathers-auth.provider.spec.ts b/apps/server/src/modules/authorization/feathers/feathers-auth.provider.spec.ts index ccf1f2177aa..f035fa5a867 100644 --- a/apps/server/src/modules/authorization/feathers/feathers-auth.provider.spec.ts +++ b/apps/server/src/modules/authorization/feathers/feathers-auth.provider.spec.ts @@ -2,7 +2,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; import { Test, TestingModule } from '@nestjs/testing'; import { NewsTargetModel } from '@shared/domain'; -import { FeathersServiceProvider } from '@shared/infra/feathers'; +import { FeathersServiceProvider } from '@infra/feathers'; import { FeathersAuthProvider } from './feathers-auth.provider'; describe('FeathersAuthProvider', () => { diff --git a/apps/server/src/modules/authorization/feathers/feathers-auth.provider.ts b/apps/server/src/modules/authorization/feathers/feathers-auth.provider.ts index 1f3f40886eb..4e4f87c56d1 100644 --- a/apps/server/src/modules/authorization/feathers/feathers-auth.provider.ts +++ b/apps/server/src/modules/authorization/feathers/feathers-auth.provider.ts @@ -1,7 +1,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; import { BaseEntity, EntityId, NewsTargetModel } from '@shared/domain'; import { ObjectId } from '@mikro-orm/mongodb'; -import { FeathersServiceProvider } from '@shared/infra/feathers'; +import { FeathersServiceProvider } from '@infra/feathers'; interface User { _id: ObjectId; diff --git a/apps/server/src/modules/board/board.module.ts b/apps/server/src/modules/board/board.module.ts index 7722326a21d..ffa1e7ad580 100644 --- a/apps/server/src/modules/board/board.module.ts +++ b/apps/server/src/modules/board/board.module.ts @@ -3,7 +3,7 @@ import { ContextExternalToolModule } from '@modules/tool/context-external-tool'; import { UserModule } from '@modules/user'; import { Module } from '@nestjs/common'; import { ContentElementFactory } from '@shared/domain'; -import { ConsoleWriterModule } from '@shared/infra/console'; +import { ConsoleWriterModule } from '@infra/console'; import { CourseRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { BoardDoRepo, BoardNodeRepo, RecursiveDeleteVisitor } from './repo'; diff --git a/apps/server/src/modules/board/repo/board-do.repo.spec.ts b/apps/server/src/modules/board/repo/board-do.repo.spec.ts index 3874e9301ba..2f9a6633e69 100644 --- a/apps/server/src/modules/board/repo/board-do.repo.spec.ts +++ b/apps/server/src/modules/board/repo/board-do.repo.spec.ts @@ -14,7 +14,7 @@ import { ColumnBoard, RichTextElementNode, } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cardFactory, cardNodeFactory, diff --git a/apps/server/src/modules/board/repo/board-node.repo.spec.ts b/apps/server/src/modules/board/repo/board-node.repo.spec.ts index 656d751f01d..2ebed80d0af 100644 --- a/apps/server/src/modules/board/repo/board-node.repo.spec.ts +++ b/apps/server/src/modules/board/repo/board-node.repo.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { ColumnBoardNode } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cardNodeFactory, cleanupCollections, diff --git a/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts b/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts index 6236d5de8bb..4b0688f0a0d 100644 --- a/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts +++ b/apps/server/src/modules/board/repo/recursive-delete.visitor.spec.ts @@ -3,7 +3,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { FileDto, FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ContextExternalToolService } from '@modules/tool/context-external-tool/service'; import { Test, TestingModule } from '@nestjs/testing'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { columnBoardFactory, columnFactory, diff --git a/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts index d7c71352166..40a62ede2ed 100644 --- a/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts +++ b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts @@ -18,7 +18,7 @@ import { RichTextElement, SubmissionContainerElement, } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { cardFactory, columnBoardFactory, diff --git a/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts index ba76693bb93..137f189319c 100644 --- a/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts +++ b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts @@ -12,7 +12,7 @@ import { SubmissionItem, } from '@shared/domain'; import { LinkElement } from '@shared/domain/domainobject/board/link-element.do'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { ObjectId } from 'bson'; import { SchoolSpecificFileCopyService } from './school-specific-file-copy.interface'; diff --git a/apps/server/src/modules/board/uc/board-management.uc.spec.ts b/apps/server/src/modules/board/uc/board-management.uc.spec.ts index 7c3464a8a52..83948e0ae1e 100644 --- a/apps/server/src/modules/board/uc/board-management.uc.spec.ts +++ b/apps/server/src/modules/board/uc/board-management.uc.spec.ts @@ -1,8 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { ConsoleWriterService } from '@infra/console'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { courseFactory } from '@shared/testing'; import { BoardManagementUc } from '@modules/management/uc/board-management.uc'; diff --git a/apps/server/src/modules/class/repo/classes.repo.spec.ts b/apps/server/src/modules/class/repo/classes.repo.spec.ts index 7801045aff0..df0191d24ef 100644 --- a/apps/server/src/modules/class/repo/classes.repo.spec.ts +++ b/apps/server/src/modules/class/repo/classes.repo.spec.ts @@ -4,7 +4,7 @@ import { Test } from '@nestjs/testing'; import { TestingModule } from '@nestjs/testing/testing-module'; import { NotFoundLoggableException } from '@shared/common/loggable-exception'; import { SchoolEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, schoolFactory } from '@shared/testing'; import { Class } from '../domain'; import { ClassEntity } from '../entity'; diff --git a/apps/server/src/modules/collaborative-storage/collaborative-storage.module.ts b/apps/server/src/modules/collaborative-storage/collaborative-storage.module.ts index eedf1b5638e..a654ff86bdc 100644 --- a/apps/server/src/modules/collaborative-storage/collaborative-storage.module.ts +++ b/apps/server/src/modules/collaborative-storage/collaborative-storage.module.ts @@ -1,14 +1,13 @@ import { Module } from '@nestjs/common'; -import { CollaborativeStorageAdapterModule } from '@shared/infra/collaborative-storage/collaborative-storage-adapter.module'; +import { CollaborativeStorageAdapterModule } from '@infra/collaborative-storage'; import { TeamsRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { AuthorizationModule } from '@modules/authorization'; -import { TeamPermissionsMapper } from '@modules/collaborative-storage/mapper/team-permissions.mapper'; -import { TeamMapper } from '@modules/collaborative-storage/mapper/team.mapper'; -import { CollaborativeStorageService } from '@modules/collaborative-storage/services/collaborative-storage.service'; -import { RoleModule } from '@modules/role/role.module'; -import { CollaborativeStorageController } from './controller/collaborative-storage.controller'; -import { CollaborativeStorageUc } from './uc/collaborative-storage.uc'; +import { RoleModule } from '@modules/role'; +import { CollaborativeStorageService } from './services'; +import { TeamPermissionsMapper, TeamMapper } from './mapper'; +import { CollaborativeStorageController } from './controller'; +import { CollaborativeStorageUc } from './uc'; @Module({ imports: [CollaborativeStorageAdapterModule, AuthorizationModule, LoggerModule, RoleModule], diff --git a/apps/server/src/modules/collaborative-storage/controller/index.ts b/apps/server/src/modules/collaborative-storage/controller/index.ts new file mode 100644 index 00000000000..6e3d2c24555 --- /dev/null +++ b/apps/server/src/modules/collaborative-storage/controller/index.ts @@ -0,0 +1 @@ +export * from './collaborative-storage.controller'; diff --git a/apps/server/src/modules/collaborative-storage/index.ts b/apps/server/src/modules/collaborative-storage/index.ts index 55ed293fd82..6a36bd891cf 100644 --- a/apps/server/src/modules/collaborative-storage/index.ts +++ b/apps/server/src/modules/collaborative-storage/index.ts @@ -1,2 +1,2 @@ -export * from './collaborative-storage.module'; -export * from './services'; +export { CollaborativeStorageModule } from './collaborative-storage.module'; +export { CollaborativeStorageService, TeamDto, TeamPermissionsDto, TeamUserDto } from './services'; diff --git a/apps/server/src/modules/collaborative-storage/mapper/index.ts b/apps/server/src/modules/collaborative-storage/mapper/index.ts new file mode 100644 index 00000000000..df052363bc4 --- /dev/null +++ b/apps/server/src/modules/collaborative-storage/mapper/index.ts @@ -0,0 +1,2 @@ +export * from './team-permissions.mapper'; +export * from './team.mapper'; diff --git a/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.spec.ts b/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.spec.ts index 4f95ae44a11..a1f8757f576 100644 --- a/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.spec.ts +++ b/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.spec.ts @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { RoleName, TeamEntity } from '@shared/domain'; -import { CollaborativeStorageAdapter } from '@shared/infra/collaborative-storage'; +import { CollaborativeStorageAdapter } from '@infra/collaborative-storage'; import { TeamsRepo } from '@shared/repo'; import { setupEntities } from '@shared/testing'; import { teamFactory } from '@shared/testing/factory/team.factory'; diff --git a/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.ts b/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.ts index f9807cf691c..8f32f0ffc5f 100644 --- a/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.ts +++ b/apps/server/src/modules/collaborative-storage/services/collaborative-storage.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { EntityId, Permission } from '@shared/domain'; -import { CollaborativeStorageAdapter } from '@shared/infra/collaborative-storage'; +import { CollaborativeStorageAdapter } from '@infra/collaborative-storage'; import { TeamsRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; diff --git a/apps/server/src/modules/collaborative-storage/uc/index.ts b/apps/server/src/modules/collaborative-storage/uc/index.ts new file mode 100644 index 00000000000..b08c347bf88 --- /dev/null +++ b/apps/server/src/modules/collaborative-storage/uc/index.ts @@ -0,0 +1 @@ +export * from './collaborative-storage.uc'; diff --git a/apps/server/src/modules/deletion/deletion.module.ts b/apps/server/src/modules/deletion/deletion.module.ts new file mode 100644 index 00000000000..440a9418d70 --- /dev/null +++ b/apps/server/src/modules/deletion/deletion.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; +import { LoggerModule } from '@src/core/logger'; +import { DeletionRequestService } from './services/deletion-request.service'; +import { DeletionRequestRepo } from './repo/deletion-request.repo'; + +@Module({ + imports: [LoggerModule], + providers: [DeletionRequestService, DeletionRequestRepo], + exports: [DeletionRequestService], +}) +export class DeletionModule {} diff --git a/apps/server/src/modules/deletion/domain/deletion-log.do.spec.ts b/apps/server/src/modules/deletion/domain/deletion-log.do.spec.ts new file mode 100644 index 00000000000..9117ded29c5 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/deletion-log.do.spec.ts @@ -0,0 +1,70 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { deletionLogFactory } from './testing/factory/deletion-log.factory'; +import { DeletionLog } from './deletion-log.do'; +import { DeletionOperationModel } from './types/deletion-operation-model.enum'; +import { DeletionDomainModel } from './types/deletion-domain-model.enum'; + +describe(DeletionLog.name, () => { + describe('constructor', () => { + describe('When constructor is called', () => { + it('should create a deletionRequest by passing required properties', () => { + const domainObject: DeletionLog = deletionLogFactory.build(); + + expect(domainObject instanceof DeletionLog).toEqual(true); + }); + }); + + describe('when passed a valid id', () => { + const setup = () => { + const domainObject: DeletionLog = deletionLogFactory.buildWithId(); + + return { domainObject }; + }; + + it('should set the id', () => { + const { domainObject } = setup(); + + const deletionLogDomainObject: DeletionLog = new DeletionLog(domainObject); + + expect(deletionLogDomainObject.id).toEqual(domainObject.id); + }); + }); + }); + + describe('getters', () => { + describe('When getters are used', () => { + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + domain: DeletionDomainModel.USER, + operation: DeletionOperationModel.DELETE, + modifiedCount: 0, + deletedCount: 1, + deletionRequestId: new ObjectId().toHexString(), + createdAt: new Date(), + updatedAt: new Date(), + }; + + const deletionLogDo = new DeletionLog(props); + + return { props, deletionLogDo }; + }; + it('getters should return proper values', () => { + const { props, deletionLogDo } = setup(); + + const gettersValues = { + id: deletionLogDo.id, + domain: deletionLogDo.domain, + operation: deletionLogDo.operation, + modifiedCount: deletionLogDo.modifiedCount, + deletedCount: deletionLogDo.deletedCount, + deletionRequestId: deletionLogDo.deletionRequestId, + createdAt: deletionLogDo.createdAt, + updatedAt: deletionLogDo.updatedAt, + }; + + expect(gettersValues).toEqual(props); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/domain/deletion-log.do.ts b/apps/server/src/modules/deletion/domain/deletion-log.do.ts new file mode 100644 index 00000000000..73e62b46055 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/deletion-log.do.ts @@ -0,0 +1,44 @@ +import { EntityId } from '@shared/domain/types'; +import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; +import { DeletionDomainModel } from './types/deletion-domain-model.enum'; +import { DeletionOperationModel } from './types/deletion-operation-model.enum'; + +export interface DeletionLogProps extends AuthorizableObject { + createdAt?: Date; + updatedAt?: Date; + domain: DeletionDomainModel; + operation?: DeletionOperationModel; + modifiedCount?: number; + deletedCount?: number; + deletionRequestId?: EntityId; +} + +export class DeletionLog extends DomainObject { + get createdAt(): Date | undefined { + return this.props.createdAt; + } + + get updatedAt(): Date | undefined { + return this.props.updatedAt; + } + + get domain(): DeletionDomainModel { + return this.props.domain; + } + + get operation(): DeletionOperationModel | undefined { + return this.props.operation; + } + + get modifiedCount(): number | undefined { + return this.props.modifiedCount; + } + + get deletedCount(): number | undefined { + return this.props.deletedCount; + } + + get deletionRequestId(): EntityId | undefined { + return this.props.deletionRequestId; + } +} diff --git a/apps/server/src/modules/deletion/domain/deletion-request.do.spec.ts b/apps/server/src/modules/deletion/domain/deletion-request.do.spec.ts new file mode 100644 index 00000000000..3c0eb608c87 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/deletion-request.do.spec.ts @@ -0,0 +1,69 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionRequest } from './deletion-request.do'; +import { DeletionDomainModel } from './types/deletion-domain-model.enum'; +import { deletionRequestFactory } from './testing/factory/deletion-request.factory'; +import { DeletionStatusModel } from './types/deletion-status-model.enum'; + +describe(DeletionRequest.name, () => { + describe('constructor', () => { + describe('When constructor is called', () => { + it('should create a deletionRequest by passing required properties', () => { + const domainObject: DeletionRequest = deletionRequestFactory.build(); + + expect(domainObject instanceof DeletionRequest).toEqual(true); + }); + }); + + describe('when passed a valid id', () => { + const setup = () => { + const domainObject: DeletionRequest = deletionRequestFactory.buildWithId(); + + return { domainObject }; + }; + + it('should set the id', () => { + const { domainObject } = setup(); + + const deletionRequestDomainObject: DeletionRequest = new DeletionRequest(domainObject); + + expect(deletionRequestDomainObject.id).toEqual(domainObject.id); + }); + }); + }); + + describe('getters', () => { + describe('When getters are used', () => { + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + targetRefDomain: DeletionDomainModel.USER, + deleteAfter: new Date(), + targetRefId: new ObjectId().toHexString(), + status: DeletionStatusModel.REGISTERED, + createdAt: new Date(), + updatedAt: new Date(), + }; + + const deletionRequestDo = new DeletionRequest(props); + + return { props, deletionRequestDo }; + }; + + it('getters should return proper values', () => { + const { props, deletionRequestDo } = setup(); + + const gettersValues = { + id: deletionRequestDo.id, + targetRefDomain: deletionRequestDo.targetRefDomain, + deleteAfter: deletionRequestDo.deleteAfter, + targetRefId: deletionRequestDo.targetRefId, + status: deletionRequestDo.status, + createdAt: deletionRequestDo.createdAt, + updatedAt: deletionRequestDo.updatedAt, + }; + + expect(gettersValues).toEqual(props); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/domain/deletion-request.do.ts b/apps/server/src/modules/deletion/domain/deletion-request.do.ts new file mode 100644 index 00000000000..e1a8b289ef0 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/deletion-request.do.ts @@ -0,0 +1,39 @@ +import { EntityId } from '@shared/domain/types'; +import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; +import { DeletionDomainModel } from './types/deletion-domain-model.enum'; +import { DeletionStatusModel } from './types/deletion-status-model.enum'; + +export interface DeletionRequestProps extends AuthorizableObject { + createdAt?: Date; + updatedAt?: Date; + targetRefDomain: DeletionDomainModel; + deleteAfter: Date; + targetRefId: EntityId; + status: DeletionStatusModel; +} + +export class DeletionRequest extends DomainObject { + get createdAt(): Date | undefined { + return this.props.createdAt; + } + + get updatedAt(): Date | undefined { + return this.props.updatedAt; + } + + get targetRefDomain(): DeletionDomainModel { + return this.props.targetRefDomain; + } + + get deleteAfter(): Date { + return this.props.deleteAfter; + } + + get targetRefId(): EntityId { + return this.props.targetRefId; + } + + get status(): DeletionStatusModel { + return this.props.status; + } +} diff --git a/apps/server/src/modules/deletion/domain/testing/factory/deletion-log.factory.ts b/apps/server/src/modules/deletion/domain/testing/factory/deletion-log.factory.ts new file mode 100644 index 00000000000..d83b2f44c8a --- /dev/null +++ b/apps/server/src/modules/deletion/domain/testing/factory/deletion-log.factory.ts @@ -0,0 +1,18 @@ +import { DoBaseFactory } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionLog, DeletionLogProps } from '../../deletion-log.do'; +import { DeletionOperationModel } from '../../types/deletion-operation-model.enum'; +import { DeletionDomainModel } from '../../types/deletion-domain-model.enum'; + +export const deletionLogFactory = DoBaseFactory.define(DeletionLog, () => { + return { + id: new ObjectId().toHexString(), + domain: DeletionDomainModel.USER, + operation: DeletionOperationModel.DELETE, + modifiedCount: 0, + deletedCount: 1, + deletionRequestId: new ObjectId().toHexString(), + createdAt: new Date(), + updatedAt: new Date(), + }; +}); diff --git a/apps/server/src/modules/deletion/domain/testing/factory/deletion-request.factory.ts b/apps/server/src/modules/deletion/domain/testing/factory/deletion-request.factory.ts new file mode 100644 index 00000000000..9f87bbc1cbf --- /dev/null +++ b/apps/server/src/modules/deletion/domain/testing/factory/deletion-request.factory.ts @@ -0,0 +1,28 @@ +import { DoBaseFactory } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeepPartial } from 'fishery'; +import { DeletionRequest, DeletionRequestProps } from '../../deletion-request.do'; +import { DeletionDomainModel } from '../../types/deletion-domain-model.enum'; +import { DeletionStatusModel } from '../../types/deletion-status-model.enum'; + +class DeletionRequestFactory extends DoBaseFactory { + withUserIds(id: string): this { + const params: DeepPartial = { + targetRefId: id, + }; + + return this.params(params); + } +} + +export const deletionRequestFactory = DeletionRequestFactory.define(DeletionRequest, () => { + return { + id: new ObjectId().toHexString(), + targetRefDomain: DeletionDomainModel.USER, + deleteAfter: new Date(), + targetRefId: new ObjectId().toHexString(), + status: DeletionStatusModel.REGISTERED, + createdAt: new Date(), + updatedAt: new Date(), + }; +}); diff --git a/apps/server/src/modules/deletion/domain/types/deletion-domain-model.enum.ts b/apps/server/src/modules/deletion/domain/types/deletion-domain-model.enum.ts new file mode 100644 index 00000000000..1a4f3bcf425 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/types/deletion-domain-model.enum.ts @@ -0,0 +1,12 @@ +export const enum DeletionDomainModel { + ACCOUNT = 'account', + CLASS = 'class', + COURSEGROUP = 'courseGroup', + COURSE = 'course', + FILE = 'file', + LESSONS = 'lessons', + PSEUDONYMS = 'pseudonyms', + ROCKETCHATUSER = 'rocketChatUser', + TEAMS = 'teams', + USER = 'user', +} diff --git a/apps/server/src/modules/deletion/domain/types/deletion-operation-model.enum.ts b/apps/server/src/modules/deletion/domain/types/deletion-operation-model.enum.ts new file mode 100644 index 00000000000..675189e634b --- /dev/null +++ b/apps/server/src/modules/deletion/domain/types/deletion-operation-model.enum.ts @@ -0,0 +1,4 @@ +export const enum DeletionOperationModel { + DELETE = 'delete', + UPDATE = 'update', +} diff --git a/apps/server/src/modules/deletion/domain/types/deletion-status-model.enum.ts b/apps/server/src/modules/deletion/domain/types/deletion-status-model.enum.ts new file mode 100644 index 00000000000..5681d1be214 --- /dev/null +++ b/apps/server/src/modules/deletion/domain/types/deletion-status-model.enum.ts @@ -0,0 +1,5 @@ +export const enum DeletionStatusModel { + FAILED = 'failed', + REGISTERED = 'registered', + SUCCESS = 'success', +} diff --git a/apps/server/src/modules/deletion/entity/deletion-log.entity.spec.ts b/apps/server/src/modules/deletion/entity/deletion-log.entity.spec.ts new file mode 100644 index 00000000000..4f9f098cbb3 --- /dev/null +++ b/apps/server/src/modules/deletion/entity/deletion-log.entity.spec.ts @@ -0,0 +1,60 @@ +import { setupEntities } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionLogEntity } from './deletion-log.entity'; +import { DeletionOperationModel } from '../domain/types/deletion-operation-model.enum'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; + +describe(DeletionLogEntity.name, () => { + beforeAll(async () => { + await setupEntities(); + }); + + describe('constructor', () => { + describe('When constructor is called', () => { + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + domain: DeletionDomainModel.USER, + operation: DeletionOperationModel.DELETE, + modifiedCount: 0, + deletedCount: 1, + deletionRequestId: new ObjectId(), + createdAt: new Date(), + updatedAt: new Date(), + }; + + return { props }; + }; + it('should throw an error by empty constructor', () => { + // @ts-expect-error: Test case + const test = () => new DeletionLogEntity(); + expect(test).toThrow(); + }); + + it('should create a deletionLog by passing required properties', () => { + const { props } = setup(); + const entity: DeletionLogEntity = new DeletionLogEntity(props); + + expect(entity instanceof DeletionLogEntity).toEqual(true); + }); + + it(`should return a valid object with fields values set from the provided complete props object`, () => { + const { props } = setup(); + const entity: DeletionLogEntity = new DeletionLogEntity(props); + + const entityProps = { + id: entity.id, + domain: entity.domain, + operation: entity.operation, + modifiedCount: entity.modifiedCount, + deletedCount: entity.deletedCount, + deletionRequestId: entity.deletionRequestId, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + expect(entityProps).toEqual(props); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/entity/deletion-log.entity.ts b/apps/server/src/modules/deletion/entity/deletion-log.entity.ts new file mode 100644 index 00000000000..8a9d2bab025 --- /dev/null +++ b/apps/server/src/modules/deletion/entity/deletion-log.entity.ts @@ -0,0 +1,67 @@ +import { Entity, Property } from '@mikro-orm/core'; +import { BaseEntityWithTimestamps, EntityId } from '@shared/domain'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionOperationModel } from '../domain/types/deletion-operation-model.enum'; + +export interface DeletionLogEntityProps { + id?: EntityId; + domain: DeletionDomainModel; + operation?: DeletionOperationModel; + modifiedCount?: number; + deletedCount?: number; + deletionRequestId?: ObjectId; + createdAt?: Date; + updatedAt?: Date; +} + +@Entity({ tableName: 'deletionlogs' }) +export class DeletionLogEntity extends BaseEntityWithTimestamps { + @Property() + domain: DeletionDomainModel; + + @Property({ nullable: true }) + operation?: DeletionOperationModel; + + @Property({ nullable: true }) + modifiedCount?: number; + + @Property({ nullable: true }) + deletedCount?: number; + + @Property({ nullable: true }) + deletionRequestId?: ObjectId; + + constructor(props: DeletionLogEntityProps) { + super(); + if (props.id !== undefined) { + this.id = props.id; + } + + this.domain = props.domain; + + if (props.operation !== undefined) { + this.operation = props.operation; + } + + if (props.modifiedCount !== undefined) { + this.modifiedCount = props.modifiedCount; + } + + if (props.deletedCount !== undefined) { + this.deletedCount = props.deletedCount; + } + + if (props.deletionRequestId !== undefined) { + this.deletionRequestId = props.deletionRequestId; + } + + if (props.createdAt !== undefined) { + this.createdAt = props.createdAt; + } + + if (props.updatedAt !== undefined) { + this.updatedAt = props.updatedAt; + } + } +} diff --git a/apps/server/src/modules/deletion/entity/deletion-request.entity.spec.ts b/apps/server/src/modules/deletion/entity/deletion-request.entity.spec.ts new file mode 100644 index 00000000000..6a0e416d580 --- /dev/null +++ b/apps/server/src/modules/deletion/entity/deletion-request.entity.spec.ts @@ -0,0 +1,85 @@ +import { setupEntities } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionRequestEntity } from '@src/modules/deletion/entity/deletion-request.entity'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +describe(DeletionRequestEntity.name, () => { + beforeAll(async () => { + await setupEntities(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + targetRefDomain: DeletionDomainModel.USER, + deleteAfter: new Date(), + targetRefId: new ObjectId().toHexString(), + status: DeletionStatusModel.REGISTERED, + createdAt: new Date(), + updatedAt: new Date(), + }; + + return { props }; + }; + + describe('constructor', () => { + describe('When constructor is called', () => { + it('should throw an error by empty constructor', () => { + // @ts-expect-error: Test case + const test = () => new DeletionRequestEntity(); + expect(test).toThrow(); + }); + + it('should create a deletionRequest by passing required properties', () => { + const { props } = setup(); + const entity: DeletionRequestEntity = new DeletionRequestEntity(props); + + expect(entity instanceof DeletionRequestEntity).toEqual(true); + }); + + it(`should return a valid object with fields values set from the provided complete props object`, () => { + const { props } = setup(); + const entity: DeletionRequestEntity = new DeletionRequestEntity(props); + + const entityProps = { + id: entity.id, + targetRefDomain: entity.targetRefDomain, + deleteAfter: entity.deleteAfter, + targetRefId: entity.targetRefId, + status: entity.status, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + expect(entityProps).toEqual(props); + }); + }); + }); + + describe('executed', () => { + it('should update status with value success', () => { + const { props } = setup(); + const entity: DeletionRequestEntity = new DeletionRequestEntity(props); + + entity.executed(); + + expect(entity.status).toEqual(DeletionStatusModel.SUCCESS); + }); + }); + + describe('failed', () => { + it('should update status with value failed', () => { + const { props } = setup(); + const entity: DeletionRequestEntity = new DeletionRequestEntity(props); + + entity.failed(); + + expect(entity.status).toEqual(DeletionStatusModel.FAILED); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/entity/deletion-request.entity.ts b/apps/server/src/modules/deletion/entity/deletion-request.entity.ts new file mode 100644 index 00000000000..150fed4d91e --- /dev/null +++ b/apps/server/src/modules/deletion/entity/deletion-request.entity.ts @@ -0,0 +1,60 @@ +import { Entity, Index, Property } from '@mikro-orm/core'; +import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; +import { EntityId } from '@shared/domain'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +export interface DeletionRequestEntityProps { + id?: EntityId; + targetRefDomain: DeletionDomainModel; + deleteAfter: Date; + targetRefId: EntityId; + status: DeletionStatusModel; + createdAt?: Date; + updatedAt?: Date; +} + +@Entity({ tableName: 'deletionrequests' }) +@Index({ properties: ['targetRefId', 'targetRefDomain'] }) +export class DeletionRequestEntity extends BaseEntityWithTimestamps { + @Property() + deleteAfter: Date; + + @Property() + targetRefId: EntityId; + + @Property() + targetRefDomain: DeletionDomainModel; + + @Property() + @Index() + status: DeletionStatusModel; + + constructor(props: DeletionRequestEntityProps) { + super(); + if (props.id !== undefined) { + this.id = props.id; + } + + this.targetRefDomain = props.targetRefDomain; + this.deleteAfter = props.deleteAfter; + this.targetRefId = props.targetRefId; + this.status = props.status; + + if (props.createdAt !== undefined) { + this.createdAt = props.createdAt; + } + + if (props.updatedAt !== undefined) { + this.updatedAt = props.updatedAt; + } + } + + public executed(): void { + this.status = DeletionStatusModel.SUCCESS; + } + + public failed(): void { + this.status = DeletionStatusModel.FAILED; + } +} diff --git a/apps/server/src/modules/deletion/entity/index.ts b/apps/server/src/modules/deletion/entity/index.ts new file mode 100644 index 00000000000..7e3e31dcd19 --- /dev/null +++ b/apps/server/src/modules/deletion/entity/index.ts @@ -0,0 +1,2 @@ +export * from './deletion-request.entity'; +export * from './deletion-log.entity'; diff --git a/apps/server/src/modules/deletion/entity/testing/factory/deletion-log.entity.factory.ts b/apps/server/src/modules/deletion/entity/testing/factory/deletion-log.entity.factory.ts new file mode 100644 index 00000000000..897fba6820a --- /dev/null +++ b/apps/server/src/modules/deletion/entity/testing/factory/deletion-log.entity.factory.ts @@ -0,0 +1,21 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseFactory } from '@shared/testing'; +import { DeletionLogEntity, DeletionLogEntityProps } from '../../deletion-log.entity'; +import { DeletionOperationModel } from '../../../domain/types/deletion-operation-model.enum'; +import { DeletionDomainModel } from '../../../domain/types/deletion-domain-model.enum'; + +export const deletionLogEntityFactory = BaseFactory.define( + DeletionLogEntity, + () => { + return { + id: new ObjectId().toHexString(), + domain: DeletionDomainModel.USER, + operation: DeletionOperationModel.DELETE, + modifiedCount: 0, + deletedCount: 1, + deletionRequestId: new ObjectId(), + createdAt: new Date(), + updatedAt: new Date(), + }; + } +); diff --git a/apps/server/src/modules/deletion/entity/testing/factory/deletion-request.entity.factory.ts b/apps/server/src/modules/deletion/entity/testing/factory/deletion-request.entity.factory.ts new file mode 100644 index 00000000000..3ccba779e3e --- /dev/null +++ b/apps/server/src/modules/deletion/entity/testing/factory/deletion-request.entity.factory.ts @@ -0,0 +1,20 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseFactory } from '@shared/testing'; +import { DeletionStatusModel } from '../../../domain/types/deletion-status-model.enum'; +import { DeletionRequestEntity, DeletionRequestEntityProps } from '../../deletion-request.entity'; +import { DeletionDomainModel } from '../../../domain/types/deletion-domain-model.enum'; + +export const deletionRequestEntityFactory = BaseFactory.define( + DeletionRequestEntity, + () => { + return { + id: new ObjectId().toHexString(), + targetRefDomain: DeletionDomainModel.USER, + deleteAfter: new Date(), + targetRefId: new ObjectId().toHexString(), + status: DeletionStatusModel.REGISTERED, + createdAt: new Date(), + updatedAt: new Date(), + }; + } +); diff --git a/apps/server/src/modules/deletion/index.ts b/apps/server/src/modules/deletion/index.ts new file mode 100644 index 00000000000..bd89c1e8d84 --- /dev/null +++ b/apps/server/src/modules/deletion/index.ts @@ -0,0 +1,2 @@ +export * from './deletion.module'; +export * from './services'; diff --git a/apps/server/src/modules/deletion/repo/deletion-log.repo.spec.ts b/apps/server/src/modules/deletion/repo/deletion-log.repo.spec.ts new file mode 100644 index 00000000000..bba32408e84 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/deletion-log.repo.spec.ts @@ -0,0 +1,190 @@ +import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Test } from '@nestjs/testing'; +import { TestingModule } from '@nestjs/testing/testing-module'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { cleanupCollections } from '@shared/testing'; +import { DeletionLogMapper } from './mapper'; +import { DeletionLogEntity } from '../entity'; +import { DeletionLogRepo } from './deletion-log.repo'; +import { deletionLogFactory } from '../domain/testing/factory/deletion-log.factory'; +import { DeletionLog } from '../domain/deletion-log.do'; +import { deletionLogEntityFactory } from '../entity/testing/factory/deletion-log.entity.factory'; + +describe(DeletionLogRepo.name, () => { + let module: TestingModule; + let repo: DeletionLogRepo; + let em: EntityManager; + + beforeAll(async () => { + module = await Test.createTestingModule({ + imports: [ + MongoMemoryDatabaseModule.forRoot({ + entities: [DeletionLogEntity], + }), + ], + providers: [DeletionLogRepo, DeletionLogMapper], + }).compile(); + + repo = module.get(DeletionLogRepo); + em = module.get(EntityManager); + }); + + afterAll(async () => { + await module.close(); + }); + + afterEach(async () => { + await cleanupCollections(em); + }); + + describe('defined', () => { + it('repo should be defined', () => { + expect(repo).toBeDefined(); + }); + + it('entity manager should be defined', () => { + expect(em).toBeDefined(); + }); + + it('should implement entityName getter', () => { + expect(repo.entityName).toBe(DeletionLogEntity); + }); + }); + + describe('create deletionLog', () => { + describe('when deletionLog is new', () => { + const setup = () => { + const domainObject: DeletionLog = deletionLogFactory.build(); + const deletionLogId = domainObject.id; + + const expectedDomainObject = { + id: domainObject.id, + domain: domainObject.domain, + operation: domainObject.operation, + modifiedCount: domainObject.modifiedCount, + deletedCount: domainObject.deletedCount, + deletionRequestId: domainObject.deletionRequestId, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }; + + return { domainObject, deletionLogId, expectedDomainObject }; + }; + it('should create a new deletionLog', async () => { + const { domainObject, deletionLogId, expectedDomainObject } = setup(); + await repo.create(domainObject); + + const result = await repo.findById(deletionLogId); + + expect(result).toEqual(expect.objectContaining(expectedDomainObject)); + }); + }); + }); + + describe('findById', () => { + describe('when searching by Id', () => { + const setup = async () => { + // Test deletionLog entity + const entity: DeletionLogEntity = deletionLogEntityFactory.build(); + await em.persistAndFlush(entity); + + const expectedDeletionLog = { + id: entity.id, + domain: entity.domain, + operation: entity.operation, + modifiedCount: entity.modifiedCount, + deletedCount: entity.deletedCount, + deletionRequestId: entity.deletionRequestId?.toHexString(), + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + return { + entity, + expectedDeletionLog, + }; + }; + + it('should find the deletionRequest', async () => { + const { entity, expectedDeletionLog } = await setup(); + + const result: DeletionLog = await repo.findById(entity.id); + + // Verify explicit fields. + expect(result).toEqual(expect.objectContaining(expectedDeletionLog)); + }); + }); + }); + + describe('findAllByDeletionRequestId', () => { + describe('when there is no deletionLog for deletionRequestId', () => { + it('should return empty array', async () => { + const deletionRequestId = new ObjectId().toHexString(); + const result = await repo.findAllByDeletionRequestId(deletionRequestId); + + expect(result).toEqual([]); + }); + }); + + describe('when searching by deletionRequestId', () => { + const setup = async () => { + const deletionRequest1Id = new ObjectId(); + const deletionRequest2Id = new ObjectId(); + const deletionLogEntity1: DeletionLogEntity = deletionLogEntityFactory.build({ + deletionRequestId: deletionRequest1Id, + }); + const deletionLogEntity2: DeletionLogEntity = deletionLogEntityFactory.build({ + deletionRequestId: deletionRequest1Id, + }); + const deletionLogEntity3: DeletionLogEntity = deletionLogEntityFactory.build({ + deletionRequestId: deletionRequest2Id, + }); + + await em.persistAndFlush([deletionLogEntity1, deletionLogEntity2, deletionLogEntity3]); + em.clear(); + + const expectedArray = [ + { + id: deletionLogEntity1.id, + domain: deletionLogEntity1.domain, + operation: deletionLogEntity1.operation, + deletionRequestId: deletionLogEntity1.deletionRequestId?.toHexString(), + modifiedCount: deletionLogEntity1.modifiedCount, + deletedCount: deletionLogEntity1.deletedCount, + createdAt: deletionLogEntity1.createdAt, + updatedAt: deletionLogEntity1.updatedAt, + }, + { + id: deletionLogEntity2.id, + domain: deletionLogEntity2.domain, + operation: deletionLogEntity2.operation, + deletionRequestId: deletionLogEntity2.deletionRequestId?.toHexString(), + modifiedCount: deletionLogEntity2.modifiedCount, + deletedCount: deletionLogEntity2.deletedCount, + createdAt: deletionLogEntity2.createdAt, + updatedAt: deletionLogEntity2.updatedAt, + }, + ]; + + return { deletionLogEntity3, deletionRequest1Id, expectedArray }; + }; + + it('should find deletionRequests with deleteAfter smaller then today', async () => { + const { deletionLogEntity3, deletionRequest1Id, expectedArray } = await setup(); + + const results = await repo.findAllByDeletionRequestId(deletionRequest1Id.toHexString()); + + expect(results.length).toEqual(2); + + // Verify explicit fields. + expect(results).toEqual( + expect.arrayContaining([expect.objectContaining(expectedArray[0]), expect.objectContaining(expectedArray[1])]) + ); + + const result: DeletionLog = await repo.findById(deletionLogEntity3.id); + + expect(result.id).toEqual(deletionLogEntity3.id); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/repo/deletion-log.repo.ts b/apps/server/src/modules/deletion/repo/deletion-log.repo.ts new file mode 100644 index 00000000000..d71032eb124 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/deletion-log.repo.ts @@ -0,0 +1,41 @@ +import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { DeletionLog } from '../domain/deletion-log.do'; +import { DeletionLogEntity } from '../entity/deletion-log.entity'; +import { DeletionLogMapper } from './mapper/deletion-log.mapper'; + +@Injectable() +export class DeletionLogRepo { + constructor(private readonly em: EntityManager) {} + + get entityName() { + return DeletionLogEntity; + } + + async findById(deletionLogId: EntityId): Promise { + const deletionLog: DeletionLogEntity = await this.em.findOneOrFail(DeletionLogEntity, { + id: deletionLogId, + }); + + const mapped: DeletionLog = DeletionLogMapper.mapToDO(deletionLog); + + return mapped; + } + + async findAllByDeletionRequestId(deletionRequestId: EntityId): Promise { + const deletionLogEntities: DeletionLogEntity[] = await this.em.find(DeletionLogEntity, { + deletionRequestId: new ObjectId(deletionRequestId), + }); + + const mapped: DeletionLog[] = DeletionLogMapper.mapToDOs(deletionLogEntities); + + return mapped; + } + + async create(deletionLog: DeletionLog): Promise { + const deletionLogEntity: DeletionLogEntity = DeletionLogMapper.mapToEntity(deletionLog); + this.em.persist(deletionLogEntity); + await this.em.flush(); + } +} diff --git a/apps/server/src/modules/deletion/repo/deletion-request-scope.ts b/apps/server/src/modules/deletion/repo/deletion-request-scope.ts new file mode 100644 index 00000000000..202bc09a887 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/deletion-request-scope.ts @@ -0,0 +1,17 @@ +import { Scope } from '@shared/repo'; +import { DeletionRequestEntity } from '../entity'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +export class DeletionRequestScope extends Scope { + byDeleteAfter(currentDate: Date): DeletionRequestScope { + this.addQuery({ deleteAfter: { $lt: currentDate } }); + + return this; + } + + byStatus(): DeletionRequestScope { + this.addQuery({ status: [DeletionStatusModel.REGISTERED, DeletionStatusModel.FAILED] }); + + return this; + } +} diff --git a/apps/server/src/modules/deletion/repo/deletion-request.repo.spec.ts b/apps/server/src/modules/deletion/repo/deletion-request.repo.spec.ts new file mode 100644 index 00000000000..c3018180218 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/deletion-request.repo.spec.ts @@ -0,0 +1,342 @@ +import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Test } from '@nestjs/testing'; +import { TestingModule } from '@nestjs/testing/testing-module'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { cleanupCollections } from '@shared/testing'; +import { DeletionRequestMapper } from './mapper'; +import { DeletionRequestRepo } from './deletion-request.repo'; +import { DeletionRequestEntity } from '../entity'; +import { DeletionRequest } from '../domain/deletion-request.do'; +import { deletionRequestEntityFactory } from '../entity/testing/factory/deletion-request.entity.factory'; +import { deletionRequestFactory } from '../domain/testing/factory/deletion-request.factory'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +describe(DeletionRequestRepo.name, () => { + let module: TestingModule; + let repo: DeletionRequestRepo; + let em: EntityManager; + + beforeAll(async () => { + module = await Test.createTestingModule({ + imports: [ + MongoMemoryDatabaseModule.forRoot({ + entities: [DeletionRequestEntity], + }), + ], + providers: [DeletionRequestRepo, DeletionRequestMapper], + }).compile(); + + repo = module.get(DeletionRequestRepo); + em = module.get(EntityManager); + }); + + afterAll(async () => { + await module.close(); + }); + + afterEach(async () => { + await cleanupCollections(em); + }); + + describe('defined', () => { + it('repo should be defined', () => { + expect(repo).toBeDefined(); + }); + + it('entity manager should be defined', () => { + expect(em).toBeDefined(); + }); + + it('should implement entityName getter', () => { + expect(repo.entityName).toBe(DeletionRequestEntity); + }); + }); + + describe('create deletionRequest', () => { + describe('when deletionRequest is new', () => { + it('should create a new deletionRequest', async () => { + const domainObject: DeletionRequest = deletionRequestFactory.build(); + const deletionRequestId = domainObject.id; + await repo.create(domainObject); + + const result = await repo.findById(deletionRequestId); + + expect(result).toEqual(domainObject); + }); + }); + }); + + describe('findById', () => { + describe('when searching by Id', () => { + const setup = async () => { + const userId = new ObjectId().toHexString(); + + const entity: DeletionRequestEntity = deletionRequestEntityFactory.build({ targetRefId: userId }); + await em.persistAndFlush(entity); + + const expectedDeletionRequest = { + id: entity.id, + targetRefDomain: entity.targetRefDomain, + deleteAfter: entity.deleteAfter, + targetRefId: entity.targetRefId, + status: entity.status, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + return { + entity, + expectedDeletionRequest, + }; + }; + + it('should find the deletionRequest', async () => { + const { entity, expectedDeletionRequest } = await setup(); + + const result: DeletionRequest = await repo.findById(entity.id); + + // Verify explicit fields. + expect(result).toEqual(expect.objectContaining(expectedDeletionRequest)); + }); + }); + }); + + describe('findAllItemsToExecution', () => { + describe('when there is no deletionRequest for execution', () => { + it('should return empty array', async () => { + const result = await repo.findAllItemsToExecution(); + + expect(result).toEqual([]); + }); + }); + + describe('when there are deletionRequests for execution', () => { + const setup = async () => { + const dateInFuture = new Date(); + dateInFuture.setDate(dateInFuture.getDate() + 30); + const deletionRequestEntity1: DeletionRequestEntity = deletionRequestEntityFactory.build({ + createdAt: new Date(2023, 7, 1), + deleteAfter: new Date(2023, 8, 1), + status: DeletionStatusModel.SUCCESS, + }); + const deletionRequestEntity2: DeletionRequestEntity = deletionRequestEntityFactory.build({ + createdAt: new Date(2023, 7, 1), + deleteAfter: new Date(2023, 8, 1), + status: DeletionStatusModel.FAILED, + }); + const deletionRequestEntity3: DeletionRequestEntity = deletionRequestEntityFactory.build({ + createdAt: new Date(2023, 8, 1), + deleteAfter: new Date(2023, 9, 1), + }); + const deletionRequestEntity4: DeletionRequestEntity = deletionRequestEntityFactory.build({ + createdAt: new Date(2023, 9, 1), + deleteAfter: new Date(2023, 10, 1), + }); + const deletionRequestEntity5: DeletionRequestEntity = deletionRequestEntityFactory.build({ + deleteAfter: dateInFuture, + }); + + await em.persistAndFlush([ + deletionRequestEntity1, + deletionRequestEntity2, + deletionRequestEntity3, + deletionRequestEntity4, + deletionRequestEntity5, + ]); + em.clear(); + + const expectedArray = [ + { + id: deletionRequestEntity4.id, + targetRefDomain: deletionRequestEntity4.targetRefDomain, + deleteAfter: deletionRequestEntity4.deleteAfter, + targetRefId: deletionRequestEntity4.targetRefId, + status: deletionRequestEntity4.status, + createdAt: deletionRequestEntity4.createdAt, + updatedAt: deletionRequestEntity4.updatedAt, + }, + { + id: deletionRequestEntity3.id, + targetRefDomain: deletionRequestEntity3.targetRefDomain, + deleteAfter: deletionRequestEntity3.deleteAfter, + targetRefId: deletionRequestEntity3.targetRefId, + status: deletionRequestEntity3.status, + createdAt: deletionRequestEntity3.createdAt, + updatedAt: deletionRequestEntity3.updatedAt, + }, + { + id: deletionRequestEntity2.id, + targetRefDomain: deletionRequestEntity2.targetRefDomain, + deleteAfter: deletionRequestEntity2.deleteAfter, + targetRefId: deletionRequestEntity2.targetRefId, + status: deletionRequestEntity2.status, + createdAt: deletionRequestEntity2.createdAt, + updatedAt: deletionRequestEntity2.updatedAt, + }, + ]; + + return { deletionRequestEntity1, deletionRequestEntity5, expectedArray }; + }; + + it('should find deletionRequests with deleteAfter smaller then today and status with value registered or failed', async () => { + const { deletionRequestEntity1, deletionRequestEntity5, expectedArray } = await setup(); + + const results = await repo.findAllItemsToExecution(); + + expect(results.length).toEqual(3); + + // Verify explicit fields. + expect(results).toEqual( + expect.arrayContaining([ + expect.objectContaining(expectedArray[0]), + expect.objectContaining(expectedArray[1]), + expect.objectContaining(expectedArray[2]), + ]) + ); + + const result1: DeletionRequest = await repo.findById(deletionRequestEntity1.id); + + expect(result1.id).toEqual(deletionRequestEntity1.id); + + const result5: DeletionRequest = await repo.findById(deletionRequestEntity5.id); + + expect(result5.id).toEqual(deletionRequestEntity5.id); + }); + + it('should find deletionRequests to execute with limit = 2', async () => { + const { expectedArray } = await setup(); + + const results = await repo.findAllItemsToExecution(2); + + expect(results.length).toEqual(2); + + // Verify explicit fields. + expect(results).toEqual( + expect.arrayContaining([expect.objectContaining(expectedArray[0]), expect.objectContaining(expectedArray[1])]) + ); + }); + }); + }); + + describe('update', () => { + describe('when updating deletionRequest', () => { + const setup = async () => { + const userId = new ObjectId().toHexString(); + + const entity: DeletionRequestEntity = deletionRequestEntityFactory.build({ targetRefId: userId }); + await em.persistAndFlush(entity); + + // Arrange expected DeletionRequestEntity after changing status + entity.status = DeletionStatusModel.SUCCESS; + const deletionRequestToUpdate = DeletionRequestMapper.mapToDO(entity); + + return { + entity, + deletionRequestToUpdate, + }; + }; + + it('should update the deletionRequest', async () => { + const { entity, deletionRequestToUpdate } = await setup(); + + await repo.update(deletionRequestToUpdate); + + const result: DeletionRequest = await repo.findById(entity.id); + + expect(result.status).toEqual(entity.status); + }); + }); + }); + + describe('markDeletionRequestAsFailed', () => { + describe('when mark deletionRequest as failed', () => { + const setup = async () => { + const userId = new ObjectId().toHexString(); + + const entity: DeletionRequestEntity = deletionRequestEntityFactory.build({ targetRefId: userId }); + await em.persistAndFlush(entity); + + return { entity }; + }; + + it('should update the deletionRequest', async () => { + const { entity } = await setup(); + + const result = await repo.markDeletionRequestAsFailed(entity.id); + + expect(result).toBe(true); + }); + + it('should update the deletionRequest', async () => { + const { entity } = await setup(); + + await repo.markDeletionRequestAsFailed(entity.id); + + const result: DeletionRequest = await repo.findById(entity.id); + + expect(result.status).toEqual(DeletionStatusModel.FAILED); + }); + }); + }); + + describe('markDeletionRequestAsExecuted', () => { + describe('when mark deletionRequest as executed', () => { + const setup = async () => { + const userId = new ObjectId().toHexString(); + + const entity: DeletionRequestEntity = deletionRequestEntityFactory.build({ targetRefId: userId }); + await em.persistAndFlush(entity); + + return { entity }; + }; + + it('should update the deletionRequest', async () => { + const { entity } = await setup(); + + const result = await repo.markDeletionRequestAsExecuted(entity.id); + + expect(result).toBe(true); + }); + + it('should update the deletionRequest', async () => { + const { entity } = await setup(); + + await repo.markDeletionRequestAsExecuted(entity.id); + + const result: DeletionRequest = await repo.findById(entity.id); + + expect(result.status).toEqual(DeletionStatusModel.SUCCESS); + }); + }); + }); + + describe('deleteById', () => { + describe('when deleting deletionRequest exists', () => { + const setup = async () => { + const userId = new ObjectId().toHexString(); + const entity: DeletionRequestEntity = deletionRequestEntityFactory.build({ targetRefId: userId }); + const deletionRequestId = entity.id; + await em.persistAndFlush(entity); + em.clear(); + + return { deletionRequestId }; + }; + + it('should delete the deletionRequest with deletionRequestId', async () => { + const { deletionRequestId } = await setup(); + + await repo.deleteById(deletionRequestId); + + expect(await em.findOne(DeletionRequestEntity, { id: deletionRequestId })).toBeNull(); + }); + + it('should return true', async () => { + const { deletionRequestId } = await setup(); + + const result: boolean = await repo.deleteById(deletionRequestId); + + expect(result).toEqual(true); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/repo/deletion-request.repo.ts b/apps/server/src/modules/deletion/repo/deletion-request.repo.ts new file mode 100644 index 00000000000..b24cf792f01 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/deletion-request.repo.ts @@ -0,0 +1,86 @@ +import { EntityManager } from '@mikro-orm/mongodb'; +import { Injectable } from '@nestjs/common'; +import { EntityId, SortOrder } from '@shared/domain'; +import { DeletionRequest } from '../domain/deletion-request.do'; +import { DeletionRequestEntity } from '../entity'; +import { DeletionRequestMapper } from './mapper/deletion-request.mapper'; +import { DeletionRequestScope } from './deletion-request-scope'; + +@Injectable() +export class DeletionRequestRepo { + constructor(private readonly em: EntityManager) {} + + get entityName() { + return DeletionRequestEntity; + } + + async findById(deletionRequestId: EntityId): Promise { + const deletionRequest: DeletionRequestEntity = await this.em.findOneOrFail(DeletionRequestEntity, { + id: deletionRequestId, + }); + + const mapped: DeletionRequest = DeletionRequestMapper.mapToDO(deletionRequest); + + return mapped; + } + + async create(deletionRequest: DeletionRequest): Promise { + const deletionRequestEntity = DeletionRequestMapper.mapToEntity(deletionRequest); + this.em.persist(deletionRequestEntity); + await this.em.flush(); + } + + async findAllItemsToExecution(limit?: number): Promise { + const currentDate = new Date(); + const scope = new DeletionRequestScope().byDeleteAfter(currentDate).byStatus(); + const order = { createdAt: SortOrder.desc }; + + const [deletionRequestEntities] = await this.em.findAndCount(DeletionRequestEntity, scope.query, { + limit, + orderBy: order, + }); + + const mapped: DeletionRequest[] = deletionRequestEntities.map((entity) => DeletionRequestMapper.mapToDO(entity)); + + return mapped; + } + + async update(deletionRequest: DeletionRequest): Promise { + const deletionRequestEntity = DeletionRequestMapper.mapToEntity(deletionRequest); + const referencedEntity = this.em.getReference(DeletionRequestEntity, deletionRequestEntity.id); + + await this.em.persistAndFlush(referencedEntity); + } + + async markDeletionRequestAsExecuted(deletionRequestId: EntityId): Promise { + const deletionRequest: DeletionRequestEntity = await this.em.findOneOrFail(DeletionRequestEntity, { + id: deletionRequestId, + }); + + deletionRequest.executed(); + await this.em.persistAndFlush(deletionRequest); + + return true; + } + + async markDeletionRequestAsFailed(deletionRequestId: EntityId): Promise { + const deletionRequest: DeletionRequestEntity = await this.em.findOneOrFail(DeletionRequestEntity, { + id: deletionRequestId, + }); + + deletionRequest.failed(); + await this.em.persistAndFlush(deletionRequest); + + return true; + } + + async deleteById(deletionRequestId: EntityId): Promise { + const entity: DeletionRequestEntity | null = await this.em.findOneOrFail(DeletionRequestEntity, { + id: deletionRequestId, + }); + + await this.em.removeAndFlush(entity); + + return true; + } +} diff --git a/apps/server/src/modules/deletion/repo/index.ts b/apps/server/src/modules/deletion/repo/index.ts new file mode 100644 index 00000000000..68860c00a79 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/index.ts @@ -0,0 +1,2 @@ +export * from './deletion-log.repo'; +export * from './deletion-request.repo'; diff --git a/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.spec.ts b/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.spec.ts new file mode 100644 index 00000000000..a5823f5ce32 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.spec.ts @@ -0,0 +1,162 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { deletionLogEntityFactory } from '../../entity/testing/factory/deletion-log.entity.factory'; +import { DeletionLogMapper } from './deletion-log.mapper'; +import { DeletionLog } from '../../domain/deletion-log.do'; +import { deletionLogFactory } from '../../domain/testing/factory/deletion-log.factory'; +import { DeletionLogEntity } from '../../entity'; + +describe(DeletionLogMapper.name, () => { + describe('mapToDO', () => { + describe('When entity is mapped for domainObject', () => { + const setup = () => { + const entity = deletionLogEntityFactory.build(); + + const expectedDomainObject = new DeletionLog({ + id: entity.id, + domain: entity.domain, + operation: entity.operation, + deletionRequestId: entity.deletionRequestId?.toHexString(), + modifiedCount: entity.modifiedCount, + deletedCount: entity.deletedCount, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }); + + return { entity, expectedDomainObject }; + }; + it('should properly map the entity to the domain object', () => { + const { entity, expectedDomainObject } = setup(); + + const domainObject = DeletionLogMapper.mapToDO(entity); + + expect(domainObject).toEqual(expectedDomainObject); + }); + }); + }); + + describe('mapToDOs', () => { + describe('When empty entities array is mapped for an empty domainObjects array', () => { + it('should return empty domain objects array for an empty entities array', () => { + const domainObjects = DeletionLogMapper.mapToDOs([]); + + expect(domainObjects).toEqual([]); + }); + }); + + describe('When entities array is mapped for domainObjects array', () => { + const setup = () => { + const entities = [deletionLogEntityFactory.build()]; + + const expectedDomainObjects = entities.map( + (entity) => + new DeletionLog({ + id: entity.id, + domain: entity.domain, + operation: entity.operation, + deletionRequestId: entity.deletionRequestId?.toHexString(), + modifiedCount: entity.modifiedCount, + deletedCount: entity.deletedCount, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }) + ); + + return { entities, expectedDomainObjects }; + }; + it('should properly map the entities to the domain objects', () => { + const { entities, expectedDomainObjects } = setup(); + + const domainObjects = DeletionLogMapper.mapToDOs(entities); + + expect(domainObjects).toEqual(expectedDomainObjects); + }); + }); + }); + + describe('mapToEntity', () => { + describe('When domainObject is mapped for entity', () => { + beforeAll(() => { + jest.useFakeTimers(); + jest.setSystemTime(new Date()); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + const setup = () => { + const domainObject = deletionLogFactory.build(); + + const expectedEntities = new DeletionLogEntity({ + id: domainObject.id, + domain: domainObject.domain, + operation: domainObject.operation, + deletionRequestId: new ObjectId(domainObject.deletionRequestId), + modifiedCount: domainObject.modifiedCount, + deletedCount: domainObject.deletedCount, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }); + + return { domainObject, expectedEntities }; + }; + + it('should properly map the domainObject to the entity', () => { + const { domainObject, expectedEntities } = setup(); + + const entities = DeletionLogMapper.mapToEntity(domainObject); + + expect(entities).toEqual(expectedEntities); + }); + }); + }); + + describe('mapToEntities', () => { + describe('When empty domainObjects array is mapped for an entities array', () => { + it('should return empty entities array for an empty domain objects array', () => { + const entities = DeletionLogMapper.mapToEntities([]); + + expect(entities).toEqual([]); + }); + }); + + describe('When domainObjects array is mapped for entities array', () => { + beforeAll(() => { + jest.useFakeTimers(); + jest.setSystemTime(new Date()); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + const setup = () => { + const domainObjects = [deletionLogFactory.build()]; + + const expectedEntities = domainObjects.map( + (domainObject) => + new DeletionLogEntity({ + id: domainObject.id, + domain: domainObject.domain, + operation: domainObject.operation, + deletionRequestId: new ObjectId(domainObject.deletionRequestId), + modifiedCount: domainObject.modifiedCount, + deletedCount: domainObject.deletedCount, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }) + ); + + return { domainObjects, expectedEntities }; + }; + + it('should properly map the domainObjects to the entities', () => { + const { domainObjects, expectedEntities } = setup(); + + const entities = DeletionLogMapper.mapToEntities(domainObjects); + + expect(entities).toEqual(expectedEntities); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.ts b/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.ts new file mode 100644 index 00000000000..820cd9d87c0 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/mapper/deletion-log.mapper.ts @@ -0,0 +1,39 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionLogEntity } from '../../entity/deletion-log.entity'; +import { DeletionLog } from '../../domain/deletion-log.do'; + +export class DeletionLogMapper { + static mapToDO(entity: DeletionLogEntity): DeletionLog { + return new DeletionLog({ + id: entity.id, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + domain: entity.domain, + operation: entity.operation, + modifiedCount: entity.modifiedCount, + deletedCount: entity.deletedCount, + deletionRequestId: entity.deletionRequestId?.toHexString(), + }); + } + + static mapToEntity(domainObject: DeletionLog): DeletionLogEntity { + return new DeletionLogEntity({ + id: domainObject.id, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + domain: domainObject.domain, + operation: domainObject.operation, + modifiedCount: domainObject.modifiedCount, + deletedCount: domainObject.deletedCount, + deletionRequestId: new ObjectId(domainObject.deletionRequestId), + }); + } + + static mapToDOs(entities: DeletionLogEntity[]): DeletionLog[] { + return entities.map((entity) => this.mapToDO(entity)); + } + + static mapToEntities(domainObjects: DeletionLog[]): DeletionLogEntity[] { + return domainObjects.map((domainObject) => this.mapToEntity(domainObject)); + } +} diff --git a/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.spec.ts b/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.spec.ts new file mode 100644 index 00000000000..4e880aab54e --- /dev/null +++ b/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.spec.ts @@ -0,0 +1,71 @@ +import { DeletionRequest } from '../../domain/deletion-request.do'; +import { deletionRequestFactory } from '../../domain/testing/factory/deletion-request.factory'; +import { DeletionRequestEntity } from '../../entity'; +import { deletionRequestEntityFactory } from '../../entity/testing/factory/deletion-request.entity.factory'; +import { DeletionRequestMapper } from './deletion-request.mapper'; + +describe(DeletionRequestMapper.name, () => { + describe('mapToDO', () => { + describe('When entity is mapped for domainObject', () => { + const setup = () => { + const entity = deletionRequestEntityFactory.build(); + + const expectedDomainObject = new DeletionRequest({ + id: entity.id, + targetRefDomain: entity.targetRefDomain, + deleteAfter: entity.deleteAfter, + targetRefId: entity.targetRefId, + status: entity.status, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }); + + return { entity, expectedDomainObject }; + }; + + it('should properly map the entity to the domain object', () => { + const { entity, expectedDomainObject } = setup(); + + const domainObject = DeletionRequestMapper.mapToDO(entity); + + expect(domainObject).toEqual(expectedDomainObject); + }); + }); + }); + + describe('mapToEntity', () => { + describe('When domainObject is mapped for entity', () => { + beforeAll(() => { + jest.useFakeTimers(); + jest.setSystemTime(new Date()); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + const setup = () => { + const domainObject = deletionRequestFactory.build(); + + const expectedEntity = new DeletionRequestEntity({ + id: domainObject.id, + targetRefDomain: domainObject.targetRefDomain, + deleteAfter: domainObject.deleteAfter, + targetRefId: domainObject.targetRefId, + status: domainObject.status, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }); + + return { domainObject, expectedEntity }; + }; + + it('should properly map the domainObject to the entity', () => { + const { domainObject, expectedEntity } = setup(); + + const entity = DeletionRequestMapper.mapToEntity(domainObject); + + expect(entity).toEqual(expectedEntity); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.ts b/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.ts new file mode 100644 index 00000000000..fd6c273011f --- /dev/null +++ b/apps/server/src/modules/deletion/repo/mapper/deletion-request.mapper.ts @@ -0,0 +1,28 @@ +import { DeletionRequest } from '../../domain/deletion-request.do'; +import { DeletionRequestEntity } from '../../entity'; + +export class DeletionRequestMapper { + static mapToDO(entity: DeletionRequestEntity): DeletionRequest { + return new DeletionRequest({ + id: entity.id, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + targetRefDomain: entity.targetRefDomain, + deleteAfter: entity.deleteAfter, + targetRefId: entity.targetRefId, + status: entity.status, + }); + } + + static mapToEntity(domainObject: DeletionRequest): DeletionRequestEntity { + return new DeletionRequestEntity({ + id: domainObject.id, + targetRefDomain: domainObject.targetRefDomain, + deleteAfter: domainObject.deleteAfter, + targetRefId: domainObject.targetRefId, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + status: domainObject.status, + }); + } +} diff --git a/apps/server/src/modules/deletion/repo/mapper/index.ts b/apps/server/src/modules/deletion/repo/mapper/index.ts new file mode 100644 index 00000000000..0407135b228 --- /dev/null +++ b/apps/server/src/modules/deletion/repo/mapper/index.ts @@ -0,0 +1,2 @@ +export * from './deletion-request.mapper'; +export * from './deletion-log.mapper'; diff --git a/apps/server/src/modules/deletion/services/deletion-log.service.spec.ts b/apps/server/src/modules/deletion/services/deletion-log.service.spec.ts new file mode 100644 index 00000000000..21522e5e924 --- /dev/null +++ b/apps/server/src/modules/deletion/services/deletion-log.service.spec.ts @@ -0,0 +1,110 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { setupEntities } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionLogRepo } from '../repo'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionLogService } from './deletion-log.service'; +import { DeletionOperationModel } from '../domain/types/deletion-operation-model.enum'; +import { deletionLogFactory } from '../domain/testing/factory/deletion-log.factory'; + +describe(DeletionLogService.name, () => { + let module: TestingModule; + let service: DeletionLogService; + let deletionLogRepo: DeepMocked; + + beforeAll(async () => { + module = await Test.createTestingModule({ + providers: [ + DeletionLogService, + { + provide: DeletionLogRepo, + useValue: createMock(), + }, + ], + }).compile(); + + service = module.get(DeletionLogService); + deletionLogRepo = module.get(DeletionLogRepo); + + await setupEntities(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + afterAll(async () => { + await module.close(); + }); + + describe('defined', () => { + it('should be defined', () => { + expect(service).toBeDefined(); + }); + }); + + describe('createDeletionRequest', () => { + describe('when creating a deletionRequest', () => { + const setup = () => { + const deletionRequestId = '653e4833cc39e5907a1e18d2'; + const domain = DeletionDomainModel.USER; + const operation = DeletionOperationModel.DELETE; + const modifiedCount = 0; + const deletedCount = 1; + + return { deletionRequestId, domain, operation, modifiedCount, deletedCount }; + }; + + it('should call deletionRequestRepo.create', async () => { + const { deletionRequestId, domain, operation, modifiedCount, deletedCount } = setup(); + + await service.createDeletionLog(deletionRequestId, domain, operation, modifiedCount, deletedCount); + + expect(deletionLogRepo.create).toHaveBeenCalledWith( + expect.objectContaining({ + id: expect.any(String), + deletionRequestId, + domain, + operation, + modifiedCount, + deletedCount, + }) + ); + }); + }); + }); + + describe('findByDeletionRequestId', () => { + describe('when finding all logs for deletionRequestId', () => { + const setup = () => { + const deletionRequestId = new ObjectId().toHexString(); + const deletionLog1 = deletionLogFactory.build({ deletionRequestId }); + const deletionLog2 = deletionLogFactory.build({ + deletionRequestId, + domain: DeletionDomainModel.PSEUDONYMS, + }); + const deletionLogs = [deletionLog1, deletionLog2]; + + deletionLogRepo.findAllByDeletionRequestId.mockResolvedValue(deletionLogs); + + return { deletionRequestId, deletionLogs }; + }; + + it('should call deletionLogRepo.findAllByDeletionRequestId', async () => { + const { deletionRequestId } = setup(); + await service.findByDeletionRequestId(deletionRequestId); + + expect(deletionLogRepo.findAllByDeletionRequestId).toBeCalledWith(deletionRequestId); + }); + + it('should return array of two deletionLogs with deletionRequestId', async () => { + const { deletionRequestId, deletionLogs } = setup(); + const result = await service.findByDeletionRequestId(deletionRequestId); + + expect(result).toHaveLength(2); + expect(result).toEqual(deletionLogs); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/services/deletion-log.service.ts b/apps/server/src/modules/deletion/services/deletion-log.service.ts new file mode 100644 index 00000000000..937d422ebb3 --- /dev/null +++ b/apps/server/src/modules/deletion/services/deletion-log.service.ts @@ -0,0 +1,37 @@ +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionLogRepo } from '../repo'; +import { DeletionLog } from '../domain/deletion-log.do'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionOperationModel } from '../domain/types/deletion-operation-model.enum'; + +@Injectable() +export class DeletionLogService { + constructor(private readonly deletionLogRepo: DeletionLogRepo) {} + + async createDeletionLog( + deletionRequestId: EntityId, + domain: DeletionDomainModel, + operation: DeletionOperationModel, + modifiedCount: number, + deletedCount: number + ): Promise { + const newDeletionLog = new DeletionLog({ + id: new ObjectId().toHexString(), + domain, + deletionRequestId, + operation, + modifiedCount, + deletedCount, + }); + + await this.deletionLogRepo.create(newDeletionLog); + } + + async findByDeletionRequestId(deletionRequestId: EntityId): Promise { + const deletionLogs: DeletionLog[] = await this.deletionLogRepo.findAllByDeletionRequestId(deletionRequestId); + + return deletionLogs; + } +} diff --git a/apps/server/src/modules/deletion/services/deletion-request.service.spec.ts b/apps/server/src/modules/deletion/services/deletion-request.service.spec.ts new file mode 100644 index 00000000000..fcccfc433db --- /dev/null +++ b/apps/server/src/modules/deletion/services/deletion-request.service.spec.ts @@ -0,0 +1,200 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { Test, TestingModule } from '@nestjs/testing'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { setupEntities } from '@shared/testing'; +import { DeletionRequestService } from './deletion-request.service'; +import { DeletionRequestRepo } from '../repo'; +import { deletionRequestFactory } from '../domain/testing/factory/deletion-request.factory'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +describe(DeletionRequestService.name, () => { + let module: TestingModule; + let service: DeletionRequestService; + let deletionRequestRepo: DeepMocked; + + beforeAll(async () => { + module = await Test.createTestingModule({ + providers: [ + DeletionRequestService, + { + provide: DeletionRequestRepo, + useValue: createMock(), + }, + ], + }).compile(); + + service = module.get(DeletionRequestService); + deletionRequestRepo = module.get(DeletionRequestRepo); + + await setupEntities(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + afterAll(async () => { + await module.close(); + }); + + describe('defined', () => { + it('should be defined', () => { + expect(service).toBeDefined(); + }); + }); + + describe('createDeletionRequest', () => { + describe('when creating a deletionRequest', () => { + const setup = () => { + const targetRefId = '653e4833cc39e5907a1e18d2'; + const targetRefDomain = DeletionDomainModel.USER; + + return { targetRefId, targetRefDomain }; + }; + + it('should call deletionRequestRepo.create', async () => { + const { targetRefId, targetRefDomain } = setup(); + + await service.createDeletionRequest(targetRefId, targetRefDomain); + + expect(deletionRequestRepo.create).toHaveBeenCalledWith( + expect.objectContaining({ + id: expect.any(String), + targetRefDomain, + deleteAfter: expect.any(Date), + targetRefId, + status: DeletionStatusModel.REGISTERED, + }) + ); + }); + }); + }); + + describe('findById', () => { + describe('when finding by deletionRequestId', () => { + const setup = () => { + const deletionRequestId = new ObjectId().toHexString(); + const deletionRequest = deletionRequestFactory.build({ id: deletionRequestId }); + + deletionRequestRepo.findById.mockResolvedValue(deletionRequest); + + return { deletionRequestId, deletionRequest }; + }; + + it('should call deletionRequestRepo.findById', async () => { + const { deletionRequestId } = setup(); + + await service.findById(deletionRequestId); + + expect(deletionRequestRepo.findById).toBeCalledWith(deletionRequestId); + }); + + it('should return deletionRequest', async () => { + const { deletionRequestId, deletionRequest } = setup(); + + const result = await service.findById(deletionRequestId); + + expect(result).toEqual(deletionRequest); + }); + }); + }); + + describe('findAllItemsToExecute', () => { + describe('when finding all deletionRequests for execution', () => { + const setup = () => { + const dateInPast = new Date(); + dateInPast.setDate(dateInPast.getDate() - 1); + const deletionRequest1 = deletionRequestFactory.build({ deleteAfter: dateInPast }); + const deletionRequest2 = deletionRequestFactory.build({ deleteAfter: dateInPast }); + + deletionRequestRepo.findAllItemsToExecution.mockResolvedValue([deletionRequest1, deletionRequest2]); + + const deletionRequests = [deletionRequest1, deletionRequest2]; + return { deletionRequests }; + }; + + it('should call deletionRequestRepo.findAllItemsByDeletionDate', async () => { + await service.findAllItemsToExecute(); + + expect(deletionRequestRepo.findAllItemsToExecution).toBeCalled(); + }); + + it('should return array of two deletionRequests to execute', async () => { + const { deletionRequests } = setup(); + const result = await service.findAllItemsToExecute(); + + expect(result).toHaveLength(2); + expect(result).toEqual(deletionRequests); + }); + }); + }); + + describe('update', () => { + describe('when updating deletionRequest', () => { + const setup = () => { + const deletionRequest = deletionRequestFactory.buildWithId(); + + return { deletionRequest }; + }; + + it('should call deletionRequestRepo.update', async () => { + const { deletionRequest } = setup(); + await service.update(deletionRequest); + + expect(deletionRequestRepo.update).toBeCalledWith(deletionRequest); + }); + }); + }); + + describe('markDeletionRequestAsExecuted', () => { + describe('when mark deletionRequest as executed', () => { + const setup = () => { + const deletionRequestId = new ObjectId().toHexString(); + + return { deletionRequestId }; + }; + + it('should call deletionRequestRepo.markDeletionRequestAsExecuted', async () => { + const { deletionRequestId } = setup(); + await service.markDeletionRequestAsExecuted(deletionRequestId); + + expect(deletionRequestRepo.markDeletionRequestAsExecuted).toBeCalledWith(deletionRequestId); + }); + }); + }); + + describe('markDeletionRequestAsFailed', () => { + describe('when mark deletionRequest as failed', () => { + const setup = () => { + const deletionRequestId = new ObjectId().toHexString(); + + return { deletionRequestId }; + }; + + it('should call deletionRequestRepo.markDeletionRequestAsExecuted', async () => { + const { deletionRequestId } = setup(); + await service.markDeletionRequestAsFailed(deletionRequestId); + + expect(deletionRequestRepo.markDeletionRequestAsFailed).toBeCalledWith(deletionRequestId); + }); + }); + }); + + describe('deleteById', () => { + describe('when deleting deletionRequest', () => { + const setup = () => { + const deletionRequestId = new ObjectId().toHexString(); + + return { deletionRequestId }; + }; + + it('should call deletionRequestRepo.findAllItemsByDeletionDate', async () => { + const { deletionRequestId } = setup(); + await service.deleteById(deletionRequestId); + + expect(deletionRequestRepo.deleteById).toBeCalledWith(deletionRequestId); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/services/deletion-request.service.ts b/apps/server/src/modules/deletion/services/deletion-request.service.ts new file mode 100644 index 00000000000..82b65521d68 --- /dev/null +++ b/apps/server/src/modules/deletion/services/deletion-request.service.ts @@ -0,0 +1,61 @@ +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { DeletionRequestRepo } from '../repo/deletion-request.repo'; +import { DeletionRequest } from '../domain/deletion-request.do'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; + +@Injectable() +export class DeletionRequestService { + constructor(private readonly deletionRequestRepo: DeletionRequestRepo) {} + + async createDeletionRequest( + targetRefId: EntityId, + targetRefDomain: DeletionDomainModel, + deleteInMinutes = 43200 + ): Promise<{ requestId: EntityId; deletionPlannedAt: Date }> { + const dateOfDeletion = new Date(); + dateOfDeletion.setMinutes(dateOfDeletion.getMinutes() + deleteInMinutes); + + const newDeletionRequest = new DeletionRequest({ + id: new ObjectId().toHexString(), + targetRefDomain, + deleteAfter: dateOfDeletion, + targetRefId, + status: DeletionStatusModel.REGISTERED, + }); + + await this.deletionRequestRepo.create(newDeletionRequest); + + return { requestId: newDeletionRequest.id, deletionPlannedAt: newDeletionRequest.deleteAfter }; + } + + async findById(deletionRequestId: EntityId): Promise { + const deletionRequest: DeletionRequest = await this.deletionRequestRepo.findById(deletionRequestId); + + return deletionRequest; + } + + async findAllItemsToExecute(limit?: number): Promise { + const itemsToDelete: DeletionRequest[] = await this.deletionRequestRepo.findAllItemsToExecution(limit); + + return itemsToDelete; + } + + async update(deletionRequestToUpdate: DeletionRequest): Promise { + await this.deletionRequestRepo.update(deletionRequestToUpdate); + } + + async markDeletionRequestAsExecuted(deletionRequestId: EntityId): Promise { + return this.deletionRequestRepo.markDeletionRequestAsExecuted(deletionRequestId); + } + + async markDeletionRequestAsFailed(deletionRequestId: EntityId): Promise { + return this.deletionRequestRepo.markDeletionRequestAsFailed(deletionRequestId); + } + + async deleteById(deletionRequestId: EntityId): Promise { + await this.deletionRequestRepo.deleteById(deletionRequestId); + } +} diff --git a/apps/server/src/modules/deletion/services/index.ts b/apps/server/src/modules/deletion/services/index.ts new file mode 100644 index 00000000000..9661354718c --- /dev/null +++ b/apps/server/src/modules/deletion/services/index.ts @@ -0,0 +1 @@ +export * from './deletion-request.service'; diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.spec.ts b/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.spec.ts new file mode 100644 index 00000000000..c2952f40f59 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.spec.ts @@ -0,0 +1,22 @@ +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; +import { DeletionLogStatisticBuilder } from './deletion-log-statistic.builder'; + +describe(DeletionLogStatisticBuilder.name, () => { + afterAll(() => { + jest.clearAllMocks(); + }); + + it('should build generic deletionLogStatistic with all attributes', () => { + // Arrange + const domain = DeletionDomainModel.PSEUDONYMS; + const modifiedCount = 0; + const deletedCount = 2; + + const result = DeletionLogStatisticBuilder.build(domain, modifiedCount, deletedCount); + + // Assert + expect(result.domain).toEqual(domain); + expect(result.modifiedCount).toEqual(modifiedCount); + expect(result.deletedCount).toEqual(deletedCount); + }); +}); diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.ts b/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.ts new file mode 100644 index 00000000000..a562505b885 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-log-statistic.builder.ts @@ -0,0 +1,10 @@ +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; +import { DeletionLogStatistic } from '../interface'; + +export class DeletionLogStatisticBuilder { + static build(domain: DeletionDomainModel, modifiedCount?: number, deletedCount?: number): DeletionLogStatistic { + const deletionLogStatistic = { domain, modifiedCount, deletedCount }; + + return deletionLogStatistic; + } +} diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.spec.ts b/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.spec.ts new file mode 100644 index 00000000000..b317a4b2221 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.spec.ts @@ -0,0 +1,28 @@ +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; +import { DeletionLogStatisticBuilder } from './deletion-log-statistic.builder'; +import { DeletionRequestLogBuilder } from './deletion-request-log.builder'; +import { DeletionTargetRefBuilder } from './deletion-target-ref.builder'; + +describe(DeletionRequestLogBuilder.name, () => { + afterAll(() => { + jest.clearAllMocks(); + }); + + it('should build generic deletionRequestLog with all attributes', () => { + // Arrange + const targetRefDomain = DeletionDomainModel.PSEUDONYMS; + const targetRefId = '653e4833cc39e5907a1e18d2'; + const targetRef = DeletionTargetRefBuilder.build(targetRefDomain, targetRefId); + const deletionPlannedAt = new Date(); + const modifiedCount = 0; + const deletedCount = 2; + const statistics = [DeletionLogStatisticBuilder.build(targetRefDomain, modifiedCount, deletedCount)]; + + const result = DeletionRequestLogBuilder.build(targetRef, deletionPlannedAt, statistics); + + // Assert + expect(result.targetRef).toEqual(targetRef); + expect(result.deletionPlannedAt).toEqual(deletionPlannedAt); + expect(result.statistics).toEqual(statistics); + }); +}); diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.ts b/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.ts new file mode 100644 index 00000000000..8247acf6776 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-request-log.builder.ts @@ -0,0 +1,13 @@ +import { DeletionLogStatistic, DeletionRequestLog, DeletionTargetRef } from '../interface'; + +export class DeletionRequestLogBuilder { + static build( + targetRef: DeletionTargetRef, + deletionPlannedAt: Date, + statistics?: DeletionLogStatistic[] + ): DeletionRequestLog { + const deletionRequestLog = { targetRef, deletionPlannedAt, statistics }; + + return deletionRequestLog; + } +} diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.spec.ts b/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.spec.ts new file mode 100644 index 00000000000..2fb4ae440a7 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.spec.ts @@ -0,0 +1,20 @@ +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; +import { DeletionTargetRefBuilder } from './deletion-target-ref.builder'; + +describe(DeletionTargetRefBuilder.name, () => { + afterAll(() => { + jest.clearAllMocks(); + }); + + it('should build generic deletionTargetRef with all attributes', () => { + // Arrange + const domain = DeletionDomainModel.PSEUDONYMS; + const refId = '653e4833cc39e5907a1e18d2'; + + const result = DeletionTargetRefBuilder.build(domain, refId); + + // Assert + expect(result.targetRefDomain).toEqual(domain); + expect(result.targetRefId).toEqual(refId); + }); +}); diff --git a/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.ts b/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.ts new file mode 100644 index 00000000000..91f3385a9aa --- /dev/null +++ b/apps/server/src/modules/deletion/uc/builder/deletion-target-ref.builder.ts @@ -0,0 +1,11 @@ +import { EntityId } from '@shared/domain'; +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; +import { DeletionTargetRef } from '../interface'; + +export class DeletionTargetRefBuilder { + static build(targetRefDomain: DeletionDomainModel, targetRefId: EntityId): DeletionTargetRef { + const deletionTargetRef = { targetRefDomain, targetRefId }; + + return deletionTargetRef; + } +} diff --git a/apps/server/src/modules/deletion/uc/deletion-request.uc.spec.ts b/apps/server/src/modules/deletion/uc/deletion-request.uc.spec.ts new file mode 100644 index 00000000000..34c34e302f5 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/deletion-request.uc.spec.ts @@ -0,0 +1,511 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { setupEntities } from '@shared/testing'; +import { AccountService } from '@modules/account/services'; +import { ClassService } from '@modules/class'; +import { CourseGroupService, CourseService } from '@modules/learnroom/service'; +import { FilesService } from '@modules/files/service'; +import { LessonService } from '@modules/lesson/service'; +import { PseudonymService } from '@modules/pseudonym'; +import { TeamService } from '@modules/teams'; +import { UserService } from '@modules/user'; +import { RocketChatService } from '@modules/rocketchat'; +import { rocketChatUserFactory } from '@modules/rocketchat-user/domain/testing'; +import { RocketChatUser, RocketChatUserService } from '@modules/rocketchat-user'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionLogService } from '../services/deletion-log.service'; +import { DeletionRequestService } from '../services'; +import { DeletionRequestUc } from './deletion-request.uc'; +import { deletionRequestFactory } from '../domain/testing/factory/deletion-request.factory'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; +import { deletionLogFactory } from '../domain/testing/factory/deletion-log.factory'; +import { DeletionRequestLog, DeletionRequestProps } from './interface'; + +describe(DeletionRequestUc.name, () => { + let module: TestingModule; + let uc: DeletionRequestUc; + let deletionRequestService: DeepMocked; + let deletionLogService: DeepMocked; + let accountService: DeepMocked; + let classService: DeepMocked; + let courseGroupService: DeepMocked; + let courseService: DeepMocked; + let filesService: DeepMocked; + let lessonService: DeepMocked; + let pseudonymService: DeepMocked; + let teamService: DeepMocked; + let userService: DeepMocked; + let rocketChatUserService: DeepMocked; + let rocketChatService: DeepMocked; + + beforeAll(async () => { + module = await Test.createTestingModule({ + providers: [ + DeletionRequestUc, + { + provide: DeletionRequestService, + useValue: createMock(), + }, + { + provide: DeletionLogService, + useValue: createMock(), + }, + { + provide: AccountService, + useValue: createMock(), + }, + { + provide: ClassService, + useValue: createMock(), + }, + { + provide: CourseGroupService, + useValue: createMock(), + }, + { + provide: CourseService, + useValue: createMock(), + }, + { + provide: FilesService, + useValue: createMock(), + }, + { + provide: LessonService, + useValue: createMock(), + }, + { + provide: PseudonymService, + useValue: createMock(), + }, + { + provide: TeamService, + useValue: createMock(), + }, + { + provide: UserService, + useValue: createMock(), + }, + { + provide: RocketChatUserService, + useValue: createMock(), + }, + { + provide: RocketChatService, + useValue: createMock(), + }, + ], + }).compile(); + + uc = module.get(DeletionRequestUc); + deletionRequestService = module.get(DeletionRequestService); + deletionLogService = module.get(DeletionLogService); + accountService = module.get(AccountService); + classService = module.get(ClassService); + courseGroupService = module.get(CourseGroupService); + courseService = module.get(CourseService); + filesService = module.get(FilesService); + lessonService = module.get(LessonService); + pseudonymService = module.get(PseudonymService); + teamService = module.get(TeamService); + userService = module.get(UserService); + rocketChatUserService = module.get(RocketChatUserService); + rocketChatService = module.get(RocketChatService); + await setupEntities(); + }); + + describe('createDeletionRequest', () => { + describe('when creating a deletionRequest', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequestToCreate: DeletionRequestProps = { + targetRef: { + targetRefDoamin: DeletionDomainModel.USER, + targetRefId: '653e4833cc39e5907a1e18d2', + }, + deleteInMinutes: 1440, + }; + const deletionRequest = deletionRequestFactory.build(); + + return { + deletionRequestToCreate, + deletionRequest, + }; + }; + + it('should call the service to create the deletionRequest', async () => { + const { deletionRequestToCreate } = setup(); + + await uc.createDeletionRequest(deletionRequestToCreate); + + expect(deletionRequestService.createDeletionRequest).toHaveBeenCalledWith( + deletionRequestToCreate.targetRef.targetRefId, + deletionRequestToCreate.targetRef.targetRefDoamin, + deletionRequestToCreate.deleteInMinutes + ); + }); + + it('should return the deletionRequestID and deletionPlannedAt', async () => { + const { deletionRequestToCreate, deletionRequest } = setup(); + + deletionRequestService.createDeletionRequest.mockResolvedValueOnce({ + requestId: deletionRequest.id, + deletionPlannedAt: deletionRequest.deleteAfter, + }); + + const result = await uc.createDeletionRequest(deletionRequestToCreate); + + expect(result).toEqual({ + requestId: deletionRequest.id, + deletionPlannedAt: deletionRequest.deleteAfter, + }); + }); + }); + }); + + describe('executeDeletionRequests', () => { + describe('when executing deletionRequests', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequestToExecute = deletionRequestFactory.build({ deleteAfter: new Date('2023-01-01') }); + const rocketChatUser: RocketChatUser = rocketChatUserFactory.build({ + userId: deletionRequestToExecute.targetRefId, + }); + + classService.deleteUserDataFromClasses.mockResolvedValueOnce(1); + courseGroupService.deleteUserDataFromCourseGroup.mockResolvedValueOnce(2); + courseService.deleteUserDataFromCourse.mockResolvedValueOnce(2); + filesService.markFilesOwnedByUserForDeletion.mockResolvedValueOnce(2); + filesService.removeUserPermissionsToAnyFiles.mockResolvedValueOnce(2); + lessonService.deleteUserDataFromLessons.mockResolvedValueOnce(2); + pseudonymService.deleteByUserId.mockResolvedValueOnce(2); + teamService.deleteUserDataFromTeams.mockResolvedValueOnce(2); + userService.deleteUser.mockResolvedValueOnce(1); + rocketChatUserService.deleteByUserId.mockResolvedValueOnce(1); + + return { + deletionRequestToExecute, + rocketChatUser, + }; + }; + + it('should call deletionRequestService.findAllItemsToExecute', async () => { + await uc.executeDeletionRequests(); + + expect(deletionRequestService.findAllItemsToExecute).toHaveBeenCalled(); + }); + + it('should call deletionRequestService.markDeletionRequestAsExecuted to update status of deletionRequests', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(deletionRequestService.markDeletionRequestAsExecuted).toHaveBeenCalledWith(deletionRequestToExecute.id); + }); + + it('should call accountService.deleteByUserId to delete user data in account module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(accountService.deleteByUserId).toHaveBeenCalled(); + }); + + it('should call classService.deleteUserDataFromClasses to delete user data in class module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(classService.deleteUserDataFromClasses).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call courseGroupService.deleteUserDataFromCourseGroup to delete user data in courseGroup module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(courseGroupService.deleteUserDataFromCourseGroup).toHaveBeenCalledWith( + deletionRequestToExecute.targetRefId + ); + }); + + it('should call courseService.deleteUserDataFromCourse to delete user data in course module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(courseService.deleteUserDataFromCourse).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call filesService.markFilesOwnedByUserForDeletion to mark users files to delete in file module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(filesService.markFilesOwnedByUserForDeletion).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call filesService.removeUserPermissionsToAnyFiles to remove users permissions to any files in file module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(filesService.removeUserPermissionsToAnyFiles).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call lessonService.deleteUserDataFromLessons to delete users data in lesson module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(lessonService.deleteUserDataFromLessons).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call pseudonymService.deleteByUserId to delete users data in pseudonym module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(pseudonymService.deleteByUserId).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call teamService.deleteUserDataFromTeams to delete users data in teams module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(teamService.deleteUserDataFromTeams).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call userService.deleteUsers to delete user in user module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(userService.deleteUser).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call rocketChatUserService.findByUserId to find rocketChatUser in rocketChatUser module', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(rocketChatUserService.findByUserId).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call rocketChatUserService.deleteByUserId to delete rocketChatUser in rocketChatUser module', async () => { + const { deletionRequestToExecute, rocketChatUser } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + rocketChatUserService.findByUserId.mockResolvedValueOnce(rocketChatUser); + + await uc.executeDeletionRequests(); + + expect(rocketChatUserService.deleteByUserId).toHaveBeenCalledWith(deletionRequestToExecute.targetRefId); + }); + + it('should call rocketChatService.deleteUser to delete rocketChatUser in rocketChat external module', async () => { + const { deletionRequestToExecute, rocketChatUser } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + rocketChatUserService.findByUserId.mockResolvedValueOnce(rocketChatUser); + + await uc.executeDeletionRequests(); + + expect(rocketChatService.deleteUser).toHaveBeenCalledWith(rocketChatUser.username); + }); + + it('should call deletionLogService.createDeletionLog to create logs for deletionRequest', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(deletionLogService.createDeletionLog).toHaveBeenCalledTimes(9); + }); + }); + + describe('when an error occurred', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequestToExecute = deletionRequestFactory.build({ deleteAfter: new Date('2023-01-01') }); + + classService.deleteUserDataFromClasses.mockResolvedValueOnce(1); + courseGroupService.deleteUserDataFromCourseGroup.mockResolvedValueOnce(2); + courseService.deleteUserDataFromCourse.mockResolvedValueOnce(2); + filesService.markFilesOwnedByUserForDeletion.mockResolvedValueOnce(2); + filesService.removeUserPermissionsToAnyFiles.mockResolvedValueOnce(2); + lessonService.deleteUserDataFromLessons.mockResolvedValueOnce(2); + pseudonymService.deleteByUserId.mockResolvedValueOnce(2); + teamService.deleteUserDataFromTeams.mockResolvedValueOnce(2); + userService.deleteUser.mockRejectedValueOnce(new Error()); + + return { + deletionRequestToExecute, + }; + }; + + it('should throw an arror', async () => { + const { deletionRequestToExecute } = setup(); + + deletionRequestService.findAllItemsToExecute.mockResolvedValueOnce([deletionRequestToExecute]); + + await uc.executeDeletionRequests(); + + expect(deletionRequestService.markDeletionRequestAsFailed).toHaveBeenCalledWith(deletionRequestToExecute.id); + }); + }); + }); + + describe('findById', () => { + describe('when searching for logs for deletionRequest which was executed', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequestExecuted = deletionRequestFactory.build({ status: DeletionStatusModel.SUCCESS }); + const deletionLogExecuted1 = deletionLogFactory.build({ deletionRequestId: deletionRequestExecuted.id }); + const deletionLogExecuted2 = deletionLogFactory.build({ + deletionRequestId: deletionRequestExecuted.id, + domain: DeletionDomainModel.ACCOUNT, + modifiedCount: 0, + deletedCount: 1, + }); + + const executedDeletionRequestSummary: DeletionRequestLog = { + targetRef: { + targetRefDomain: deletionRequestExecuted.targetRefDomain, + targetRefId: deletionRequestExecuted.targetRefId, + }, + deletionPlannedAt: deletionRequestExecuted.deleteAfter, + statistics: [ + { + domain: deletionLogExecuted1.domain, + modifiedCount: deletionLogExecuted1.modifiedCount, + deletedCount: deletionLogExecuted1.deletedCount, + }, + { + domain: deletionLogExecuted2.domain, + modifiedCount: deletionLogExecuted2.modifiedCount, + deletedCount: deletionLogExecuted2.deletedCount, + }, + ], + }; + + return { + deletionRequestExecuted, + executedDeletionRequestSummary, + deletionLogExecuted1, + deletionLogExecuted2, + }; + }; + + it('should call to deletionRequestService and deletionLogService', async () => { + const { deletionRequestExecuted } = setup(); + + deletionRequestService.findById.mockResolvedValueOnce(deletionRequestExecuted); + + await uc.findById(deletionRequestExecuted.id); + + expect(deletionRequestService.findById).toHaveBeenCalledWith(deletionRequestExecuted.id); + expect(deletionLogService.findByDeletionRequestId).toHaveBeenCalledWith(deletionRequestExecuted.id); + }); + + it('should return object with summary of deletionRequest', async () => { + const { deletionRequestExecuted, deletionLogExecuted1, deletionLogExecuted2, executedDeletionRequestSummary } = + setup(); + + deletionRequestService.findById.mockResolvedValueOnce(deletionRequestExecuted); + deletionLogService.findByDeletionRequestId.mockResolvedValueOnce([deletionLogExecuted1, deletionLogExecuted2]); + + const result = await uc.findById(deletionRequestExecuted.id); + + expect(result).toEqual(executedDeletionRequestSummary); + }); + }); + + describe('when searching for logs for deletionRequest which was not executed', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequest = deletionRequestFactory.build(); + const notExecutedDeletionRequestSummary: DeletionRequestLog = { + targetRef: { + targetRefDomain: deletionRequest.targetRefDomain, + targetRefId: deletionRequest.targetRefId, + }, + deletionPlannedAt: deletionRequest.deleteAfter, + }; + + return { + deletionRequest, + notExecutedDeletionRequestSummary, + }; + }; + + it('should call to deletionRequestService', async () => { + const { deletionRequest } = setup(); + + deletionRequestService.findById.mockResolvedValueOnce(deletionRequest); + + await uc.findById(deletionRequest.id); + + expect(deletionRequestService.findById).toHaveBeenCalledWith(deletionRequest.id); + expect(deletionLogService.findByDeletionRequestId).not.toHaveBeenCalled(); + }); + + it('should return object with summary of deletionRequest', async () => { + const { deletionRequest, notExecutedDeletionRequestSummary } = setup(); + + deletionRequestService.findById.mockResolvedValueOnce(deletionRequest); + + const result = await uc.findById(deletionRequest.id); + + expect(result).toEqual(notExecutedDeletionRequestSummary); + }); + }); + }); + + describe('deleteDeletionRequestById', () => { + describe('when deleting a deletionRequestId', () => { + const setup = () => { + jest.clearAllMocks(); + const deletionRequest = deletionRequestFactory.build(); + + return { + deletionRequest, + }; + }; + + it('should call the service deletionRequestService.deleteById', async () => { + const { deletionRequest } = setup(); + + await uc.deleteDeletionRequestById(deletionRequest.id); + + expect(deletionRequestService.deleteById).toHaveBeenCalledWith(deletionRequest.id); + }); + }); + }); +}); diff --git a/apps/server/src/modules/deletion/uc/deletion-request.uc.ts b/apps/server/src/modules/deletion/uc/deletion-request.uc.ts new file mode 100644 index 00000000000..abea56fda96 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/deletion-request.uc.ts @@ -0,0 +1,225 @@ +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { PseudonymService } from '@modules/pseudonym'; +import { UserService } from '@modules/user'; +import { TeamService } from '@modules/teams'; +import { ClassService } from '@modules/class'; +import { LessonService } from '@modules/lesson/service'; +import { CourseGroupService, CourseService } from '@modules/learnroom/service'; +import { FilesService } from '@modules/files/service'; +import { AccountService } from '@modules/account/services'; +import { RocketChatUserService } from '@modules/rocketchat-user'; +import { RocketChatService } from '@modules/rocketchat'; +import { DeletionRequestService } from '../services/deletion-request.service'; +import { DeletionDomainModel } from '../domain/types/deletion-domain-model.enum'; +import { DeletionLogService } from '../services/deletion-log.service'; +import { DeletionRequest } from '../domain/deletion-request.do'; +import { DeletionOperationModel } from '../domain/types/deletion-operation-model.enum'; +import { DeletionStatusModel } from '../domain/types/deletion-status-model.enum'; +import { DeletionLog } from '../domain/deletion-log.do'; +import { + DeletionRequestProps, + DeletionRequestLog, + DeletionLogStatistic, + DeletionRequestCreateAnswer, +} from './interface/interfaces'; +import { DeletionLogStatisticBuilder } from './builder/deletion-log-statistic.builder'; +import { DeletionRequestLogBuilder } from './builder/deletion-request-log.builder'; +import { DeletionTargetRefBuilder } from './builder/deletion-target-ref.builder'; + +@Injectable() +export class DeletionRequestUc { + constructor( + private readonly deletionRequestService: DeletionRequestService, + private readonly deletionLogService: DeletionLogService, + private readonly accountService: AccountService, + private readonly classService: ClassService, + private readonly courseGroupService: CourseGroupService, + private readonly courseService: CourseService, + private readonly filesService: FilesService, + private readonly lessonService: LessonService, + private readonly pseudonymService: PseudonymService, + private readonly teamService: TeamService, + private readonly userService: UserService, + private readonly rocketChatUserService: RocketChatUserService, + private readonly rocketChatService: RocketChatService + ) {} + + async createDeletionRequest(deletionRequest: DeletionRequestProps): Promise { + const result = await this.deletionRequestService.createDeletionRequest( + deletionRequest.targetRef.targetRefId, + deletionRequest.targetRef.targetRefDoamin, + deletionRequest.deleteInMinutes + ); + + return result; + } + + async executeDeletionRequests(limit?: number): Promise { + const deletionRequestToExecution: DeletionRequest[] = await this.deletionRequestService.findAllItemsToExecute( + limit + ); + + for (const req of deletionRequestToExecution) { + // eslint-disable-next-line no-await-in-loop + await this.executeDeletionRequest(req); + } + } + + async findById(deletionRequestId: EntityId): Promise { + const deletionRequest: DeletionRequest = await this.deletionRequestService.findById(deletionRequestId); + let response: DeletionRequestLog = DeletionRequestLogBuilder.build( + DeletionTargetRefBuilder.build(deletionRequest.targetRefDomain, deletionRequest.targetRefId), + deletionRequest.deleteAfter + ); + + if (deletionRequest.status === DeletionStatusModel.SUCCESS) { + const deletionLog: DeletionLog[] = await this.deletionLogService.findByDeletionRequestId(deletionRequestId); + const deletionLogStatistic: DeletionLogStatistic[] = deletionLog.map((log) => + DeletionLogStatisticBuilder.build(log.domain, log.modifiedCount, log.deletedCount) + ); + response = { ...response, statistics: deletionLogStatistic }; + } + + return response; + } + + async deleteDeletionRequestById(deletionRequestId: EntityId): Promise { + await this.deletionRequestService.deleteById(deletionRequestId); + } + + private async executeDeletionRequest(deletionRequest: DeletionRequest): Promise { + try { + await Promise.all([ + this.removeAccount(deletionRequest), + this.removeUserFromClasses(deletionRequest), + this.removeUserFromCourseGroup(deletionRequest), + this.removeUserFromCourse(deletionRequest), + this.removeUsersFilesAndPermissions(deletionRequest), + this.removeUserFromLessons(deletionRequest), + this.removeUsersPseudonyms(deletionRequest), + this.removeUserFromTeams(deletionRequest), + this.removeUser(deletionRequest), + this.removeUserFromRocketChat(deletionRequest), + ]); + await this.deletionRequestService.markDeletionRequestAsExecuted(deletionRequest.id); + } catch (error) { + await this.deletionRequestService.markDeletionRequestAsFailed(deletionRequest.id); + } + } + + private async logDeletion( + deletionRequest: DeletionRequest, + domainModel: DeletionDomainModel, + operationModel: DeletionOperationModel, + updatedCount: number, + deletedCount: number + ): Promise { + if (updatedCount > 0 || deletedCount > 0) { + await this.deletionLogService.createDeletionLog( + deletionRequest.id, + domainModel, + operationModel, + updatedCount, + deletedCount + ); + } + } + + private async removeAccount(deletionRequest: DeletionRequest) { + await this.accountService.deleteByUserId(deletionRequest.targetRefId); + await this.logDeletion(deletionRequest, DeletionDomainModel.ACCOUNT, DeletionOperationModel.DELETE, 0, 1); + } + + private async removeUserFromClasses(deletionRequest: DeletionRequest) { + const classesUpdated: number = await this.classService.deleteUserDataFromClasses(deletionRequest.targetRefId); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.CLASS, + DeletionOperationModel.UPDATE, + classesUpdated, + 0 + ); + } + + private async removeUserFromCourseGroup(deletionRequest: DeletionRequest) { + const courseGroupUpdated: number = await this.courseGroupService.deleteUserDataFromCourseGroup( + deletionRequest.targetRefId + ); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.COURSEGROUP, + DeletionOperationModel.UPDATE, + courseGroupUpdated, + 0 + ); + } + + private async removeUserFromCourse(deletionRequest: DeletionRequest) { + const courseUpdated: number = await this.courseService.deleteUserDataFromCourse(deletionRequest.targetRefId); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.COURSE, + DeletionOperationModel.UPDATE, + courseUpdated, + 0 + ); + } + + private async removeUsersFilesAndPermissions(deletionRequest: DeletionRequest) { + const filesDeleted: number = await this.filesService.markFilesOwnedByUserForDeletion(deletionRequest.targetRefId); + const filePermissionsUpdated: number = await this.filesService.removeUserPermissionsToAnyFiles( + deletionRequest.targetRefId + ); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.FILE, + DeletionOperationModel.UPDATE, + filesDeleted + filePermissionsUpdated, + 0 + ); + } + + private async removeUserFromLessons(deletionRequest: DeletionRequest) { + const lessonsUpdated: number = await this.lessonService.deleteUserDataFromLessons(deletionRequest.targetRefId); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.LESSONS, + DeletionOperationModel.UPDATE, + lessonsUpdated, + 0 + ); + } + + private async removeUsersPseudonyms(deletionRequest: DeletionRequest) { + const pseudonymDeleted: number = await this.pseudonymService.deleteByUserId(deletionRequest.targetRefId); + await this.logDeletion( + deletionRequest, + DeletionDomainModel.PSEUDONYMS, + DeletionOperationModel.DELETE, + 0, + pseudonymDeleted + ); + } + + private async removeUserFromTeams(deletionRequest: DeletionRequest) { + const teamsUpdated: number = await this.teamService.deleteUserDataFromTeams(deletionRequest.targetRefId); + await this.logDeletion(deletionRequest, DeletionDomainModel.TEAMS, DeletionOperationModel.UPDATE, teamsUpdated, 0); + } + + private async removeUser(deletionRequest: DeletionRequest) { + const userDeleted: number = await this.userService.deleteUser(deletionRequest.targetRefId); + await this.logDeletion(deletionRequest, DeletionDomainModel.USER, DeletionOperationModel.DELETE, 0, userDeleted); + } + + private async removeUserFromRocketChat(deletionRequest: DeletionRequest): Promise { + const rocketChatUser = await this.rocketChatUserService.findByUserId(deletionRequest.targetRefId); + + const [, rocketChatUserDeleted] = await Promise.all([ + this.rocketChatService.deleteUser(rocketChatUser.username), + this.rocketChatUserService.deleteByUserId(rocketChatUser.userId), + ]); + + return rocketChatUserDeleted; + } +} diff --git a/apps/server/src/modules/deletion/uc/interface/index.ts b/apps/server/src/modules/deletion/uc/interface/index.ts new file mode 100644 index 00000000000..95786098275 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/interface/index.ts @@ -0,0 +1 @@ +export * from './interfaces'; diff --git a/apps/server/src/modules/deletion/uc/interface/interfaces.ts b/apps/server/src/modules/deletion/uc/interface/interfaces.ts new file mode 100644 index 00000000000..47f4d887735 --- /dev/null +++ b/apps/server/src/modules/deletion/uc/interface/interfaces.ts @@ -0,0 +1,29 @@ +import { EntityId } from '@shared/domain'; +import { DeletionDomainModel } from '../../domain/types/deletion-domain-model.enum'; + +export interface DeletionTargetRef { + targetRefDomain: DeletionDomainModel; + targetRefId: EntityId; +} + +export interface DeletionRequestLog { + targetRef: DeletionTargetRef; + deletionPlannedAt: Date; + statistics?: DeletionLogStatistic[]; +} + +export interface DeletionLogStatistic { + domain: DeletionDomainModel; + modifiedCount?: number; + deletedCount?: number; +} + +export interface DeletionRequestProps { + targetRef: { targetRefDoamin: DeletionDomainModel; targetRefId: EntityId }; + deleteInMinutes?: number; +} + +export interface DeletionRequestCreateAnswer { + requestId: EntityId; + deletionPlannedAt: Date; +} diff --git a/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts b/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts index 509eee7f49f..0017e0aaa42 100644 --- a/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts +++ b/apps/server/src/modules/files-storage-client/dto/file.dto.spec.ts @@ -1,4 +1,4 @@ -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { FileDto } from './file.dto'; describe('FileDto', () => { diff --git a/apps/server/src/modules/files-storage-client/dto/file.dto.ts b/apps/server/src/modules/files-storage-client/dto/file.dto.ts index 5ac6e76181f..38d6daf4c3b 100644 --- a/apps/server/src/modules/files-storage-client/dto/file.dto.ts +++ b/apps/server/src/modules/files-storage-client/dto/file.dto.ts @@ -1,5 +1,5 @@ import { EntityId } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { IFileDomainObjectProps } from '../interfaces'; export class FileDto { diff --git a/apps/server/src/modules/files-storage-client/interfaces/file-domain-object-props.ts b/apps/server/src/modules/files-storage-client/interfaces/file-domain-object-props.ts index 35513f27b02..f302e53e9a0 100644 --- a/apps/server/src/modules/files-storage-client/interfaces/file-domain-object-props.ts +++ b/apps/server/src/modules/files-storage-client/interfaces/file-domain-object-props.ts @@ -1,5 +1,5 @@ import { EntityId } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; export interface IFileDomainObjectProps { id: EntityId; diff --git a/apps/server/src/modules/files-storage-client/interfaces/file-request-info.ts b/apps/server/src/modules/files-storage-client/interfaces/file-request-info.ts index d45df0aef3d..12a7898d9cf 100644 --- a/apps/server/src/modules/files-storage-client/interfaces/file-request-info.ts +++ b/apps/server/src/modules/files-storage-client/interfaces/file-request-info.ts @@ -1,5 +1,5 @@ import { EntityId } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; export interface IFileRequestInfo { schoolId: EntityId; diff --git a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts index 9cb8f09553f..ccce67a089a 100644 --- a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.spec.ts @@ -1,5 +1,5 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { lessonFactory, setupEntities, taskFactory } from '@shared/testing'; import { CopyFilesOfParentParamBuilder } from './copy-files-of-parent-param.builder'; import { FileParamBuilder } from './files-storage-param.builder'; diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts index 2a7d100ca86..f48d66dce48 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.spec.ts @@ -1,4 +1,4 @@ -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { ICopyFileDomainObjectProps, IFileDomainObjectProps } from '../interfaces'; import { FilesStorageClientMapper } from './files-storage-client.mapper'; diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.ts index 2c73ec3824e..233e47fd4c8 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-client.mapper.ts @@ -1,5 +1,5 @@ import { LessonEntity, Submission, Task } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { CopyFileDto, FileDto } from '../dto'; import { EntitiesWithFiles, ICopyFileDomainObjectProps, IFileDomainObjectProps } from '../interfaces'; diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts index 72a639620f1..23ce4f7e175 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.spec.ts @@ -1,4 +1,4 @@ -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { lessonFactory, setupEntities, taskFactory } from '@shared/testing'; import { FileParamBuilder } from './files-storage-param.builder'; diff --git a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts index 7e4ed5a1c83..ef2ac9c9d1d 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage.producer.spec.ts @@ -3,7 +3,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { ErrorMapper, FileRecordParentType, FilesStorageEvents, FilesStorageExchange } from '@shared/infra/rabbitmq'; +import { ErrorMapper, FileRecordParentType, FilesStorageEvents, FilesStorageExchange } from '@infra/rabbitmq'; import { setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FilesStorageProducer } from './files-storage.producer'; diff --git a/apps/server/src/modules/files-storage-client/service/files-storage.producer.ts b/apps/server/src/modules/files-storage-client/service/files-storage.producer.ts index ea049442df4..34927c01831 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage.producer.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage.producer.ts @@ -11,7 +11,7 @@ import { IFileDO, IFileRecordParams, RpcMessageProducer, -} from '@src/shared/infra/rabbitmq'; +} from '@infra/rabbitmq'; import { IFilesStorageClientConfig } from '../interfaces'; @Injectable() diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-copy-files.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-copy-files.api.spec.ts index 22a7a11fb5b..4a966165633 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-copy-files.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-copy-files.api.spec.ts @@ -6,8 +6,8 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, courseFactory, diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-delete-files.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-delete-files.api.spec.ts index 0557843b8eb..6c1087ce371 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-delete-files.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-delete-files.api.spec.ts @@ -6,8 +6,8 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, fileRecordFactory, diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-download-upload.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-download-upload.api.spec.ts index a3d601db829..7a69f279b60 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-download-upload.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-download-upload.api.spec.ts @@ -7,8 +7,8 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import NodeClam from 'clamscan'; import { Request } from 'express'; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-preview.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-preview.api.spec.ts index e87aa5ddbe6..f63eef6ac68 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-preview.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-preview.api.spec.ts @@ -6,9 +6,9 @@ import { ExecutionContext, INestApplication, NotFoundException, StreamableFile } import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { PreviewProducer } from '@shared/infra/preview-generator'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { PreviewProducer } from '@infra/preview-generator'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import NodeClam from 'clamscan'; import { Request } from 'express'; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-restore-files.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-restore-files.api.spec.ts index 496f399d41b..9e666437748 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-restore-files.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-restore-files.api.spec.ts @@ -6,8 +6,8 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, fileRecordFactory, diff --git a/apps/server/src/modules/files-storage/controller/dto/file-storage.params.ts b/apps/server/src/modules/files-storage/controller/dto/file-storage.params.ts index 6555b7bd0f9..913a259e9c3 100644 --- a/apps/server/src/modules/files-storage/controller/dto/file-storage.params.ts +++ b/apps/server/src/modules/files-storage/controller/dto/file-storage.params.ts @@ -1,7 +1,7 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { StringToBoolean } from '@shared/controller'; import { EntityId } from '@shared/domain'; -import { ScanResult } from '@shared/infra/antivirus'; +import { ScanResult } from '@infra/antivirus'; import { Allow, IsBoolean, IsEnum, IsMongoId, IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator'; import { FileRecordParentType } from '../../entity'; import { PreviewOutputMimeTypes, PreviewWidth } from '../../interface'; diff --git a/apps/server/src/modules/files-storage/controller/files-storage.consumer.ts b/apps/server/src/modules/files-storage/controller/files-storage.consumer.ts index aabefa60f16..fc500fedee1 100644 --- a/apps/server/src/modules/files-storage/controller/files-storage.consumer.ts +++ b/apps/server/src/modules/files-storage/controller/files-storage.consumer.ts @@ -2,9 +2,9 @@ import { RabbitPayload, RabbitRPC } from '@golevelup/nestjs-rabbitmq'; import { MikroORM, UseRequestContext } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; -import { RpcMessage } from '@shared/infra/rabbitmq/rpc-message'; +import { RpcMessage } from '@infra/rabbitmq/rpc-message'; import { LegacyLogger } from '@src/core/logger'; -import { FilesStorageEvents, FilesStorageExchange, ICopyFileDO, IFileDO } from '@src/shared/infra/rabbitmq'; +import { FilesStorageEvents, FilesStorageExchange, ICopyFileDO, IFileDO } from '@infra/rabbitmq'; import { FilesStorageMapper } from '../mapper'; import { FilesStorageService } from '../service/files-storage.service'; import { PreviewService } from '../service/preview.service'; diff --git a/apps/server/src/modules/files-storage/dto/file.dto.ts b/apps/server/src/modules/files-storage/dto/file.dto.ts index 9668ac3af72..ecdc3a73296 100644 --- a/apps/server/src/modules/files-storage/dto/file.dto.ts +++ b/apps/server/src/modules/files-storage/dto/file.dto.ts @@ -1,4 +1,4 @@ -import { File } from '@shared/infra/s3-client'; +import { File } from '@infra/s3-client'; import { Readable } from 'stream'; export class FileDto implements File { diff --git a/apps/server/src/modules/files-storage/files-preview-amqp.module.ts b/apps/server/src/modules/files-storage/files-preview-amqp.module.ts index 411a26e76d6..78a1aec0129 100644 --- a/apps/server/src/modules/files-storage/files-preview-amqp.module.ts +++ b/apps/server/src/modules/files-storage/files-preview-amqp.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { PreviewGeneratorConsumerModule } from '@shared/infra/preview-generator'; +import { PreviewGeneratorConsumerModule } from '@infra/preview-generator'; import { defaultConfig, s3Config } from './files-storage.config'; @Module({ diff --git a/apps/server/src/modules/files-storage/files-storage-test.module.ts b/apps/server/src/modules/files-storage/files-storage-test.module.ts index 6f3d865ebb2..f219c8bccac 100644 --- a/apps/server/src/modules/files-storage/files-storage-test.module.ts +++ b/apps/server/src/modules/files-storage/files-storage-test.module.ts @@ -1,11 +1,10 @@ import { DynamicModule, Module } from '@nestjs/common'; import { ALL_ENTITIES } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types'; -import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq/rabbitmq.module'; +import { MongoMemoryDatabaseModule, MongoDatabaseModuleOptions } from '@infra/database'; +import { RabbitMQWrapperTestModule } from '@infra/rabbitmq'; import { CoreModule } from '@src/core'; import { LoggerModule } from '@src/core/logger'; -import { AuthenticationModule } from '@modules/authentication/authentication.module'; +import { AuthenticationModule } from '@modules/authentication'; import { AuthorizationModule } from '@modules/authorization'; import { FileRecord } from './entity'; import { FilesStorageApiModule } from './files-storage-api.module'; diff --git a/apps/server/src/modules/files-storage/files-storage.config.ts b/apps/server/src/modules/files-storage/files-storage.config.ts index 7fac8ded763..985b07f0ef1 100644 --- a/apps/server/src/modules/files-storage/files-storage.config.ts +++ b/apps/server/src/modules/files-storage/files-storage.config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import { S3Config } from '@shared/infra/s3-client'; +import { S3Config } from '@infra/s3-client'; import { ICoreModuleConfig } from '@src/core'; export const FILES_STORAGE_S3_CONNECTION = 'FILES_STORAGE_S3_CONNECTION'; diff --git a/apps/server/src/modules/files-storage/files-storage.module.ts b/apps/server/src/modules/files-storage/files-storage.module.ts index ccdaeb7f9fa..a7432172a21 100644 --- a/apps/server/src/modules/files-storage/files-storage.module.ts +++ b/apps/server/src/modules/files-storage/files-storage.module.ts @@ -4,17 +4,16 @@ import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ALL_ENTITIES } from '@shared/domain'; -import { AntivirusModule } from '@shared/infra/antivirus/antivirus.module'; -import { PreviewGeneratorProducerModule } from '@shared/infra/preview-generator'; -import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq/rabbitmq.module'; -import { S3ClientModule } from '@shared/infra/s3-client'; +import { AntivirusModule } from '@infra/antivirus'; +import { PreviewGeneratorProducerModule } from '@infra/preview-generator'; +import { RabbitMQWrapperModule } from '@infra/rabbitmq'; +import { S3ClientModule } from '@infra/s3-client'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; import { LoggerModule } from '@src/core/logger'; import { FileRecord, FileRecordSecurityCheck } from './entity'; import { config, s3Config } from './files-storage.config'; import { FileRecordRepo } from './repo'; -import { FilesStorageService } from './service/files-storage.service'; -import { PreviewService } from './service/preview.service'; +import { FilesStorageService, PreviewService } from './service'; const imports = [ LoggerModule, diff --git a/apps/server/src/modules/files-storage/helper/path.ts b/apps/server/src/modules/files-storage/helper/path.ts index 3ae81aef62d..f11a3ce7b2a 100644 --- a/apps/server/src/modules/files-storage/helper/path.ts +++ b/apps/server/src/modules/files-storage/helper/path.ts @@ -1,5 +1,5 @@ import { EntityId } from '@shared/domain'; -import { CopyFiles } from '@shared/infra/s3-client'; +import { CopyFiles } from '@infra/s3-client'; import { FileRecord } from '../entity'; import { ErrorType } from '../error'; diff --git a/apps/server/src/modules/files-storage/helper/test-helper.ts b/apps/server/src/modules/files-storage/helper/test-helper.ts index a66bec17de2..77671a2d552 100644 --- a/apps/server/src/modules/files-storage/helper/test-helper.ts +++ b/apps/server/src/modules/files-storage/helper/test-helper.ts @@ -1,4 +1,4 @@ -import { GetFile } from '@shared/infra/s3-client'; +import { GetFile } from '@infra/s3-client'; import { Readable } from 'stream'; import { GetFileResponse } from '../interface'; diff --git a/apps/server/src/modules/files-storage/mapper/file-response.builder.ts b/apps/server/src/modules/files-storage/mapper/file-response.builder.ts index 02344e4b3cb..7ad856deb97 100644 --- a/apps/server/src/modules/files-storage/mapper/file-response.builder.ts +++ b/apps/server/src/modules/files-storage/mapper/file-response.builder.ts @@ -1,4 +1,4 @@ -import { GetFile } from '@shared/infra/s3-client'; +import { GetFile } from '@infra/s3-client'; import { GetFileResponse } from '../interface'; export class FileResponseBuilder { diff --git a/apps/server/src/modules/files-storage/mapper/preview.builder.ts b/apps/server/src/modules/files-storage/mapper/preview.builder.ts index 83a16448a98..aea85be53d8 100644 --- a/apps/server/src/modules/files-storage/mapper/preview.builder.ts +++ b/apps/server/src/modules/files-storage/mapper/preview.builder.ts @@ -1,4 +1,4 @@ -import { PreviewFileOptions } from '@shared/infra/preview-generator'; +import { PreviewFileOptions } from '@infra/preview-generator'; import { PreviewParams } from '../controller/dto'; import { FileRecord } from '../entity'; import { createPath, createPreviewFilePath, createPreviewNameHash, getFormat } from '../helper'; diff --git a/apps/server/src/modules/files-storage/repo/filerecord.repo.integration.spec.ts b/apps/server/src/modules/files-storage/repo/filerecord.repo.integration.spec.ts index 735359db012..d1dbe490c25 100644 --- a/apps/server/src/modules/files-storage/repo/filerecord.repo.integration.spec.ts +++ b/apps/server/src/modules/files-storage/repo/filerecord.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { cleanupCollections, fileRecordFactory } from '@shared/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { FileRecord, FileRecordParentType } from '../entity'; import { FileRecordRepo } from './filerecord.repo'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-copy.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-copy.service.spec.ts index 4ba05e540a8..51e2535e557 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-copy.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-copy.service.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-delete.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-delete.service.spec.ts index 3705f93b51c..353b77837d9 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-delete.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-delete.service.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { InternalServerErrorException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts index bcee168c2b9..4c5f08e39ef 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-download.service.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { NotAcceptableException, NotFoundException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { GetFile, S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { GetFile, S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-get.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-get.service.spec.ts index 95f7c2d204c..546ac842799 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-get.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-get.service.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams, SingleFileParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-restore.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-restore.service.spec.ts index c82f96074f1..3b6dec255fa 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-restore.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-restore.service.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-update.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-update.service.spec.ts index 8523c7388fd..eefd8176169 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-update.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-update.service.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { ConflictException, NotFoundException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import _ from 'lodash'; diff --git a/apps/server/src/modules/files-storage/service/files-storage-upload.service.spec.ts b/apps/server/src/modules/files-storage/service/files-storage-upload.service.spec.ts index 022e6a4bf0d..765de1077bd 100644 --- a/apps/server/src/modules/files-storage/service/files-storage-upload.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/files-storage-upload.service.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { BadRequestException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { readableStreamWithFileTypeFactory } from '@shared/testing/factory/readable-stream-with-file-type.factory'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/modules/files-storage/service/files-storage.service.ts b/apps/server/src/modules/files-storage/service/files-storage.service.ts index 209f1804d3e..6eb9e89ea96 100644 --- a/apps/server/src/modules/files-storage/service/files-storage.service.ts +++ b/apps/server/src/modules/files-storage/service/files-storage.service.ts @@ -8,8 +8,8 @@ import { } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Counted, EntityId } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { LegacyLogger } from '@src/core/logger'; import FileType from 'file-type-cjs/file-type-cjs-index'; import { PassThrough, Readable } from 'stream'; diff --git a/apps/server/src/modules/files-storage/service/index.ts b/apps/server/src/modules/files-storage/service/index.ts new file mode 100644 index 00000000000..f5f1eb61392 --- /dev/null +++ b/apps/server/src/modules/files-storage/service/index.ts @@ -0,0 +1,2 @@ +export * from './files-storage.service'; +export * from './preview.service'; diff --git a/apps/server/src/modules/files-storage/service/preview.service.spec.ts b/apps/server/src/modules/files-storage/service/preview.service.spec.ts index f02f48aee21..a5fed69ef51 100644 --- a/apps/server/src/modules/files-storage/service/preview.service.spec.ts +++ b/apps/server/src/modules/files-storage/service/preview.service.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { NotFoundException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { PreviewProducer } from '@shared/infra/preview-generator'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { PreviewProducer } from '@infra/preview-generator'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/service/preview.service.ts b/apps/server/src/modules/files-storage/service/preview.service.ts index e27fbc0645a..0a9ba63e8e1 100644 --- a/apps/server/src/modules/files-storage/service/preview.service.ts +++ b/apps/server/src/modules/files-storage/service/preview.service.ts @@ -1,6 +1,6 @@ import { Inject, Injectable, NotFoundException, UnprocessableEntityException } from '@nestjs/common'; -import { PreviewProducer } from '@shared/infra/preview-generator'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { PreviewProducer } from '@infra/preview-generator'; +import { S3ClientAdapter } from '@infra/s3-client'; import { LegacyLogger } from '@src/core/logger'; import { PreviewParams } from '../controller/dto'; import { FileRecord, PreviewStatus } from '../entity'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-copy.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-copy.uc.spec.ts index 2b7f1052121..cefaba3ac24 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-copy.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-copy.uc.spec.ts @@ -4,8 +4,8 @@ import { HttpService } from '@nestjs/axios'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId, Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { Action } from '@modules/authorization'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-delete.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-delete.uc.spec.ts index b12006367aa..ef0dc16c1b6 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-delete.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-delete.uc.spec.ts @@ -5,8 +5,8 @@ import { HttpService } from '@nestjs/axios'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Counted, EntityId } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { FileRecordParams } from '../controller/dto'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-download-preview.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-download-preview.uc.spec.ts index f0aa9dcc25a..d34f004d73b 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-download-preview.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-download-preview.uc.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-download.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-download.uc.spec.ts index 51ad0fd0b77..bcb5b2ec827 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-download.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-download.uc.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-get.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-get.uc.spec.ts index 60d3fdd1a64..a4f3e0f8b2f 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-get.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-get.uc.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-restore.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-restore.uc.spec.ts index b66c9c8821d..dc811c566a4 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-restore.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-restore.uc.spec.ts @@ -3,8 +3,8 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-update.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-update.uc.spec.ts index c59f37d2599..5b126c8ea2a 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-update.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-update.uc.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { HttpService } from '@nestjs/axios'; import { Test, TestingModule } from '@nestjs/testing'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; diff --git a/apps/server/src/modules/files-storage/uc/files-storage-upload.uc.spec.ts b/apps/server/src/modules/files-storage/uc/files-storage-upload.uc.spec.ts index 43d9e9b7750..1125e7644bb 100644 --- a/apps/server/src/modules/files-storage/uc/files-storage-upload.uc.spec.ts +++ b/apps/server/src/modules/files-storage/uc/files-storage-upload.uc.spec.ts @@ -4,8 +4,8 @@ import { HttpService } from '@nestjs/axios'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { AntivirusService } from '@shared/infra/antivirus'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { AxiosHeadersKeyValue, axiosResponseFactory, fileRecordFactory, setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { Action } from '@modules/authorization'; diff --git a/apps/server/src/modules/files/repo/files.repo.spec.ts b/apps/server/src/modules/files/repo/files.repo.spec.ts index ea33ae7917a..0ef8136918d 100644 --- a/apps/server/src/modules/files/repo/files.repo.spec.ts +++ b/apps/server/src/modules/files/repo/files.repo.spec.ts @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { StorageProviderEntity } from '@shared/domain'; import { FileEntity } from '../entity'; import { fileEntityFactory, filePermissionEntityFactory } from '../entity/testing'; diff --git a/apps/server/src/modules/fwu-learning-contents/controller/api-test/fwu-learning-contents.api.spec.ts b/apps/server/src/modules/fwu-learning-contents/controller/api-test/fwu-learning-contents.api.spec.ts index 9eee09a30af..1c9921dbff5 100644 --- a/apps/server/src/modules/fwu-learning-contents/controller/api-test/fwu-learning-contents.api.spec.ts +++ b/apps/server/src/modules/fwu-learning-contents/controller/api-test/fwu-learning-contents.api.spec.ts @@ -2,7 +2,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { INestApplication, NotFoundException } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { Readable } from 'stream'; import request from 'supertest'; diff --git a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts index 62e25bef4e2..d644ca2a57c 100644 --- a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts +++ b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts @@ -2,10 +2,10 @@ import { HttpModule } from '@nestjs/axios'; import { DynamicModule, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { Account, Role, SchoolEntity, SchoolYearEntity, SystemEntity, User } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types'; -import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; -import { S3ClientModule } from '@shared/infra/s3-client'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { MongoDatabaseModuleOptions } from '@infra/database/mongo-memory-database/types'; +import { RabbitMQWrapperTestModule } from '@infra/rabbitmq'; +import { S3ClientModule } from '@infra/s3-client'; import { createConfigModuleOptions } from '@src/config'; import { CoreModule } from '@src/core'; import { LoggerModule } from '@src/core/logger'; diff --git a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.config.ts b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.config.ts index 56ae93e0205..6cfcb03b74f 100644 --- a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.config.ts +++ b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import { S3Config } from '@shared/infra/s3-client'; +import { S3Config } from '@infra/s3-client'; export const FWU_CONTENT_S3_CONNECTION = 'FWU_CONTENT_S3_CONNECTION'; diff --git a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts index b15c8a04054..a991ca56503 100644 --- a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts +++ b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts @@ -4,8 +4,8 @@ import { HttpModule } from '@nestjs/axios'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { Account, Role, SchoolEntity, SchoolYearEntity, SystemEntity, User } from '@shared/domain'; -import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq'; -import { S3ClientModule } from '@shared/infra/s3-client'; +import { RabbitMQWrapperModule } from '@infra/rabbitmq'; +import { S3ClientModule } from '@infra/s3-client'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; import { CoreModule } from '@src/core'; import { LoggerModule } from '@src/core/logger'; diff --git a/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.spec.ts b/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.spec.ts index 80240e0ea8e..e7606aeb245 100644 --- a/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.spec.ts +++ b/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { LegacyLogger } from '@src/core/logger'; import { Readable } from 'stream'; import { FWU_CONTENT_S3_CONNECTION } from '../fwu-learning-contents.config'; diff --git a/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.ts b/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.ts index afab92d46a5..6cdc20b9321 100644 --- a/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.ts +++ b/apps/server/src/modules/fwu-learning-contents/uc/fwu-learning-contents.uc.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { LegacyLogger } from '@src/core/logger'; import { FWU_CONTENT_S3_CONNECTION } from '../fwu-learning-contents.config'; diff --git a/apps/server/src/modules/group/repo/group.repo.spec.ts b/apps/server/src/modules/group/repo/group.repo.spec.ts index 358b3c13983..1bcc024514a 100644 --- a/apps/server/src/modules/group/repo/group.repo.spec.ts +++ b/apps/server/src/modules/group/repo/group.repo.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { ExternalSource, SchoolEntity, UserDO, User } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, groupEntityFactory, diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-ajax.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-ajax.api.spec.ts index 543db38ebbf..0c7251e6134 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-ajax.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-ajax.api.spec.ts @@ -3,7 +3,7 @@ import { H5PAjaxEndpoint } from '@lumieducation/h5p-server'; import { EntityManager } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { TestApiClient, UserAndAccountTestFactory } from '@shared/testing'; import { H5PEditorTestModule } from '../../h5p-editor-test.module'; import { H5P_CONTENT_S3_CONNECTION, H5P_LIBRARIES_S3_CONNECTION } from '../../h5p-editor.config'; diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-delete.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-delete.api.spec.ts index 9f3b0017d08..e2af08f3fd5 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-delete.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-delete.api.spec.ts @@ -3,7 +3,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-files.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-files.api.spec.ts index 702aac1a717..05132888f71 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-files.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-files.api.spec.ts @@ -4,7 +4,7 @@ import { ContentMetadata } from '@lumieducation/h5p-server/build/src/ContentMeta import { EntityManager } from '@mikro-orm/mongodb'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { courseFactory, h5pContentFactory, diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-editor.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-editor.api.spec.ts index 737266f300d..3f738fd67c0 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-editor.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-editor.api.spec.ts @@ -3,7 +3,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-player.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-player.api.spec.ts index 708dfef968a..6e98bb6905a 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-player.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-get-player.api.spec.ts @@ -4,7 +4,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; diff --git a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-save-create.api.spec.ts b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-save-create.api.spec.ts index 9981a13e81f..0e1d5a13686 100644 --- a/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-save-create.api.spec.ts +++ b/apps/server/src/modules/h5p-editor/controller/api-test/h5p-editor-save-create.api.spec.ts @@ -3,7 +3,7 @@ import { IContentMetadata } from '@lumieducation/h5p-server'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { TestApiClient, UserAndAccountTestFactory } from '@shared/testing'; import { H5PContentParentType } from '../../entity'; import { H5PEditorTestModule } from '../../h5p-editor-test.module'; diff --git a/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts b/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts index 1ac4fc092e3..277c233dfa4 100644 --- a/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts +++ b/apps/server/src/modules/h5p-editor/controller/dto/h5p-file.dto.ts @@ -1,5 +1,5 @@ import { Readable } from 'stream'; -import { File } from '@shared/infra/s3-client'; +import { File } from '@infra/s3-client'; export class H5pFileDto implements File { constructor(file: H5pFileDto) { diff --git a/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts b/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts index 62cd06dcf6e..49d53c57726 100644 --- a/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts +++ b/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts @@ -1,14 +1,14 @@ import { DynamicModule, Module } from '@nestjs/common'; import { ALL_ENTITIES } from '@shared/domain'; -import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; -import { S3ClientModule } from '@shared/infra/s3-client'; +import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@infra/database'; +import { RabbitMQWrapperTestModule } from '@infra/rabbitmq'; +import { S3ClientModule } from '@infra/s3-client'; import { CoreModule } from '@src/core'; import { LoggerModule } from '@src/core/logger'; -import { AuthenticationModule } from '@modules/authentication/authentication.module'; +import { AuthenticationModule } from '@modules/authentication'; import { AuthorizationReferenceModule } from '@modules/authorization/authorization-reference.module'; import { UserModule } from '@modules/user'; -import { AuthenticationApiModule } from '../authentication/authentication-api.module'; +import { AuthenticationApiModule } from '@modules/authentication/authentication-api.module'; import { H5PEditorModule } from './h5p-editor.module'; import { H5PContentRepo, LibraryRepo, TemporaryFileRepo } from './repo'; import { ContentStorage, LibraryStorage, TemporaryFileStorage } from './service'; diff --git a/apps/server/src/modules/h5p-editor/h5p-editor.config.ts b/apps/server/src/modules/h5p-editor/h5p-editor.config.ts index f02084aa4e5..9509cf66a76 100644 --- a/apps/server/src/modules/h5p-editor/h5p-editor.config.ts +++ b/apps/server/src/modules/h5p-editor/h5p-editor.config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import { S3Config } from '@shared/infra/s3-client'; +import { S3Config } from '@infra/s3-client'; const h5pEditorConfig = { NEST_LOG_LEVEL: Configuration.get('NEST_LOG_LEVEL') as string, diff --git a/apps/server/src/modules/h5p-editor/h5p-editor.module.ts b/apps/server/src/modules/h5p-editor/h5p-editor.module.ts index 34efcedd69e..c80ff8bd6c0 100644 --- a/apps/server/src/modules/h5p-editor/h5p-editor.module.ts +++ b/apps/server/src/modules/h5p-editor/h5p-editor.module.ts @@ -3,14 +3,14 @@ import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ALL_ENTITIES } from '@shared/domain'; -import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq'; +import { RabbitMQWrapperModule } from '@infra/rabbitmq'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; import { CoreModule } from '@src/core'; import { Logger } from '@src/core/logger'; import { AuthorizationReferenceModule } from '@modules/authorization/authorization-reference.module'; import { UserModule } from '@modules/user'; -import { S3ClientModule } from '@shared/infra/s3-client'; -import { AuthenticationModule } from '../authentication/authentication.module'; +import { S3ClientModule } from '@infra/s3-client'; +import { AuthenticationModule } from '@modules/authentication'; import { H5PEditorController } from './controller/h5p-editor.controller'; import { H5PContent, InstalledLibrary, H5pEditorTempFile } from './entity'; import { config, s3ConfigContent, s3ConfigLibraries } from './h5p-editor.config'; diff --git a/apps/server/src/modules/h5p-editor/repo/h5p-content.repo.integration.spec.ts b/apps/server/src/modules/h5p-editor/repo/h5p-content.repo.integration.spec.ts index e06836ced99..f9672ffb3ce 100644 --- a/apps/server/src/modules/h5p-editor/repo/h5p-content.repo.integration.spec.ts +++ b/apps/server/src/modules/h5p-editor/repo/h5p-content.repo.integration.spec.ts @@ -1,6 +1,6 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, h5pContentFactory } from '@shared/testing'; import { H5PContent } from '../entity'; import { H5PContentRepo } from './h5p-content.repo'; diff --git a/apps/server/src/modules/h5p-editor/repo/library.repo.spec.ts b/apps/server/src/modules/h5p-editor/repo/library.repo.spec.ts index 78d219aa557..79bcde09fe9 100644 --- a/apps/server/src/modules/h5p-editor/repo/library.repo.spec.ts +++ b/apps/server/src/modules/h5p-editor/repo/library.repo.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { cleanupCollections } from '@shared/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ILibraryMetadata } from '@lumieducation/h5p-server'; import { LibraryRepo } from './library.repo'; diff --git a/apps/server/src/modules/h5p-editor/repo/temporary-file.repo.integration.spec.ts b/apps/server/src/modules/h5p-editor/repo/temporary-file.repo.integration.spec.ts index ccaff625d66..e5e763b6216 100644 --- a/apps/server/src/modules/h5p-editor/repo/temporary-file.repo.integration.spec.ts +++ b/apps/server/src/modules/h5p-editor/repo/temporary-file.repo.integration.spec.ts @@ -1,6 +1,6 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, h5pTemporaryFileFactory } from '@shared/testing'; import { H5pEditorTempFile } from '../entity'; import { TemporaryFileRepo } from './temporary-file.repo'; diff --git a/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts index a02c8867cd0..df19f05ae21 100644 --- a/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/contentStorage.service.spec.ts @@ -4,7 +4,7 @@ import { IContentMetadata, ILibraryName, IUser, LibraryName } from '@lumieducati import { HttpException, InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { IEntity } from '@shared/domain'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; import { GetH5PFileResponse } from '../controller/dto'; diff --git a/apps/server/src/modules/h5p-editor/service/contentStorage.service.ts b/apps/server/src/modules/h5p-editor/service/contentStorage.service.ts index 95895b867c8..753f40201e3 100644 --- a/apps/server/src/modules/h5p-editor/service/contentStorage.service.ts +++ b/apps/server/src/modules/h5p-editor/service/contentStorage.service.ts @@ -17,7 +17,7 @@ import { NotFoundException, UnprocessableEntityException, } from '@nestjs/common'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { ErrorUtils } from '@src/core/error/utils'; import { Readable } from 'stream'; import { H5pFileDto } from '../controller/dto/h5p-file.dto'; diff --git a/apps/server/src/modules/h5p-editor/service/libraryStorage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/libraryStorage.service.spec.ts index afde26d59b0..1b7910f057d 100644 --- a/apps/server/src/modules/h5p-editor/service/libraryStorage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/libraryStorage.service.spec.ts @@ -6,7 +6,7 @@ import { H5pError, ILibraryMetadata, ILibraryName } from '@lumieducation/h5p-ser import { NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { FileMetadata, InstalledLibrary } from '../entity/library.entity'; import { H5P_LIBRARIES_S3_CONNECTION } from '../h5p-editor.config'; import { LibraryRepo } from '../repo/library.repo'; diff --git a/apps/server/src/modules/h5p-editor/service/libraryStorage.service.ts b/apps/server/src/modules/h5p-editor/service/libraryStorage.service.ts index 6839a9d2a27..aff2b76ae16 100644 --- a/apps/server/src/modules/h5p-editor/service/libraryStorage.service.ts +++ b/apps/server/src/modules/h5p-editor/service/libraryStorage.service.ts @@ -10,7 +10,7 @@ import { type ILibraryStorage, } from '@lumieducation/h5p-server'; import { ConflictException, Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import mime from 'mime'; import path from 'node:path/posix'; import { Readable } from 'stream'; diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts index bcbdfa9945c..b7d65e25cb4 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.spec.ts @@ -2,7 +2,7 @@ import { ServiceOutputTypes } from '@aws-sdk/client-s3'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { IUser } from '@lumieducation/h5p-server'; import { Test, TestingModule } from '@nestjs/testing'; -import { File, S3ClientAdapter } from '@shared/infra/s3-client'; +import { File, S3ClientAdapter } from '@infra/s3-client'; import { ReadStream } from 'fs'; import { Readable } from 'node:stream'; import { GetH5pFileResponse } from '../controller/dto'; diff --git a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts index 6bfa164e630..7921b52a27b 100644 --- a/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts +++ b/apps/server/src/modules/h5p-editor/service/temporary-file-storage.service.ts @@ -1,6 +1,6 @@ import { ITemporaryFile, ITemporaryFileStorage, IUser } from '@lumieducation/h5p-server'; import { Inject, Injectable, NotAcceptableException } from '@nestjs/common'; -import { S3ClientAdapter } from '@shared/infra/s3-client'; +import { S3ClientAdapter } from '@infra/s3-client'; import { ReadStream } from 'fs'; import { Readable } from 'stream'; import { H5pFileDto } from '../controller/dto/h5p-file.dto'; diff --git a/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts b/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts index 64db859ddac..8a586c39eb6 100644 --- a/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/column-board-target.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { ColumnBoardTarget } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, columnBoardTargetFactory } from '@shared/testing'; import { ColumnBoardService } from '@modules/board'; import { ColumnBoardTargetService } from './column-board-target.service'; diff --git a/apps/server/src/modules/learnroom/service/index.ts b/apps/server/src/modules/learnroom/service/index.ts index 608249cbf43..ca9d75634cf 100644 --- a/apps/server/src/modules/learnroom/service/index.ts +++ b/apps/server/src/modules/learnroom/service/index.ts @@ -4,3 +4,4 @@ export * from './column-board-target.service'; export * from './common-cartridge-export.service'; export * from './course.service'; export * from './rooms.service'; +export * from './coursegroup.service'; diff --git a/apps/server/src/modules/legacy-school/repo/schoolyear.repo.integration.spec.ts b/apps/server/src/modules/legacy-school/repo/schoolyear.repo.integration.spec.ts index 5439fdef9f6..1688e9e6d97 100644 --- a/apps/server/src/modules/legacy-school/repo/schoolyear.repo.integration.spec.ts +++ b/apps/server/src/modules/legacy-school/repo/schoolyear.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { SchoolYearEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections } from '@shared/testing'; import { schoolYearFactory } from '@shared/testing/factory/schoolyear.factory'; import { SchoolYearRepo } from './schoolyear.repo'; diff --git a/apps/server/src/modules/lesson/lesson.module.ts b/apps/server/src/modules/lesson/lesson.module.ts index 2e246c63211..dde1eb157ec 100644 --- a/apps/server/src/modules/lesson/lesson.module.ts +++ b/apps/server/src/modules/lesson/lesson.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { FeathersServiceProvider } from '@shared/infra/feathers'; +import { FeathersServiceProvider } from '@infra/feathers'; import { LessonRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { CopyHelperModule } from '@modules/copy-helper'; diff --git a/apps/server/src/modules/lesson/service/etherpad.service.spec.ts b/apps/server/src/modules/lesson/service/etherpad.service.spec.ts index 81a903008c6..02bc68e67bf 100644 --- a/apps/server/src/modules/lesson/service/etherpad.service.spec.ts +++ b/apps/server/src/modules/lesson/service/etherpad.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId } from '@shared/domain'; -import { FeathersServiceProvider } from '@shared/infra/feathers/feathers-service.provider'; +import { FeathersServiceProvider } from '@infra/feathers/feathers-service.provider'; import { LegacyLogger } from '@src/core/logger'; import { EtherpadService } from './etherpad.service'; diff --git a/apps/server/src/modules/lesson/service/etherpad.service.ts b/apps/server/src/modules/lesson/service/etherpad.service.ts index d630a93420e..62e0773071b 100644 --- a/apps/server/src/modules/lesson/service/etherpad.service.ts +++ b/apps/server/src/modules/lesson/service/etherpad.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain/types'; -import { FeathersServiceProvider } from '@shared/infra/feathers/feathers-service.provider'; +import { FeathersServiceProvider } from '@infra/feathers'; import { LegacyLogger } from '@src/core/logger'; export type PadResponse = { data: { padID: string } }; diff --git a/apps/server/src/modules/lesson/service/nexboard.service.spec.ts b/apps/server/src/modules/lesson/service/nexboard.service.spec.ts index a4f40bd1989..8085a5fdd89 100644 --- a/apps/server/src/modules/lesson/service/nexboard.service.spec.ts +++ b/apps/server/src/modules/lesson/service/nexboard.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId } from '@shared/domain'; -import { FeathersServiceProvider } from '@shared/infra/feathers/feathers-service.provider'; +import { FeathersServiceProvider } from '@infra/feathers'; import { LegacyLogger } from '@src/core/logger'; import { NexboardService } from './nexboard.service'; diff --git a/apps/server/src/modules/lesson/service/nexboard.service.ts b/apps/server/src/modules/lesson/service/nexboard.service.ts index 01ca20647ad..31da21a9f92 100644 --- a/apps/server/src/modules/lesson/service/nexboard.service.ts +++ b/apps/server/src/modules/lesson/service/nexboard.service.ts @@ -1,4 +1,4 @@ -import { FeathersServiceProvider } from '@shared/infra/feathers/feathers-service.provider'; +import { FeathersServiceProvider } from '@infra/feathers/feathers-service.provider'; import { LegacyLogger } from '@src/core/logger'; import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain/types'; diff --git a/apps/server/src/modules/management/console/board-management.console.spec.ts b/apps/server/src/modules/management/console/board-management.console.spec.ts index d6027bece93..4fe62db18a5 100644 --- a/apps/server/src/modules/management/console/board-management.console.spec.ts +++ b/apps/server/src/modules/management/console/board-management.console.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { ObjectId } from 'bson'; import { BoardManagementUc } from '../uc/board-management.uc'; import { BoardManagementConsole } from './board-management.console'; diff --git a/apps/server/src/modules/management/console/board-management.console.ts b/apps/server/src/modules/management/console/board-management.console.ts index f2762eccb17..83e5d4d7961 100644 --- a/apps/server/src/modules/management/console/board-management.console.ts +++ b/apps/server/src/modules/management/console/board-management.console.ts @@ -1,4 +1,4 @@ -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { ObjectId } from 'bson'; import { Command, Console } from 'nestjs-console'; import { BoardManagementUc } from '../uc/board-management.uc'; diff --git a/apps/server/src/modules/management/console/database-management.console.spec.ts b/apps/server/src/modules/management/console/database-management.console.spec.ts index f987bddff41..44517e19396 100644 --- a/apps/server/src/modules/management/console/database-management.console.spec.ts +++ b/apps/server/src/modules/management/console/database-management.console.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { DatabaseManagementUc } from '../uc/database-management.uc'; import { DatabaseManagementConsole } from './database-management.console'; diff --git a/apps/server/src/modules/management/console/database-management.console.ts b/apps/server/src/modules/management/console/database-management.console.ts index 29d98005bfe..780072aa837 100644 --- a/apps/server/src/modules/management/console/database-management.console.ts +++ b/apps/server/src/modules/management/console/database-management.console.ts @@ -1,4 +1,4 @@ -import { ConsoleWriterService } from '@shared/infra/console/console-writer/console-writer.service'; +import { ConsoleWriterService } from '@infra/console/console-writer/console-writer.service'; import { Command, Console } from 'nestjs-console'; import { DatabaseManagementUc } from '../uc/database-management.uc'; diff --git a/apps/server/src/modules/management/management-server.module.ts b/apps/server/src/modules/management/management-server.module.ts index b7481646c11..c24bf90cc09 100644 --- a/apps/server/src/modules/management/management-server.module.ts +++ b/apps/server/src/modules/management/management-server.module.ts @@ -2,8 +2,8 @@ import { Dictionary, IPrimaryKey } from '@mikro-orm/core'; import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; import { DynamicModule, Module, NotFoundException } from '@nestjs/common'; import { ALL_ENTITIES } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { MongoDatabaseModuleOptions } from '@infra/database/mongo-memory-database/types'; import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config'; import { ManagementModule } from './management.module'; diff --git a/apps/server/src/modules/management/management.module.ts b/apps/server/src/modules/management/management.module.ts index fc4c8bc08d3..c1ed6aed227 100644 --- a/apps/server/src/modules/management/management.module.ts +++ b/apps/server/src/modules/management/management.module.ts @@ -1,11 +1,11 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { ConsoleWriterService } from '@shared/infra/console'; -import { DatabaseManagementModule, DatabaseManagementService } from '@shared/infra/database'; -import { EncryptionModule } from '@shared/infra/encryption'; -import { FileSystemModule } from '@shared/infra/file-system'; -import { KeycloakConfigurationModule } from '@shared/infra/identity-management/keycloak-configuration/keycloak-configuration.module'; +import { ConsoleWriterService } from '@infra/console'; +import { DatabaseManagementModule, DatabaseManagementService } from '@infra/database'; +import { EncryptionModule } from '@infra/encryption'; +import { FileSystemModule } from '@infra/file-system'; +import { KeycloakConfigurationModule } from '@infra/identity-management/keycloak-configuration/keycloak-configuration.module'; import { createConfigModuleOptions } from '@src/config'; import { LoggerModule } from '@src/core/logger'; import { serverConfig } from '@modules/server'; diff --git a/apps/server/src/modules/management/uc/board-management.uc.ts b/apps/server/src/modules/management/uc/board-management.uc.ts index d57af94e6e9..8fa595690e8 100644 --- a/apps/server/src/modules/management/uc/board-management.uc.ts +++ b/apps/server/src/modules/management/uc/board-management.uc.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; import { BoardExternalReferenceType, BoardNode, Course, EntityId, InputFormat } from '@shared/domain'; -import { ConsoleWriterService } from '@shared/infra/console'; +import { ConsoleWriterService } from '@infra/console'; import { cardNodeFactory, columnBoardNodeFactory, diff --git a/apps/server/src/modules/management/uc/database-management.uc.spec.ts b/apps/server/src/modules/management/uc/database-management.uc.spec.ts index d74ecb0475e..0aa2c005a39 100644 --- a/apps/server/src/modules/management/uc/database-management.uc.spec.ts +++ b/apps/server/src/modules/management/uc/database-management.uc.spec.ts @@ -4,13 +4,9 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { StorageProviderEntity, SystemEntity } from '@shared/domain'; -import { DatabaseManagementService } from '@shared/infra/database'; -import { - DefaultEncryptionService, - LdapEncryptionService, - SymetricKeyEncryptionService, -} from '@shared/infra/encryption'; -import { FileSystemAdapter } from '@shared/infra/file-system'; +import { DatabaseManagementService } from '@infra/database'; +import { DefaultEncryptionService, LdapEncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; +import { FileSystemAdapter } from '@infra/file-system'; import { setupEntities } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { ObjectId } from 'mongodb'; diff --git a/apps/server/src/modules/management/uc/database-management.uc.ts b/apps/server/src/modules/management/uc/database-management.uc.ts index 5a51d249de9..7b3d034c504 100644 --- a/apps/server/src/modules/management/uc/database-management.uc.ts +++ b/apps/server/src/modules/management/uc/database-management.uc.ts @@ -3,9 +3,9 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Inject, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { StorageProviderEntity, SystemEntity } from '@shared/domain'; -import { DatabaseManagementService } from '@shared/infra/database'; -import { DefaultEncryptionService, IEncryptionService, LdapEncryptionService } from '@shared/infra/encryption'; -import { FileSystemAdapter } from '@shared/infra/file-system'; +import { DatabaseManagementService } from '@infra/database'; +import { DefaultEncryptionService, IEncryptionService, LdapEncryptionService } from '@infra/encryption'; +import { FileSystemAdapter } from '@infra/file-system'; import { LegacyLogger } from '@src/core/logger'; import { orderBy } from 'lodash'; import { BsonConverter } from '../converter/bson.converter'; diff --git a/apps/server/src/modules/meta-tag-extractor/meta-tag-extractor.module.ts b/apps/server/src/modules/meta-tag-extractor/meta-tag-extractor.module.ts index 817d7257330..a85e71c526f 100644 --- a/apps/server/src/modules/meta-tag-extractor/meta-tag-extractor.module.ts +++ b/apps/server/src/modules/meta-tag-extractor/meta-tag-extractor.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { ConsoleWriterModule } from '@shared/infra/console'; +import { ConsoleWriterModule } from '@infra/console'; import { createConfigModuleOptions } from '@src/config'; import { LoggerModule } from '@src/core/logger'; import { AuthenticationModule } from '../authentication/authentication.module'; diff --git a/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.spec.ts b/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.spec.ts index 83a3e3ac47b..bc993271066 100644 --- a/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.spec.ts +++ b/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.spec.ts @@ -20,7 +20,7 @@ import { ProviderConsentSessionResponse, ProviderLoginResponse, ProviderRedirectResponse, -} from '@shared/infra/oauth-provider/dto'; +} from '@infra/oauth-provider/dto'; import { OauthProviderConsentFlowUc } from '@modules/oauth-provider/uc/oauth-provider.consent-flow.uc'; import { ICurrentUser } from '@modules/authentication'; import { OauthProviderUc } from '@modules/oauth-provider/uc/oauth-provider.uc'; diff --git a/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.ts b/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.ts index 054cca37ffa..97b16e8e49f 100644 --- a/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.ts +++ b/apps/server/src/modules/oauth-provider/controller/oauth-provider.controller.ts @@ -1,14 +1,14 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; -// import should be @shared/infra/oauth-provider +// import should be @infra/oauth-provider import { ProviderConsentResponse, ProviderLoginResponse, ProviderOauthClient, ProviderRedirectResponse, ProviderConsentSessionResponse, -} from '@shared/infra/oauth-provider/dto'; +} from '@infra/oauth-provider/dto'; import { ApiTags } from '@nestjs/swagger'; import { OauthProviderLogoutFlowUc } from '../uc/oauth-provider.logout-flow.uc'; import { OauthProviderLoginFlowUc } from '../uc/oauth-provider.login-flow.uc'; diff --git a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts index 14db6718476..d34571dcbb7 100644 --- a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts +++ b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.spec.ts @@ -1,4 +1,4 @@ -import { AcceptLoginRequestBody } from '@shared/infra/oauth-provider/dto'; +import { AcceptLoginRequestBody } from '@infra/oauth-provider/dto'; import { LoginRequestBody } from '../controller/dto'; import { OauthProviderRequestMapper } from './oauth-provider-request.mapper'; diff --git a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.ts b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.ts index e0d4c4aaef4..aa8aa988408 100644 --- a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.ts +++ b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-request.mapper.ts @@ -1,4 +1,4 @@ -import { AcceptLoginRequestBody } from '@shared/infra/oauth-provider/dto'; +import { AcceptLoginRequestBody } from '@infra/oauth-provider/dto'; import { LoginRequestBody } from '@modules/oauth-provider/controller/dto'; export class OauthProviderRequestMapper { diff --git a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.spec.ts b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.spec.ts index 13119635f75..f28ab378771 100644 --- a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.spec.ts +++ b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.spec.ts @@ -5,7 +5,7 @@ import { ProviderLoginResponse, ProviderOauthClient, ProviderRedirectResponse, -} from '@shared/infra/oauth-provider/dto'; +} from '@infra/oauth-provider/dto'; import { ConsentResponse, ConsentSessionResponse, diff --git a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.ts b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.ts index 01038c23526..c97b86366b0 100644 --- a/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.ts +++ b/apps/server/src/modules/oauth-provider/mapper/oauth-provider-response.mapper.ts @@ -5,7 +5,7 @@ import { ProviderLoginResponse, ProviderOauthClient, ProviderRedirectResponse, -} from '@shared/infra/oauth-provider/dto'; +} from '@infra/oauth-provider/dto'; import { ConsentResponse, ConsentSessionResponse, diff --git a/apps/server/src/modules/oauth-provider/oauth-provider-api.module.ts b/apps/server/src/modules/oauth-provider/oauth-provider-api.module.ts index ccbd1566cda..bf131e22eee 100644 --- a/apps/server/src/modules/oauth-provider/oauth-provider-api.module.ts +++ b/apps/server/src/modules/oauth-provider/oauth-provider-api.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { OauthProviderServiceModule } from '@shared/infra/oauth-provider'; +import { OauthProviderServiceModule } from '@infra/oauth-provider'; import { LoggerModule } from '@src/core/logger'; import { AuthorizationModule } from '@modules/authorization'; import { PseudonymModule } from '@modules/pseudonym'; diff --git a/apps/server/src/modules/oauth-provider/oauth-provider.module.ts b/apps/server/src/modules/oauth-provider/oauth-provider.module.ts index 4289644d29e..7483ad140e5 100644 --- a/apps/server/src/modules/oauth-provider/oauth-provider.module.ts +++ b/apps/server/src/modules/oauth-provider/oauth-provider.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { OauthProviderServiceModule } from '@shared/infra/oauth-provider'; +import { OauthProviderServiceModule } from '@infra/oauth-provider'; import { TeamsRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { LtiToolModule } from '@modules/lti-tool'; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts index 6ce203ab5b7..d2eb1636e53 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Permission, User } from '@shared/domain'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { setupEntities, userFactory } from '@shared/testing'; import { AuthorizationService } from '@modules/authorization'; import { ICurrentUser } from '@modules/authentication'; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.ts index 3595f00679b..18fd23ae788 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.client-crud.uc.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; -import { OauthProviderService } from '@shared/infra/oauth-provider/index'; +import { OauthProviderService } from '@infra/oauth-provider/index'; import { Permission, User } from '@shared/domain/index'; import { AuthorizationService } from '@modules/authorization'; -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { ICurrentUser } from '@modules/authentication'; @Injectable() diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.spec.ts index b397b048dd4..e56700477a8 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.spec.ts @@ -1,12 +1,8 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { OauthProviderService } from '@shared/infra/oauth-provider/index'; +import { OauthProviderService } from '@infra/oauth-provider'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; -import { - AcceptConsentRequestBody, - ProviderConsentResponse, - ProviderRedirectResponse, -} from '@shared/infra/oauth-provider/dto'; +import { AcceptConsentRequestBody, ProviderConsentResponse, ProviderRedirectResponse } from '@infra/oauth-provider/dto'; import { OauthProviderConsentFlowUc } from '@modules/oauth-provider/uc/oauth-provider.consent-flow.uc'; import { ICurrentUser } from '@modules/authentication'; import { ForbiddenException } from '@nestjs/common'; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.ts index eb91d8132fe..126f68f1b80 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.consent-flow.uc.ts @@ -3,12 +3,12 @@ import { ProviderConsentResponse, ProviderRedirectResponse, RejectRequestBody, -} from '@shared/infra/oauth-provider/dto'; +} from '@infra/oauth-provider/dto'; import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; import { ICurrentUser } from '@modules/authentication'; import { ForbiddenException, Injectable } from '@nestjs/common'; import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; +import { OauthProviderService } from '@infra/oauth-provider'; import { IdToken } from '@modules/oauth-provider/interface/id-token'; @Injectable() diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.spec.ts index a9225031d04..1c160b021d7 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.spec.ts @@ -2,8 +2,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { InternalServerErrorException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LtiToolDO, Permission, Pseudonym, UserDO } from '@shared/domain'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { ProviderLoginResponse, ProviderRedirectResponse } from '@shared/infra/oauth-provider/dto'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderLoginResponse, ProviderRedirectResponse } from '@infra/oauth-provider/dto'; import { externalToolFactory, ltiToolDOFactory, diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.ts index dade1cb3f07..cfe208c477c 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.login-flow.uc.ts @@ -1,12 +1,8 @@ import { Injectable, InternalServerErrorException, UnprocessableEntityException } from '@nestjs/common'; import { Permission, Pseudonym, User, UserDO } from '@shared/domain'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { - AcceptLoginRequestBody, - ProviderLoginResponse, - ProviderRedirectResponse, -} from '@shared/infra/oauth-provider/dto'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { AcceptLoginRequestBody, ProviderLoginResponse, ProviderRedirectResponse } from '@infra/oauth-provider/dto'; import { AuthorizationService } from '@modules/authorization'; import { AcceptQuery, LoginRequestBody, OAuthRejectableBody } from '@modules/oauth-provider/controller/dto'; import { OauthProviderRequestMapper } from '@modules/oauth-provider/mapper/oauth-provider-request.mapper'; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts index 778112840b2..62171565cda 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { OauthProviderLogoutFlowUc } from '@modules/oauth-provider/uc/oauth-provider.logout-flow.uc'; -import { OauthProviderService } from '@shared/infra/oauth-provider/index'; +import { OauthProviderService } from '@infra/oauth-provider/index'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; describe('OauthProviderUc', () => { diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.ts index 68f1eb95bf9..30f45ba4188 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.logout-flow.uc.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { ProviderRedirectResponse } from '@shared/infra/oauth-provider/dto'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderRedirectResponse } from '@infra/oauth-provider/dto'; @Injectable() export class OauthProviderLogoutFlowUc { diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts index f1205db3d28..2faf242f0e5 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.spec.ts @@ -1,8 +1,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { OauthProviderUc } from '@modules/oauth-provider/uc/oauth-provider.uc'; -import { OauthProviderService } from '@shared/infra/oauth-provider/index'; +import { OauthProviderService } from '@infra/oauth-provider/index'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { ProviderConsentSessionResponse } from '@shared/infra/oauth-provider/dto'; +import { ProviderConsentSessionResponse } from '@infra/oauth-provider/dto'; describe('OauthProviderUc', () => { let module: TestingModule; diff --git a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.ts b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.ts index 74bf0543d90..39ad1effd7f 100644 --- a/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.ts +++ b/apps/server/src/modules/oauth-provider/uc/oauth-provider.uc.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; +import { OauthProviderService } from '@infra/oauth-provider'; import { EntityId } from '@shared/domain'; -import { ProviderConsentSessionResponse } from '@shared/infra/oauth-provider/dto/'; +import { ProviderConsentSessionResponse } from '@infra/oauth-provider/dto/'; @Injectable() export class OauthProviderUc { diff --git a/apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts b/apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts index eaaf07f4500..a259c405cfb 100644 --- a/apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts +++ b/apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { Account, EntityId, SchoolEntity, SystemEntity, User } from '@shared/domain'; import { UserLoginMigrationEntity } from '@shared/domain/entity/user-login-migration.entity'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; -import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service'; +import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; import { accountFactory, cleanupCollections, diff --git a/apps/server/src/modules/oauth/oauth.module.ts b/apps/server/src/modules/oauth/oauth.module.ts index 273a099159b..ae0f0eda48d 100644 --- a/apps/server/src/modules/oauth/oauth.module.ts +++ b/apps/server/src/modules/oauth/oauth.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; -import { CacheWrapperModule } from '@shared/infra/cache'; -import { EncryptionModule } from '@shared/infra/encryption'; +import { CacheWrapperModule } from '@infra/cache'; +import { EncryptionModule } from '@infra/encryption'; import { LtiToolRepo } from '@shared/repo'; import { LoggerModule } from '@src/core/logger'; import { AuthorizationModule } from '@modules/authorization'; diff --git a/apps/server/src/modules/oauth/service/hydra.service.spec.ts b/apps/server/src/modules/oauth/service/hydra.service.spec.ts index 3886aa40a58..2dc2a22a6ce 100644 --- a/apps/server/src/modules/oauth/service/hydra.service.spec.ts +++ b/apps/server/src/modules/oauth/service/hydra.service.spec.ts @@ -6,7 +6,7 @@ import { InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LtiPrivacyPermission, LtiRoleType, OauthConfig } from '@shared/domain'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; -import { DefaultEncryptionService, SymetricKeyEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; import { LtiToolRepo } from '@shared/repo'; import { axiosResponseFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/modules/oauth/service/hydra.service.ts b/apps/server/src/modules/oauth/service/hydra.service.ts index 9b335604825..360926d080a 100644 --- a/apps/server/src/modules/oauth/service/hydra.service.ts +++ b/apps/server/src/modules/oauth/service/hydra.service.ts @@ -4,7 +4,7 @@ import { Inject, InternalServerErrorException } from '@nestjs/common'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { OauthConfig } from '@shared/domain'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; import { LtiToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { AuthorizationParams } from '@modules/oauth/controller/dto/authorization.params'; diff --git a/apps/server/src/modules/oauth/service/oauth.service.spec.ts b/apps/server/src/modules/oauth/service/oauth.service.spec.ts index 2743037e214..9c4b45582df 100644 --- a/apps/server/src/modules/oauth/service/oauth.service.spec.ts +++ b/apps/server/src/modules/oauth/service/oauth.service.spec.ts @@ -4,7 +4,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LegacySchoolDo, OauthConfig, SchoolFeatures, SystemEntity } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; -import { DefaultEncryptionService, IEncryptionService, SymetricKeyEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; import { legacySchoolDoFactory, setupEntities, systemFactory, userDoFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { ProvisioningDto, ProvisioningService } from '@modules/provisioning'; diff --git a/apps/server/src/modules/oauth/service/oauth.service.ts b/apps/server/src/modules/oauth/service/oauth.service.ts index 28a24c0534a..190c962cd97 100644 --- a/apps/server/src/modules/oauth/service/oauth.service.ts +++ b/apps/server/src/modules/oauth/service/oauth.service.ts @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { Inject } from '@nestjs/common'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { EntityId, LegacySchoolDo, OauthConfig, SchoolFeatures, UserDO } from '@shared/domain'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; import { LegacyLogger } from '@src/core/logger'; import { ProvisioningService } from '@modules/provisioning'; import { OauthDataDto } from '@modules/provisioning/dto'; diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts index 9d3711aff02..324e444afcb 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.integration.spec.ts @@ -3,7 +3,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Page, Pseudonym } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, externalToolPseudonymEntityFactory, pseudonymFactory, userFactory } from '@shared/testing'; import { pseudonymEntityFactory } from '@shared/testing/factory/pseudonym.factory'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts b/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts index 548ba1b0512..8246479da4a 100644 --- a/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts +++ b/apps/server/src/modules/pseudonym/repo/pseudonyms.repo.spec.ts @@ -3,7 +3,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Pseudonym } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, pseudonymFactory, userFactory } from '@shared/testing'; import { pseudonymEntityFactory } from '@shared/testing/factory/pseudonym.factory'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/modules/rocketchat-user/domain/index.ts b/apps/server/src/modules/rocketchat-user/domain/index.ts new file mode 100644 index 00000000000..0246dd0f0f9 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/domain/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.do'; diff --git a/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.spec.ts b/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.spec.ts new file mode 100644 index 00000000000..a1be448f80c --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.spec.ts @@ -0,0 +1,67 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { RocketChatUser } from './rocket-chat-user.do'; +import { rocketChatUserFactory } from './testing/rocket-chat-user.factory'; + +describe(RocketChatUser.name, () => { + describe('constructor', () => { + describe('When constructor is called', () => { + it('should create a rocketChatUser by passing required properties', () => { + const domainObject: RocketChatUser = rocketChatUserFactory.build(); + + expect(domainObject instanceof RocketChatUser).toEqual(true); + }); + }); + + describe('when passed a valid id', () => { + const setup = () => { + const domainObject: RocketChatUser = rocketChatUserFactory.build(); + + return { domainObject }; + }; + + it('should set the id', () => { + const { domainObject } = setup(); + + const rocketChatUserObject: RocketChatUser = new RocketChatUser(domainObject); + + expect(rocketChatUserObject.id).toEqual(domainObject.id); + }); + }); + }); + + describe('getters', () => { + describe('When getters are used', () => { + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + userId: new ObjectId().toHexString(), + username: 'Test.User.shls', + rcId: 'JfMJXua6t29KYXdDc', + authToken: 'OL8e5YCZHy3agGnLS-gHAx1wU4ZCG8-DXU_WZnUxUu6', + createdAt: new Date(), + updatedAt: new Date(), + }; + + const rocketChatUserDo = new RocketChatUser(props); + + return { props, rocketChatUserDo }; + }; + + it('getters should return proper values', () => { + const { props, rocketChatUserDo } = setup(); + + const gettersValues = { + id: rocketChatUserDo.id, + userId: rocketChatUserDo.userId, + username: rocketChatUserDo.username, + rcId: rocketChatUserDo.rcId, + authToken: rocketChatUserDo.authToken, + createdAt: rocketChatUserDo.createdAt, + updatedAt: rocketChatUserDo.updatedAt, + }; + + expect(gettersValues).toEqual(props); + }); + }); + }); +}); diff --git a/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.ts b/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.ts new file mode 100644 index 00000000000..8dfd830f3eb --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.ts @@ -0,0 +1,37 @@ +import { EntityId } from '@shared/domain/types'; +import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; + +export interface RocketChatUserProps extends AuthorizableObject { + userId: EntityId; + username: string; + rcId: string; + authToken?: string; + createdAt?: Date; + updatedAt?: Date; +} + +export class RocketChatUser extends DomainObject { + get userId(): EntityId { + return this.props.userId; + } + + get username(): string { + return this.props.username; + } + + get rcId(): string { + return this.props.rcId; + } + + get authToken(): string | undefined { + return this.props.authToken; + } + + get createdAt(): Date | undefined { + return this.props.createdAt; + } + + get updatedAt(): Date | undefined { + return this.props.updatedAt; + } +} diff --git a/apps/server/src/modules/rocketchat-user/domain/testing/index.ts b/apps/server/src/modules/rocketchat-user/domain/testing/index.ts new file mode 100644 index 00000000000..2ef434c0975 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/domain/testing/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.factory'; diff --git a/apps/server/src/modules/rocketchat-user/domain/testing/rocket-chat-user.factory.ts b/apps/server/src/modules/rocketchat-user/domain/testing/rocket-chat-user.factory.ts new file mode 100644 index 00000000000..3ad6432d1d5 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/domain/testing/rocket-chat-user.factory.ts @@ -0,0 +1,18 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseFactory } from '@shared/testing'; +import { RocketChatUser, RocketChatUserProps } from '../rocket-chat-user.do'; + +export const rocketChatUserFactory = BaseFactory.define( + RocketChatUser, + ({ sequence }) => { + return { + id: new ObjectId().toHexString(), + userId: new ObjectId().toHexString(), + username: `username-${sequence}`, + rcId: `rcId-${sequence}`, + authToken: `aythToken-${sequence}`, + createdAt: new Date(), + updatedAt: new Date(), + }; + } +); diff --git a/apps/server/src/modules/rocketchat-user/entity/index.ts b/apps/server/src/modules/rocketchat-user/entity/index.ts new file mode 100644 index 00000000000..9528e8da500 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/entity/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.entity'; diff --git a/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.spec.ts b/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.spec.ts new file mode 100644 index 00000000000..f8d5318c5bf --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.spec.ts @@ -0,0 +1,61 @@ +import { setupEntities } from '@shared/testing'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { RocketChatUserEntity } from '@src/modules/rocketchat-user/entity'; + +describe(RocketChatUserEntity.name, () => { + beforeAll(async () => { + await setupEntities(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + const setup = () => { + const props = { + id: new ObjectId().toHexString(), + userId: new ObjectId(), + username: 'Test.User.shls', + rcId: 'JfMJXua6t29KYXdDc', + authToken: 'OL8e5YCZHy3agGnLS-gHAx1wU4ZCG8-DXU_WZnUxUu6', + createdAt: new Date(), + updatedAt: new Date(), + }; + + return { props }; + }; + + describe('constructor', () => { + describe('When constructor is called', () => { + it('should throw an error by empty constructor', () => { + // @ts-expect-error: Test case + const test = () => new RocketChatUserEntity(); + expect(test).toThrow(); + }); + + it('should create a rocketChatUser by passing required properties', () => { + const { props } = setup(); + const entity: RocketChatUserEntity = new RocketChatUserEntity(props); + + expect(entity instanceof RocketChatUserEntity).toEqual(true); + }); + + it(`should return a valid object with fields values set from the provided complete props object`, () => { + const { props } = setup(); + const entity: RocketChatUserEntity = new RocketChatUserEntity(props); + + const entityProps = { + id: entity.id, + userId: entity.userId, + username: entity.username, + rcId: entity.rcId, + authToken: entity.authToken, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + expect(entityProps).toEqual(props); + }); + }); + }); +}); diff --git a/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.ts b/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.ts new file mode 100644 index 00000000000..6df469e0ddb --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.ts @@ -0,0 +1,56 @@ +import { Entity, Index, Property, Unique } from '@mikro-orm/core'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; +import { EntityId } from '@shared/domain'; + +export interface RocketChatUserEntityProps { + id?: EntityId; + userId: ObjectId; + username: string; + rcId: string; + authToken?: string; + createdAt?: Date; + updatedAt?: Date; +} + +@Entity({ tableName: 'rocketchatuser' }) +export class RocketChatUserEntity extends BaseEntityWithTimestamps { + @Property() + @Unique() + username: string; + + @Property() + @Unique() + userId: ObjectId; + + @Property() + @Index() + rcId: string; + + @Property({ nullable: true }) + authToken?: string; + + constructor(props: RocketChatUserEntityProps) { + super(); + + if (props.id !== undefined) { + this.id = props.id; + } + + this.userId = props.userId; + this.username = props.username; + this.rcId = props.rcId; + + if (props.authToken !== undefined) { + this.authToken = props.authToken; + } + + if (props.createdAt !== undefined) { + this.createdAt = props.createdAt; + } + + if (props.updatedAt !== undefined) { + this.updatedAt = props.updatedAt; + } + } +} diff --git a/apps/server/src/modules/rocketchat-user/entity/testing/index.ts b/apps/server/src/modules/rocketchat-user/entity/testing/index.ts new file mode 100644 index 00000000000..f19ebd8c74a --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/entity/testing/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.entity.factory'; diff --git a/apps/server/src/modules/rocketchat-user/entity/testing/rocket-chat-user.entity.factory.ts b/apps/server/src/modules/rocketchat-user/entity/testing/rocket-chat-user.entity.factory.ts new file mode 100644 index 00000000000..302459a4eb6 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/entity/testing/rocket-chat-user.entity.factory.ts @@ -0,0 +1,20 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { BaseFactory } from '@shared/testing'; +import { RocketChatUserEntity, RocketChatUserEntityProps } from '../rocket-chat-user.entity'; + +class RocketChatUserFactory extends BaseFactory {} + +export const rocketChatUserEntityFactory = RocketChatUserFactory.define< + RocketChatUserEntity, + RocketChatUserEntityProps +>(RocketChatUserEntity, ({ sequence }) => { + return { + id: new ObjectId().toHexString(), + userId: new ObjectId(), + username: `username-${sequence}`, + rcId: `rcId-${sequence}`, + authToken: `aythToken-${sequence}`, + createdAt: new Date(), + updatedAt: new Date(), + }; +}); diff --git a/apps/server/src/modules/rocketchat-user/index.ts b/apps/server/src/modules/rocketchat-user/index.ts new file mode 100644 index 00000000000..34ae0f25f87 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/index.ts @@ -0,0 +1,3 @@ +export * from './rocketchat-user.module'; +export * from './service'; +export * from './domain'; diff --git a/apps/server/src/modules/rocketchat-user/repo/index.ts b/apps/server/src/modules/rocketchat-user/repo/index.ts new file mode 100644 index 00000000000..b05b92fc380 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.repo'; diff --git a/apps/server/src/modules/rocketchat-user/repo/mapper/index.ts b/apps/server/src/modules/rocketchat-user/repo/mapper/index.ts new file mode 100644 index 00000000000..7a33e93289e --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/mapper/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.mapper'; diff --git a/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.spec.ts b/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.spec.ts new file mode 100644 index 00000000000..bd5a07abb5c --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.spec.ts @@ -0,0 +1,61 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { RocketChatUser } from '../../domain/rocket-chat-user.do'; +import { rocketChatUserFactory } from '../../domain/testing/rocket-chat-user.factory'; +import { RocketChatUserEntity } from '../../entity'; +import { rocketChatUserEntityFactory } from '../../entity/testing/rocket-chat-user.entity.factory'; +import { RocketChatUserMapper } from './rocket-chat-user.mapper'; + +describe(RocketChatUserMapper.name, () => { + describe('mapToDO', () => { + describe('When entity is mapped for domainObject', () => { + it('should properly map the entity to the domain object', () => { + const entity = rocketChatUserEntityFactory.build(); + + const domainObject = RocketChatUserMapper.mapToDO(entity); + + const expectedDomainObject = new RocketChatUser({ + id: entity.id, + userId: entity.userId.toHexString(), + username: entity.username, + rcId: entity.rcId, + authToken: entity.authToken, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }); + + expect(domainObject).toEqual(expectedDomainObject); + }); + }); + }); + + describe('mapToEntity', () => { + describe('When domainObject is mapped for entity', () => { + beforeAll(() => { + jest.useFakeTimers(); + jest.setSystemTime(new Date()); + }); + + afterAll(() => { + jest.useRealTimers(); + }); + + it('should properly map the domainObject to the entity', () => { + const domainObject = rocketChatUserFactory.build(); + + const entity = RocketChatUserMapper.mapToEntity(domainObject); + + const expectedEntity = new RocketChatUserEntity({ + id: domainObject.id, + userId: new ObjectId(domainObject.userId), + username: domainObject.username, + rcId: domainObject.rcId, + authToken: domainObject.authToken, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }); + + expect(entity).toEqual(expectedEntity); + }); + }); + }); +}); diff --git a/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.ts b/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.ts new file mode 100644 index 00000000000..3d45c9c34ac --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.ts @@ -0,0 +1,29 @@ +import { ObjectId } from '@mikro-orm/mongodb'; +import { RocketChatUserEntity } from '../../entity'; +import { RocketChatUser } from '../../domain/rocket-chat-user.do'; + +export class RocketChatUserMapper { + static mapToDO(entity: RocketChatUserEntity): RocketChatUser { + return new RocketChatUser({ + id: entity.id, + userId: entity.userId.toHexString(), + username: entity.username, + rcId: entity.rcId, + authToken: entity.authToken, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }); + } + + static mapToEntity(domainObject: RocketChatUser): RocketChatUserEntity { + return new RocketChatUserEntity({ + id: domainObject.id, + userId: new ObjectId(domainObject.userId), + username: domainObject.username, + rcId: domainObject.rcId, + authToken: domainObject.authToken, + createdAt: domainObject.createdAt, + updatedAt: domainObject.updatedAt, + }); + } +} diff --git a/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.spec.ts b/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.spec.ts new file mode 100644 index 00000000000..d58e5fc42d1 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.spec.ts @@ -0,0 +1,131 @@ +import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Test, TestingModule } from '@nestjs/testing'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { cleanupCollections } from '@shared/testing'; +import { RocketChatUserMapper } from './mapper'; +import { RocketChatUserEntity } from '../entity'; +import { RocketChatUserRepo } from './rocket-chat-user.repo'; +import { RocketChatUser } from '../domain'; +import { rocketChatUserEntityFactory } from '../entity/testing'; + +describe(RocketChatUserRepo.name, () => { + let module: TestingModule; + let repo: RocketChatUserRepo; + let em: EntityManager; + + beforeAll(async () => { + module = await Test.createTestingModule({ + imports: [ + MongoMemoryDatabaseModule.forRoot({ + entities: [RocketChatUserEntity], + }), + ], + providers: [RocketChatUserRepo, RocketChatUserMapper], + }).compile(); + + repo = module.get(RocketChatUserRepo); + em = module.get(EntityManager); + }); + + afterAll(async () => { + await module.close(); + }); + + afterEach(async () => { + await cleanupCollections(em); + }); + + describe('defined', () => { + it('repo should be defined', () => { + expect(repo).toBeDefined(); + expect(typeof repo.findByUserId).toEqual('function'); + }); + + it('entity manager should be defined', () => { + expect(em).toBeDefined(); + }); + + it('should implement entityName getter', () => { + expect(repo.entityName).toBe(RocketChatUserEntity); + }); + }); + + describe('findByUserId', () => { + describe('when searching rocketChatUser by userId', () => { + const setup = async () => { + const userId = new ObjectId(); + const entity: RocketChatUserEntity = rocketChatUserEntityFactory.build({ userId }); + await em.persistAndFlush(entity); + em.clear(); + const expectedRocketChatUser = { + id: entity.id, + userId: entity.userId.toHexString(), + username: entity.username, + rcId: entity.rcId, + authToken: entity.authToken, + createdAt: entity.createdAt, + updatedAt: entity.updatedAt, + }; + + return { + entity, + expectedRocketChatUser, + }; + }; + + it('should find the rocketChatUser', async () => { + const { entity, expectedRocketChatUser } = await setup(); + + const result: RocketChatUser = await repo.findByUserId(entity.userId.toHexString()); + + // Verify explicit fields. + expect(result).toEqual(expect.objectContaining(expectedRocketChatUser)); + }); + }); + }); + + describe('deleteByUserId', () => { + describe('when deleting rocketChatUser exists', () => { + const setup = async () => { + const entity: RocketChatUserEntity = rocketChatUserEntityFactory.build(); + const rocketChatUserId = entity.userId.toHexString(); + await em.persistAndFlush(entity); + em.clear(); + + return { rocketChatUserId }; + }; + + it('should delete the rocketChatUSer with userId', async () => { + const { rocketChatUserId } = await setup(); + + await repo.deleteByUserId(rocketChatUserId); + + expect(await em.findOne(RocketChatUserEntity, { userId: new ObjectId(rocketChatUserId) })).toBeNull(); + }); + + it('should return number equal 1', async () => { + const { rocketChatUserId } = await setup(); + + const result: number = await repo.deleteByUserId(rocketChatUserId); + + expect(result).toEqual(1); + }); + }); + + describe('when no rocketChatUser exists', () => { + const setup = () => { + const rocketChatUserId = new ObjectId().toHexString(); + + return { rocketChatUserId }; + }; + + it('should return false', async () => { + const { rocketChatUserId } = setup(); + + const result: number = await repo.deleteByUserId(rocketChatUserId); + + expect(result).toEqual(0); + }); + }); + }); +}); diff --git a/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.ts b/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.ts new file mode 100644 index 00000000000..741f297f804 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/repo/rocket-chat-user.repo.ts @@ -0,0 +1,33 @@ +import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { RocketChatUserEntity } from '../entity'; +import { RocketChatUser } from '../domain/rocket-chat-user.do'; +import { RocketChatUserMapper } from './mapper'; + +@Injectable() +export class RocketChatUserRepo { + constructor(private readonly em: EntityManager) {} + + get entityName() { + return RocketChatUserEntity; + } + + async findByUserId(userId: EntityId): Promise { + const entity: RocketChatUserEntity = await this.em.findOneOrFail(RocketChatUserEntity, { + userId: new ObjectId(userId), + }); + + const mapped: RocketChatUser = RocketChatUserMapper.mapToDO(entity); + + return mapped; + } + + async deleteByUserId(userId: EntityId): Promise { + const promise: Promise = this.em.nativeDelete(RocketChatUserEntity, { + userId: new ObjectId(userId), + }); + + return promise; + } +} diff --git a/apps/server/src/modules/rocketchat-user/rocketchat-user.module.ts b/apps/server/src/modules/rocketchat-user/rocketchat-user.module.ts new file mode 100644 index 00000000000..798b2276a4d --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/rocketchat-user.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { RocketChatUserRepo } from './repo'; +import { RocketChatUserService } from './service/rocket-chat-user.service'; +import { RocketChatService } from '../rocketchat/rocket-chat.service'; + +@Module({ + providers: [RocketChatUserService, RocketChatUserRepo], + exports: [RocketChatService], +}) +export class RocketChatUserModule {} diff --git a/apps/server/src/modules/rocketchat-user/service/index.ts b/apps/server/src/modules/rocketchat-user/service/index.ts new file mode 100644 index 00000000000..350217d4e38 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/service/index.ts @@ -0,0 +1 @@ +export * from './rocket-chat-user.service'; diff --git a/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.spec.ts b/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.spec.ts new file mode 100644 index 00000000000..dd8ae17667c --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.spec.ts @@ -0,0 +1,94 @@ +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { Test, TestingModule } from '@nestjs/testing'; +import { setupEntities } from '@shared/testing'; +import { RocketChatUserService } from './rocket-chat-user.service'; +import { RocketChatUserRepo } from '../repo'; +import { rocketChatUserFactory } from '../domain/testing/rocket-chat-user.factory'; +import { RocketChatUser } from '../domain'; + +describe(RocketChatUserService.name, () => { + let module: TestingModule; + let service: RocketChatUserService; + let rocketChatUserRepo: DeepMocked; + + beforeAll(async () => { + module = await Test.createTestingModule({ + providers: [ + RocketChatUserService, + { + provide: RocketChatUserRepo, + useValue: createMock(), + }, + ], + }).compile(); + + service = module.get(RocketChatUserService); + rocketChatUserRepo = module.get(RocketChatUserRepo); + + await setupEntities(); + }); + + beforeEach(() => { + jest.clearAllMocks(); + }); + + afterAll(async () => { + await module.close(); + }); + + describe('findByUserId', () => { + describe('when searching rocketChatUser', () => { + const setup = () => { + const userId: string = new ObjectId().toHexString(); + + const rocketChatUser: RocketChatUser = rocketChatUserFactory.build(); + + rocketChatUserRepo.findByUserId.mockResolvedValueOnce(rocketChatUser); + + return { + userId, + rocketChatUser, + }; + }; + + it('should return the rocketChatUser', async () => { + const { userId, rocketChatUser } = setup(); + + const result: RocketChatUser = await service.findByUserId(userId); + + expect(result).toEqual(rocketChatUser); + }); + }); + }); + + describe('deleteUserDataFromClasses', () => { + describe('when deleting rocketChatUser', () => { + const setup = () => { + const userId = new ObjectId().toHexString(); + + rocketChatUserRepo.deleteByUserId.mockResolvedValueOnce(1); + + return { + userId, + }; + }; + + it('should call rocketChatUserRepo', async () => { + const { userId } = setup(); + + await service.deleteByUserId(userId); + + expect(rocketChatUserRepo.deleteByUserId).toBeCalledWith(userId); + }); + + it('should delete rocketChatUser by userId', async () => { + const { userId } = setup(); + + const result: number = await service.deleteByUserId(userId); + + expect(result).toEqual(1); + }); + }); + }); +}); diff --git a/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.ts b/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.ts new file mode 100644 index 00000000000..32a600c0f75 --- /dev/null +++ b/apps/server/src/modules/rocketchat-user/service/rocket-chat-user.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@nestjs/common'; +import { EntityId } from '@shared/domain'; +import { RocketChatUserRepo } from '../repo'; +import { RocketChatUser } from '../domain'; + +@Injectable() +export class RocketChatUserService { + constructor(private readonly rocketChatUserRepo: RocketChatUserRepo) {} + + public async findByUserId(userId: EntityId): Promise { + const user: RocketChatUser = await this.rocketChatUserRepo.findByUserId(userId); + + return user; + } + + public deleteByUserId(userId: EntityId): Promise { + return this.rocketChatUserRepo.deleteByUserId(userId); + } +} diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index 09dd2210928..becc7ec78fc 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import type { IIdentityManagementConfig } from '@shared/infra/identity-management'; +import type { IIdentityManagementConfig } from '@infra/identity-management'; import type { ICoreModuleConfig } from '@src/core'; import type { IAccountConfig } from '@modules/account'; import type { IFilesStorageClientConfig } from '@modules/files-storage-client'; diff --git a/apps/server/src/modules/server/server.module.ts b/apps/server/src/modules/server/server.module.ts index 9454fa06154..a812ff773b2 100644 --- a/apps/server/src/modules/server/server.module.ts +++ b/apps/server/src/modules/server/server.module.ts @@ -28,10 +28,10 @@ import { VideoConferenceApiModule } from '@modules/video-conference/video-confer import { DynamicModule, Inject, MiddlewareConsumer, Module, NestModule, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { ALL_ENTITIES } from '@shared/domain'; -import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@shared/infra/database'; -import { MailModule } from '@shared/infra/mail'; -import { RabbitMQWrapperModule, RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; -import { RedisModule, REDIS_CLIENT } from '@shared/infra/redis'; +import { MongoDatabaseModuleOptions, MongoMemoryDatabaseModule } from '@infra/database'; +import { MailModule } from '@infra/mail'; +import { RabbitMQWrapperModule, RabbitMQWrapperTestModule } from '@infra/rabbitmq'; +import { RedisModule, REDIS_CLIENT } from '@infra/redis'; import { createConfigModuleOptions, DB_PASSWORD, DB_URL, DB_USERNAME } from '@src/config'; import { CoreModule } from '@src/core'; import { LegacyLogger, LoggerModule } from '@src/core/logger'; diff --git a/apps/server/src/modules/sharing/repo/share-token.repo.integration.spec.ts b/apps/server/src/modules/sharing/repo/share-token.repo.integration.spec.ts index 4bd73e6c2a8..f5e01b0e9ea 100644 --- a/apps/server/src/modules/sharing/repo/share-token.repo.integration.spec.ts +++ b/apps/server/src/modules/sharing/repo/share-token.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, schoolFactory, shareTokenFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { ShareTokenContextType } from '../domainobject/share-token.do'; diff --git a/apps/server/src/modules/system/service/system.service.spec.ts b/apps/server/src/modules/system/service/system.service.spec.ts index ead44bf6133..89ef533058b 100644 --- a/apps/server/src/modules/system/service/system.service.spec.ts +++ b/apps/server/src/modules/system/service/system.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { OauthConfig, SystemEntity, SystemTypeEnum } from '@shared/domain'; -import { IdentityManagementOauthService } from '@shared/infra/identity-management'; +import { IdentityManagementOauthService } from '@infra/identity-management'; import { SystemRepo } from '@shared/repo'; import { systemFactory } from '@shared/testing'; import { SystemMapper } from '../mapper/system.mapper'; diff --git a/apps/server/src/modules/system/service/system.service.ts b/apps/server/src/modules/system/service/system.service.ts index 960c15f7945..bfb6a2ec7bf 100644 --- a/apps/server/src/modules/system/service/system.service.ts +++ b/apps/server/src/modules/system/service/system.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; import { EntityNotFoundError } from '@shared/common'; import { EntityId, SystemEntity, SystemTypeEnum } from '@shared/domain'; -import { IdentityManagementOauthService } from '@shared/infra/identity-management/identity-management-oauth.service'; +import { IdentityManagementOauthService } from '@infra/identity-management/identity-management-oauth.service'; import { SystemRepo } from '@shared/repo'; import { SystemMapper } from '@modules/system/mapper/system.mapper'; import { SystemDto } from '@modules/system/service/dto/system.dto'; diff --git a/apps/server/src/modules/system/system.module.ts b/apps/server/src/modules/system/system.module.ts index 64caef0df61..37ca8d7a858 100644 --- a/apps/server/src/modules/system/system.module.ts +++ b/apps/server/src/modules/system/system.module.ts @@ -1,5 +1,5 @@ import { Module } from '@nestjs/common'; -import { IdentityManagementModule } from '@shared/infra/identity-management/identity-management.module'; +import { IdentityManagementModule } from '@infra/identity-management/identity-management.module'; import { SystemRepo } from '@shared/repo'; import { SystemService } from '@modules/system/service/system.service'; import { SystemOidcService } from './service/system-oidc.service'; diff --git a/apps/server/src/modules/task/service/submission.service.spec.ts b/apps/server/src/modules/task/service/submission.service.spec.ts index 4d7373570cf..abf5ed9f152 100644 --- a/apps/server/src/modules/task/service/submission.service.spec.ts +++ b/apps/server/src/modules/task/service/submission.service.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { Counted, Submission } from '@shared/domain'; -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { SubmissionRepo } from '@shared/repo'; import { setupEntities, submissionFactory, taskFactory } from '@shared/testing'; import { FileDto, FilesStorageClientAdapterService } from '@modules/files-storage-client'; diff --git a/apps/server/src/modules/tool/external-tool/external-tool.module.ts b/apps/server/src/modules/tool/external-tool/external-tool.module.ts index 7db5c25a252..2fbd2f28edd 100644 --- a/apps/server/src/modules/tool/external-tool/external-tool.module.ts +++ b/apps/server/src/modules/tool/external-tool/external-tool.module.ts @@ -1,8 +1,8 @@ import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; import { LoggerModule } from '@src/core/logger'; -import { OauthProviderServiceModule } from '@shared/infra/oauth-provider'; -import { EncryptionModule } from '@shared/infra/encryption'; +import { OauthProviderServiceModule } from '@infra/oauth-provider'; +import { EncryptionModule } from '@infra/encryption'; import { ExternalToolRepo } from '@shared/repo'; import { ToolConfigModule } from '../tool-config.module'; import { diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.spec.ts index 53a07c02e30..fb506a22f8c 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { ExternalToolServiceMapper } from './external-tool-service.mapper'; import { TokenEndpointAuthMethod, ToolConfigType } from '../../common/enum'; import { Oauth2ToolConfig } from '../domain'; diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.ts index 31ff93db828..c531f33c483 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-service.mapper.ts @@ -1,4 +1,4 @@ -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { Injectable } from '@nestjs/common'; import { Oauth2ToolConfig } from '../domain'; diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool.service.spec.ts index 4db2a5be0b0..ddb88ca4ff3 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool.service.spec.ts @@ -2,9 +2,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { IFindOptions, Page, SortOrder } from '@shared/domain'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { externalToolFactory, diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool.service.ts index fcc1a7e2d5c..0aa6181682c 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool.service.ts @@ -1,8 +1,8 @@ import { Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; import { EntityId, IFindOptions, Page } from '@shared/domain'; -import { DefaultEncryptionService, IEncryptionService } from '@shared/infra/encryption'; -import { OauthProviderService } from '@shared/infra/oauth-provider'; -import { ProviderOauthClient } from '@shared/infra/oauth-provider/dto'; +import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { TokenEndpointAuthMethod } from '../../common/enum'; diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts b/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts index 3c3baa56475..ff4aa4c266c 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts @@ -16,7 +16,7 @@ import { SystemEntity, User, } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ImportUserRepo, SystemRepo, UserRepo } from '@shared/repo'; import { federalStateFactory, importUserFactory, schoolFactory, userFactory } from '@shared/testing'; import { systemFactory } from '@shared/testing/factory/system.factory'; diff --git a/apps/server/src/modules/video-conference/service/video-conference.service.spec.ts b/apps/server/src/modules/video-conference/service/video-conference.service.spec.ts index c7a1ed30668..28711a06c1a 100644 --- a/apps/server/src/modules/video-conference/service/video-conference.service.spec.ts +++ b/apps/server/src/modules/video-conference/service/video-conference.service.spec.ts @@ -12,7 +12,7 @@ import { VideoConferenceDO, VideoConferenceScope, } from '@shared/domain'; -import { CalendarEventDto, CalendarService } from '@shared/infra/calendar'; +import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; import { LegacySchoolService } from '@modules/legacy-school'; diff --git a/apps/server/src/modules/video-conference/service/video-conference.service.ts b/apps/server/src/modules/video-conference/service/video-conference.service.ts index 22e7a7462f1..401cc0a0015 100644 --- a/apps/server/src/modules/video-conference/service/video-conference.service.ts +++ b/apps/server/src/modules/video-conference/service/video-conference.service.ts @@ -14,7 +14,7 @@ import { VideoConferenceOptionsDO, VideoConferenceScope, } from '@shared/domain'; -import { CalendarEventDto, CalendarService } from '@shared/infra/calendar'; +import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; import { CourseService } from '@modules/learnroom'; diff --git a/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.spec.ts b/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.spec.ts index 994c8042a6d..bf1fd3e1394 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.spec.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.spec.ts @@ -14,8 +14,8 @@ import { VideoConferenceDO, } from '@shared/domain'; import { VideoConferenceScope } from '@shared/domain/interface'; -import { CalendarService } from '@shared/infra/calendar'; -import { CalendarEventDto } from '@shared/infra/calendar/dto/calendar-event.dto'; +import { CalendarService } from '@infra/calendar'; +import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; import { roleFactory, setupEntities, userDoFactory } from '@shared/testing'; import { teamFactory } from '@shared/testing/factory/team.factory'; diff --git a/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.ts b/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.ts index 41e011c4acd..95470053e6d 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-deprecated.uc.ts @@ -13,8 +13,8 @@ import { VideoConferenceOptionsDO, } from '@shared/domain'; import { VideoConferenceScope } from '@shared/domain/interface'; -import { CalendarService } from '@shared/infra/calendar'; -import { CalendarEventDto } from '@shared/infra/calendar/dto/calendar-event.dto'; +import { CalendarService } from '@infra/calendar'; +import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; import { TeamsRepo } from '@shared/repo'; import { VideoConferenceRepo } from '@shared/repo/videoconference/video-conference.repo'; import { ICurrentUser } from '@modules/authentication'; diff --git a/apps/server/src/modules/video-conference/video-conference.module.ts b/apps/server/src/modules/video-conference/video-conference.module.ts index c9708b16dc9..d7e4671c0f2 100644 --- a/apps/server/src/modules/video-conference/video-conference.module.ts +++ b/apps/server/src/modules/video-conference/video-conference.module.ts @@ -1,6 +1,6 @@ import { Module } from '@nestjs/common'; import { HttpModule } from '@nestjs/axios'; -import { CalendarModule } from '@shared/infra/calendar'; +import { CalendarModule } from '@infra/calendar'; import { VideoConferenceRepo } from '@shared/repo/videoconference/video-conference.repo'; import { AuthorizationModule } from '@modules/authorization'; import { AuthorizationReferenceModule } from '@modules/authorization/authorization-reference.module'; diff --git a/apps/server/src/shared/domain/entity/all-entities.spec.ts b/apps/server/src/shared/domain/entity/all-entities.spec.ts index 33d924b20ce..b7a27fd58b4 100644 --- a/apps/server/src/shared/domain/entity/all-entities.spec.ts +++ b/apps/server/src/shared/domain/entity/all-entities.spec.ts @@ -1,7 +1,7 @@ import { MikroORM } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ALL_ENTITIES } from '.'; describe('BaseRepo', () => { diff --git a/apps/server/src/shared/infra/collaborative-storage/index.ts b/apps/server/src/shared/infra/collaborative-storage/index.ts deleted file mode 100644 index ea5aa25514c..00000000000 --- a/apps/server/src/shared/infra/collaborative-storage/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './collaborative-storage.adapter'; diff --git a/apps/server/src/shared/repo/base.do.repo.integration.spec.ts b/apps/server/src/shared/repo/base.do.repo.integration.spec.ts index 563940a571e..1ca91bd184e 100644 --- a/apps/server/src/shared/repo/base.do.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/base.do.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Entity, EntityName, Property } from '@mikro-orm/core'; import { BaseDO, BaseEntityWithTimestamps } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { Injectable } from '@nestjs/common'; import { BaseDORepo } from '@shared/repo/base.do.repo'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/shared/repo/base.repo.integration.spec.ts b/apps/server/src/shared/repo/base.repo.integration.spec.ts index 0c0e041f575..372a6ba4cda 100644 --- a/apps/server/src/shared/repo/base.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/base.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Entity, EntityName, Property } from '@mikro-orm/core'; import { BaseEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { Injectable } from '@nestjs/common'; import { BaseRepo } from './base.repo'; diff --git a/apps/server/src/shared/repo/board/board.repo.spec.ts b/apps/server/src/shared/repo/board/board.repo.spec.ts index 51ce325e90a..7d5f4b71e41 100644 --- a/apps/server/src/shared/repo/board/board.repo.spec.ts +++ b/apps/server/src/shared/repo/board/board.repo.spec.ts @@ -10,7 +10,7 @@ import { cleanupCollections, } from '@shared/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { BoardRepo } from './board.repo'; diff --git a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts index 0a9151d8c9c..854c3958135 100644 --- a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { SchoolEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ExternalToolRepoMapper } from '@shared/repo/externaltool/external-tool.repo.mapper'; import { cleanupCollections, diff --git a/apps/server/src/shared/repo/course/course.repo.integration.spec.ts b/apps/server/src/shared/repo/course/course.repo.integration.spec.ts index 5474c4ec19d..2a77ad1f078 100644 --- a/apps/server/src/shared/repo/course/course.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/course/course.repo.integration.spec.ts @@ -3,7 +3,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Course, EntityId, SortOrder } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, courseFactory, courseGroupFactory, userFactory } from '@shared/testing'; import { CourseRepo } from './course.repo'; diff --git a/apps/server/src/shared/repo/coursegroup/coursegroup.repo.integration.spec.ts b/apps/server/src/shared/repo/coursegroup/coursegroup.repo.integration.spec.ts index 459a2add113..805088480fd 100644 --- a/apps/server/src/shared/repo/coursegroup/coursegroup.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/coursegroup/coursegroup.repo.integration.spec.ts @@ -1,6 +1,6 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { EntityId, CourseGroup, Course } from '@shared/domain'; import { courseFactory, courseGroupFactory } from '@shared/testing'; import { CourseGroupRepo } from './coursegroup.repo'; diff --git a/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.spec.ts b/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.spec.ts index 4f242caecd8..32b35ced07e 100644 --- a/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.spec.ts +++ b/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.spec.ts @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { InternalServerErrorException } from '@nestjs/common'; import { DashboardEntity, diff --git a/apps/server/src/shared/repo/dashboard/dashboard.repo.integration.spec.ts b/apps/server/src/shared/repo/dashboard/dashboard.repo.integration.spec.ts index 1b3e2aefd63..3ca95112f4d 100644 --- a/apps/server/src/shared/repo/dashboard/dashboard.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/dashboard/dashboard.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { DashboardEntity, DashboardGridElementModel, GridElement } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { courseFactory, userFactory } from '@shared/testing'; import { DashboardModelMapper } from './dashboard.model.mapper'; import { DashboardRepo } from './dashboard.repo'; diff --git a/apps/server/src/shared/repo/externaltool/external-tool.repo.integration.spec.ts b/apps/server/src/shared/repo/externaltool/external-tool.repo.integration.spec.ts index 56cba80ec69..1654da1b5b7 100644 --- a/apps/server/src/shared/repo/externaltool/external-tool.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/externaltool/external-tool.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { IFindOptions, Page, SortOrder } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ExternalToolRepo, ExternalToolRepoMapper } from '@shared/repo'; import { cleanupCollections, externalToolEntityFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; diff --git a/apps/server/src/shared/repo/federalstate/federal-state.repo.spec.ts b/apps/server/src/shared/repo/federalstate/federal-state.repo.spec.ts index bfd6b6e358e..0b5742c7621 100644 --- a/apps/server/src/shared/repo/federalstate/federal-state.repo.spec.ts +++ b/apps/server/src/shared/repo/federalstate/federal-state.repo.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { EntityManager } from '@mikro-orm/mongodb'; import { FederalStateEntity } from '@shared/domain'; import { cleanupCollections, federalStateFactory } from '@shared/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { FederalStateRepo } from './federal-state.repo'; describe('FederalStateRepo', () => { diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts b/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts index 7f02bf4ea01..148984c393a 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts @@ -12,7 +12,7 @@ import { SchoolEntity, User, } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ImportUserRepo } from '.'; describe('ImportUserRepo', () => { diff --git a/apps/server/src/shared/repo/lesson/lesson.repo.integration.spec.ts b/apps/server/src/shared/repo/lesson/lesson.repo.integration.spec.ts index 5143eb6fba8..eae071d55ae 100644 --- a/apps/server/src/shared/repo/lesson/lesson.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/lesson/lesson.repo.integration.spec.ts @@ -3,7 +3,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ComponentType, IComponentProperties, LessonEntity } from '@shared/domain'; import { cleanupCollections, courseFactory, lessonFactory, materialFactory, taskFactory } from '@shared/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { LessonRepo } from './lesson.repo'; diff --git a/apps/server/src/shared/repo/ltitool/ltitool.repo.spec.ts b/apps/server/src/shared/repo/ltitool/ltitool.repo.spec.ts index c8b8a7aea50..97fc81e9ea1 100644 --- a/apps/server/src/shared/repo/ltitool/ltitool.repo.spec.ts +++ b/apps/server/src/shared/repo/ltitool/ltitool.repo.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ILtiToolProperties, LtiTool } from '@shared/domain'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; import { LtiPrivacyPermission, LtiRoleType } from '@shared/domain/entity/ltitool.entity'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { LtiToolRepo } from '@shared/repo/ltitool/ltitool.repo'; import { cleanupCollections } from '@shared/testing'; import { ltiToolFactory } from '@shared/testing/factory/ltitool.factory'; diff --git a/apps/server/src/shared/repo/materials/materials.repo.integration.spec.ts b/apps/server/src/shared/repo/materials/materials.repo.integration.spec.ts index 13556fad62c..0b6b26ff39f 100644 --- a/apps/server/src/shared/repo/materials/materials.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/materials/materials.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Material } from '@shared/domain/entity/materials.entity'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections } from '@shared/testing'; import { MaterialsRepo } from './materials.repo'; diff --git a/apps/server/src/shared/repo/news/news-inheritance.spec.ts b/apps/server/src/shared/repo/news/news-inheritance.spec.ts index 53eb2aa4dd4..d9d5a003d5d 100644 --- a/apps/server/src/shared/repo/news/news-inheritance.spec.ts +++ b/apps/server/src/shared/repo/news/news-inheritance.spec.ts @@ -2,7 +2,7 @@ import { Collection, Entity, Enum, ManyToMany, ManyToOne, Property } from '@mikr import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { BaseEntityWithTimestamps } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections } from '@shared/testing'; @Entity({ tableName: 'users' }) diff --git a/apps/server/src/shared/repo/news/news.repo.integration.spec.ts b/apps/server/src/shared/repo/news/news.repo.integration.spec.ts index 93bff583f4e..d68e50e0df1 100644 --- a/apps/server/src/shared/repo/news/news.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/news/news.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { News, NewsTargetModel, SortOrder } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { courseNewsFactory, schoolNewsFactory, diff --git a/apps/server/src/shared/repo/role/role.repo.integration.spec.ts b/apps/server/src/shared/repo/role/role.repo.integration.spec.ts index 04834698419..65bc0931a6e 100644 --- a/apps/server/src/shared/repo/role/role.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/role/role.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError, NullCacheAdapter, ValidationError } from '@mikro-orm/cor import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Role, RoleName } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, roleFactory } from '@shared/testing'; import { RoleRepo } from './role.repo'; diff --git a/apps/server/src/shared/repo/school/legacy-school.repo.integration.spec.ts b/apps/server/src/shared/repo/school/legacy-school.repo.integration.spec.ts index e9f14ba3315..775c193675d 100644 --- a/apps/server/src/shared/repo/school/legacy-school.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/school/legacy-school.repo.integration.spec.ts @@ -13,7 +13,7 @@ import { SystemEntity, UserLoginMigrationEntity, } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { legacySchoolDoFactory, schoolFactory, diff --git a/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.integration.spec.ts b/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.integration.spec.ts index a2844e8e426..47196013b63 100644 --- a/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { type SchoolEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { ExternalToolRepoMapper } from '@shared/repo/externaltool/external-tool.repo.mapper'; import { cleanupCollections, diff --git a/apps/server/src/shared/repo/storageprovider/storageprovider.repo.spec.ts b/apps/server/src/shared/repo/storageprovider/storageprovider.repo.spec.ts index 707ff1b778d..1f24fe0bd0b 100644 --- a/apps/server/src/shared/repo/storageprovider/storageprovider.repo.spec.ts +++ b/apps/server/src/shared/repo/storageprovider/storageprovider.repo.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { StorageProviderEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, storageProviderFactory } from '@shared/testing'; import { StorageProviderRepo } from './storageprovider.repo'; diff --git a/apps/server/src/shared/repo/submission/submission.repo.integration.spec.ts b/apps/server/src/shared/repo/submission/submission.repo.integration.spec.ts index 772c9d4ea1b..547fe2f05a1 100644 --- a/apps/server/src/shared/repo/submission/submission.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/submission/submission.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { Submission } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, courseFactory, diff --git a/apps/server/src/shared/repo/system/system.repo.integration.spec.ts b/apps/server/src/shared/repo/system/system.repo.integration.spec.ts index 7c3c10a2fab..d8a5c1d87e3 100644 --- a/apps/server/src/shared/repo/system/system.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/system/system.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { SystemEntity, SystemTypeEnum } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { SystemRepo } from '@shared/repo'; import { systemFactory } from '@shared/testing/factory/system.factory'; diff --git a/apps/server/src/shared/repo/task/task.repo.integration.spec.ts b/apps/server/src/shared/repo/task/task.repo.integration.spec.ts index 52f20ab2cab..b975f485dea 100644 --- a/apps/server/src/shared/repo/task/task.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/task/task.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { SortOrder, Task } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, courseFactory, diff --git a/apps/server/src/shared/repo/teams/team.repo.integration.spec.ts b/apps/server/src/shared/repo/teams/team.repo.integration.spec.ts index 8d68ea8cf21..92e3d9d63c7 100644 --- a/apps/server/src/shared/repo/teams/team.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/teams/team.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId, TeamEntity, TeamUserEntity } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { TeamsRepo } from '@shared/repo'; import { cleanupCollections, roleFactory } from '@shared/testing'; import { teamFactory } from '@shared/testing/factory/team.factory'; diff --git a/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts b/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts index ddcfb55b520..43d46a95383 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.integration.spec.ts @@ -16,7 +16,7 @@ import { } from '@shared/domain'; import { Page } from '@shared/domain/domainobject/page'; import { UserDO } from '@shared/domain/domainobject/user.do'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; import { cleanupCollections, diff --git a/apps/server/src/shared/repo/user/user.repo.integration.spec.ts b/apps/server/src/shared/repo/user/user.repo.integration.spec.ts index d469b59c14b..ea10e6e5b3e 100644 --- a/apps/server/src/shared/repo/user/user.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/user/user.repo.integration.spec.ts @@ -2,7 +2,7 @@ import { NotFoundError } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { MatchCreator, SortOrder, SystemEntity, User } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, importUserFactory, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import { systemFactory } from '@shared/testing/factory/system.factory'; import { UserRepo } from './user.repo'; diff --git a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts index 230e715307a..266cd0381c1 100644 --- a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts @@ -3,7 +3,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; import { SchoolEntity, SystemEntity, UserLoginMigrationDO } from '@shared/domain'; import { UserLoginMigrationEntity } from '@shared/domain/entity/user-login-migration.entity'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections, schoolFactory, systemFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; import { userLoginMigrationFactory } from '../../testing/factory/user-login-migration.factory'; diff --git a/apps/server/src/shared/repo/videoconference/video-conference.repo.spec.ts b/apps/server/src/shared/repo/videoconference/video-conference.repo.spec.ts index 239b80fc3e9..06e4f057fa7 100644 --- a/apps/server/src/shared/repo/videoconference/video-conference.repo.spec.ts +++ b/apps/server/src/shared/repo/videoconference/video-conference.repo.spec.ts @@ -1,7 +1,7 @@ import { VideoConferenceRepo } from '@shared/repo'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { MongoMemoryDatabaseModule } from '@shared/infra/database'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { cleanupCollections } from '@shared/testing'; import { IVideoConferenceProperties, diff --git a/apps/server/src/shared/testing/factory/filerecord.factory.ts b/apps/server/src/shared/testing/factory/filerecord.factory.ts index 36811ed9752..4e12787f661 100644 --- a/apps/server/src/shared/testing/factory/filerecord.factory.ts +++ b/apps/server/src/shared/testing/factory/filerecord.factory.ts @@ -1,4 +1,4 @@ -import { FileRecordParentType } from '@shared/infra/rabbitmq'; +import { FileRecordParentType } from '@infra/rabbitmq'; import { FileRecord, FileRecordSecurityCheck, IFileRecordProperties } from '@modules/files-storage/entity'; import { ObjectId } from 'bson'; import { DeepPartial } from 'fishery'; diff --git a/jest.config.ts b/jest.config.ts index 032f4828dde..9ee33256a5e 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -26,6 +26,7 @@ let config: Config.InitialOptions = { '^@shared/(.*)$': '/apps/server/src/shared/$1', '^@src/(.*)$': '/apps/server/src/$1', '^@modules/(.*)$': '/apps/server/src/modules/$1', + '^@infra/(.*)$': '/apps/server/src/infra/$1', }, maxWorkers: 2, // limited for not taking all workers within of a single github action }; diff --git a/tsconfig.json b/tsconfig.json index 9bb7c6f72f0..147df972b6f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "@shared/*": ["apps/server/src/shared/*"], "@src/*": ["apps/server/src/*"], "@modules/*": ["apps/server/src/modules/*"], + "@infra/*": ["apps/server/src/infra/*"], }, } }