From a534f54dc17414501fe90dbf93fafa7bd47f321d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 10:58:46 +0100 Subject: [PATCH 001/110] IErrorType -> ErrorType --- .../src/core/error/interface/error-type.interface.ts | 2 +- apps/server/src/core/error/server-error-types.ts | 10 +++++----- apps/server/src/shared/common/error/business.error.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/core/error/interface/error-type.interface.ts b/apps/server/src/core/error/interface/error-type.interface.ts index 9ea4939da89..006fa18c793 100644 --- a/apps/server/src/core/error/interface/error-type.interface.ts +++ b/apps/server/src/core/error/interface/error-type.interface.ts @@ -1,4 +1,4 @@ -export interface IErrorType { +export interface ErrorType { readonly type: string; readonly title: string; readonly defaultMessage: string; diff --git a/apps/server/src/core/error/server-error-types.ts b/apps/server/src/core/error/server-error-types.ts index 3224aec5016..91538d75cc3 100644 --- a/apps/server/src/core/error/server-error-types.ts +++ b/apps/server/src/core/error/server-error-types.ts @@ -1,13 +1,13 @@ /** * all errors defined in the application require a definition, - * implementing the @IErrorType where their type is unambigious within of the application. + * implementing the @ErrorType where their type is unambigious within of the application. * */ import legacyErrorTypes = require('../../../../../src/errors/commonErrorTypes'); -import { IErrorType } from './interface/error-type.interface'; +import { ErrorType } from './interface/error-type.interface'; -// check legacy error typing is matching IErrorType -const serverErrorTypes: { [index: string]: IErrorType } = legacyErrorTypes; +// check legacy error typing is matching ErrorType +const serverErrorTypes: { [index: string]: ErrorType } = legacyErrorTypes; // re-use legacy error types export const { INTERNAL_SERVER_ERROR_TYPE, ASSERTION_ERROR_TYPE, API_VALIDATION_ERROR_TYPE, FORBIDDEN_ERROR_TYPE } = @@ -15,7 +15,7 @@ export const { INTERNAL_SERVER_ERROR_TYPE, ASSERTION_ERROR_TYPE, API_VALIDATION_ // further error types -export const NOT_FOUND_ERROR_TYPE: IErrorType = { +export const NOT_FOUND_ERROR_TYPE: ErrorType = { type: 'NOT_FOUND_ERROR', title: 'Not Found', defaultMessage: 'The requested ressource has not been found.', diff --git a/apps/server/src/shared/common/error/business.error.ts b/apps/server/src/shared/common/error/business.error.ts index b65a43d0fa9..cb90422071c 100644 --- a/apps/server/src/shared/common/error/business.error.ts +++ b/apps/server/src/shared/common/error/business.error.ts @@ -1,7 +1,7 @@ import { HttpException, HttpStatus } from '@nestjs/common'; import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { ErrorResponse } from '@src/core/error/dto/error.response'; -import { IErrorType } from '@src/core/error/interface'; +import { ErrorType } from '@src/core/error/interface'; /** * Abstract base class for business errors, errors that are handled @@ -25,7 +25,7 @@ export abstract class BusinessError extends HttpException { readonly details?: Record; protected constructor( - { type, title, defaultMessage }: IErrorType, + { type, title, defaultMessage }: ErrorType, code: HttpStatus = HttpStatus.CONFLICT, details?: Record, cause?: unknown From fac77e33e2ff3c0097699629f2850768a1ca6e63 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 11:07:01 +0100 Subject: [PATCH 002/110] ICoreModuleConfig -> CoreModuleConfig --- apps/server/src/core/interfaces/core-module-config.ts | 2 +- .../src/modules/files-storage/files-storage.config.ts | 4 ++-- apps/server/src/modules/server/server.config.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/core/interfaces/core-module-config.ts b/apps/server/src/core/interfaces/core-module-config.ts index 21f4cd51b7d..6455adf437f 100644 --- a/apps/server/src/core/interfaces/core-module-config.ts +++ b/apps/server/src/core/interfaces/core-module-config.ts @@ -1,4 +1,4 @@ import { IInterceptorConfig } from '@shared/common'; import { ILoggerConfig } from '../logger'; -export interface ICoreModuleConfig extends IInterceptorConfig, ILoggerConfig {} +export interface CoreModuleConfig extends IInterceptorConfig, ILoggerConfig {} 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..f1cc7286d21 100644 --- a/apps/server/src/modules/files-storage/files-storage.config.ts +++ b/apps/server/src/modules/files-storage/files-storage.config.ts @@ -1,9 +1,9 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { S3Config } from '@shared/infra/s3-client'; -import { ICoreModuleConfig } from '@src/core'; +import { CoreModuleConfig } from '@src/core'; export const FILES_STORAGE_S3_CONNECTION = 'FILES_STORAGE_S3_CONNECTION'; -export interface IFileStorageConfig extends ICoreModuleConfig { +export interface IFileStorageConfig extends CoreModuleConfig { MAX_FILE_SIZE: number; MAX_SECURITY_CHECK_FILE_SIZE: number; USE_STREAM_TO_ANTIVIRUS: boolean; diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index 09dd2210928..a31b0793316 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -1,10 +1,10 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import type { IIdentityManagementConfig } from '@shared/infra/identity-management'; -import type { ICoreModuleConfig } from '@src/core'; import type { IAccountConfig } from '@modules/account'; import type { IFilesStorageClientConfig } from '@modules/files-storage-client'; -import type { IUserConfig } from '@modules/user'; import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; +import type { IUserConfig } from '@modules/user'; +import type { IIdentityManagementConfig } from '@shared/infra/identity-management'; +import type { CoreModuleConfig } from '@src/core'; export enum NodeEnvType { TEST = 'test', @@ -14,7 +14,7 @@ export enum NodeEnvType { } export interface IServerConfig - extends ICoreModuleConfig, + extends CoreModuleConfig, IUserConfig, IFilesStorageClientConfig, IAccountConfig, From 6ef26a5553c3a42ab03fc73aa1c9ef3fa9dba22b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 11:11:16 +0100 Subject: [PATCH 003/110] IInterceptorConfig -> InterceptorConfig --- apps/server/src/core/interceptor/interceptor.module.ts | 6 +++--- apps/server/src/core/interfaces/core-module-config.ts | 4 ++-- .../common/interceptor/interfaces/interceptor-config.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/core/interceptor/interceptor.module.ts b/apps/server/src/core/interceptor/interceptor.module.ts index 6815e44a867..12f12306335 100644 --- a/apps/server/src/core/interceptor/interceptor.module.ts +++ b/apps/server/src/core/interceptor/interceptor.module.ts @@ -1,7 +1,7 @@ import { ClassSerializerInterceptor, Module } from '@nestjs/common'; -import { APP_INTERCEPTOR } from '@nestjs/core'; -import { IInterceptorConfig, TimeoutInterceptor } from '@shared/common'; import { ConfigService } from '@nestjs/config'; +import { APP_INTERCEPTOR } from '@nestjs/core'; +import { InterceptorConfig, TimeoutInterceptor } from '@shared/common'; /** ********************************************* * Global Interceptor setup @@ -18,7 +18,7 @@ import { ConfigService } from '@nestjs/config'; }, { provide: APP_INTERCEPTOR, // TODO remove (for testing) - useFactory: (configService: ConfigService) => { + useFactory: (configService: ConfigService) => { const timeout = configService.get('INCOMING_REQUEST_TIMEOUT'); return new TimeoutInterceptor(timeout); }, diff --git a/apps/server/src/core/interfaces/core-module-config.ts b/apps/server/src/core/interfaces/core-module-config.ts index 6455adf437f..ef431c6d8da 100644 --- a/apps/server/src/core/interfaces/core-module-config.ts +++ b/apps/server/src/core/interfaces/core-module-config.ts @@ -1,4 +1,4 @@ -import { IInterceptorConfig } from '@shared/common'; +import { InterceptorConfig } from '@shared/common'; import { ILoggerConfig } from '../logger'; -export interface CoreModuleConfig extends IInterceptorConfig, ILoggerConfig {} +export interface CoreModuleConfig extends InterceptorConfig, ILoggerConfig {} diff --git a/apps/server/src/shared/common/interceptor/interfaces/interceptor-config.ts b/apps/server/src/shared/common/interceptor/interfaces/interceptor-config.ts index 7bcbe5fad3f..510ada13458 100644 --- a/apps/server/src/shared/common/interceptor/interfaces/interceptor-config.ts +++ b/apps/server/src/shared/common/interceptor/interfaces/interceptor-config.ts @@ -1,4 +1,4 @@ -export interface IInterceptorConfig { +export interface InterceptorConfig { INCOMING_REQUEST_TIMEOUT: number; INCOMING_REQUEST_TIMEOUT_COPY_API: number; } From 0d9cad53b93eff2f56e1ef610a0b03d40af1ac62 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 11:13:36 +0100 Subject: [PATCH 004/110] ILoggerConfig -> LoggerConfig --- apps/server/src/core/interfaces/core-module-config.ts | 4 ++-- apps/server/src/core/logger/interfaces/logger-config.ts | 2 +- apps/server/src/core/logger/logger.module.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/core/interfaces/core-module-config.ts b/apps/server/src/core/interfaces/core-module-config.ts index ef431c6d8da..a51eb7bd08d 100644 --- a/apps/server/src/core/interfaces/core-module-config.ts +++ b/apps/server/src/core/interfaces/core-module-config.ts @@ -1,4 +1,4 @@ import { InterceptorConfig } from '@shared/common'; -import { ILoggerConfig } from '../logger'; +import { LoggerConfig } from '../logger'; -export interface CoreModuleConfig extends InterceptorConfig, ILoggerConfig {} +export interface CoreModuleConfig extends InterceptorConfig, LoggerConfig {} diff --git a/apps/server/src/core/logger/interfaces/logger-config.ts b/apps/server/src/core/logger/interfaces/logger-config.ts index d9fe1e86538..0d9c651ec70 100644 --- a/apps/server/src/core/logger/interfaces/logger-config.ts +++ b/apps/server/src/core/logger/interfaces/logger-config.ts @@ -1,3 +1,3 @@ -export interface ILoggerConfig { +export interface LoggerConfig { NEST_LOG_LEVEL: string; } diff --git a/apps/server/src/core/logger/logger.module.ts b/apps/server/src/core/logger/logger.module.ts index 7751a48b8aa..477037b7cfa 100644 --- a/apps/server/src/core/logger/logger.module.ts +++ b/apps/server/src/core/logger/logger.module.ts @@ -3,14 +3,14 @@ import { ConfigService } from '@nestjs/config'; import { utilities, WinstonModule } from 'nest-winston'; import winston from 'winston'; import { ErrorLogger } from './error-logger'; -import { ILoggerConfig } from './interfaces'; +import { LoggerConfig } from './interfaces'; import { LegacyLogger } from './legacy-logger.service'; import { Logger } from './logger'; @Module({ imports: [ WinstonModule.forRootAsync({ - useFactory: (configService: ConfigService) => { + useFactory: (configService: ConfigService) => { return { levels: winston.config.syslog.levels, level: configService.get('NEST_LOG_LEVEL'), From 4b1b2c883d4649723420fa5b2881f702d14b9ad8 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 11:18:52 +0100 Subject: [PATCH 005/110] IAccountConfig -> AccountConfig --- apps/server/src/modules/account/account-config.ts | 2 +- apps/server/src/modules/account/uc/account.uc.ts | 10 +++++----- apps/server/src/modules/server/server.config.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/account/account-config.ts b/apps/server/src/modules/account/account-config.ts index cb2bd64e517..38b6acf7e58 100644 --- a/apps/server/src/modules/account/account-config.ts +++ b/apps/server/src/modules/account/account-config.ts @@ -1,4 +1,4 @@ -export interface IAccountConfig { +export interface AccountConfig { LOGIN_BLOCK_TIME: number; TEACHER_STUDENT_VISIBILITY__IS_CONFIGURABLE: boolean; } diff --git a/apps/server/src/modules/account/uc/account.uc.ts b/apps/server/src/modules/account/uc/account.uc.ts index ac4ac053dae..dac0b936ba5 100644 --- a/apps/server/src/modules/account/uc/account.uc.ts +++ b/apps/server/src/modules/account/uc/account.uc.ts @@ -1,3 +1,5 @@ +import { AccountService } from '@modules/account/services/account.service'; +import { AccountDto } from '@modules/account/services/dto/account.dto'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { @@ -8,13 +10,11 @@ import { } from '@shared/common/error'; import { Account, EntityId, Permission, PermissionService, Role, RoleName, SchoolEntity, User } from '@shared/domain'; import { UserRepo } from '@shared/repo'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountDto } from '@modules/account/services/dto/account.dto'; -import { BruteForcePrevention } from '@src/imports-from-feathers'; import { ICurrentUser } from '@modules/authentication'; +import { BruteForcePrevention } from '@src/imports-from-feathers'; import { ObjectId } from 'bson'; -import { IAccountConfig } from '../account-config'; +import { AccountConfig } from '../account-config'; import { AccountByIdBodyParams, AccountByIdParams, @@ -39,7 +39,7 @@ export class AccountUc { private readonly userRepo: UserRepo, private readonly permissionService: PermissionService, private readonly accountValidationService: AccountValidationService, - private readonly configService: ConfigService + private readonly configService: ConfigService ) {} /** diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index a31b0793316..ef31dc53f89 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 { IAccountConfig } from '@modules/account'; +import type { AccountConfig } from '@modules/account'; import type { IFilesStorageClientConfig } from '@modules/files-storage-client'; import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; import type { IUserConfig } from '@modules/user'; @@ -17,7 +17,7 @@ export interface IServerConfig extends CoreModuleConfig, IUserConfig, IFilesStorageClientConfig, - IAccountConfig, + AccountConfig, IIdentityManagementConfig, ICommonCartridgeConfig { NODE_ENV: string; From 8ea67c47deb496246f167f4da53e2f65d8ed1502 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 15:09:48 +0100 Subject: [PATCH 006/110] ClassEntityProps, RepoLoader --- .../domain/service/reference.loader.ts | 14 +++++++------- .../src/modules/class/entity/class.entity.ts | 8 ++++---- .../entity/testing/factory/class.entity.factory.ts | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/server/src/modules/authorization/domain/service/reference.loader.ts b/apps/server/src/modules/authorization/domain/service/reference.loader.ts index d584561be9e..f37fdb9a309 100644 --- a/apps/server/src/modules/authorization/domain/service/reference.loader.ts +++ b/apps/server/src/modules/authorization/domain/service/reference.loader.ts @@ -1,19 +1,19 @@ +import { BoardDoAuthorizableService } from '@modules/board'; +import { ContextExternalToolAuthorizableService } from '@modules/tool/context-external-tool/service'; import { Injectable, NotImplementedException } from '@nestjs/common'; import { BaseDO, EntityId } from '@shared/domain'; import { AuthorizableObject } from '@shared/domain/domain-object'; import { CourseGroupRepo, CourseRepo, + LegacySchoolRepo, LessonRepo, SchoolExternalToolRepo, - LegacySchoolRepo, SubmissionRepo, TaskRepo, TeamsRepo, UserRepo, } from '@shared/repo'; -import { BoardDoAuthorizableService } from '@modules/board'; -import { ContextExternalToolAuthorizableService } from '@modules/tool/context-external-tool/service'; import { AuthorizableReferenceType } from '../type'; type RepoType = @@ -29,14 +29,14 @@ type RepoType = | BoardDoAuthorizableService | ContextExternalToolAuthorizableService; -interface IRepoLoader { +interface RepoLoader { repo: RepoType; populate?: boolean; } @Injectable() export class ReferenceLoader { - private repos: Map = new Map(); + private repos: Map = new Map(); constructor( private readonly userRepo: UserRepo, @@ -66,7 +66,7 @@ export class ReferenceLoader { }); } - private resolveRepo(type: AuthorizableReferenceType): IRepoLoader { + private resolveRepo(type: AuthorizableReferenceType): RepoLoader { const repo = this.repos.get(type); if (repo) { return repo; @@ -78,7 +78,7 @@ export class ReferenceLoader { objectName: AuthorizableReferenceType, objectId: EntityId ): Promise { - const repoLoader: IRepoLoader = this.resolveRepo(objectName); + const repoLoader: RepoLoader = this.resolveRepo(objectName); let object: AuthorizableObject | BaseDO; if (repoLoader.populate) { diff --git a/apps/server/src/modules/class/entity/class.entity.ts b/apps/server/src/modules/class/entity/class.entity.ts index 3f08ba49582..e5b2dce908e 100644 --- a/apps/server/src/modules/class/entity/class.entity.ts +++ b/apps/server/src/modules/class/entity/class.entity.ts @@ -1,10 +1,10 @@ import { Embedded, Entity, Index, Property } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; -import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; import { EntityId } from '@shared/domain'; +import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; import { ClassSourceOptionsEntity } from './class-source-options.entity'; -export interface IClassEntityProps { +export interface ClassEntityProps { id?: EntityId; name: string; schoolId: ObjectId; @@ -59,13 +59,13 @@ export class ClassEntity extends BaseEntityWithTimestamps { @Embedded(() => ClassSourceOptionsEntity, { object: true, nullable: true }) sourceOptions?: ClassSourceOptionsEntity; - private validate(props: IClassEntityProps) { + private validate(props: ClassEntityProps) { if (props.gradeLevel !== undefined && (props.gradeLevel < 1 || props.gradeLevel > 13)) { throw new Error('gradeLevel must be value beetween 1 and 13'); } } - constructor(props: IClassEntityProps) { + constructor(props: ClassEntityProps) { super(); this.validate(props); diff --git a/apps/server/src/modules/class/entity/testing/factory/class.entity.factory.ts b/apps/server/src/modules/class/entity/testing/factory/class.entity.factory.ts index b98d20853fc..d122a5933d6 100644 --- a/apps/server/src/modules/class/entity/testing/factory/class.entity.factory.ts +++ b/apps/server/src/modules/class/entity/testing/factory/class.entity.factory.ts @@ -1,11 +1,11 @@ -import { DeepPartial } from 'fishery'; +import { ClassEntity, ClassEntityProps, ClassSourceOptionsEntity } from '@modules/class/entity'; import { BaseFactory } from '@shared/testing/factory/base.factory'; -import { ClassEntity, ClassSourceOptionsEntity, IClassEntityProps } from '@modules/class/entity'; import { ObjectId } from 'bson'; +import { DeepPartial } from 'fishery'; -class ClassEntityFactory extends BaseFactory { +class ClassEntityFactory extends BaseFactory { withUserIds(userIds: ObjectId[]): this { - const params: DeepPartial = { + const params: DeepPartial = { userIds, }; From 4c60045e35da4e7f0215bcb367609e569c299a14 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 15:14:43 +0100 Subject: [PATCH 007/110] FileStorageConfig --- apps/server/src/modules/files-storage/files-storage.config.ts | 4 ++-- .../modules/files-storage/service/files-storage.service.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 f1cc7286d21..7791ba2ec5d 100644 --- a/apps/server/src/modules/files-storage/files-storage.config.ts +++ b/apps/server/src/modules/files-storage/files-storage.config.ts @@ -3,7 +3,7 @@ import { S3Config } from '@shared/infra/s3-client'; import { CoreModuleConfig } from '@src/core'; export const FILES_STORAGE_S3_CONNECTION = 'FILES_STORAGE_S3_CONNECTION'; -export interface IFileStorageConfig extends CoreModuleConfig { +export interface FileStorageConfig extends CoreModuleConfig { MAX_FILE_SIZE: number; MAX_SECURITY_CHECK_FILE_SIZE: number; USE_STREAM_TO_ANTIVIRUS: boolean; @@ -14,7 +14,7 @@ export const defaultConfig = { INCOMING_REQUEST_TIMEOUT: Configuration.get('FILES_STORAGE__INCOMING_REQUEST_TIMEOUT') as number, }; -const fileStorageConfig: IFileStorageConfig = { +const fileStorageConfig: FileStorageConfig = { INCOMING_REQUEST_TIMEOUT_COPY_API: Configuration.get('INCOMING_REQUEST_TIMEOUT_COPY_API') as number, MAX_FILE_SIZE: Configuration.get('FILES_STORAGE__MAX_FILE_SIZE') as number, MAX_SECURITY_CHECK_FILE_SIZE: Configuration.get('FILES_STORAGE__MAX_FILE_SIZE') as number, 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..c9a8ee9e6d4 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 @@ -25,7 +25,7 @@ import { import { FileDto } from '../dto'; import { FileRecord, ScanStatus } from '../entity'; import { ErrorType } from '../error'; -import { FILES_STORAGE_S3_CONNECTION, IFileStorageConfig } from '../files-storage.config'; +import { FileStorageConfig, FILES_STORAGE_S3_CONNECTION } from '../files-storage.config'; import { createCopyFiles, createFileRecord, @@ -45,7 +45,7 @@ export class FilesStorageService { private readonly fileRecordRepo: FileRecordRepo, @Inject(FILES_STORAGE_S3_CONNECTION) private readonly storageClient: S3ClientAdapter, private readonly antivirusService: AntivirusService, - private readonly configService: ConfigService, + private readonly configService: ConfigService, private logger: LegacyLogger ) { this.logger.setContext(FilesStorageService.name); From 3e830fdb59fff42782383d8f01409669628e9f91 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 15:18:16 +0100 Subject: [PATCH 008/110] FileRecordSecurityCheckProperties, ParentInfo, FileRecordProperties --- .../files-storage/entity/filerecord.entity.ts | 14 +++++++------- .../shared/testing/factory/filerecord.factory.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/files-storage/entity/filerecord.entity.ts b/apps/server/src/modules/files-storage/entity/filerecord.entity.ts index 26f2807924c..a477a013e83 100644 --- a/apps/server/src/modules/files-storage/entity/filerecord.entity.ts +++ b/apps/server/src/modules/files-storage/entity/filerecord.entity.ts @@ -34,7 +34,7 @@ export enum PreviewStatus { PREVIEW_NOT_POSSIBLE_WRONG_MIME_TYPE = 'preview_not_possible_wrong_mime_type', } -export interface IFileRecordSecurityCheckProperties { +export interface FileRecordSecurityCheckProperties { status?: ScanStatus; reason?: string; requestToken?: string; @@ -56,7 +56,7 @@ export class FileRecordSecurityCheck { @Property() updatedAt = new Date(); - constructor(props: IFileRecordSecurityCheckProperties) { + constructor(props: FileRecordSecurityCheckProperties) { if (props.status !== undefined) { this.status = props.status; } @@ -69,7 +69,7 @@ export class FileRecordSecurityCheck { } } -export interface IFileRecordProperties { +export interface FileRecordProperties { size: number; name: string; mimeType: string; @@ -81,7 +81,7 @@ export interface IFileRecordProperties { isCopyFrom?: EntityId; } -interface IParentInfo { +interface ParentInfo { schoolId: EntityId; parentId: EntityId; parentType: FileRecordParentType; @@ -150,7 +150,7 @@ export class FileRecord extends BaseEntityWithTimestamps { return result; } - constructor(props: IFileRecordProperties) { + constructor(props: FileRecordProperties) { super(); this.size = props.size; this.name = props.name; @@ -177,7 +177,7 @@ export class FileRecord extends BaseEntityWithTimestamps { return this.securityCheck.requestToken; } - public copy(userId: EntityId, targetParentInfo: IParentInfo): FileRecord { + public copy(userId: EntityId, targetParentInfo: ParentInfo): FileRecord { const { size, name, mimeType, id } = this; const { parentType, parentId, schoolId } = targetParentInfo; @@ -261,7 +261,7 @@ export class FileRecord extends BaseEntityWithTimestamps { return isPreviewPossible; } - public getParentInfo(): IParentInfo { + public getParentInfo(): ParentInfo { const { parentId, parentType, schoolId } = this; return { parentId, parentType, schoolId }; diff --git a/apps/server/src/shared/testing/factory/filerecord.factory.ts b/apps/server/src/shared/testing/factory/filerecord.factory.ts index 36811ed9752..22269f6e1af 100644 --- a/apps/server/src/shared/testing/factory/filerecord.factory.ts +++ b/apps/server/src/shared/testing/factory/filerecord.factory.ts @@ -1,14 +1,14 @@ +import { FileRecord, FileRecordProperties, FileRecordSecurityCheck } from '@modules/files-storage/entity'; import { FileRecordParentType } from '@shared/infra/rabbitmq'; -import { FileRecord, FileRecordSecurityCheck, IFileRecordProperties } from '@modules/files-storage/entity'; import { ObjectId } from 'bson'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; const yesterday = new Date(Date.now() - 86400000); -class FileRecordFactory extends BaseFactory { +class FileRecordFactory extends BaseFactory { markedForDelete(): this { - const params: DeepPartial = { deletedSince: yesterday }; + const params: DeepPartial = { deletedSince: yesterday }; return this.params(params); } } From bc2271fa8301719fae59857ef339bd2513f4bca0 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 15:33:42 +0100 Subject: [PATCH 009/110] CopyFileDomainObjectProps, FileDomainObjectProps, CopyFilesRequestInfo, FileRequestInfo --- .../files-storage-client/dto/copy-file.dto.ts | 4 ++-- .../src/modules/files-storage-client/dto/file.dto.ts | 4 ++-- .../interfaces/copy-file-domain-object-props.ts | 2 +- .../interfaces/copy-file-request-info.ts | 8 ++++---- .../interfaces/file-domain-object-props.ts | 2 +- .../interfaces/file-request-info.ts | 2 +- .../mapper/copy-files-of-parent-param.builder.ts | 6 +++--- .../mapper/files-storage-client.mapper.ts | 12 ++++++------ .../mapper/files-storage-param.builder.ts | 4 ++-- .../service/files-storage-client.service.ts | 8 ++++---- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/server/src/modules/files-storage-client/dto/copy-file.dto.ts b/apps/server/src/modules/files-storage-client/dto/copy-file.dto.ts index eaddf253791..8c6936f33fa 100644 --- a/apps/server/src/modules/files-storage-client/dto/copy-file.dto.ts +++ b/apps/server/src/modules/files-storage-client/dto/copy-file.dto.ts @@ -1,5 +1,5 @@ import { EntityId } from '@shared/domain'; -import { ICopyFileDomainObjectProps } from '../interfaces'; +import { CopyFileDomainObjectProps } from '../interfaces'; export class CopyFileDto { id?: EntityId | undefined; @@ -8,7 +8,7 @@ export class CopyFileDto { name: string; - constructor(data: ICopyFileDomainObjectProps) { + constructor(data: CopyFileDomainObjectProps) { this.id = data.id; this.sourceId = data.sourceId; this.name = data.name; 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..bbb2217f85b 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,6 +1,6 @@ import { EntityId } from '@shared/domain'; import { FileRecordParentType } from '@shared/infra/rabbitmq'; -import { IFileDomainObjectProps } from '../interfaces'; +import { FileDomainObjectProps } from '../interfaces'; export class FileDto { id: EntityId; @@ -11,7 +11,7 @@ export class FileDto { parentId: EntityId; - constructor(props: IFileDomainObjectProps) { + constructor(props: FileDomainObjectProps) { this.id = props.id; this.name = props.name; this.parentType = props.parentType; diff --git a/apps/server/src/modules/files-storage-client/interfaces/copy-file-domain-object-props.ts b/apps/server/src/modules/files-storage-client/interfaces/copy-file-domain-object-props.ts index 89348ea8c68..0dfa8455094 100644 --- a/apps/server/src/modules/files-storage-client/interfaces/copy-file-domain-object-props.ts +++ b/apps/server/src/modules/files-storage-client/interfaces/copy-file-domain-object-props.ts @@ -1,6 +1,6 @@ import { EntityId } from '@shared/domain'; -export interface ICopyFileDomainObjectProps { +export interface CopyFileDomainObjectProps { id?: EntityId | undefined; sourceId: EntityId; name: string; diff --git a/apps/server/src/modules/files-storage-client/interfaces/copy-file-request-info.ts b/apps/server/src/modules/files-storage-client/interfaces/copy-file-request-info.ts index e52bbce9b1a..42c971d9a0d 100644 --- a/apps/server/src/modules/files-storage-client/interfaces/copy-file-request-info.ts +++ b/apps/server/src/modules/files-storage-client/interfaces/copy-file-request-info.ts @@ -1,8 +1,8 @@ import { EntityId } from '@shared/domain'; -import { IFileRequestInfo } from './file-request-info'; +import { FileRequestInfo } from './file-request-info'; -export interface ICopyFilesRequestInfo { +export interface CopyFilesRequestInfo { userId: EntityId; - source: IFileRequestInfo; - target: IFileRequestInfo; + source: FileRequestInfo; + target: FileRequestInfo; } 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..4e14025609d 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,7 +1,7 @@ import { EntityId } from '@shared/domain'; import { FileRecordParentType } from '@shared/infra/rabbitmq'; -export interface IFileDomainObjectProps { +export interface FileDomainObjectProps { id: EntityId; name: string; parentType: FileRecordParentType; 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..8f45e237cfa 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,7 +1,7 @@ import { EntityId } from '@shared/domain'; import { FileRecordParentType } from '@shared/infra/rabbitmq'; -export interface IFileRequestInfo { +export interface FileRequestInfo { schoolId: EntityId; parentType: FileRecordParentType; parentId: EntityId; diff --git a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.ts b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.ts index 9edee50870a..fe1bbf09c08 100644 --- a/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.ts +++ b/apps/server/src/modules/files-storage-client/mapper/copy-files-of-parent-param.builder.ts @@ -1,9 +1,9 @@ import { EntityId } from '@shared/domain'; -import { IFileRequestInfo } from '../interfaces'; -import { ICopyFilesRequestInfo } from '../interfaces/copy-file-request-info'; +import { FileRequestInfo } from '../interfaces'; +import { CopyFilesRequestInfo } from '../interfaces/copy-file-request-info'; export class CopyFilesOfParentParamBuilder { - static build(userId: EntityId, source: IFileRequestInfo, target: IFileRequestInfo): ICopyFilesRequestInfo { + static build(userId: EntityId, source: FileRequestInfo, target: FileRequestInfo): CopyFilesRequestInfo { const fileRequestInfo = { userId, source, 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..2378890481f 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,11 +1,11 @@ import { LessonEntity, Submission, Task } from '@shared/domain'; import { FileRecordParentType } from '@shared/infra/rabbitmq'; import { CopyFileDto, FileDto } from '../dto'; -import { EntitiesWithFiles, ICopyFileDomainObjectProps, IFileDomainObjectProps } from '../interfaces'; +import { CopyFileDomainObjectProps, EntitiesWithFiles, FileDomainObjectProps } from '../interfaces'; export class FilesStorageClientMapper { - static mapfileRecordListResponseToDomainFilesDto(fileRecordListResponse: IFileDomainObjectProps[]): FileDto[] { - const filesDto = fileRecordListResponse.map((record: IFileDomainObjectProps) => { + static mapfileRecordListResponseToDomainFilesDto(fileRecordListResponse: FileDomainObjectProps[]): FileDto[] { + const filesDto = fileRecordListResponse.map((record: FileDomainObjectProps) => { const fileDto = FilesStorageClientMapper.mapFileRecordResponseToFileDto(record); return fileDto; @@ -14,7 +14,7 @@ export class FilesStorageClientMapper { return filesDto; } - static mapCopyFileListResponseToCopyFilesDto(copyFileListResponse: ICopyFileDomainObjectProps[]): CopyFileDto[] { + static mapCopyFileListResponseToCopyFilesDto(copyFileListResponse: CopyFileDomainObjectProps[]): CopyFileDto[] { const filesDto = copyFileListResponse.map((response) => { const fileDto = FilesStorageClientMapper.mapCopyFileResponseToCopyFileDto(response); @@ -24,7 +24,7 @@ export class FilesStorageClientMapper { return filesDto; } - static mapFileRecordResponseToFileDto(fileRecordResponse: IFileDomainObjectProps) { + static mapFileRecordResponseToFileDto(fileRecordResponse: FileDomainObjectProps) { const parentType = FilesStorageClientMapper.mapStringToParentType(fileRecordResponse.parentType); const fileDto = new FileDto({ id: fileRecordResponse.id, @@ -36,7 +36,7 @@ export class FilesStorageClientMapper { return fileDto; } - static mapCopyFileResponseToCopyFileDto(response: ICopyFileDomainObjectProps) { + static mapCopyFileResponseToCopyFileDto(response: CopyFileDomainObjectProps) { const dto = new CopyFileDto({ id: response.id, sourceId: response.sourceId, diff --git a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.ts b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.ts index bd37c97ceb5..08ae8552bf0 100644 --- a/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.ts +++ b/apps/server/src/modules/files-storage-client/mapper/files-storage-param.builder.ts @@ -1,9 +1,9 @@ import { EntityId } from '@shared/domain'; -import { EntitiesWithFiles, IFileRequestInfo } from '../interfaces'; +import { EntitiesWithFiles, FileRequestInfo } from '../interfaces'; import { FilesStorageClientMapper } from './files-storage-client.mapper'; export class FileParamBuilder { - static build(schoolId: EntityId, parent: EntitiesWithFiles): IFileRequestInfo { + static build(schoolId: EntityId, parent: EntitiesWithFiles): FileRequestInfo { const parentType = FilesStorageClientMapper.mapEntityToParentType(parent); const fileRequestInfo = { parentType, diff --git a/apps/server/src/modules/files-storage-client/service/files-storage-client.service.ts b/apps/server/src/modules/files-storage-client/service/files-storage-client.service.ts index c632631b884..6cb47305248 100644 --- a/apps/server/src/modules/files-storage-client/service/files-storage-client.service.ts +++ b/apps/server/src/modules/files-storage-client/service/files-storage-client.service.ts @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; import { CopyFileDto, FileDto } from '../dto'; -import { IFileRequestInfo } from '../interfaces'; -import { ICopyFilesRequestInfo } from '../interfaces/copy-file-request-info'; +import { FileRequestInfo } from '../interfaces'; +import { CopyFilesRequestInfo } from '../interfaces/copy-file-request-info'; import { FilesStorageClientMapper } from '../mapper'; import { FilesStorageProducer } from './files-storage.producer'; @@ -13,14 +13,14 @@ export class FilesStorageClientAdapterService { this.logger.setContext(FilesStorageClientAdapterService.name); } - async copyFilesOfParent(param: ICopyFilesRequestInfo): Promise { + async copyFilesOfParent(param: CopyFilesRequestInfo): Promise { const response = await this.fileStorageMQProducer.copyFilesOfParent(param); const fileInfos = FilesStorageClientMapper.mapCopyFileListResponseToCopyFilesDto(response); return fileInfos; } - async listFilesOfParent(param: IFileRequestInfo): Promise { + async listFilesOfParent(param: FileRequestInfo): Promise { const response = await this.fileStorageMQProducer.listFilesOfParent(param); const fileInfos = FilesStorageClientMapper.mapfileRecordListResponseToDomainFilesDto(response); From 48b3328002bd2eaddce20601b3ba6474477b0063 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 2 Nov 2023 16:03:07 +0100 Subject: [PATCH 010/110] FilesStorageClientConfig, FilesStorageClientConfig, CopyFileDomainObjectProps, FileDomainObjectProps, CommonCartridgeElement, CommonCartridgeElement tests adjusted --- .../src/modules/files-storage-client/index.ts | 2 +- .../interfaces/files-storage-client-config.ts | 2 +- .../mapper/files-storage-client.mapper.spec.ts | 8 ++++---- .../service/files-storage.producer.ts | 4 ++-- .../common-cartridge-element.interface.ts | 2 +- .../common-cartridge-file-builder.ts | 14 +++++++------- .../common-cartridge-lti-resource.ts | 6 +++--- .../common-cartridge-manifest-element.ts | 10 +++++----- .../common-cartridge-metadata-element.ts | 4 ++-- .../common-cartridge-organization-item-element.ts | 4 ++-- ...ommon-cartridge-organization-wrapper-element.ts | 6 +++--- .../common-cartridge-resource-item-element.ts | 10 +++++----- .../common-cartridge-resource-wrapper-element.ts | 6 +++--- .../common-cartridge-web-content-resource.ts | 6 +++--- .../common-cartridge-web-link-resource.ts | 6 +++--- apps/server/src/modules/server/server.config.ts | 4 ++-- 16 files changed, 47 insertions(+), 47 deletions(-) diff --git a/apps/server/src/modules/files-storage-client/index.ts b/apps/server/src/modules/files-storage-client/index.ts index 7b242946d8f..13ee08bfeaf 100644 --- a/apps/server/src/modules/files-storage-client/index.ts +++ b/apps/server/src/modules/files-storage-client/index.ts @@ -1,6 +1,6 @@ export { FileDto } from './dto'; export * from './files-storage-client.module'; -export { IFilesStorageClientConfig } from './interfaces'; +export { FilesStorageClientConfig } from './interfaces'; export { FileParamBuilder } from './mapper/files-storage-param.builder'; export { CopyFilesService } from './service/copy-files.service'; export { FilesStorageClientAdapterService } from './service/files-storage-client.service'; diff --git a/apps/server/src/modules/files-storage-client/interfaces/files-storage-client-config.ts b/apps/server/src/modules/files-storage-client/interfaces/files-storage-client-config.ts index 8e8457f7c4b..8e746ecdd8d 100644 --- a/apps/server/src/modules/files-storage-client/interfaces/files-storage-client-config.ts +++ b/apps/server/src/modules/files-storage-client/interfaces/files-storage-client-config.ts @@ -1,3 +1,3 @@ -export interface IFilesStorageClientConfig { +export interface FilesStorageClientConfig { INCOMING_REQUEST_TIMEOUT_COPY_API: number; } 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..b790ea91a39 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,5 +1,5 @@ import { FileRecordParentType } from '@shared/infra/rabbitmq'; -import { ICopyFileDomainObjectProps, IFileDomainObjectProps } from '../interfaces'; +import { CopyFileDomainObjectProps, FileDomainObjectProps } from '../interfaces'; import { FilesStorageClientMapper } from './files-storage-client.mapper'; describe('FilesStorageClientMapper', () => { @@ -15,7 +15,7 @@ describe('FilesStorageClientMapper', () => { parentType: FileRecordParentType.Task, }; - const response: IFileDomainObjectProps[] = [record]; + const response: FileDomainObjectProps[] = [record]; describe('mapfileRecordListResponseToDomainFilesDto', () => { it('Should map to valid file Dtos.', () => { @@ -83,13 +83,13 @@ describe('FilesStorageClientMapper', () => { }); describe('copyFileDto mapper', () => { - const copyFileResponse: ICopyFileDomainObjectProps = { + const copyFileResponse: CopyFileDomainObjectProps = { id: 'id123', sourceId: 'sourceId123', name: 'name', }; - const list: ICopyFileDomainObjectProps[] = [copyFileResponse]; + const list: CopyFileDomainObjectProps[] = [copyFileResponse]; describe('mapCopyFileListResponseToCopyFilesDto', () => { it('Should map to valid file Dtos.', () => { 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..f69225fd712 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 @@ -12,14 +12,14 @@ import { IFileRecordParams, RpcMessageProducer, } from '@src/shared/infra/rabbitmq'; -import { IFilesStorageClientConfig } from '../interfaces'; +import { FilesStorageClientConfig } from '../interfaces'; @Injectable() export class FilesStorageProducer extends RpcMessageProducer { constructor( protected readonly amqpConnection: AmqpConnection, private readonly logger: LegacyLogger, - protected readonly configService: ConfigService + protected readonly configService: ConfigService ) { super(amqpConnection, FilesStorageExchange, configService.get('INCOMING_REQUEST_TIMEOUT_COPY_API')); this.logger.setContext(FilesStorageProducer.name); diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-element.interface.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-element.interface.ts index 7f30cec6977..400b31dabb1 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-element.interface.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-element.interface.ts @@ -1,3 +1,3 @@ -export interface ICommonCartridgeElement { +export interface CommonCartridgeElement { transform(): Record; } diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts index e119aba85fe..d8d47dada78 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts @@ -1,16 +1,16 @@ import AdmZip from 'adm-zip'; import { Builder } from 'xml2js'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeVersion } from './common-cartridge-enums'; -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeManifestElement } from './common-cartridge-manifest-element'; -import { - CommonCartridgeResourceItemElement, - ICommonCartridgeResourceProps, -} from './common-cartridge-resource-item-element'; import { CommonCartridgeOrganizationItemElement, ICommonCartridgeOrganizationProps, } from './common-cartridge-organization-item-element'; +import { + CommonCartridgeResourceItemElement, + ICommonCartridgeResourceProps, +} from './common-cartridge-resource-item-element'; export type ICommonCartridgeFileBuilderOptions = { identifier: string; @@ -39,11 +39,11 @@ class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganization private readonly zipBuilder: AdmZip ) {} - get organization(): ICommonCartridgeElement { + get organization(): CommonCartridgeElement { return new CommonCartridgeOrganizationItemElement(this.props); } - get resources(): ICommonCartridgeElement[] { + get resources(): CommonCartridgeElement[] { return this.props.resources.map( (resourceProps) => new CommonCartridgeResourceItemElement(resourceProps, this.xmlBuilder) ); diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts index 993ed71a6d6..b5ed4cffe51 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts @@ -1,7 +1,7 @@ import { Builder } from 'xml2js'; -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; +import { ICommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeLtiResourceProps = { type: CommonCartridgeResourceType.LTI; @@ -13,7 +13,7 @@ export type ICommonCartridgeLtiResourceProps = { url: string; }; -export class CommonCartridgeLtiResource implements ICommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeLtiResource implements CommonCartridgeElement, ICommonCartridgeFile { constructor(private readonly props: ICommonCartridgeLtiResourceProps, private readonly xmlBuilder: Builder) {} canInline(): boolean { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.ts index 6411359726a..8e71b9adee4 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-manifest-element.ts @@ -1,19 +1,19 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeVersion } from './common-cartridge-enums'; import { CommonCartridgeMetadataElement, ICommonCartridgeMetadataProps } from './common-cartridge-metadata-element'; import { CommonCartridgeOrganizationWrapperElement } from './common-cartridge-organization-wrapper-element'; import { CommonCartridgeResourceWrapperElement } from './common-cartridge-resource-wrapper-element'; -import { CommonCartridgeVersion } from './common-cartridge-enums'; export type ICommonCartridgeManifestProps = { identifier: string; }; -export class CommonCartridgeManifestElement implements ICommonCartridgeElement { +export class CommonCartridgeManifestElement implements CommonCartridgeElement { constructor( private readonly props: ICommonCartridgeManifestProps, private readonly metadataProps: ICommonCartridgeMetadataProps, - private readonly organizations: ICommonCartridgeElement[], - private readonly resources: ICommonCartridgeElement[] + private readonly organizations: CommonCartridgeElement[], + private readonly resources: CommonCartridgeElement[] ) {} transform(): Record { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.ts index b15cc01d8d1..17a0cf45faa 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-metadata-element.ts @@ -1,4 +1,4 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeVersion } from './common-cartridge-enums'; export type ICommonCartridgeMetadataProps = { @@ -8,7 +8,7 @@ export type ICommonCartridgeMetadataProps = { version: CommonCartridgeVersion; }; -export class CommonCartridgeMetadataElement implements ICommonCartridgeElement { +export class CommonCartridgeMetadataElement implements CommonCartridgeElement { constructor(private readonly props: ICommonCartridgeMetadataProps) {} transform(): Record { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts index e77fcbc0905..5d237fc3f98 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts @@ -1,4 +1,4 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { ICommonCartridgeResourceProps } from './common-cartridge-resource-item-element'; import { createIdentifier } from './utils'; @@ -9,7 +9,7 @@ export type ICommonCartridgeOrganizationProps = { resources: ICommonCartridgeResourceProps[]; }; -export class CommonCartridgeOrganizationItemElement implements ICommonCartridgeElement { +export class CommonCartridgeOrganizationItemElement implements CommonCartridgeElement { constructor(private readonly props: ICommonCartridgeOrganizationProps) {} transform(): Record { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.ts index 12def098fd3..34200b31e37 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.ts @@ -1,7 +1,7 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; -export class CommonCartridgeOrganizationWrapperElement implements ICommonCartridgeElement { - constructor(private readonly organizationElements: ICommonCartridgeElement[]) {} +export class CommonCartridgeOrganizationWrapperElement implements CommonCartridgeElement { + constructor(private readonly organizationElements: CommonCartridgeElement[]) {} transform(): Record { return { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts index 1ea4c909cb8..202c9ae04f9 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts @@ -1,4 +1,7 @@ import { Builder } from 'xml2js'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeResourceType } from './common-cartridge-enums'; +import { ICommonCartridgeFile } from './common-cartridge-file.interface'; import { CommonCartridgeLtiResource, ICommonCartridgeLtiResourceProps } from './common-cartridge-lti-resource'; import { CommonCartridgeWebContentResource, @@ -8,17 +11,14 @@ import { CommonCartridgeWebLinkResourceElement, ICommonCartridgeWebLinkResourceProps, } from './common-cartridge-web-link-resource'; -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; -import { CommonCartridgeResourceType } from './common-cartridge-enums'; export type ICommonCartridgeResourceProps = | ICommonCartridgeLtiResourceProps | ICommonCartridgeWebContentResourceProps | ICommonCartridgeWebLinkResourceProps; -export class CommonCartridgeResourceItemElement implements ICommonCartridgeElement, ICommonCartridgeFile { - private readonly inner: ICommonCartridgeElement & ICommonCartridgeFile; +export class CommonCartridgeResourceItemElement implements CommonCartridgeElement, ICommonCartridgeFile { + private readonly inner: CommonCartridgeElement & ICommonCartridgeFile; constructor(props: ICommonCartridgeResourceProps, xmlBuilder: Builder) { if (props.type === CommonCartridgeResourceType.LTI) { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.ts index 613090ae8a8..c188651f3d4 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.ts @@ -1,7 +1,7 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; -export class CommonCartridgeResourceWrapperElement implements ICommonCartridgeElement { - constructor(private readonly resourceElements: ICommonCartridgeElement[]) {} +export class CommonCartridgeResourceWrapperElement implements CommonCartridgeElement { + constructor(private readonly resourceElements: CommonCartridgeElement[]) {} transform(): Record { return { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts index 740f4779a17..2e40e368e3b 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts @@ -1,10 +1,10 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeIntendedUseType, CommonCartridgeResourceType, CommonCartridgeVersion, } from './common-cartridge-enums'; +import { ICommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeWebContentResourceProps = { type: CommonCartridgeResourceType.WEB_CONTENT; @@ -16,7 +16,7 @@ export type ICommonCartridgeWebContentResourceProps = { intendedUse?: CommonCartridgeIntendedUseType; }; -export class CommonCartridgeWebContentResource implements ICommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeWebContentResource implements CommonCartridgeElement, ICommonCartridgeFile { constructor(private readonly props: ICommonCartridgeWebContentResourceProps) {} canInline(): boolean { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts index f9d78af76f1..e52a3db3528 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts @@ -1,7 +1,7 @@ import { Builder } from 'xml2js'; -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; +import { ICommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeWebLinkResourceProps = { type: CommonCartridgeResourceType.WEB_LINK_V1 | CommonCartridgeResourceType.WEB_LINK_V3; @@ -12,7 +12,7 @@ export type ICommonCartridgeWebLinkResourceProps = { url: string; }; -export class CommonCartridgeWebLinkResourceElement implements ICommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeWebLinkResourceElement implements CommonCartridgeElement, ICommonCartridgeFile { constructor(private readonly props: ICommonCartridgeWebLinkResourceProps, private readonly xmlBuilder: Builder) {} canInline(): boolean { diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index ef31dc53f89..078ccf93ff4 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import type { AccountConfig } from '@modules/account'; -import type { IFilesStorageClientConfig } from '@modules/files-storage-client'; +import type { FilesStorageClientConfig } from '@modules/files-storage-client'; import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; import type { IUserConfig } from '@modules/user'; import type { IIdentityManagementConfig } from '@shared/infra/identity-management'; @@ -16,7 +16,7 @@ export enum NodeEnvType { export interface IServerConfig extends CoreModuleConfig, IUserConfig, - IFilesStorageClientConfig, + FilesStorageClientConfig, AccountConfig, IIdentityManagementConfig, ICommonCartridgeConfig { From af9b2cf431028f457f1c2b9fa129c37320a36407 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:18:25 +0100 Subject: [PATCH 011/110] solved some merge conflicts --- .../src/modules/files-storage-client/dto/file.dto.ts | 4 ++-- .../mapper/files-storage-client.mapper.spec.ts | 2 +- .../service/files-storage.producer.ts | 10 +++++----- .../src/modules/files-storage/files-storage.config.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) 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 dfdb4764d09..c5a5118ceae 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,6 +1,6 @@ -import { EntityId } from '@shared/domain'; import { FileRecordParentType } from '@infra/rabbitmq'; -import { IFileDomainObjectProps } from '../interfaces'; +import { EntityId } from '@shared/domain'; +import { FileDomainObjectProps } from '../interfaces'; export class FileDto { id: EntityId; 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 6e9d9433fc1..a33ef506e51 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,5 +1,5 @@ import { FileRecordParentType } from '@infra/rabbitmq'; -import { ICopyFileDomainObjectProps, IFileDomainObjectProps } from '../interfaces'; +import { CopyFileDomainObjectProps, FileDomainObjectProps } from '../interfaces'; import { FilesStorageClientMapper } from './files-storage-client.mapper'; describe('FilesStorageClientMapper', () => { 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 bd23e62381e..32cdaf0c391 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 @@ -1,8 +1,4 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; -import { Injectable } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; -import { EntityId } from '@shared/domain'; -import { LegacyLogger } from '@src/core/logger'; import { FilesStorageEvents, FilesStorageExchange, @@ -12,7 +8,11 @@ import { IFileRecordParams, RpcMessageProducer, } from '@infra/rabbitmq'; -import { IFilesStorageClientConfig } from '../interfaces'; +import { Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; +import { EntityId } from '@shared/domain'; +import { LegacyLogger } from '@src/core/logger'; +import { FilesStorageClientConfig } from '../interfaces'; @Injectable() export class FilesStorageProducer extends RpcMessageProducer { 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 cafeb47de13..5c02be598e6 100644 --- a/apps/server/src/modules/files-storage/files-storage.config.ts +++ b/apps/server/src/modules/files-storage/files-storage.config.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { S3Config } from '@infra/s3-client'; -import { ICoreModuleConfig } from '@src/core'; +import { CoreModuleConfig } from '@src/core'; export const FILES_STORAGE_S3_CONNECTION = 'FILES_STORAGE_S3_CONNECTION'; export interface FileStorageConfig extends CoreModuleConfig { From 14da12042f831ecee738a6a26e2cb34968dcae4e Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:30:46 +0100 Subject: [PATCH 012/110] ILgecyLogger named temp LegacyLoggerInterface --- .../src/core/logger/interfaces/legacy-logger.interface.ts | 2 +- apps/server/src/core/logger/legacy-logger.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts b/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts index 5f88f503de1..b27fb122991 100644 --- a/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts +++ b/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts @@ -7,7 +7,7 @@ export type RequestLoggingBody = { /** * @deprecated The new logger for loggables should be used. */ -export interface ILegacyLogger { +export interface LegacyLoggerInterface { http(message: RequestLoggingBody, context?: string): void; log(message: unknown, context?: string): void; error(message: unknown, trace?: string, context?: string): void; diff --git a/apps/server/src/core/logger/legacy-logger.service.ts b/apps/server/src/core/logger/legacy-logger.service.ts index e8b8139e041..91a6defc1f8 100644 --- a/apps/server/src/core/logger/legacy-logger.service.ts +++ b/apps/server/src/core/logger/legacy-logger.service.ts @@ -3,7 +3,7 @@ import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import util from 'util'; import { Logger as WinstonLogger } from 'winston'; import { RequestLoggingBody } from './interfaces'; -import { ILegacyLogger } from './interfaces/legacy-logger.interface'; +import { LegacyLoggerInterface } from './interfaces/legacy-logger.interface'; @Injectable({ scope: Scope.TRANSIENT }) /** @@ -12,7 +12,7 @@ import { ILegacyLogger } from './interfaces/legacy-logger.interface'; * Must implement ILegacyLogger but must not extend ConsoleLogger (this can be changed). * Transient injection: Wherever injected, a separate instance will be created, that can be provided with a custom context. */ -export class LegacyLogger implements ILegacyLogger { +export class LegacyLogger implements LegacyLoggerInterface { /** * This Logger Service can be injected into every Class, * use setContext() with CustomProviderClass.name that will be added to every log. From d4db1525ec31bf9fcdd4a42a954d26333c8458dc Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:32:36 +0100 Subject: [PATCH 013/110] ICalendarEvent -> CalendarEvent --- .../calendar/interface/calendar-event.interface.ts | 2 +- .../src/infra/calendar/mapper/calendar.mapper.ts | 4 ++-- .../src/infra/calendar/service/calendar.service.ts | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/infra/calendar/interface/calendar-event.interface.ts b/apps/server/src/infra/calendar/interface/calendar-event.interface.ts index b9c6a1e6293..1ce70acdf87 100644 --- a/apps/server/src/infra/calendar/interface/calendar-event.interface.ts +++ b/apps/server/src/infra/calendar/interface/calendar-event.interface.ts @@ -1,4 +1,4 @@ -export interface ICalendarEvent { +export interface CalendarEvent { data: { attributes: { summary: string; diff --git a/apps/server/src/infra/calendar/mapper/calendar.mapper.ts b/apps/server/src/infra/calendar/mapper/calendar.mapper.ts index a75ff01eae6..c229df3c278 100644 --- a/apps/server/src/infra/calendar/mapper/calendar.mapper.ts +++ b/apps/server/src/infra/calendar/mapper/calendar.mapper.ts @@ -1,10 +1,10 @@ -import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; +import { CalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; import { Injectable } from '@nestjs/common'; import { CalendarEventDto } from '../dto/calendar-event.dto'; @Injectable() export class CalendarMapper { - mapToDto(event: ICalendarEvent): CalendarEventDto { + mapToDto(event: CalendarEvent): CalendarEventDto { const { attributes } = event.data[0]; return new CalendarEventDto({ teamId: attributes['x-sc-teamid'], diff --git a/apps/server/src/infra/calendar/service/calendar.service.ts b/apps/server/src/infra/calendar/service/calendar.service.ts index 3bf2a6576be..7f39c21ae58 100644 --- a/apps/server/src/infra/calendar/service/calendar.service.ts +++ b/apps/server/src/infra/calendar/service/calendar.service.ts @@ -4,11 +4,11 @@ import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { EntityId } from '@shared/domain'; import { ErrorUtils } from '@src/core/error/utils'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { Observable, firstValueFrom } from 'rxjs'; +import { firstValueFrom, Observable } 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'; +import { CalendarEvent } from '../interface/calendar-event.interface'; +import { CalendarMapper } from '../mapper/calendar.mapper'; @Injectable() export class CalendarService { @@ -34,7 +34,7 @@ export class CalendarService { timeout: this.timeoutMs, }) ) - .then((resp: AxiosResponse) => this.calendarMapper.mapToDto(resp.data)) + .then((resp: AxiosResponse) => this.calendarMapper.mapToDto(resp.data)) .catch((error) => { throw new InternalServerErrorException( null, @@ -47,7 +47,7 @@ export class CalendarService { path: string, queryParams: URLSearchParams, config: AxiosRequestConfig - ): Observable> { + ): Observable> { const url: URL = new URL(this.baseURL); url.pathname = path; url.search = queryParams.toString(); From 94b841279305285761b3320af0cd036875512d39 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:34:05 +0100 Subject: [PATCH 014/110] ICollaborativeStorageStrategy -> CollaborativeStorageStrategy --- .../collaborative-storage.adapter.ts | 10 +++++----- .../strategy/base.interface.strategy.ts | 2 +- .../strategy/nextcloud/nextcloud.strategy.ts | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.ts index b50657f393e..27cfdd1b201 100644 --- a/apps/server/src/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 { RoleDto } from '@modules/role/service/dto/role.dto'; import { Inject, Injectable } from '@nestjs/common'; 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'; +import { CollaborativeStorageStrategy } from './strategy/base.interface.strategy'; /** * Provides an Adapter to an external collaborative storage. @@ -12,10 +12,10 @@ import { ICollaborativeStorageStrategy } from './strategy/base.interface.strateg */ @Injectable() export class CollaborativeStorageAdapter { - strategy: ICollaborativeStorageStrategy; + strategy: CollaborativeStorageStrategy; constructor( - @Inject('ICollaborativeStorageStrategy') strategy: ICollaborativeStorageStrategy, + @Inject('CollaborativeStorageStrategy') strategy: CollaborativeStorageStrategy, private mapper: CollaborativeStorageAdapterMapper, private logger: LegacyLogger ) { @@ -27,7 +27,7 @@ export class CollaborativeStorageAdapter { * Set the strategy that should be used by the adapter * @param strategy The strategy */ - setStrategy(strategy: ICollaborativeStorageStrategy) { + setStrategy(strategy: CollaborativeStorageStrategy) { this.strategy = strategy; } diff --git a/apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts b/apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts index f960452df5f..3021d53dcb7 100644 --- a/apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts +++ b/apps/server/src/infra/collaborative-storage/strategy/base.interface.strategy.ts @@ -4,7 +4,7 @@ import { TeamRolePermissionsDto } from '../dto/team-role-permissions.dto'; /** * base interface for all CollaborativeStorage Strategies */ -export interface ICollaborativeStorageStrategy { +export interface CollaborativeStorageStrategy { /** * Updates The Permissions for the given Role in the given Team * @param dto The DTO to be processed diff --git a/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts index 6b75d6ec76f..b7312f9158e 100644 --- a/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts +++ b/apps/server/src/infra/collaborative-storage/strategy/nextcloud/nextcloud.strategy.ts @@ -1,24 +1,24 @@ +import { TeamDto, TeamUserDto } from '@modules/collaborative-storage'; +import { PseudonymService } from '@modules/pseudonym'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; +import { ExternalToolService } from '@modules/tool/external-tool/service'; +import { UserService } from '@modules/user'; import { Injectable, UnprocessableEntityException } from '@nestjs/common'; import { Pseudonym, UserDO } from '@shared/domain/'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; import { LtiToolRepo } from '@shared/repo/ltitool/'; import { LegacyLogger } from '@src/core/logger'; -import { TeamDto, TeamUserDto } from '@modules/collaborative-storage'; -import { PseudonymService } from '@modules/pseudonym'; -import { UserService } from '@modules/user'; -import { ExternalToolService } from '@modules/tool/external-tool/service'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; import { TeamRolePermissionsDto } from '../../dto/team-role-permissions.dto'; -import { ICollaborativeStorageStrategy } from '../base.interface.strategy'; +import { CollaborativeStorageStrategy } from '../base.interface.strategy'; import { NextcloudClient } from './nextcloud.client'; /** * Nextcloud Strategy Implementation for Collaborative Storage * - * @implements {ICollaborativeStorageStrategy} + * @implements {CollaborativeStorageStrategy} */ @Injectable() -export class NextcloudStrategy implements ICollaborativeStorageStrategy { +export class NextcloudStrategy implements CollaborativeStorageStrategy { constructor( private readonly logger: LegacyLogger, private readonly client: NextcloudClient, From 1127a0537e93c1acd264bad1040fa7b4581ef9dd Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:38:27 +0100 Subject: [PATCH 015/110] IEncryptionService -> EncryptionService --- .../src/infra/encryption/encryption.interface.ts | 2 +- .../src/infra/encryption/encryption.service.ts | 4 ++-- .../mapper/identity-provider.mapper.ts | 6 +++--- ...keycloak-identity-management-oauth.service.ts | 6 +++--- .../management/uc/database-management.uc.ts | 10 +++++----- .../src/modules/oauth/service/hydra.service.ts | 12 ++++++------ .../src/modules/oauth/service/oauth.service.ts | 16 ++++++++-------- .../service/external-tool.service.ts | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/server/src/infra/encryption/encryption.interface.ts b/apps/server/src/infra/encryption/encryption.interface.ts index b8a26d7d145..062e7184d0e 100644 --- a/apps/server/src/infra/encryption/encryption.interface.ts +++ b/apps/server/src/infra/encryption/encryption.interface.ts @@ -1,7 +1,7 @@ export const DefaultEncryptionService = Symbol('DefaultEncryptionService'); export const LdapEncryptionService = Symbol('LdapEncryptionService'); -export interface IEncryptionService { +export interface EncryptionService { encrypt(data: string): string; decrypt(data: string): string; } diff --git a/apps/server/src/infra/encryption/encryption.service.ts b/apps/server/src/infra/encryption/encryption.service.ts index a443503e9ef..d23a7395675 100644 --- a/apps/server/src/infra/encryption/encryption.service.ts +++ b/apps/server/src/infra/encryption/encryption.service.ts @@ -2,10 +2,10 @@ import CryptoJs from 'crypto-js'; import { Injectable } from '@nestjs/common'; import { LegacyLogger } from '@src/core/logger'; -import { IEncryptionService } from './encryption.interface'; +import { EncryptionService } from './encryption.interface'; @Injectable() -export class SymetricKeyEncryptionService implements IEncryptionService { +export class SymetricKeyEncryptionService implements EncryptionService { constructor(private logger: LegacyLogger, private key?: string) { if (!this.key) { this.logger.warn('No AES key defined. Encryption will no work'); diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts b/apps/server/src/infra/identity-management/keycloak-configuration/mapper/identity-provider.mapper.ts index 6573ed35a5b..a7f9e360074 100644 --- a/apps/server/src/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,10 +1,10 @@ +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; import IdentityProviderRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation'; -import { Inject } from '@nestjs/common'; -import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; import { OidcConfigDto } from '@modules/system/service'; +import { Inject } from '@nestjs/common'; export class OidcIdentityProviderMapper { - constructor(@Inject(DefaultEncryptionService) private readonly defaultEncryptionService: IEncryptionService) {} + constructor(@Inject(DefaultEncryptionService) private readonly defaultEncryptionService: EncryptionService) {} public mapToKeycloakIdentityProvider(oidcConfig: OidcConfigDto, flowAlias: string): IdentityProviderRepresentation { return { diff --git a/apps/server/src/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 index 9eab3a4f60a..cbfa289165e 100644 --- a/apps/server/src/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,8 +1,8 @@ +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; +import { OauthConfigDto } from '@modules/system/service'; import { HttpService } from '@nestjs/axios'; import { Inject, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; -import { OauthConfigDto } from '@modules/system/service'; import qs from 'qs'; import { lastValueFrom } from 'rxjs'; import { IdentityManagementOauthService } from '../../identity-management-oauth.service'; @@ -16,7 +16,7 @@ export class KeycloakIdentityManagementOauthService extends IdentityManagementOa private readonly kcAdminService: KeycloakAdministrationService, private readonly configService: ConfigService, private readonly httpService: HttpService, - @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: IEncryptionService + @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: EncryptionService ) { super(); } 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 7b3d034c504..c238f38dfda 100644 --- a/apps/server/src/modules/management/uc/database-management.uc.ts +++ b/apps/server/src/modules/management/uc/database-management.uc.ts @@ -1,11 +1,11 @@ import { Configuration } from '@hpi-schul-cloud/commons'; +import { DatabaseManagementService } from '@infra/database'; +import { DefaultEncryptionService, EncryptionService, LdapEncryptionService } from '@infra/encryption'; +import { FileSystemAdapter } from '@infra/file-system'; 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 '@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'; @@ -35,8 +35,8 @@ export class DatabaseManagementUc { private readonly configService: ConfigService, private readonly logger: LegacyLogger, private em: EntityManager, - @Inject(DefaultEncryptionService) private readonly defaultEncryptionService: IEncryptionService, - @Inject(LdapEncryptionService) private readonly ldapEncryptionService: IEncryptionService + @Inject(DefaultEncryptionService) private readonly defaultEncryptionService: EncryptionService, + @Inject(LdapEncryptionService) private readonly ldapEncryptionService: EncryptionService ) { this.logger.setContext(DatabaseManagementUc.name); } diff --git a/apps/server/src/modules/oauth/service/hydra.service.ts b/apps/server/src/modules/oauth/service/hydra.service.ts index 360926d080a..9c02a537d42 100644 --- a/apps/server/src/modules/oauth/service/hydra.service.ts +++ b/apps/server/src/modules/oauth/service/hydra.service.ts @@ -1,26 +1,26 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; +import { AuthorizationParams } from '@modules/oauth/controller/dto/authorization.params'; +import { CookiesDto } from '@modules/oauth/service/dto/cookies.dto'; +import { HydraRedirectDto } from '@modules/oauth/service/dto/hydra.redirect.dto'; import { HttpService } from '@nestjs/axios'; 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 '@infra/encryption'; import { LtiToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; -import { AuthorizationParams } from '@modules/oauth/controller/dto/authorization.params'; -import { CookiesDto } from '@modules/oauth/service/dto/cookies.dto'; -import { HydraRedirectDto } from '@modules/oauth/service/dto/hydra.redirect.dto'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; import { nanoid } from 'nanoid'; import QueryString from 'qs'; -import { Observable, firstValueFrom } from 'rxjs'; +import { firstValueFrom, Observable } from 'rxjs'; @Injectable() export class HydraSsoService { constructor( private readonly ltiRepo: LtiToolRepo, private readonly httpService: HttpService, - @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: IEncryptionService, + @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: EncryptionService, private readonly logger: LegacyLogger ) {} diff --git a/apps/server/src/modules/oauth/service/oauth.service.ts b/apps/server/src/modules/oauth/service/oauth.service.ts index 190c962cd97..17081fcc406 100644 --- a/apps/server/src/modules/oauth/service/oauth.service.ts +++ b/apps/server/src/modules/oauth/service/oauth.service.ts @@ -1,19 +1,19 @@ 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 '@infra/encryption'; -import { LegacyLogger } from '@src/core/logger'; +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; +import { LegacySchoolService } from '@modules/legacy-school'; import { ProvisioningService } from '@modules/provisioning'; import { OauthDataDto } from '@modules/provisioning/dto'; -import { LegacySchoolService } from '@modules/legacy-school'; import { SystemService } from '@modules/system'; import { SystemDto } from '@modules/system/service'; import { UserService } from '@modules/user'; import { MigrationCheckService, UserMigrationService } from '@modules/user-login-migration'; +import { Inject } from '@nestjs/common'; +import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; +import { EntityId, LegacySchoolDo, OauthConfig, SchoolFeatures, UserDO } from '@shared/domain'; +import { LegacyLogger } from '@src/core/logger'; import jwt, { JwtPayload } from 'jsonwebtoken'; -import { OAuthSSOError, SSOErrorCode, UserNotFoundAfterProvisioningLoggableException } from '../loggable'; import { OAuthTokenDto } from '../interface'; +import { OAuthSSOError, SSOErrorCode, UserNotFoundAfterProvisioningLoggableException } from '../loggable'; import { TokenRequestMapper } from '../mapper/token-request.mapper'; import { AuthenticationCodeGrantTokenRequest, OauthTokenResponse } from './dto'; import { OauthAdapterService } from './oauth-adapter.service'; @@ -23,7 +23,7 @@ export class OAuthService { constructor( private readonly userService: UserService, private readonly oauthAdapterService: OauthAdapterService, - @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: IEncryptionService, + @Inject(DefaultEncryptionService) private readonly oAuthEncryptionService: EncryptionService, private readonly logger: LegacyLogger, private readonly provisioningService: ProvisioningService, private readonly systemService: SystemService, 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 0aa6181682c..562ae443112 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 '@infra/encryption'; +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; +import { Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; +import { EntityId, IFindOptions, Page } from '@shared/domain'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { TokenEndpointAuthMethod } from '../../common/enum'; @@ -20,7 +20,7 @@ export class ExternalToolService { private readonly mapper: ExternalToolServiceMapper, private readonly schoolExternalToolRepo: SchoolExternalToolRepo, private readonly contextExternalToolRepo: ContextExternalToolRepo, - @Inject(DefaultEncryptionService) private readonly encryptionService: IEncryptionService, + @Inject(DefaultEncryptionService) private readonly encryptionService: EncryptionService, private readonly legacyLogger: LegacyLogger, private readonly externalToolVersionService: ExternalToolVersionService ) {} From 7ec975b3ef6bd50559bb1f4fdde2f475c28306ba Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:42:24 +0100 Subject: [PATCH 016/110] CollaborativeStorageStrategy - ModuleName changed --- .../collaborative-storage-adapter.module.ts | 14 +++++++------- .../collaborative-storage.adapter.spec.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts index f60ff664654..3415d0dbdc3 100644 --- a/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage-adapter.module.ts @@ -1,18 +1,18 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { PseudonymModule } from '@modules/pseudonym'; +import { ToolModule } from '@modules/tool'; +import { UserModule } from '@modules/user'; import { HttpModule } from '@nestjs/axios'; import { Module, Provider } from '@nestjs/common'; 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'; +import { CollaborativeStorageAdapterMapper } from './mapper'; +import { NextcloudClient } from './strategy/nextcloud/nextcloud.client'; +import { NextcloudStrategy } from './strategy/nextcloud/nextcloud.strategy'; const storageStrategy: Provider = { - provide: 'ICollaborativeStorageStrategy', + provide: 'CollaborativeStorageStrategy', useExisting: NextcloudStrategy, }; diff --git a/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts index 3b9ba2175e6..36198998f51 100644 --- a/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts @@ -1,14 +1,14 @@ import { createMock } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; +import { TeamDto } from '@modules/collaborative-storage/services/dto/team.dto'; // invalid import please fix import { Test, TestingModule } from '@nestjs/testing'; import { RoleName } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; -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'; +import { CollaborativeStorageStrategy } from './strategy/base.interface.strategy'; -class TestStrategy implements ICollaborativeStorageStrategy { +class TestStrategy implements CollaborativeStorageStrategy { baseURL: string; constructor() { From 200c67a87169321aa551cb0f984a2af629bab1ec Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 10:58:30 +0100 Subject: [PATCH 017/110] IIdentityManagementConfig -> IdentityManagementConfig --- .../calendar/mapper/calendar.mapper.spec.ts | 4 ++-- .../infra/encryption/encryption.module.spec.ts | 6 +++--- .../identity-management.config.ts | 2 +- .../authentication/strategy/local.strategy.ts | 16 ++++++++-------- ...artridge-organization-wrapper-element.spec.ts | 4 ++-- ...on-cartridge-resource-wrapper-element.spec.ts | 4 ++-- apps/server/src/modules/server/server.config.ts | 9 ++++----- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts b/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts index 9679ce0a4fa..f84427791b9 100644 --- a/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts +++ b/apps/server/src/infra/calendar/mapper/calendar.mapper.spec.ts @@ -1,4 +1,4 @@ -import { ICalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; +import { CalendarEvent } from '@infra/calendar/interface/calendar-event.interface'; import { Test, TestingModule } from '@nestjs/testing'; import { CalendarMapper } from './calendar.mapper'; @@ -6,7 +6,7 @@ describe('CalendarMapper', () => { let module: TestingModule; let mapper: CalendarMapper; - const event: ICalendarEvent = { + const event: CalendarEvent = { data: [ { attributes: { diff --git a/apps/server/src/infra/encryption/encryption.module.spec.ts b/apps/server/src/infra/encryption/encryption.module.spec.ts index 2625f37a321..c65896efeaf 100644 --- a/apps/server/src/infra/encryption/encryption.module.spec.ts +++ b/apps/server/src/infra/encryption/encryption.module.spec.ts @@ -1,11 +1,11 @@ import { ConfigModule } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { DefaultEncryptionService, EncryptionModule, IEncryptionService, LdapEncryptionService } from '.'; +import { DefaultEncryptionService, EncryptionModule, EncryptionService, LdapEncryptionService } from '.'; describe('EncryptionModule', () => { let module: TestingModule; - let defaultService: IEncryptionService; - let ldapService: IEncryptionService; + let defaultService: EncryptionService; + let ldapService: EncryptionService; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/infra/identity-management/identity-management.config.ts b/apps/server/src/infra/identity-management/identity-management.config.ts index 39ff137fb2b..5c4d8953813 100644 --- a/apps/server/src/infra/identity-management/identity-management.config.ts +++ b/apps/server/src/infra/identity-management/identity-management.config.ts @@ -1,4 +1,4 @@ -export interface IIdentityManagementConfig { +export interface IdentityManagementConfig { FEATURE_IDENTITY_MANAGEMENT_ENABLED: boolean; FEATURE_IDENTITY_MANAGEMENT_STORE_ENABLED: boolean; FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED: boolean; diff --git a/apps/server/src/modules/authentication/strategy/local.strategy.ts b/apps/server/src/modules/authentication/strategy/local.strategy.ts index 1d31a86d833..c423fc396ff 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.ts @@ -1,14 +1,14 @@ -import { Strategy } from 'passport-local'; +import { IdentityManagementConfig, IdentityManagementOauthService } from '@infra/identity-management'; +import { AccountDto } from '@modules/account/services/dto'; +import { Injectable, UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PassportStrategy } from '@nestjs/passport'; -import { Injectable, UnauthorizedException } from '@nestjs/common'; -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 '@infra/identity-management'; -import { CurrentUserMapper } from '../mapper'; +import { UserRepo } from '@shared/repo'; +import bcrypt from 'bcryptjs'; +import { Strategy } from 'passport-local'; import { ICurrentUser } from '../interface'; +import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; @Injectable() @@ -16,7 +16,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) { constructor( private readonly authenticationService: AuthenticationService, private readonly idmOauthService: IdentityManagementOauthService, - private readonly configService: ConfigService, + private readonly configService: ConfigService, private readonly userRepo: UserRepo ) { super(); diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts index 6f3e08793af..a26e40bc37c 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-wrapper-element.spec.ts @@ -1,9 +1,9 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeOrganizationWrapperElement } from './common-cartridge-organization-wrapper-element'; describe('CommonCartridgeOrganizationWrapperElement', () => { it('should transform the organization elements into the expected structure', () => { - const organizationElementsMock: ICommonCartridgeElement[] = [ + const organizationElementsMock: CommonCartridgeElement[] = [ { transform: jest.fn().mockReturnValue({ identifier: 'element-1' }), }, diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts index 8e267b33b11..cd96c9d6784 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-wrapper-element.spec.ts @@ -1,9 +1,9 @@ -import { ICommonCartridgeElement } from './common-cartridge-element.interface'; +import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceWrapperElement } from './common-cartridge-resource-wrapper-element'; describe('CommonCartridgeResourceWrapperElement', () => { it('should transform the resource elements into an array of transformed objects', () => { - const resourceElementsMock: ICommonCartridgeElement[] = [ + const resourceElementsMock: CommonCartridgeElement[] = [ { transform: jest.fn().mockReturnValue({ identifier: 'resource-1' }), }, diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index eba1b22f8cf..dc305f3a6c7 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -1,13 +1,12 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import type { IIdentityManagementConfig } from '@infra/identity-management'; -import type { CoreModuleConfig } from '@src/core'; +import type { IdentityManagementConfig } from '@infra/identity-management'; import type { AccountConfig } from '@modules/account'; import type { FilesStorageClientConfig } from '@modules/files-storage-client'; -import type { IUserConfig } from '@modules/user'; import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; +import type { IUserConfig } from '@modules/user'; +import type { CoreModuleConfig } from '@src/core'; import { IMailConfig } from '@src/infra/mail/interfaces/mail-config'; - export enum NodeEnvType { TEST = 'test', DEVELOPMENT = 'development', @@ -20,7 +19,7 @@ export interface IServerConfig IUserConfig, FilesStorageClientConfig, AccountConfig, - IIdentityManagementConfig, + IdentityManagementConfig, ICommonCartridgeConfig, IMailConfig { NODE_ENV: string; From 58aa01a898d5cef591a6c0260ddaae82d8a1382d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:04:20 +0100 Subject: [PATCH 018/110] IKeycloakSettings -> KeycloakSettingsInterface (temp) --- .../interface/keycloak-settings.interface.ts | 2 +- .../keycloak-administration/keycloak-config.ts | 6 +++--- .../service/keycloak-administration.service.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts b/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts index 6c0b3205669..ebb0c55521a 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts @@ -1,6 +1,6 @@ export const KeycloakSettings = Symbol('KeycloakSettings'); -export interface IKeycloakSettings { +export interface KeycloakSettingsInterface { baseUrl: string; realmName: string; clientId: string; diff --git a/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts index 0565ed0b2be..f90786ed287 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { IKeycloakSettings } from './interface/keycloak-settings.interface'; +import { KeycloakSettingsInterface } from './interface/keycloak-settings.interface'; export default class KeycloakAdministration { static keycloakSettings = (Configuration.get('FEATURE_IDENTITY_MANAGEMENT_ENABLED') as boolean) @@ -13,6 +13,6 @@ export default class KeycloakAdministration { password: Configuration.get('IDENTITY_MANAGEMENT__ADMIN_PASSWORD') as string, clientId: Configuration.get('IDENTITY_MANAGEMENT__ADMIN_CLIENTID') as string, }, - } as IKeycloakSettings) - : ({} as IKeycloakSettings); + } as KeycloakSettingsInterface) + : ({} as KeycloakSettingsInterface); } diff --git a/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts index a953d0b558a..3f087446d41 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts @@ -1,6 +1,6 @@ import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import { Inject, Injectable } from '@nestjs/common'; -import { IKeycloakSettings, KeycloakSettings } from '../interface/keycloak-settings.interface'; +import { KeycloakSettings, KeycloakSettingsInterface } from '../interface/keycloak-settings.interface'; @Injectable() export class KeycloakAdministrationService { @@ -10,7 +10,7 @@ export class KeycloakAdministrationService { public constructor( private readonly kcAdminClient: KeycloakAdminClient, - @Inject(KeycloakSettings) private readonly kcSettings: IKeycloakSettings + @Inject(KeycloakSettings) private readonly kcSettings: KeycloakSettingsInterface ) { this.kcAdminClient.setConfig({ baseUrl: kcSettings.baseUrl, From 4a0d98e791c8b5cc26f4f7a1b87ec4dd59c9158e Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:06:03 +0100 Subject: [PATCH 019/110] renamed RetryOptions, MigrationOptions, CleanOptions --- .../console/keycloak-configuration.console.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts index 85d3f7a5a3c..10daef11317 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/console/keycloak-configuration.console.ts @@ -5,18 +5,18 @@ import { KeycloakConfigurationUc } from '../uc/keycloak-configuration.uc'; const defaultError = new Error('IDM is not reachable or authentication failed.'); -interface IRetryOptions { +interface RetryOptions { retryCount?: number; retryDelay?: number; } -interface IMigrationOptions { +interface MigrationOptions { skip?: number; query?: string; verbose?: boolean; } -interface ICleanOptions { +interface CleanOptions { pageSize?: number; } @Console({ command: 'idm', description: 'Prefixes all Identity Management (IDM) related console commands.' }) @@ -74,7 +74,7 @@ export class KeycloakConsole { }, ], }) - async clean(options: IRetryOptions & ICleanOptions): Promise { + async clean(options: RetryOptions & CleanOptions): Promise { await this.repeatCommand( 'clean', async () => { @@ -96,7 +96,7 @@ export class KeycloakConsole { description: 'Add all seed users to the IDM.', options: KeycloakConsole.retryFlags, }) - async seed(options: IRetryOptions): Promise { + async seed(options: RetryOptions): Promise { await this.repeatCommand( 'seed', async () => { @@ -118,7 +118,7 @@ export class KeycloakConsole { description: 'Configures Keycloak identity providers.', options: [...KeycloakConsole.retryFlags], }) - async configure(options: IRetryOptions): Promise { + async configure(options: RetryOptions): Promise { await this.repeatCommand( 'configure', async () => { @@ -153,7 +153,7 @@ export class KeycloakConsole { }, ], }) - async migrate(options: IRetryOptions & IMigrationOptions): Promise { + async migrate(options: RetryOptions & MigrationOptions): Promise { await this.repeatCommand( 'migrate', async () => { From 00d92693f3d1f3957104faac95e25f4c2969dc84 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:07:08 +0100 Subject: [PATCH 020/110] IJsonAccount -> JsonAccount --- .../interface/json-account.interface.ts | 2 +- .../service/keycloak-seed.service.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts index 7a284b70a6b..2b8d74a1006 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-account.interface.ts @@ -1,4 +1,4 @@ -export interface IJsonAccount { +export interface JsonAccount { _id: { $oid: string; }; diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts index eaf08cebe27..a8bf7abd8a6 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts @@ -2,12 +2,12 @@ import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRep import { Inject } from '@nestjs/common'; import { LegacyLogger } from '@src/core/logger'; import fs from 'node:fs/promises'; -import { IJsonAccount } from '../interface/json-account.interface'; -import { IJsonUser } from '../interface/json-user.interface'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; +import { JsonAccount } from '../interface/json-account.interface'; +import { IJsonUser } from '../interface/json-user.interface'; import { - KeycloakConfigurationInputFiles, IKeycloakConfigurationInputFiles, + KeycloakConfigurationInputFiles, } from '../interface/keycloak-configuration-input-files.interface'; export class KeycloakSeedService { @@ -57,7 +57,7 @@ export class KeycloakSeedService { return deletedUsers; } - private async createOrUpdateIdmAccount(account: IJsonAccount, user: IJsonUser): Promise { + private async createOrUpdateIdmAccount(account: JsonAccount, user: IJsonUser): Promise { const idmUserRepresentation: UserRepresentation = { username: account.username, firstName: user.firstName, @@ -91,9 +91,9 @@ export class KeycloakSeedService { return false; } - private async loadAccounts(): Promise { + private async loadAccounts(): Promise { const data = await fs.readFile(this.inputFiles.accountsFile, { encoding: 'utf-8' }); - return JSON.parse(data) as IJsonAccount[]; + return JSON.parse(data) as JsonAccount[]; } private async loadUsers(): Promise { From b71afc54453ae6336394cceaf30b2546d3393bce Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:07:52 +0100 Subject: [PATCH 021/110] IJsonUser -> JsonUser --- .../interface/json-user.interface.ts | 2 +- .../service/keycloak-seed.service.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts index 79ff1d11708..2e4f3f89c9d 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/interface/json-user.interface.ts @@ -1,4 +1,4 @@ -export interface IJsonUser { +export interface JsonUser { _id: { $oid: string; }; diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts index a8bf7abd8a6..5ba3071c2b4 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts @@ -4,7 +4,7 @@ import { LegacyLogger } from '@src/core/logger'; import fs from 'node:fs/promises'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; import { JsonAccount } from '../interface/json-account.interface'; -import { IJsonUser } from '../interface/json-user.interface'; +import { JsonUser } from '../interface/json-user.interface'; import { IKeycloakConfigurationInputFiles, KeycloakConfigurationInputFiles, @@ -57,7 +57,7 @@ export class KeycloakSeedService { return deletedUsers; } - private async createOrUpdateIdmAccount(account: JsonAccount, user: IJsonUser): Promise { + private async createOrUpdateIdmAccount(account: JsonAccount, user: JsonUser): Promise { const idmUserRepresentation: UserRepresentation = { username: account.username, firstName: user.firstName, @@ -96,8 +96,8 @@ export class KeycloakSeedService { return JSON.parse(data) as JsonAccount[]; } - private async loadUsers(): Promise { + private async loadUsers(): Promise { const data = await fs.readFile(this.inputFiles.usersFile, { encoding: 'utf-8' }); - return JSON.parse(data) as IJsonUser[]; + return JSON.parse(data) as JsonUser[]; } } From e1c6ca53a9454f58d6089141b54377266a3177d3 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:11:12 +0100 Subject: [PATCH 022/110] IKeycloakConfigurationInputFiles -> KeycloakConfigurationInputFilesInterface (temp) --- .../interface/keycloak-configuration-input-files.interface.ts | 2 +- .../keycloak-configuration/keycloak-config.ts | 4 ++-- .../keycloak-configuration/service/keycloak-seed.service.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/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 index f5568c29481..5725f67714b 100644 --- a/apps/server/src/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 @@ -1,6 +1,6 @@ export const KeycloakConfigurationInputFiles = Symbol('KeycloakConfigurationInputFiles'); -export interface IKeycloakConfigurationInputFiles { +export interface KeycloakConfigurationInputFilesInterface { accountsFile: string; usersFile: string; } diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts index ed51cff7d8d..34842ab1d26 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts @@ -1,7 +1,7 @@ -import { IKeycloakConfigurationInputFiles } from './interface/keycloak-configuration-input-files.interface'; +import { KeycloakConfigurationInputFilesInterface } from './interface/keycloak-configuration-input-files.interface'; export default class KeycloakConfiguration { - static keycloakInputFiles: IKeycloakConfigurationInputFiles = { + static keycloakInputFiles: KeycloakConfigurationInputFilesInterface = { accountsFile: './backup/setup/accounts.json', usersFile: './backup/setup/users.json', }; diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts index 5ba3071c2b4..6a435477f96 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts @@ -6,15 +6,15 @@ import { KeycloakAdministrationService } from '../../keycloak-administration/ser import { JsonAccount } from '../interface/json-account.interface'; import { JsonUser } from '../interface/json-user.interface'; import { - IKeycloakConfigurationInputFiles, KeycloakConfigurationInputFiles, + KeycloakConfigurationInputFilesInterface, } from '../interface/keycloak-configuration-input-files.interface'; export class KeycloakSeedService { constructor( private readonly kcAdmin: KeycloakAdministrationService, private readonly logger: LegacyLogger, - @Inject(KeycloakConfigurationInputFiles) private readonly inputFiles: IKeycloakConfigurationInputFiles + @Inject(KeycloakConfigurationInputFiles) private readonly inputFiles: KeycloakConfigurationInputFilesInterface ) {} async seed(): Promise { From 142afeba0c54e5e1d0ef9849319c80299668f901 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:45:36 +0100 Subject: [PATCH 023/110] ICopyFilesOfParentParams > CopyFilesOfParentParams IMailConfig -> MailConfig IError -> ErrorInterface (temp) --- apps/server/src/core/error/filter/global-error.filter.ts | 4 ++-- apps/server/src/infra/mail/interfaces/mail-config.ts | 2 +- apps/server/src/infra/mail/mail.module.ts | 6 +++--- apps/server/src/infra/mail/mail.service.ts | 4 ++-- apps/server/src/infra/rabbitmq/error.mapper.ts | 4 ++-- apps/server/src/infra/rabbitmq/exchange/files-storage.ts | 2 +- apps/server/src/infra/rabbitmq/rpc-message.ts | 4 ++-- .../files-storage-client/service/files-storage.producer.ts | 4 ++-- apps/server/src/modules/server/server.config.ts | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) 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 314c8247d18..7c3943b4e30 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 { ErrorInterface, RpcMessage } from '@infra/rabbitmq/rpc-message'; import { ArgumentsHost, Catch, ExceptionFilter, HttpException, InternalServerErrorException } from '@nestjs/common'; import { ApiValidationError, BusinessError } from '@shared/common'; -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'; @@ -12,7 +12,7 @@ import { ErrorLoggable } from '../loggable/error.loggable'; import { ErrorUtils } from '../utils'; @Catch() -export class GlobalErrorFilter implements ExceptionFilter { +export class GlobalErrorFilter implements ExceptionFilter { constructor(private readonly logger: ErrorLogger) {} // eslint-disable-next-line consistent-return diff --git a/apps/server/src/infra/mail/interfaces/mail-config.ts b/apps/server/src/infra/mail/interfaces/mail-config.ts index 6dbb0c7864d..d4baab878e7 100644 --- a/apps/server/src/infra/mail/interfaces/mail-config.ts +++ b/apps/server/src/infra/mail/interfaces/mail-config.ts @@ -1,3 +1,3 @@ -export interface IMailConfig { +export interface MailConfig { ADDITIONAL_BLACKLISTED_EMAIL_DOMAINS: string[]; } diff --git a/apps/server/src/infra/mail/mail.module.ts b/apps/server/src/infra/mail/mail.module.ts index ee6d50d59e7..0f30be221a7 100644 --- a/apps/server/src/infra/mail/mail.module.ts +++ b/apps/server/src/infra/mail/mail.module.ts @@ -1,7 +1,7 @@ -import { Module, DynamicModule } from '@nestjs/common'; +import { DynamicModule, Module } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { MailConfig } from './interfaces/mail-config'; import { MailService } from './mail.service'; -import { IMailConfig } from './interfaces/mail-config'; interface MailModuleOptions { exchange: string; @@ -19,7 +19,7 @@ export class MailModule { provide: 'MAIL_SERVICE_OPTIONS', useValue: { exchange: options.exchange, routingKey: options.routingKey }, }, - ConfigService, + ConfigService, ], exports: [MailService], }; diff --git a/apps/server/src/infra/mail/mail.service.ts b/apps/server/src/infra/mail/mail.service.ts index 432f0746934..ce8f68ceddb 100644 --- a/apps/server/src/infra/mail/mail.service.ts +++ b/apps/server/src/infra/mail/mail.service.ts @@ -1,8 +1,8 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { Inject, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { MailConfig } from './interfaces/mail-config'; import { Mail } from './mail.interface'; -import { IMailConfig } from './interfaces/mail-config'; interface MailServiceOptions { exchange: string; @@ -16,7 +16,7 @@ export class MailService { constructor( private readonly amqpConnection: AmqpConnection, @Inject('MAIL_SERVICE_OPTIONS') private readonly options: MailServiceOptions, - private readonly configService: ConfigService + private readonly configService: ConfigService ) { this.domainBlacklist = this.configService.get('ADDITIONAL_BLACKLISTED_EMAIL_DOMAINS'); } diff --git a/apps/server/src/infra/rabbitmq/error.mapper.ts b/apps/server/src/infra/rabbitmq/error.mapper.ts index 6f7083d3ad9..cacd539cdc6 100644 --- a/apps/server/src/infra/rabbitmq/error.mapper.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.ts @@ -1,10 +1,10 @@ +import { ErrorInterface } from '@infra/rabbitmq'; import { BadRequestException, ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { ErrorUtils } from '@src/core/error/utils'; -import { IError } from '@infra/rabbitmq'; export class ErrorMapper { static mapRpcErrorResponseToDomainError( - errorObj: IError + errorObj: ErrorInterface ): BadRequestException | ForbiddenException | InternalServerErrorException { let error: BadRequestException | ForbiddenException | InternalServerErrorException; if (errorObj.status === 400) { diff --git a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts index 080bcfebae5..513352fb624 100644 --- a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts +++ b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts @@ -27,7 +27,7 @@ export enum FileRecordParentType { 'BoardNode' = 'boardnodes', } -export interface ICopyFilesOfParentParams { +export interface CopyFilesOfParentParams { userId: EntityId; source: IFileRecordParams; target: IFileRecordParams; diff --git a/apps/server/src/infra/rabbitmq/rpc-message.ts b/apps/server/src/infra/rabbitmq/rpc-message.ts index c7e0e7de41f..fefaf34c4e0 100644 --- a/apps/server/src/infra/rabbitmq/rpc-message.ts +++ b/apps/server/src/infra/rabbitmq/rpc-message.ts @@ -1,8 +1,8 @@ -export interface IError extends Error { +export interface ErrorInterface extends Error { status?: number; message: string; } export interface RpcMessage { message: T; - error?: IError; + error?: ErrorInterface; } 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 32cdaf0c391..0a732a46f7f 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 @@ -1,9 +1,9 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { + CopyFilesOfParentParams, FilesStorageEvents, FilesStorageExchange, ICopyFileDO, - ICopyFilesOfParentParams, IFileDO, IFileRecordParams, RpcMessageProducer, @@ -25,7 +25,7 @@ export class FilesStorageProducer extends RpcMessageProducer { this.logger.setContext(FilesStorageProducer.name); } - async copyFilesOfParent(payload: ICopyFilesOfParentParams): Promise { + async copyFilesOfParent(payload: CopyFilesOfParentParams): Promise { this.logger.debug({ action: 'copyFilesOfParent:started', payload }); const response = await this.request(FilesStorageEvents.COPY_FILES_OF_PARENT, payload); diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index dc305f3a6c7..0b3110285ab 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -5,7 +5,7 @@ import type { FilesStorageClientConfig } from '@modules/files-storage-client'; import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; import type { IUserConfig } from '@modules/user'; import type { CoreModuleConfig } from '@src/core'; -import { IMailConfig } from '@src/infra/mail/interfaces/mail-config'; +import { MailConfig } from '@src/infra/mail/interfaces/mail-config'; export enum NodeEnvType { TEST = 'test', @@ -21,7 +21,7 @@ export interface IServerConfig AccountConfig, IdentityManagementConfig, ICommonCartridgeConfig, - IMailConfig { + MailConfig { NODE_ENV: string; SC_DOMAIN: string; } From 7eed3b285e32d7a3f7d896a21742dddaa1c22723 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:46:46 +0100 Subject: [PATCH 024/110] IMailConfig -> MailConfig --- apps/server/src/infra/rabbitmq/exchange/files-storage.ts | 6 +++--- .../files-storage-client/service/files-storage.producer.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts index 513352fb624..ff11b24a8e4 100644 --- a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts +++ b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts @@ -29,11 +29,11 @@ export enum FileRecordParentType { export interface CopyFilesOfParentParams { userId: EntityId; - source: IFileRecordParams; - target: IFileRecordParams; + source: FileRecordParams; + target: FileRecordParams; } -export interface IFileRecordParams { +export interface FileRecordParams { schoolId: EntityId; parentId: EntityId; parentType: FileRecordParentType; 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 0a732a46f7f..ea7d277add7 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 @@ -1,11 +1,11 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { CopyFilesOfParentParams, + FileRecordParams, FilesStorageEvents, FilesStorageExchange, ICopyFileDO, IFileDO, - IFileRecordParams, RpcMessageProducer, } from '@infra/rabbitmq'; import { Injectable } from '@nestjs/common'; @@ -34,7 +34,7 @@ export class FilesStorageProducer extends RpcMessageProducer { return response; } - async listFilesOfParent(payload: IFileRecordParams): Promise { + async listFilesOfParent(payload: FileRecordParams): Promise { this.logger.debug({ action: 'listFilesOfParent:started', payload }); const response = await this.request(FilesStorageEvents.LIST_FILES_OF_PARENT, payload); From 0c98f35266171ffb046946b9abc59646bf502bf4 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:48:41 +0100 Subject: [PATCH 025/110] ICopyFileDO -> CopyFileDO --- apps/server/src/infra/rabbitmq/exchange/files-storage.ts | 2 +- .../files-storage-client/service/files-storage.producer.ts | 6 +++--- .../files-storage/controller/files-storage.consumer.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts index ff11b24a8e4..fb249449936 100644 --- a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts +++ b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts @@ -39,7 +39,7 @@ export interface FileRecordParams { parentType: FileRecordParentType; } -export interface ICopyFileDO { +export interface CopyFileDO { id?: EntityId; sourceId: EntityId; name: string; 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 ea7d277add7..dc5afb8243f 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 @@ -1,10 +1,10 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { + CopyFileDO, CopyFilesOfParentParams, FileRecordParams, FilesStorageEvents, FilesStorageExchange, - ICopyFileDO, IFileDO, RpcMessageProducer, } from '@infra/rabbitmq'; @@ -25,9 +25,9 @@ export class FilesStorageProducer extends RpcMessageProducer { this.logger.setContext(FilesStorageProducer.name); } - async copyFilesOfParent(payload: CopyFilesOfParentParams): Promise { + async copyFilesOfParent(payload: CopyFilesOfParentParams): Promise { this.logger.debug({ action: 'copyFilesOfParent:started', payload }); - const response = await this.request(FilesStorageEvents.COPY_FILES_OF_PARENT, payload); + const response = await this.request(FilesStorageEvents.COPY_FILES_OF_PARENT, payload); this.logger.debug({ action: 'copyFilesOfParent:finished', payload }); 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 fc500fedee1..d8c7f097f41 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 @@ -1,10 +1,10 @@ import { RabbitPayload, RabbitRPC } from '@golevelup/nestjs-rabbitmq'; +import { CopyFileDO, FilesStorageEvents, FilesStorageExchange, IFileDO } from '@infra/rabbitmq'; +import { RpcMessage } from '@infra/rabbitmq/rpc-message'; import { MikroORM, UseRequestContext } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; -import { RpcMessage } from '@infra/rabbitmq/rpc-message'; import { LegacyLogger } from '@src/core/logger'; -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'; @@ -30,7 +30,7 @@ export class FilesStorageConsumer { @UseRequestContext() public async copyFilesOfParent( @RabbitPayload() payload: CopyFilesOfParentPayload - ): Promise> { + ): Promise> { this.logger.debug({ action: 'copyFilesOfParent', payload }); const { userId, source, target } = payload; From 9ce7e25c954a3adf12dead60b466058e832e281a Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 11:50:10 +0100 Subject: [PATCH 026/110] IFileDO -> FileDO --- .../src/infra/rabbitmq/exchange/files-storage.ts | 2 +- .../service/files-storage.producer.ts | 10 +++++----- .../files-storage/controller/files-storage.consumer.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts index fb249449936..86d2f710a57 100644 --- a/apps/server/src/infra/rabbitmq/exchange/files-storage.ts +++ b/apps/server/src/infra/rabbitmq/exchange/files-storage.ts @@ -45,7 +45,7 @@ export interface CopyFileDO { name: string; } -export interface IFileDO { +export interface FileDO { id: string; name: string; parentId: string; 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 dc5afb8243f..5f122263a14 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 @@ -2,10 +2,10 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; import { CopyFileDO, CopyFilesOfParentParams, + FileDO, FileRecordParams, FilesStorageEvents, FilesStorageExchange, - IFileDO, RpcMessageProducer, } from '@infra/rabbitmq'; import { Injectable } from '@nestjs/common'; @@ -34,18 +34,18 @@ export class FilesStorageProducer extends RpcMessageProducer { return response; } - async listFilesOfParent(payload: FileRecordParams): Promise { + async listFilesOfParent(payload: FileRecordParams): Promise { this.logger.debug({ action: 'listFilesOfParent:started', payload }); - const response = await this.request(FilesStorageEvents.LIST_FILES_OF_PARENT, payload); + const response = await this.request(FilesStorageEvents.LIST_FILES_OF_PARENT, payload); this.logger.debug({ action: 'listFilesOfParent:finished', payload }); return response; } - async deleteFilesOfParent(payload: EntityId): Promise { + async deleteFilesOfParent(payload: EntityId): Promise { this.logger.debug({ action: 'deleteFilesOfParent:started', payload }); - const response = await this.request(FilesStorageEvents.DELETE_FILES_OF_PARENT, payload); + const response = await this.request(FilesStorageEvents.DELETE_FILES_OF_PARENT, payload); this.logger.debug({ action: 'deleteFilesOfParent:finished', payload }); 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 d8c7f097f41..3b6b5654c4c 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 @@ -1,5 +1,5 @@ import { RabbitPayload, RabbitRPC } from '@golevelup/nestjs-rabbitmq'; -import { CopyFileDO, FilesStorageEvents, FilesStorageExchange, IFileDO } from '@infra/rabbitmq'; +import { CopyFileDO, FileDO, FilesStorageEvents, FilesStorageExchange } from '@infra/rabbitmq'; import { RpcMessage } from '@infra/rabbitmq/rpc-message'; import { MikroORM, UseRequestContext } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; @@ -45,7 +45,7 @@ export class FilesStorageConsumer { queue: FilesStorageEvents.LIST_FILES_OF_PARENT, }) @UseRequestContext() - public async getFilesOfParent(@RabbitPayload() payload: FileRecordParams): Promise> { + public async getFilesOfParent(@RabbitPayload() payload: FileRecordParams): Promise> { this.logger.debug({ action: 'getFilesOfParent', payload }); const [fileRecords, total] = await this.filesStorageService.getFileRecordsOfParent(payload.parentId); @@ -60,7 +60,7 @@ export class FilesStorageConsumer { queue: FilesStorageEvents.DELETE_FILES_OF_PARENT, }) @UseRequestContext() - public async deleteFilesOfParent(@RabbitPayload() payload: EntityId): Promise> { + public async deleteFilesOfParent(@RabbitPayload() payload: EntityId): Promise> { this.logger.debug({ action: 'deleteFilesOfParent', payload }); const [fileRecords, total] = await this.filesStorageService.getFileRecordsOfParent(payload); From 7e4f9b21151949b240c250eb2e84b0179b519d3c Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:01:42 +0100 Subject: [PATCH 027/110] ICurrentUserInterface -> CurrentUserInterface --- .../controllers/login.controller.ts | 12 +++++-- .../src/modules/authentication/index.ts | 4 +-- .../modules/authentication/interface/user.ts | 2 +- .../authentication/strategy/jwt.strategy.ts | 6 ++-- .../authentication/strategy/ldap.strategy.ts | 11 ++++-- .../authentication/strategy/local.strategy.ts | 6 ++-- .../strategy/oauth2.strategy.ts | 10 +++--- .../src/modules/authentication/uc/login.uc.ts | 4 +-- .../uc/video-conference-deprecated.uc.ts | 34 +++++++++---------- .../request-logging.interceptor.ts | 4 +-- .../testing/map-user-to-current-user.ts | 6 ++-- 11 files changed, 55 insertions(+), 44 deletions(-) diff --git a/apps/server/src/modules/authentication/controllers/login.controller.ts b/apps/server/src/modules/authentication/controllers/login.controller.ts index 68af396233e..a747358b6ee 100644 --- a/apps/server/src/modules/authentication/controllers/login.controller.ts +++ b/apps/server/src/modules/authentication/controllers/login.controller.ts @@ -3,7 +3,7 @@ import { AuthGuard } from '@nestjs/passport'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ForbiddenOperationError, ValidationError } from '@shared/common'; import { CurrentUser } from '../decorator'; -import type { ICurrentUser, OauthCurrentUser } from '../interface'; +import type { CurrentUserInterface, OauthCurrentUser } from '../interface'; import { LoginDto } from '../uc/dto'; import { LoginUc } from '../uc/login.uc'; import { @@ -28,7 +28,10 @@ export class LoginController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid user credentials.' }) // eslint-disable-next-line @typescript-eslint/no-unused-vars - async loginLdap(@CurrentUser() user: ICurrentUser, @Body() _: LdapAuthorizationBodyParams): Promise { + async loginLdap( + @CurrentUser() user: CurrentUserInterface, + @Body() _: LdapAuthorizationBodyParams + ): Promise { const loginDto: LoginDto = await this.loginUc.getLoginData(user); const mapped: LoginResponse = LoginResponseMapper.mapToLoginResponse(loginDto); @@ -44,7 +47,10 @@ export class LoginController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid user credentials.' }) // eslint-disable-next-line @typescript-eslint/no-unused-vars - async loginLocal(@CurrentUser() user: ICurrentUser, @Body() _: LocalAuthorizationBodyParams): Promise { + async loginLocal( + @CurrentUser() user: CurrentUserInterface, + @Body() _: LocalAuthorizationBodyParams + ): Promise { const loginDto: LoginDto = await this.loginUc.getLoginData(user); const mapped: LoginResponse = LoginResponseMapper.mapToLoginResponse(loginDto); diff --git a/apps/server/src/modules/authentication/index.ts b/apps/server/src/modules/authentication/index.ts index 59e749c7abc..299d360dbe7 100644 --- a/apps/server/src/modules/authentication/index.ts +++ b/apps/server/src/modules/authentication/index.ts @@ -1,3 +1,3 @@ -export { ICurrentUser } from './interface'; -export { JWT, CurrentUser, Authenticate } from './decorator'; export { AuthenticationModule } from './authentication.module'; +export { Authenticate, CurrentUser, JWT } from './decorator'; +export { CurrentUserInterface } from './interface'; diff --git a/apps/server/src/modules/authentication/interface/user.ts b/apps/server/src/modules/authentication/interface/user.ts index 82b6d292d50..5c57713742e 100644 --- a/apps/server/src/modules/authentication/interface/user.ts +++ b/apps/server/src/modules/authentication/interface/user.ts @@ -1,6 +1,6 @@ import { EntityId } from '@shared/domain'; -export interface ICurrentUser { +export interface CurrentUserInterface { /** authenticated users id */ userId: EntityId; /** users role ids as EntityId[] */ diff --git a/apps/server/src/modules/authentication/strategy/jwt.strategy.ts b/apps/server/src/modules/authentication/strategy/jwt.strategy.ts index 6133cf28a69..76a9b46ce17 100644 --- a/apps/server/src/modules/authentication/strategy/jwt.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/jwt.strategy.ts @@ -2,7 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { ExtractJwt, Strategy } from 'passport-jwt'; import { jwtConstants } from '../constants'; -import { ICurrentUser } from '../interface'; +import { CurrentUserInterface } from '../interface'; import { JwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from '../mapper'; import { JwtExtractor } from './jwt-extractor'; @@ -22,14 +22,14 @@ export class JwtStrategy extends PassportStrategy(Strategy) { }); } - async validate(payload: JwtPayload): Promise { + async validate(payload: JwtPayload): Promise { const { accountId, jti } = payload; // check user exists try { // TODO: check user/account is active and has one role // check jwt is whitelisted and extend whitelist entry await this.jwtValidationAdapter.isWhitelisted(accountId, jti); - const currentUser = CurrentUserMapper.jwtToICurrentUser(payload); + const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(payload); return currentUser; } catch (err) { throw new UnauthorizedException('Unauthorized.', { cause: err as Error }); diff --git a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts index 6f33e92f21a..3f7e9bf3f9f 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts @@ -7,7 +7,7 @@ import { ErrorLoggable } from '@src/core/error/loggable/error.loggable'; import { Logger } from '@src/core/logger'; import { Strategy } from 'passport-custom'; import { LdapAuthorizationBodyParams } from '../controllers/dto'; -import { ICurrentUser } from '../interface'; +import { CurrentUserInterface } from '../interface'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; import { LdapService } from '../services/ldap.service'; @@ -25,7 +25,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { super(); } - async validate(request: { body: LdapAuthorizationBodyParams }): Promise { + async validate(request: { body: LdapAuthorizationBodyParams }): Promise { const { username, password, systemId, schoolId } = this.extractParamsFromRequest(request); const system: SystemEntity = await this.systemRepo.findById(systemId); @@ -48,7 +48,12 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { await this.checkCredentials(account, system, ldapDn, password); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(account.id, user, true, systemId); + const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( + account.id, + user, + true, + systemId + ); return currentUser; } diff --git a/apps/server/src/modules/authentication/strategy/local.strategy.ts b/apps/server/src/modules/authentication/strategy/local.strategy.ts index c423fc396ff..cfceb6f4ed3 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.ts @@ -7,7 +7,7 @@ import { GuardAgainst } from '@shared/common/utils/guard-against'; import { UserRepo } from '@shared/repo'; import bcrypt from 'bcryptjs'; import { Strategy } from 'passport-local'; -import { ICurrentUser } from '../interface'; +import { CurrentUserInterface } from '../interface'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; @@ -22,7 +22,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) { super(); } - async validate(username?: string, password?: string): Promise { + async validate(username?: string, password?: string): Promise { ({ username, password } = this.cleanupInput(username, password)); const account = await this.authenticationService.loadAccount(username); @@ -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, false); + const currentUser = CurrentUserMapper.userToCurrentUserInterface(account.id, user, false); return currentUser; } diff --git a/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts b/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts index 599744cc1a7..6580becc0cc 100644 --- a/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts @@ -1,14 +1,14 @@ -import { Injectable, UnauthorizedException } from '@nestjs/common'; -import { PassportStrategy } from '@nestjs/passport'; -import { UserDO } from '@shared/domain/domainobject/user.do'; import { AccountService } from '@modules/account/services/account.service'; import { AccountDto } from '@modules/account/services/dto'; import { OAuthTokenDto } from '@modules/oauth'; import { OAuthService } from '@modules/oauth/service/oauth.service'; +import { Injectable, UnauthorizedException } from '@nestjs/common'; +import { PassportStrategy } from '@nestjs/passport'; +import { UserDO } from '@shared/domain/domainobject/user.do'; import { Strategy } from 'passport-custom'; import { Oauth2AuthorizationBodyParams } from '../controllers/dto'; import { SchoolInMigrationError } from '../errors/school-in-migration.error'; -import { ICurrentUser, OauthCurrentUser } from '../interface'; +import { CurrentUserInterface, OauthCurrentUser } from '../interface'; import { CurrentUserMapper } from '../mapper'; @Injectable() @@ -17,7 +17,7 @@ export class Oauth2Strategy extends PassportStrategy(Strategy, 'oauth2') { super(); } - async validate(request: { body: Oauth2AuthorizationBodyParams }): Promise { + async validate(request: { body: Oauth2AuthorizationBodyParams }): Promise { const { systemId, redirectUri, code } = request.body; const tokenDto: OAuthTokenDto = await this.oauthService.authenticateUser(systemId, redirectUri, code); diff --git a/apps/server/src/modules/authentication/uc/login.uc.ts b/apps/server/src/modules/authentication/uc/login.uc.ts index 2a6404b0a87..fbb50f6a693 100644 --- a/apps/server/src/modules/authentication/uc/login.uc.ts +++ b/apps/server/src/modules/authentication/uc/login.uc.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { ICurrentUser } from '../interface'; +import { CurrentUserInterface } from '../interface'; import { CreateJwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; @@ -9,7 +9,7 @@ import { LoginDto } from './dto'; export class LoginUc { constructor(private readonly authService: AuthenticationService) {} - async getLoginData(userInfo: ICurrentUser): Promise { + async getLoginData(userInfo: CurrentUserInterface): Promise { const createJwtPayload: CreateJwtPayload = CurrentUserMapper.mapCurrentUserToCreateJwtPayload(userInfo); const accessTokenDto: LoginDto = await this.authService.generateJwt(createJwtPayload); 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 95470053e6d..91efc0a1378 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 @@ -1,4 +1,12 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { CalendarService } from '@infra/calendar'; +import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; +import { CurrentUserInterface } from '@modules/authentication'; +import { Action, AuthorizationContextBuilder } from '@modules/authorization'; +import { AuthorizableReferenceType, AuthorizationReferenceService } from '@modules/authorization/domain'; +import { CourseService } from '@modules/learnroom'; +import { LegacySchoolService } from '@modules/legacy-school'; +import { UserService } from '@modules/user'; import { BadRequestException, ForbiddenException, Injectable } from '@nestjs/common'; import { Course, @@ -13,16 +21,8 @@ import { VideoConferenceOptionsDO, } from '@shared/domain'; import { VideoConferenceScope } from '@shared/domain/interface'; -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'; -import { Action, AuthorizationContextBuilder } from '@modules/authorization'; -import { AuthorizationReferenceService, AuthorizableReferenceType } from '@modules/authorization/domain'; -import { LegacySchoolService } from '@modules/legacy-school'; -import { CourseService } from '@modules/learnroom'; -import { UserService } from '@modules/user'; import { BBBBaseMeetingConfig, BBBBaseResponse, @@ -71,14 +71,14 @@ export class VideoConferenceDeprecatedUc { /** * Creates a new video conference. - * @param {ICurrentUser} currentUser + * @param {CurrentUserInterface} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @param {VideoConferenceOptions} options * @returns {Promise>} */ async create( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, conferenceScope: VideoConferenceScope, refId: EntityId, options: VideoConferenceOptions @@ -136,13 +136,13 @@ export class VideoConferenceDeprecatedUc { /** * Generates a join link for a video conference. - * @param {ICurrentUser} currentUser + * @param {CurrentUserInterface} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {Promise} */ async join( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise { @@ -191,13 +191,13 @@ export class VideoConferenceDeprecatedUc { /** * Retrieves information about a video conference. - * @param {ICurrentUser} currentUser + * @param {CurrentUserInterface} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {BBBResponse} */ async getMeetingInfo( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise { @@ -268,13 +268,13 @@ export class VideoConferenceDeprecatedUc { /** * Ends a video conference. - * @param {ICurrentUser} currentUser + * @param {CurrentUserInterface} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {Promise>} */ async end( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise> { @@ -304,7 +304,7 @@ export class VideoConferenceDeprecatedUc { } protected async isExpert( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, conferenceScope: VideoConferenceScope, scopeId: string ): Promise { diff --git a/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts b/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts index 838ae020039..29eae6c3567 100644 --- a/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts +++ b/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts @@ -1,9 +1,9 @@ +import { CurrentUserInterface } from '@modules/authentication/interface/user'; import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; import { LegacyLogger, RequestLoggingBody } from '@src/core/logger'; import { Request } from 'express'; import { Observable, throwError } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; -import { ICurrentUser } from '@modules/authentication/interface/user'; @Injectable() export class RequestLoggingInterceptor implements NestInterceptor { @@ -13,7 +13,7 @@ export class RequestLoggingInterceptor implements NestInterceptor { this.logger.setContext(`${context.getClass().name}::${context.getHandler().name}()`); const req: Request = context.switchToHttp().getRequest(); - const currentUser = req.user as ICurrentUser; + const currentUser = req.user as CurrentUserInterface; const logging: RequestLoggingBody = { userId: currentUser.userId, request: { diff --git a/apps/server/src/shared/testing/map-user-to-current-user.ts b/apps/server/src/shared/testing/map-user-to-current-user.ts index b8c975f125d..7974894d1d2 100644 --- a/apps/server/src/shared/testing/map-user-to-current-user.ts +++ b/apps/server/src/shared/testing/map-user-to-current-user.ts @@ -1,14 +1,14 @@ import { ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; import { Account, EntityId, User } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; export const mapUserToCurrentUser = ( user: User, account?: Account, systemId?: EntityId, impersonated?: boolean -): ICurrentUser => { - const currentUser: ICurrentUser = { +): CurrentUserInterface => { + const currentUser: CurrentUserInterface = { userId: user.id, roles: user.roles.getItems().map((r) => r.id), schoolId: user.school.id, From ea5cdc6d0bbf9da70c3002991b16da8e3d0d1659 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:20:31 +0100 Subject: [PATCH 028/110] ICurrentUser -> CurrentUserInterface (temp) --- .../account/controller/account.controller.ts | 19 +++++----- .../src/modules/account/uc/account.uc.ts | 15 ++++---- .../decorator/auth.decorator.ts | 22 ++++++------ .../interface/oauth-current-user.ts | 4 +-- .../mapper/current-user.mapper.ts | 13 ++++--- .../controller/board-submission.controller.ts | 10 +++--- .../board/controller/board.controller.ts | 15 ++++---- .../board/controller/card.controller.ts | 14 ++++---- .../board/controller/column.controller.ts | 15 ++++---- .../board/controller/element.controller.ts | 10 +++--- .../collaborative-storage.controller.ts | 6 ++-- .../controller/files-storage.controller.ts | 26 +++++++------- .../group/controller/group.controller.ts | 8 ++--- .../controller/h5p-editor.controller.ts | 28 +++++++-------- .../h5p-editor/entity/h5p-content.entity.ts | 4 +-- .../src/modules/h5p-editor/uc/h5p.uc.ts | 34 ++++++++++-------- .../learnroom/controller/course.controller.ts | 14 ++++---- .../controller/dashboard.controller.ts | 8 ++--- .../learnroom/controller/rooms.controller.ts | 16 ++++----- .../controller/legacy-school.controller.ts | 8 ++--- .../lesson/controller/lesson.controller.ts | 7 ++-- .../meta-tag-extractor.controller.ts | 4 +-- .../news/controller/news.controller.ts | 18 ++++++---- .../news/controller/team-news.controller.ts | 4 +-- .../controller/oauth-provider.controller.ts | 35 ++++++++++--------- .../uc/oauth-provider.client-crud.uc.ts | 18 +++++----- .../uc/oauth-provider.consent-flow.uc.ts | 12 +++---- .../oauth/controller/oauth-sso.controller.ts | 16 ++++----- .../controller/pseudonym.controller.ts | 4 +-- .../controller/share-token.controller.ts | 10 +++--- .../task/controller/submission.controller.ts | 9 +++-- .../task/controller/task.controller.ts | 26 ++++++++------ .../controller/tool-context.controller.ts | 12 +++---- .../controller/tool-reference.controller.ts | 6 ++-- .../tool-configuration.controller.ts | 10 +++--- .../controller/tool.controller.ts | 12 +++---- .../controller/tool-school.controller.ts | 28 +++++++-------- .../controller/tool-launch.controller.ts | 8 ++--- .../controller/import-user.controller.ts | 18 +++++----- .../user-login-migration.controller.ts | 18 +++++----- .../user/controller/user.controller.ts | 6 ++-- .../video-conference-deprecated.controller.ts | 8 ++--- .../controller/video-conference.controller.ts | 13 ++++--- .../testing/factory/h5p-content.factory.ts | 4 +-- 44 files changed, 322 insertions(+), 273 deletions(-) diff --git a/apps/server/src/modules/account/controller/account.controller.ts b/apps/server/src/modules/account/controller/account.controller.ts index 2256cb9fc90..c9d141cc4c3 100644 --- a/apps/server/src/modules/account/controller/account.controller.ts +++ b/apps/server/src/modules/account/controller/account.controller.ts @@ -1,8 +1,8 @@ import { Body, Controller, Delete, Get, Param, Patch, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; import { EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; +import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; import { AccountUc } from '../uc/account.uc'; import { AccountByIdBodyParams, @@ -29,7 +29,7 @@ export class AccountController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' }) async searchAccounts( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() query: AccountSearchQueryParams ): Promise { return this.accountUc.searchAccounts(currentUser, query); @@ -42,7 +42,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async findAccountById( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: AccountByIdParams ): Promise { return this.accountUc.findAccountById(currentUser, params); @@ -57,7 +57,10 @@ export class AccountController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid password.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) - async updateMyAccount(@CurrentUser() currentUser: ICurrentUser, @Body() params: PatchMyAccountParams): Promise { + async updateMyAccount( + @CurrentUser() currentUser: CurrentUserInterface, + @Body() params: PatchMyAccountParams + ): Promise { return this.accountUc.updateMyAccount(currentUser.userId, params); } @@ -68,7 +71,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async updateAccountById( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: AccountByIdParams, @Body() body: AccountByIdBodyParams ): Promise { @@ -82,7 +85,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async deleteAccountById( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: AccountByIdParams ): Promise { return this.accountUc.deleteAccountById(currentUser, params); @@ -95,7 +98,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid password.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account or user not found.' }) async replaceMyPassword( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() params: PatchMyPasswordParams ): Promise { return this.accountUc.replaceMyTemporaryPassword(currentUser.userId, params.password, params.confirmPassword); diff --git a/apps/server/src/modules/account/uc/account.uc.ts b/apps/server/src/modules/account/uc/account.uc.ts index dac0b936ba5..e3f33d20c14 100644 --- a/apps/server/src/modules/account/uc/account.uc.ts +++ b/apps/server/src/modules/account/uc/account.uc.ts @@ -11,7 +11,7 @@ import { import { Account, EntityId, Permission, PermissionService, Role, RoleName, SchoolEntity, User } from '@shared/domain'; import { UserRepo } from '@shared/repo'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { BruteForcePrevention } from '@src/imports-from-feathers'; import { ObjectId } from 'bson'; import { AccountConfig } from '../account-config'; @@ -50,7 +50,10 @@ export class AccountUc { * @throws {ValidationError} * @throws {ForbiddenOperationError} */ - async searchAccounts(currentUser: ICurrentUser, query: AccountSearchQueryParams): Promise { + async searchAccounts( + currentUser: CurrentUserInterface, + query: AccountSearchQueryParams + ): Promise { const skip = query.skip ?? 0; const limit = query.limit ?? 10; const executingUser = await this.userRepo.findById(currentUser.userId, true); @@ -88,7 +91,7 @@ export class AccountUc { * @throws {ForbiddenOperationError} * @throws {EntityNotFoundError} */ - async findAccountById(currentUser: ICurrentUser, params: AccountByIdParams): Promise { + async findAccountById(currentUser: CurrentUserInterface, params: AccountByIdParams): Promise { if (!(await this.isSuperhero(currentUser))) { throw new ForbiddenOperationError('Current user is not authorized to search for accounts.'); } @@ -110,7 +113,7 @@ export class AccountUc { * @throws {EntityNotFoundError} */ async updateAccountById( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, params: AccountByIdParams, body: AccountByIdBodyParams ): Promise { @@ -173,7 +176,7 @@ export class AccountUc { * @throws {ForbiddenOperationError} * @throws {EntityNotFoundError} */ - async deleteAccountById(currentUser: ICurrentUser, params: AccountByIdParams): Promise { + async deleteAccountById(currentUser: CurrentUserInterface, params: AccountByIdParams): Promise { if (!(await this.isSuperhero(currentUser))) { throw new ForbiddenOperationError('Current user is not authorized to delete an account.'); } @@ -330,7 +333,7 @@ export class AccountUc { return user.roles.getItems().some((role) => role.name === roleName); } - private async isSuperhero(currentUser: ICurrentUser): Promise { + private async isSuperhero(currentUser: CurrentUserInterface): Promise { const user = await this.userRepo.findById(currentUser.userId, true); return user.roles.getItems().some((role) => role.name === RoleName.SUPERHERO); } diff --git a/apps/server/src/modules/authentication/decorator/auth.decorator.ts b/apps/server/src/modules/authentication/decorator/auth.decorator.ts index 4f0167ec854..48b069e97d1 100644 --- a/apps/server/src/modules/authentication/decorator/auth.decorator.ts +++ b/apps/server/src/modules/authentication/decorator/auth.decorator.ts @@ -6,11 +6,11 @@ import { UnauthorizedException, UseGuards, } from '@nestjs/common'; -import { Request } from 'express'; import { ApiBearerAuth } from '@nestjs/swagger'; +import { Request } from 'express'; import { ExtractJwt } from 'passport-jwt'; -import { ICurrentUser } from '../interface/user'; import { JwtAuthGuard } from '../guard/jwt-auth.guard'; +import { CurrentUserInterface } from '../interface/user'; import { JwtExtractor } from '../strategy/jwt-extractor'; const STRATEGIES = ['jwt'] as const; @@ -40,14 +40,16 @@ export const Authenticate = (...strategies: Strategies) => { * @requires Authenticated */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const CurrentUser = createParamDecorator((data: unknown, ctx: ExecutionContext) => { - const { user }: Request = ctx.switchToHttp().getRequest(); - if (!user) - throw new UnauthorizedException( - 'CurrentUser missing in request context. This route requires jwt authentication guard enabled.' - ); - return user as ICurrentUser; -}); +export const CurrentUser = createParamDecorator( + (data: unknown, ctx: ExecutionContext) => { + const { user }: Request = ctx.switchToHttp().getRequest(); + if (!user) + throw new UnauthorizedException( + 'CurrentUser missing in request context. This route requires jwt authentication guard enabled.' + ); + return user as CurrentUserInterface; + } +); /** * Returns the current JWT. diff --git a/apps/server/src/modules/authentication/interface/oauth-current-user.ts b/apps/server/src/modules/authentication/interface/oauth-current-user.ts index ddf15e1ca5d..22301f844ae 100644 --- a/apps/server/src/modules/authentication/interface/oauth-current-user.ts +++ b/apps/server/src/modules/authentication/interface/oauth-current-user.ts @@ -1,6 +1,6 @@ -import { ICurrentUser } from './user'; +import { CurrentUserInterface } from './user'; -export interface OauthCurrentUser extends ICurrentUser { +export interface OauthCurrentUser extends CurrentUserInterface { /** 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.ts b/apps/server/src/modules/authentication/mapper/current-user.mapper.ts index 35dd6c5fe7c..61cf3dcf7da 100644 --- a/apps/server/src/modules/authentication/mapper/current-user.mapper.ts +++ b/apps/server/src/modules/authentication/mapper/current-user.mapper.ts @@ -2,11 +2,16 @@ import { ValidationError } from '@shared/common'; import { Role, User } from '@shared/domain'; import { RoleReference } from '@shared/domain/domainobject'; import { UserDO } from '@shared/domain/domainobject/user.do'; -import { ICurrentUser, OauthCurrentUser } from '../interface'; +import { CurrentUserInterface, OauthCurrentUser } from '../interface'; import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload'; export class CurrentUserMapper { - static userToICurrentUser(accountId: string, user: User, isExternalUser: boolean, systemId?: string): ICurrentUser { + static userToCurrentUserInterface( + accountId: string, + user: User, + isExternalUser: boolean, + systemId?: string + ): CurrentUserInterface { return { accountId, systemId, @@ -38,7 +43,7 @@ export class CurrentUserMapper { }; } - static mapCurrentUserToCreateJwtPayload(currentUser: ICurrentUser): CreateJwtPayload { + static mapCurrentUserToCreateJwtPayload(currentUser: CurrentUserInterface): CreateJwtPayload { return { accountId: currentUser.accountId, userId: currentUser.userId, @@ -50,7 +55,7 @@ export class CurrentUserMapper { }; } - static jwtToICurrentUser(jwtPayload: JwtPayload): ICurrentUser { + static jwtToCurrentUserInterface(jwtPayload: JwtPayload): CurrentUserInterface { return { accountId: jwtPayload.accountId, systemId: jwtPayload.systemId, diff --git a/apps/server/src/modules/board/controller/board-submission.controller.ts b/apps/server/src/modules/board/controller/board-submission.controller.ts index 4e81d342849..c575dc75404 100644 --- a/apps/server/src/modules/board/controller/board-submission.controller.ts +++ b/apps/server/src/modules/board/controller/board-submission.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, @@ -11,8 +12,6 @@ import { } from '@nestjs/common'; import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; -import { SubmissionsResponse } from './dto/submission-item/submissions.response'; import { CardUc } from '../uc'; import { ElementUc } from '../uc/element.uc'; import { SubmissionItemUc } from '../uc/submission-item.uc'; @@ -24,6 +23,7 @@ import { SubmissionItemUrlParams, UpdateSubmissionItemBodyParams, } from './dto'; +import { SubmissionsResponse } from './dto/submission-item/submissions.response'; import { ContentElementResponseFactory, SubmissionItemResponseMapper } from './mapper'; @ApiTags('Board Submission') @@ -42,7 +42,7 @@ export class BoardSubmissionController { @ApiResponse({ status: 403, type: ForbiddenException }) @Get(':submissionContainerId') async getSubmissionItems( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: SubmissionContainerUrlParams ): Promise { const { submissionItems, users } = await this.submissionItemUc.findSubmissionItems( @@ -63,7 +63,7 @@ export class BoardSubmissionController { @HttpCode(204) @Patch(':submissionItemId') async updateSubmissionItem( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: SubmissionItemUrlParams, @Body() bodyParams: UpdateSubmissionItemBodyParams ) { @@ -89,7 +89,7 @@ export class BoardSubmissionController { async createElement( @Param() urlParams: SubmissionItemUrlParams, @Body() bodyParams: CreateContentElementBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const { type } = bodyParams; const element = await this.submissionItemUc.createElement(currentUser.userId, urlParams.submissionItemId, type); diff --git a/apps/server/src/modules/board/controller/board.controller.ts b/apps/server/src/modules/board/controller/board.controller.ts index 0d77aa80b3d..82bea1bccb0 100644 --- a/apps/server/src/modules/board/controller/board.controller.ts +++ b/apps/server/src/modules/board/controller/board.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, @@ -12,7 +13,6 @@ import { } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { BoardUc } from '../uc'; import { BoardResponse, BoardUrlParams, ColumnResponse, RenameBodyParams } from './dto'; import { BoardContextResponse } from './dto/board/board-context.reponse'; @@ -32,7 +32,7 @@ export class BoardController { @Get(':boardId') async getBoardSkeleton( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const board = await this.boardUc.findBoard(currentUser.userId, urlParams.boardId); @@ -49,7 +49,7 @@ export class BoardController { @Get(':boardId/context') async getBoardContext( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const boardContext = await this.boardUc.findBoardContext(currentUser.userId, urlParams.boardId); @@ -68,7 +68,7 @@ export class BoardController { async updateBoardTitle( @Param() urlParams: BoardUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.boardUc.updateBoardTitle(currentUser.userId, urlParams.boardId, bodyParams.title); } @@ -80,7 +80,10 @@ export class BoardController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':boardId') - async deleteBoard(@Param() urlParams: BoardUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async deleteBoard( + @Param() urlParams: BoardUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { await this.boardUc.deleteBoard(currentUser.userId, urlParams.boardId); } @@ -92,7 +95,7 @@ export class BoardController { @Post(':boardId/columns') async createColumn( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const column = await this.boardUc.createColumn(currentUser.userId, urlParams.boardId); diff --git a/apps/server/src/modules/board/controller/card.controller.ts b/apps/server/src/modules/board/controller/card.controller.ts index e75d7afc7a5..573405d7c7a 100644 --- a/apps/server/src/modules/board/controller/card.controller.ts +++ b/apps/server/src/modules/board/controller/card.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, @@ -14,7 +15,6 @@ import { } from '@nestjs/common'; import { ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { CardUc, ColumnUc } from '../uc'; import { AnyContentElementResponse, @@ -45,7 +45,7 @@ export class CardController { @ApiResponse({ status: 403, type: ForbiddenException }) @Get() async getCards( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() cardIdParams: CardIdsParams ): Promise { const cardIds = Array.isArray(cardIdParams.ids) ? cardIdParams.ids : [cardIdParams.ids]; @@ -68,7 +68,7 @@ export class CardController { async moveCard( @Param() urlParams: CardUrlParams, @Body() bodyParams: MoveCardBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.columnUc.moveCard(currentUser.userId, urlParams.cardId, bodyParams.toColumnId, bodyParams.toPosition); } @@ -83,7 +83,7 @@ export class CardController { async updateCardHeight( @Param() urlParams: CardUrlParams, @Body() bodyParams: SetHeightBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.cardUc.updateCardHeight(currentUser.userId, urlParams.cardId, bodyParams.height); } @@ -98,7 +98,7 @@ export class CardController { async updateCardTitle( @Param() urlParams: CardUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.cardUc.updateCardTitle(currentUser.userId, urlParams.cardId, bodyParams.title); } @@ -110,7 +110,7 @@ export class CardController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':cardId') - async deleteCard(@Param() urlParams: CardUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async deleteCard(@Param() urlParams: CardUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { await this.cardUc.deleteCard(currentUser.userId, urlParams.cardId); } @@ -141,7 +141,7 @@ export class CardController { async createElement( @Param() urlParams: CardUrlParams, @Body() bodyParams: CreateContentElementBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const { type, toPosition } = bodyParams; const element = await this.cardUc.createElement(currentUser.userId, urlParams.cardId, type, toPosition); diff --git a/apps/server/src/modules/board/controller/column.controller.ts b/apps/server/src/modules/board/controller/column.controller.ts index 870bcc5dc06..09cd7c5e61a 100644 --- a/apps/server/src/modules/board/controller/column.controller.ts +++ b/apps/server/src/modules/board/controller/column.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, @@ -12,11 +13,10 @@ import { } from '@nestjs/common'; import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { BoardUc, ColumnUc } from '../uc'; import { CardResponse, ColumnUrlParams, MoveColumnBodyParams, RenameBodyParams } from './dto'; -import { CardResponseMapper } from './mapper'; import { CreateCardBodyParams } from './dto/card/create-card.body.params'; +import { CardResponseMapper } from './mapper'; @ApiTags('Board Column') @Authenticate('jwt') @@ -34,7 +34,7 @@ export class ColumnController { async moveColumn( @Param() urlParams: ColumnUrlParams, @Body() bodyParams: MoveColumnBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.boardUc.moveColumn(currentUser.userId, urlParams.columnId, bodyParams.toBoardId, bodyParams.toPosition); } @@ -49,7 +49,7 @@ export class ColumnController { async updateColumnTitle( @Param() urlParams: ColumnUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.columnUc.updateColumnTitle(currentUser.userId, urlParams.columnId, bodyParams.title); } @@ -61,7 +61,10 @@ export class ColumnController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':columnId') - async deleteColumn(@Param() urlParams: ColumnUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async deleteColumn( + @Param() urlParams: ColumnUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { await this.columnUc.deleteColumn(currentUser.userId, urlParams.columnId); } @@ -74,7 +77,7 @@ export class ColumnController { @Post(':columnId/cards') async createCard( @Param() urlParams: ColumnUrlParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() createCardBodyParams?: CreateCardBodyParams ): Promise { const { requiredEmptyElements } = createCardBodyParams || {}; diff --git a/apps/server/src/modules/board/controller/element.controller.ts b/apps/server/src/modules/board/controller/element.controller.ts index 2bed9006a0f..8c62ebbf493 100644 --- a/apps/server/src/modules/board/controller/element.controller.ts +++ b/apps/server/src/modules/board/controller/element.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, @@ -12,7 +13,6 @@ import { } from '@nestjs/common'; import { ApiBody, ApiExtraModels, ApiOperation, ApiResponse, ApiTags, getSchemaPath } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { CardUc } from '../uc'; import { ElementUc } from '../uc/element.uc'; import { @@ -51,7 +51,7 @@ export class ElementController { async moveElement( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: MoveContentElementBody, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.cardUc.moveElement( currentUser.userId, @@ -89,7 +89,7 @@ export class ElementController { async updateElement( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: UpdateElementContentBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const element = await this.elementUc.updateElementContent( currentUser.userId, @@ -109,7 +109,7 @@ export class ElementController { @Delete(':contentElementId') async deleteElement( @Param() urlParams: ContentElementUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.elementUc.deleteElement(currentUser.userId, urlParams.contentElementId); } @@ -125,7 +125,7 @@ export class ElementController { async createSubmissionItem( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: CreateSubmissionItemBodyParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const submissionItem = await this.elementUc.createSubmissionItem( currentUser.userId, diff --git a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts index 19fbccbed1c..81f2152b352 100644 --- a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts +++ b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts @@ -1,6 +1,6 @@ -import { ApiResponse, ApiTags } from '@nestjs/swagger'; +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Param, Patch } from '@nestjs/common'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; +import { ApiResponse, ApiTags } from '@nestjs/swagger'; import { LegacyLogger } from '@src/core/logger'; import { CollaborativeStorageUc } from '../uc/collaborative-storage.uc'; import { TeamPermissionsBody } from './dto/team-permissions.body.params'; @@ -30,7 +30,7 @@ export class CollaborativeStorageController { @ApiResponse({ status: 403, description: 'User does not have the correct permission' }) @ApiResponse({ status: 404, description: 'Team or Role not found!' }) updateTeamPermissionsForRole( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() teamRole: TeamRoleDto, @Body() permissionsBody: TeamPermissionsBody ): Promise { diff --git a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts index 7269336c44c..22926c2d01a 100644 --- a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts +++ b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { BadRequestException, Body, @@ -63,7 +63,7 @@ export class FilesStorageController { async uploadFromUrl( @Body() body: FileUrlParams, @Param() params: FileRecordParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const fileRecord = await this.filesStorageUC.uploadFromUrl(currentUser.userId, { ...body, ...params }); @@ -83,7 +83,7 @@ export class FilesStorageController { async upload( @Body() _: FileParams, @Param() params: FileRecordParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Req() req: Request ): Promise { const fileRecord = await this.filesStorageUC.upload(currentUser.userId, params, req); @@ -105,7 +105,7 @@ export class FilesStorageController { @Get('/download/:fileRecordId/:fileName') async download( @Param() params: DownloadFileParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Req() req: Request, @Res({ passthrough: true }) response: Response, @Headers('Range') bytesRange?: string @@ -131,7 +131,7 @@ export class FilesStorageController { @RequestTimeout(config().INCOMING_REQUEST_TIMEOUT) async downloadPreview( @Param() params: DownloadFileParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() previewParams: PreviewParams, @Req() req: Request, @Res({ passthrough: true }) response: Response, @@ -192,7 +192,7 @@ export class FilesStorageController { @Get('/list/:schoolId/:parentType/:parentId') async list( @Param() params: FileRecordParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() pagination: PaginationParams ): Promise { const [fileRecords, total] = await this.filesStorageUC.getFileRecordsOfParent(currentUser.userId, params); @@ -217,7 +217,7 @@ export class FilesStorageController { async patchFilename( @Param() params: SingleFileParams, @Body() renameFileParam: RenameFileParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const fileRecord = await this.filesStorageUC.patchFilename(currentUser.userId, params, renameFileParam); @@ -238,7 +238,7 @@ export class FilesStorageController { @UseInterceptors(RequestLoggingInterceptor) async deleteByParent( @Param() params: FileRecordParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const [fileRecords, total] = await this.filesStorageUC.deleteFilesOfParent(currentUser.userId, params); const response = FileRecordMapper.mapToFileRecordListResponse(fileRecords, total); @@ -255,7 +255,7 @@ export class FilesStorageController { @UseInterceptors(RequestLoggingInterceptor) async deleteFile( @Param() params: SingleFileParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const fileRecord = await this.filesStorageUC.deleteOneFile(currentUser.userId, params); @@ -271,7 +271,7 @@ export class FilesStorageController { @Post('/restore/:schoolId/:parentType/:parentId') async restore( @Param() params: FileRecordParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const [fileRecords, total] = await this.filesStorageUC.restoreFilesOfParent(currentUser.userId, params); @@ -287,7 +287,7 @@ export class FilesStorageController { @Post('/restore/:fileRecordId') async restoreFile( @Param() params: SingleFileParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const fileRecord = await this.filesStorageUC.restoreOneFile(currentUser.userId, params); @@ -305,7 +305,7 @@ export class FilesStorageController { async copy( @Param() params: FileRecordParams, @Body() copyFilesParam: CopyFilesOfParentParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const [response, count] = await this.filesStorageUC.copyFilesOfParent(currentUser.userId, params, copyFilesParam); @@ -322,7 +322,7 @@ export class FilesStorageController { async copyFile( @Param() params: SingleFileParams, @Body() copyFileParam: CopyFileParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const response = await this.filesStorageUC.copyOneFile(currentUser.userId, params, copyFileParam); diff --git a/apps/server/src/modules/group/controller/group.controller.ts b/apps/server/src/modules/group/controller/group.controller.ts index c92ee337050..4aba6ad39cf 100644 --- a/apps/server/src/modules/group/controller/group.controller.ts +++ b/apps/server/src/modules/group/controller/group.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, HttpStatus, Param, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; @@ -6,7 +6,7 @@ import { Page } from '@shared/domain'; import { ErrorResponse } from '@src/core/error/dto'; import { GroupUc } from '../uc'; import { ClassInfoDto, ResolvedGroupDto } from '../uc/dto'; -import { ClassInfoSearchListResponse, ClassSortParams, GroupIdParams, GroupResponse, ClassFilterParams } from './dto'; +import { ClassFilterParams, ClassInfoSearchListResponse, ClassSortParams, GroupIdParams, GroupResponse } from './dto'; import { GroupResponseMapper } from './mapper'; @ApiTags('Group') @@ -24,7 +24,7 @@ export class GroupController { @Query() pagination: PaginationParams, @Query() sortingQuery: ClassSortParams, @Query() filterParams: ClassFilterParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const board: Page = await this.groupUc.findAllClasses( currentUser.userId, @@ -51,7 +51,7 @@ export class GroupController { @ApiResponse({ status: '4XX', type: ErrorResponse }) @ApiResponse({ status: '5XX', type: ErrorResponse }) public async getGroup( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: GroupIdParams ): Promise { const group: ResolvedGroupDto = await this.groupUc.getGroup(currentUser.userId, params.groupId); diff --git a/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts b/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts index 8c80d6bc0e4..7271ff6c551 100644 --- a/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts +++ b/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts @@ -1,3 +1,5 @@ +import { CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate } from '@modules/authentication/decorator/auth.decorator'; import { BadRequestException, Body, @@ -18,13 +20,10 @@ import { import { FileFieldsInterceptor } from '@nestjs/platform-express'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiValidationError } from '@shared/common'; -import { ICurrentUser, CurrentUser } from '@modules/authentication'; import { Request, Response } from 'express'; -import { Authenticate } from '@modules/authentication/decorator/auth.decorator'; import { H5PEditorUc } from '../uc/h5p.uc'; -import { AjaxPostBodyParamsTransformPipe } from './dto/ajax/post.body.params.transform-pipe'; import { AjaxGetQueryParams, AjaxPostBodyParams, @@ -37,6 +36,7 @@ import { PostH5PContentCreateParams, SaveH5PEditorParams, } from './dto'; +import { AjaxPostBodyParamsTransformPipe } from './dto/ajax/post.body.params.transform-pipe'; import { H5PEditorModelContentResponse, H5PEditorModelResponse, H5PSaveResponse } from './dto/h5p-editor.response'; @ApiTags('h5p-editor') @@ -51,7 +51,7 @@ export class H5PEditorController { @ApiResponse({ status: 403, type: ForbiddenException }) @ApiResponse({ status: 500, type: InternalServerErrorException }) @Get('/play/:contentId') - async getPlayer(@CurrentUser() currentUser: ICurrentUser, @Param() params: GetH5PContentParams) { + async getPlayer(@CurrentUser() currentUser: CurrentUserInterface, @Param() params: GetH5PContentParams) { return this.h5pEditorUc.getH5pPlayer(currentUser, params.contentId); } @@ -73,7 +73,7 @@ export class H5PEditorController { } @Get('params/:id') - async getContentParameters(@Param('id') id: string, @CurrentUser() currentUser: ICurrentUser) { + async getContentParameters(@Param('id') id: string, @CurrentUser() currentUser: CurrentUserInterface) { const content = await this.h5pEditorUc.getContentParameters(id, currentUser); return content; @@ -84,7 +84,7 @@ export class H5PEditorController { @Param() params: ContentFileUrlParams, @Req() req: Request, @Res({ passthrough: true }) res: Response, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ) { const { data, contentType, contentLength, contentRange } = await this.h5pEditorUc.getContentFile( params.id, @@ -102,7 +102,7 @@ export class H5PEditorController { @Get('temp-files/:file(*)') async getTemporaryFile( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param('file') file: string, @Req() req: Request, @Res({ passthrough: true }) res: Response @@ -121,7 +121,7 @@ export class H5PEditorController { } @Get('ajax') - async getAjax(@Query() query: AjaxGetQueryParams, @CurrentUser() currentUser: ICurrentUser) { + async getAjax(@Query() query: AjaxGetQueryParams, @CurrentUser() currentUser: CurrentUserInterface) { const response = this.h5pEditorUc.getAjax(query, currentUser); return response; @@ -137,7 +137,7 @@ export class H5PEditorController { async postAjax( @Body(AjaxPostBodyParamsTransformPipe) body: AjaxPostBodyParams, @Query() query: AjaxPostQueryParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @UploadedFiles() files?: { file?: Express.Multer.File[]; h5p?: Express.Multer.File[] } ) { const contentFile = files?.file?.[0]; @@ -151,7 +151,7 @@ export class H5PEditorController { @Post('/delete/:contentId') async deleteH5pContent( @Param() params: GetH5PContentParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const deleteSuccessfull = this.h5pEditorUc.deleteH5pContent(currentUser, params.contentId); @@ -160,7 +160,7 @@ export class H5PEditorController { @Get('/edit/:language') @ApiResponse({ status: 200, type: H5PEditorModelResponse }) - async getNewH5PEditor(@Param() params: GetH5PEditorParamsCreate, @CurrentUser() currentUser: ICurrentUser) { + async getNewH5PEditor(@Param() params: GetH5PEditorParamsCreate, @CurrentUser() currentUser: CurrentUserInterface) { const editorModel = await this.h5pEditorUc.getEmptyH5pEditor(currentUser, params.language); return new H5PEditorModelResponse(editorModel); @@ -168,7 +168,7 @@ export class H5PEditorController { @Get('/edit/:contentId/:language') @ApiResponse({ status: 200, type: H5PEditorModelContentResponse }) - async getH5PEditor(@Param() params: GetH5PEditorParams, @CurrentUser() currentUser: ICurrentUser) { + async getH5PEditor(@Param() params: GetH5PEditorParams, @CurrentUser() currentUser: CurrentUserInterface) { const { editorModel, content } = await this.h5pEditorUc.getH5pEditor( currentUser, params.contentId, @@ -180,7 +180,7 @@ export class H5PEditorController { @Post('/edit') @ApiResponse({ status: 201, type: H5PSaveResponse }) - async createH5pContent(@Body() body: PostH5PContentCreateParams, @CurrentUser() currentUser: ICurrentUser) { + async createH5pContent(@Body() body: PostH5PContentCreateParams, @CurrentUser() currentUser: CurrentUserInterface) { const response = await this.h5pEditorUc.createH5pContentGetMetadata( currentUser, body.params.params, @@ -200,7 +200,7 @@ export class H5PEditorController { async saveH5pContent( @Body() body: PostH5PContentCreateParams, @Param() params: SaveH5PEditorParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ) { const response = await this.h5pEditorUc.saveH5pContentGetMetadata( params.contentId, diff --git a/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.ts b/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.ts index 3f9e6113172..7b96978294f 100644 --- a/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.ts +++ b/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.ts @@ -106,7 +106,7 @@ export enum H5PContentParentType { 'Lesson' = 'lessons', } -export interface IH5PContentProperties { +export interface H5PContentProperties { creatorId: EntityId; parentType: H5PContentParentType; parentId: EntityId; @@ -149,7 +149,7 @@ export class H5PContent extends BaseEntityWithTimestamps { @Property({ type: JsonType }) content: unknown; - constructor({ parentType, parentId, creatorId, schoolId, metadata, content }: IH5PContentProperties) { + constructor({ parentType, parentId, creatorId, schoolId, metadata, content }: H5PContentProperties) { super(); this.parentType = parentType; diff --git a/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts b/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts index f456491509a..0bafba101f6 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts @@ -22,7 +22,7 @@ import { NotFoundException, } from '@nestjs/common'; import { EntityId, LanguageType } from '@shared/domain'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContext, AuthorizationContextBuilder } from '@src/modules/authorization'; import { AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; @@ -92,7 +92,7 @@ export class H5PEditorUc { public async getAjax( query: AjaxGetQueryParams, - currentUser: ICurrentUser + currentUser: CurrentUserInterface ): Promise { const user = this.changeUserType(currentUser); const language = await this.getUserLanguage(currentUser); @@ -116,7 +116,7 @@ export class H5PEditorUc { } public async postAjax( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, query: AjaxPostQueryParams, body: AjaxPostBodyParams, contentFile?: Express.Multer.File, @@ -167,7 +167,7 @@ export class H5PEditorUc { } } - public async getContentParameters(contentId: string, currentUser: ICurrentUser) { + public async getContentParameters(contentId: string, currentUser: CurrentUserInterface) { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -186,7 +186,7 @@ export class H5PEditorUc { contentId: string, file: string, req: Request, - currentUser: ICurrentUser + currentUser: CurrentUserInterface ): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -227,7 +227,11 @@ export class H5PEditorUc { } } - public async getTemporaryFile(file: string, req: Request, currentUser: ICurrentUser): Promise { + public async getTemporaryFile( + file: string, + req: Request, + currentUser: CurrentUserInterface + ): Promise { const user = this.changeUserType(currentUser); try { @@ -262,7 +266,7 @@ export class H5PEditorUc { } } - public async getH5pPlayer(currentUser: ICurrentUser, contentId: string): Promise { + public async getH5pPlayer(currentUser: CurrentUserInterface, contentId: string): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -273,7 +277,7 @@ export class H5PEditorUc { return playerModel; } - public async getEmptyH5pEditor(currentUser: ICurrentUser, language: LanguageType) { + public async getEmptyH5pEditor(currentUser: CurrentUserInterface, language: LanguageType) { const user = this.changeUserType(currentUser); const fakeUndefinedString = this.fakeUndefinedAsString(); @@ -287,7 +291,7 @@ export class H5PEditorUc { return createdH5PEditor; } - public async getH5pEditor(currentUser: ICurrentUser, contentId: string, language: LanguageType) { + public async getH5pEditor(currentUser: CurrentUserInterface, contentId: string, language: LanguageType) { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.write([])); @@ -304,7 +308,7 @@ export class H5PEditorUc { }; } - public async deleteH5pContent(currentUser: ICurrentUser, contentId: string): Promise { + public async deleteH5pContent(currentUser: CurrentUserInterface, contentId: string): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.write([])); @@ -324,7 +328,7 @@ export class H5PEditorUc { } public async createH5pContentGetMetadata( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, params: unknown, metadata: IContentMetadata, mainLibraryUbername: string, @@ -349,7 +353,7 @@ export class H5PEditorUc { public async saveH5pContentGetMetadata( contentId: string, - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, params: unknown, metadata: IContentMetadata, mainLibraryUbername: string, @@ -371,7 +375,7 @@ export class H5PEditorUc { return newContentId; } - private changeUserType(currentUser: ICurrentUser): LumiIUser { + private changeUserType(currentUser: CurrentUserInterface): LumiIUser { const user: LumiIUser = { canCreateRestricted: false, canInstallRecommended: true, @@ -386,7 +390,7 @@ export class H5PEditorUc { } private createAugmentedLumiUser( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, contentParentType: H5PContentParentType, contentParentId: EntityId ) { @@ -399,7 +403,7 @@ export class H5PEditorUc { return user; } - private async getUserLanguage(currentUser: ICurrentUser): Promise { + private async getUserLanguage(currentUser: CurrentUserInterface): Promise { const languageUser = await this.userService.findById(currentUser.userId); let userLanguage = LanguageType.DE; if (languageUser?.language) { diff --git a/apps/server/src/modules/learnroom/controller/course.controller.ts b/apps/server/src/modules/learnroom/controller/course.controller.ts index dfb4e920957..cebb03a864a 100644 --- a/apps/server/src/modules/learnroom/controller/course.controller.ts +++ b/apps/server/src/modules/learnroom/controller/course.controller.ts @@ -1,13 +1,13 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, NotFoundException, Param, Query, Res, StreamableFile } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import { ApiTags } from '@nestjs/swagger'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { PaginationParams } from '@shared/controller/'; import { Response } from 'express'; -import { ConfigService } from '@nestjs/config'; -import { CourseUc } from '../uc/course.uc'; -import { CourseExportUc } from '../uc/course-export.uc'; -import { CourseMetadataListResponse, CourseUrlParams, CourseQueryParams } from './dto'; import { CourseMapper } from '../mapper/course.mapper'; +import { CourseExportUc } from '../uc/course-export.uc'; +import { CourseUc } from '../uc/course.uc'; +import { CourseMetadataListResponse, CourseQueryParams, CourseUrlParams } from './dto'; @ApiTags('Courses') @Authenticate('jwt') @@ -21,7 +21,7 @@ export class CourseController { @Get() async findForUser( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() pagination: PaginationParams ): Promise { const [courses, total] = await this.courseUc.findAllByUser(currentUser.userId, pagination); @@ -34,7 +34,7 @@ export class CourseController { @Get(':courseId/export') async exportCourse( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: CourseUrlParams, @Query() queryParams: CourseQueryParams, @Res({ passthrough: true }) response: Response diff --git a/apps/server/src/modules/learnroom/controller/dashboard.controller.ts b/apps/server/src/modules/learnroom/controller/dashboard.controller.ts index 224f6c41ca7..1559be97f59 100644 --- a/apps/server/src/modules/learnroom/controller/dashboard.controller.ts +++ b/apps/server/src/modules/learnroom/controller/dashboard.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Get, Param, Patch, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { DashboardMapper } from '../mapper/dashboard.mapper'; import { DashboardUc } from '../uc/dashboard.uc'; import { DashboardResponse, DashboardUrlParams, MoveElementParams, PatchGroupParams } from './dto'; @@ -12,7 +12,7 @@ export class DashboardController { constructor(private readonly dashboardUc: DashboardUc) {} @Get() - async findForUser(@CurrentUser() currentUser: ICurrentUser): Promise { + async findForUser(@CurrentUser() currentUser: CurrentUserInterface): Promise { const dashboard = await this.dashboardUc.getUsersDashboard(currentUser.userId); const dto = DashboardMapper.mapToResponse(dashboard); return dto; @@ -22,7 +22,7 @@ export class DashboardController { async moveElement( @Param() { dashboardId }: DashboardUrlParams, @Body() params: MoveElementParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const dashboard = await this.dashboardUc.moveElementOnDashboard( dashboardId, @@ -40,7 +40,7 @@ export class DashboardController { @Query('x') x: number, @Query('y') y: number, @Body() params: PatchGroupParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const dashboard = await this.dashboardUc.renameGroupOnDashboard( urlParams.dashboardId, diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.ts index 0e0b2f7c7a0..24a3dabc34d 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.ts @@ -1,9 +1,9 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; +import { serverConfig } from '@modules/server/server.config'; import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { RequestTimeout } from '@shared/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; -import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; -import { serverConfig } from '@modules/server/server.config'; import { RoomBoardResponseMapper } from '../mapper/room-board-response.mapper'; import { CourseCopyUC } from '../uc/course-copy.uc'; import { LessonCopyUC } from '../uc/lesson-copy.uc'; @@ -32,7 +32,7 @@ export class RoomsController { @Get(':roomId/board') async getRoomBoard( @Param() urlParams: RoomUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const board = await this.roomsUc.getBoard(urlParams.roomId, currentUser.userId); const mapped = this.mapper.mapToResponse(board); @@ -43,7 +43,7 @@ export class RoomsController { async patchElementVisibility( @Param() urlParams: RoomElementUrlParams, @Body() params: PatchVisibilityParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.roomsUc.updateVisibilityOfBoardElement( urlParams.roomId, @@ -57,7 +57,7 @@ export class RoomsController { async patchOrderingOfElements( @Param() urlParams: RoomUrlParams, @Body() params: PatchOrderParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { await this.roomsUc.reorderBoardElements(urlParams.roomId, currentUser.userId, params.elements); } @@ -65,7 +65,7 @@ export class RoomsController { @Post(':roomId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyCourse( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: RoomUrlParams ): Promise { const copyStatus = await this.courseCopyUc.copyCourse(currentUser.userId, urlParams.roomId); @@ -76,7 +76,7 @@ export class RoomsController { @Post('lessons/:lessonId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyLesson( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: LessonUrlParams, @Body() params: LessonCopyApiParams ): Promise { diff --git a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts index 58b591faea1..a3b3b93659a 100644 --- a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts +++ b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Get, Param, Put } from '@nestjs/common'; import { ApiFoundResponse, @@ -6,10 +7,9 @@ import { ApiTags, ApiUnauthorizedResponse, } from '@nestjs/swagger'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { MigrationMapper } from '../mapper/migration.mapper'; -import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; import { LegacySchoolUc } from '../uc'; +import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; import { MigrationBody, MigrationResponse, SchoolParams } from './dto'; /** @@ -28,7 +28,7 @@ export class LegacySchoolController { async setMigration( @Param() schoolParams: SchoolParams, @Body() migrationBody: MigrationBody, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const migrationDto: OauthMigrationDto = await this.schoolUc.setMigration( schoolParams.schoolId, @@ -50,7 +50,7 @@ export class LegacySchoolController { @ApiNotFoundResponse({ description: 'Migrationsflags could not be found for the given school' }) async getMigration( @Param() schoolParams: SchoolParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const migrationDto: OauthMigrationDto = await this.schoolUc.getMigration(schoolParams.schoolId, currentUser.userId); diff --git a/apps/server/src/modules/lesson/controller/lesson.controller.ts b/apps/server/src/modules/lesson/controller/lesson.controller.ts index 14762a47d8c..edd926642e0 100644 --- a/apps/server/src/modules/lesson/controller/lesson.controller.ts +++ b/apps/server/src/modules/lesson/controller/lesson.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Delete, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { LessonUC } from '../uc'; import { LessonUrlParams } from './dto'; @@ -11,7 +11,10 @@ export class LessonController { constructor(private readonly lessonUC: LessonUC) {} @Delete(':lessonId') - async delete(@Param() urlParams: LessonUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async delete( + @Param() urlParams: LessonUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const result = await this.lessonUC.delete(currentUser.userId, urlParams.lessonId); return result; diff --git a/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts b/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts index 8133c4c0b83..146513d1e38 100644 --- a/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts +++ b/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, InternalServerErrorException, Post, UnauthorizedException } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; import { MetaTagExtractorUc } from '../uc'; import { MetaTagExtractorResponse } from './dto'; @@ -18,7 +18,7 @@ export class MetaTagExtractorController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Post('') async getData( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() bodyParams: GetMetaTagDataBody ): Promise { const result = await this.metaTagExtractorUc.fetchMetaData(currentUser.userId, bodyParams.url); diff --git a/apps/server/src/modules/news/controller/news.controller.ts b/apps/server/src/modules/news/controller/news.controller.ts index 2f1c227401a..dfad2718345 100644 --- a/apps/server/src/modules/news/controller/news.controller.ts +++ b/apps/server/src/modules/news/controller/news.controller.ts @@ -1,7 +1,7 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { NewsMapper } from '../mapper/news.mapper'; import { NewsUc } from '../uc/news.uc'; import { @@ -23,7 +23,10 @@ export class NewsController { * Create a news by a user in a given scope (school or team). */ @Post() - async create(@CurrentUser() currentUser: ICurrentUser, @Body() params: CreateNewsParams): Promise { + async create( + @CurrentUser() currentUser: CurrentUserInterface, + @Body() params: CreateNewsParams + ): Promise { const news = await this.newsUc.create( currentUser.userId, currentUser.schoolId, @@ -38,7 +41,7 @@ export class NewsController { */ @Get() async findAll( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() scope: FilterNewsParams, @Query() pagination: PaginationParams ): Promise { @@ -58,7 +61,10 @@ export class NewsController { * The news entity has school and user names populated. */ @Get(':newsId') - async findOne(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async findOne( + @Param() urlParams: NewsUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const news = await this.newsUc.findOneByIdForUser(urlParams.newsId, currentUser.userId); const dto = NewsMapper.mapToResponse(news); return dto; @@ -70,7 +76,7 @@ export class NewsController { @Patch(':newsId') async update( @Param() urlParams: NewsUrlParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() params: UpdateNewsParams ): Promise { const news = await this.newsUc.update( @@ -86,7 +92,7 @@ export class NewsController { * Delete a news. */ @Delete(':newsId') - async delete(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async delete(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { const deletedId = await this.newsUc.delete(urlParams.newsId, currentUser.userId); return deletedId; } diff --git a/apps/server/src/modules/news/controller/team-news.controller.ts b/apps/server/src/modules/news/controller/team-news.controller.ts index 2344d6f2ac9..71e66c6c34c 100644 --- a/apps/server/src/modules/news/controller/team-news.controller.ts +++ b/apps/server/src/modules/news/controller/team-news.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, Param, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; import { PaginationParams } from '@shared/controller'; import { NewsMapper } from '../mapper/news.mapper'; import { NewsUc } from '../uc'; @@ -18,7 +18,7 @@ export class TeamNewsController { @Get(':teamId/news') async findAllForTeam( @Param() urlParams: TeamUrlParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() scope: FilterNewsParams, @Query() pagination: PaginationParams ): Promise { 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 97b16e8e49f..0eb5323d368 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,22 +1,20 @@ import { Configuration } from '@hpi-schul-cloud/commons'; +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; -import { ICurrentUser, Authenticate, CurrentUser } from '@modules/authentication'; // import should be @infra/oauth-provider import { ProviderConsentResponse, + ProviderConsentSessionResponse, ProviderLoginResponse, ProviderOauthClient, ProviderRedirectResponse, - ProviderConsentSessionResponse, } 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'; import { OauthProviderResponseMapper } from '../mapper/oauth-provider-response.mapper'; -import { OauthProviderConsentFlowUc } from '../uc/oauth-provider.consent-flow.uc'; -import { ConsentResponse } from './dto/response/consent.response'; import { OauthProviderClientCrudUc } from '../uc/oauth-provider.client-crud.uc'; -import { RedirectResponse } from './dto/response/redirect.response'; +import { OauthProviderConsentFlowUc } from '../uc/oauth-provider.consent-flow.uc'; +import { OauthProviderLoginFlowUc } from '../uc/oauth-provider.login-flow.uc'; +import { OauthProviderLogoutFlowUc } from '../uc/oauth-provider.logout-flow.uc'; import { OauthProviderUc } from '../uc/oauth-provider.uc'; import { AcceptQuery, @@ -31,6 +29,8 @@ import { OauthClientResponse, RevokeConsentParams, } from './dto'; +import { ConsentResponse } from './dto/response/consent.response'; +import { RedirectResponse } from './dto/response/redirect.response'; @Controller('oauth2') @ApiTags('Oauth2') @@ -47,7 +47,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('clients/:id') async getOAuth2Client( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: IdParams ): Promise { const client: ProviderOauthClient = await this.crudUc.getOAuth2Client(currentUser, params.id); @@ -58,7 +58,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('clients') async listOAuth2Clients( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ListOauthClientsParams ): Promise { const clients: ProviderOauthClient[] = await this.crudUc.listOAuth2Clients( @@ -78,7 +78,7 @@ export class OauthProviderController { @Authenticate('jwt') @Post('clients') async createOAuth2Client( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: OauthClientBody ): Promise { const client: ProviderOauthClient = await this.crudUc.createOAuth2Client(currentUser, body); @@ -89,7 +89,7 @@ export class OauthProviderController { @Authenticate('jwt') @Put('clients/:id') async updateOAuth2Client( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: IdParams, @Body() body: OauthClientBody ): Promise { @@ -100,7 +100,7 @@ export class OauthProviderController { @Authenticate('jwt') @Delete('clients/:id') - deleteOAuth2Client(@CurrentUser() currentUser: ICurrentUser, @Param() params: IdParams): Promise { + deleteOAuth2Client(@CurrentUser() currentUser: CurrentUserInterface, @Param() params: IdParams): Promise { const promise: Promise = this.crudUc.deleteOAuth2Client(currentUser, params.id); return promise; } @@ -118,7 +118,7 @@ export class OauthProviderController { @Param() params: ChallengeParams, @Query() query: AcceptQuery, @Body() body: LoginRequestBody, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const redirectResponse: ProviderRedirectResponse = await this.oauthProviderLoginFlowUc.patchLoginRequest( currentUser.userId, @@ -152,7 +152,7 @@ export class OauthProviderController { @Param() params: ChallengeParams, @Query() query: AcceptQuery, @Body() body: ConsentRequestBody, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const redirectResponse: ProviderRedirectResponse = await this.consentFlowUc.patchConsentRequest( params.challenge, @@ -166,7 +166,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('auth/sessions/consent') - async listConsentSessions(@CurrentUser() currentUser: ICurrentUser): Promise { + async listConsentSessions(@CurrentUser() currentUser: CurrentUserInterface): Promise { const sessions: ProviderConsentSessionResponse[] = await this.oauthProviderUc.listConsentSessions( currentUser.userId ); @@ -179,7 +179,10 @@ export class OauthProviderController { @Authenticate('jwt') @Delete('auth/sessions/consent') - revokeConsentSession(@CurrentUser() currentUser: ICurrentUser, @Param() params: RevokeConsentParams): Promise { + revokeConsentSession( + @CurrentUser() currentUser: CurrentUserInterface, + @Param() params: RevokeConsentParams + ): Promise { const promise: Promise = this.oauthProviderUc.revokeConsentSession(currentUser.userId, params.client); return promise; } 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 18fd23ae788..e29c23249f7 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,9 +1,9 @@ -import { Injectable } from '@nestjs/common'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { OauthProviderService } from '@infra/oauth-provider/index'; -import { Permission, User } from '@shared/domain/index'; +import { CurrentUserInterface } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; -import { ProviderOauthClient } from '@infra/oauth-provider/dto'; -import { ICurrentUser } from '@modules/authentication'; +import { Injectable } from '@nestjs/common'; +import { Permission, User } from '@shared/domain/index'; @Injectable() export class OauthProviderClientCrudUc { @@ -20,7 +20,7 @@ export class OauthProviderClientCrudUc { }; async listOAuth2Clients( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, limit?: number, offset?: number, client_name?: string, @@ -38,7 +38,7 @@ export class OauthProviderClientCrudUc { return client; } - async getOAuth2Client(currentUser: ICurrentUser, id: string): Promise { + async getOAuth2Client(currentUser: CurrentUserInterface, id: string): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_VIEW]); @@ -47,7 +47,7 @@ export class OauthProviderClientCrudUc { return client; } - async createOAuth2Client(currentUser: ICurrentUser, data: ProviderOauthClient): Promise { + async createOAuth2Client(currentUser: CurrentUserInterface, data: ProviderOauthClient): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_EDIT]); @@ -57,7 +57,7 @@ export class OauthProviderClientCrudUc { } async updateOAuth2Client( - currentUser: ICurrentUser, + currentUser: CurrentUserInterface, id: string, data: ProviderOauthClient ): Promise { @@ -69,7 +69,7 @@ export class OauthProviderClientCrudUc { return client; } - async deleteOAuth2Client(currentUser: ICurrentUser, id: string): Promise { + async deleteOAuth2Client(currentUser: CurrentUserInterface, id: string): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_EDIT]); 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 126f68f1b80..a38cbcd6d5c 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 @@ -1,15 +1,15 @@ +import { OauthProviderService } from '@infra/oauth-provider'; import { AcceptConsentRequestBody, ProviderConsentResponse, ProviderRedirectResponse, RejectRequestBody, } from '@infra/oauth-provider/dto'; +import { CurrentUserInterface } from '@modules/authentication'; 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 '@infra/oauth-provider'; import { IdToken } from '@modules/oauth-provider/interface/id-token'; +import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; +import { ForbiddenException, Injectable } from '@nestjs/common'; @Injectable() export class OauthProviderConsentFlowUc { @@ -27,7 +27,7 @@ export class OauthProviderConsentFlowUc { challenge: string, query: AcceptQuery, body: ConsentRequestBody, - currentUser: ICurrentUser + currentUser: CurrentUserInterface ): Promise { const consentResponse = await this.oauthProviderService.getConsentRequest(challenge); this.validateSubject(currentUser, consentResponse); @@ -77,7 +77,7 @@ export class OauthProviderConsentFlowUc { return redirectResponse; } - private validateSubject(currentUser: ICurrentUser, response: ProviderConsentResponse): void { + private validateSubject(currentUser: CurrentUserInterface, response: ProviderConsentResponse): void { if (response.subject !== currentUser.userId) { throw new ForbiddenException("You want to patch another user's consent"); } diff --git a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts index 5ff7e7cae02..ba0ff44a218 100644 --- a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts +++ b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts @@ -1,4 +1,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { Authenticate, CurrentUser, CurrentUserInterface, JWT } from '@modules/authentication'; +import { OAuthMigrationError } from '@modules/user-login-migration/error/oauth-migration.error'; +import { MigrationDto } from '@modules/user-login-migration/service/dto'; import { Controller, Get, @@ -14,21 +17,18 @@ import { import { ApiOkResponse, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ISession } from '@shared/domain/types/session'; import { LegacyLogger } from '@src/core/logger'; -import { ICurrentUser, Authenticate, CurrentUser, JWT } from '@modules/authentication'; -import { OAuthMigrationError } from '@modules/user-login-migration/error/oauth-migration.error'; -import { MigrationDto } from '@modules/user-login-migration/service/dto'; import { CookieOptions, Request, Response } from 'express'; -import { HydraOauthUc } from '../uc/hydra-oauth.uc'; -import { UserMigrationResponse } from './dto/user-migration.response'; -import { OAuthSSOError } from '../loggable/oauth-sso.error'; import { OAuthTokenDto } from '../interface'; +import { OAuthSSOError } from '../loggable/oauth-sso.error'; import { OauthLoginStateMapper } from '../mapper/oauth-login-state.mapper'; import { UserMigrationMapper } from '../mapper/user-migration.mapper'; import { OAuthProcessDto } from '../service/dto'; import { OauthUc } from '../uc'; import { OauthLoginStateDto } from '../uc/dto/oauth-login-state.dto'; +import { HydraOauthUc } from '../uc/hydra-oauth.uc'; import { AuthorizationParams, SSOLoginQuery, SystemIdParams } from './dto'; import { StatelessAuthorizationParams } from './dto/stateless-authorization.params'; +import { UserMigrationResponse } from './dto/user-migration.response'; @ApiTags('SSO') @Controller('sso') @@ -160,7 +160,7 @@ export class OauthSSOController { @Get('auth/:oauthClientId') @Authenticate('jwt') async requestAuthToken( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Req() req: Request, @Param('oauthClientId') oauthClientId: string ): Promise { @@ -183,7 +183,7 @@ export class OauthSSOController { async migrateUser( @JWT() jwt: string, @Session() session: ISession, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() query: AuthorizationParams, @Res() res: Response ): Promise { diff --git a/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts b/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts index f7e378e050a..82e3dc9f584 100644 --- a/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts +++ b/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -7,7 +8,6 @@ import { ApiUnauthorizedResponse, } from '@nestjs/swagger'; import { Pseudonym } from '@shared/domain'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { PseudonymMapper } from '../mapper/pseudonym.mapper'; import { PseudonymUc } from '../uc'; import { PseudonymResponse } from './dto'; @@ -26,7 +26,7 @@ export class PseudonymController { @ApiOperation({ summary: 'Returns the related user and tool information to a pseudonym' }) async getPseudonym( @Param() params: PseudonymParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const pseudonym: Pseudonym = await this.pseudonymUc.findPseudonymByPseudonym(currentUser.userId, params.pseudonym); diff --git a/apps/server/src/modules/sharing/controller/share-token.controller.ts b/apps/server/src/modules/sharing/controller/share-token.controller.ts index 373e1169600..f5793033b9d 100644 --- a/apps/server/src/modules/sharing/controller/share-token.controller.ts +++ b/apps/server/src/modules/sharing/controller/share-token.controller.ts @@ -1,3 +1,5 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; import { Body, Controller, @@ -11,8 +13,6 @@ import { } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiValidationError, RequestTimeout } from '@shared/common'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; -import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; // invalid import can produce dependency cycles import { serverConfig } from '@modules/server/server.config'; import { ShareTokenInfoResponseMapper, ShareTokenResponseMapper } from '../mapper'; @@ -38,7 +38,7 @@ export class ShareTokenController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Post() async createShareToken( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: ShareTokenBodyParams ): Promise { const shareToken = await this.shareTokenUC.createShareToken( @@ -65,7 +65,7 @@ export class ShareTokenController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Get(':token') async lookupShareToken( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: ShareTokenUrlParams ): Promise { const shareTokenInfo = await this.shareTokenUC.lookupShareToken(currentUser.userId, urlParams.token); @@ -84,7 +84,7 @@ export class ShareTokenController { @Post(':token/import') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async importShareToken( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: ShareTokenUrlParams, @Body() body: ShareTokenImportBodyParams ): Promise { diff --git a/apps/server/src/modules/task/controller/submission.controller.ts b/apps/server/src/modules/task/controller/submission.controller.ts index 64d3a23296f..ccaed6fc403 100644 --- a/apps/server/src/modules/task/controller/submission.controller.ts +++ b/apps/server/src/modules/task/controller/submission.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Delete, Get, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { SubmissionMapper } from '../mapper'; import { SubmissionUc } from '../uc'; import { SubmissionStatusListResponse, SubmissionUrlParams, TaskUrlParams } from './dto'; @@ -13,7 +13,7 @@ export class SubmissionController { @Get('status/task/:taskId') async findStatusesByTask( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: TaskUrlParams ): Promise { const submissions = await this.submissionUc.findAllByTask(currentUser.userId, params.taskId); @@ -26,7 +26,10 @@ export class SubmissionController { } @Delete(':submissionId') - async delete(@Param() urlParams: SubmissionUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async delete( + @Param() urlParams: SubmissionUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const result = await this.submissionUc.delete(currentUser.userId, urlParams.submissionId); return result; diff --git a/apps/server/src/modules/task/controller/task.controller.ts b/apps/server/src/modules/task/controller/task.controller.ts index 44911973ffd..b4dcf47724e 100644 --- a/apps/server/src/modules/task/controller/task.controller.ts +++ b/apps/server/src/modules/task/controller/task.controller.ts @@ -1,9 +1,9 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { RequestTimeout } from '@shared/common'; import { PaginationParams } from '@shared/controller/'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; -import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; // invalid import can produce dependency cycles import { serverConfig } from '@modules/server/server.config'; import { TaskMapper } from '../mapper'; @@ -20,7 +20,7 @@ export class TaskController { @Get() async findAll( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() pagination: PaginationParams ): Promise { return this.findAllTasks(currentUser, pagination); @@ -28,14 +28,14 @@ export class TaskController { @Get('finished') async findAllFinished( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() pagination: PaginationParams ): Promise { return this.findAllTasks(currentUser, pagination, true); } private async findAllTasks( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() pagination: PaginationParams, finished = false ): Promise { @@ -51,7 +51,10 @@ export class TaskController { } @Patch(':taskId/finish') - async finish(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async finish( + @Param() urlParams: TaskUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const task = await this.taskUc.changeFinishedForUser(currentUser.userId, urlParams.taskId, true); const response = TaskMapper.mapToResponse(task); @@ -60,7 +63,10 @@ export class TaskController { } @Patch(':taskId/restore') - async restore(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async restore( + @Param() urlParams: TaskUrlParams, + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const task = await this.taskUc.changeFinishedForUser(currentUser.userId, urlParams.taskId, false); const response = TaskMapper.mapToResponse(task); @@ -71,7 +77,7 @@ export class TaskController { @Patch(':taskId/revertPublished') async revertPublished( @Param() urlParams: TaskUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const task = await this.taskUc.revertPublished(currentUser.userId, urlParams.taskId); @@ -83,7 +89,7 @@ export class TaskController { @Post(':taskId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyTask( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() urlParams: TaskUrlParams, @Body() params: TaskCopyApiParams ): Promise { @@ -97,7 +103,7 @@ export class TaskController { } @Delete(':taskId') - async delete(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { + async delete(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { const result = await this.taskUc.delete(currentUser.userId, urlParams.taskId); return result; diff --git a/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts b/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts index 20d8b96f795..68a75a57a60 100644 --- a/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts +++ b/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common'; import { ApiCreatedResponse, @@ -42,7 +42,7 @@ export class ToolContextController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates a ContextExternalTool' }) async createContextExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: ContextExternalToolPostParams ): Promise { const contextExternalTool: ContextExternalToolDto = @@ -68,7 +68,7 @@ export class ToolContextController { @ApiOperation({ summary: 'Deletes a ContextExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteContextExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolIdParams ): Promise { await this.contextExternalToolUc.deleteContextExternalTool(currentUser.userId, params.contextExternalToolId); @@ -87,7 +87,7 @@ export class ToolContextController { }) @ApiOperation({ summary: 'Returns a list of ContextExternalTools for the given context' }) async getContextExternalToolsForContext( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolContextParams ): Promise { const contextExternalTools: ContextExternalTool[] = @@ -120,7 +120,7 @@ export class ToolContextController { }) @ApiOperation({ summary: 'Searches a ContextExternalTool for the given id' }) async getContextExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolIdParams ): Promise { const contextExternalTool: ContextExternalTool = await this.contextExternalToolUc.getContextExternalTool( @@ -144,7 +144,7 @@ export class ToolContextController { @ApiUnprocessableEntityResponse() @ApiOperation({ summary: 'Updates a ContextExternalTool' }) async updateContextExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolIdParams, @Body() body: ContextExternalToolPostParams ): Promise { diff --git a/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts b/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts index 3c00d30e6e2..6b53af1ebfc 100644 --- a/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts +++ b/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, ApiOkResponse, ApiOperation, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { ToolReference } from '../domain'; import { ContextExternalToolResponseMapper } from '../mapper'; import { ToolReferenceUc } from '../uc'; @@ -26,7 +26,7 @@ export class ToolReferenceController { @ApiForbiddenResponse({ description: 'User is not allowed to access this resource.' }) @ApiUnauthorizedResponse({ description: 'User is not logged in.' }) async getToolReference( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolIdParams ): Promise { const toolReference: ToolReference = await this.toolReferenceUc.getToolReference( @@ -49,7 +49,7 @@ export class ToolReferenceController { @ApiForbiddenResponse({ description: 'User is not allowed to access this resource.' }) @ApiUnauthorizedResponse({ description: 'User is not logged in.' }) async getToolReferencesForContext( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolContextParams ): Promise { const toolReferences: ToolReference[] = await this.toolReferenceUc.getToolReferencesForContext( diff --git a/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts index 589a1e38e7c..570bf1282ff 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -7,7 +8,6 @@ import { ApiTags, ApiUnauthorizedResponse, } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { ExternalTool } from '../domain'; import { ToolConfigurationMapper } from '../mapper/tool-configuration.mapper'; import { ContextExternalToolTemplateInfo, ExternalToolConfigurationUc } from '../uc'; @@ -36,7 +36,7 @@ export class ToolConfigurationController { type: SchoolExternalToolConfigurationTemplateListResponse, }) public async getAvailableToolsForSchool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: SchoolIdParams ): Promise { const availableTools: ExternalTool[] = await this.externalToolConfigurationUc.getAvailableToolsForSchool( @@ -58,7 +58,7 @@ export class ToolConfigurationController { type: ContextExternalToolConfigurationTemplateListResponse, }) public async getAvailableToolsForContext( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextRefParams ): Promise { const availableTools: ContextExternalToolTemplateInfo[] = @@ -84,7 +84,7 @@ export class ToolConfigurationController { type: SchoolExternalToolConfigurationTemplateResponse, }) public async getConfigurationTemplateForSchool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: SchoolExternalToolIdParams ): Promise { const tool: ExternalTool = await this.externalToolConfigurationUc.getTemplateForSchoolExternalTool( @@ -107,7 +107,7 @@ export class ToolConfigurationController { type: ContextExternalToolConfigurationTemplateResponse, }) public async getConfigurationTemplateForContext( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ContextExternalToolIdParams ): Promise { const tool: ContextExternalToolTemplateInfo = diff --git a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts index 80139a586cb..ec102455d06 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query, Res } from '@nestjs/common'; import { ApiCreatedResponse, @@ -14,7 +15,6 @@ import { ValidationError } from '@shared/common'; import { PaginationParams } from '@shared/controller'; import { IFindOptions, Page } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Response } from 'express'; import { ExternalToolSearchQuery } from '../../common/interface'; import { ExternalTool } from '../domain'; @@ -51,7 +51,7 @@ export class ToolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates an ExternalTool' }) async createExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() externalToolParams: ExternalToolCreateParams ): Promise { const externalTool: ExternalToolCreate = this.externalToolDOMapper.mapCreateRequest(externalToolParams); @@ -71,7 +71,7 @@ export class ToolController { @ApiForbiddenResponse() @ApiOperation({ summary: 'Returns a list of ExternalTools' }) async findExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() filterQuery: ExternalToolSearchParams, @Query() pagination: PaginationParams, @Query() sortingQuery: SortExternalToolParams @@ -99,7 +99,7 @@ export class ToolController { @Get(':externalToolId') @ApiOperation({ summary: 'Returns an ExternalTool for the given id' }) async getExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ExternalToolIdParams ): Promise { const externalTool: ExternalTool = await this.externalToolUc.getExternalTool( @@ -118,7 +118,7 @@ export class ToolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Updates an ExternalTool' }) async updateExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ExternalToolIdParams, @Body() externalToolParams: ExternalToolUpdateParams ): Promise { @@ -140,7 +140,7 @@ export class ToolController { @ApiOperation({ summary: 'Deletes an ExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ExternalToolIdParams ): Promise { const promise: Promise = this.externalToolUc.deleteExternalTool(currentUser.userId, params.externalToolId); diff --git a/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts b/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts index 79d6f789443..5ef5b4fd8d8 100644 --- a/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts +++ b/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts @@ -1,21 +1,24 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { + ApiBadRequestResponse, ApiCreatedResponse, ApiForbiddenResponse, ApiFoundResponse, - ApiResponse, ApiOkResponse, - ApiBadRequestResponse, + ApiOperation, + ApiResponse, ApiTags, ApiUnauthorizedResponse, ApiUnprocessableEntityResponse, - ApiOperation, } from '@nestjs/swagger'; -import { Body, Controller, Delete, Get, Param, Post, Query, Put, HttpCode, HttpStatus } from '@nestjs/common'; import { ValidationError } from '@shared/common'; import { LegacyLogger } from '@src/core/logger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; -import { SchoolExternalToolRequestMapper, SchoolExternalToolResponseMapper } from '../mapper'; import { ExternalToolSearchListResponse } from '../../external-tool/controller/dto'; +import { SchoolExternalTool } from '../domain'; +import { SchoolExternalToolRequestMapper, SchoolExternalToolResponseMapper } from '../mapper'; +import { SchoolExternalToolUc } from '../uc'; +import { SchoolExternalToolDto } from '../uc/dto/school-external-tool.types'; import { SchoolExternalToolIdParams, SchoolExternalToolPostParams, @@ -23,9 +26,6 @@ import { SchoolExternalToolSearchListResponse, SchoolExternalToolSearchParams, } from './dto'; -import { SchoolExternalToolDto } from '../uc/dto/school-external-tool.types'; -import { SchoolExternalToolUc } from '../uc'; -import { SchoolExternalTool } from '../domain'; @ApiTags('Tool') @Authenticate('jwt') @@ -44,7 +44,7 @@ export class ToolSchoolController { @ApiUnauthorizedResponse() @ApiOperation({ summary: 'Returns a list of SchoolExternalTools for a given school' }) async getSchoolExternalTools( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() schoolExternalToolParams: SchoolExternalToolSearchParams ): Promise { const found: SchoolExternalTool[] = await this.schoolExternalToolUc.findSchoolExternalTools(currentUser.userId, { @@ -59,7 +59,7 @@ export class ToolSchoolController { @ApiUnauthorizedResponse() @ApiOperation({ summary: 'Returns a SchoolExternalTool for the given id' }) async getSchoolExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: SchoolExternalToolIdParams ): Promise { const schoolExternalTool: SchoolExternalTool = await this.schoolExternalToolUc.getSchoolExternalTool( @@ -77,7 +77,7 @@ export class ToolSchoolController { @ApiBadRequestResponse({ type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Updates a SchoolExternalTool' }) async updateSchoolExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: SchoolExternalToolIdParams, @Body() body: SchoolExternalToolPostParams ): Promise { @@ -99,7 +99,7 @@ export class ToolSchoolController { @ApiOperation({ summary: 'Deletes a SchoolExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteSchoolExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: SchoolExternalToolIdParams ): Promise { await this.schoolExternalToolUc.deleteSchoolExternalTool(currentUser.userId, params.schoolExternalToolId); @@ -119,7 +119,7 @@ export class ToolSchoolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates a SchoolExternalTool' }) async createSchoolExternalTool( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: SchoolExternalToolPostParams ): Promise { const schoolExternalToolDto: SchoolExternalToolDto = this.requestMapper.mapSchoolExternalToolRequest(body); diff --git a/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts b/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts index 12424b294ed..a11a61468c0 100644 --- a/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts +++ b/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiBadRequestResponse, @@ -7,11 +8,10 @@ import { ApiTags, ApiUnauthorizedResponse, } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; -import { ToolLaunchUc } from '../uc'; -import { ToolLaunchParams, ToolLaunchRequestResponse } from './dto'; import { ToolLaunchMapper } from '../mapper'; import { ToolLaunchRequest } from '../types'; +import { ToolLaunchUc } from '../uc'; +import { ToolLaunchParams, ToolLaunchRequestResponse } from './dto'; @ApiTags('Tool') @Authenticate('jwt') @@ -26,7 +26,7 @@ export class ToolLaunchController { @ApiForbiddenResponse({ description: 'Forbidden' }) @ApiBadRequestResponse({ description: 'Outdated tools cannot be launched' }) async getToolLaunchRequest( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() params: ToolLaunchParams ): Promise { const toolLaunchRequest: ToolLaunchRequest = await this.toolLaunchUc.getToolLaunchRequest( diff --git a/apps/server/src/modules/user-import/controller/import-user.controller.ts b/apps/server/src/modules/user-import/controller/import-user.controller.ts index c4368b5ea3f..6f49104c425 100644 --- a/apps/server/src/modules/user-import/controller/import-user.controller.ts +++ b/apps/server/src/modules/user-import/controller/import-user.controller.ts @@ -1,8 +1,8 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; import { IFindOptions, ImportUser, User } from '@shared/domain'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { ImportUserMapper } from '../mapper/import-user.mapper'; import { UserMatchMapper } from '../mapper/user-match.mapper'; import { UserImportUc } from '../uc/user-import.uc'; @@ -27,7 +27,7 @@ export class ImportUserController { @Get() async findAllImportUsers( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() scope: FilterImportUserParams, @Query() sortingQuery: SortImportUserParams, @Query() pagination: PaginationParams @@ -46,7 +46,7 @@ export class ImportUserController { @Patch(':importUserId/match') async setMatch( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() params: UpdateMatchParams ): Promise { const result = await this.userImportUc.setMatch(currentUser.userId, urlParams.importUserId, params.userId); @@ -58,7 +58,7 @@ export class ImportUserController { @Delete(':importUserId/match') async removeMatch( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const result = await this.userImportUc.removeMatch(currentUser.userId, urlParams.importUserId); const response = ImportUserMapper.mapToResponse(result); @@ -69,7 +69,7 @@ export class ImportUserController { @Patch(':importUserId/flag') async updateFlag( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() params: UpdateFlagParams ): Promise { const result = await this.userImportUc.updateFlag(currentUser.userId, urlParams.importUserId, params.flagged); @@ -80,7 +80,7 @@ export class ImportUserController { @Get('unassigned') async findAllUnmatchedUsers( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query() scope: FilterUserParams, @Query() pagination: PaginationParams ): Promise { @@ -96,20 +96,20 @@ export class ImportUserController { } @Post('migrate') - async saveAllUsersMatches(@CurrentUser() currentUser: ICurrentUser): Promise { + async saveAllUsersMatches(@CurrentUser() currentUser: CurrentUserInterface): Promise { await this.userImportUc.saveAllUsersMatches(currentUser.userId); } @Post('startUserMigration') async startSchoolInUserMigration( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Query('useCentralLdap') useCentralLdap?: boolean ): Promise { await this.userImportUc.startSchoolInUserMigration(currentUser.userId, useCentralLdap); } @Post('startSync') - async endSchoolInMaintenance(@CurrentUser() currentUser: ICurrentUser): Promise { + async endSchoolInMaintenance(@CurrentUser() currentUser: CurrentUserInterface): Promise { await this.userImportUc.endSchoolInMaintenance(currentUser.userId); } } diff --git a/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts b/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts index fc1c9c9f9cf..aac715c2171 100644 --- a/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts +++ b/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, ICurrentUser, JWT } from '@modules/authentication'; +import { Authenticate, CurrentUser, CurrentUserInterface, JWT } from '@modules/authentication'; import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -57,7 +57,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'UserLoginMigrations has been found.', type: UserLoginMigrationSearchListResponse }) @ApiInternalServerErrorResponse({ description: 'Cannot find target system information.' }) async getMigrations( - @CurrentUser() user: ICurrentUser, + @CurrentUser() user: CurrentUserInterface, @Query() params: UserLoginMigrationSearchParams ): Promise { const userLoginMigrationQuery: UserLoginMigrationQuery = UserLoginMigrationMapper.mapSearchParamsToQuery(params); @@ -87,7 +87,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'UserLoginMigrations has been found', type: UserLoginMigrationResponse }) @ApiNotFoundResponse({ description: 'Cannot find UserLoginMigration' }) async findUserLoginMigrationBySchool( - @CurrentUser() user: ICurrentUser, + @CurrentUser() user: CurrentUserInterface, @Param() params: SchoolIdParams ): Promise { const userLoginMigration: UserLoginMigrationDO = await this.userLoginMigrationUc.findUserLoginMigrationBySchool( @@ -112,7 +112,7 @@ export class UserLoginMigrationController { }) @ApiOkResponse({ description: 'User login migration started', type: UserLoginMigrationResponse }) @ApiForbiddenResponse() - async startMigration(@CurrentUser() currentUser: ICurrentUser): Promise { + async startMigration(@CurrentUser() currentUser: CurrentUserInterface): Promise { const migrationDto: UserLoginMigrationDO = await this.startUserLoginMigrationUc.startMigration( currentUser.userId, currentUser.schoolId @@ -136,7 +136,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'User login migration started', type: UserLoginMigrationResponse }) @ApiUnauthorizedResponse() @ApiForbiddenResponse() - async restartMigration(@CurrentUser() currentUser: ICurrentUser): Promise { + async restartMigration(@CurrentUser() currentUser: CurrentUserInterface): Promise { const migrationDto: UserLoginMigrationDO = await this.restartUserLoginMigrationUc.restartMigration( currentUser.userId, currentUser.schoolId @@ -165,7 +165,7 @@ export class UserLoginMigrationController { @ApiUnauthorizedResponse() @ApiForbiddenResponse() async setMigrationMandatory( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: UserLoginMigrationMandatoryParams ): Promise { const migrationDto: UserLoginMigrationDO = await this.toggleUserLoginMigrationUc.setMigrationMandatory( @@ -198,7 +198,9 @@ export class UserLoginMigrationController { @ApiUnauthorizedResponse() @ApiForbiddenResponse() @ApiNoContentResponse({ description: 'User login migration was reverted' }) - async closeMigration(@CurrentUser() currentUser: ICurrentUser): Promise { + async closeMigration( + @CurrentUser() currentUser: CurrentUserInterface + ): Promise { const userLoginMigration: UserLoginMigrationDO | undefined = await this.closeUserLoginMigrationUc.closeMigration( currentUser.userId, currentUser.schoolId @@ -217,7 +219,7 @@ export class UserLoginMigrationController { @ApiInternalServerErrorResponse({ description: 'The migration of the User was not possible.' }) async migrateUserLogin( @JWT() jwt: string, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Body() body: Oauth2MigrationParams ): Promise { await this.userLoginMigrationUc.migrate(jwt, currentUser.userId, body.systemId, body.code, body.redirectUri); diff --git a/apps/server/src/modules/user/controller/user.controller.ts b/apps/server/src/modules/user/controller/user.controller.ts index 16729c2667b..5261898b3fa 100644 --- a/apps/server/src/modules/user/controller/user.controller.ts +++ b/apps/server/src/modules/user/controller/user.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Get, Patch } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { ResolvedUserMapper } from '../mapper'; import { UserUc } from '../uc'; import { ChangeLanguageParams, ResolvedUserResponse, SuccessfulResponse } from './dto'; @@ -12,7 +12,7 @@ export class UserController { constructor(private readonly userUc: UserUc) {} @Get('me') - async me(@CurrentUser() currentUser: ICurrentUser): Promise { + async me(@CurrentUser() currentUser: CurrentUserInterface): Promise { const [user, permissions] = await this.userUc.me(currentUser.userId); // only the root roles of the user get published @@ -24,7 +24,7 @@ export class UserController { @Patch('/language') async changeLanguage( @Body() params: ChangeLanguageParams, - @CurrentUser() currentUser: ICurrentUser + @CurrentUser() currentUser: CurrentUserInterface ): Promise { const result = await this.userUc.patchLanguage(currentUser.userId, params); diff --git a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts index 8dbec66972e..db130c87288 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts @@ -1,3 +1,4 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { BadRequestException, Body, @@ -11,7 +12,6 @@ import { } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { VideoConferenceScope } from '@shared/domain/interface'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { BBBBaseResponse } from '../bbb'; import { defaultVideoConferenceOptions } from '../interface'; import { VideoConferenceResponseDeprecatedMapper } from '../mapper/vc-deprecated-response.mapper'; @@ -44,7 +44,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async createAndJoin( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string, @Body() params: VideoConferenceCreateParams @@ -84,7 +84,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async info( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string ): Promise { @@ -104,7 +104,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async end( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string ): Promise { diff --git a/apps/server/src/modules/video-conference/controller/video-conference.controller.ts b/apps/server/src/modules/video-conference/controller/video-conference.controller.ts index 442e9132758..062b4c27ec5 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference.controller.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference.controller.ts @@ -1,6 +1,6 @@ +import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; import { Body, Controller, Get, HttpStatus, Param, Put, Req } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Request } from 'express'; import { InvalidOriginForLogoutUrlLoggableException } from '../error'; import { VideoConferenceOptions } from '../interface'; @@ -43,7 +43,7 @@ export class VideoConferenceController { @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async start( @Req() req: Request, - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() scopeParams: VideoConferenceScopeParams, @Body() params: VideoConferenceCreateParams ): Promise { @@ -75,7 +75,7 @@ export class VideoConferenceController { }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async join( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() scopeParams: VideoConferenceScopeParams ): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); @@ -103,7 +103,7 @@ export class VideoConferenceController { }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async info( - @CurrentUser() currentUser: ICurrentUser, + @CurrentUser() currentUser: CurrentUserInterface, @Param() scopeParams: VideoConferenceScopeParams ): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); @@ -129,7 +129,10 @@ export class VideoConferenceController { description: 'User does not have the permission to end this conference.', }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) - async end(@CurrentUser() currentUser: ICurrentUser, @Param() scopeParams: VideoConferenceScopeParams): Promise { + async end( + @CurrentUser() currentUser: CurrentUserInterface, + @Param() scopeParams: VideoConferenceScopeParams + ): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); await this.videoConferenceEndUc.end(currentUser.userId, scopeRef); diff --git a/apps/server/src/shared/testing/factory/h5p-content.factory.ts b/apps/server/src/shared/testing/factory/h5p-content.factory.ts index 4d07c369cd5..7931f9b1529 100644 --- a/apps/server/src/shared/testing/factory/h5p-content.factory.ts +++ b/apps/server/src/shared/testing/factory/h5p-content.factory.ts @@ -2,12 +2,12 @@ import { ContentMetadata, H5PContent, H5PContentParentType, - IH5PContentProperties, + H5PContentProperties, } from '@src/modules/h5p-editor/entity'; import { ObjectID } from 'bson'; import { BaseFactory } from './base.factory'; -class H5PContentFactory extends BaseFactory {} +class H5PContentFactory extends BaseFactory {} export const h5pContentFactory = H5PContentFactory.define(H5PContent, ({ sequence }) => { return { From 09200ba9276a1feed97d50bd498ffbfb11bb48e1 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:21:50 +0100 Subject: [PATCH 029/110] ITemporaryFileProperties -> TemporaryFileProperties --- .../modules/h5p-editor/entity/h5p-editor-tempfile.entity.ts | 6 +++--- .../shared/testing/factory/h5p-temporary-file.factory.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/modules/h5p-editor/entity/h5p-editor-tempfile.entity.ts b/apps/server/src/modules/h5p-editor/entity/h5p-editor-tempfile.entity.ts index a4ebeb30e8a..f7a6913eef7 100644 --- a/apps/server/src/modules/h5p-editor/entity/h5p-editor-tempfile.entity.ts +++ b/apps/server/src/modules/h5p-editor/entity/h5p-editor-tempfile.entity.ts @@ -1,8 +1,8 @@ +import { IFileStats, ITemporaryFile } from '@lumieducation/h5p-server'; import { Entity, Property } from '@mikro-orm/core'; -import { ITemporaryFile, IFileStats } from '@lumieducation/h5p-server'; import { BaseEntityWithTimestamps } from '@shared/domain'; -export interface ITemporaryFileProperties { +export interface TemporaryFileProperties { filename: string; ownedByUserId: string; expiresAt: Date; @@ -30,7 +30,7 @@ export class H5pEditorTempFile extends BaseEntityWithTimestamps implements ITemp @Property() size: number; - constructor({ filename, ownedByUserId, expiresAt, birthtime, size }: ITemporaryFileProperties) { + constructor({ filename, ownedByUserId, expiresAt, birthtime, size }: TemporaryFileProperties) { super(); this.filename = filename; this.ownedByUserId = ownedByUserId; diff --git a/apps/server/src/shared/testing/factory/h5p-temporary-file.factory.ts b/apps/server/src/shared/testing/factory/h5p-temporary-file.factory.ts index 4c9fbea5b11..4f2205b0490 100644 --- a/apps/server/src/shared/testing/factory/h5p-temporary-file.factory.ts +++ b/apps/server/src/shared/testing/factory/h5p-temporary-file.factory.ts @@ -1,14 +1,14 @@ -import { ITemporaryFileProperties, H5pEditorTempFile } from '@src/modules/h5p-editor/entity'; +import { H5pEditorTempFile, TemporaryFileProperties } from '@src/modules/h5p-editor/entity'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; const oneDay = 24 * 60 * 60 * 1000; -class H5PTemporaryFileFactory extends BaseFactory { +class H5PTemporaryFileFactory extends BaseFactory { isExpired(): this { const birthtime = new Date(Date.now() - oneDay * 2); // Created two days ago const expiresAt = new Date(Date.now() - oneDay); // Expired yesterday - const params: DeepPartial = { expiresAt, birthtime }; + const params: DeepPartial = { expiresAt, birthtime }; return this.params(params); } From acd279f7183496a534abf150bf9bc410c836fdcf Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:31:58 +0100 Subject: [PATCH 030/110] ICommonCartridgeFileBuilder -> CommonCartridgeFileBuilderInterface ICommonCartridgeOrganizationBuilder -> CommonCartridgeOrganizationBuilderInterface ICommonCartridgeFileBuilder -> CommonCartridgeFileBuilderInterface all temp --- .../common-cartridge-file-builder.ts | 24 +++++++++---------- .../common-cartridge-file.interface.ts | 2 +- .../common-cartridge-lti-resource.ts | 4 ++-- .../common-cartridge-resource-item-element.ts | 6 ++--- .../common-cartridge-web-content-resource.ts | 4 ++-- .../common-cartridge-web-link-resource.ts | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts index d8d47dada78..f0a13c98fdd 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts @@ -12,7 +12,7 @@ import { ICommonCartridgeResourceProps, } from './common-cartridge-resource-item-element'; -export type ICommonCartridgeFileBuilderOptions = { +export type CommonCartridgeFileBuilderOptions = { identifier: string; title: string; copyrightOwners: string; @@ -20,19 +20,19 @@ export type ICommonCartridgeFileBuilderOptions = { version: CommonCartridgeVersion; }; -export interface ICommonCartridgeOrganizationBuilder { - addResourceToOrganization(props: ICommonCartridgeResourceProps): ICommonCartridgeOrganizationBuilder; +export interface CommonCartridgeOrganizationBuilderInterface { + addResourceToOrganization(props: ICommonCartridgeResourceProps): CommonCartridgeOrganizationBuilderInterface; } -export interface ICommonCartridgeFileBuilder { - addOrganization(props: ICommonCartridgeOrganizationProps): ICommonCartridgeOrganizationBuilder; +export interface CommonCartridgeFileBuilderInterface { + addOrganization(props: ICommonCartridgeOrganizationProps): CommonCartridgeOrganizationBuilderInterface; - addResourceToFile(props: ICommonCartridgeResourceProps): ICommonCartridgeFileBuilder; + addResourceToFile(props: ICommonCartridgeResourceProps): CommonCartridgeFileBuilderInterface; build(): Promise; } -class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganizationBuilder { +class CommonCartridgeOrganizationBuilder implements CommonCartridgeOrganizationBuilderInterface { constructor( private readonly props: ICommonCartridgeOrganizationProps, private readonly xmlBuilder: Builder, @@ -49,7 +49,7 @@ class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganization ); } - addResourceToOrganization(props: ICommonCartridgeResourceProps): ICommonCartridgeOrganizationBuilder { + addResourceToOrganization(props: ICommonCartridgeResourceProps): CommonCartridgeOrganizationBuilderInterface { const newResource = new CommonCartridgeResourceItemElement(props, this.xmlBuilder); this.props.resources.push(props); if (!newResource.canInline()) { @@ -59,7 +59,7 @@ class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganization } } -export class CommonCartridgeFileBuilder implements ICommonCartridgeFileBuilder { +export class CommonCartridgeFileBuilder implements CommonCartridgeFileBuilderInterface { private readonly xmlBuilder = new Builder(); private readonly zipBuilder = new AdmZip(); @@ -68,15 +68,15 @@ export class CommonCartridgeFileBuilder implements ICommonCartridgeFileBuilder { private readonly resources = new Array(); - constructor(private readonly options: ICommonCartridgeFileBuilderOptions) {} + constructor(private readonly options: CommonCartridgeFileBuilderOptions) {} - addOrganization(props: ICommonCartridgeOrganizationProps): ICommonCartridgeOrganizationBuilder { + addOrganization(props: ICommonCartridgeOrganizationProps): CommonCartridgeOrganizationBuilderInterface { const organizationBuilder = new CommonCartridgeOrganizationBuilder(props, this.xmlBuilder, this.zipBuilder); this.organizations.push(organizationBuilder); return organizationBuilder; } - addResourceToFile(props: ICommonCartridgeResourceProps): ICommonCartridgeFileBuilder { + addResourceToFile(props: ICommonCartridgeResourceProps): CommonCartridgeFileBuilderInterface { const resource = new CommonCartridgeResourceItemElement(props, this.xmlBuilder); if (!resource.canInline()) { this.zipBuilder.addFile(props.href, Buffer.from(resource.content())); diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file.interface.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file.interface.ts index 3d936699c64..0969e712b05 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file.interface.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file.interface.ts @@ -1,4 +1,4 @@ -export interface ICommonCartridgeFile { +export interface CommonCartridgeFile { canInline(): boolean; content(): string; } diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts index b5ed4cffe51..a374b3687a6 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-lti-resource.ts @@ -1,7 +1,7 @@ import { Builder } from 'xml2js'; import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeLtiResourceProps = { type: CommonCartridgeResourceType.LTI; @@ -13,7 +13,7 @@ export type ICommonCartridgeLtiResourceProps = { url: string; }; -export class CommonCartridgeLtiResource implements CommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeLtiResource implements CommonCartridgeElement, CommonCartridgeFile { constructor(private readonly props: ICommonCartridgeLtiResourceProps, private readonly xmlBuilder: Builder) {} canInline(): boolean { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts index 202c9ae04f9..219e7296075 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-resource-item-element.ts @@ -1,7 +1,7 @@ import { Builder } from 'xml2js'; import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceType } from './common-cartridge-enums'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeFile } from './common-cartridge-file.interface'; import { CommonCartridgeLtiResource, ICommonCartridgeLtiResourceProps } from './common-cartridge-lti-resource'; import { CommonCartridgeWebContentResource, @@ -17,8 +17,8 @@ export type ICommonCartridgeResourceProps = | ICommonCartridgeWebContentResourceProps | ICommonCartridgeWebLinkResourceProps; -export class CommonCartridgeResourceItemElement implements CommonCartridgeElement, ICommonCartridgeFile { - private readonly inner: CommonCartridgeElement & ICommonCartridgeFile; +export class CommonCartridgeResourceItemElement implements CommonCartridgeElement, CommonCartridgeFile { + private readonly inner: CommonCartridgeElement & CommonCartridgeFile; constructor(props: ICommonCartridgeResourceProps, xmlBuilder: Builder) { if (props.type === CommonCartridgeResourceType.LTI) { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts index 2e40e368e3b..c45b981184f 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-content-resource.ts @@ -4,7 +4,7 @@ import { CommonCartridgeResourceType, CommonCartridgeVersion, } from './common-cartridge-enums'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeWebContentResourceProps = { type: CommonCartridgeResourceType.WEB_CONTENT; @@ -16,7 +16,7 @@ export type ICommonCartridgeWebContentResourceProps = { intendedUse?: CommonCartridgeIntendedUseType; }; -export class CommonCartridgeWebContentResource implements CommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeWebContentResource implements CommonCartridgeElement, CommonCartridgeFile { constructor(private readonly props: ICommonCartridgeWebContentResourceProps) {} canInline(): boolean { diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts index e52a3db3528..09184d5ef0f 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-web-link-resource.ts @@ -1,7 +1,7 @@ import { Builder } from 'xml2js'; import { CommonCartridgeElement } from './common-cartridge-element.interface'; import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; -import { ICommonCartridgeFile } from './common-cartridge-file.interface'; +import { CommonCartridgeFile } from './common-cartridge-file.interface'; export type ICommonCartridgeWebLinkResourceProps = { type: CommonCartridgeResourceType.WEB_LINK_V1 | CommonCartridgeResourceType.WEB_LINK_V3; @@ -12,7 +12,7 @@ export type ICommonCartridgeWebLinkResourceProps = { url: string; }; -export class CommonCartridgeWebLinkResourceElement implements CommonCartridgeElement, ICommonCartridgeFile { +export class CommonCartridgeWebLinkResourceElement implements CommonCartridgeElement, CommonCartridgeFile { constructor(private readonly props: ICommonCartridgeWebLinkResourceProps, private readonly xmlBuilder: Builder) {} canInline(): boolean { From b56b63ec47eaa1056de84d5d6718244babe3349e Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:33:02 +0100 Subject: [PATCH 031/110] ICommonCartridgeConfig -> CommonCartridgeConfig --- .../learnroom/common-cartridge/common-cartridge.config.ts | 2 +- apps/server/src/modules/server/server.config.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge.config.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge.config.ts index 2041383512b..afbff1098a5 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge.config.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge.config.ts @@ -1,3 +1,3 @@ -export interface ICommonCartridgeConfig { +export interface CommonCartridgeConfig { FEATURE_IMSCC_COURSE_EXPORT_ENABLED: boolean; } diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index 0b3110285ab..f6658564d82 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import type { IdentityManagementConfig } from '@infra/identity-management'; import type { AccountConfig } from '@modules/account'; import type { FilesStorageClientConfig } from '@modules/files-storage-client'; -import type { ICommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; +import type { CommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; import type { IUserConfig } from '@modules/user'; import type { CoreModuleConfig } from '@src/core'; import { MailConfig } from '@src/infra/mail/interfaces/mail-config'; @@ -20,7 +20,7 @@ export interface IServerConfig FilesStorageClientConfig, AccountConfig, IdentityManagementConfig, - ICommonCartridgeConfig, + CommonCartridgeConfig, MailConfig { NODE_ENV: string; SC_DOMAIN: string; From dc069f53d342f22083d75f3d22262f2c771fa927 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:39:12 +0100 Subject: [PATCH 032/110] ExternalToolPseudonymEntityProps --- .../management/uc/database-management.uc.ts | 14 +++++++------- .../entity/external-tool-pseudonym.entity.ts | 6 +++--- .../pseudonym/repo/external-tool-pseudonym.repo.ts | 6 +++--- .../factory/external-tool-pseudonym.factory.ts | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) 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 c238f38dfda..370c4652aeb 100644 --- a/apps/server/src/modules/management/uc/database-management.uc.ts +++ b/apps/server/src/modules/management/uc/database-management.uc.ts @@ -11,7 +11,7 @@ import { orderBy } from 'lodash'; import { BsonConverter } from '../converter/bson.converter'; import { generateSeedData } from '../seed-data/generateSeedData'; -export interface ICollectionFilePath { +export interface CollectionFilePath { filePath: string; collectionName: string; } @@ -75,9 +75,9 @@ export class DatabaseManagementUc { /** * Loads all collection names from database and adds related file paths. - * @returns {ICollectionFilePath} + * @returns {CollectionFilePath} */ - private async loadAllCollectionsFromDatabase(targetFolder: string): Promise { + private async loadAllCollectionsFromDatabase(targetFolder: string): Promise { const collections = await this.databaseManagementService.getCollectionNames(); const collectionsWithFilePaths = collections.map((collectionName) => { return { @@ -90,9 +90,9 @@ export class DatabaseManagementUc { /** * Loads all collection names and file paths from backup files. - * @returns {ICollectionFilePath} + * @returns {CollectionFilePath} */ - private async loadAllCollectionsFromFilesystem(baseDir: string): Promise { + private async loadAllCollectionsFromFilesystem(baseDir: string): Promise { const filenames = await this.fileSystemAdapter.readDir(baseDir); const collectionsWithFilePaths = filenames.map((fileName) => { return { @@ -107,14 +107,14 @@ export class DatabaseManagementUc { * Scans for existing collections and optionally filters them based on * @param source * @param collectionNameFilter - * @returns {ICollectionFilePath} the filtered collection names and related file paths + * @returns {CollectionFilePath} the filtered collection names and related file paths */ private async loadCollectionsAvailableFromSourceAndFilterByCollectionNames( source: 'files' | 'database', folder: string, collectionNameFilter?: string[] ) { - let allCollectionsWithFilePaths: ICollectionFilePath[] = []; + let allCollectionsWithFilePaths: CollectionFilePath[] = []; // load all available collections from source if (source === 'files') { diff --git a/apps/server/src/modules/pseudonym/entity/external-tool-pseudonym.entity.ts b/apps/server/src/modules/pseudonym/entity/external-tool-pseudonym.entity.ts index 3505f0bc7df..9fabd37f91c 100644 --- a/apps/server/src/modules/pseudonym/entity/external-tool-pseudonym.entity.ts +++ b/apps/server/src/modules/pseudonym/entity/external-tool-pseudonym.entity.ts @@ -1,9 +1,9 @@ import { Entity, 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'; +import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; -export interface IExternalToolPseudonymEntityProps { +export interface ExternalToolPseudonymEntityProps { id?: EntityId; pseudonym: string; toolId: ObjectId; @@ -23,7 +23,7 @@ export class ExternalToolPseudonymEntity extends BaseEntityWithTimestamps { @Property() userId: ObjectId; - constructor(props: IExternalToolPseudonymEntityProps) { + constructor(props: ExternalToolPseudonymEntityProps) { super(); if (props.id != null) { this.id = props.id; diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts index 79a17a80541..5c57d0e0ad5 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts @@ -3,7 +3,7 @@ import { Injectable } from '@nestjs/common'; import { EntityId, IFindOptions, IPagination, Page, Pseudonym } from '@shared/domain'; import { Scope } from '@shared/repo'; import { PseudonymSearchQuery } from '../domain'; -import { ExternalToolPseudonymEntity, IExternalToolPseudonymEntityProps } from '../entity'; +import { ExternalToolPseudonymEntity, ExternalToolPseudonymEntityProps } from '../entity'; import { PseudonymScope } from '../entity/pseudonym.scope'; @Injectable() @@ -50,7 +50,7 @@ export class ExternalToolPseudonymRepo { .getUnitOfWork() .getById(ExternalToolPseudonymEntity.name, domainObject.id); - const entityProps: IExternalToolPseudonymEntityProps = this.mapDomainObjectToEntityProperties(domainObject); + const entityProps: ExternalToolPseudonymEntityProps = this.mapDomainObjectToEntityProperties(domainObject); let entity: ExternalToolPseudonymEntity = new ExternalToolPseudonymEntity(entityProps); if (existing) { @@ -101,7 +101,7 @@ export class ExternalToolPseudonymRepo { return pseudonym; } - protected mapDomainObjectToEntityProperties(entityDO: Pseudonym): IExternalToolPseudonymEntityProps { + protected mapDomainObjectToEntityProperties(entityDO: Pseudonym): ExternalToolPseudonymEntityProps { return { pseudonym: entityDO.pseudonym, toolId: new ObjectId(entityDO.toolId), diff --git a/apps/server/src/shared/testing/factory/external-tool-pseudonym.factory.ts b/apps/server/src/shared/testing/factory/external-tool-pseudonym.factory.ts index b3ee2595412..d21bfbcff78 100644 --- a/apps/server/src/shared/testing/factory/external-tool-pseudonym.factory.ts +++ b/apps/server/src/shared/testing/factory/external-tool-pseudonym.factory.ts @@ -1,10 +1,10 @@ -import { BaseFactory } from '@shared/testing/factory/base.factory'; import { ObjectId } from '@mikro-orm/mongodb'; -import { ExternalToolPseudonymEntity, IExternalToolPseudonymEntityProps } from '@modules/pseudonym/entity'; +import { ExternalToolPseudonymEntity, ExternalToolPseudonymEntityProps } from '@modules/pseudonym/entity'; +import { BaseFactory } from '@shared/testing/factory/base.factory'; export const externalToolPseudonymEntityFactory = BaseFactory.define< ExternalToolPseudonymEntity, - IExternalToolPseudonymEntityProps + ExternalToolPseudonymEntityProps >(ExternalToolPseudonymEntity, ({ sequence }) => { return { pseudonym: `pseudonym-${sequence}`, From 86206afbae83ae387daf7e11e38c81e78cda8796 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:41:55 +0100 Subject: [PATCH 033/110] IServerConfig -> ServerConfig --- .../service/keycloak-configuration.service.ts | 8 ++++---- apps/server/src/modules/account/account.module.ts | 12 ++++++------ .../account/services/account-lookup.service.ts | 6 +++--- .../src/modules/account/services/account.service.ts | 4 ++-- .../services/authentication.service.ts | 8 ++++---- apps/server/src/modules/server/server.config.ts | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts index ae7f2631bce..89389a5318d 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-configuration.service.ts @@ -4,11 +4,11 @@ import ClientRepresentation from '@keycloak/keycloak-admin-client/lib/defs/clien import IdentityProviderMapperRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperRepresentation'; import IdentityProviderRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation'; import ProtocolMapperRepresentation from '@keycloak/keycloak-admin-client/lib/defs/protocolMapperRepresentation'; -import { Injectable } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; -import { IServerConfig } from '@modules/server/server.config'; +import { ServerConfig } from '@modules/server/server.config'; import { OidcConfigDto } from '@modules/system/service'; import { SystemOidcService } from '@modules/system/service/system-oidc.service'; +import { Injectable } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; import { OidcIdentityProviderMapper } from '../mapper/identity-provider.mapper'; @@ -26,7 +26,7 @@ const oidcExternalSubMapperName = 'External Sub Mapper'; export class KeycloakConfigurationService { constructor( private readonly kcAdmin: KeycloakAdministrationService, - private readonly configService: ConfigService, + private readonly configService: ConfigService, private readonly oidcIdentityProviderMapper: OidcIdentityProviderMapper, private readonly systemOidcService: SystemOidcService ) {} diff --git a/apps/server/src/modules/account/account.module.ts b/apps/server/src/modules/account/account.module.ts index 2e11af11c6d..9a57ba37a44 100644 --- a/apps/server/src/modules/account/account.module.ts +++ b/apps/server/src/modules/account/account.module.ts @@ -1,19 +1,19 @@ +import { IdentityManagementModule } from '@infra/identity-management'; import { Module } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { PermissionService } from '@shared/domain'; import { SystemRepo, UserRepo } from '@shared/repo'; -import { IdentityManagementModule } from '@infra/identity-management'; import { LoggerModule } from '@src/core/logger/logger.module'; +import { ServerConfig } from '../server/server.config'; +import { AccountIdmToDtoMapper, AccountIdmToDtoMapperDb, AccountIdmToDtoMapperIdm } from './mapper'; import { AccountRepo } from './repo/account.repo'; -import { AccountService } from './services/account.service'; -import { AccountValidationService } from './services/account.validation.service'; import { AccountServiceDb } from './services/account-db.service'; import { AccountServiceIdm } from './services/account-idm.service'; -import { AccountIdmToDtoMapper, AccountIdmToDtoMapperDb, AccountIdmToDtoMapperIdm } from './mapper'; -import { IServerConfig } from '../server/server.config'; import { AccountLookupService } from './services/account-lookup.service'; +import { AccountService } from './services/account.service'; +import { AccountValidationService } from './services/account.validation.service'; -function accountIdmToDtoMapperFactory(configService: ConfigService): AccountIdmToDtoMapper { +function accountIdmToDtoMapperFactory(configService: ConfigService): AccountIdmToDtoMapper { if (configService.get('FEATURE_IDENTITY_MANAGEMENT_LOGIN_ENABLED') === true) { return new AccountIdmToDtoMapperIdm(); } 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 ed67d03232d..41064d077e9 100644 --- a/apps/server/src/modules/account/services/account-lookup.service.ts +++ b/apps/server/src/modules/account/services/account-lookup.service.ts @@ -1,8 +1,8 @@ +import { IdentityManagementService } from '@infra/identity-management'; +import { ServerConfig } from '@modules/server/server.config'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { EntityId } from '@shared/domain'; -import { IdentityManagementService } from '@infra/identity-management'; -import { IServerConfig } from '@modules/server/server.config'; import { ObjectId } from 'bson'; /** @@ -15,7 +15,7 @@ import { ObjectId } from 'bson'; export class AccountLookupService { constructor( private readonly idmService: IdentityManagementService, - private readonly configService: ConfigService + private readonly configService: ConfigService ) {} /** diff --git a/apps/server/src/modules/account/services/account.service.ts b/apps/server/src/modules/account/services/account.service.ts index 6c2070550ab..6e6107954ce 100644 --- a/apps/server/src/modules/account/services/account.service.ts +++ b/apps/server/src/modules/account/services/account.service.ts @@ -5,7 +5,7 @@ import { ValidationError } from '@shared/common'; import { Counted } from '@shared/domain'; import { isEmail, validateOrReject } from 'class-validator'; import { LegacyLogger } from '../../../core/logger'; -import { IServerConfig } from '../../server/server.config'; +import { ServerConfig } from '../../server/server.config'; import { AccountServiceDb } from './account-db.service'; import { AccountServiceIdm } from './account-idm.service'; import { AbstractAccountService } from './account.service.abstract'; @@ -19,7 +19,7 @@ export class AccountService extends AbstractAccountService { constructor( private readonly accountDb: AccountServiceDb, private readonly accountIdm: AccountServiceIdm, - private readonly configService: ConfigService, + private readonly configService: ConfigService, private readonly accountValidationService: AccountValidationService, private readonly logger: LegacyLogger ) { diff --git a/apps/server/src/modules/authentication/services/authentication.service.ts b/apps/server/src/modules/authentication/services/authentication.service.ts index 41aab6153ea..efa8ec35b27 100644 --- a/apps/server/src/modules/authentication/services/authentication.service.ts +++ b/apps/server/src/modules/authentication/services/authentication.service.ts @@ -1,16 +1,16 @@ +import { AccountService } from '@modules/account'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { JwtService } from '@nestjs/jwt'; -import { AccountService } from '@modules/account'; // invalid import import { AccountDto } from '@modules/account/services/dto'; // invalid import, can produce dependency cycles -import type { IServerConfig } from '@modules/server'; +import type { ServerConfig } from '@modules/server'; import { randomUUID } from 'crypto'; import jwt, { JwtPayload } from 'jsonwebtoken'; -import { JwtValidationAdapter } from '../strategy/jwt-validation.adapter'; import { BruteForceError, UnauthorizedLoggableException } from '../errors'; import { CreateJwtPayload } from '../interface/jwt-payload'; +import { JwtValidationAdapter } from '../strategy/jwt-validation.adapter'; import { LoginDto } from '../uc/dto'; @Injectable() @@ -19,7 +19,7 @@ export class AuthenticationService { private readonly jwtService: JwtService, private readonly jwtValidationAdapter: JwtValidationAdapter, private readonly accountService: AccountService, - private readonly configService: ConfigService + private readonly configService: ConfigService ) {} async loadAccount(username: string, systemId?: string): Promise { diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index f6658564d82..a7e429d2fec 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -14,7 +14,7 @@ export enum NodeEnvType { MIGRATION = 'migration', } -export interface IServerConfig +export interface ServerConfig extends CoreModuleConfig, IUserConfig, FilesStorageClientConfig, @@ -26,7 +26,7 @@ export interface IServerConfig SC_DOMAIN: string; } -const config: IServerConfig = { +const config: ServerConfig = { SC_DOMAIN: Configuration.get('SC_DOMAIN') as string, INCOMING_REQUEST_TIMEOUT: Configuration.get('INCOMING_REQUEST_TIMEOUT_API') as number, INCOMING_REQUEST_TIMEOUT_COPY_API: Configuration.get('INCOMING_REQUEST_TIMEOUT_COPY_API') as number, From 6009a7e9ab07280493d0562ceef300a9ed817c1d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:42:59 +0100 Subject: [PATCH 034/110] IShareTokenProperties -> ShareTokenProperties --- .../src/modules/sharing/entity/share-token.entity.ts | 4 ++-- .../src/modules/sharing/repo/share-token.repo.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/modules/sharing/entity/share-token.entity.ts b/apps/server/src/modules/sharing/entity/share-token.entity.ts index fd83e054029..c5e2b41e6d0 100644 --- a/apps/server/src/modules/sharing/entity/share-token.entity.ts +++ b/apps/server/src/modules/sharing/entity/share-token.entity.ts @@ -4,7 +4,7 @@ import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; import { EntityId } from '@shared/domain/types/entity-id'; import { ShareTokenContextType, ShareTokenParentType, ShareTokenString } from '../domainobject/share-token.do'; -export interface IShareTokenProperties { +export interface ShareTokenProperties { token: ShareTokenString; parentType: ShareTokenParentType; parentId: EntityId | ObjectId; @@ -42,7 +42,7 @@ export class ShareToken extends BaseEntityWithTimestamps { @Property({ nullable: true }) expiresAt?: Date; - constructor(props: IShareTokenProperties) { + constructor(props: ShareTokenProperties) { super(); this.token = props.token; this.parentType = props.parentType; diff --git a/apps/server/src/modules/sharing/repo/share-token.repo.ts b/apps/server/src/modules/sharing/repo/share-token.repo.ts index a04808df2de..ea5fee7194f 100644 --- a/apps/server/src/modules/sharing/repo/share-token.repo.ts +++ b/apps/server/src/modules/sharing/repo/share-token.repo.ts @@ -2,15 +2,15 @@ import { EntityName } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { BaseDORepo } from '@shared/repo/base.do.repo'; import { ShareTokenContext, ShareTokenDO, ShareTokenPayload, ShareTokenString } from '../domainobject/share-token.do'; -import { IShareTokenProperties, ShareToken } from '../entity/share-token.entity'; +import { ShareToken, ShareTokenProperties } from '../entity/share-token.entity'; @Injectable() -export class ShareTokenRepo extends BaseDORepo { +export class ShareTokenRepo extends BaseDORepo { get entityName(): EntityName { return ShareToken; } - entityFactory(props: IShareTokenProperties): ShareToken { + entityFactory(props: ShareTokenProperties): ShareToken { return new ShareToken(props); } @@ -43,8 +43,8 @@ export class ShareTokenRepo extends BaseDORepo Date: Mon, 13 Nov 2023 12:46:47 +0100 Subject: [PATCH 035/110] IToolFeatures -> ToolFeaturesInterface --- .../service/oauth-provider.login-flow.service.ts | 10 +++++----- .../service/external-tool-configuration.service.ts | 12 ++++++------ .../service/external-tool-logo.service.ts | 4 ++-- apps/server/src/modules/tool/tool-config.ts | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts index 0b1948baa28..f82072ff847 100644 --- a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts +++ b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts @@ -1,18 +1,18 @@ +import { LtiToolService } from '@modules/lti-tool/service'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; +import { ExternalToolService } from '@modules/tool/external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '@modules/tool/tool-config'; import { Inject } from '@nestjs/common'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; import { LtiToolDO } from '@shared/domain/domainobject/ltitool.do'; -import { LtiToolService } from '@modules/lti-tool/service'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; -import { ExternalToolService } from '@modules/tool/external-tool/service'; -import { IToolFeatures, ToolFeatures } from '@modules/tool/tool-config'; @Injectable() export class OauthProviderLoginFlowService { constructor( private readonly ltiToolService: LtiToolService, private readonly externalToolService: ExternalToolService, - @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures + @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface ) {} public async findToolByClientId(clientId: string): Promise { diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts index 3b5a186d1ba..7f6c7896bbd 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts @@ -1,16 +1,16 @@ import { Inject, Injectable } from '@nestjs/common'; import { EntityId, Page } from '@shared/domain'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; -import { ExternalTool } from '../domain'; -import { SchoolExternalTool } from '../../school-external-tool/domain'; -import { ContextExternalTool } from '../../context-external-tool/domain'; -import { CustomParameterScope } from '../../common/enum'; import { CustomParameter } from '../../common/domain'; +import { CustomParameterScope } from '../../common/enum'; +import { ContextExternalTool } from '../../context-external-tool/domain'; +import { SchoolExternalTool } from '../../school-external-tool/domain'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { ExternalTool } from '../domain'; import { ContextExternalToolTemplateInfo } from '../uc/dto'; @Injectable() export class ExternalToolConfigurationService { - constructor(@Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures) {} + constructor(@Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface) {} public filterForAvailableTools(externalTools: Page, toolIdsInUse: EntityId[]): ExternalTool[] { const visibleTools: ExternalTool[] = externalTools.data.filter((tool: ExternalTool): boolean => !tool.isHidden); diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts index b39684fbd1b..f74e1fe3bae 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts @@ -4,7 +4,7 @@ import { EntityId } from '@shared/domain'; import { Logger } from '@src/core/logger'; import { AxiosResponse } from 'axios'; import { lastValueFrom } from 'rxjs'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogo } from '../domain/external-tool-logo'; import { @@ -25,7 +25,7 @@ const contentTypeDetector: Record = { export class ExternalToolLogoService { constructor( - @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures, + @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface, private readonly logger: Logger, private readonly httpService: HttpService, private readonly externalToolService: ExternalToolService diff --git a/apps/server/src/modules/tool/tool-config.ts b/apps/server/src/modules/tool/tool-config.ts index 2bd47089286..de3e4810c1e 100644 --- a/apps/server/src/modules/tool/tool-config.ts +++ b/apps/server/src/modules/tool/tool-config.ts @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; export const ToolFeatures = Symbol('ToolFeatures'); -export interface IToolFeatures { +export interface ToolFeaturesInterface { ctlToolsTabEnabled: boolean; ltiToolsTabEnabled: boolean; contextConfigurationEnabled: boolean; @@ -11,7 +11,7 @@ export interface IToolFeatures { } export default class ToolConfiguration { - static toolFeatures: IToolFeatures = { + static toolFeatures: ToolFeaturesInterface = { ctlToolsTabEnabled: Configuration.get('FEATURE_CTL_TOOLS_TAB_ENABLED') as boolean, ltiToolsTabEnabled: Configuration.get('FEATURE_LTI_TOOLS_TAB_ENABLED') as boolean, contextConfigurationEnabled: Configuration.get('FEATURE_CTL_CONTEXT_CONFIGURATION_ENABLED') as boolean, From cd501376a1a0bbff05e0c3ef538023e7b4e63108 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:49:44 +0100 Subject: [PATCH 036/110] IContextExternalToolProperties -> ContextExternalToolProperties --- .../entity/context-external-tool.entity.ts | 4 ++-- .../context-external-tool.repo.ts | 14 +++++++------- .../context-external-tool-entity.factory.ts | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/src/modules/tool/context-external-tool/entity/context-external-tool.entity.ts b/apps/server/src/modules/tool/context-external-tool/entity/context-external-tool.entity.ts index aebab1a8d5d..b82475a64ca 100644 --- a/apps/server/src/modules/tool/context-external-tool/entity/context-external-tool.entity.ts +++ b/apps/server/src/modules/tool/context-external-tool/entity/context-external-tool.entity.ts @@ -4,7 +4,7 @@ import { CustomParameterEntryEntity } from '../../common/entity'; import { SchoolExternalToolEntity } from '../../school-external-tool/entity'; import { ContextExternalToolType } from './context-external-tool-type.enum'; -export interface IContextExternalToolProperties { +export interface ContextExternalToolProperties { schoolTool: SchoolExternalToolEntity; contextId: string; @@ -38,7 +38,7 @@ export class ContextExternalToolEntity extends BaseEntityWithTimestamps { @Property() toolVersion: number; - constructor(props: IContextExternalToolProperties) { + constructor(props: ContextExternalToolProperties) { super(); this.schoolTool = props.schoolTool; this.contextId = props.contextId; diff --git a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.ts b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.ts index 5ad1629f0c2..8a31f0870f0 100644 --- a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.ts +++ b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.ts @@ -1,18 +1,18 @@ import { EntityName } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; -import { Injectable } from '@nestjs/common'; -import { BaseDORepo } from '@shared/repo'; -import { LegacyLogger } from '@src/core/logger'; import { ToolContextType } from '@modules/tool/common/enum/tool-context-type.enum'; import { ContextExternalTool, ContextRef } from '@modules/tool/context-external-tool/domain'; import { ContextExternalToolEntity, + ContextExternalToolProperties, ContextExternalToolType, - IContextExternalToolProperties, } from '@modules/tool/context-external-tool/entity'; import { ContextExternalToolQuery } from '@modules/tool/context-external-tool/uc/dto/context-external-tool.types'; import { SchoolExternalToolRefDO } from '@modules/tool/school-external-tool/domain'; import { SchoolExternalToolEntity } from '@modules/tool/school-external-tool/entity'; +import { Injectable } from '@nestjs/common'; +import { BaseDORepo } from '@shared/repo'; +import { LegacyLogger } from '@src/core/logger'; import { EntityId } from '../../domain'; import { ExternalToolRepoMapper } from '../externaltool'; import { ContextExternalToolScope } from './context-external-tool.scope'; @@ -21,7 +21,7 @@ import { ContextExternalToolScope } from './context-external-tool.scope'; export class ContextExternalToolRepo extends BaseDORepo< ContextExternalTool, ContextExternalToolEntity, - IContextExternalToolProperties + ContextExternalToolProperties > { constructor(protected readonly _em: EntityManager, protected readonly logger: LegacyLogger) { super(_em, logger); @@ -31,7 +31,7 @@ export class ContextExternalToolRepo extends BaseDORepo< return ContextExternalToolEntity; } - entityFactory(props: IContextExternalToolProperties): ContextExternalToolEntity { + entityFactory(props: ContextExternalToolProperties): ContextExternalToolEntity { return new ContextExternalToolEntity(props); } @@ -100,7 +100,7 @@ export class ContextExternalToolRepo extends BaseDORepo< }); } - mapDOToEntityProperties(entityDO: ContextExternalTool): IContextExternalToolProperties { + mapDOToEntityProperties(entityDO: ContextExternalTool): ContextExternalToolProperties { return { contextId: entityDO.contextRef.id, contextType: this.mapContextTypeToEntityType(entityDO.contextRef.type), diff --git a/apps/server/src/shared/testing/factory/context-external-tool-entity.factory.ts b/apps/server/src/shared/testing/factory/context-external-tool-entity.factory.ts index fb545c1e2e7..3e7f4e4b1cb 100644 --- a/apps/server/src/shared/testing/factory/context-external-tool-entity.factory.ts +++ b/apps/server/src/shared/testing/factory/context-external-tool-entity.factory.ts @@ -1,16 +1,16 @@ -import { BaseFactory } from '@shared/testing/factory/base.factory'; import { CustomParameterEntryEntity } from '@modules/tool/common/entity'; import { ContextExternalToolEntity, + ContextExternalToolProperties, ContextExternalToolType, - IContextExternalToolProperties, } from '@modules/tool/context-external-tool/entity'; +import { BaseFactory } from '@shared/testing/factory/base.factory'; import { courseFactory } from './course.factory'; import { schoolExternalToolEntityFactory } from './school-external-tool-entity.factory'; export const contextExternalToolEntityFactory = BaseFactory.define< ContextExternalToolEntity, - IContextExternalToolProperties + ContextExternalToolProperties >(ContextExternalToolEntity, () => { return { contextId: courseFactory.buildWithId().id, From c31f625c770c593a41cdb99b08767be4e68af394 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:51:09 +0100 Subject: [PATCH 037/110] ISchoolExternalToolProperties -> SchoolExternalToolProperties --- .../entity/school-external-tool.entity.ts | 4 ++-- .../school-external-tool.repo.ts | 16 ++++++++-------- .../school-external-tool-entity.factory.ts | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/src/modules/tool/school-external-tool/entity/school-external-tool.entity.ts b/apps/server/src/modules/tool/school-external-tool/entity/school-external-tool.entity.ts index fc7f6703d05..b5545239042 100644 --- a/apps/server/src/modules/tool/school-external-tool/entity/school-external-tool.entity.ts +++ b/apps/server/src/modules/tool/school-external-tool/entity/school-external-tool.entity.ts @@ -4,7 +4,7 @@ import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { CustomParameterEntryEntity } from '../../common/entity'; import { ExternalToolEntity } from '../../external-tool/entity'; -export interface ISchoolExternalToolProperties { +export interface SchoolExternalToolProperties { tool: ExternalToolEntity; school: SchoolEntity; schoolParameters?: CustomParameterEntryEntity[]; @@ -25,7 +25,7 @@ export class SchoolExternalToolEntity extends BaseEntityWithTimestamps { @Property() toolVersion: number; - constructor(props: ISchoolExternalToolProperties) { + constructor(props: SchoolExternalToolProperties) { super(); this.tool = props.tool; this.school = props.school; diff --git a/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.ts b/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.ts index 64f55c715e8..50aa257950e 100644 --- a/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.ts +++ b/apps/server/src/shared/repo/schoolexternaltool/school-external-tool.repo.ts @@ -1,21 +1,21 @@ import { EntityName } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; +import { ExternalToolEntity } from '@modules/tool/external-tool/entity'; +import { SchoolExternalTool } from '@modules/tool/school-external-tool/domain'; +import { SchoolExternalToolEntity, SchoolExternalToolProperties } from '@modules/tool/school-external-tool/entity'; +import { SchoolExternalToolQuery } from '@modules/tool/school-external-tool/uc/dto/school-external-tool.types'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { SchoolEntity } from '@shared/domain'; import { BaseDORepo } from '@shared/repo/base.do.repo'; import { LegacyLogger } from '@src/core/logger'; -import { SchoolExternalToolQuery } from '@modules/tool/school-external-tool/uc/dto/school-external-tool.types'; -import { ISchoolExternalToolProperties, SchoolExternalToolEntity } from '@modules/tool/school-external-tool/entity'; -import { SchoolExternalTool } from '@modules/tool/school-external-tool/domain'; -import { ExternalToolEntity } from '@modules/tool/external-tool/entity'; -import { SchoolExternalToolScope } from './school-external-tool.scope'; import { ExternalToolRepoMapper } from '../externaltool'; +import { SchoolExternalToolScope } from './school-external-tool.scope'; @Injectable() export class SchoolExternalToolRepo extends BaseDORepo< SchoolExternalTool, SchoolExternalToolEntity, - ISchoolExternalToolProperties + SchoolExternalToolProperties > { constructor(protected readonly _em: EntityManager, protected readonly logger: LegacyLogger) { super(_em, logger); @@ -25,7 +25,7 @@ export class SchoolExternalToolRepo extends BaseDORepo< return SchoolExternalToolEntity; } - entityFactory(props: ISchoolExternalToolProperties): SchoolExternalToolEntity { + entityFactory(props: SchoolExternalToolProperties): SchoolExternalToolEntity { return new SchoolExternalToolEntity(props); } @@ -81,7 +81,7 @@ export class SchoolExternalToolRepo extends BaseDORepo< }); } - mapDOToEntityProperties(entityDO: SchoolExternalTool): ISchoolExternalToolProperties { + mapDOToEntityProperties(entityDO: SchoolExternalTool): SchoolExternalToolProperties { return { school: this._em.getReference(SchoolEntity, entityDO.schoolId), tool: this._em.getReference(ExternalToolEntity, entityDO.toolId), diff --git a/apps/server/src/shared/testing/factory/school-external-tool-entity.factory.ts b/apps/server/src/shared/testing/factory/school-external-tool-entity.factory.ts index 456356e6e23..023e3a2626d 100644 --- a/apps/server/src/shared/testing/factory/school-external-tool-entity.factory.ts +++ b/apps/server/src/shared/testing/factory/school-external-tool-entity.factory.ts @@ -1,11 +1,11 @@ +import { SchoolExternalToolEntity, SchoolExternalToolProperties } from '@modules/tool/school-external-tool/entity'; import { BaseFactory } from '@shared/testing/factory/base.factory'; -import { ISchoolExternalToolProperties, SchoolExternalToolEntity } from '@modules/tool/school-external-tool/entity'; import { externalToolEntityFactory } from './external-tool-entity.factory'; import { schoolFactory } from './school.factory'; export const schoolExternalToolEntityFactory = BaseFactory.define< SchoolExternalToolEntity, - ISchoolExternalToolProperties + SchoolExternalToolProperties >(SchoolExternalToolEntity, () => { return { tool: externalToolEntityFactory.buildWithId(), From 02a6036c78a686df4dfa83516dcd9bb355de7627 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:53:07 +0100 Subject: [PATCH 038/110] IToolLaunchParams -> ToolLaunchParams --- .../service/launch-strategy/abstract-launch.strategy.ts | 8 ++++---- .../service/launch-strategy/basic-tool-launch.strategy.ts | 4 ++-- .../service/launch-strategy/lti11-tool-launch.strategy.ts | 4 ++-- .../launch-strategy/oauth2-tool-launch.strategy.ts | 4 ++-- .../launch-strategy/tool-launch-params.interface.ts | 2 +- .../launch-strategy/tool-launch-strategy.interface.ts | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts index ce0f07c5731..f3cf46db3ad 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts @@ -16,7 +16,7 @@ import { AutoSchoolIdStrategy, AutoSchoolNumberStrategy, } from '../auto-parameter-strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; import { IToolLaunchStrategy } from './tool-launch-strategy.interface'; @Injectable() @@ -37,7 +37,7 @@ export abstract class AbstractLaunchStrategy implements IToolLaunchStrategy { ]); } - public async createLaunchData(userId: EntityId, data: IToolLaunchParams): Promise { + public async createLaunchData(userId: EntityId, data: ToolLaunchParams): Promise { const launchData: ToolLaunchData = this.buildToolLaunchDataFromExternalTool(data.externalTool); const launchDataProperties: PropertyData[] = await this.buildToolLaunchDataFromTools(data); @@ -54,7 +54,7 @@ export abstract class AbstractLaunchStrategy implements IToolLaunchStrategy { public abstract buildToolLaunchDataFromConcreteConfig( userId: EntityId, - config: IToolLaunchParams + config: ToolLaunchParams ): Promise; public abstract buildToolLaunchRequestPayload(url: string, properties: PropertyData[]): string | null; @@ -136,7 +136,7 @@ export abstract class AbstractLaunchStrategy implements IToolLaunchStrategy { return launchData; } - private async buildToolLaunchDataFromTools(data: IToolLaunchParams): Promise { + private async buildToolLaunchDataFromTools(data: ToolLaunchParams): Promise { const propertyData: PropertyData[] = []; const { externalTool, schoolExternalTool, contextExternalTool } = data; const customParameters = externalTool.parameters || []; diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.ts index abe5810820d..399b428a710 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; import { LaunchRequestMethod, PropertyData, PropertyLocation } from '../../types'; import { AbstractLaunchStrategy } from './abstract-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; @Injectable() export class BasicToolLaunchStrategy extends AbstractLaunchStrategy { @@ -10,7 +10,7 @@ export class BasicToolLaunchStrategy extends AbstractLaunchStrategy { // eslint-disable-next-line @typescript-eslint/no-unused-vars userId: EntityId, // eslint-disable-next-line @typescript-eslint/no-unused-vars - data: IToolLaunchParams + data: ToolLaunchParams ): Promise { return Promise.resolve([]); } diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.ts index 09516395234..fca44aaf90b 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.ts @@ -16,7 +16,7 @@ import { } from '../auto-parameter-strategy'; import { Lti11EncryptionService } from '../lti11-encryption.service'; import { AbstractLaunchStrategy } from './abstract-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; @Injectable() export class Lti11ToolLaunchStrategy extends AbstractLaunchStrategy { @@ -35,7 +35,7 @@ export class Lti11ToolLaunchStrategy extends AbstractLaunchStrategy { // eslint-disable-next-line @typescript-eslint/no-unused-vars public override async buildToolLaunchDataFromConcreteConfig( userId: EntityId, - data: IToolLaunchParams + data: ToolLaunchParams ): Promise { const { config } = data.externalTool; const contextId: EntityId = data.contextExternalTool.contextRef.id; diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.ts index 5052310a77d..833b0742a7b 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { EntityId } from '@shared/domain'; import { LaunchRequestMethod, PropertyData } from '../../types'; import { AbstractLaunchStrategy } from './abstract-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; @Injectable() export class OAuth2ToolLaunchStrategy extends AbstractLaunchStrategy { @@ -10,7 +10,7 @@ export class OAuth2ToolLaunchStrategy extends AbstractLaunchStrategy { // eslint-disable-next-line @typescript-eslint/no-unused-vars userId: EntityId, // eslint-disable-next-line @typescript-eslint/no-unused-vars - data: IToolLaunchParams + data: ToolLaunchParams ): Promise { return Promise.resolve([]); } diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-params.interface.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-params.interface.ts index 24e368476f5..73fdf1d78b7 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-params.interface.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-params.interface.ts @@ -2,7 +2,7 @@ import { ContextExternalTool } from '../../../context-external-tool/domain'; import { ExternalTool } from '../../../external-tool/domain'; import { SchoolExternalTool } from '../../../school-external-tool/domain'; -export interface IToolLaunchParams { +export interface ToolLaunchParams { externalTool: ExternalTool; schoolExternalTool: SchoolExternalTool; diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts index 09ea919b0c7..2f330056ef6 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts @@ -1,9 +1,9 @@ import { EntityId } from '@shared/domain'; import { ToolLaunchData, ToolLaunchRequest } from '../../types'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; export interface IToolLaunchStrategy { - createLaunchData(userId: EntityId, params: IToolLaunchParams): Promise; + createLaunchData(userId: EntityId, params: ToolLaunchParams): Promise; createLaunchRequest(toolLaunchDataDO: ToolLaunchData): ToolLaunchRequest; } From c6ef423d9261d390be542de29a20245c8cc354e4 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:57:03 +0100 Subject: [PATCH 039/110] IToolLaunchStrategy -> ToolLaunchStrategy --- .../service/launch-strategy/abstract-launch.strategy.ts | 4 ++-- .../launch-strategy/tool-launch-strategy.interface.ts | 2 +- .../tool/tool-launch/service/tool-launch.service.ts | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts index f3cf46db3ad..d5e920bacf4 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.ts @@ -17,10 +17,10 @@ import { AutoSchoolNumberStrategy, } from '../auto-parameter-strategy'; import { ToolLaunchParams } from './tool-launch-params.interface'; -import { IToolLaunchStrategy } from './tool-launch-strategy.interface'; +import { ToolLaunchStrategy } from './tool-launch-strategy.interface'; @Injectable() -export abstract class AbstractLaunchStrategy implements IToolLaunchStrategy { +export abstract class AbstractLaunchStrategy implements ToolLaunchStrategy { private readonly autoParameterStrategyMap: Map; constructor( diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts index 2f330056ef6..a0ba86c5648 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/tool-launch-strategy.interface.ts @@ -2,7 +2,7 @@ import { EntityId } from '@shared/domain'; import { ToolLaunchData, ToolLaunchRequest } from '../../types'; import { ToolLaunchParams } from './tool-launch-params.interface'; -export interface IToolLaunchStrategy { +export interface ToolLaunchStrategy { createLaunchData(userId: EntityId, params: ToolLaunchParams): Promise; createLaunchRequest(toolLaunchDataDO: ToolLaunchData): ToolLaunchRequest; diff --git a/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.ts b/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.ts index abb5598796f..f87d23311f8 100644 --- a/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.ts +++ b/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.ts @@ -12,14 +12,14 @@ import { ToolLaunchMapper } from '../mapper'; import { ToolLaunchData, ToolLaunchRequest } from '../types'; import { BasicToolLaunchStrategy, - IToolLaunchStrategy, Lti11ToolLaunchStrategy, OAuth2ToolLaunchStrategy, + ToolLaunchStrategy, } from './launch-strategy'; @Injectable() export class ToolLaunchService { - private strategies: Map; + private strategies: Map; constructor( private readonly schoolExternalToolService: SchoolExternalToolService, @@ -37,7 +37,7 @@ export class ToolLaunchService { generateLaunchRequest(toolLaunchData: ToolLaunchData): ToolLaunchRequest { const toolConfigType: ToolConfigType = ToolLaunchMapper.mapToToolConfigType(toolLaunchData.type); - const strategy: IToolLaunchStrategy | undefined = this.strategies.get(toolConfigType); + const strategy: ToolLaunchStrategy | undefined = this.strategies.get(toolConfigType); if (!strategy) { throw new InternalServerErrorException('Unknown tool launch data type'); @@ -55,7 +55,7 @@ export class ToolLaunchService { this.isToolStatusLatestOrThrow(userId, externalTool, schoolExternalTool, contextExternalTool); - const strategy: IToolLaunchStrategy | undefined = this.strategies.get(externalTool.config.type); + const strategy: ToolLaunchStrategy | undefined = this.strategies.get(externalTool.config.type); if (!strategy) { throw new InternalServerErrorException('Unknown tool config type'); From 969aec97548e8c0ce999c2d214d6f2ed6fed0fbb Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 12:59:05 +0100 Subject: [PATCH 040/110] IUserConfig -> UserConfig --- apps/server/src/modules/server/server.config.ts | 4 ++-- apps/server/src/modules/user/interfaces/user-config.ts | 2 +- apps/server/src/modules/user/service/user.service.ts | 6 +++--- apps/server/src/modules/user/uc/user.uc.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/server/server.config.ts b/apps/server/src/modules/server/server.config.ts index a7e429d2fec..c119d0fa25a 100644 --- a/apps/server/src/modules/server/server.config.ts +++ b/apps/server/src/modules/server/server.config.ts @@ -3,7 +3,7 @@ import type { IdentityManagementConfig } from '@infra/identity-management'; import type { AccountConfig } from '@modules/account'; import type { FilesStorageClientConfig } from '@modules/files-storage-client'; import type { CommonCartridgeConfig } from '@modules/learnroom/common-cartridge'; -import type { IUserConfig } from '@modules/user'; +import type { UserConfig } from '@modules/user'; import type { CoreModuleConfig } from '@src/core'; import { MailConfig } from '@src/infra/mail/interfaces/mail-config'; @@ -16,7 +16,7 @@ export enum NodeEnvType { export interface ServerConfig extends CoreModuleConfig, - IUserConfig, + UserConfig, FilesStorageClientConfig, AccountConfig, IdentityManagementConfig, diff --git a/apps/server/src/modules/user/interfaces/user-config.ts b/apps/server/src/modules/user/interfaces/user-config.ts index cd8576522e1..95935d4866c 100644 --- a/apps/server/src/modules/user/interfaces/user-config.ts +++ b/apps/server/src/modules/user/interfaces/user-config.ts @@ -1,3 +1,3 @@ -export interface IUserConfig { +export interface UserConfig { AVAILABLE_LANGUAGES: string[]; } diff --git a/apps/server/src/modules/user/service/user.service.ts b/apps/server/src/modules/user/service/user.service.ts index 2cc95991f96..6ef014f8696 100644 --- a/apps/server/src/modules/user/service/user.service.ts +++ b/apps/server/src/modules/user/service/user.service.ts @@ -1,6 +1,7 @@ import { AccountService } from '@modules/account'; import { AccountDto } from '@modules/account/services/dto'; // invalid import +import { OauthCurrentUser } from '@modules/authentication/interface'; import { CurrentUserMapper } from '@modules/authentication/mapper'; import { RoleDto } from '@modules/role/service/dto/role.dto'; import { RoleService } from '@modules/role/service/role.service'; @@ -10,8 +11,7 @@ import { EntityId, IFindOptions, LanguageType, User } from '@shared/domain'; import { Page, RoleReference, UserDO } from '@shared/domain/domainobject'; import { UserRepo } from '@shared/repo'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; -import { OauthCurrentUser } from '@modules/authentication/interface'; -import { IUserConfig } from '../interfaces'; +import { UserConfig } from '../interfaces'; import { UserMapper } from '../mapper/user.mapper'; import { UserDto } from '../uc/dto/user.dto'; import { UserQuery } from './user-query.type'; @@ -21,7 +21,7 @@ export class UserService { constructor( private readonly userRepo: UserRepo, private readonly userDORepo: UserDORepo, - private readonly configService: ConfigService, + private readonly configService: ConfigService, private readonly roleService: RoleService, private readonly accountService: AccountService ) {} diff --git a/apps/server/src/modules/user/uc/user.uc.ts b/apps/server/src/modules/user/uc/user.uc.ts index 0996fa6bd9c..2f2661eb0a2 100644 --- a/apps/server/src/modules/user/uc/user.uc.ts +++ b/apps/server/src/modules/user/uc/user.uc.ts @@ -3,11 +3,11 @@ import { ConfigService } from '@nestjs/config'; import { EntityId, LanguageType, User } from '@shared/domain'; import { UserRepo } from '@shared/repo'; import { ChangeLanguageParams } from '../controller/dto'; -import { IUserConfig } from '../interfaces'; +import { UserConfig } from '../interfaces'; @Injectable() export class UserUc { - constructor(private readonly userRepo: UserRepo, private readonly configService: ConfigService) {} + constructor(private readonly userRepo: UserRepo, private readonly configService: ConfigService) {} async me(userId: EntityId): Promise<[User, string[]]> { const user = await this.userRepo.findById(userId, true); From bb67f5e8ab8740a5794557bb39db3c2839ec6202 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 13:16:21 +0100 Subject: [PATCH 041/110] IBbbSettings -> BbbSettingsInterface --- .../video-conference/bbb/bbb-settings.interface.ts | 2 +- .../src/modules/video-conference/bbb/bbb.service.ts | 6 +++--- .../interface/video-conference-settings.interface.ts | 4 ++-- .../modules/video-conference/video-conference-config.ts | 4 ++-- config/README.md | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts b/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts index c250bebb929..97f7c9319ca 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts @@ -1,6 +1,6 @@ export const BbbSettings = Symbol('BbbSettings'); -export interface IBbbSettings { +export interface BbbSettingsInterface { host: string; salt: string; presentationUrl: string; diff --git a/apps/server/src/modules/video-conference/bbb/bbb.service.ts b/apps/server/src/modules/video-conference/bbb/bbb.service.ts index 54b9ef4549b..e6c645b9f38 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb.service.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb.service.ts @@ -4,16 +4,16 @@ import { ConverterUtil } from '@shared/common/utils'; import { ErrorUtils } from '@src/core/error/utils'; import { AxiosResponse } from 'axios'; import crypto from 'crypto'; -import { Observable, firstValueFrom } from 'rxjs'; +import { firstValueFrom, Observable } from 'rxjs'; import { URL, URLSearchParams } from 'url'; -import { BbbSettings, IBbbSettings } from './bbb-settings.interface'; +import { BbbSettings, BbbSettingsInterface } from './bbb-settings.interface'; import { BBBBaseMeetingConfig, BBBCreateConfig, BBBJoinConfig } from './request'; import { BBBBaseResponse, BBBCreateResponse, BBBMeetingInfoResponse, BBBResponse, BBBStatus } from './response'; @Injectable() export class BBBService { constructor( - @Inject(BbbSettings) private readonly bbbSettings: IBbbSettings, + @Inject(BbbSettings) private readonly bbbSettings: BbbSettingsInterface, private readonly httpService: HttpService, private readonly converterUtil: ConverterUtil ) {} diff --git a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts index a1d07fb516a..08f788451e2 100644 --- a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts +++ b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts @@ -1,9 +1,9 @@ -import { IBbbSettings } from '../bbb'; +import { BbbSettingsInterface } from '../bbb'; export const VideoConferenceSettings = Symbol('VideoConferenceSettings'); export interface IVideoConferenceSettings { enabled: boolean; hostUrl: string; - bbb: IBbbSettings; + bbb: BbbSettingsInterface; } diff --git a/apps/server/src/modules/video-conference/video-conference-config.ts b/apps/server/src/modules/video-conference/video-conference-config.ts index 7e65d0e7155..3b045b9b852 100644 --- a/apps/server/src/modules/video-conference/video-conference-config.ts +++ b/apps/server/src/modules/video-conference/video-conference-config.ts @@ -1,9 +1,9 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { IBbbSettings } from './bbb'; +import { BbbSettingsInterface } from './bbb'; import { IVideoConferenceSettings } from './interface'; export default class VideoConferenceConfiguration { - static bbb: IBbbSettings = { + static bbb: BbbSettingsInterface = { host: Configuration.get('VIDEOCONFERENCE_HOST') as string, salt: Configuration.get('VIDEOCONFERENCE_SALT') as string, presentationUrl: Configuration.get('VIDEOCONFERENCE_DEFAULT_PRESENTATION') as string, diff --git a/config/README.md b/config/README.md index cbdf77a73a9..f55c442d036 100644 --- a/config/README.md +++ b/config/README.md @@ -149,12 +149,12 @@ This code shows a minimal flow. ``` javascript // needed configuration for a module - export interface IUserConfig { + export interface UserConfig { AVAILABLE_LANGUAGES: string[]; } // server.config.ts - export interface IServerConfig extends ICoreModuleConfig, IUserConfig, IFilesStorageClientConfig { + export interface IServerConfig extends ICoreModuleConfig, UserConfig, IFilesStorageClientConfig { NODE_ENV: string; } @@ -176,9 +176,9 @@ This code shows a minimal flow. //use via injections import { ConfigService } from '@nestjs/config'; - import { IUserConfig } from '../interfaces'; + import { UserConfig } from '../interfaces'; - constructor(private readonly configService: ConfigService){} + constructor(private readonly configService: ConfigService){} this.configService.get('AVAILABLE_LANGUAGES'); From d42576bdedb2e7f54ae3601f05518542b67c643a Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 13:21:02 +0100 Subject: [PATCH 042/110] IVideoConferenceSettings -> VideoConferenceSettingsInterface --- .../video-conference-settings.interface.ts | 2 +- .../service/video-conference.service.ts | 14 +++++++------- .../video-conference/video-conference-config.ts | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts index 08f788451e2..64c687d6709 100644 --- a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts +++ b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts @@ -2,7 +2,7 @@ import { BbbSettingsInterface } from '../bbb'; export const VideoConferenceSettings = Symbol('VideoConferenceSettings'); -export interface IVideoConferenceSettings { +export interface VideoConferenceSettingsInterface { enabled: boolean; hostUrl: string; bbb: BbbSettingsInterface; 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 401cc0a0015..0c0e3f64752 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 @@ -1,3 +1,8 @@ +import { CalendarEventDto, CalendarService } from '@infra/calendar'; +import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; +import { CourseService } from '@modules/learnroom'; +import { LegacySchoolService } from '@modules/legacy-school'; +import { UserService } from '@modules/user'; import { BadRequestException, ForbiddenException, Inject, Injectable } from '@nestjs/common'; import { Course, @@ -14,21 +19,16 @@ import { VideoConferenceOptionsDO, VideoConferenceScope, } from '@shared/domain'; -import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; -import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; -import { CourseService } from '@modules/learnroom'; -import { LegacySchoolService } from '@modules/legacy-school'; -import { UserService } from '@modules/user'; import { BBBRole } from '../bbb'; import { ErrorStatus } from '../error'; -import { IVideoConferenceSettings, VideoConferenceOptions, VideoConferenceSettings } from '../interface'; +import { VideoConferenceOptions, VideoConferenceSettings, VideoConferenceSettingsInterface } from '../interface'; import { IScopeInfo, VideoConferenceState } from '../uc/dto'; @Injectable() export class VideoConferenceService { constructor( - @Inject(VideoConferenceSettings) private readonly vcSettings: IVideoConferenceSettings, + @Inject(VideoConferenceSettings) private readonly vcSettings: VideoConferenceSettingsInterface, private readonly courseService: CourseService, private readonly calendarService: CalendarService, private readonly authorizationService: AuthorizationService, diff --git a/apps/server/src/modules/video-conference/video-conference-config.ts b/apps/server/src/modules/video-conference/video-conference-config.ts index 3b045b9b852..9154a7884e7 100644 --- a/apps/server/src/modules/video-conference/video-conference-config.ts +++ b/apps/server/src/modules/video-conference/video-conference-config.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { BbbSettingsInterface } from './bbb'; -import { IVideoConferenceSettings } from './interface'; +import { VideoConferenceSettingsInterface } from './interface'; export default class VideoConferenceConfiguration { static bbb: BbbSettingsInterface = { @@ -9,7 +9,7 @@ export default class VideoConferenceConfiguration { presentationUrl: Configuration.get('VIDEOCONFERENCE_DEFAULT_PRESENTATION') as string, }; - static videoConference: IVideoConferenceSettings = { + static videoConference: VideoConferenceSettingsInterface = { enabled: Configuration.get('FEATURE_VIDEOCONFERENCE_ENABLED') as boolean, hostUrl: Configuration.get('HOST') as string, bbb: VideoConferenceConfiguration.bbb, From 6ae052affad44bdc5088502848c1a0cf8d5a65e1 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 13:23:09 +0100 Subject: [PATCH 043/110] IScopeInfo -> ScopeInfo --- .../service/video-conference.service.ts | 6 +++--- .../video-conference/uc/dto/scope-info.interface.ts | 2 +- .../uc/video-conference-create.uc.ts | 8 ++++---- .../uc/video-conference-deprecated.uc.ts | 12 ++++++------ .../video-conference/uc/video-conference-end.uc.ts | 10 +++++----- .../video-conference/uc/video-conference-info.uc.ts | 12 ++++++------ 6 files changed, 25 insertions(+), 25 deletions(-) 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 0c0e3f64752..d0d003c0347 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 @@ -23,7 +23,7 @@ import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; import { BBBRole } from '../bbb'; import { ErrorStatus } from '../error'; import { VideoConferenceOptions, VideoConferenceSettings, VideoConferenceSettingsInterface } from '../interface'; -import { IScopeInfo, VideoConferenceState } from '../uc/dto'; +import { ScopeInfo, VideoConferenceState } from '../uc/dto'; @Injectable() export class VideoConferenceService { @@ -165,7 +165,7 @@ export class VideoConferenceService { return text.replace(/[^\dA-Za-zÀ-ÖØ-öø-ÿ.\-=_`´ ]/g, ''); } - async getScopeInfo(userId: EntityId, scopeId: string, scope: VideoConferenceScope): Promise { + async getScopeInfo(userId: EntityId, scopeId: string, scope: VideoConferenceScope): Promise { switch (scope) { case VideoConferenceScope.COURSE: { const course: Course = await this.courseService.findById(scopeId); @@ -197,7 +197,7 @@ export class VideoConferenceService { scopeId: EntityId, scope: VideoConferenceScope ): Promise<{ role: BBBRole; isGuest: boolean }> { - const scopeInfo: IScopeInfo = await this.getScopeInfo(userId, scopeId, scope); + const scopeInfo: ScopeInfo = await this.getScopeInfo(userId, scopeId, scope); const role: BBBRole = await this.determineBbbRole(userId, scopeInfo.scopeId, scope); diff --git a/apps/server/src/modules/video-conference/uc/dto/scope-info.interface.ts b/apps/server/src/modules/video-conference/uc/dto/scope-info.interface.ts index 1f304e3a235..2469f49ad29 100644 --- a/apps/server/src/modules/video-conference/uc/dto/scope-info.interface.ts +++ b/apps/server/src/modules/video-conference/uc/dto/scope-info.interface.ts @@ -1,6 +1,6 @@ import { EntityId } from '@shared/domain'; -export interface IScopeInfo { +export interface ScopeInfo { scopeId: EntityId; scopeName: string; diff --git a/apps/server/src/modules/video-conference/uc/video-conference-create.uc.ts b/apps/server/src/modules/video-conference/uc/video-conference-create.uc.ts index 940113276a2..d9ba4e0d61c 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-create.uc.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-create.uc.ts @@ -1,6 +1,6 @@ +import { UserService } from '@modules/user'; import { ForbiddenException, Injectable } from '@nestjs/common'; import { EntityId, UserDO } from '@shared/domain'; -import { UserService } from '@modules/user'; import { BBBBaseMeetingConfig, BBBCreateConfigBuilder, @@ -13,7 +13,7 @@ import { import { ErrorStatus } from '../error/error-status.enum'; import { VideoConferenceOptions } from '../interface'; import { VideoConferenceService } from '../service'; -import { IScopeInfo, ScopeRef } from './dto'; +import { ScopeInfo, ScopeRef } from './dto'; @Injectable() export class VideoConferenceCreateUc { @@ -48,7 +48,7 @@ export class VideoConferenceCreateUc { await this.verifyFeaturesEnabled(user.schoolId); - const scopeInfo: IScopeInfo = await this.videoConferenceService.getScopeInfo(currentUserId, scope.id, scope.scope); + const scopeInfo: ScopeInfo = await this.videoConferenceService.getScopeInfo(currentUserId, scope.id, scope.scope); const bbbRole: BBBRole = await this.videoConferenceService.determineBbbRole( currentUserId, @@ -67,7 +67,7 @@ export class VideoConferenceCreateUc { private prepareBBBCreateConfigBuilder( scope: ScopeRef, options: VideoConferenceOptions, - scopeInfo: IScopeInfo + scopeInfo: ScopeInfo ): BBBCreateConfigBuilder { const configBuilder: BBBCreateConfigBuilder = new BBBCreateConfigBuilder({ name: this.videoConferenceService.sanitizeString(scopeInfo.title), 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 91efc0a1378..e0de32b730f 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 @@ -37,7 +37,7 @@ import { } from '../bbb'; import { ErrorStatus } from '../error/error-status.enum'; import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; -import { IScopeInfo, VideoConference, VideoConferenceInfo, VideoConferenceJoin, VideoConferenceState } from './dto'; +import { ScopeInfo, VideoConference, VideoConferenceInfo, VideoConferenceJoin, VideoConferenceState } from './dto'; const PermissionMapping = { [BBBRole.MODERATOR]: Permission.START_MEETING, @@ -86,7 +86,7 @@ export class VideoConferenceDeprecatedUc { const { userId, schoolId } = currentUser; await this.throwOnFeaturesDisabled(schoolId); - const scopeInfo: IScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); + const scopeInfo: ScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); const bbbRole: BBBRole = await this.checkPermission(userId, conferenceScope, scopeInfo.scopeId); @@ -150,7 +150,7 @@ export class VideoConferenceDeprecatedUc { await this.throwOnFeaturesDisabled(schoolId); - const scopeInfo: IScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); + const scopeInfo: ScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); const bbbRole: BBBRole = await this.checkPermission(userId, conferenceScope, scopeInfo.scopeId); @@ -205,7 +205,7 @@ export class VideoConferenceDeprecatedUc { await this.throwOnFeaturesDisabled(schoolId); - const scopeInfo: IScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); + const scopeInfo: ScopeInfo = await this.getScopeInfo(userId, conferenceScope, refId); const bbbRole: BBBRole = await this.checkPermission(userId, conferenceScope, scopeInfo.scopeId); @@ -337,13 +337,13 @@ export class VideoConferenceDeprecatedUc { * @param {EntityId} userId * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. - * @returns {Promise} + * @returns {Promise} */ protected async getScopeInfo( userId: EntityId, conferenceScope: VideoConferenceScope, refId: string - ): Promise { + ): Promise { switch (conferenceScope) { case VideoConferenceScope.COURSE: { const course: Course = await this.courseService.findById(refId); diff --git a/apps/server/src/modules/video-conference/uc/video-conference-end.uc.ts b/apps/server/src/modules/video-conference/uc/video-conference-end.uc.ts index 6cb70edc176..a1648a4cba1 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-end.uc.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-end.uc.ts @@ -1,11 +1,11 @@ +import { UserService } from '@modules/user'; +import { ErrorStatus } from '@modules/video-conference/error/error-status.enum'; import { ForbiddenException, Injectable } from '@nestjs/common'; import { EntityId, UserDO } from '@shared/domain'; -import { ErrorStatus } from '@modules/video-conference/error/error-status.enum'; -import { UserService } from '@modules/user'; import { BBBBaseMeetingConfig, BBBBaseResponse, BBBResponse, BBBRole, BBBService } from '../bbb'; -import { IScopeInfo, ScopeRef, VideoConference, VideoConferenceState } from './dto'; -import { VideoConferenceService } from '../service'; import { PermissionMapping } from '../mapper/video-conference.mapper'; +import { VideoConferenceService } from '../service'; +import { ScopeInfo, ScopeRef, VideoConference, VideoConferenceState } from './dto'; @Injectable() export class VideoConferenceEndUc { @@ -27,7 +27,7 @@ export class VideoConferenceEndUc { await this.videoConferenceService.throwOnFeaturesDisabled(user.schoolId); - const scopeInfo: IScopeInfo = await this.videoConferenceService.getScopeInfo(userId, scope.id, scope.scope); + const scopeInfo: ScopeInfo = await this.videoConferenceService.getScopeInfo(userId, scope.id, scope.scope); const bbbRole: BBBRole = await this.videoConferenceService.determineBbbRole(userId, scopeInfo.scopeId, scope.scope); diff --git a/apps/server/src/modules/video-conference/uc/video-conference-info.uc.ts b/apps/server/src/modules/video-conference/uc/video-conference-info.uc.ts index 1c3736d1d01..7e39db7bb7b 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-info.uc.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-info.uc.ts @@ -1,12 +1,12 @@ +import { UserService } from '@modules/user'; +import { ErrorStatus } from '@modules/video-conference/error/error-status.enum'; import { ForbiddenException, Injectable } from '@nestjs/common'; import { EntityId, UserDO, VideoConferenceDO, VideoConferenceOptionsDO } from '@shared/domain'; -import { ErrorStatus } from '@modules/video-conference/error/error-status.enum'; -import { UserService } from '@modules/user'; import { BBBBaseMeetingConfig, BBBMeetingInfoResponse, BBBResponse, BBBRole, BBBService } from '../bbb'; -import { IScopeInfo, ScopeRef, VideoConferenceInfo, VideoConferenceState } from './dto'; -import { VideoConferenceService } from '../service'; -import { PermissionMapping } from '../mapper/video-conference.mapper'; import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; +import { PermissionMapping } from '../mapper/video-conference.mapper'; +import { VideoConferenceService } from '../service'; +import { ScopeInfo, ScopeRef, VideoConferenceInfo, VideoConferenceState } from './dto'; @Injectable() export class VideoConferenceInfoUc { @@ -27,7 +27,7 @@ export class VideoConferenceInfoUc { await this.videoConferenceService.throwOnFeaturesDisabled(user.schoolId); - const scopeInfo: IScopeInfo = await this.videoConferenceService.getScopeInfo(currentUserId, scope.id, scope.scope); + const scopeInfo: ScopeInfo = await this.videoConferenceService.getScopeInfo(currentUserId, scope.id, scope.scope); const bbbRole: BBBRole = await this.videoConferenceService.determineBbbRole( currentUserId, From 76df21bb24c0bab407f6f6269a2ab78a72a9c184 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Mon, 13 Nov 2023 13:24:33 +0100 Subject: [PATCH 044/110] ICourseProperties -> CourseProperties --- .../src/shared/domain/entity/course.entity.ts | 8 ++++---- .../src/shared/testing/factory/course.factory.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 81fdcb741d9..79af9774248 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -1,8 +1,8 @@ import { Collection, Entity, Enum, Index, ManyToMany, ManyToOne, OneToMany, Property, Unique } from '@mikro-orm/core'; -import { InternalServerErrorException } from '@nestjs/common/exceptions/internal-server-error.exception'; -import { IEntityWithSchool, ILearnroom } from '@shared/domain/interface'; import { ClassEntity } from '@modules/class/entity/class.entity'; import { GroupEntity } from '@modules/group/entity/group.entity'; +import { InternalServerErrorException } from '@nestjs/common/exceptions/internal-server-error.exception'; +import { IEntityWithSchool, ILearnroom } from '@shared/domain/interface'; import { EntityId, LearnroomMetadata, LearnroomTypes } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; @@ -11,7 +11,7 @@ import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; -export interface ICourseProperties { +export interface CourseProperties { name?: string; description?: string; school: SchoolEntity; @@ -105,7 +105,7 @@ export class Course @ManyToMany(() => GroupEntity, undefined, { fieldName: 'groupIds' }) groups = new Collection(this); - constructor(props: ICourseProperties) { + constructor(props: CourseProperties) { super(); if (props.name) this.name = props.name; if (props.description) this.description = props.description; diff --git a/apps/server/src/shared/testing/factory/course.factory.ts b/apps/server/src/shared/testing/factory/course.factory.ts index 150b7b2270b..a0418771486 100644 --- a/apps/server/src/shared/testing/factory/course.factory.ts +++ b/apps/server/src/shared/testing/factory/course.factory.ts @@ -1,38 +1,38 @@ import { DeepPartial } from 'fishery'; -import { Course, ICourseProperties } from '@shared/domain'; +import { Course, CourseProperties } from '@shared/domain'; -import { schoolFactory } from './school.factory'; import { BaseFactory } from './base.factory'; +import { schoolFactory } from './school.factory'; import { userFactory } from './user.factory'; const oneDay = 24 * 60 * 60 * 1000; -class CourseFactory extends BaseFactory { +class CourseFactory extends BaseFactory { isFinished(): this { const untilDate = new Date(Date.now() - oneDay); - const params: DeepPartial = { untilDate }; + const params: DeepPartial = { untilDate }; return this.params(params); } isOpen(): this { const untilDate = new Date(Date.now() + oneDay); - const params: DeepPartial = { untilDate }; + const params: DeepPartial = { untilDate }; return this.params(params); } studentsWithId(numberOfStudents: number): this { const students = userFactory.buildListWithId(numberOfStudents); - const params: DeepPartial = { students }; + const params: DeepPartial = { students }; return this.params(params); } teachersWithId(numberOfTeachers: number): this { const teachers = userFactory.buildListWithId(numberOfTeachers); - const params: DeepPartial = { teachers }; + const params: DeepPartial = { teachers }; return this.params(params); } From dee5fdf99057deacbc3bd8e0ce906504198cb7b0 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:21:21 +0100 Subject: [PATCH 045/110] ICourseGroupProperties -> CourseGroupProperties --- .../server/src/shared/domain/entity/coursegroup.entity.ts | 4 ++-- .../src/shared/testing/factory/coursegroup.factory.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/shared/domain/entity/coursegroup.entity.ts b/apps/server/src/shared/domain/entity/coursegroup.entity.ts index c883e6adcce..47479904088 100644 --- a/apps/server/src/shared/domain/entity/coursegroup.entity.ts +++ b/apps/server/src/shared/domain/entity/coursegroup.entity.ts @@ -8,7 +8,7 @@ import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; -export interface ICourseGroupProperties { +export interface CourseGroupProperties { name: string; course: Course; students?: User[]; @@ -32,7 +32,7 @@ export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWith @Index() school: SchoolEntity; - constructor(props: ICourseGroupProperties) { + constructor(props: CourseGroupProperties) { super(); this.name = props.name; this.course = props.course; diff --git a/apps/server/src/shared/testing/factory/coursegroup.factory.ts b/apps/server/src/shared/testing/factory/coursegroup.factory.ts index f1408fd664d..3b98de4a17c 100644 --- a/apps/server/src/shared/testing/factory/coursegroup.factory.ts +++ b/apps/server/src/shared/testing/factory/coursegroup.factory.ts @@ -1,13 +1,13 @@ -import { CourseGroup, ICourseGroupProperties } from '@shared/domain'; +import { CourseGroup, CourseGroupProperties } from '@shared/domain'; import { DeepPartial } from 'fishery'; -import { courseFactory } from './course.factory'; import { BaseFactory } from './base.factory'; +import { courseFactory } from './course.factory'; import { userFactory } from './user.factory'; -class CourseGroupFactory extends BaseFactory { +class CourseGroupFactory extends BaseFactory { studentsWithId(numberOfStudents: number): this { const students = userFactory.buildListWithId(numberOfStudents); - const params: DeepPartial = { students }; + const params: DeepPartial = { students }; return this.params(params); } From 0d72efc3394ba83a38491148ce1b6d162fdbcfdc Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:46:01 +0100 Subject: [PATCH 046/110] IImportUserProperties -> ImportUserProperties --- apps/server/doc/file-structure.md | 4 +- .../calendar/service/calendar.service.spec.ts | 10 +- .../collaborative-storage.adapter.spec.ts | 6 +- .../keycloak-administration.service.spec.ts | 6 +- ...-identity-management-oauth.service.spec.ts | 4 +- .../controller/api-test/account.api.spec.ts | 4 +- .../src/modules/account/uc/account.uc.spec.ts | 104 +++++++++--------- .../controllers/api-test/login.api.spec.ts | 4 +- .../decorator/auth.decorator.spec.ts | 10 +- .../mapper/current-user.mapper.spec.ts | 35 +++--- .../services/authentication.service.spec.ts | 8 +- .../strategy/ldap.strategy.spec.ts | 8 +- .../strategy/oauth2.strategy.spec.ts | 14 +-- .../api-test/board-delete.api.spec.ts | 8 +- .../api-test/board-lookup.api.spec.ts | 8 +- .../api-test/card-create.api.spec.ts | 8 +- .../api-test/card-delete.api.spec.ts | 8 +- .../api-test/card-lookup.api.spec.ts | 8 +- .../controller/api-test/card-move.api.spec.ts | 8 +- .../api-test/column-create.api.spec.ts | 8 +- .../api-test/column-delete.api.spec.ts | 8 +- .../api-test/column-move.api.spec.ts | 8 +- .../content-element-delete.api.spec.ts | 8 +- .../api-test/content-element-move.api.spec.ts | 8 +- .../collaborative-storage.controller.spec.ts | 8 +- .../api-test/files-security.api.spec.ts | 4 +- .../files-storage-copy-files.api.spec.ts | 8 +- .../files-storage-delete-files.api.spec.ts | 8 +- .../files-storage-download-upload.api.spec.ts | 8 +- .../files-storage-list-files.api.spec.ts | 4 +- .../files-storage-preview.api.spec.ts | 4 +- .../files-storage-rename-file.api.spec.ts | 4 +- .../files-storage-restore-files.api.spec.ts | 8 +- .../entity/filerecord.entity.spec.ts | 4 +- .../api-test/h5p-editor-delete.api.spec.ts | 8 +- .../h5p-editor-get-editor.api.spec.ts | 8 +- .../h5p-editor-get-player.api.spec.ts | 8 +- .../h5p-editor/uc/h5p-delete.uc.spec.ts | 8 +- .../h5p-editor/uc/h5p-files.uc.spec.ts | 8 +- .../h5p-editor/uc/h5p-get-editor.uc.spec.ts | 8 +- .../h5p-editor/uc/h5p-get-player.uc.spec.ts | 10 +- .../h5p-editor/uc/h5p-save-create.uc.spec.ts | 16 +-- .../controller/api-test/dashboard.api.spec.ts | 12 +- .../api-test/rooms-copy-timeout.api.spec.ts | 10 +- .../controller/api-test/rooms.api.spec.ts | 14 +-- .../controller/dashboard.controller.spec.ts | 18 +-- .../controller/rooms.controller.spec.ts | 14 +-- .../legacy-school.controller.spec.ts | 6 +- .../management/seed-data/federalstates.ts | 6 +- .../oauth-provider.controller.spec.ts | 24 ++-- .../oauth-provider.login-flow.service.spec.ts | 10 +- .../uc/oauth-provider.client-crud.uc.spec.ts | 10 +- .../uc/oauth-provider.consent-flow.uc.spec.ts | 16 +-- .../controller/api-test/oauth-sso.api.spec.ts | 12 +- .../controller/oauth-sso.controller.spec.ts | 10 +- .../oauth/service/oauth.service.spec.ts | 20 ++-- .../api-test/sharing-create-token.api.spec.ts | 14 +-- .../api-test/sharing-import-token.api.spec.ts | 10 +- .../controller/share-token.controller.spec.ts | 12 +- .../controller/api-test/system.api.spec.ts | 8 +- .../api-test/submission.api.spec.ts | 14 +-- .../api-test/task-copy-timeout.api.spec.ts | 4 +- .../api-test/task-finished.api.spec.ts | 10 +- .../task/controller/task.controller.spec.ts | 6 +- .../external-tool/uc/external-tool.uc.spec.ts | 12 +- .../oauth2-tool-launch.strategy.spec.ts | 4 +- .../api-test/import-user.api.spec.ts | 40 +++---- .../service/school-migration.service.spec.ts | 12 +- .../api-test/user-language.api.spec.ts | 10 +- .../controller/api-test/user-me.api.spec.ts | 10 +- ...o-conference-deprecated.controller.spec.ts | 4 +- .../uc/video-conference-deprecated.uc.spec.ts | 22 ++-- .../shared/domain/entity/dashboard.entity.ts | 24 ++-- .../domain/entity/dashboard.model.entity.ts | 4 +- .../domain/entity/federal-state.entity.ts | 4 +- .../domain/entity/import-user.entity.ts | 4 +- .../testing/factory/federal-state.factory.ts | 4 +- .../testing/factory/import-user.factory.ts | 6 +- 78 files changed, 437 insertions(+), 422 deletions(-) diff --git a/apps/server/doc/file-structure.md b/apps/server/doc/file-structure.md index 8b0c2969a8c..9f63d339c30 100644 --- a/apps/server/doc/file-structure.md +++ b/apps/server/doc/file-structure.md @@ -158,7 +158,7 @@ The main responsibilities of a controller is to define the REST API interface as ```TypeScript @Post() - async create(@CurrentUser() currentUser: ICurrentUser, @Body() params: CreateNewsParams): Promise { + async create(@CurrentUser() currentUser: CurrentUserInterface, @Body() params: CreateNewsParams): Promise { const news = await this.newsUc.create( currentUser.userId, currentUser.schoolId, @@ -171,7 +171,7 @@ The main responsibilities of a controller is to define the REST API interface as #### JWT-Authentication -For **authentication**, use [guards](https://docs.nestjs.com/guards) like JwtAuthGuard. It can be applied to a whole controller or a single controller method only. Then, [ICurrentUser](/apps/server/src/modules/authentication/interface/jwt-payload.ts) can be injected using the `@CurrentUser()` decorator. +For **authentication**, use [guards](https://docs.nestjs.com/guards) like JwtAuthGuard. It can be applied to a whole controller or a single controller method only. Then, [CurrentUserInterface](/apps/server/src/modules/authentication/interface/jwt-payload.ts) can be injected using the `@CurrentUser()` decorator. #### Validation diff --git a/apps/server/src/infra/calendar/service/calendar.service.spec.ts b/apps/server/src/infra/calendar/service/calendar.service.spec.ts index ed6bb4620bc..95d1fa95e22 100644 --- a/apps/server/src/infra/calendar/service/calendar.service.spec.ts +++ b/apps/server/src/infra/calendar/service/calendar.service.spec.ts @@ -1,14 +1,14 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { HttpService } from '@nestjs/axios'; import { InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { axiosResponseFactory } from '@shared/testing'; import { AxiosResponse } from 'axios'; import { of, throwError } from 'rxjs'; +import { CalendarEvent } from '../interface/calendar-event.interface'; import { CalendarMapper } from '../mapper/calendar.mapper'; -import { ICalendarEvent } from '../interface/calendar-event.interface'; describe('CalendarServiceSpec', () => { let module: TestingModule; @@ -56,7 +56,7 @@ describe('CalendarServiceSpec', () => { const title = 'eventTitle'; const teamId = 'teamId'; - const event: ICalendarEvent = { + const event: CalendarEvent = { data: [ { attributes: { @@ -66,7 +66,7 @@ describe('CalendarServiceSpec', () => { }, ], }; - const axiosResponse: AxiosResponse = axiosResponseFactory.build({ + const axiosResponse: AxiosResponse = axiosResponseFactory.build({ data: event, }); httpService.get.mockReturnValue(of(axiosResponse)); diff --git a/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts index 36198998f51..3742c3ff408 100644 --- a/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts +++ b/apps/server/src/infra/collaborative-storage/collaborative-storage.adapter.spec.ts @@ -38,7 +38,7 @@ class TestStrategy implements CollaborativeStorageStrategy { describe('CollaborativeStorage Adapter', () => { let module: TestingModule; let adapter: CollaborativeStorageAdapter; - let strategy: ICollaborativeStorageStrategy; + let strategy: CollaborativeStorageStrategy; beforeAll(async () => { module = await Test.createTestingModule({ @@ -50,8 +50,8 @@ describe('CollaborativeStorage Adapter', () => { useValue: createMock(), }, { - provide: 'ICollaborativeStorageStrategy', - useValue: createMock(), + provide: 'CollaborativeStorageStrategy', + useValue: createMock(), }, ], }).compile(); diff --git a/apps/server/src/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 index 77e372bdc45..cb153fb6ea7 100644 --- a/apps/server/src/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 @@ -2,18 +2,18 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import { Clients } from '@keycloak/keycloak-admin-client/lib/resources/clients'; import { Test, TestingModule } from '@nestjs/testing'; -import { IKeycloakSettings, KeycloakSettings } from '../interface/keycloak-settings.interface'; +import { KeycloakSettings, KeycloakSettingsInterface } from '../interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from './keycloak-administration.service'; describe('KeycloakAdministrationService', () => { let module: TestingModule; let kcAdminClient: DeepMocked; - let settings: IKeycloakSettings; + let settings: KeycloakSettingsInterface; let service: KeycloakAdministrationService; const kcApiClientMock = createMock(); - const getSettings = (): IKeycloakSettings => { + const getSettings = (): KeycloakSettingsInterface => { return { baseUrl: 'http://localhost:8080', realmName: 'master', diff --git a/apps/server/src/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 index 9ccd20b6f99..8bd354ff379 100644 --- a/apps/server/src/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 @@ -1,9 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { DefaultEncryptionService, EncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; 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 '@infra/encryption'; import { AxiosResponse } from 'axios'; import { of } from 'rxjs'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; @@ -38,7 +38,7 @@ describe('KeycloakIdentityManagementService', () => { }, { provide: DefaultEncryptionService, - useValue: createMock(), + useValue: createMock(), }, ], }).compile(); diff --git a/apps/server/src/modules/account/controller/api-test/account.api.spec.ts b/apps/server/src/modules/account/controller/api-test/account.api.spec.ts index fefdb006bf8..412ef54a2f4 100644 --- a/apps/server/src/modules/account/controller/api-test/account.api.spec.ts +++ b/apps/server/src/modules/account/controller/api-test/account.api.spec.ts @@ -2,7 +2,6 @@ import { EntityManager } from '@mikro-orm/core'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Account, Permission, RoleName, User } from '@shared/domain'; -import { ICurrentUser } from '@src/modules/authentication'; import { accountFactory, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; import { AccountByIdBodyParams, @@ -11,6 +10,7 @@ import { PatchMyAccountParams, PatchMyPasswordParams, } from '@src/modules/account/controller/dto'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@src/modules/server/server.module'; import { Request } from 'express'; @@ -32,7 +32,7 @@ describe('Account Controller (API)', () => { let studentUser: User; let superheroUser: User; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; const defaultPassword = 'DummyPasswd!1'; const defaultPasswordHash = '$2a$10$/DsztV5o6P5piW2eWJsxw.4nHovmJGBA.QNwiTmuZ/uvUc40b.Uhu'; diff --git a/apps/server/src/modules/account/uc/account.uc.spec.ts b/apps/server/src/modules/account/uc/account.uc.spec.ts index aa4cdf56a82..f9a16fea991 100644 --- a/apps/server/src/modules/account/uc/account.uc.spec.ts +++ b/apps/server/src/modules/account/uc/account.uc.spec.ts @@ -1,4 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { AccountService } from '@modules/account/services/account.service'; +import { AccountSaveDto } from '@modules/account/services/dto'; +import { AccountDto } from '@modules/account/services/dto/account.dto'; +import { CurrentUserInterface } from '@modules/authentication'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { AuthorizationError, EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common'; @@ -18,10 +22,6 @@ import { import { UserRepo } from '@shared/repo'; import { accountFactory, schoolFactory, setupEntities, systemFactory, userFactory } from '@shared/testing'; import { BruteForcePrevention } from '@src/imports-from-feathers'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountSaveDto } from '@modules/account/services/dto'; -import { AccountDto } from '@modules/account/services/dto/account.dto'; -import { ICurrentUser } from '@modules/authentication'; import { ObjectId } from 'bson'; import { AccountByIdBodyParams, @@ -795,7 +795,7 @@ describe('AccountUc', () => { describe('searchAccounts', () => { it('should return one account, if search type is userId', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams ); const expected = new AccountSearchListResponse( @@ -808,7 +808,7 @@ describe('AccountUc', () => { }); it('should return empty list, if account is not found', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { type: AccountSearchType.USER_ID, value: mockUserWithoutAccount.id } as AccountSearchQueryParams ); const expected = new AccountSearchListResponse([], 0, 0, 0); @@ -816,7 +816,7 @@ describe('AccountUc', () => { }); it('should return one or more accounts, if search type is username', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { type: AccountSearchType.USERNAME, value: '' } as AccountSearchQueryParams ); expect(accounts.skip).toEqual(0); @@ -827,21 +827,21 @@ describe('AccountUc', () => { it('should throw, if user has not the right permissions', async () => { await expect( accountUc.searchAccounts( - { userId: mockTeacherUser.id } as ICurrentUser, + { userId: mockTeacherUser.id } as CurrentUserInterface, { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); await expect( accountUc.searchAccounts( - { userId: mockStudentUser.id } as ICurrentUser, + { userId: mockStudentUser.id } as CurrentUserInterface, { type: AccountSearchType.USER_ID, value: mockOtherStudentUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); await expect( accountUc.searchAccounts( - { userId: mockStudentUser.id } as ICurrentUser, + { userId: mockStudentUser.id } as CurrentUserInterface, { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -849,7 +849,7 @@ describe('AccountUc', () => { it('should throw, if search type is unknown', async () => { await expect( accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { type: '' as AccountSearchType } as AccountSearchQueryParams ) ).rejects.toThrow('Invalid search type.'); @@ -857,7 +857,7 @@ describe('AccountUc', () => { it('should throw, if user is no superhero', async () => { await expect( accountUc.searchAccounts( - { userId: mockTeacherUser.id } as ICurrentUser, + { userId: mockTeacherUser.id } as CurrentUserInterface, { type: AccountSearchType.USERNAME, value: mockStudentUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -868,22 +868,22 @@ describe('AccountUc', () => { configService.get.mockReturnValue(false); }); it('admin can access teacher of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('admin can access student of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('admin can not access admin of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('admin can not access any account of a foreign school via user id', async () => { - const currentUser = { userId: mockDifferentSchoolAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockDifferentSchoolAdminUser.id } as CurrentUserInterface; let params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -892,22 +892,22 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('teacher can access teacher of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockOtherTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('teacher can access student of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('teacher can not access admin of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('teacher can not access any account of a foreign school via user id', async () => { - const currentUser = { userId: mockDifferentSchoolTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockDifferentSchoolTeacherUser.id } as CurrentUserInterface; let params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -917,7 +917,7 @@ describe('AccountUc', () => { }); it('teacher can access student of the same school via user id if school has global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockTeacherNoUserPermissionUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherNoUserPermissionUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockStudentSchoolPermissionUser.id, @@ -926,14 +926,14 @@ describe('AccountUc', () => { }); it('teacher can not access student of the same school if school has no global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockTeacherNoUserNoSchoolPermissionUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherNoUserNoSchoolPermissionUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(ForbiddenOperationError); }); it('student can not access student of the same school if school has global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockStudentSchoolPermissionUser.id } as ICurrentUser; + const currentUser = { userId: mockStudentSchoolPermissionUser.id } as CurrentUserInterface; const params = { type: AccountSearchType.USER_ID, value: mockOtherStudentSchoolPermissionUser.id, @@ -941,7 +941,7 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(ForbiddenOperationError); }); it('student can not access any other account via user id', async () => { - const currentUser = { userId: mockStudentUser.id } as ICurrentUser; + const currentUser = { userId: mockStudentUser.id } as CurrentUserInterface; let params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -953,7 +953,7 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('superhero can access any account via username', async () => { - const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; + const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; let params = { type: AccountSearchType.USERNAME, value: mockAdminAccount.username } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); @@ -988,7 +988,7 @@ describe('AccountUc', () => { describe('findAccountById', () => { it('should return an account, if the current user is a superhero', async () => { const account = await accountUc.findAccountById( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { id: mockStudentAccount.id } as AccountByIdParams ); expect(account).toStrictEqual( @@ -1003,19 +1003,25 @@ describe('AccountUc', () => { it('should throw, if the current user is no superhero', async () => { await expect( accountUc.findAccountById( - { userId: mockTeacherUser.id } as ICurrentUser, + { userId: mockTeacherUser.id } as CurrentUserInterface, { id: mockStudentAccount.id } as AccountByIdParams ) ).rejects.toThrow(ForbiddenOperationError); }); it('should throw, if no account matches the search term', async () => { await expect( - accountUc.findAccountById({ userId: mockSuperheroUser.id } as ICurrentUser, { id: 'xxx' } as AccountByIdParams) + accountUc.findAccountById( + { userId: mockSuperheroUser.id } as CurrentUserInterface, + { id: 'xxx' } as AccountByIdParams + ) ).rejects.toThrow(EntityNotFoundError); }); it('should throw, if target account has no user', async () => { await expect( - accountUc.findAccountById({ userId: mockSuperheroUser.id } as ICurrentUser, { id: 'xxx' } as AccountByIdParams) + accountUc.findAccountById( + { userId: mockSuperheroUser.id } as CurrentUserInterface, + { id: 'xxx' } as AccountByIdParams + ) ).rejects.toThrow(EntityNotFoundError); }); }); @@ -1042,20 +1048,20 @@ describe('AccountUc', () => { describe('updateAccountById', () => { it('should throw if executing user does not exist', async () => { - const currentUser = { userId: '000000000000000' } as ICurrentUser; + const currentUser = { userId: '000000000000000' } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should throw if target account does not exist', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: '000000000000000' } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should update target account password', async () => { const previousPasswordHash = mockStudentAccount.password; - const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; + const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { password: defaultPassword } as AccountByIdBodyParams; expect(mockStudentUser.forcePasswordChange).toBeFalsy(); @@ -1065,7 +1071,7 @@ describe('AccountUc', () => { }); it('should update target account username', async () => { const newUsername = 'newUsername'; - const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; + const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: newUsername } as AccountByIdBodyParams; expect(mockStudentAccount.username).not.toBe(newUsername); @@ -1073,20 +1079,20 @@ describe('AccountUc', () => { expect(mockStudentAccount.username).toBe(newUsername.toLowerCase()); }); it('should update target account activation state', async () => { - const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; + const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { activated: false } as AccountByIdBodyParams; await accountUc.updateAccountById(currentUser, params, body); expect(mockStudentAccount.activated).toBeFalsy(); }); it('should throw if account can not be updated', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: 'fail@to.update' } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should throw if user can not be updated', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: 'user-fail@to.update' } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); @@ -1094,7 +1100,7 @@ describe('AccountUc', () => { it('should throw if target account has no user', async () => { await expect( accountUc.updateAccountById( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { id: mockAccountWithoutUser.id } as AccountByIdParams, { username: 'user-fail@to.update' } as AccountByIdBodyParams ) @@ -1103,7 +1109,7 @@ describe('AccountUc', () => { it('should throw if new username already in use', async () => { const accountIsUniqueEmailSpy = jest.spyOn(accountValidationService, 'isUniqueEmail'); accountIsUniqueEmailSpy.mockResolvedValueOnce(false); - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: mockOtherTeacherAccount.username } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ValidationError); @@ -1111,49 +1117,49 @@ describe('AccountUc', () => { describe('hasPermissionsToUpdateAccount', () => { it('admin can edit teacher', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('teacher can edit student', async () => { - const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('admin can edit student', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('teacher cannot edit other teacher', async () => { - const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; + const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; const params = { id: mockOtherTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it("other school's admin cannot edit teacher", async () => { - const currentUser = { userId: mockDifferentSchoolAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockDifferentSchoolAdminUser.id } as CurrentUserInterface; const params = { id: mockTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it('superhero can edit admin', async () => { - const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; + const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; const params = { id: mockAdminAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('undefined user role fails by default', async () => { - const currentUser = { userId: mockUnknownRoleUser.id } as ICurrentUser; + const currentUser = { userId: mockUnknownRoleUser.id } as CurrentUserInterface; const params = { id: mockAccountWithoutRole.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it('user without role cannot be edited', async () => { - const currentUser = { userId: mockAdminUser.id } as ICurrentUser; + const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; const params = { id: mockUnknownRoleUserAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); @@ -1165,7 +1171,7 @@ describe('AccountUc', () => { it('should delete an account, if current user is authorized', async () => { await expect( accountUc.deleteAccountById( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { id: mockStudentAccount.id } as AccountByIdParams ) ).resolves.not.toThrow(); @@ -1173,7 +1179,7 @@ describe('AccountUc', () => { it('should throw, if the current user is no superhero', async () => { await expect( accountUc.deleteAccountById( - { userId: mockAdminUser.id } as ICurrentUser, + { userId: mockAdminUser.id } as CurrentUserInterface, { id: mockStudentAccount.id } as AccountByIdParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -1181,7 +1187,7 @@ describe('AccountUc', () => { it('should throw, if no account matches the search term', async () => { await expect( accountUc.deleteAccountById( - { userId: mockSuperheroUser.id } as ICurrentUser, + { userId: mockSuperheroUser.id } as CurrentUserInterface, { id: 'xxx' } as AccountByIdParams ) ).rejects.toThrow(EntityNotFoundError); 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 04683e182a8..4f62addfebe 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 @@ -11,7 +11,7 @@ import MockAdapter from 'axios-mock-adapter'; import crypto, { KeyPairKeyObjectResult } from 'crypto'; import jwt from 'jsonwebtoken'; import request, { Response } from 'supertest'; -import { ICurrentUser } from '../../interface'; +import { CurrentUserInterface } from '../../interface'; import { LdapAuthorizationBodyParams, LocalAuthorizationBodyParams, OauthLoginResponse } from '../dto'; const ldapAccountUserName = 'ldapAccountUserName'; @@ -282,7 +282,7 @@ describe('Login Controller (api)', () => { expect(response.body.accessToken).toBeDefined(); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument const decodedToken = jwt.decode(response.body.accessToken); - expect(decodedToken).toMatchObject({ + expect(decodedToken).toMatchObject({ userId: user.id, systemId: system.id, roles: [studentRole.id], diff --git a/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts b/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts index f193bd67516..4cfc981f89d 100644 --- a/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts +++ b/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ +import { CurrentUserInterface } from '@modules/authentication'; +import { ServerTestModule } from '@modules/server/server.module'; import { Controller, ExecutionContext, ForbiddenException, Get, INestApplication } from '@nestjs/common'; -import request from 'supertest'; import { Test, TestingModule } from '@nestjs/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { ServerTestModule } from '@modules/server/server.module'; +import request from 'supertest'; import { JwtAuthGuard } from '../guard/jwt-auth.guard'; import { Authenticate, CurrentUser, JWT } from './auth.decorator'; @@ -11,7 +11,7 @@ import { Authenticate, CurrentUser, JWT } from './auth.decorator'; @Controller('test_decorator_currentUser') export class TestDecoratorCurrentUserController { @Get('test') - async test(@CurrentUser() currentUser: ICurrentUser): Promise { + async test(@CurrentUser() currentUser: CurrentUserInterface): Promise { return Promise.resolve(); } } @@ -27,7 +27,7 @@ export class TestDecoratorJWTController { describe('auth.decorator', () => { let app: INestApplication; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let module: TestingModule; beforeAll(async () => { 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 104ca1219a4..1339d54cb4c 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 @@ -2,7 +2,7 @@ import { ValidationError } from '@shared/common'; import { Permission, RoleName } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { roleFactory, schoolFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; -import { ICurrentUser, OauthCurrentUser } from '../interface'; +import { CurrentUserInterface, OauthCurrentUser } from '../interface'; import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from './current-user.mapper'; @@ -13,7 +13,7 @@ describe('CurrentUserMapper', () => { await setupEntities(); }); - describe('userToICurrentUser', () => { + describe('userToCurrentUserInterface', () => { describe('when mapping from a user entity to the current user object', () => { describe('when user has roles', () => { const setup = () => { @@ -34,7 +34,11 @@ describe('CurrentUserMapper', () => { it('should map with roles', () => { const { teacherRole, user } = setup(); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false); + const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( + accountId, + user, + false + ); expect(currentUser).toMatchObject({ accountId, @@ -50,7 +54,7 @@ describe('CurrentUserMapper', () => { it('should map without roles', () => { const user = userFactory.buildWithId(); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, true); + const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface(accountId, user, true); expect(currentUser).toMatchObject({ accountId, @@ -78,7 +82,12 @@ describe('CurrentUserMapper', () => { it('should map system and school', () => { const { user, systemId } = setup(); - const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false, systemId); + const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( + accountId, + user, + false, + systemId + ); expect(currentUser).toMatchObject({ accountId, @@ -160,7 +169,7 @@ describe('CurrentUserMapper', () => { }; }; - it('should return valid ICurrentUser instance with systemId', () => { + it('should return valid CurrentUserInterface instance with systemId', () => { const { user, userId, systemId, idToken } = setup(); const currentUser: OauthCurrentUser = CurrentUserMapper.mapToOauthCurrentUser( @@ -202,7 +211,7 @@ describe('CurrentUserMapper', () => { }; }; - it('should return valid ICurrentUser instance without systemId', () => { + it('should return valid CurrentUserInterface instance without systemId', () => { const { user } = setup(); const currentUser = CurrentUserMapper.mapToOauthCurrentUser(accountId, user, undefined, 'idToken'); @@ -218,7 +227,7 @@ describe('CurrentUserMapper', () => { }); }); - describe('jwtToICurrentUser', () => { + describe('jwtToCurrentUserInterface', () => { describe('when JWT is provided with all claims', () => { const setup = () => { const jwtPayload: JwtPayload = { @@ -245,7 +254,7 @@ describe('CurrentUserMapper', () => { it('should return current user', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); + const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); expect(currentUser).toMatchObject({ accountId: jwtPayload.accountId, @@ -260,7 +269,7 @@ describe('CurrentUserMapper', () => { it('should return current user with default for isExternalUser', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); + const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); expect(currentUser).toMatchObject({ isExternalUser: jwtPayload.isExternalUser, @@ -292,7 +301,7 @@ describe('CurrentUserMapper', () => { it('should return current user', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); + const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); expect(currentUser).toMatchObject({ accountId: jwtPayload.accountId, @@ -306,7 +315,7 @@ describe('CurrentUserMapper', () => { it('should return current user with default for isExternalUser', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); + const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); expect(currentUser).toMatchObject({ isExternalUser: false, @@ -317,7 +326,7 @@ describe('CurrentUserMapper', () => { describe('mapCurrentUserToCreateJwtPayload', () => { it('should map current user to create jwt payload', () => { - const currentUser: ICurrentUser = { + const currentUser: CurrentUserInterface = { accountId: 'dummyAccountId', systemId: 'dummySystemId', roles: ['mockRoleId'], diff --git a/apps/server/src/modules/authentication/services/authentication.service.spec.ts b/apps/server/src/modules/authentication/services/authentication.service.spec.ts index 1e5c69ecfb1..6c010e4cead 100644 --- a/apps/server/src/modules/authentication/services/authentication.service.spec.ts +++ b/apps/server/src/modules/authentication/services/authentication.service.spec.ts @@ -1,11 +1,11 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { AccountService } from '@modules/account/services/account.service'; +import { AccountDto } from '@modules/account/services/dto'; +import { CurrentUserInterface } from '@modules/authentication'; import { UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { JwtService } from '@nestjs/jwt'; import { Test, TestingModule } from '@nestjs/testing'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountDto } from '@modules/account/services/dto'; -import { ICurrentUser } from '@modules/authentication'; import jwt from 'jsonwebtoken'; import { BruteForceError } from '../errors/brute-force.error'; import { JwtValidationAdapter } from '../strategy/jwt-validation.adapter'; @@ -94,7 +94,7 @@ describe('AuthenticationService', () => { describe('generateJwt', () => { describe('when generating new jwt', () => { it('should pass the correct parameters', async () => { - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', 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 5b23be9eb74..5a1b7c7c676 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts @@ -1,4 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { AccountDto } from '@modules/account/services/dto'; import { UnauthorizedException } from '@nestjs/common'; import { PassportModule } from '@nestjs/passport'; import { Test, TestingModule } from '@nestjs/testing'; @@ -15,9 +16,8 @@ import { userFactory, } from '@shared/testing'; import { Logger } from '@src/core/logger'; -import { AccountDto } from '@modules/account/services/dto'; import { LdapAuthorizationBodyParams } from '../controllers/dto'; -import { ICurrentUser } from '../interface'; +import { CurrentUserInterface } from '../interface'; import { AuthenticationService } from '../services/authentication.service'; import { LdapService } from '../services/ldap.service'; import { LdapStrategy } from './ldap.strategy'; @@ -428,7 +428,7 @@ describe('LdapStrategy', () => { it('should authentication with LDAP successfully and return the user', async () => { const { request, user, school, account, system } = setup(); - const result: ICurrentUser = await strategy.validate(request); + const result: CurrentUserInterface = await strategy.validate(request); expect(result).toEqual({ userId: user.id, @@ -492,7 +492,7 @@ describe('LdapStrategy', () => { it('should authentication with LDAP successfully and return the user', async () => { const { request, user, school, account, system } = setup(); - const result: ICurrentUser = await strategy.validate(request); + const result: CurrentUserInterface = await strategy.validate(request); expect(authenticationServiceMock.loadAccount).toHaveBeenCalledTimes(2); expect(result).toEqual({ diff --git a/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts index f67f620175d..6df5944ce4d 100644 --- a/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts @@ -1,15 +1,15 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { AccountService } from '@modules/account/services/account.service'; +import { AccountDto } from '@modules/account/services/dto'; +import { OAuthTokenDto } from '@modules/oauth'; +import { OAuthService } from '@modules/oauth/service/oauth.service'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId, RoleName } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { userDoFactory } from '@shared/testing'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountDto } from '@modules/account/services/dto'; -import { OAuthTokenDto } from '@modules/oauth'; -import { OAuthService } from '@modules/oauth/service/oauth.service'; import { SchoolInMigrationError } from '../errors/school-in-migration.error'; -import { ICurrentUser, OauthCurrentUser } from '../interface'; +import { CurrentUserInterface, OauthCurrentUser } from '../interface'; import { Oauth2Strategy } from './oauth2.strategy'; describe('Oauth2Strategy', () => { @@ -74,10 +74,10 @@ describe('Oauth2Strategy', () => { return { systemId, user, account, idToken }; }; - it('should return the ICurrentUser', async () => { + it('should return the CurrentUserInterface', async () => { const { systemId, user, account, idToken } = setup(); - const result: ICurrentUser = await strategy.validate({ + const result: CurrentUserInterface = await strategy.validate({ body: { code: 'code', redirectUri: 'redirectUri', systemId }, }); diff --git a/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts index e92bb645872..9875001374b 100644 --- a/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -11,9 +14,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server'; import { Request } from 'express'; import request from 'supertest'; import { BoardResponse } from '../dto'; @@ -43,7 +43,7 @@ class API { describe(`board delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts b/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts index 8423d68f793..33ada0e8a18 100644 --- a/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -12,9 +15,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; import { BoardResponse } from '../dto'; @@ -44,7 +44,7 @@ class API { describe(`board lookup (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts index 4b0f57c361d..c7b12b8e48a 100644 --- a/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -11,9 +14,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; import { CardResponse } from '../dto'; @@ -44,7 +44,7 @@ class API { describe(`card create (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts index 3fff41b3660..8b21a8b0004 100644 --- a/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -13,9 +16,6 @@ import { richTextElementNodeFactory, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server'; import { Request } from 'express'; import request from 'supertest'; @@ -43,7 +43,7 @@ class API { describe(`card delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts index 711ccf1ac8f..cb7dce16180 100644 --- a/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -15,9 +18,6 @@ import { schoolFactory, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; import { CardIdsParams, CardListResponse } from '../dto'; @@ -48,7 +48,7 @@ class API { describe(`card lookup (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts index e9e55b27dd2..ef35c254025 100644 --- a/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -12,9 +15,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -43,7 +43,7 @@ class API { describe(`card move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts index 52aaa4608ca..b0dfc362af9 100644 --- a/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -10,9 +13,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; import { ColumnResponse } from '../dto'; @@ -42,7 +42,7 @@ class API { describe(`board create (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts index 86e3e666c84..0d978999022 100644 --- a/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -12,9 +15,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -42,7 +42,7 @@ class API { describe(`column delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts index 6fda90f739a..46df08c17af 100644 --- a/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -12,9 +15,6 @@ import { mapUserToCurrentUser, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -43,7 +43,7 @@ class API { describe(`column move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts index 6b99a64e7ab..1ee2538781e 100644 --- a/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -13,9 +16,6 @@ import { richTextElementNodeFactory, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -43,7 +43,7 @@ class API { describe(`content element delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts index dbcd9acbc31..ef6d43e422e 100644 --- a/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts @@ -1,4 +1,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; @@ -13,9 +16,6 @@ import { richTextElementNodeFactory, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -44,7 +44,7 @@ class API { describe(`content element move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts index 4622fed4c00..92cfb9042d2 100644 --- a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts +++ b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts @@ -1,8 +1,8 @@ +import { createMock } from '@golevelup/ts-jest'; +import { CurrentUserInterface } from '@modules/authentication'; import { CollaborativeStorageController } from '@modules/collaborative-storage/controller/collaborative-storage.controller'; -import { Test, TestingModule } from '@nestjs/testing'; import { CollaborativeStorageUc } from '@modules/collaborative-storage/uc/collaborative-storage.uc'; -import { createMock } from '@golevelup/ts-jest'; -import { ICurrentUser } from '@modules/authentication'; +import { Test, TestingModule } from '@nestjs/testing'; import { LegacyLogger } from '@src/core/logger'; describe('CollaborativeStorage Controller', () => { @@ -29,7 +29,7 @@ describe('CollaborativeStorage Controller', () => { describe('Update TeamPermissions For Role', () => { it('should call the UC', async () => { await controller.updateTeamPermissionsForRole( - { userId: 'userId' } as ICurrentUser, + { userId: 'userId' } as CurrentUserInterface, { teamId: 'testTeam', roleId: 'testRole' }, { read: false, write: false, create: false, delete: false, share: false } ); diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts index 4694b1817ac..d449cb5f4b3 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -48,7 +48,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let validId: string; 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 4a966165633..6bf8d5f4fb8 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 @@ -1,13 +1,13 @@ import { createMock } from '@golevelup/ts-jest'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; 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 '@infra/antivirus'; -import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, courseFactory, @@ -85,7 +85,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { 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 6c1087ce371..638f6634b07 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 @@ -1,13 +1,13 @@ import { createMock } from '@golevelup/ts-jest'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; 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 '@infra/antivirus'; -import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, fileRecordFactory, @@ -84,7 +84,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { 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 27661af51f8..ed272ef5d0b 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 @@ -1,13 +1,13 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; 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 '@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'; @@ -93,7 +93,7 @@ describe('files-storage controller (API)', () => { let app: INestApplication; let em: EntityManager; let s3ClientAdapter: DeepMocked; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let validId: EntityId; let appPort: number; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts index 35410d712c8..65b8c285af7 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -48,7 +48,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let validId: string; 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 6ccc6d0d5ea..609d6f62dec 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 @@ -3,7 +3,7 @@ import { AntivirusService } from '@infra/antivirus'; import { PreviewProducer } from '@infra/preview-generator'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication, NotFoundException, StreamableFile } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -104,7 +104,7 @@ describe('File Controller (API) - preview', () => { let em: EntityManager; let s3ClientAdapter: DeepMocked; let antivirusService: DeepMocked; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let schoolId: EntityId; let appPort: number; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts index fb1dfa866eb..bada5cf5723 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -47,7 +47,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let fileRecord: FileRecord; let fileRecords: FileRecord[]; 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 9e666437748..d3efedf02e9 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 @@ -1,13 +1,13 @@ import { createMock } from '@golevelup/ts-jest'; +import { AntivirusService } from '@infra/antivirus'; +import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; 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 '@infra/antivirus'; -import { S3ClientAdapter } from '@infra/s3-client'; import { cleanupCollections, fileRecordFactory, @@ -109,7 +109,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/files-storage/entity/filerecord.entity.spec.ts b/apps/server/src/modules/files-storage/entity/filerecord.entity.spec.ts index f497ff39a6c..a3d28c5bdec 100644 --- a/apps/server/src/modules/files-storage/entity/filerecord.entity.spec.ts +++ b/apps/server/src/modules/files-storage/entity/filerecord.entity.spec.ts @@ -6,8 +6,8 @@ import { PreviewInputMimeTypes } from '../interface'; import { FileRecord, FileRecordParentType, + FileRecordProperties, FileRecordSecurityCheck, - IFileRecordProperties, PreviewStatus, ScanStatus, } from './filerecord.entity'; @@ -18,7 +18,7 @@ describe('FileRecord Entity', () => { }); describe('when creating a new instance using the constructor', () => { - let props: IFileRecordProperties; + let props: FileRecordProperties; beforeEach(() => { props = { 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 e2af08f3fd5..0306a5ee710 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 @@ -1,11 +1,11 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest/lib/mocks'; +import { createMock, DeepMocked } from '@golevelup/ts-jest/lib/mocks'; +import { S3ClientAdapter } from '@infra/s3-client'; 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 '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -35,7 +35,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let h5PEditorUc: DeepMocked; beforeAll(async () => { 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 3f738fd67c0..51fd9bb90f3 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 @@ -1,11 +1,11 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest/lib/mocks'; +import { createMock, DeepMocked } from '@golevelup/ts-jest/lib/mocks'; +import { S3ClientAdapter } from '@infra/s3-client'; 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 '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -53,7 +53,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let h5PEditorUc: DeepMocked; beforeAll(async () => { 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 6e98bb6905a..19a2002503d 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 @@ -1,12 +1,12 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest/lib/mocks'; +import { createMock, DeepMocked } from '@golevelup/ts-jest/lib/mocks'; +import { S3ClientAdapter } from '@infra/s3-client'; import { IPlayerModel } from '@lumieducation/h5p-server'; 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 '@infra/s3-client'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -45,7 +45,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let h5PEditorUc: DeepMocked; beforeAll(async () => { diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts index 174d5c0fd3a..e6a67661761 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts @@ -1,20 +1,20 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { H5PEditor, H5PPlayer } from '@lumieducation/h5p-server'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; +import { H5PAjaxEndpointProvider } from '../provider'; import { H5PContentRepo } from '../repo'; import { LibraryStorage } from '../service'; -import { H5PAjaxEndpointProvider } from '../provider'; import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts index ab38282cc56..01666e42ebe 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts @@ -1,23 +1,23 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { H5PAjaxEndpoint, H5PEditor, IPlayerModel } from '@lumieducation/h5p-server'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { Request } from 'express'; import { Readable } from 'stream'; +import { H5PEditorProvider, H5PPlayerProvider } from '../provider'; import { H5PContentRepo } from '../repo'; import { ContentStorage, LibraryStorage } from '../service'; -import { H5PEditorProvider, H5PPlayerProvider } from '../provider'; import { TemporaryFileStorage } from '../service/temporary-file-storage.service'; import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts index 4322dd06352..02fdeebe80d 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts @@ -1,22 +1,22 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { H5PEditor, H5PPlayer, IEditorModel } from '@lumieducation/h5p-server'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LanguageType } from '@shared/domain'; import { UserRepo } from '@shared/repo'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; +import { H5PAjaxEndpointProvider } from '../provider'; import { H5PContentRepo } from '../repo'; import { LibraryStorage } from '../service'; -import { H5PAjaxEndpointProvider } from '../provider'; import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts index 6db9d27a905..e44ff01fc3d 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts @@ -1,20 +1,20 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { H5PEditor, H5PPlayer, IPlayerModel } from '@lumieducation/h5p-server'; +import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; -import { ForbiddenException, NotFoundException } from '@nestjs/common'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; +import { H5PAjaxEndpointProvider } from '../provider'; import { H5PContentRepo } from '../repo'; import { LibraryStorage } from '../service'; -import { H5PAjaxEndpointProvider } from '../provider'; import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts index 2bd23edecdc..efac96eeefa 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts @@ -1,18 +1,18 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { H5PEditor, H5PPlayer } from '@lumieducation/h5p-server'; -import { Test, TestingModule } from '@nestjs/testing'; -import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { ICurrentUser } from '@src/modules/authentication'; import { ObjectId } from '@mikro-orm/mongodb'; import { ForbiddenException } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import { h5pContentFactory, setupEntities } from '@shared/testing'; +import { CurrentUserInterface } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; -import { LibraryStorage } from '../service'; -import { H5PAjaxEndpointProvider } from '../provider'; -import { H5PEditorUc } from './h5p.uc'; import { H5PContentParentType } from '../entity'; +import { H5PAjaxEndpointProvider } from '../provider'; import { H5PContentRepo } from '../repo'; +import { LibraryStorage } from '../service'; import { LumiUserWithContentData } from '../types/lumi-types'; +import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const { content: parameters, metadata } = h5pContentFactory.build(); @@ -22,7 +22,7 @@ const createParams = () => { const contentId = new ObjectId().toHexString(); const parentId = new ObjectId().toHexString(); - const mockCurrentUser: ICurrentUser = { + const mockCurrentUser: CurrentUserInterface = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts index b6c27736d93..db4f2a421c2 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts @@ -1,13 +1,13 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { DashboardResponse } from '@modules/learnroom/controller/dto'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { DashboardEntity, GridElement, Permission, User, RoleName } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; +import { DashboardEntity, GridElement, Permission, RoleName, User } from '@shared/domain'; import { IDashboardRepo } from '@shared/repo'; import { courseFactory, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { DashboardResponse } from '@modules/learnroom/controller/dto'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -15,7 +15,7 @@ describe('Dashboard Controller (API)', () => { let app: INestApplication; let em: EntityManager; let dashboardRepo: IDashboardRepo; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts index 2941e185ca1..e76043d41de 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts @@ -1,9 +1,12 @@ +import { createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, courseFactory, @@ -12,11 +15,8 @@ import { roleFactory, userFactory, } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; -import { createMock } from '@golevelup/ts-jest'; // config must be set outside before the server module is importat, otherwise the configuration is already set const configBefore = Configuration.toObject({ plainSecrets: true }); @@ -30,7 +30,7 @@ import { ServerTestModule } from '@modules/server'; describe('Rooms copy (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts index 6db5100405a..68fb3e5b3b9 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts @@ -1,6 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { CopyApiResponse } from '@modules/copy-helper'; +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; +import { SingleColumnBoardResponse } from '@modules/learnroom/controller/dto'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Board, Course, Permission, Task } from '@shared/domain'; @@ -14,19 +20,13 @@ import { taskFactory, userFactory, } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { CopyApiResponse } from '@modules/copy-helper'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; -import { SingleColumnBoardResponse } from '@modules/learnroom/controller/dto'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; describe('Rooms Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let filesStorageClientAdapterService: DeepMocked; const setConfig = () => { diff --git a/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts b/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts index 284f18ef862..9f12a182716 100644 --- a/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts +++ b/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts @@ -1,3 +1,4 @@ +import { CurrentUserInterface } from '@modules/authentication'; import { Test, TestingModule } from '@nestjs/testing'; import { DashboardEntity, @@ -7,7 +8,6 @@ import { LearnroomMetadata, LearnroomTypes, } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { DashboardUc } from '../uc/dashboard.uc'; import { DashboardController } from './dashboard.controller'; import { DashboardResponse } from './dto'; @@ -65,7 +65,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -76,7 +76,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -98,7 +98,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -110,7 +110,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; await controller.findForUser(currentUser); expect(spy).toHaveBeenCalledWith('userId'); @@ -133,7 +133,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; await controller.moveElement( { dashboardId: 'dashboardId' }, { from: { x: 1, y: 2 }, to: { x: 2, y: 1 } }, @@ -157,7 +157,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const response = await controller.moveElement( { dashboardId: 'dashboardId' }, { @@ -189,7 +189,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; await controller.patchGroup({ dashboardId: 'dashboardId' }, 3, 4, { title: 'groupTitle' }, currentUser); expect(spy).toHaveBeenCalledWith('dashboardId', { x: 3, y: 4 }, 'groupTitle', currentUser.userId); }); @@ -212,7 +212,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const response = await controller.patchGroup( { dashboardId: 'dashboardId' }, 3, diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts index c63e2e380ae..c87462f3b2f 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts @@ -1,8 +1,8 @@ import { createMock } from '@golevelup/ts-jest'; +import { CurrentUserInterface } from '@modules/authentication'; +import { CopyApiResponse, CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; -import { CopyApiResponse, CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { RoomBoardResponseMapper } from '../mapper/room-board-response.mapper'; import { RoomBoardDTO } from '../types'; import { CourseCopyUC } from '../uc/course-copy.uc'; @@ -73,7 +73,7 @@ describe('rooms controller', () => { describe('getRoomBoard', () => { describe('when simple room is fetched', () => { const setup = () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucResult = { roomId: 'id', @@ -123,7 +123,7 @@ describe('rooms controller', () => { describe('patchVisibility', () => { it('should call uc', async () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucSpy = jest.spyOn(uc, 'updateVisibilityOfBoardElement').mockImplementation(() => Promise.resolve()); await controller.patchElementVisibility( { roomId: 'roomid', elementId: 'elementId' }, @@ -136,7 +136,7 @@ describe('rooms controller', () => { describe('patchOrder', () => { it('should call uc', async () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucSpy = jest.spyOn(uc, 'reorderBoardElements').mockImplementation(() => Promise.resolve()); await controller.patchOrderingOfElements({ roomId: 'roomid' }, { elements: ['id', 'id', 'id'] }, currentUser); expect(ucSpy).toHaveBeenCalledWith('roomid', 'userId', ['id', 'id', 'id']); @@ -146,7 +146,7 @@ describe('rooms controller', () => { describe('copyCourse', () => { describe('when course should be copied via API call', () => { const setup = () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucResult = { title: 'example title', type: 'COURSE' as CopyElementType, @@ -175,7 +175,7 @@ describe('rooms controller', () => { describe('copyLesson', () => { describe('when lesson should be copied via API call', () => { const setup = () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucResult = { title: 'example title', type: 'LESSON' as CopyElementType, diff --git a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts index 764d71b6abf..ff209d151a0 100644 --- a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts +++ b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; import { Test, TestingModule } from '@nestjs/testing'; -import { ICurrentUser } from '@modules/authentication'; import { MigrationMapper } from '../mapper/migration.mapper'; -import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; import { LegacySchoolUc } from '../uc'; +import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; import { MigrationBody, MigrationResponse, SchoolParams } from './dto'; import { LegacySchoolController } from './legacy-school.controller'; @@ -44,7 +44,7 @@ describe('Legacy School Controller', () => { const setupBasicData = () => { const schoolParams: SchoolParams = { schoolId: new ObjectId().toHexString() }; - const testUser: ICurrentUser = { userId: 'testUser' } as ICurrentUser; + const testUser: CurrentUserInterface = { userId: 'testUser' } as CurrentUserInterface; const migrationResp: MigrationResponse = { oauthMigrationMandatory: new Date(), diff --git a/apps/server/src/modules/management/seed-data/federalstates.ts b/apps/server/src/modules/management/seed-data/federalstates.ts index c5f6447a4b7..2630aa8797a 100644 --- a/apps/server/src/modules/management/seed-data/federalstates.ts +++ b/apps/server/src/modules/management/seed-data/federalstates.ts @@ -1,8 +1,8 @@ -import { County, IFederalStateProperties } from '@shared/domain/entity/federal-state.entity'; +import { County, FederalStateProperties } from '@shared/domain/entity/federal-state.entity'; import { federalStateFactory } from '@shared/testing/factory/federal-state.factory'; import { DeepPartial } from 'fishery'; -type SeedFederalStateProperties = Omit & { +type SeedFederalStateProperties = Omit & { id: string; counties?: (County & { id: string })[]; createdAt?: string; @@ -219,7 +219,7 @@ export function generateFederalStates() { }) ) ?? []; - const params: DeepPartial = { + const params: DeepPartial = { counties, name: federalState.name, abbreviation: federalState.abbreviation, 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 bc993271066..7df890ee1f0 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 @@ -1,8 +1,12 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { OauthProviderLogoutFlowUc } from '@modules/oauth-provider/uc/oauth-provider.logout-flow.uc'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { OauthProviderResponseMapper } from '@modules/oauth-provider/mapper/oauth-provider-response.mapper'; +import { + ProviderConsentResponse, + ProviderConsentSessionResponse, + ProviderLoginResponse, + ProviderRedirectResponse, +} from '@infra/oauth-provider/dto'; +import { CurrentUserInterface } from '@modules/authentication'; import { AcceptQuery, ChallengeParams, @@ -15,18 +19,14 @@ import { OauthClientResponse, RedirectResponse, } from '@modules/oauth-provider/controller/dto'; -import { - ProviderConsentResponse, - ProviderConsentSessionResponse, - ProviderLoginResponse, - ProviderRedirectResponse, -} from '@infra/oauth-provider/dto'; +import { OauthProviderResponseMapper } from '@modules/oauth-provider/mapper/oauth-provider-response.mapper'; import { OauthProviderConsentFlowUc } from '@modules/oauth-provider/uc/oauth-provider.consent-flow.uc'; -import { ICurrentUser } from '@modules/authentication'; +import { OauthProviderLogoutFlowUc } from '@modules/oauth-provider/uc/oauth-provider.logout-flow.uc'; import { OauthProviderUc } from '@modules/oauth-provider/uc/oauth-provider.uc'; -import { OauthProviderController } from './oauth-provider.controller'; +import { Test, TestingModule } from '@nestjs/testing'; import { OauthProviderClientCrudUc } from '../uc/oauth-provider.client-crud.uc'; import { OauthProviderLoginFlowUc } from '../uc/oauth-provider.login-flow.uc'; +import { OauthProviderController } from './oauth-provider.controller'; describe('OauthProviderController', () => { let module: TestingModule; @@ -40,7 +40,7 @@ describe('OauthProviderController', () => { let responseMapper: DeepMocked; const hydraUri = 'http://hydra.uri'; - const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; beforeAll(async () => { jest.spyOn(Configuration, 'get').mockReturnValue(hydraUri); diff --git a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts index 3c85dde6c62..b096b0bc1e6 100644 --- a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts +++ b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts @@ -1,12 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { LtiToolService } from '@modules/lti-tool'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; +import { ExternalToolService } from '@modules/tool/external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '@modules/tool/tool-config'; import { NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LtiToolDO } from '@shared/domain'; import { externalToolFactory, ltiToolDOFactory, setupEntities } from '@shared/testing'; -import { LtiToolService } from '@modules/lti-tool'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; -import { ExternalToolService } from '@modules/tool/external-tool/service'; -import { IToolFeatures, ToolFeatures } from '@modules/tool/tool-config'; import { OauthProviderLoginFlowService } from './oauth-provider.login-flow.service'; describe('OauthProviderLoginFlowService', () => { @@ -15,7 +15,7 @@ describe('OauthProviderLoginFlowService', () => { let ltiToolService: DeepMocked; let externalToolService: DeepMocked; - let toolFeatures: IToolFeatures; + let toolFeatures: ToolFeaturesInterface; beforeAll(async () => { module = await Test.createTestingModule({ 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 d2eb1636e53..ad90d21c502 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 @@ -1,12 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { OauthProviderService } from '@infra/oauth-provider'; +import { ProviderOauthClient } from '@infra/oauth-provider/dto'; +import { CurrentUserInterface } from '@modules/authentication'; +import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Permission, User } from '@shared/domain'; -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'; import { OauthProviderClientCrudUc } from './oauth-provider.client-crud.uc'; import resetAllMocks = jest.resetAllMocks; @@ -19,7 +19,7 @@ describe('OauthProviderUc', () => { let user: User; - const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; const defaultOauthClientBody: ProviderOauthClient = { scope: 'openid offline', grant_types: ['authorization_code', 'refresh_token'], 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 e56700477a8..3a61544bb37 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,13 +1,13 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { OauthProviderService } from '@infra/oauth-provider'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; +import { OauthProviderService } from '@infra/oauth-provider'; import { AcceptConsentRequestBody, ProviderConsentResponse, ProviderRedirectResponse } from '@infra/oauth-provider/dto'; +import { CurrentUserInterface } from '@modules/authentication'; +import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; +import { IdToken } from '@modules/oauth-provider/interface/id-token'; +import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; import { OauthProviderConsentFlowUc } from '@modules/oauth-provider/uc/oauth-provider.consent-flow.uc'; -import { ICurrentUser } from '@modules/authentication'; import { ForbiddenException } from '@nestjs/common'; -import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; -import { IdToken } from '@modules/oauth-provider/interface/id-token'; +import { Test, TestingModule } from '@nestjs/testing'; describe('OauthProviderConsentFlowUc', () => { let module: TestingModule; @@ -45,12 +45,12 @@ describe('OauthProviderConsentFlowUc', () => { describe('consent', () => { let challenge: string; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let consentResponse: ProviderConsentResponse; beforeEach(() => { challenge = 'challengexyz'; - currentUser = { userId: 'userId' } as ICurrentUser; + currentUser = { userId: 'userId' } as CurrentUserInterface; consentResponse = { challenge, subject: currentUser.userId, 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 a259c405cfb..9dc197122b7 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 @@ -1,11 +1,15 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { SanisResponse, SanisRole } from '@modules/provisioning/strategy/sanis/response'; +import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; 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 '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; import { accountFactory, cleanupCollections, @@ -16,10 +20,6 @@ import { } from '@shared/testing'; import { JwtTestFactory } from '@shared/testing/factory/jwt.test.factory'; import { userLoginMigrationFactory } from '@shared/testing/factory/user-login-migration.factory'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { SanisResponse, SanisRole } from '@modules/provisioning/strategy/sanis/response'; -import { ServerTestModule } from '@modules/server'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { UUID } from 'bson'; @@ -45,7 +45,7 @@ jest.mock('jwks-rsa', () => () => { describe('OAuth SSO Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let axiosMock: MockAdapter; const sessionCookieName: string = Configuration.get('SESSION__NAME') as string; diff --git a/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts b/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts index 3d1a470e227..2f08ba660b4 100644 --- a/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts +++ b/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts @@ -1,14 +1,14 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; +import { CurrentUserInterface } from '@modules/authentication'; +import { HydraOauthUc } from '@modules/oauth/uc/hydra-oauth.uc'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LegacyLogger } from '@src/core/logger'; -import { ICurrentUser } from '@modules/authentication'; -import { HydraOauthUc } from '@modules/oauth/uc/hydra-oauth.uc'; import { Request } from 'express'; -import { OauthSSOController } from './oauth-sso.controller'; -import { StatelessAuthorizationParams } from './dto/stateless-authorization.params'; import { OauthUc } from '../uc'; +import { StatelessAuthorizationParams } from './dto/stateless-authorization.params'; +import { OauthSSOController } from './oauth-sso.controller'; describe('OAuthController', () => { let module: TestingModule; @@ -90,7 +90,7 @@ describe('OAuthController', () => { }); describe('requestAuthToken', () => { - const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; const oauthClientId = 'clientId'; it('should call the hydraOauthUc', async () => { 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 9c4b45582df..d2d0a7b703c 100644 --- a/apps/server/src/modules/oauth/service/oauth.service.spec.ts +++ b/apps/server/src/modules/oauth/service/oauth.service.spec.ts @@ -1,23 +1,23 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; -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 '@infra/encryption'; -import { legacySchoolDoFactory, setupEntities, systemFactory, userDoFactory } from '@shared/testing'; -import { LegacyLogger } from '@src/core/logger'; +import { DefaultEncryptionService, EncryptionService, SymetricKeyEncryptionService } from '@infra/encryption'; +import { LegacySchoolService } from '@modules/legacy-school'; import { ProvisioningDto, ProvisioningService } from '@modules/provisioning'; import { ExternalSchoolDto, ExternalUserDto, OauthDataDto, ProvisioningSystemDto } from '@modules/provisioning/dto'; -import { LegacySchoolService } from '@modules/legacy-school'; import { OauthConfigDto } from '@modules/system/service'; import { SystemDto } from '@modules/system/service/dto/system.dto'; import { SystemService } from '@modules/system/service/system.service'; import { UserService } from '@modules/user'; import { MigrationCheckService, UserMigrationService } from '@modules/user-login-migration'; +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 { legacySchoolDoFactory, setupEntities, systemFactory, userDoFactory } from '@shared/testing'; +import { LegacyLogger } from '@src/core/logger'; import jwt, { JwtPayload } from 'jsonwebtoken'; -import { OAuthSSOError, UserNotFoundAfterProvisioningLoggableException } from '../loggable'; import { OAuthTokenDto } from '../interface'; +import { OAuthSSOError, UserNotFoundAfterProvisioningLoggableException } from '../loggable'; import { OauthTokenResponse } from './dto'; import { OauthAdapterService } from './oauth-adapter.service'; import { OAuthService } from './oauth.service'; @@ -71,7 +71,7 @@ describe('OAuthService', () => { }, { provide: DefaultEncryptionService, - useValue: createMock(), + useValue: createMock(), }, { provide: LegacyLogger, diff --git a/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts b/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts index 7890f778f86..c9aae09c483 100644 --- a/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts +++ b/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts @@ -1,12 +1,12 @@ -import { Request } from 'express'; -import request from 'supertest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { Permission } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, courseFactory, @@ -15,10 +15,10 @@ import { schoolFactory, userFactory, } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; -import { ShareTokenBodyParams, ShareTokenResponse } from '../dto'; +import { Request } from 'express'; +import request from 'supertest'; import { ShareTokenParentType } from '../../domainobject/share-token.do'; +import { ShareTokenBodyParams, ShareTokenResponse } from '../dto'; const baseRouteName = '/sharetoken'; @@ -46,7 +46,7 @@ class API { describe(`share token creation (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts b/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts index f19dea681f2..306c16fe118 100644 --- a/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts +++ b/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts @@ -1,10 +1,13 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { CopyApiResponse, CopyElementType, CopyStatusEnum } from '@modules/copy-helper'; +import { ServerTestModule } from '@modules/server'; import { ExecutionContext, HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { Permission } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, courseFactory, @@ -13,9 +16,6 @@ import { schoolFactory, userFactory, } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { CopyApiResponse, CopyElementType, CopyStatusEnum } from '@modules/copy-helper'; -import { ServerTestModule } from '@modules/server'; import { Request } from 'express'; import request from 'supertest'; import { ShareTokenContext, ShareTokenContextType, ShareTokenParentType } from '../../domainobject/share-token.do'; @@ -49,7 +49,7 @@ class API { describe(`share token import (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let shareTokenService: ShareTokenService; let api: API; diff --git a/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts b/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts index 7d6f51fa471..ca17e72738c 100644 --- a/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts +++ b/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts @@ -1,8 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { CurrentUserInterface } from '@modules/authentication'; +import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { Test, TestingModule } from '@nestjs/testing'; import { courseFactory, setupEntities, shareTokenFactory } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { ShareTokenParentType } from '../domainobject/share-token.do'; import { ShareTokenUC } from '../uc'; import { ShareTokenInfoDto } from '../uc/dto'; @@ -39,7 +39,7 @@ describe('ShareTokenController', () => { describe('creating a token', () => { const setup = () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const shareToken = shareTokenFactory.build({ token: 'ctuW1FG0RsTo' }); uc.createShareToken.mockResolvedValue(shareToken); const body = { @@ -84,7 +84,7 @@ describe('ShareTokenController', () => { describe('looking up a token', () => { it('should call the use case', async () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const token = 'ctuW1FG0RsTo'; await controller.lookupShareToken(currentUser, { token }); @@ -93,7 +93,7 @@ describe('ShareTokenController', () => { }); it('should return the token data', async () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const shareTokenInfo: ShareTokenInfoDto = { token: 'ctuW1FG0RsTo', parentType: ShareTokenParentType.Course, @@ -110,7 +110,7 @@ describe('ShareTokenController', () => { describe('importing a share token', () => { const setup = () => { - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const token = 'ctuW1FG0RsTo'; const course = courseFactory.buildWithId(); const status: CopyStatus = { diff --git a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts index d067abf1889..3657b4a92a7 100644 --- a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts +++ b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts @@ -1,11 +1,11 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { OauthConfig, SystemEntity } from '@shared/domain'; import { cleanupCollections, systemFactory } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server'; import { Request } from 'express'; import request, { Response } from 'supertest'; import { PublicSystemListResponse } from '../dto/public-system-list.response'; @@ -14,7 +14,7 @@ import { PublicSystemResponse } from '../dto/public-system-response'; describe('System (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; beforeAll(async () => { const moduleRef: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts b/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts index 6aea7ac2521..27a6a7eb77e 100644 --- a/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts @@ -1,10 +1,14 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; +import { ServerTestModule } from '@modules/server/server.module'; +import { SubmissionStatusListResponse } from '@modules/task/controller/dto/submission.response'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ApiValidationError } from '@shared/common'; import { Permission, Submission } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, courseGroupFactory, @@ -14,10 +18,6 @@ import { taskFactory, userFactory, } from '@shared/testing'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; -import { SubmissionStatusListResponse } from '@modules/task/controller/dto/submission.response'; import { Request } from 'express'; import request from 'supertest'; @@ -58,7 +58,7 @@ class API { describe('Submission Controller (API)', () => { describe('find statuses by task', () => { let app: INestApplication; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let em: EntityManager; @@ -182,7 +182,7 @@ describe('Submission Controller (API)', () => { describe('delete submission', () => { let app: INestApplication; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; let em: EntityManager; let filesStorageClientAdapterService: DeepMocked; diff --git a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts index d5546c435da..7a69fbecdee 100644 --- a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { IConfig } from '@hpi-schul-cloud/commons/lib/interfaces/IConfig'; import { EntityManager } from '@mikro-orm/mongodb'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -30,7 +30,7 @@ import { ServerTestModule } from '@modules/server/server.module'; describe('Task copy (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let configBefore: IConfig; beforeAll(async () => { diff --git a/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts b/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts index 93c79e4015d..4177ce1ed18 100644 --- a/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts @@ -1,8 +1,11 @@ import { EntityManager } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; +import { TaskListResponse } from '@modules/task/controller/dto'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { Permission } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, courseFactory, @@ -12,9 +15,6 @@ import { taskFactory, userFactory, } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; -import { TaskListResponse } from '@modules/task/controller/dto'; import { Request } from 'express'; import request from 'supertest'; @@ -44,7 +44,7 @@ class API { describe('Task controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/task/controller/task.controller.spec.ts b/apps/server/src/modules/task/controller/task.controller.spec.ts index e44deee06c3..219418c521b 100644 --- a/apps/server/src/modules/task/controller/task.controller.spec.ts +++ b/apps/server/src/modules/task/controller/task.controller.spec.ts @@ -1,8 +1,8 @@ import { createMock } from '@golevelup/ts-jest'; -import { Test, TestingModule } from '@nestjs/testing'; -import { ICurrentUser } from '@modules/authentication'; +import { CurrentUserInterface } from '@modules/authentication'; import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { CopyApiResponse } from '@modules/copy-helper/dto/copy.response'; +import { Test, TestingModule } from '@nestjs/testing'; import { TaskCopyUC, TaskUC } from '../uc'; import { TaskController } from './task.controller'; @@ -42,7 +42,7 @@ describe('TaskController', () => { describe('when task should be copied via API call', () => { const setup = () => { // todo: why not use builder instead of as - const currentUser = { userId: 'userId' } as ICurrentUser; + const currentUser = { userId: 'userId' } as CurrentUserInterface; const ucResult = { title: 'example title', type: 'TASK' as CopyElementType, diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts index 2d371f47c9e..56c0075ae97 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts @@ -1,4 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { CurrentUserInterface } from '@modules/authentication'; +import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { IFindOptions, Permission, SortOrder, User } from '@shared/domain'; @@ -8,8 +10,6 @@ import { externalToolFactory, oauth2ToolConfigFactory, } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; -import { ICurrentUser } from '@modules/authentication'; -import { AuthorizationService } from '@modules/authorization'; import { ExternalToolSearchQuery } from '../../common/interface'; import { ExternalTool, Oauth2ToolConfig } from '../domain'; import { ExternalToolLogoService, ExternalToolService, ExternalToolValidationService } from '../service'; @@ -68,7 +68,7 @@ describe('ExternalToolUc', () => { const setupAuthorization = () => { const user: User = userFactory.buildWithId(); - const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; authorizationService.getUserWithPermissions.mockResolvedValue(user); @@ -190,7 +190,7 @@ describe('ExternalToolUc', () => { describe('when fetching logo', () => { const setupLogo = () => { const user: User = userFactory.buildWithId(); - const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; const externalTool: ExternalTool = externalToolFactory.buildWithId(); @@ -414,7 +414,7 @@ describe('ExternalToolUc', () => { describe('when fetching logo', () => { const setupLogo = () => { const user: User = userFactory.buildWithId(); - const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; const externalTool: ExternalTool = externalToolFactory.buildWithId(); @@ -439,7 +439,7 @@ describe('ExternalToolUc', () => { describe('deleteExternalTool', () => { const setupDelete = () => { const toolId = 'toolId'; - const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; const user: User = userFactory.buildWithId(); authorizationService.getUserWithPermissions.mockResolvedValue(user); diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.spec.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.spec.ts index 8f81a1d0eb2..4e80d439a97 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/oauth2-tool-launch.strategy.spec.ts @@ -12,7 +12,7 @@ import { AutoSchoolNumberStrategy, } from '../auto-parameter-strategy'; import { OAuth2ToolLaunchStrategy } from './oauth2-tool-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; describe('OAuth2ToolLaunchStrategy', () => { let module: TestingModule; @@ -61,7 +61,7 @@ describe('OAuth2ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.build(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.build(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, diff --git a/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts b/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts index 29b7796b40d..2b4e8fc25ee 100644 --- a/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts +++ b/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts @@ -1,5 +1,24 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; +import { + FilterImportUserParams, + FilterMatchType, + FilterRoleType, + FilterUserParams, + ImportUserListResponse, + ImportUserResponse, + ImportUserSortOrder, + MatchType, + SortImportUserParams, + UpdateFlagParams, + UpdateMatchParams, + UserMatchListResponse, + UserMatchResponse, + UserRole, +} from '@modules/user-import/controller/dto'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { PaginationParams } from '@shared/controller'; @@ -14,7 +33,6 @@ import { SystemEntity, User, } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; import { cleanupCollections, importUserFactory, @@ -24,31 +42,13 @@ import { systemFactory, userFactory, } from '@shared/testing'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; -import { - FilterImportUserParams, - FilterMatchType, - FilterRoleType, - FilterUserParams, - ImportUserListResponse, - ImportUserResponse, - ImportUserSortOrder, - MatchType, - SortImportUserParams, - UpdateFlagParams, - UpdateMatchParams, - UserMatchListResponse, - UserMatchResponse, - UserRole, -} from '@modules/user-import/controller/dto'; import { Request } from 'express'; import request from 'supertest'; describe('ImportUser Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; const authenticatedUser = async (permissions: Permission[] = [], features: SchoolFeatures[] = []) => { const system = systemFactory.buildWithId(); // TODO no id? diff --git a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts index 8addd2afae6..bb4b76328e5 100644 --- a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts +++ b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts @@ -1,5 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; +import { LegacySchoolService } from '@modules/legacy-school'; +import { UserService } from '@modules/user'; +import { OAuthMigrationError } from '@modules/user-login-migration/error/oauth-migration.error'; import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { ValidationError } from '@shared/common'; @@ -7,10 +11,6 @@ import { LegacySchoolDo, Page, UserDO, UserLoginMigrationDO } from '@shared/doma import { UserLoginMigrationRepo } from '@shared/repo/userloginmigration/user-login-migration.repo'; import { legacySchoolDoFactory, setupEntities, userDoFactory, userLoginMigrationDOFactory } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; -import { ICurrentUser } from '@modules/authentication'; -import { LegacySchoolService } from '@modules/legacy-school'; -import { UserService } from '@modules/user'; -import { OAuthMigrationError } from '@modules/user-login-migration/error/oauth-migration.error'; import { SchoolMigrationService } from './school-migration.service'; describe('SchoolMigrationService', () => { @@ -127,11 +127,11 @@ describe('SchoolMigrationService', () => { const userDO: UserDO = userDoFactory.buildWithId({ schoolId: schoolDO.id }, new ObjectId().toHexString(), {}); - const currentUser: ICurrentUser = { + const currentUser: CurrentUserInterface = { userId: userDO.id, schoolId: userDO.schoolId, systemId: 'systemId', - } as ICurrentUser; + } as CurrentUserInterface; return { externalId: schoolDO.externalId as string, diff --git a/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts b/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts index 28bc7c5d14e..c8f19e289fb 100644 --- a/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts +++ b/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts @@ -2,12 +2,12 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; +import { CurrentUserInterface } from '@modules/authentication'; +import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; +import { ServerTestModule } from '@modules/server/server.module'; import { ApiValidationError } from '@shared/common'; import { LanguageType, User } from '@shared/domain'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; -import { ICurrentUser } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { ServerTestModule } from '@modules/server/server.module'; import { Request } from 'express'; import request from 'supertest'; @@ -85,7 +85,7 @@ describe(baseRouteName, () => { describe('with bad request data', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { @@ -139,7 +139,7 @@ describe(baseRouteName, () => { describe('without valid request data', () => { let app: INestApplication; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts b/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts index 370de7e4fa6..3e89c362d0c 100644 --- a/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts +++ b/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts @@ -5,13 +5,13 @@ import { Test, TestingModule } from '@nestjs/testing'; import { Request } from 'express'; import request from 'supertest'; -import { ApiValidationError } from '@shared/common'; -import { LanguageType } from '@shared/domain'; -import { ICurrentUser } from '@modules/authentication'; -import { cleanupCollections, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; +import { CurrentUserInterface } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ResolvedUserResponse } from '@modules/user/controller/dto'; +import { ApiValidationError } from '@shared/common'; +import { LanguageType } from '@shared/domain'; +import { cleanupCollections, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; const baseRouteName = '/user/me'; @@ -87,7 +87,7 @@ describe(baseRouteName, () => { let app: INestApplication; let orm: MikroORM; let em: EntityManager; - let currentUser: ICurrentUser; + let currentUser: CurrentUserInterface; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts index 6d78b513d75..a2411336426 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts @@ -1,8 +1,8 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; +import { CurrentUserInterface } from '@modules/authentication'; import { Test, TestingModule } from '@nestjs/testing'; import { VideoConferenceScope } from '@shared/domain/interface'; -import { ICurrentUser } from '@modules/authentication'; import { BBBBaseResponse, BBBCreateResponse } from '../bbb'; import { defaultVideoConferenceOptions } from '../interface'; import { VideoConferenceDeprecatedUc } from '../uc'; @@ -18,7 +18,7 @@ describe('VideoConferenceDeprecatedController', () => { let controller: VideoConferenceDeprecatedController; let videoConferenceUc: DeepMocked; - const currentUser: ICurrentUser = { userId: new ObjectId().toHexString() } as ICurrentUser; + const currentUser: CurrentUserInterface = { userId: new ObjectId().toHexString() } as CurrentUserInterface; beforeAll(async () => { module = await Test.createTestingModule({ 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 bf1fd3e1394..ad69aa95a03 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 @@ -1,5 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { CalendarService } from '@infra/calendar'; +import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; +import { CurrentUserInterface } from '@modules/authentication'; +import { AuthorizationReferenceService } from '@modules/authorization/domain'; +import { CourseService } from '@modules/learnroom/service'; +import { LegacySchoolService } from '@modules/legacy-school'; +import { UserService } from '@modules/user'; import { BadRequestException, ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { @@ -14,18 +21,9 @@ import { VideoConferenceDO, } from '@shared/domain'; import { VideoConferenceScope } from '@shared/domain/interface'; -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'; -import { AuthorizationReferenceService } from '@modules/authorization/domain'; -import { ICurrentUser } from '@modules/authentication'; -import { CourseService } from '@modules/learnroom/service'; -import { LegacySchoolService } from '@modules/legacy-school'; -import { UserService } from '@modules/user'; -import { IScopeInfo, VideoConference, VideoConferenceJoin, VideoConferenceState } from './dto'; -import { VideoConferenceDeprecatedUc } from './video-conference-deprecated.uc'; import { BBBBaseMeetingConfig, BBBBaseResponse, @@ -39,8 +37,10 @@ import { BBBStatus, GuestPolicy, } from '../bbb'; -import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; import { ErrorStatus } from '../error/error-status.enum'; +import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; +import { IScopeInfo, VideoConference, VideoConferenceJoin, VideoConferenceState } from './dto'; +import { VideoConferenceDeprecatedUc } from './video-conference-deprecated.uc'; class VideoConferenceDeprecatedUcSpec extends VideoConferenceDeprecatedUc { async getScopeInfoSpec(userId: EntityId, conferenceScope: VideoConferenceScope, refId: string): Promise { @@ -81,7 +81,7 @@ describe('VideoConferenceUc', () => { teamId: 'teamId', }); let featureEnabled = false; - let defaultCurrentUser: ICurrentUser; + let defaultCurrentUser: CurrentUserInterface; let defaultOptions: VideoConferenceOptions; const userPermissions: Map> = new Map>(); diff --git a/apps/server/src/shared/domain/entity/dashboard.entity.ts b/apps/server/src/shared/domain/entity/dashboard.entity.ts index b3165dedf8a..eeeddec70e8 100644 --- a/apps/server/src/shared/domain/entity/dashboard.entity.ts +++ b/apps/server/src/shared/domain/entity/dashboard.entity.ts @@ -1,10 +1,10 @@ -import { NotFoundException, BadRequestException } from '@nestjs/common'; -import { EntityId, LearnroomMetadata } from '@shared/domain/types'; +import { BadRequestException, NotFoundException } from '@nestjs/common'; import { ILearnroom } from '@shared/domain/interface'; +import { EntityId, LearnroomMetadata } from '@shared/domain/types'; const defaultColumns = 4; -export interface IGridElement { +export interface GridElementInterface { hasId(): boolean; getId: () => EntityId | undefined; @@ -34,7 +34,7 @@ export type GridElementContent = { copyingSince?: Date; }; -export class GridElement implements IGridElement { +export class GridElement implements GridElementInterface { id?: EntityId; title?: string; @@ -151,7 +151,7 @@ export type GridPosition = { x: number; y: number }; export type GridPositionWithGroupIndex = { x: number; y: number; groupIndex?: number }; export type GridElementWithPosition = { - gridElement: IGridElement; + gridElement: GridElementInterface; pos: GridPosition; }; @@ -162,7 +162,7 @@ export class DashboardEntity { columns: number; - grid: Map; + grid: Map; userId: EntityId; @@ -181,7 +181,7 @@ export class DashboardEntity { constructor(id: string, props: DashboardProps) { this.columns = props.colums || defaultColumns; - this.grid = new Map(); + this.grid = new Map(); props.grid.forEach((element) => { this.grid.set(this.gridIndexFromPosition(element.pos), element.gridElement); }); @@ -201,7 +201,7 @@ export class DashboardEntity { getGrid(): GridElementWithPosition[] { const result = [...this.grid.keys()].map((key) => { const position = this.positionFromGridIndex(key); - const value = this.grid.get(key) as IGridElement; + const value = this.grid.get(key) as GridElementInterface; return { pos: position, gridElement: value, @@ -210,7 +210,7 @@ export class DashboardEntity { return result; } - getElement(position: GridPosition): IGridElement { + getElement(position: GridPosition): GridElementInterface { const element = this.grid.get(this.gridIndexFromPosition(position)); if (!element) { throw new NotFoundException('no element at grid position'); @@ -239,7 +239,7 @@ export class DashboardEntity { private removeRoomsNotInList(roomList: ILearnroom[]): void { [...this.grid.keys()].forEach((key) => { - const element = this.grid.get(key) as IGridElement; + const element = this.grid.get(key) as GridElementInterface; const currentRooms = element.getReferences(); currentRooms.forEach((room) => { if (!roomList.includes(room)) { @@ -283,7 +283,7 @@ export class DashboardEntity { return i; } - private getReferencesFromPosition(position: GridPositionWithGroupIndex): IGridElement { + private getReferencesFromPosition(position: GridPositionWithGroupIndex): GridElementInterface { const elementToMove = this.getElement(position); if (typeof position.groupIndex === 'number' && elementToMove.isGroup()) { @@ -304,7 +304,7 @@ export class DashboardEntity { } } - private mergeElementIntoPosition(element: IGridElement, position: GridPosition): IGridElement { + private mergeElementIntoPosition(element: GridElementInterface, position: GridPosition): GridElementInterface { const targetElement = this.grid.get(this.gridIndexFromPosition(position)); if (targetElement) { targetElement.addReferences(element.getReferences()); diff --git a/apps/server/src/shared/domain/entity/dashboard.model.entity.ts b/apps/server/src/shared/domain/entity/dashboard.model.entity.ts index b7d6acbe8d6..b0463ff5355 100644 --- a/apps/server/src/shared/domain/entity/dashboard.model.entity.ts +++ b/apps/server/src/shared/domain/entity/dashboard.model.entity.ts @@ -56,7 +56,7 @@ export class DashboardGridElementModel extends BaseEntityWithTimestamps { dashboard: IdentifiedReference; } -export interface IDashboardModelProperties { +export interface DashboardModelProperties { id: string; user: User; gridElements?: DashboardGridElementModel[]; @@ -64,7 +64,7 @@ export interface IDashboardModelProperties { @Entity({ tableName: 'dashboard' }) export class DashboardModelEntity extends BaseEntityWithTimestamps { - constructor(props: IDashboardModelProperties) { + constructor(props: DashboardModelProperties) { super(); this._id = ObjectId.createFromHexString(props.id); this.id = props.id; diff --git a/apps/server/src/shared/domain/entity/federal-state.entity.ts b/apps/server/src/shared/domain/entity/federal-state.entity.ts index d65b36c9826..d7c84567fec 100644 --- a/apps/server/src/shared/domain/entity/federal-state.entity.ts +++ b/apps/server/src/shared/domain/entity/federal-state.entity.ts @@ -1,7 +1,7 @@ import { Embeddable, Embedded, Entity, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from './base.entity'; -export interface IFederalStateProperties { +export interface FederalStateProperties { name: string; abbreviation: string; logoUrl: string; @@ -39,7 +39,7 @@ export class FederalStateEntity extends BaseEntityWithTimestamps { @Embedded(() => County, { array: true, nullable: true }) counties?: County[]; - constructor(props: IFederalStateProperties) { + constructor(props: FederalStateProperties) { super(); this.name = props.name; this.abbreviation = props.abbreviation; diff --git a/apps/server/src/shared/domain/entity/import-user.entity.ts b/apps/server/src/shared/domain/entity/import-user.entity.ts index 09a10179e3d..22d05489da7 100644 --- a/apps/server/src/shared/domain/entity/import-user.entity.ts +++ b/apps/server/src/shared/domain/entity/import-user.entity.ts @@ -7,7 +7,7 @@ import type { User } from './user.entity'; export type IImportUserRoleName = RoleName.ADMINISTRATOR | RoleName.TEACHER | RoleName.STUDENT; -export interface IImportUserProperties { +export interface ImportUserProperties { // references school: SchoolEntity; system: SystemEntity; @@ -35,7 +35,7 @@ export enum MatchCreator { @Unique({ properties: ['school', 'ldapDn'] }) @Unique({ properties: ['school', 'email'] }) export class ImportUser extends BaseEntityWithTimestamps implements IEntityWithSchool { - constructor(props: IImportUserProperties) { + constructor(props: ImportUserProperties) { super(); this.school = wrap(props.school).toReference(); this.system = wrap(props.system).toReference(); diff --git a/apps/server/src/shared/testing/factory/federal-state.factory.ts b/apps/server/src/shared/testing/factory/federal-state.factory.ts index 71290151668..11a685140a5 100644 --- a/apps/server/src/shared/testing/factory/federal-state.factory.ts +++ b/apps/server/src/shared/testing/factory/federal-state.factory.ts @@ -1,7 +1,7 @@ -import { County, FederalStateEntity, IFederalStateProperties } from '@shared/domain'; +import { County, FederalStateEntity, FederalStateProperties } from '@shared/domain'; import { BaseFactory } from './base.factory'; -export const federalStateFactory = BaseFactory.define( +export const federalStateFactory = BaseFactory.define( FederalStateEntity, () => { return { diff --git a/apps/server/src/shared/testing/factory/import-user.factory.ts b/apps/server/src/shared/testing/factory/import-user.factory.ts index 1dd8fd3c024..d2cc011b995 100644 --- a/apps/server/src/shared/testing/factory/import-user.factory.ts +++ b/apps/server/src/shared/testing/factory/import-user.factory.ts @@ -1,14 +1,14 @@ import { v4 as uuidv4 } from 'uuid'; -import { IImportUserProperties, IImportUserRoleName, ImportUser, MatchCreator, RoleName, User } from '@shared/domain'; +import { IImportUserRoleName, ImportUser, ImportUserProperties, MatchCreator, RoleName, User } from '@shared/domain'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; import { schoolFactory } from './school.factory'; import { systemFactory } from './system.factory'; -class ImportUserFactory extends BaseFactory { +class ImportUserFactory extends BaseFactory { matched(matchedBy: MatchCreator, user: User): this { - const params: DeepPartial = { matchedBy, user }; + const params: DeepPartial = { matchedBy, user }; return this.params(params); } } From d55a0db629fe9affd8110bd7aaa395968f0c329b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:48:05 +0100 Subject: [PATCH 047/110] ILessonProperties -> LessonProperties --- apps/server/src/shared/domain/entity/lesson.entity.ts | 6 +++--- apps/server/src/shared/testing/factory/lesson.factory.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index a47aab2a8b3..c7521229dc6 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -6,10 +6,10 @@ import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import { CourseGroup } from './coursegroup.entity'; import { Material } from './materials.entity'; -import { Task } from './task.entity'; import type { ITaskParent } from './task.entity'; +import { Task } from './task.entity'; -export interface ILessonProperties { +export interface LessonProperties { name: string; hidden: boolean; course: Course; @@ -109,7 +109,7 @@ export class LessonEntity extends BaseEntityWithTimestamps implements ILearnroom @OneToMany('Task', 'lesson', { orphanRemoval: true }) tasks = new Collection(this); - constructor(props: ILessonProperties) { + constructor(props: LessonProperties) { super(); this.name = props.name; if (props.hidden !== undefined) this.hidden = props.hidden; diff --git a/apps/server/src/shared/testing/factory/lesson.factory.ts b/apps/server/src/shared/testing/factory/lesson.factory.ts index af7aff56fc1..f736dc556ee 100644 --- a/apps/server/src/shared/testing/factory/lesson.factory.ts +++ b/apps/server/src/shared/testing/factory/lesson.factory.ts @@ -1,11 +1,11 @@ -import { Course, IComponentProperties, ILessonProperties, LessonEntity } from '@shared/domain'; +import { Course, IComponentProperties, LessonEntity, LessonProperties } from '@shared/domain'; import { BaseFactory } from './base.factory'; import { courseFactory } from './course.factory'; -class LessonFactory extends BaseFactory {} +class LessonFactory extends BaseFactory {} -export const lessonFactory = LessonFactory.define( +export const lessonFactory = LessonFactory.define( LessonEntity, ({ sequence, params }) => { let course: Course; From 95fe19ba15392ca0d937a09d648ed805c1654d26 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:50:06 +0100 Subject: [PATCH 048/110] IComponentTextProperties -> ComponentTextProperties --- .../service/common-cartridge-export.service.spec.ts | 12 ++++++------ .../lesson/service/lesson-copy.service.spec.ts | 10 +++++----- .../modules/lesson/service/lesson-copy.service.ts | 12 ++++++------ .../server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts index af1bc727d6a..fb1919e1d17 100644 --- a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts @@ -1,18 +1,18 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { CourseService } from '@modules/learnroom/service'; +import { CommonCartridgeExportService } from '@modules/learnroom/service/common-cartridge-export.service'; +import { LessonService } from '@modules/lesson/service'; +import { TaskService } from '@modules/task/service/task.service'; import { Test, TestingModule } from '@nestjs/testing'; import { + ComponentTextProperties, ComponentType, Course, IComponentProperties, - IComponentTextProperties, LessonEntity, Task, } from '@shared/domain'; import { courseFactory, lessonFactory, setupEntities, taskFactory } from '@shared/testing'; -import { CommonCartridgeExportService } from '@modules/learnroom/service/common-cartridge-export.service'; -import { CourseService } from '@modules/learnroom/service'; -import { LessonService } from '@modules/lesson/service'; -import { TaskService } from '@modules/task/service/task.service'; import AdmZip from 'adm-zip'; import { CommonCartridgeVersion } from '../common-cartridge'; @@ -87,7 +87,7 @@ describe('CommonCartridgeExportService', () => { describe('exportCourse', () => { const setupExport = async (version: CommonCartridgeVersion) => { const [lesson] = lessons; - const textContent = { text: 'Some random text' } as IComponentTextProperties; + const textContent = { text: 'Some random text' } as ComponentTextProperties; const lessonContent: IComponentProperties = { _id: 'random_id', title: 'A random title', diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index 34392c91c0c..03bb3eb22ee 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -1,8 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; +import { CopyElementType, CopyHelperService, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; +import { CopyFilesService } from '@modules/files-storage-client'; +import { TaskCopyService } from '@modules/task/service'; import { Test, TestingModule } from '@nestjs/testing'; import { BaseEntity, + ComponentTextProperties, ComponentType, EntityId, IComponentEtherpadProperties, @@ -10,7 +14,6 @@ import { IComponentInternalProperties, IComponentNexboardProperties, IComponentProperties, - IComponentTextProperties, LessonEntity, Material, } from '@shared/domain'; @@ -24,9 +27,6 @@ import { taskFactory, userFactory, } from '@shared/testing'; -import { CopyElementType, CopyHelperService, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; -import { CopyFilesService } from '@modules/files-storage-client'; -import { TaskCopyService } from '@modules/task/service'; import { EtherpadService } from './etherpad.service'; import { LessonCopyService } from './lesson-copy.service'; import { NexboardService } from './nexboard.service'; @@ -467,7 +467,7 @@ describe('lesson copy service', () => { const lessonCopy = status.copyEntity as LessonEntity; const contentsStatus = status.elements?.find((el) => el.type === CopyElementType.LESSON_CONTENT_GROUP); expect(contentsStatus).toBeDefined(); - expect((lessonCopy.contents[0].content as IComponentTextProperties).text).not.toContain(FILE_ID_TO_BE_REPLACED); + expect((lessonCopy.contents[0].content as ComponentTextProperties).text).not.toContain(FILE_ID_TO_BE_REPLACED); }); }); diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index b6d7e7849c7..3b9973d67b5 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -1,21 +1,21 @@ import { Configuration } from '@hpi-schul-cloud/commons'; +import { CopyDictionary, CopyElementType, CopyHelperService, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; +import { CopyFilesService } from '@modules/files-storage-client'; +import { FileUrlReplacement } from '@modules/files-storage-client/service/copy-files.service'; +import { TaskCopyService } from '@modules/task/service/task-copy.service'; import { Injectable } from '@nestjs/common'; import { + ComponentTextProperties, ComponentType, IComponentEtherpadProperties, IComponentGeogebraProperties, IComponentLernstoreProperties, IComponentNexboardProperties, IComponentProperties, - IComponentTextProperties, LessonEntity, Material, } from '@shared/domain'; import { LessonRepo } from '@shared/repo'; -import { CopyDictionary, CopyElementType, CopyHelperService, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; -import { CopyFilesService } from '@modules/files-storage-client'; -import { FileUrlReplacement } from '@modules/files-storage-client/service/copy-files.service'; -import { TaskCopyService } from '@modules/task/service/task-copy.service'; import { randomBytes } from 'crypto'; import { LessonCopyParams } from '../types'; import { EtherpadService } from './etherpad.service'; @@ -254,7 +254,7 @@ export class LessonCopyService { component: ComponentType.TEXT, user: element.user, // TODO should be params.user - but that made the server crash, but property is normally undefined content: { - text: (element.content as IComponentTextProperties).text, + text: (element.content as ComponentTextProperties).text, }, }; } diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index c7521229dc6..6a7eeb44f40 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -28,7 +28,7 @@ export enum ComponentType { NEXBOARD = 'neXboard', } -export interface IComponentTextProperties { +export interface ComponentTextProperties { text: string; } @@ -69,7 +69,7 @@ export type IComponentProperties = { hidden: boolean; user?: EntityId; } & ( - | { component: ComponentType.TEXT; content: IComponentTextProperties } + | { component: ComponentType.TEXT; content: ComponentTextProperties } | { component: ComponentType.ETHERPAD; content: IComponentEtherpadProperties } | { component: ComponentType.GEOGEBRA; content: IComponentGeogebraProperties } | { component: ComponentType.INTERNAL; content: IComponentInternalProperties } From 88cd247d02b399950f81dcba05edc8aca684e9fb Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:50:38 +0100 Subject: [PATCH 049/110] IComponentTextProperties -> ComponentTextProperties --- .../src/modules/lesson/service/lesson-copy.service.spec.ts | 4 ++-- apps/server/src/modules/lesson/service/lesson-copy.service.ts | 4 ++-- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index 03bb3eb22ee..f3c6ead207e 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -6,11 +6,11 @@ import { TaskCopyService } from '@modules/task/service'; import { Test, TestingModule } from '@nestjs/testing'; import { BaseEntity, + ComponentGeogebraProperties, ComponentTextProperties, ComponentType, EntityId, IComponentEtherpadProperties, - IComponentGeogebraProperties, IComponentInternalProperties, IComponentNexboardProperties, IComponentProperties, @@ -612,7 +612,7 @@ describe('lesson copy service', () => { }); const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; - const geoGebraContent = lessonContents[0].content as IComponentGeogebraProperties; + const geoGebraContent = lessonContents[0].content as ComponentGeogebraProperties; expect(geoGebraContent.materialId).toEqual(''); }); diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index 3b9973d67b5..4d7cb338ed1 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -5,10 +5,10 @@ import { FileUrlReplacement } from '@modules/files-storage-client/service/copy-f import { TaskCopyService } from '@modules/task/service/task-copy.service'; import { Injectable } from '@nestjs/common'; import { + ComponentGeogebraProperties, ComponentTextProperties, ComponentType, IComponentEtherpadProperties, - IComponentGeogebraProperties, IComponentLernstoreProperties, IComponentNexboardProperties, IComponentProperties, @@ -290,7 +290,7 @@ export class LessonCopyService { private static copyGeogebra(originalElement: IComponentProperties): IComponentProperties { const copy = { ...originalElement, hidden: true } as IComponentProperties; - copy.content = { ...copy.content, materialId: '' } as IComponentGeogebraProperties; + copy.content = { ...copy.content, materialId: '' } as ComponentGeogebraProperties; delete copy._id; return copy; } diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index 6a7eeb44f40..14ab5d6ccd7 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -32,7 +32,7 @@ export interface ComponentTextProperties { text: string; } -export interface IComponentGeogebraProperties { +export interface ComponentGeogebraProperties { materialId: string; } @@ -71,7 +71,7 @@ export type IComponentProperties = { } & ( | { component: ComponentType.TEXT; content: ComponentTextProperties } | { component: ComponentType.ETHERPAD; content: IComponentEtherpadProperties } - | { component: ComponentType.GEOGEBRA; content: IComponentGeogebraProperties } + | { component: ComponentType.GEOGEBRA; content: ComponentGeogebraProperties } | { component: ComponentType.INTERNAL; content: IComponentInternalProperties } | { component: ComponentType.LERNSTORE; content?: IComponentLernstoreProperties } | { component: ComponentType.NEXBOARD; content: IComponentNexboardProperties } From 78be73ade9374c8a1abc11ba79005dcc98a9eecd Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:51:54 +0100 Subject: [PATCH 050/110] IComponentLernstoreProperties -> ComponentLernstoreProperties --- .../src/modules/lesson/service/lesson-copy.service.ts | 6 +++--- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index 4d7cb338ed1..9c22d4642f2 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -6,10 +6,10 @@ import { TaskCopyService } from '@modules/task/service/task-copy.service'; import { Injectable } from '@nestjs/common'; import { ComponentGeogebraProperties, + ComponentLernstoreProperties, ComponentTextProperties, ComponentType, IComponentEtherpadProperties, - IComponentLernstoreProperties, IComponentNexboardProperties, IComponentProperties, LessonEntity, @@ -268,7 +268,7 @@ export class LessonCopyService { }; if (element.content) { - const resources = ((element.content as IComponentLernstoreProperties).resources ?? []).map( + const resources = ((element.content as ComponentLernstoreProperties).resources ?? []).map( ({ client, description, merlinReference, title, url }) => { const result = { client, @@ -281,7 +281,7 @@ export class LessonCopyService { } ); - const lernstoreContent: IComponentLernstoreProperties = { resources }; + const lernstoreContent: ComponentLernstoreProperties = { resources }; lernstore.content = lernstoreContent; } diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index 14ab5d6ccd7..a84a3d15fb8 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -36,7 +36,7 @@ export interface ComponentGeogebraProperties { materialId: string; } -export interface IComponentLernstoreProperties { +export interface ComponentLernstoreProperties { resources: { client: string; description: string; @@ -73,7 +73,7 @@ export type IComponentProperties = { | { component: ComponentType.ETHERPAD; content: IComponentEtherpadProperties } | { component: ComponentType.GEOGEBRA; content: ComponentGeogebraProperties } | { component: ComponentType.INTERNAL; content: IComponentInternalProperties } - | { component: ComponentType.LERNSTORE; content?: IComponentLernstoreProperties } + | { component: ComponentType.LERNSTORE; content?: ComponentLernstoreProperties } | { component: ComponentType.NEXBOARD; content: IComponentNexboardProperties } ); From 4422b5156d7e134694211d8cb3a0bcf1a4228ac1 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:53:52 +0100 Subject: [PATCH 051/110] IComponentEtherpadProperties -> ComponentEtherpadProperties --- .../src/modules/lesson/service/lesson-copy.service.spec.ts | 4 ++-- apps/server/src/modules/lesson/service/lesson-copy.service.ts | 4 ++-- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index f3c6ead207e..ce668ab8a53 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -6,11 +6,11 @@ import { TaskCopyService } from '@modules/task/service'; import { Test, TestingModule } from '@nestjs/testing'; import { BaseEntity, + ComponentEtherpadProperties, ComponentGeogebraProperties, ComponentTextProperties, ComponentType, EntityId, - IComponentEtherpadProperties, IComponentInternalProperties, IComponentNexboardProperties, IComponentProperties, @@ -912,7 +912,7 @@ describe('lesson copy service', () => { user, }); const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; - const copiedEtherpad = copiedLessonContents[0].content as IComponentEtherpadProperties; + const copiedEtherpad = copiedLessonContents[0].content as ComponentEtherpadProperties; expect(copiedEtherpad.url).toEqual('http://pad.uri/abc'); }); diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index 9c22d4642f2..da73bd0a4d7 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -5,11 +5,11 @@ import { FileUrlReplacement } from '@modules/files-storage-client/service/copy-f import { TaskCopyService } from '@modules/task/service/task-copy.service'; import { Injectable } from '@nestjs/common'; import { + ComponentEtherpadProperties, ComponentGeogebraProperties, ComponentLernstoreProperties, ComponentTextProperties, ComponentType, - IComponentEtherpadProperties, IComponentNexboardProperties, IComponentProperties, LessonEntity, @@ -301,7 +301,7 @@ export class LessonCopyService { ): Promise { const copy = { ...originalElement } as IComponentProperties; delete copy._id; - const content = { ...copy.content, url: '' } as IComponentEtherpadProperties; + const content = { ...copy.content, url: '' } as ComponentEtherpadProperties; content.title = randomBytes(12).toString('hex'); const etherpadPadId = await this.etherpadService.createEtherpad( diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index a84a3d15fb8..d12f523e030 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -46,7 +46,7 @@ export interface ComponentLernstoreProperties { }[]; } -export interface IComponentEtherpadProperties { +export interface ComponentEtherpadProperties { description: string; title: string; url: string; @@ -70,7 +70,7 @@ export type IComponentProperties = { user?: EntityId; } & ( | { component: ComponentType.TEXT; content: ComponentTextProperties } - | { component: ComponentType.ETHERPAD; content: IComponentEtherpadProperties } + | { component: ComponentType.ETHERPAD; content: ComponentEtherpadProperties } | { component: ComponentType.GEOGEBRA; content: ComponentGeogebraProperties } | { component: ComponentType.INTERNAL; content: IComponentInternalProperties } | { component: ComponentType.LERNSTORE; content?: ComponentLernstoreProperties } From 121b3e18bfe93becaf436549bcbd12e196a19ae5 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:56:02 +0100 Subject: [PATCH 052/110] IComponentInternalProperties -> ComponentInternalProperties --- .../lesson/service/lesson-copy.service.spec.ts | 12 ++++++------ .../modules/lesson/service/lesson-copy.service.ts | 4 ++-- .../server/src/shared/domain/entity/lesson.entity.ts | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index ce668ab8a53..1545d78f6cf 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -8,11 +8,11 @@ import { BaseEntity, ComponentEtherpadProperties, ComponentGeogebraProperties, + ComponentInternalProperties, + ComponentNexboardProperties, ComponentTextProperties, ComponentType, EntityId, - IComponentInternalProperties, - IComponentNexboardProperties, IComponentProperties, LessonEntity, Material, @@ -1103,7 +1103,7 @@ describe('lesson copy service', () => { user, }); const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; - const copiedNexboard = copiedLessonContents[0].content as IComponentNexboardProperties; + const copiedNexboard = copiedLessonContents[0].content as ComponentNexboardProperties; expect(copiedNexboard.url).toEqual('abc'); expect(copiedNexboard.board).toEqual('123'); }); @@ -1388,8 +1388,8 @@ describe('lesson copy service', () => { throw new Error('lesson should be part of the copy'); } const content = lesson.contents.find((el) => el.component === ComponentType.INTERNAL); - expect((content?.content as IComponentInternalProperties).url).not.toContain(originalTask.id); - expect((content?.content as IComponentInternalProperties).url).toContain(copiedTask.id); + expect((content?.content as ComponentInternalProperties).url).not.toContain(originalTask.id); + expect((content?.content as ComponentInternalProperties).url).toContain(copiedTask.id); }); it('should maintain order of content elements', () => { @@ -1413,7 +1413,7 @@ describe('lesson copy service', () => { throw new Error('lesson should be part of the copy'); } const content = lesson.contents.find((el) => el.component === ComponentType.INTERNAL); - expect((content?.content as IComponentInternalProperties).url).toEqual( + expect((content?.content as ComponentInternalProperties).url).toEqual( `http://somebasedomain.de/homeworks/${originalTask.id}` ); }); diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index da73bd0a4d7..04b3b0418d2 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -8,9 +8,9 @@ import { ComponentEtherpadProperties, ComponentGeogebraProperties, ComponentLernstoreProperties, + ComponentNexboardProperties, ComponentTextProperties, ComponentType, - IComponentNexboardProperties, IComponentProperties, LessonEntity, Material, @@ -324,7 +324,7 @@ export class LessonCopyService { ): Promise { const copy = { ...originalElement } as IComponentProperties; delete copy._id; - const content = { ...copy.content, url: '', board: '' } as IComponentNexboardProperties; + const content = { ...copy.content, url: '', board: '' } as ComponentNexboardProperties; const nexboard = await this.nexboardService.createNexboard(params.user.id, content.title, content.description); if (nexboard) { diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index d12f523e030..d150a21ee3c 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -52,14 +52,14 @@ export interface ComponentEtherpadProperties { url: string; } -export interface IComponentNexboardProperties { +export interface ComponentNexboardProperties { board: string; description: string; title: string; url: string; } -export interface IComponentInternalProperties { +export interface ComponentInternalProperties { url: string; } @@ -72,9 +72,9 @@ export type IComponentProperties = { | { component: ComponentType.TEXT; content: ComponentTextProperties } | { component: ComponentType.ETHERPAD; content: ComponentEtherpadProperties } | { component: ComponentType.GEOGEBRA; content: ComponentGeogebraProperties } - | { component: ComponentType.INTERNAL; content: IComponentInternalProperties } + | { component: ComponentType.INTERNAL; content: ComponentInternalProperties } | { component: ComponentType.LERNSTORE; content?: ComponentLernstoreProperties } - | { component: ComponentType.NEXBOARD; content: IComponentNexboardProperties } + | { component: ComponentType.NEXBOARD; content: ComponentNexboardProperties } ); export interface ILessonParent { From 8b96f099b08c8051e02b43ac89126f408cf192e9 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 09:57:51 +0100 Subject: [PATCH 053/110] IComponentProperties -> ComponentProperties --- .../service/copy-files.service.spec.ts | 10 ++-- .../common-cartridge-export.service.spec.ts | 12 ++--- .../common-cartridge-export.service.ts | 10 ++-- .../service/lesson-copy.service.spec.ts | 44 ++++++++--------- .../lesson/service/lesson-copy.service.ts | 47 +++++++++---------- .../lesson/service/lesson.service.spec.ts | 10 ++-- .../modules/lesson/service/lesson.service.ts | 6 +-- .../domain/entity/lesson.entity.spec.ts | 4 +- .../src/shared/domain/entity/lesson.entity.ts | 8 ++-- .../lesson/lesson.repo.integration.spec.ts | 6 +-- .../shared/testing/factory/lesson.factory.ts | 4 +- 11 files changed, 79 insertions(+), 82 deletions(-) diff --git a/apps/server/src/modules/files-storage-client/service/copy-files.service.spec.ts b/apps/server/src/modules/files-storage-client/service/copy-files.service.spec.ts index 5bfc98a361a..24de3426bc9 100644 --- a/apps/server/src/modules/files-storage-client/service/copy-files.service.spec.ts +++ b/apps/server/src/modules/files-storage-client/service/copy-files.service.spec.ts @@ -1,14 +1,14 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { CopyElementType, CopyHelperService } from '@modules/copy-helper'; import { Test, TestingModule } from '@nestjs/testing'; -import { ComponentType, IComponentProperties } from '@shared/domain'; +import { ComponentProperties, ComponentType } from '@shared/domain'; import { courseFactory, + legacyFileEntityMockFactory, lessonFactory, schoolFactory, - legacyFileEntityMockFactory, setupEntities, } from '@shared/testing'; -import { CopyElementType, CopyHelperService } from '@modules/copy-helper'; import { CopyFilesService } from './copy-files.service'; import { FilesStorageClientAdapterService } from './files-storage-client.service'; @@ -69,13 +69,13 @@ describe('copy files service', () => { const lessonSetup = () => { const { school, imageHTML1, imageHTML2 } = setup(); const originalCourse = courseFactory.build({ school }); - const textContent: IComponentProperties = { + const textContent: ComponentProperties = { title: '', hidden: false, component: ComponentType.TEXT, content: { text: `${imageHTML1} test abschnitt ${imageHTML2}` }, }; - const geoGebraContent: IComponentProperties = { + const geoGebraContent: ComponentProperties = { title: 'geoGebra component 1', hidden: false, component: ComponentType.GEOGEBRA, diff --git a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts index fb1919e1d17..8cd788f7793 100644 --- a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts +++ b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.spec.ts @@ -5,10 +5,10 @@ import { LessonService } from '@modules/lesson/service'; import { TaskService } from '@modules/task/service/task.service'; import { Test, TestingModule } from '@nestjs/testing'; import { + ComponentProperties, ComponentTextProperties, ComponentType, Course, - IComponentProperties, LessonEntity, Task, } from '@shared/domain'; @@ -59,22 +59,22 @@ describe('CommonCartridgeExportService', () => { content: { text: 'text', }, - } as IComponentProperties, + } as ComponentProperties, { component: ComponentType.ETHERPAD, title: 'Etherpad', content: { url: 'url', }, - } as IComponentProperties, + } as ComponentProperties, { component: ComponentType.GEOGEBRA, title: 'Geogebra', content: { materialId: 'materialId', }, - } as IComponentProperties, - {} as IComponentProperties, + } as ComponentProperties, + {} as ComponentProperties, ], }); tasks = taskFactory.buildListWithId(5); @@ -88,7 +88,7 @@ describe('CommonCartridgeExportService', () => { const setupExport = async (version: CommonCartridgeVersion) => { const [lesson] = lessons; const textContent = { text: 'Some random text' } as ComponentTextProperties; - const lessonContent: IComponentProperties = { + const lessonContent: ComponentProperties = { _id: 'random_id', title: 'A random title', hidden: false, diff --git a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.ts b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.ts index e25d2a62367..4da9bfeedd0 100644 --- a/apps/server/src/modules/learnroom/service/common-cartridge-export.service.ts +++ b/apps/server/src/modules/learnroom/service/common-cartridge-export.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from '@nestjs/common'; -import { Course, EntityId, IComponentProperties, Task } from '@shared/domain'; import { LessonService } from '@modules/lesson/service'; -import { ComponentType } from '@src/shared/domain/entity/lesson.entity'; import { TaskService } from '@modules/task/service'; +import { Injectable } from '@nestjs/common'; +import { ComponentProperties, Course, EntityId, Task } from '@shared/domain'; +import { ComponentType } from '@src/shared/domain/entity/lesson.entity'; import { CommonCartridgeFileBuilder, CommonCartridgeIntendedUseType, @@ -11,8 +11,8 @@ import { ICommonCartridgeResourceProps, ICommonCartridgeWebContentResourceProps, } from '../common-cartridge'; -import { CourseService } from './course.service'; import { createIdentifier } from '../common-cartridge/utils'; +import { CourseService } from './course.service'; @Injectable() export class CommonCartridgeExportService { @@ -84,7 +84,7 @@ export class CommonCartridgeExportService { private mapContentToResource( lessonId: string, - content: IComponentProperties, + content: ComponentProperties, version: CommonCartridgeVersion ): ICommonCartridgeResourceProps | undefined { const commonProps = { diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts index 1545d78f6cf..9f94c52c725 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.spec.ts @@ -10,10 +10,10 @@ import { ComponentGeogebraProperties, ComponentInternalProperties, ComponentNexboardProperties, + ComponentProperties, ComponentTextProperties, ComponentType, EntityId, - IComponentProperties, LessonEntity, Material, } from '@shared/domain'; @@ -304,7 +304,7 @@ describe('lesson copy service', () => { describe('when lesson contains at least one content element', () => { const setup = () => { - const contentOne: IComponentProperties = { + const contentOne: ComponentProperties = { title: 'title component 1', hidden: false, component: ComponentType.TEXT, @@ -312,7 +312,7 @@ describe('lesson copy service', () => { text: 'this is a text content', }, }; - const contentTwo: IComponentProperties = { + const contentTwo: ComponentProperties = { title: 'title component 2', hidden: false, component: ComponentType.LERNSTORE, @@ -405,7 +405,7 @@ describe('lesson copy service', () => { describe('when lesson contains text content element', () => { const setup = (text = 'this is a text content') => { - const textContent: IComponentProperties = { + const textContent: ComponentProperties = { title: 'text component 1', hidden: false, component: ComponentType.TEXT, @@ -473,7 +473,7 @@ describe('lesson copy service', () => { describe('when lesson contains LernStore content element', () => { const setup = () => { - const lernStoreContent: IComponentProperties = { + const lernStoreContent: ComponentProperties = { title: 'text component 1', hidden: false, component: ComponentType.LERNSTORE, @@ -510,7 +510,7 @@ describe('lesson copy service', () => { user, }); - const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const copiedLessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(copiedLessonContents[0]).toEqual(lernStoreContent); }); @@ -533,7 +533,7 @@ describe('lesson copy service', () => { describe('when lesson contains LernStore content element without set resource', () => { const setup = () => { - const lernStoreContent: IComponentProperties = { + const lernStoreContent: ComponentProperties = { title: 'text component 1', hidden: false, component: ComponentType.LERNSTORE, @@ -559,7 +559,7 @@ describe('lesson copy service', () => { user, }); - const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const copiedLessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(copiedLessonContents[0]).toEqual(lernStoreContent); }); @@ -582,7 +582,7 @@ describe('lesson copy service', () => { describe('when lesson contains geoGebra content element', () => { const setup = () => { - const geoGebraContent: IComponentProperties = { + const geoGebraContent: ComponentProperties = { title: 'text component 1', hidden: false, component: ComponentType.GEOGEBRA, @@ -611,7 +611,7 @@ describe('lesson copy service', () => { user, }); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; const geoGebraContent = lessonContents[0].content as ComponentGeogebraProperties; expect(geoGebraContent.materialId).toEqual(''); @@ -626,7 +626,7 @@ describe('lesson copy service', () => { user, }); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(lessonContents[0].hidden).toEqual(true); }); @@ -815,7 +815,7 @@ describe('lesson copy service', () => { describe('when lesson contains Etherpad content element', () => { const setup = () => { - const etherpadContent: IComponentProperties = { + const etherpadContent: ComponentProperties = { title: 'text', hidden: false, component: ComponentType.ETHERPAD, @@ -859,7 +859,7 @@ describe('lesson copy service', () => { user, }); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(configurationSpy).toHaveBeenCalledWith('FEATURE_ETHERPAD_ENABLED'); expect(etherpadService.createEtherpad).not.toHaveBeenCalled(); expect(lessonContents).toEqual([]); @@ -897,7 +897,7 @@ describe('lesson copy service', () => { } expect(contentStatus).toEqual(CopyStatusEnum.FAIL); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(lessonContents.length).toEqual(0); }); @@ -911,7 +911,7 @@ describe('lesson copy service', () => { destinationCourse, user, }); - const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const copiedLessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; const copiedEtherpad = copiedLessonContents[0].content as ComponentEtherpadProperties; expect(copiedEtherpad.url).toEqual('http://pad.uri/abc'); }); @@ -939,7 +939,7 @@ describe('lesson copy service', () => { const user = userFactory.build(); const originalCourse = courseFactory.build({ school: user.school, teachers: [user] }); const destinationCourse = courseFactory.build({ school: user.school, teachers: [user] }); - const embeddedTaskContent: IComponentProperties = { + const embeddedTaskContent: ComponentProperties = { title: 'title', hidden: false, component: ComponentType.INTERNAL, @@ -1008,7 +1008,7 @@ describe('lesson copy service', () => { describe('when lesson contains neXboard content element', () => { const setup = () => { - const nexboardContent: IComponentProperties = { + const nexboardContent: ComponentProperties = { title: 'text', hidden: false, component: ComponentType.NEXBOARD, @@ -1050,7 +1050,7 @@ describe('lesson copy service', () => { user, }); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(configurationSpy).toHaveBeenCalledWith('FEATURE_NEXBOARD_ENABLED'); expect(nexboardService.createNexboard).not.toHaveBeenCalled(); expect(lessonContents).toEqual([]); @@ -1088,7 +1088,7 @@ describe('lesson copy service', () => { } expect(contentStatus).toEqual(CopyStatusEnum.FAIL); - const lessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const lessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; expect(lessonContents.length).toEqual(0); }); @@ -1102,7 +1102,7 @@ describe('lesson copy service', () => { destinationCourse, user, }); - const copiedLessonContents = (status.copyEntity as LessonEntity).contents as IComponentProperties[]; + const copiedLessonContents = (status.copyEntity as LessonEntity).contents as ComponentProperties[]; const copiedNexboard = copiedLessonContents[0].content as ComponentNexboardProperties; expect(copiedNexboard.url).toEqual('abc'); expect(copiedNexboard.board).toEqual('123'); @@ -1324,7 +1324,7 @@ describe('lesson copy service', () => { const copiedLesson = lessonFactory.buildWithId(); const originalTask = taskFactory.buildWithId({ lesson: originalLesson }); const copiedTask = taskFactory.buildWithId({ lesson: copiedLesson }); - const embeddedTaskContent: IComponentProperties = { + const embeddedTaskContent: ComponentProperties = { title: 'title', hidden: false, component: ComponentType.INTERNAL, @@ -1332,7 +1332,7 @@ describe('lesson copy service', () => { url: `http://somebasedomain.de/homeworks/${originalTask.id}`, }, }; - const textContent: IComponentProperties = { + const textContent: ComponentProperties = { title: 'title component', hidden: false, component: ComponentType.TEXT, diff --git a/apps/server/src/modules/lesson/service/lesson-copy.service.ts b/apps/server/src/modules/lesson/service/lesson-copy.service.ts index 04b3b0418d2..5dfb80e8d50 100644 --- a/apps/server/src/modules/lesson/service/lesson-copy.service.ts +++ b/apps/server/src/modules/lesson/service/lesson-copy.service.ts @@ -9,9 +9,9 @@ import { ComponentGeogebraProperties, ComponentLernstoreProperties, ComponentNexboardProperties, + ComponentProperties, ComponentTextProperties, ComponentType, - IComponentProperties, LessonEntity, Material, } from '@shared/domain'; @@ -109,7 +109,7 @@ export class LessonCopyService { return lessonStatus; } - copiedLesson.contents = copiedLesson.contents.map((value: IComponentProperties) => + copiedLesson.contents = copiedLesson.contents.map((value: ComponentProperties) => this.updateCopiedEmbeddedTaskId(value, copyDict) ); @@ -118,10 +118,7 @@ export class LessonCopyService { return lessonStatus; } - private updateCopiedEmbeddedTaskId = ( - value: IComponentProperties, - copyDict: CopyDictionary - ): IComponentProperties => { + private updateCopiedEmbeddedTaskId = (value: ComponentProperties, copyDict: CopyDictionary): ComponentProperties => { if (value.component !== ComponentType.INTERNAL || value.content === undefined || value.content.url === undefined) { return value; } @@ -145,10 +142,10 @@ export class LessonCopyService { }; private replaceUrlsInContents( - contents: IComponentProperties[], + contents: ComponentProperties[], fileUrlReplacements: FileUrlReplacement[] - ): IComponentProperties[] { - contents = contents.map((item: IComponentProperties) => { + ): ComponentProperties[] { + contents = contents.map((item: ComponentProperties) => { if (item.component === 'text' && item.content && 'text' in item.content && item.content.text) { let { text } = item.content; fileUrlReplacements.forEach(({ regex, replacement }) => { @@ -163,15 +160,15 @@ export class LessonCopyService { } private async copyLessonContent( - content: IComponentProperties[], + content: ComponentProperties[], params: LessonCopyParams ): Promise<{ - copiedContent: IComponentProperties[]; + copiedContent: ComponentProperties[]; contentStatus: CopyStatus[]; }> { const etherpadEnabled = Configuration.get('FEATURE_ETHERPAD_ENABLED') as boolean; const nexboardEnabled = Configuration.get('FEATURE_NEXBOARD_ENABLED') as boolean; - const copiedContent: IComponentProperties[] = []; + const copiedContent: ComponentProperties[] = []; const copiedContentStatus: CopyStatus[] = []; for (let i = 0; i < content.length; i += 1) { const element = content[i]; @@ -247,7 +244,7 @@ export class LessonCopyService { return { copiedContent, contentStatus }; } - private copyTextContent(element: IComponentProperties): IComponentProperties { + private copyTextContent(element: ComponentProperties): ComponentProperties { return { title: element.title, hidden: element.hidden, @@ -259,8 +256,8 @@ export class LessonCopyService { }; } - private copyLernStore(element: IComponentProperties): IComponentProperties { - const lernstore: IComponentProperties = { + private copyLernStore(element: ComponentProperties): ComponentProperties { + const lernstore: ComponentProperties = { title: element.title, hidden: element.hidden, component: ComponentType.LERNSTORE, @@ -288,18 +285,18 @@ export class LessonCopyService { return lernstore; } - private static copyGeogebra(originalElement: IComponentProperties): IComponentProperties { - const copy = { ...originalElement, hidden: true } as IComponentProperties; + private static copyGeogebra(originalElement: ComponentProperties): ComponentProperties { + const copy = { ...originalElement, hidden: true } as ComponentProperties; copy.content = { ...copy.content, materialId: '' } as ComponentGeogebraProperties; delete copy._id; return copy; } private async copyEtherpad( - originalElement: IComponentProperties, + originalElement: ComponentProperties, params: LessonCopyParams - ): Promise { - const copy = { ...originalElement } as IComponentProperties; + ): Promise { + const copy = { ...originalElement } as ComponentProperties; delete copy._id; const content = { ...copy.content, url: '' } as ComponentEtherpadProperties; content.title = randomBytes(12).toString('hex'); @@ -319,10 +316,10 @@ export class LessonCopyService { } private async copyNexboard( - originalElement: IComponentProperties, + originalElement: ComponentProperties, params: LessonCopyParams - ): Promise { - const copy = { ...originalElement } as IComponentProperties; + ): Promise { + const copy = { ...originalElement } as ComponentProperties; delete copy._id; const content = { ...copy.content, url: '', board: '' } as ComponentNexboardProperties; @@ -389,8 +386,8 @@ export class LessonCopyService { return { copiedMaterials, materialsStatus }; } - private copyEmbeddedTaskLink(originalElement: IComponentProperties) { - const copy = JSON.parse(JSON.stringify(originalElement)) as IComponentProperties; + private copyEmbeddedTaskLink(originalElement: ComponentProperties) { + const copy = JSON.parse(JSON.stringify(originalElement)) as ComponentProperties; delete copy._id; return copy; } diff --git a/apps/server/src/modules/lesson/service/lesson.service.spec.ts b/apps/server/src/modules/lesson/service/lesson.service.spec.ts index a94ecfe9c8b..fb0a6daceb7 100644 --- a/apps/server/src/modules/lesson/service/lesson.service.spec.ts +++ b/apps/server/src/modules/lesson/service/lesson.service.spec.ts @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { ObjectId } from '@mikro-orm/mongodb'; +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { Test, TestingModule } from '@nestjs/testing'; +import { ComponentProperties, ComponentType } from '@shared/domain'; import { LessonRepo } from '@shared/repo'; import { lessonFactory, setupEntities } from '@shared/testing'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; -import { ObjectId } from '@mikro-orm/mongodb'; -import { ComponentType, IComponentProperties } from '@shared/domain'; import { LessonService } from './lesson.service'; describe('LessonService', () => { @@ -81,7 +81,7 @@ describe('LessonService', () => { describe('when finding by userId', () => { const setup = () => { const userId = new ObjectId().toHexString(); - const contentExample: IComponentProperties = { + const contentExample: ComponentProperties = { title: 'title', hidden: false, user: userId, @@ -122,7 +122,7 @@ describe('LessonService', () => { describe('when deleting by userId', () => { const setup = () => { const userId = new ObjectId().toHexString(); - const contentExample: IComponentProperties = { + const contentExample: ComponentProperties = { title: 'title', hidden: false, user: userId, diff --git a/apps/server/src/modules/lesson/service/lesson.service.ts b/apps/server/src/modules/lesson/service/lesson.service.ts index 2dee6f05563..28c24cc00c1 100644 --- a/apps/server/src/modules/lesson/service/lesson.service.ts +++ b/apps/server/src/modules/lesson/service/lesson.service.ts @@ -1,7 +1,7 @@ +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { Injectable } from '@nestjs/common'; -import { Counted, EntityId, IComponentProperties, LessonEntity } from '@shared/domain'; +import { ComponentProperties, Counted, EntityId, LessonEntity } from '@shared/domain'; import { LessonRepo } from '@shared/repo'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; @Injectable() export class LessonService { @@ -34,7 +34,7 @@ export class LessonService { const lessons = await this.lessonRepo.findByUserId(userId); const updatedLessons = lessons.map((lesson: LessonEntity) => { - lesson.contents.map((c: IComponentProperties) => { + lesson.contents.map((c: ComponentProperties) => { if (c.user === userId) { c.user = ''; } diff --git a/apps/server/src/shared/domain/entity/lesson.entity.spec.ts b/apps/server/src/shared/domain/entity/lesson.entity.spec.ts index 631d04f0380..daca93d86e5 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.spec.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.spec.ts @@ -8,7 +8,7 @@ import { setupEntities, taskFactory, } from '../../testing'; -import { ComponentType, IComponentProperties } from './lesson.entity'; +import { ComponentProperties, ComponentType } from './lesson.entity'; import { Material } from './materials.entity'; import { Task } from './task.entity'; @@ -152,7 +152,7 @@ describe('Lesson Entity', () => { describe('getLessonComponents', () => { it('should return the content components', () => { - const expectedTextContent: IComponentProperties = { + const expectedTextContent: ComponentProperties = { title: 'test component', hidden: false, component: ComponentType.TEXT, diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index d150a21ee3c..2b276abd094 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -15,7 +15,7 @@ export interface LessonProperties { course: Course; courseGroup?: CourseGroup; position?: number; - contents: IComponentProperties[] | []; + contents: ComponentProperties[] | []; materials?: Material[]; } @@ -63,7 +63,7 @@ export interface ComponentInternalProperties { url: string; } -export type IComponentProperties = { +export type ComponentProperties = { _id?: string; title: string; hidden: boolean; @@ -101,7 +101,7 @@ export class LessonEntity extends BaseEntityWithTimestamps implements ILearnroom position: number; @Property() - contents: IComponentProperties[] | []; + contents: ComponentProperties[] | []; @ManyToMany('Material', undefined, { fieldName: 'materialIds' }) materials = new Collection(this); @@ -152,7 +152,7 @@ export class LessonEntity extends BaseEntityWithTimestamps implements ILearnroom return filtered.length; } - getLessonComponents(): IComponentProperties[] | [] { + getLessonComponents(): ComponentProperties[] | [] { return this.contents; } 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 eae071d55ae..d6bdafd1971 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 @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { ComponentType, IComponentProperties, LessonEntity } from '@shared/domain'; +import { ComponentProperties, ComponentType, LessonEntity } from '@shared/domain'; import { cleanupCollections, courseFactory, lessonFactory, materialFactory, taskFactory } from '@shared/testing'; import { MongoMemoryDatabaseModule } from '@infra/database'; @@ -165,7 +165,7 @@ describe('LessonRepo', () => { it('should return lessons which contains a specific userId', async () => { // Arrange const userId = new ObjectId().toHexString(); - const contentExample: IComponentProperties = { + const contentExample: ComponentProperties = { title: 'title', hidden: false, user: userId, @@ -195,7 +195,7 @@ describe('LessonRepo', () => { it('should update Lessons without deleted user', async () => { // Arrange const userId = new ObjectId().toHexString(); - const contentExample: IComponentProperties = { + const contentExample: ComponentProperties = { title: 'title', hidden: false, user: userId, diff --git a/apps/server/src/shared/testing/factory/lesson.factory.ts b/apps/server/src/shared/testing/factory/lesson.factory.ts index f736dc556ee..a83d47cec80 100644 --- a/apps/server/src/shared/testing/factory/lesson.factory.ts +++ b/apps/server/src/shared/testing/factory/lesson.factory.ts @@ -1,4 +1,4 @@ -import { Course, IComponentProperties, LessonEntity, LessonProperties } from '@shared/domain'; +import { ComponentProperties, Course, LessonEntity, LessonProperties } from '@shared/domain'; import { BaseFactory } from './base.factory'; import { courseFactory } from './course.factory'; @@ -15,7 +15,7 @@ export const lessonFactory = LessonFactory.define { contents.push(element); From 987dd80da8daf833735e73bdb72c9fa6711db1ab Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:00:18 +0100 Subject: [PATCH 054/110] ILessonParent -> LessonParent --- apps/server/src/shared/domain/entity/course.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/coursegroup.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 79af9774248..6578664636a 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -6,7 +6,7 @@ import { IEntityWithSchool, ILearnroom } from '@shared/domain/interface'; import { EntityId, LearnroomMetadata, LearnroomTypes } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; -import type { ILessonParent } from './lesson.entity'; +import type { LessonParent } from './lesson.entity'; import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; @@ -51,7 +51,7 @@ export class UsersList { @Entity({ tableName: 'courses' }) export class Course extends BaseEntityWithTimestamps - implements ILearnroom, IEntityWithSchool, ITaskParent, ILessonParent + implements ILearnroom, IEntityWithSchool, ITaskParent, LessonParent { @Property() name: string = DEFAULT.name; diff --git a/apps/server/src/shared/domain/entity/coursegroup.entity.ts b/apps/server/src/shared/domain/entity/coursegroup.entity.ts index 47479904088..3f43b52b221 100644 --- a/apps/server/src/shared/domain/entity/coursegroup.entity.ts +++ b/apps/server/src/shared/domain/entity/coursegroup.entity.ts @@ -3,7 +3,7 @@ import { IEntityWithSchool } from '../interface'; import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; -import type { ILessonParent } from './lesson.entity'; +import type { LessonParent } from './lesson.entity'; import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; @@ -16,7 +16,7 @@ export interface CourseGroupProperties { @Entity({ tableName: 'coursegroups' }) @Index({ properties: ['school', 'course'] }) -export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWithSchool, ITaskParent, ILessonParent { +export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWithSchool, ITaskParent, LessonParent { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index 2b276abd094..cc1112b0f8d 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -77,7 +77,7 @@ export type ComponentProperties = { | { component: ComponentType.NEXBOARD; content: ComponentNexboardProperties } ); -export interface ILessonParent { +export interface LessonParent { getStudentIds(): EntityId[]; } @@ -120,7 +120,7 @@ export class LessonEntity extends BaseEntityWithTimestamps implements ILearnroom if (props.materials) this.materials.set(props.materials); } - private getParent(): ILessonParent { + private getParent(): LessonParent { const parent = this.courseGroup || this.course; return parent; From 0bb7e448fde637bd436d2041348caa9bb171e42b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:11:38 +0100 Subject: [PATCH 055/110] ILearnroomElement -> LearnroomElement --- .../src/shared/domain/entity/legacy-board/board.entity.ts | 4 ++-- .../domain/entity/legacy-board/column-board-target.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/task.entity.ts | 4 ++-- apps/server/src/shared/domain/interface/learnroom.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/shared/domain/entity/legacy-board/board.entity.ts b/apps/server/src/shared/domain/entity/legacy-board/board.entity.ts index 073c30e8d94..18f6e7d864f 100644 --- a/apps/server/src/shared/domain/entity/legacy-board/board.entity.ts +++ b/apps/server/src/shared/domain/entity/legacy-board/board.entity.ts @@ -1,6 +1,6 @@ import { Collection, Entity, IdentifiedReference, ManyToMany, OneToOne, wrap } from '@mikro-orm/core'; import { BadRequestException, NotFoundException } from '@nestjs/common'; -import { ILearnroomElement } from '../../interface'; +import { LearnroomElement } from '../../interface'; import { EntityId } from '../../types'; import { BaseEntityWithTimestamps } from '../base.entity'; import type { Course } from '../course.entity'; @@ -31,7 +31,7 @@ export class Board extends BaseEntityWithTimestamps { @ManyToMany('BoardElement', undefined, { fieldName: 'referenceIds' }) references = new Collection(this); - getByTargetId(id: EntityId): ILearnroomElement { + getByTargetId(id: EntityId): LearnroomElement { const element = this.getElementByTargetId(id); return element.target; } diff --git a/apps/server/src/shared/domain/entity/legacy-board/column-board-target.entity.ts b/apps/server/src/shared/domain/entity/legacy-board/column-board-target.entity.ts index 33545699362..6008c97c550 100644 --- a/apps/server/src/shared/domain/entity/legacy-board/column-board-target.entity.ts +++ b/apps/server/src/shared/domain/entity/legacy-board/column-board-target.entity.ts @@ -1,5 +1,5 @@ import { Entity, Property } from '@mikro-orm/core'; -import { ILearnroomElement } from '@shared/domain/interface'; +import { LearnroomElement } from '@shared/domain/interface'; import { EntityId } from '@shared/domain/types'; import { ObjectId } from 'bson'; import { BaseEntityWithTimestamps } from '../base.entity'; @@ -10,7 +10,7 @@ type ColumnBoardTargetProps = { }; @Entity() -export class ColumnBoardTarget extends BaseEntityWithTimestamps implements ILearnroomElement { +export class ColumnBoardTarget extends BaseEntityWithTimestamps implements LearnroomElement { constructor(props: ColumnBoardTargetProps) { super(); this._columnBoardId = new ObjectId(props.columnBoardId); diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index cc1112b0f8d..e45cdccdbe9 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -1,6 +1,6 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, OneToMany, Property } from '@mikro-orm/core'; import { InternalServerErrorException } from '@nestjs/common'; -import { ILearnroomElement } from '@shared/domain/interface'; +import { LearnroomElement } from '@shared/domain/interface'; import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; @@ -82,7 +82,7 @@ export interface LessonParent { } @Entity({ tableName: 'lessons' }) -export class LessonEntity extends BaseEntityWithTimestamps implements ILearnroomElement, ITaskParent { +export class LessonEntity extends BaseEntityWithTimestamps implements LearnroomElement, ITaskParent { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index c63156e6aa4..506f8c1f42b 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -3,7 +3,7 @@ import { InternalServerErrorException } from '@nestjs/common'; import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { InputFormat } from '@shared/domain/types/input-format.types'; import type { IEntityWithSchool } from '../interface'; -import type { ILearnroomElement } from '../interface/learnroom'; +import type { LearnroomElement } from '../interface/learnroom'; import type { EntityId } from '../types/entity-id'; import type { ITaskProperties, ITaskStatus } from '../types/task.types'; import { BaseEntityWithTimestamps } from './base.entity'; @@ -40,7 +40,7 @@ export interface ITaskParent { @Index({ properties: ['id', 'private'] }) @Index({ properties: ['finished', 'course'] }) @Index({ properties: ['finished', 'course'] }) -export class Task extends BaseEntityWithTimestamps implements ILearnroomElement, IEntityWithSchool { +export class Task extends BaseEntityWithTimestamps implements LearnroomElement, IEntityWithSchool { @Property() name: string; diff --git a/apps/server/src/shared/domain/interface/learnroom.ts b/apps/server/src/shared/domain/interface/learnroom.ts index 1bbfaac1298..849493969a2 100644 --- a/apps/server/src/shared/domain/interface/learnroom.ts +++ b/apps/server/src/shared/domain/interface/learnroom.ts @@ -4,7 +4,7 @@ export interface ILearnroom { getMetadata: () => LearnroomMetadata; } -export interface ILearnroomElement { +export interface LearnroomElement { publish: () => void; unpublish: () => void; } From 8fefd281ecaa5c8dee3e34a7b9733e426ed1bdea Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:13:18 +0100 Subject: [PATCH 056/110] ITargetGroupProperties -> TargetGroupProperties --- apps/server/src/shared/domain/entity/materials.entity.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/shared/domain/entity/materials.entity.ts b/apps/server/src/shared/domain/entity/materials.entity.ts index 9bd73edcfd8..35e308badd0 100644 --- a/apps/server/src/shared/domain/entity/materials.entity.ts +++ b/apps/server/src/shared/domain/entity/materials.entity.ts @@ -1,7 +1,7 @@ import { Entity, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from './base.entity'; -export interface ITargetGroupProperties { +export interface TargetGroupProperties { state?: string; schoolType?: string; grade?: string; @@ -20,7 +20,7 @@ export interface IMaterialProperties { relatedResources: IRelatedResourceProperties[]; subjects: string[]; tags: string[]; - targetGroups: ITargetGroupProperties[]; + targetGroups: TargetGroupProperties[]; title: string; url: string; } @@ -49,7 +49,7 @@ export class Material extends BaseEntityWithTimestamps { tags: string[] | []; @Property() - targetGroups: ITargetGroupProperties[] | []; + targetGroups: TargetGroupProperties[] | []; @Property() title: string; From b8ea87185965facee8d41870b667fbea89204521 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:14:03 +0100 Subject: [PATCH 057/110] IRelatedResourceProperties -> RelatedResourceProperties --- apps/server/src/shared/domain/entity/materials.entity.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/shared/domain/entity/materials.entity.ts b/apps/server/src/shared/domain/entity/materials.entity.ts index 35e308badd0..ed874611907 100644 --- a/apps/server/src/shared/domain/entity/materials.entity.ts +++ b/apps/server/src/shared/domain/entity/materials.entity.ts @@ -7,7 +7,7 @@ export interface TargetGroupProperties { grade?: string; } -export interface IRelatedResourceProperties { +export interface RelatedResourceProperties { originId?: string; relationType?: string; } @@ -17,7 +17,7 @@ export interface IMaterialProperties { description?: string; license: string[]; merlinReference?: string; - relatedResources: IRelatedResourceProperties[]; + relatedResources: RelatedResourceProperties[]; subjects: string[]; tags: string[]; targetGroups: TargetGroupProperties[]; @@ -40,7 +40,7 @@ export class Material extends BaseEntityWithTimestamps { merlinReference?: string; @Property() - relatedResources: IRelatedResourceProperties[] | []; + relatedResources: RelatedResourceProperties[] | []; @Property() subjects: string[] | []; From 46abb7f528c84a9ab6bd3e4be1d3591ac4296cba Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:14:53 +0100 Subject: [PATCH 058/110] IMaterialProperties -> MaterialProperties --- apps/server/src/shared/domain/entity/materials.entity.ts | 4 ++-- apps/server/src/shared/testing/factory/material.factory.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/server/src/shared/domain/entity/materials.entity.ts b/apps/server/src/shared/domain/entity/materials.entity.ts index ed874611907..273174f9782 100644 --- a/apps/server/src/shared/domain/entity/materials.entity.ts +++ b/apps/server/src/shared/domain/entity/materials.entity.ts @@ -12,7 +12,7 @@ export interface RelatedResourceProperties { relationType?: string; } -export interface IMaterialProperties { +export interface MaterialProperties { client: string; description?: string; license: string[]; @@ -57,7 +57,7 @@ export class Material extends BaseEntityWithTimestamps { @Property() url: string; - constructor(props: IMaterialProperties) { + constructor(props: MaterialProperties) { super(); this.client = props.client; this.description = props.description || ''; diff --git a/apps/server/src/shared/testing/factory/material.factory.ts b/apps/server/src/shared/testing/factory/material.factory.ts index 62d77f1e116..5d0e07e4936 100644 --- a/apps/server/src/shared/testing/factory/material.factory.ts +++ b/apps/server/src/shared/testing/factory/material.factory.ts @@ -1,9 +1,9 @@ -import { IMaterialProperties, Material } from '@shared/domain/entity/materials.entity'; +import { Material, MaterialProperties } from '@shared/domain/entity/materials.entity'; import { BaseFactory } from './base.factory'; -class MaterialFactory extends BaseFactory {} +class MaterialFactory extends BaseFactory {} -export const materialFactory = MaterialFactory.define(Material, ({ sequence }) => { +export const materialFactory = MaterialFactory.define(Material, ({ sequence }) => { return { client: 'test material client', description: 'test material description', From 7301828d5897b53c1c221ab1229497c0a4952a91 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:16:28 +0100 Subject: [PATCH 059/110] NewsProperties -> INewsProperties --- .../modules/news/mapper/news.mapper.spec.ts | 20 +++++++++---------- .../src/shared/domain/entity/news.entity.ts | 16 +++++++-------- .../shared/testing/factory/news.factory.ts | 14 ++++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/server/src/modules/news/mapper/news.mapper.spec.ts b/apps/server/src/modules/news/mapper/news.mapper.spec.ts index 1ca549bfe74..07b613c68fe 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.spec.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.spec.ts @@ -1,21 +1,20 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { CourseNews, - INewsProperties, + ICreateNews, + INewsScope, + IUpdateNews, News, + NewsProperties, + NewsTarget, + NewsTargetModel, SchoolEntity, SchoolNews, TeamEntity, TeamNews, User, - NewsTargetModel, - INewsScope, - ICreateNews, - IUpdateNews, - NewsTarget, } from '@shared/domain'; -import { courseFactory, schoolFactory, userFactory, setupEntities } from '@shared/testing'; -import { NewsMapper } from './news.mapper'; +import { courseFactory, schoolFactory, setupEntities, userFactory } from '@shared/testing'; import { CreateNewsParams, FilterNewsParams, @@ -25,6 +24,7 @@ import { UserInfoResponse, } from '../controller/dto'; import { TargetInfoResponse } from '../controller/dto/target-info.response'; +import { NewsMapper } from './news.mapper'; const getTargetModel = (news: News): NewsTargetModel => { if (news instanceof SchoolNews) { @@ -42,14 +42,14 @@ const date = new Date(2021, 1, 1, 0, 0, 0); const createNews = ( newsProps, - NewsType: { new (props: INewsProperties): T }, + NewsType: { new (props: NewsProperties): T }, school: SchoolEntity, creator: User, target: NewsTarget ): T => { const newsId = new ObjectId().toHexString(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const props: INewsProperties = { + const props: NewsProperties = { id: newsId, displayAt: date, updatedAt: date, diff --git a/apps/server/src/shared/domain/entity/news.entity.ts b/apps/server/src/shared/domain/entity/news.entity.ts index 7b22c38f364..682192770a1 100644 --- a/apps/server/src/shared/domain/entity/news.entity.ts +++ b/apps/server/src/shared/domain/entity/news.entity.ts @@ -1,13 +1,13 @@ import { Entity, Enum, Index, ManyToOne, Property } from '@mikro-orm/core'; +import { EntityId } from '../types'; +import { NewsTarget, NewsTargetModel } from '../types/news.types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import { SchoolEntity } from './school.entity'; import type { TeamEntity } from './team.entity'; import type { User } from './user.entity'; -import { NewsTarget, NewsTargetModel } from '../types/news.types'; -import { EntityId } from '../types'; -export interface INewsProperties { +export interface NewsProperties { title: string; content: string; displayAt: Date; @@ -69,7 +69,7 @@ export abstract class News extends BaseEntityWithTimestamps { permissions: string[] = []; - constructor(props: INewsProperties) { + constructor(props: NewsProperties) { super(); this.title = props.title; this.content = props.content; @@ -80,7 +80,7 @@ export abstract class News extends BaseEntityWithTimestamps { this.sourceDescription = props.sourceDescription; } - static createInstance(targetModel: NewsTargetModel, props: INewsProperties): News { + static createInstance(targetModel: NewsTargetModel, props: NewsProperties): News { let news: News; if (targetModel === NewsTargetModel.Course) { // eslint-disable-next-line @typescript-eslint/no-use-before-define @@ -101,7 +101,7 @@ export class SchoolNews extends News { @ManyToOne(() => SchoolEntity) target!: SchoolEntity; - constructor(props: INewsProperties) { + constructor(props: NewsProperties) { super(props); this.targetModel = NewsTargetModel.School; } @@ -115,7 +115,7 @@ export class CourseNews extends News { @ManyToOne('Course', { nullable: true }) target!: Course; - constructor(props: INewsProperties) { + constructor(props: NewsProperties) { super(props); this.targetModel = NewsTargetModel.Course; } @@ -126,7 +126,7 @@ export class TeamNews extends News { @ManyToOne('TeamEntity') target!: TeamEntity; - constructor(props: INewsProperties) { + constructor(props: NewsProperties) { super(props); this.targetModel = NewsTargetModel.Team; } diff --git a/apps/server/src/shared/testing/factory/news.factory.ts b/apps/server/src/shared/testing/factory/news.factory.ts index 56b59cedf6c..55788cea9de 100644 --- a/apps/server/src/shared/testing/factory/news.factory.ts +++ b/apps/server/src/shared/testing/factory/news.factory.ts @@ -1,11 +1,11 @@ -import { SchoolNews, CourseNews, TeamNews, INewsProperties } from '@shared/domain'; +import { CourseNews, NewsProperties, SchoolNews, TeamNews } from '@shared/domain'; import { BaseFactory } from './base.factory'; import { courseFactory } from './course.factory'; import { schoolFactory } from './school.factory'; import { teamFactory } from './team.factory'; import { userFactory } from './user.factory'; -export const schoolNewsFactory = BaseFactory.define(SchoolNews, ({ sequence }) => { +export const schoolNewsFactory = BaseFactory.define(SchoolNews, ({ sequence }) => { return { title: `news ${sequence}`, content: `content of news ${sequence}`, @@ -16,7 +16,7 @@ export const schoolNewsFactory = BaseFactory.define }; }); -export const courseNewsFactory = BaseFactory.define(CourseNews, ({ sequence }) => { +export const courseNewsFactory = BaseFactory.define(CourseNews, ({ sequence }) => { return { title: `news ${sequence}`, content: `content of news ${sequence}`, @@ -27,7 +27,7 @@ export const courseNewsFactory = BaseFactory.define }; }); -export const teamNewsFactory = BaseFactory.define(TeamNews, ({ sequence }) => { +export const teamNewsFactory = BaseFactory.define(TeamNews, ({ sequence }) => { return { title: `news ${sequence}`, content: `content of news ${sequence}`, @@ -38,7 +38,7 @@ export const teamNewsFactory = BaseFactory.define(Tea }; }); -export const schoolUnpublishedNewsFactory = BaseFactory.define( +export const schoolUnpublishedNewsFactory = BaseFactory.define( SchoolNews, ({ sequence }) => { return { @@ -52,7 +52,7 @@ export const schoolUnpublishedNewsFactory = BaseFactory.define( +export const courseUnpublishedNewsFactory = BaseFactory.define( CourseNews, ({ sequence }) => { return { @@ -66,7 +66,7 @@ export const courseUnpublishedNewsFactory = BaseFactory.define(TeamNews, ({ sequence }) => { +export const teamUnpublishedNewsFactory = BaseFactory.define(TeamNews, ({ sequence }) => { return { title: `news ${sequence}`, content: `content of news ${sequence}`, From 8df48ca7b60bd53820a0d4f3f52fc6b922cdea03 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:19:53 +0100 Subject: [PATCH 060/110] IRoleProperties -> RoleProperties --- apps/server/src/infra/mail/mail.service.spec.ts | 6 +++--- apps/server/src/infra/rabbitmq/error.mapper.spec.ts | 10 +++++----- apps/server/src/modules/management/seed-data/roles.ts | 6 +++--- apps/server/src/shared/domain/entity/role.entity.ts | 4 ++-- apps/server/src/shared/testing/factory/role.factory.ts | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/server/src/infra/mail/mail.service.spec.ts b/apps/server/src/infra/mail/mail.service.spec.ts index ebc77030252..c72f182ee40 100644 --- a/apps/server/src/infra/mail/mail.service.spec.ts +++ b/apps/server/src/infra/mail/mail.service.spec.ts @@ -1,10 +1,10 @@ import { AmqpConnection } from '@golevelup/nestjs-rabbitmq'; -import { Test, TestingModule } from '@nestjs/testing'; import { createMock } from '@golevelup/ts-jest'; import { ConfigService } from '@nestjs/config'; +import { Test, TestingModule } from '@nestjs/testing'; +import { MailConfig } from './interfaces/mail-config'; import { Mail } from './mail.interface'; import { MailService } from './mail.service'; -import { IMailConfig } from './interfaces/mail-config'; describe('MailService', () => { let module: TestingModule; @@ -24,7 +24,7 @@ describe('MailService', () => { { provide: 'MAIL_SERVICE_OPTIONS', useValue: mailServiceOptions }, { provide: ConfigService, - useValue: createMock>({ get: () => ['schul-cloud.org', 'example.com'] }), + useValue: createMock>({ get: () => ['schul-cloud.org', 'example.com'] }), }, ], }).compile(); diff --git a/apps/server/src/infra/rabbitmq/error.mapper.spec.ts b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts index 884dfb35158..9ecdc45af5f 100644 --- a/apps/server/src/infra/rabbitmq/error.mapper.spec.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts @@ -1,10 +1,10 @@ +import { ErrorInterface } from '@infra/rabbitmq'; import { BadRequestException, ConflictException, ForbiddenException, InternalServerErrorException, } from '@nestjs/common'; -import { IError } from '@infra/rabbitmq'; import _ from 'lodash'; import { ErrorMapper } from './error.mapper'; @@ -13,7 +13,7 @@ describe('ErrorMapper', () => { it('Should map any 400 error to BadRequestException.', () => { const errorText = 'BadRequestException ABC'; const e = new BadRequestException(errorText); - const json = _.toPlainObject(e) as IError; + const json = _.toPlainObject(e) as ErrorInterface; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); @@ -22,7 +22,7 @@ describe('ErrorMapper', () => { it('Should map 403 error response to ForbiddenException.', () => { const errorText = 'ForbiddenException ABC'; - const rpcResponseError = _.toPlainObject(new ForbiddenException(errorText)) as IError; + const rpcResponseError = _.toPlainObject(new ForbiddenException(errorText)) as ErrorInterface; const result = ErrorMapper.mapRpcErrorResponseToDomainError(rpcResponseError); @@ -31,7 +31,7 @@ describe('ErrorMapper', () => { it('Should map 500 error response to InternalServerErrorException.', () => { const errorText = 'InternalServerErrorException ABC'; - const json = _.toPlainObject(new InternalServerErrorException(errorText)) as IError; + const json = _.toPlainObject(new InternalServerErrorException(errorText)) as ErrorInterface; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); @@ -40,7 +40,7 @@ describe('ErrorMapper', () => { it('Should map unknown error code to InternalServerErrorException.', () => { const errorText = 'Any error text'; - const json = _.toPlainObject(new ConflictException(errorText)) as IError; + const json = _.toPlainObject(new ConflictException(errorText)) as ErrorInterface; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); diff --git a/apps/server/src/modules/management/seed-data/roles.ts b/apps/server/src/modules/management/seed-data/roles.ts index f5a4ee0fbdc..3fba9d7d8ee 100644 --- a/apps/server/src/modules/management/seed-data/roles.ts +++ b/apps/server/src/modules/management/seed-data/roles.ts @@ -1,10 +1,10 @@ // All user accounts are organized by school in a single array -import { IRoleProperties, Permission, Role, RoleName } from '@shared/domain'; +import { Permission, Role, RoleName, RoleProperties } from '@shared/domain'; import { roleFactory } from '@shared/testing'; import { DeepPartial } from 'fishery'; -type SeedRoleProperties = Omit & { +type SeedRoleProperties = Omit & { id: string; createdAt: string; updatedAt: string; @@ -443,7 +443,7 @@ export function generateRole(localRoleSeedData?: { [key: string | RoleName]: See if (subRoles.some((r) => !r)) { throw new Error(`Role ${roleName} depends on non existing role`); } - const params: DeepPartial = { + const params: DeepPartial = { name: partial.name, permissions: partial.permissions, roles: subRoles, diff --git a/apps/server/src/shared/domain/entity/role.entity.ts b/apps/server/src/shared/domain/entity/role.entity.ts index 66dc6e24191..923b75c8873 100644 --- a/apps/server/src/shared/domain/entity/role.entity.ts +++ b/apps/server/src/shared/domain/entity/role.entity.ts @@ -2,7 +2,7 @@ import { Collection, Entity, ManyToMany, Property, Unique } from '@mikro-orm/cor import { Permission, RoleName } from '../interface'; import { BaseEntityWithTimestamps } from './base.entity'; -export interface IRoleProperties { +export interface RoleProperties { permissions?: Permission[]; roles?: Role[]; name: RoleName; @@ -20,7 +20,7 @@ export class Role extends BaseEntityWithTimestamps { @ManyToMany({ entity: 'Role' }) roles = new Collection(this); - constructor(props: IRoleProperties) { + constructor(props: RoleProperties) { super(); this.name = props.name; if (props.permissions) this.permissions = props.permissions; diff --git a/apps/server/src/shared/testing/factory/role.factory.ts b/apps/server/src/shared/testing/factory/role.factory.ts index f37236c2587..bd987e198b5 100644 --- a/apps/server/src/shared/testing/factory/role.factory.ts +++ b/apps/server/src/shared/testing/factory/role.factory.ts @@ -1,7 +1,7 @@ -import { IRoleProperties, Role, RoleName } from '@shared/domain'; +import { Role, RoleName, RoleProperties } from '@shared/domain'; import { BaseFactory } from './base.factory'; -export const roleFactory = BaseFactory.define(Role, ({ sequence }) => { +export const roleFactory = BaseFactory.define(Role, ({ sequence }) => { return { name: `role${sequence}` as unknown as RoleName, }; From ec9f1807f341d3967815a678227a0e0c9eba998b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:21:05 +0100 Subject: [PATCH 061/110] SchoolProperties -> SchoolProperties --- apps/server/src/modules/management/seed-data/schools.ts | 6 +++--- apps/server/src/shared/domain/entity/school.entity.ts | 6 +++--- .../repo/school/legacy-school.repo.integration.spec.ts | 8 ++++---- apps/server/src/shared/repo/school/legacy-school.repo.ts | 8 ++++---- apps/server/src/shared/testing/factory/school.factory.ts | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/server/src/modules/management/seed-data/schools.ts b/apps/server/src/modules/management/seed-data/schools.ts index ba09c0d6952..9c0cec78153 100644 --- a/apps/server/src/modules/management/seed-data/schools.ts +++ b/apps/server/src/modules/management/seed-data/schools.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/dot-notation */ import { FederalStateEntity, - ISchoolProperties, SchoolFeatures, + SchoolProperties, SchoolRoles, SchoolYearEntity, SystemEntity, @@ -12,7 +12,7 @@ import { DeepPartial } from 'fishery'; import { EFederalState } from './federalstates'; import { SeedSchoolYearEnum } from './schoolyears'; -type SeedSchoolProperties = Omit & { +type SeedSchoolProperties = Omit & { id: string; updatedAt?: string; createdAt?: string; @@ -288,7 +288,7 @@ export function generateSchools(entities: { entities.federalStates.find((fs) => partial.federalState && fs.name === partial.federalState) ?? federalStateFactory.build(); - const params: DeepPartial = { + const params: DeepPartial = { externalId: partial.externalId, features: partial.features, inMaintenanceSince: partial.inMaintenanceSince, diff --git a/apps/server/src/shared/domain/entity/school.entity.ts b/apps/server/src/shared/domain/entity/school.entity.ts index 98502a127eb..81802f595ed 100644 --- a/apps/server/src/shared/domain/entity/school.entity.ts +++ b/apps/server/src/shared/domain/entity/school.entity.ts @@ -11,9 +11,9 @@ import { } from '@mikro-orm/core'; import { UserLoginMigrationEntity } from '@shared/domain/entity/user-login-migration.entity'; import { BaseEntity } from './base.entity'; +import { FederalStateEntity } from './federal-state.entity'; import { SchoolYearEntity } from './schoolyear.entity'; import { SystemEntity } from './system.entity'; -import { FederalStateEntity } from './federal-state.entity'; export enum SchoolFeatures { ROCKET_CHAT = 'rocketChat', @@ -26,7 +26,7 @@ export enum SchoolFeatures { ENABLE_LDAP_SYNC_DURING_MIGRATION = 'enableLdapSyncDuringMigration', } -export interface ISchoolProperties { +export interface SchoolProperties { _id?: string; externalId?: string; inMaintenanceSince?: Date; @@ -106,7 +106,7 @@ export class SchoolEntity extends BaseEntity { @ManyToOne(() => FederalStateEntity, { fieldName: 'federalState', nullable: false }) federalState: FederalStateEntity; - constructor(props: ISchoolProperties) { + constructor(props: SchoolProperties) { super(); if (props.externalId) { this.externalId = props.externalId; 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 775c193675d..097f5498685 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 @@ -1,19 +1,19 @@ import { createMock } from '@golevelup/ts-jest'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { EntityManager } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import { InternalServerErrorException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { - ISchoolProperties, LegacySchoolDo, SchoolEntity, + SchoolProperties, SchoolRolePermission, SchoolRoles, SchoolYearEntity, SystemEntity, UserLoginMigrationEntity, } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@infra/database'; import { legacySchoolDoFactory, schoolFactory, @@ -241,10 +241,10 @@ describe('LegacySchoolRepo', () => { }; }; - it('should map SchoolDO properties to ISchoolProperties', async () => { + it('should map SchoolDO properties to SchoolProperties', async () => { const { entityDO, emGetReferenceSpy, system1, system2, userLoginMigration } = await setup(); - const result: ISchoolProperties = repo.mapDOToEntityProperties(entityDO); + const result: SchoolProperties = repo.mapDOToEntityProperties(entityDO); expect(result.externalId).toEqual(entityDO.externalId); expect(result.features).toEqual(entityDO.features); diff --git a/apps/server/src/shared/repo/school/legacy-school.repo.ts b/apps/server/src/shared/repo/school/legacy-school.repo.ts index 711eaea27d9..a8b5265a5c4 100644 --- a/apps/server/src/shared/repo/school/legacy-school.repo.ts +++ b/apps/server/src/shared/repo/school/legacy-school.repo.ts @@ -3,9 +3,9 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { EntityId, - ISchoolProperties, LegacySchoolDo, SchoolEntity, + SchoolProperties, SystemEntity, UserLoginMigrationEntity, } from '@shared/domain'; @@ -16,7 +16,7 @@ import { BaseDORepo } from '../base.do.repo'; * @deprecated because it uses the deprecated LegacySchoolDo. */ @Injectable() -export class LegacySchoolRepo extends BaseDORepo { +export class LegacySchoolRepo extends BaseDORepo { constructor(protected readonly _em: EntityManager, protected readonly logger: LegacyLogger) { super(_em, logger); } @@ -42,7 +42,7 @@ export class LegacySchoolRepo extends BaseDORepo(SchoolEntity, ({ sequence }) => { +export const schoolFactory = BaseFactory.define(SchoolEntity, ({ sequence }) => { return { name: `school #${sequence}`, schoolYear: schoolYearFactory.build(), From 5bf58d7450a8e2e8f6d69bad4028aa8978889c46 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:24:13 +0100 Subject: [PATCH 062/110] ISchoolYearProperties -> SchoolYearProperties --- apps/server/src/modules/management/seed-data/schoolyears.ts | 6 +++--- apps/server/src/shared/domain/entity/schoolyear.entity.ts | 6 +++--- .../server/src/shared/testing/factory/schoolyear.factory.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/management/seed-data/schoolyears.ts b/apps/server/src/modules/management/seed-data/schoolyears.ts index afd0a7a8d49..c52dee77642 100644 --- a/apps/server/src/modules/management/seed-data/schoolyears.ts +++ b/apps/server/src/modules/management/seed-data/schoolyears.ts @@ -1,8 +1,8 @@ -import { ISchoolYearProperties } from '@shared/domain'; +import { SchoolYearProperties } from '@shared/domain'; import { schoolYearFactory } from '@shared/testing/factory/schoolyear.factory'; import { DeepPartial } from 'fishery'; -type SeedSchoolYearProperties = Pick & { +type SeedSchoolYearProperties = Pick & { id: string; endDate: string; startDate: string; @@ -79,7 +79,7 @@ const seedSchoolYears: SeedSchoolYearProperties[] = [ export function generateSchoolYears() { return seedSchoolYears.map((year) => { - const params: DeepPartial = { + const params: DeepPartial = { endDate: new Date(year.endDate), name: year.name, startDate: new Date(year.startDate), diff --git a/apps/server/src/shared/domain/entity/schoolyear.entity.ts b/apps/server/src/shared/domain/entity/schoolyear.entity.ts index e1d2c1c9895..f538119652c 100644 --- a/apps/server/src/shared/domain/entity/schoolyear.entity.ts +++ b/apps/server/src/shared/domain/entity/schoolyear.entity.ts @@ -1,14 +1,14 @@ import { Entity, Property } from '@mikro-orm/core'; import { BaseEntity } from './base.entity'; -export interface ISchoolYearProperties { +export interface SchoolYearProperties { name: string; startDate: Date; endDate: Date; } @Entity({ tableName: 'years' }) -export class SchoolYearEntity extends BaseEntity implements ISchoolYearProperties { +export class SchoolYearEntity extends BaseEntity implements SchoolYearProperties { @Property() name: string; @@ -18,7 +18,7 @@ export class SchoolYearEntity extends BaseEntity implements ISchoolYearPropertie @Property() endDate: Date; - constructor(props: ISchoolYearProperties) { + constructor(props: SchoolYearProperties) { super(); this.name = props.name; this.startDate = props.startDate; diff --git a/apps/server/src/shared/testing/factory/schoolyear.factory.ts b/apps/server/src/shared/testing/factory/schoolyear.factory.ts index a1184ed66d3..b60e85c72e9 100644 --- a/apps/server/src/shared/testing/factory/schoolyear.factory.ts +++ b/apps/server/src/shared/testing/factory/schoolyear.factory.ts @@ -1,7 +1,7 @@ -import { ISchoolYearProperties, SchoolYearEntity } from '@shared/domain/entity/schoolyear.entity'; +import { SchoolYearEntity, SchoolYearProperties } from '@shared/domain/entity/schoolyear.entity'; import { BaseFactory } from './base.factory'; -export const schoolYearFactory = BaseFactory.define(SchoolYearEntity, () => { +export const schoolYearFactory = BaseFactory.define(SchoolYearEntity, () => { const year = new Date().getFullYear(); const nextYear = (year + 1).toString().substr(-2); const name = `${year}/${nextYear}`; From 86e655caf6b2a8c7afdf407f41f64207045f6bc6 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:25:29 +0100 Subject: [PATCH 063/110] IStorageProviderProperties -> StorageProviderProperties --- .../server/src/shared/domain/entity/storageprovider.entity.ts | 4 ++-- .../src/shared/testing/factory/storageprovider.factory.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/shared/domain/entity/storageprovider.entity.ts b/apps/server/src/shared/domain/entity/storageprovider.entity.ts index 7bac9b3380a..e2c0fe885ef 100644 --- a/apps/server/src/shared/domain/entity/storageprovider.entity.ts +++ b/apps/server/src/shared/domain/entity/storageprovider.entity.ts @@ -2,7 +2,7 @@ import { Entity, Property } from '@mikro-orm/core'; import { StorageProviderEncryptedStringType } from '@shared/repo/types/StorageProviderEncryptedString.type'; import { BaseEntityWithTimestamps } from './base.entity'; -export interface IStorageProviderProperties { +export interface StorageProviderProperties { endpointUrl: string; accessKeyId: string; secretAccessKey: string; @@ -23,7 +23,7 @@ export class StorageProviderEntity extends BaseEntityWithTimestamps { @Property({ nullable: true }) region?: string; - constructor(props: IStorageProviderProperties) { + constructor(props: StorageProviderProperties) { super(); this.endpointUrl = props.endpointUrl; this.accessKeyId = props.accessKeyId; diff --git a/apps/server/src/shared/testing/factory/storageprovider.factory.ts b/apps/server/src/shared/testing/factory/storageprovider.factory.ts index d0ad53be107..0406b647978 100644 --- a/apps/server/src/shared/testing/factory/storageprovider.factory.ts +++ b/apps/server/src/shared/testing/factory/storageprovider.factory.ts @@ -1,7 +1,7 @@ -import { StorageProviderEntity, IStorageProviderProperties } from '@shared/domain'; +import { StorageProviderEntity, StorageProviderProperties } from '@shared/domain'; import { BaseFactory } from './base.factory'; -export const storageProviderFactory = BaseFactory.define( +export const storageProviderFactory = BaseFactory.define( StorageProviderEntity, () => { return { From b2f334766921f4e0722b84da0f3b4e513611c37d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:26:44 +0100 Subject: [PATCH 064/110] ISubmissionProperties -> SubmissionProperties --- .../src/shared/domain/entity/submission.entity.ts | 4 ++-- .../src/shared/testing/factory/submission.factory.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/shared/domain/entity/submission.entity.ts b/apps/server/src/shared/domain/entity/submission.entity.ts index de86ba9f814..12893ed3bd5 100644 --- a/apps/server/src/shared/domain/entity/submission.entity.ts +++ b/apps/server/src/shared/domain/entity/submission.entity.ts @@ -8,7 +8,7 @@ import { SchoolEntity } from './school.entity'; import type { Task } from './task.entity'; import type { User } from './user.entity'; -export interface ISubmissionProperties { +export interface SubmissionProperties { school: SchoolEntity; task: Task; student: User; @@ -57,7 +57,7 @@ export class Submission extends BaseEntityWithTimestamps { @Property({ nullable: true }) gradeComment?: string; - constructor(props: ISubmissionProperties) { + constructor(props: SubmissionProperties) { super(); this.school = props.school; this.student = props.student; diff --git a/apps/server/src/shared/testing/factory/submission.factory.ts b/apps/server/src/shared/testing/factory/submission.factory.ts index 09e057da78e..a667e2de37c 100644 --- a/apps/server/src/shared/testing/factory/submission.factory.ts +++ b/apps/server/src/shared/testing/factory/submission.factory.ts @@ -1,32 +1,32 @@ -import { ISubmissionProperties, Submission } from '@shared/domain'; +import { Submission, SubmissionProperties } from '@shared/domain'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; import { schoolFactory } from './school.factory'; import { taskFactory } from './task.factory'; import { userFactory } from './user.factory'; -class SubmissionFactory extends BaseFactory { +class SubmissionFactory extends BaseFactory { graded(): this { - const params: DeepPartial = { graded: true }; + const params: DeepPartial = { graded: true }; return this.params(params); } submitted(): this { - const params: DeepPartial = { submitted: true }; + const params: DeepPartial = { submitted: true }; return this.params(params); } studentWithId(): this { - const params: DeepPartial = { student: userFactory.buildWithId() }; + const params: DeepPartial = { student: userFactory.buildWithId() }; return this.params(params); } teamMembersWithId(numberOfTeamMembers: number): this { const teamMembers = userFactory.buildListWithId(numberOfTeamMembers); - const params: DeepPartial = { teamMembers }; + const params: DeepPartial = { teamMembers }; return this.params(params); } From f6d0f7eb8c2ff1c11715bcf9ee60b805b310ff48 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:27:49 +0100 Subject: [PATCH 065/110] ISystemProperties -> SystemProperties --- apps/server/src/modules/management/seed-data/systems.ts | 6 +++--- apps/server/src/shared/domain/entity/system.entity.ts | 4 ++-- apps/server/src/shared/testing/factory/system.factory.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/modules/management/seed-data/systems.ts b/apps/server/src/modules/management/seed-data/systems.ts index adbffbc4b35..a9140458f6d 100644 --- a/apps/server/src/modules/management/seed-data/systems.ts +++ b/apps/server/src/modules/management/seed-data/systems.ts @@ -1,10 +1,10 @@ /* eslint-disable no-template-curly-in-string */ -import { ISystemProperties } from '@shared/domain'; +import { SystemProperties } from '@shared/domain'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; import { systemFactory } from '@shared/testing'; import { DeepPartial } from 'fishery'; -type SystemPartial = DeepPartial & { +type SystemPartial = DeepPartial & { id?: string; createdAt?: string; updatedAt?: string; @@ -66,7 +66,7 @@ const data: SystemPartial[] = [ export function generateSystems(injectEnvVars: (s: string) => string) { const systems = data.map((d) => { d = JSON.parse(injectEnvVars(JSON.stringify(d))) as typeof d; - const params: DeepPartial = { + const params: DeepPartial = { alias: d.alias, displayName: d.displayName, type: d.type, diff --git a/apps/server/src/shared/domain/entity/system.entity.ts b/apps/server/src/shared/domain/entity/system.entity.ts index 0633e515589..07cfea5bb59 100644 --- a/apps/server/src/shared/domain/entity/system.entity.ts +++ b/apps/server/src/shared/domain/entity/system.entity.ts @@ -3,7 +3,7 @@ import { SystemProvisioningStrategy } from '@shared/domain/interface/system-prov import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; -export interface ISystemProperties { +export interface SystemProperties { type: string; url?: string; alias?: string; @@ -189,7 +189,7 @@ export class OidcConfig { @Entity({ tableName: 'systems' }) export class SystemEntity extends BaseEntityWithTimestamps { - constructor(props: ISystemProperties) { + constructor(props: SystemProperties) { super(); this.type = props.type; this.url = props.url; diff --git a/apps/server/src/shared/testing/factory/system.factory.ts b/apps/server/src/shared/testing/factory/system.factory.ts index 3745736b7e1..f686c406851 100644 --- a/apps/server/src/shared/testing/factory/system.factory.ts +++ b/apps/server/src/shared/testing/factory/system.factory.ts @@ -1,11 +1,11 @@ -import { ISystemProperties, LdapConfig, OauthConfig, OidcConfig, SystemEntity } from '@shared/domain'; +import { LdapConfig, OauthConfig, OidcConfig, SystemEntity, SystemProperties } from '@shared/domain'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; -export class SystemFactory extends BaseFactory { +export class SystemFactory extends BaseFactory { withOauthConfig(): this { - const params: DeepPartial = { + const params: DeepPartial = { oauthConfig: new OauthConfig({ clientId: '12345', clientSecret: 'mocksecret', @@ -26,7 +26,7 @@ export class SystemFactory extends BaseFactory } withLdapConfig(otherParams?: DeepPartial): this { - const params: DeepPartial = { + const params: DeepPartial = { ldapConfig: new LdapConfig({ url: 'ldaps:mock.de:389', active: true, From 5546597ec8d816b86f83f44abb297bb9dd651a0e Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:30:52 +0100 Subject: [PATCH 066/110] ITaskParent -> TaskParent --- apps/server/src/shared/domain/entity/course.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/coursegroup.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/lesson.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/task.entity.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 6578664636a..9ed023c1ed7 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -8,7 +8,7 @@ import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; import type { LessonParent } from './lesson.entity'; import { SchoolEntity } from './school.entity'; -import type { ITaskParent } from './task.entity'; +import type { TaskParent } from './task.entity'; import type { User } from './user.entity'; export interface CourseProperties { @@ -51,7 +51,7 @@ export class UsersList { @Entity({ tableName: 'courses' }) export class Course extends BaseEntityWithTimestamps - implements ILearnroom, IEntityWithSchool, ITaskParent, LessonParent + implements ILearnroom, IEntityWithSchool, TaskParent, LessonParent { @Property() name: string = DEFAULT.name; diff --git a/apps/server/src/shared/domain/entity/coursegroup.entity.ts b/apps/server/src/shared/domain/entity/coursegroup.entity.ts index 3f43b52b221..b8b3d482ba4 100644 --- a/apps/server/src/shared/domain/entity/coursegroup.entity.ts +++ b/apps/server/src/shared/domain/entity/coursegroup.entity.ts @@ -5,7 +5,7 @@ import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import type { LessonParent } from './lesson.entity'; import { SchoolEntity } from './school.entity'; -import type { ITaskParent } from './task.entity'; +import type { TaskParent } from './task.entity'; import type { User } from './user.entity'; export interface CourseGroupProperties { @@ -16,7 +16,7 @@ export interface CourseGroupProperties { @Entity({ tableName: 'coursegroups' }) @Index({ properties: ['school', 'course'] }) -export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWithSchool, ITaskParent, LessonParent { +export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWithSchool, TaskParent, LessonParent { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/lesson.entity.ts b/apps/server/src/shared/domain/entity/lesson.entity.ts index e45cdccdbe9..eae1cb6169b 100644 --- a/apps/server/src/shared/domain/entity/lesson.entity.ts +++ b/apps/server/src/shared/domain/entity/lesson.entity.ts @@ -6,7 +6,7 @@ import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import { CourseGroup } from './coursegroup.entity'; import { Material } from './materials.entity'; -import type { ITaskParent } from './task.entity'; +import type { TaskParent } from './task.entity'; import { Task } from './task.entity'; export interface LessonProperties { @@ -82,7 +82,7 @@ export interface LessonParent { } @Entity({ tableName: 'lessons' }) -export class LessonEntity extends BaseEntityWithTimestamps implements LearnroomElement, ITaskParent { +export class LessonEntity extends BaseEntityWithTimestamps implements LearnroomElement, TaskParent { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index 506f8c1f42b..98f2bd2d5a9 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -31,7 +31,7 @@ export type TaskParentDescriptions = { color: string; }; -export interface ITaskParent { +export interface TaskParent { getStudentIds(): EntityId[]; } @@ -128,7 +128,7 @@ export class Task extends BaseEntityWithTimestamps implements LearnroomElement, return finishedIds; } - private getParent(): ITaskParent | User { + private getParent(): TaskParent | User { const parent = this.lesson || this.course || this.creator; return parent; From 666157027d0e7e067ecd34657d08bb4cbc97397c Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:32:12 +0100 Subject: [PATCH 067/110] ITeamProperties -> TeamProperties --- apps/server/src/shared/domain/entity/team.entity.ts | 4 ++-- .../src/shared/testing/factory/team.factory.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/shared/domain/entity/team.entity.ts b/apps/server/src/shared/domain/entity/team.entity.ts index 70e7d142885..3c4fcd6e024 100644 --- a/apps/server/src/shared/domain/entity/team.entity.ts +++ b/apps/server/src/shared/domain/entity/team.entity.ts @@ -4,7 +4,7 @@ import { Role } from './role.entity'; import { SchoolEntity } from './school.entity'; import { User } from './user.entity'; -export interface ITeamProperties { +export interface TeamProperties { name: string; teamUsers?: TeamUserEntity[]; } @@ -66,7 +66,7 @@ export class TeamEntity extends BaseEntityWithTimestamps { this.userIds = value; } - constructor(props: ITeamProperties) { + constructor(props: TeamProperties) { super(); this.name = props.name; this.userIds = props.teamUsers ? props.teamUsers.map((teamUser) => new TeamUserEntity(teamUser)) : []; diff --git a/apps/server/src/shared/testing/factory/team.factory.ts b/apps/server/src/shared/testing/factory/team.factory.ts index 1a72b84969f..332d3190c34 100644 --- a/apps/server/src/shared/testing/factory/team.factory.ts +++ b/apps/server/src/shared/testing/factory/team.factory.ts @@ -1,18 +1,18 @@ -import { ITeamProperties, Role, TeamEntity, TeamUserEntity } from '@shared/domain'; -import { DeepPartial } from 'fishery'; -import { teamUserFactory } from '@shared/testing/factory/teamuser.factory'; +import { Role, TeamEntity, TeamProperties, TeamUserEntity } from '@shared/domain'; import { BaseFactory } from '@shared/testing/factory/base.factory'; +import { teamUserFactory } from '@shared/testing/factory/teamuser.factory'; +import { DeepPartial } from 'fishery'; -class TeamFactory extends BaseFactory { +class TeamFactory extends BaseFactory { withRoleAndUserId(role: Role, userId: string): this { - const params: DeepPartial = { + const params: DeepPartial = { teamUsers: [teamUserFactory.withRoleAndUserId(role, userId).buildWithId()], }; return this.params(params); } withTeamUser(teamUser: TeamUserEntity[]): this { - const params: DeepPartial = { + const params: DeepPartial = { teamUsers: teamUser, }; return this.params(params); From b7c692e8f0732dae13871adae01cba727ad399b1 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:33:23 +0100 Subject: [PATCH 068/110] ITeamUserProperties -> TeamUserProperties --- apps/server/src/shared/domain/entity/team.entity.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/shared/domain/entity/team.entity.ts b/apps/server/src/shared/domain/entity/team.entity.ts index 3c4fcd6e024..dd39e8c9ff6 100644 --- a/apps/server/src/shared/domain/entity/team.entity.ts +++ b/apps/server/src/shared/domain/entity/team.entity.ts @@ -9,7 +9,7 @@ export interface TeamProperties { teamUsers?: TeamUserEntity[]; } -export interface ITeamUserProperties { +export interface TeamUserProperties { user: User; role: Role; school: SchoolEntity; @@ -17,7 +17,7 @@ export interface ITeamUserProperties { @Embeddable() export class TeamUserEntity { - constructor(props: ITeamUserProperties) { + constructor(props: TeamUserProperties) { this.userId = props.user; this.role = props.role; this.schoolId = props.school; From 7860052896110860f1366926fc2c8211d23ed70d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:35:39 +0100 Subject: [PATCH 069/110] IUserProperties -> IUserProperties --- .../src/shared/domain/entity/user.entity.ts | 4 +-- .../user/user-do.repo.integration.spec.ts | 12 ++++---- .../src/shared/repo/user/user-do.repo.ts | 10 +++---- .../testing/factory/base.factory.spec.ts | 28 +++++++++---------- .../shared/testing/factory/user.factory.ts | 14 +++++----- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/server/src/shared/domain/entity/user.entity.ts b/apps/server/src/shared/domain/entity/user.entity.ts index 2d1918e1d61..86ed68eea0f 100644 --- a/apps/server/src/shared/domain/entity/user.entity.ts +++ b/apps/server/src/shared/domain/entity/user.entity.ts @@ -11,7 +11,7 @@ export enum LanguageType { UK = 'uk', } -export interface IUserProperties { +export interface UserProperties { email: string; firstName: string; lastName: string; @@ -96,7 +96,7 @@ export class User extends BaseEntityWithTimestamps implements IEntityWithSchool @Property({ nullable: true }) outdatedSince?: Date; - constructor(props: IUserProperties) { + constructor(props: UserProperties) { super(); this.firstName = props.firstName; this.lastName = props.lastName; 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 43d46a95383..324e07b2092 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 @@ -1,11 +1,12 @@ import { createMock } from '@golevelup/ts-jest'; +import { MongoMemoryDatabaseModule } from '@infra/database'; import { FindOptions, NotFoundError, QueryOrderMap } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { UserQuery } from '@modules/user/service/user-query.type'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { IFindOptions, - IUserProperties, LanguageType, Role, RoleName, @@ -13,10 +14,10 @@ import { SortOrder, SystemEntity, User, + UserProperties, } from '@shared/domain'; import { Page } from '@shared/domain/domainobject/page'; import { UserDO } from '@shared/domain/domainobject/user.do'; -import { MongoMemoryDatabaseModule } from '@infra/database'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; import { cleanupCollections, @@ -27,7 +28,6 @@ import { userFactory, } from '@shared/testing'; import { LegacyLogger } from '@src/core/logger'; -import { UserQuery } from '@modules/user/service/user-query.type'; describe('UserRepo', () => { let module: TestingModule; @@ -67,7 +67,7 @@ describe('UserRepo', () => { }); describe('entityFactory', () => { - const props: IUserProperties = { + const props: UserProperties = { email: 'email@email.email', firstName: 'firstName', lastName: 'lastName', @@ -303,9 +303,9 @@ describe('UserRepo', () => { 'testId' ); - const result: IUserProperties = repo.mapDOToEntityProperties(testDO); + const result: UserProperties = repo.mapDOToEntityProperties(testDO); - expect(result).toEqual({ + expect(result).toEqual({ email: testDO.email, firstName: testDO.firstName, lastName: testDO.lastName, diff --git a/apps/server/src/shared/repo/user/user-do.repo.ts b/apps/server/src/shared/repo/user/user-do.repo.ts index e9eae128a1f..500ba635c7a 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.ts @@ -1,32 +1,32 @@ import { EntityName, FilterQuery, QueryOrderMap } from '@mikro-orm/core'; +import { UserQuery } from '@modules/user/service/user-query.type'; import { Injectable } from '@nestjs/common'; import { EntityNotFoundError } from '@shared/common'; import { EntityId, IFindOptions, IPagination, - IUserProperties, Role, SchoolEntity, SortOrder, SortOrderMap, SystemEntity, User, + UserProperties, } from '@shared/domain'; import { RoleReference } from '@shared/domain/domainobject'; import { Page } from '@shared/domain/domainobject/page'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { BaseDORepo, Scope } from '@shared/repo'; -import { UserQuery } from '@modules/user/service/user-query.type'; import { UserScope } from './user.scope'; @Injectable() -export class UserDORepo extends BaseDORepo { +export class UserDORepo extends BaseDORepo { get entityName(): EntityName { return User; } - entityFactory(props: IUserProperties): User { + entityFactory(props: UserProperties): User { return new User(props); } @@ -120,7 +120,7 @@ export class UserDORepo extends BaseDORepo { return user; } - mapDOToEntityProperties(entityDO: UserDO): IUserProperties { + mapDOToEntityProperties(entityDO: UserDO): UserProperties { return { email: entityDO.email, firstName: entityDO.firstName, diff --git a/apps/server/src/shared/testing/factory/base.factory.spec.ts b/apps/server/src/shared/testing/factory/base.factory.spec.ts index 8e681aff656..6c07cfceca8 100644 --- a/apps/server/src/shared/testing/factory/base.factory.spec.ts +++ b/apps/server/src/shared/testing/factory/base.factory.spec.ts @@ -1,7 +1,7 @@ import { BaseFactory } from './base.factory'; describe('BaseFactory', () => { - interface IUserProperties { + interface UserProperties { email: string; roles: string[]; nickName?: string; @@ -14,7 +14,7 @@ describe('BaseFactory', () => { nickName?: string; - constructor(props: IUserProperties) { + constructor(props: UserProperties) { this.email = props.email; this.roles = props.roles; this.nickName = props.nickName; @@ -29,7 +29,7 @@ describe('BaseFactory', () => { describe('when defining the factory', () => { it('should call the constructor', () => { const Constructor = jest.fn(); - const factory = BaseFactory.define(Constructor, () => { + const factory = BaseFactory.define(Constructor, () => { return { email: 'joe@example.com', roles: ['member'], @@ -41,7 +41,7 @@ describe('BaseFactory', () => { }); it('should create an instance of the class', () => { - const factory = BaseFactory.define(User, () => { + const factory = BaseFactory.define(User, () => { return { email: 'joe@example.com', roles: ['member'], @@ -52,7 +52,7 @@ describe('BaseFactory', () => { }); it('should override default properties', () => { - const factory = BaseFactory.define(User, () => { + const factory = BaseFactory.define(User, () => { return { email: 'joe@example.com', roles: ['member'], @@ -63,7 +63,7 @@ describe('BaseFactory', () => { }); it('should call afterBuild hook', () => { - const factory = BaseFactory.define(User, () => { + const factory = BaseFactory.define(User, () => { return { email: 'joe@example.com', roles: ['member'], @@ -79,7 +79,7 @@ describe('BaseFactory', () => { }); it('should delegate transient params as a trait', () => { - const factory = BaseFactory.define(User, ({ transientParams }) => { + const factory = BaseFactory.define(User, ({ transientParams }) => { const { registered, numTasks } = transientParams; return { email: `joe-${registered ? 'r' : 'u'}-${numTasks || '0'}@example.com`, roles: ['member'] }; }); @@ -88,7 +88,7 @@ describe('BaseFactory', () => { }); it('should delegate transientParams as a build option', () => { - const factory = BaseFactory.define(User, ({ transientParams }) => { + const factory = BaseFactory.define(User, ({ transientParams }) => { const { registered, numTasks } = transientParams; return { email: `joe-${registered ? 'r' : 'u'}-${numTasks || '0'}@example.com`, roles: ['member'] }; }); @@ -97,7 +97,7 @@ describe('BaseFactory', () => { }); it('should delegate associations as a trait', () => { - const factory = BaseFactory.define(User, ({ associations }) => { + const factory = BaseFactory.define(User, ({ associations }) => { return { email: 'joe@example.com', roles: associations.roles || ['member'], @@ -108,7 +108,7 @@ describe('BaseFactory', () => { }); it('should delegate associations as build option', () => { - const factory = BaseFactory.define(User, ({ associations }) => { + const factory = BaseFactory.define(User, ({ associations }) => { return { email: 'joe@example.com', roles: associations.roles || ['member'], @@ -120,7 +120,7 @@ describe('BaseFactory', () => { }); describe('when subclassing the factory', () => { - class UserFactory extends BaseFactory { + class UserFactory extends BaseFactory { admin() { return this.params({ roles: ['admin'] }); } @@ -168,7 +168,7 @@ describe('BaseFactory', () => { describe('when builing a list of objects', () => { it('should call the constructor for each item', () => { const Constructor = jest.fn(); - const factory = BaseFactory.define(Constructor, ({ sequence }) => { + const factory = BaseFactory.define(Constructor, ({ sequence }) => { return { email: `joe-${sequence}@example.com`, roles: ['member'], @@ -179,7 +179,7 @@ describe('BaseFactory', () => { }); it('should create an instance of the class for each item', () => { - const factory = BaseFactory.define(User, ({ sequence }) => { + const factory = BaseFactory.define(User, ({ sequence }) => { return { email: `joe-${sequence}@example.com`, roles: ['member'], @@ -192,7 +192,7 @@ describe('BaseFactory', () => { }); it('should override properties', () => { - const factory = BaseFactory.define(User, ({ sequence }) => { + const factory = BaseFactory.define(User, ({ sequence }) => { return { email: `joe-${sequence}@example.com`, roles: ['member'], diff --git a/apps/server/src/shared/testing/factory/user.factory.ts b/apps/server/src/shared/testing/factory/user.factory.ts index 1557b3ccd35..5b09e5c46b5 100644 --- a/apps/server/src/shared/testing/factory/user.factory.ts +++ b/apps/server/src/shared/testing/factory/user.factory.ts @@ -1,5 +1,5 @@ /* istanbul ignore file */ -import { IUserProperties, Permission, Role, RoleName, User } from '@shared/domain'; +import { Permission, Role, RoleName, User, UserProperties } from '@shared/domain'; import { DeepPartial } from 'fishery'; import _ from 'lodash'; import { adminPermissions, studentPermissions, teacherPermissions, userPermissions } from '../user-role-permissions'; @@ -7,15 +7,15 @@ import { BaseFactory } from './base.factory'; import { roleFactory } from './role.factory'; import { schoolFactory } from './school.factory'; -class UserFactory extends BaseFactory { +class UserFactory extends BaseFactory { withRoleByName(name: RoleName): this { - const params: DeepPartial = { roles: [roleFactory.buildWithId({ name })] }; + const params: DeepPartial = { roles: [roleFactory.buildWithId({ name })] }; return this.params(params); } withRole(role: Role): this { - const params: DeepPartial = { roles: [role] }; + const params: DeepPartial = { roles: [role] }; return this.params(params); } @@ -24,7 +24,7 @@ class UserFactory extends BaseFactory { const permissions = _.union(userPermissions, studentPermissions, additionalPermissions); const role = roleFactory.buildWithId({ permissions, name: RoleName.STUDENT }); - const params: DeepPartial = { roles: [role] }; + const params: DeepPartial = { roles: [role] }; return this.params(params); } @@ -33,7 +33,7 @@ class UserFactory extends BaseFactory { const permissions = _.union(userPermissions, teacherPermissions, additionalPermissions); const role = roleFactory.buildWithId({ permissions, name: RoleName.TEACHER }); - const params: DeepPartial = { roles: [role] }; + const params: DeepPartial = { roles: [role] }; return this.params(params); } @@ -42,7 +42,7 @@ class UserFactory extends BaseFactory { const permissions = _.union(userPermissions, adminPermissions, additionalPermissions); const role = roleFactory.buildWithId({ permissions, name: RoleName.ADMINISTRATOR }); - const params: DeepPartial = { roles: [role] }; + const params: DeepPartial = { roles: [role] }; return this.params(params); } From 9963fb6b6b96a162d37412a42898dfc2ba00c184 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:40:24 +0100 Subject: [PATCH 070/110] IPagination -> Pagination --- .../pseudonym/repo/external-tool-pseudonym.repo.ts | 4 ++-- apps/server/src/modules/task/uc/task.uc.ts | 12 ++++++------ .../src/shared/domain/interface/find-options.ts | 4 ++-- .../shared/repo/externaltool/external-tool.repo.ts | 10 +++++----- apps/server/src/shared/repo/user/user-do.repo.ts | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts index 5c57d0e0ad5..65ef03cd539 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; -import { EntityId, IFindOptions, IPagination, Page, Pseudonym } from '@shared/domain'; +import { EntityId, IFindOptions, Page, Pagination, Pseudonym } from '@shared/domain'; import { Scope } from '@shared/repo'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymEntity, ExternalToolPseudonymEntityProps } from '../entity'; @@ -110,7 +110,7 @@ export class ExternalToolPseudonymRepo { } async findPseudonym(query: PseudonymSearchQuery, options?: IFindOptions): Promise> { - const pagination: IPagination = options?.pagination ?? {}; + const pagination: Pagination = options?.pagination ?? {}; const scope: Scope = new PseudonymScope() .byPseudonym(query.pseudonym) .byToolId(query.toolId) diff --git a/apps/server/src/modules/task/uc/task.uc.ts b/apps/server/src/modules/task/uc/task.uc.ts index a6e40dd3b6d..2e6c392a2d4 100644 --- a/apps/server/src/modules/task/uc/task.uc.ts +++ b/apps/server/src/modules/task/uc/task.uc.ts @@ -1,18 +1,18 @@ +import { Action, AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; import { Injectable, UnauthorizedException } from '@nestjs/common'; import { Counted, Course, EntityId, - IPagination, ITaskStatus, LessonEntity, + Pagination, Permission, SortOrder, TaskWithStatusVo, User, } from '@shared/domain'; import { CourseRepo, LessonRepo, TaskRepo } from '@shared/repo'; -import { Action, AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; import { TaskService } from '../service'; @Injectable() @@ -25,7 +25,7 @@ export class TaskUC { private readonly taskService: TaskService ) {} - async findAllFinished(userId: EntityId, pagination?: IPagination): Promise> { + async findAllFinished(userId: EntityId, pagination?: Pagination): Promise> { const user = await this.authorizationService.getUserWithPermissions(userId); this.authorizationService.checkOneOfPermissions(user, [ @@ -66,7 +66,7 @@ export class TaskUC { return [taskWithStatusVos, total]; } - async findAll(userId: EntityId, pagination: IPagination): Promise> { + async findAll(userId: EntityId, pagination: Pagination): Promise> { let response: Counted; const user = await this.authorizationService.getUserWithPermissions(userId); @@ -123,7 +123,7 @@ export class TaskUC { return result; } - private async findAllForStudent(user: User, pagination: IPagination): Promise> { + private async findAllForStudent(user: User, pagination: Pagination): Promise> { const courses = await this.getPermittedCourses(user, Action.read); const openCourses = courses.filter((c) => !c.isFinished()); const lessons = await this.getPermittedLessons(user, openCourses); @@ -152,7 +152,7 @@ export class TaskUC { return [taskWithStatusVos, total]; } - private async findAllForTeacher(user: User, pagination: IPagination): Promise> { + private async findAllForTeacher(user: User, pagination: Pagination): Promise> { const courses = await this.getPermittedCourses(user, Action.write); const openCourses = courses.filter((c) => !c.isFinished()); const lessons = await this.getPermittedLessons(user, openCourses); diff --git a/apps/server/src/shared/domain/interface/find-options.ts b/apps/server/src/shared/domain/interface/find-options.ts index 2b02990d436..37fc49a5909 100644 --- a/apps/server/src/shared/domain/interface/find-options.ts +++ b/apps/server/src/shared/domain/interface/find-options.ts @@ -1,4 +1,4 @@ -export interface IPagination { +export interface Pagination { skip?: number; limit?: number; } @@ -11,6 +11,6 @@ export enum SortOrder { export type SortOrderMap = Partial>; export interface IFindOptions { - pagination?: IPagination; + pagination?: Pagination; order?: SortOrderMap; } diff --git a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts index 4ea69a54855..3d071311d82 100644 --- a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts +++ b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts @@ -1,13 +1,13 @@ import { EntityName, QueryOrderMap } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; -import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; -import { IFindOptions, IPagination, Page, SortOrder } from '@shared/domain'; -import { BaseDORepo, ExternalToolRepoMapper, ExternalToolSortingMapper, Scope } from '@shared/repo'; -import { LegacyLogger } from '@src/core/logger'; import { ToolConfigType } from '@modules/tool/common/enum'; import { ExternalToolSearchQuery } from '@modules/tool/common/interface'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { ExternalToolEntity, IExternalToolProperties } from '@modules/tool/external-tool/entity'; +import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; +import { IFindOptions, Page, Pagination, SortOrder } from '@shared/domain'; +import { BaseDORepo, ExternalToolRepoMapper, ExternalToolSortingMapper, Scope } from '@shared/repo'; +import { LegacyLogger } from '@src/core/logger'; import { ExternalToolScope } from './external-tool.scope'; @Injectable() @@ -52,7 +52,7 @@ export class ExternalToolRepo extends BaseDORepo): Promise> { - const pagination: IPagination = options?.pagination || {}; + const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = ExternalToolSortingMapper.mapDOSortOrderToQueryOrder( options?.order || {} ); diff --git a/apps/server/src/shared/repo/user/user-do.repo.ts b/apps/server/src/shared/repo/user/user-do.repo.ts index 500ba635c7a..aa13193b0e6 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.ts @@ -5,7 +5,7 @@ import { EntityNotFoundError } from '@shared/common'; import { EntityId, IFindOptions, - IPagination, + Pagination, Role, SchoolEntity, SortOrder, @@ -31,7 +31,7 @@ export class UserDORepo extends BaseDORepo { } async find(query: UserQuery, options?: IFindOptions) { - const pagination: IPagination = options?.pagination || {}; + const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = this.createQueryOrderMap(options?.order || {}); const scope: Scope = new UserScope() .bySchoolId(query.schoolId) From 3ad7af309c44198c3cdedc4362c84fc6bf78f7a2 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:56:26 +0100 Subject: [PATCH 071/110] IFindOptions -> FindOptions --- .../files-storage/repo/filerecord.repo.ts | 10 +++++----- apps/server/src/modules/news/uc/news.uc.ts | 6 +++--- .../repo/external-tool-pseudonym.repo.ts | 4 ++-- .../pseudonym/service/pseudonym.service.spec.ts | 6 +++--- .../pseudonym/service/pseudonym.service.ts | 6 +++--- .../src/modules/task/service/task.service.ts | 6 +++--- .../external-tool/controller/tool.controller.ts | 4 ++-- .../service/external-tool.service.spec.ts | 8 ++++---- .../service/external-tool.service.ts | 4 ++-- .../external-tool/uc/external-tool.uc.spec.ts | 4 ++-- .../tool/external-tool/uc/external-tool.uc.ts | 6 +++--- .../controller/import-user.controller.ts | 6 +++--- .../src/modules/user-import/uc/user-import.uc.ts | 16 ++++++++-------- .../modules/user/service/user.service.spec.ts | 12 ++++++------ .../src/modules/user/service/user.service.ts | 4 ++-- .../src/shared/domain/interface/find-options.ts | 2 +- .../server/src/shared/repo/course/course.repo.ts | 6 +++--- .../external-tool.repo.integration.spec.ts | 14 +++++++------- .../repo/externaltool/external-tool.repo.ts | 4 ++-- .../shared/repo/importuser/importuser.repo.ts | 6 +++--- apps/server/src/shared/repo/news/news.repo.ts | 8 ++++---- apps/server/src/shared/repo/task/task.repo.ts | 10 +++++----- .../repo/user/user-do.repo.integration.spec.ts | 5 ++--- apps/server/src/shared/repo/user/user-do.repo.ts | 4 ++-- apps/server/src/shared/repo/user/user.repo.ts | 4 ++-- 25 files changed, 82 insertions(+), 83 deletions(-) diff --git a/apps/server/src/modules/files-storage/repo/filerecord.repo.ts b/apps/server/src/modules/files-storage/repo/filerecord.repo.ts index 2b87fe61707..6ee9d005962 100644 --- a/apps/server/src/modules/files-storage/repo/filerecord.repo.ts +++ b/apps/server/src/modules/files-storage/repo/filerecord.repo.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { Counted, EntityId, IFindOptions, SortOrder } from '@shared/domain'; +import { Counted, EntityId, FindOptions, SortOrder } from '@shared/domain'; import { BaseRepo } from '@shared/repo'; import { FileRecord } from '../entity'; import { FileRecordScope } from './filerecord-scope'; @@ -24,7 +24,7 @@ export class FileRecordRepo extends BaseRepo { return fileRecord; } - async findByParentId(parentId: EntityId, options?: IFindOptions): Promise> { + async findByParentId(parentId: EntityId, options?: FindOptions): Promise> { const scope = new FileRecordScope().byParentId(parentId).byMarkedForDelete(false); const result = await this.findAndCount(scope, options); @@ -34,7 +34,7 @@ export class FileRecordRepo extends BaseRepo { async findBySchoolIdAndParentId( schoolId: EntityId, parentId: EntityId, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new FileRecordScope().bySchoolId(schoolId).byParentId(parentId).byMarkedForDelete(false); const result = await this.findAndCount(scope, options); @@ -45,7 +45,7 @@ export class FileRecordRepo extends BaseRepo { async findBySchoolIdAndParentIdAndMarkedForDelete( schoolId: EntityId, parentId: EntityId, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new FileRecordScope().bySchoolId(schoolId).byParentId(parentId).byMarkedForDelete(true); const result = await this.findAndCount(scope, options); @@ -64,7 +64,7 @@ export class FileRecordRepo extends BaseRepo { private async findAndCount( scope: FileRecordScope, - options?: IFindOptions + options?: FindOptions ): Promise> { const { pagination } = options || {}; const order = { createdAt: SortOrder.desc, id: SortOrder.asc }; diff --git a/apps/server/src/modules/news/uc/news.uc.ts b/apps/server/src/modules/news/uc/news.uc.ts index de0608b0234..c3d6f917657 100644 --- a/apps/server/src/modules/news/uc/news.uc.ts +++ b/apps/server/src/modules/news/uc/news.uc.ts @@ -1,9 +1,10 @@ +import { FeathersAuthorizationService } from '@modules/authorization'; import { Injectable } from '@nestjs/common'; import { Counted, EntityId, + FindOptions, ICreateNews, - IFindOptions, INewsScope, IUpdateNews, News, @@ -14,7 +15,6 @@ import { import { NewsRepo, NewsTargetFilter } from '@shared/repo'; import { CrudOperation } from '@shared/types'; import { Logger } from '@src/core/logger'; -import { FeathersAuthorizationService } from '@modules/authorization'; import { NewsCrudOperationLoggable } from '../loggable/news-crud-operation.loggable'; type NewsPermission = Permission.NEWS_VIEW | Permission.NEWS_EDIT; @@ -67,7 +67,7 @@ export class NewsUc { public async findAllForUser( userId: EntityId, scope?: INewsScope, - options?: IFindOptions + options?: FindOptions ): Promise> { const unpublished = !!scope?.unpublished; // default is only published news const permissions: [NewsPermission] = NewsUc.getRequiredPermissions(unpublished); diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts index 65ef03cd539..fc35ad9bd0d 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; -import { EntityId, IFindOptions, Page, Pagination, Pseudonym } from '@shared/domain'; +import { EntityId, FindOptions, Page, Pagination, Pseudonym } from '@shared/domain'; import { Scope } from '@shared/repo'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymEntity, ExternalToolPseudonymEntityProps } from '../entity'; @@ -109,7 +109,7 @@ export class ExternalToolPseudonymRepo { }; } - async findPseudonym(query: PseudonymSearchQuery, options?: IFindOptions): Promise> { + async findPseudonym(query: PseudonymSearchQuery, options?: FindOptions): Promise> { const pagination: Pagination = options?.pagination ?? {}; const scope: Scope = new PseudonymScope() .byPseudonym(query.pseudonym) diff --git a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts index 026d28d039f..fbf1867f985 100644 --- a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts +++ b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { IFindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; +import { FindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; import { externalToolFactory, ltiToolDOFactory, pseudonymFactory, userDoFactory } from '@shared/testing/factory'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymRepo, PseudonymsRepo } from '../repo'; import { PseudonymService } from './pseudonym.service'; @@ -474,7 +474,7 @@ describe('PseudonymService', () => { const query: PseudonymSearchQuery = { pseudonym: 'pseudonym', }; - const options: IFindOptions = {}; + const options: FindOptions = {}; const page: Page = new Page([pseudonymFactory.build()], 1); externalToolPseudonymRepo.findPseudonym.mockResolvedValueOnce(page); diff --git a/apps/server/src/modules/pseudonym/service/pseudonym.service.ts b/apps/server/src/modules/pseudonym/service/pseudonym.service.ts index 6d15d6a1ec9..7257af6ec06 100644 --- a/apps/server/src/modules/pseudonym/service/pseudonym.service.ts +++ b/apps/server/src/modules/pseudonym/service/pseudonym.service.ts @@ -1,8 +1,8 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { ObjectId } from '@mikro-orm/mongodb'; -import { Injectable, InternalServerErrorException } from '@nestjs/common'; -import { IFindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; import { ExternalTool } from '@modules/tool/external-tool/domain'; +import { Injectable, InternalServerErrorException } from '@nestjs/common'; +import { FindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; import { v4 as uuidv4 } from 'uuid'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymRepo, PseudonymsRepo } from '../repo'; @@ -123,7 +123,7 @@ export class PseudonymService { return result; } - async findPseudonym(query: PseudonymSearchQuery, options: IFindOptions): Promise> { + async findPseudonym(query: PseudonymSearchQuery, options: FindOptions): Promise> { const result: Page = await this.externalToolPseudonymRepo.findPseudonym(query, options); return result; diff --git a/apps/server/src/modules/task/service/task.service.ts b/apps/server/src/modules/task/service/task.service.ts index 78f9dca9a51..4b0490cf164 100644 --- a/apps/server/src/modules/task/service/task.service.ts +++ b/apps/server/src/modules/task/service/task.service.ts @@ -1,7 +1,7 @@ +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { Injectable } from '@nestjs/common'; -import { Counted, EntityId, IFindOptions, Task } from '@shared/domain'; +import { Counted, EntityId, FindOptions, Task } from '@shared/domain'; import { TaskRepo } from '@shared/repo'; -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { SubmissionService } from './submission.service'; @Injectable() @@ -16,7 +16,7 @@ export class TaskService { creatorId: EntityId, courseId: EntityId, filters?: { draft?: boolean; noFutureAvailableDate?: boolean }, - options?: IFindOptions + options?: FindOptions ): Promise> { return this.taskRepo.findBySingleParent(creatorId, courseId, filters, options); } diff --git a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts index ec102455d06..44f0e0be075 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts @@ -13,7 +13,7 @@ import { } from '@nestjs/swagger'; import { ValidationError } from '@shared/common'; import { PaginationParams } from '@shared/controller'; -import { IFindOptions, Page } from '@shared/domain'; +import { FindOptions, Page } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; import { Response } from 'express'; import { ExternalToolSearchQuery } from '../../common/interface'; @@ -76,7 +76,7 @@ export class ToolController { @Query() pagination: PaginationParams, @Query() sortingQuery: SortExternalToolParams ): Promise { - const options: IFindOptions = { pagination }; + const options: FindOptions = { pagination }; options.order = this.externalToolDOMapper.mapSortingQueryToDomain(sortingQuery); const query: ExternalToolSearchQuery = this.externalToolDOMapper.mapExternalToolFilterQueryToExternalToolSearchQuery(filterQuery); 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 ddb88ca4ff3..c3b55d2db6b 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 @@ -1,10 +1,10 @@ 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 '@infra/encryption'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; +import { UnprocessableEntityException } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; +import { FindOptions, Page, SortOrder } from '@shared/domain'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { externalToolFactory, @@ -223,7 +223,7 @@ describe('ExternalToolService', () => { const query: ExternalToolSearchQuery = { name: 'toolName', }; - const options: IFindOptions = { + const options: FindOptions = { order: { id: SortOrder.asc, name: SortOrder.asc, 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 562ae443112..a83ed5f3545 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 @@ -2,7 +2,7 @@ import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; -import { EntityId, IFindOptions, Page } from '@shared/domain'; +import { EntityId, FindOptions, Page } from '@shared/domain'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { TokenEndpointAuthMethod } from '../../common/enum'; @@ -50,7 +50,7 @@ export class ExternalToolService { async findExternalTools( query: ExternalToolSearchQuery, - options?: IFindOptions + options?: FindOptions ): Promise> { const tools: Page = await this.externalToolRepo.find(query, options); diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts index 56c0075ae97..f4031b52bb0 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts @@ -3,7 +3,7 @@ import { CurrentUserInterface } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { IFindOptions, Permission, SortOrder, User } from '@shared/domain'; +import { FindOptions, Permission, SortOrder, User } from '@shared/domain'; import { Page } from '@shared/domain/domainobject/page'; import { setupEntities, userFactory } from '@shared/testing'; import { @@ -87,7 +87,7 @@ describe('ExternalToolUc', () => { const query: ExternalToolSearchQuery = { name: externalTool.name, }; - const options: IFindOptions = { + const options: FindOptions = { order: { id: SortOrder.asc, name: SortOrder.asc, diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts index 2cf49867103..a082d6a067d 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts @@ -1,6 +1,6 @@ -import { Injectable } from '@nestjs/common'; -import { EntityId, IFindOptions, Page, Permission, User } from '@shared/domain'; import { AuthorizationService } from '@modules/authorization'; +import { Injectable } from '@nestjs/common'; +import { EntityId, FindOptions, Page, Permission, User } from '@shared/domain'; import { ExternalToolSearchQuery } from '../../common/interface'; import { ExternalTool, ExternalToolConfig } from '../domain'; import { ExternalToolLogoService, ExternalToolService, ExternalToolValidationService } from '../service'; @@ -52,7 +52,7 @@ export class ExternalToolUc { async findExternalTool( userId: EntityId, query: ExternalToolSearchQuery, - options: IFindOptions + options: FindOptions ): Promise> { await this.ensurePermission(userId, Permission.TOOL_ADMIN); diff --git a/apps/server/src/modules/user-import/controller/import-user.controller.ts b/apps/server/src/modules/user-import/controller/import-user.controller.ts index 6f49104c425..536b7e4c961 100644 --- a/apps/server/src/modules/user-import/controller/import-user.controller.ts +++ b/apps/server/src/modules/user-import/controller/import-user.controller.ts @@ -2,7 +2,7 @@ import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authen import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; -import { IFindOptions, ImportUser, User } from '@shared/domain'; +import { FindOptions, ImportUser, User } from '@shared/domain'; import { ImportUserMapper } from '../mapper/import-user.mapper'; import { UserMatchMapper } from '../mapper/user-match.mapper'; import { UserImportUc } from '../uc/user-import.uc'; @@ -32,7 +32,7 @@ export class ImportUserController { @Query() sortingQuery: SortImportUserParams, @Query() pagination: PaginationParams ): Promise { - const options: IFindOptions = { pagination }; + const options: FindOptions = { pagination }; options.order = ImportUserMapper.mapSortingQueryToDomain(sortingQuery); const query = ImportUserMapper.mapImportUserFilterQueryToDomain(scope); const [importUserList, count] = await this.userImportUc.findAllImportUsers(currentUser.userId, query, options); @@ -84,7 +84,7 @@ export class ImportUserController { @Query() scope: FilterUserParams, @Query() pagination: PaginationParams ): Promise { - const options: IFindOptions = { pagination }; + const options: FindOptions = { pagination }; const query = UserMatchMapper.mapToDomain(scope); const [userList, total] = await this.userUc.findAllUnmatchedUsers(currentUser.userId, query, options); diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index 2dda936b1fb..92e87cf8348 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -1,11 +1,15 @@ import { Configuration } from '@hpi-schul-cloud/commons'; +import { AccountService } from '@modules/account/services/account.service'; +import { AccountDto } from '@modules/account/services/dto/account.dto'; +import { AuthorizationService } from '@modules/authorization'; +import { LegacySchoolService } from '@modules/legacy-school'; import { BadRequestException, ForbiddenException, Injectable, InternalServerErrorException } from '@nestjs/common'; import { UserAlreadyAssignedToImportUserError } from '@shared/common'; import { Account, Counted, EntityId, - IFindOptions, + FindOptions, IImportUserScope, ImportUser, INameMatch, @@ -19,10 +23,6 @@ import { } from '@shared/domain'; import { ImportUserRepo, SystemRepo, UserRepo } from '@shared/repo'; import { Logger } from '@src/core/logger'; -import { AccountService } from '@modules/account/services/account.service'; -import { AccountDto } from '@modules/account/services/dto/account.dto'; -import { AuthorizationService } from '@modules/authorization'; -import { LegacySchoolService } from '@modules/legacy-school'; import { AccountSaveDto } from '../../account/services/dto'; import { MigrationMayBeCompleted, @@ -76,7 +76,7 @@ export class UserImportUc { async findAllImportUsers( currentUserId: EntityId, query: IImportUserScope, - options?: IFindOptions + options?: FindOptions ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); @@ -165,7 +165,7 @@ export class UserImportUc { async findAllUnmatchedUsers( currentUserId: EntityId, query: INameMatch, - options?: IFindOptions + options?: FindOptions ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); @@ -181,7 +181,7 @@ export class UserImportUc { this.checkFeatureEnabled(school); const filters: IImportUserScope = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; // TODO batch/paginated import? - const options: IFindOptions = {}; + const options: FindOptions = {}; // TODO Change ImportUserRepo to DO to fix this workaround const [importUsers, total] = await this.importUserRepo.findImportUsers(currentUser.school, filters, options); let migratedUser = 0; diff --git a/apps/server/src/modules/user/service/user.service.spec.ts b/apps/server/src/modules/user/service/user.service.spec.ts index f65d02c13a5..ad6dec2241a 100644 --- a/apps/server/src/modules/user/service/user.service.spec.ts +++ b/apps/server/src/modules/user/service/user.service.spec.ts @@ -1,18 +1,18 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/core'; +import { AccountDto, AccountService } from '@modules/account'; +import { OauthCurrentUser } from '@modules/authentication/interface'; +import { RoleService } from '@modules/role'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { EntityId, IFindOptions, LanguageType, Permission, Role, RoleName, SortOrder, User } from '@shared/domain'; +import { EntityId, FindOptions, LanguageType, Permission, Role, RoleName, SortOrder, User } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { UserRepo } from '@shared/repo'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; import { roleFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; -import { AccountService, AccountDto } from '@modules/account'; -import { RoleService } from '@modules/role'; -import { OauthCurrentUser } from '@modules/authentication/interface'; import { UserDto } from '../uc/dto/user.dto'; -import { UserService } from './user.service'; import { UserQuery } from './user-query.type'; +import { UserService } from './user.service'; describe('UserService', () => { let service: UserService; @@ -318,7 +318,7 @@ describe('UserService', () => { schoolId: 'schoolId', isOutdated: true, }; - const options: IFindOptions = { order: { id: SortOrder.asc } }; + const options: FindOptions = { order: { id: SortOrder.asc } }; await service.findUsers(query, options); diff --git a/apps/server/src/modules/user/service/user.service.ts b/apps/server/src/modules/user/service/user.service.ts index 6ef014f8696..06bc1754f8d 100644 --- a/apps/server/src/modules/user/service/user.service.ts +++ b/apps/server/src/modules/user/service/user.service.ts @@ -7,7 +7,7 @@ import { RoleDto } from '@modules/role/service/dto/role.dto'; import { RoleService } from '@modules/role/service/role.service'; import { BadRequestException, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { EntityId, IFindOptions, LanguageType, User } from '@shared/domain'; +import { EntityId, FindOptions, LanguageType, User } from '@shared/domain'; import { Page, RoleReference, UserDO } from '@shared/domain/domainobject'; import { UserRepo } from '@shared/repo'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; @@ -70,7 +70,7 @@ export class UserService { return savedUsers; } - async findUsers(query: UserQuery, options?: IFindOptions): Promise> { + async findUsers(query: UserQuery, options?: FindOptions): Promise> { const users: Page = await this.userDORepo.find(query, options); return users; diff --git a/apps/server/src/shared/domain/interface/find-options.ts b/apps/server/src/shared/domain/interface/find-options.ts index 37fc49a5909..5a3dbcb3d97 100644 --- a/apps/server/src/shared/domain/interface/find-options.ts +++ b/apps/server/src/shared/domain/interface/find-options.ts @@ -10,7 +10,7 @@ export enum SortOrder { export type SortOrderMap = Partial>; -export interface IFindOptions { +export interface FindOptions { pagination?: Pagination; order?: SortOrderMap; } diff --git a/apps/server/src/shared/repo/course/course.repo.ts b/apps/server/src/shared/repo/course/course.repo.ts index b673dbfded8..db8263d79d4 100644 --- a/apps/server/src/shared/repo/course/course.repo.ts +++ b/apps/server/src/shared/repo/course/course.repo.ts @@ -1,7 +1,7 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; -import { Counted, Course, EntityId, IFindOptions } from '@shared/domain'; +import { Counted, Course, EntityId, FindOptions } from '@shared/domain'; import { BaseRepo } from '../base.repo'; import { Scope } from '../scope'; @@ -71,7 +71,7 @@ export class CourseRepo extends BaseRepo { async findAllByUserId( userId: EntityId, filters?: { onlyActiveCourses?: boolean }, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new CourseScope(); scope.forAllGroupTypes(userId); @@ -95,7 +95,7 @@ export class CourseRepo extends BaseRepo { async findAllForTeacher( userId: EntityId, filters?: { onlyActiveCourses?: boolean }, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new CourseScope(); scope.forTeacher(userId); 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 1654da1b5b7..d5e34d34732 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 @@ -1,11 +1,6 @@ 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 '@infra/database'; -import { ExternalToolRepo, ExternalToolRepoMapper } from '@shared/repo'; -import { cleanupCollections, externalToolEntityFactory } from '@shared/testing'; -import { LegacyLogger } from '@src/core/logger'; +import { EntityManager } from '@mikro-orm/mongodb'; import { ExternalToolSearchQuery } from '@modules/tool'; import { CustomParameter } from '@modules/tool/common/domain'; import { @@ -18,6 +13,11 @@ import { } from '@modules/tool/common/enum'; import { BasicToolConfig, ExternalTool, Lti11ToolConfig, Oauth2ToolConfig } from '@modules/tool/external-tool/domain'; import { ExternalToolEntity } from '@modules/tool/external-tool/entity'; +import { Test, TestingModule } from '@nestjs/testing'; +import { FindOptions, Page, SortOrder } from '@shared/domain'; +import { ExternalToolRepo, ExternalToolRepoMapper } from '@shared/repo'; +import { cleanupCollections, externalToolEntityFactory } from '@shared/testing'; +import { LegacyLogger } from '@src/core/logger'; describe('ExternalToolRepo', () => { let module: TestingModule; @@ -218,7 +218,7 @@ describe('ExternalToolRepo', () => { const { queryExternalToolDO } = await setup(); queryExternalToolDO.name = '.'; - const options: IFindOptions = {}; + const options: FindOptions = {}; await em.nativeDelete(ExternalToolEntity, {}); const ltiToolA: ExternalToolEntity = externalToolEntityFactory.withName('A').buildWithId(); diff --git a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts index 3d071311d82..a500e7127bc 100644 --- a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts +++ b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts @@ -5,7 +5,7 @@ import { ExternalToolSearchQuery } from '@modules/tool/common/interface'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { ExternalToolEntity, IExternalToolProperties } from '@modules/tool/external-tool/entity'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; -import { IFindOptions, Page, Pagination, SortOrder } from '@shared/domain'; +import { FindOptions, Page, Pagination, SortOrder } from '@shared/domain'; import { BaseDORepo, ExternalToolRepoMapper, ExternalToolSortingMapper, Scope } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { ExternalToolScope } from './external-tool.scope'; @@ -51,7 +51,7 @@ export class ExternalToolRepo extends BaseDORepo): Promise> { + async find(query: ExternalToolSearchQuery, options?: FindOptions): Promise> { const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = ExternalToolSortingMapper.mapDOSortOrderToQueryOrder( options?.order || {} diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.ts b/apps/server/src/shared/repo/importuser/importuser.repo.ts index c09e5f9ee87..3bd0ca83f6b 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.ts @@ -2,7 +2,7 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { ObjectId } from '@mikro-orm/mongodb'; -import { Counted, EntityId, IFindOptions, IImportUserScope, ImportUser, SchoolEntity, User } from '@shared/domain'; +import { Counted, EntityId, FindOptions, IImportUserScope, ImportUser, SchoolEntity, User } from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { ImportUserScope } from './importuser.scope'; @@ -34,7 +34,7 @@ export class ImportUserRepo extends BaseRepo { async findImportUsers( school: SchoolEntity, filters: IImportUserScope = {}, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new ImportUserScope(); scope.bySchool(school); @@ -51,7 +51,7 @@ export class ImportUserRepo extends BaseRepo { private async findImportUsersAndCount( query: FilterQuery, - options?: IFindOptions + options?: FindOptions ): Promise> { const { pagination, order } = options || {}; const queryOptions = { diff --git a/apps/server/src/shared/repo/news/news.repo.ts b/apps/server/src/shared/repo/news/news.repo.ts index f6ff97cfa9c..2d5c6e19183 100644 --- a/apps/server/src/shared/repo/news/news.repo.ts +++ b/apps/server/src/shared/repo/news/news.repo.ts @@ -1,6 +1,6 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; -import { Counted, CourseNews, EntityId, IFindOptions, News, SchoolNews, TeamNews } from '@shared/domain'; +import { Counted, CourseNews, EntityId, FindOptions, News, SchoolNews, TeamNews } from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { NewsScope } from './news-scope'; import { NewsTargetFilter } from './news-target-filter'; @@ -18,7 +18,7 @@ export class NewsRepo extends BaseRepo { * @param targets * @param options */ - async findAllPublished(targets: NewsTargetFilter[], options?: IFindOptions): Promise> { + async findAllPublished(targets: NewsTargetFilter[], options?: FindOptions): Promise> { const scope = new NewsScope(); scope.byTargets(targets); scope.byPublished(); @@ -36,7 +36,7 @@ export class NewsRepo extends BaseRepo { async findAllUnpublishedByUser( targets: NewsTargetFilter[], creatorId: EntityId, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new NewsScope(); scope.byTargets(targets); @@ -55,7 +55,7 @@ export class NewsRepo extends BaseRepo { } /** resolves a news documents list with some elements (school, target, and updator/creator) populated already */ - private async findNewsAndCount(query: FilterQuery, options?: IFindOptions): Promise> { + private async findNewsAndCount(query: FilterQuery, options?: FindOptions): Promise> { const { pagination, order } = options || {}; const [newsEntities, count] = await this._em.findAndCount(News, query, { ...pagination, diff --git a/apps/server/src/shared/repo/task/task.repo.ts b/apps/server/src/shared/repo/task/task.repo.ts index 094d21a8dc5..a5ab4375284 100644 --- a/apps/server/src/shared/repo/task/task.repo.ts +++ b/apps/server/src/shared/repo/task/task.repo.ts @@ -1,7 +1,7 @@ import { FilterQuery } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { Task } from '@shared/domain/entity'; -import { IFindOptions, SortOrder } from '@shared/domain/interface'; +import { FindOptions, SortOrder } from '@shared/domain/interface'; import { Counted, EntityId } from '@shared/domain/types'; import { BaseRepo } from '../base.repo'; import { TaskScope } from './task-scope'; @@ -43,7 +43,7 @@ export class TaskRepo extends BaseRepo { finishedCourseIds: EntityId[]; lessonIdsOfFinishedCourses: EntityId[]; }, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new TaskScope('$or'); @@ -114,7 +114,7 @@ export class TaskRepo extends BaseRepo { finished?: { userId: EntityId; value: boolean }; availableOn?: Date; }, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new TaskScope(); @@ -165,7 +165,7 @@ export class TaskRepo extends BaseRepo { creatorId: EntityId, courseId: EntityId, filters?: { draft?: boolean; noFutureAvailableDate?: boolean }, - options?: IFindOptions + options?: FindOptions ): Promise> { const scope = new TaskScope(); scope.byCourseIds([courseId]); @@ -187,7 +187,7 @@ export class TaskRepo extends BaseRepo { return countedTaskList; } - private async findTasksAndCount(query: FilterQuery, options?: IFindOptions): Promise> { + private async findTasksAndCount(query: FilterQuery, options?: FindOptions): Promise> { const pagination = options?.pagination || {}; const order = options?.order || {}; 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 324e07b2092..c07e47d2453 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 @@ -6,7 +6,6 @@ import { UserQuery } from '@modules/user/service/user-query.type'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { - IFindOptions, LanguageType, Role, RoleName, @@ -336,7 +335,7 @@ describe('UserRepo', () => { lastLoginSystemChangeBetweenStart: undefined, }; - const options: IFindOptions = {}; + const options: FindOptions = {}; await em.nativeDelete(User, {}); await em.nativeDelete(SchoolEntity, {}); @@ -460,7 +459,7 @@ describe('UserRepo', () => { lastLoginSystemChangeBetweenEnd: new Date(), }; - const options: IFindOptions = {}; + const options: FindOptions = {}; await em.nativeDelete(User, {}); await em.nativeDelete(SchoolEntity, {}); diff --git a/apps/server/src/shared/repo/user/user-do.repo.ts b/apps/server/src/shared/repo/user/user-do.repo.ts index aa13193b0e6..379f86be1d1 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.ts @@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common'; import { EntityNotFoundError } from '@shared/common'; import { EntityId, - IFindOptions, + FindOptions, Pagination, Role, SchoolEntity, @@ -30,7 +30,7 @@ export class UserDORepo extends BaseDORepo { return new User(props); } - async find(query: UserQuery, options?: IFindOptions) { + async find(query: UserQuery, options?: FindOptions) { const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = this.createQueryOrderMap(options?.order || {}); const scope: Scope = new UserScope() diff --git a/apps/server/src/shared/repo/user/user.repo.ts b/apps/server/src/shared/repo/user/user.repo.ts index a067953faba..a947c646f7b 100644 --- a/apps/server/src/shared/repo/user/user.repo.ts +++ b/apps/server/src/shared/repo/user/user.repo.ts @@ -5,7 +5,7 @@ import { StringValidator } from '@shared/common'; import { Counted, EntityId, - IFindOptions, + FindOptions, ImportUser, INameMatch, Role, @@ -48,7 +48,7 @@ export class UserRepo extends BaseRepo { async findWithoutImportUser( school: SchoolEntity, filters?: INameMatch, - options?: IFindOptions + options?: FindOptions ): Promise> { const { _id: schoolId } = school; if (!ObjectId.isValid(schoolId)) throw new Error('invalid school id'); From 90927a2343736f0699999092d2ff5cb42767dbef Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 10:59:04 +0100 Subject: [PATCH 072/110] ILearnroom -> Learnroom --- .../src/shared/domain/entity/course.entity.ts | 7 +--- .../domain/entity/dashboard.entity.spec.ts | 6 +-- .../shared/domain/entity/dashboard.entity.ts | 40 +++++++++---------- .../src/shared/domain/interface/learnroom.ts | 2 +- .../repo/dashboard/dashboard.model.mapper.ts | 12 +++--- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 9ed023c1ed7..8766bb834cd 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -2,7 +2,7 @@ import { Collection, Entity, Enum, Index, ManyToMany, ManyToOne, OneToMany, Prop import { ClassEntity } from '@modules/class/entity/class.entity'; import { GroupEntity } from '@modules/group/entity/group.entity'; import { InternalServerErrorException } from '@nestjs/common/exceptions/internal-server-error.exception'; -import { IEntityWithSchool, ILearnroom } from '@shared/domain/interface'; +import { IEntityWithSchool, Learnroom } from '@shared/domain/interface'; import { EntityId, LearnroomMetadata, LearnroomTypes } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; @@ -49,10 +49,7 @@ export class UsersList { } @Entity({ tableName: 'courses' }) -export class Course - extends BaseEntityWithTimestamps - implements ILearnroom, IEntityWithSchool, TaskParent, LessonParent -{ +export class Course extends BaseEntityWithTimestamps implements Learnroom, IEntityWithSchool, TaskParent, LessonParent { @Property() name: string = DEFAULT.name; diff --git a/apps/server/src/shared/domain/entity/dashboard.entity.spec.ts b/apps/server/src/shared/domain/entity/dashboard.entity.spec.ts index b16eb7c0a16..5086255e6cf 100644 --- a/apps/server/src/shared/domain/entity/dashboard.entity.spec.ts +++ b/apps/server/src/shared/domain/entity/dashboard.entity.spec.ts @@ -1,8 +1,8 @@ -import { NotFoundException, BadRequestException } from '@nestjs/common'; -import { ILearnroom, LearnroomTypes } from '@shared/domain'; +import { BadRequestException, NotFoundException } from '@nestjs/common'; +import { Learnroom, LearnroomTypes } from '@shared/domain'; import { DashboardEntity, GridElement } from './dashboard.entity'; -const getLearnroomMock = (id: string): ILearnroom => { +const getLearnroomMock = (id: string): Learnroom => { return { getMetadata: () => { return { diff --git a/apps/server/src/shared/domain/entity/dashboard.entity.ts b/apps/server/src/shared/domain/entity/dashboard.entity.ts index eeeddec70e8..dc40c94323e 100644 --- a/apps/server/src/shared/domain/entity/dashboard.entity.ts +++ b/apps/server/src/shared/domain/entity/dashboard.entity.ts @@ -1,5 +1,5 @@ import { BadRequestException, NotFoundException } from '@nestjs/common'; -import { ILearnroom } from '@shared/domain/interface'; +import { Learnroom } from '@shared/domain/interface'; import { EntityId, LearnroomMetadata } from '@shared/domain/types'; const defaultColumns = 4; @@ -15,11 +15,11 @@ export interface GridElementInterface { removeReferenceByIndex(index: number): void; - removeReference(reference: ILearnroom): void; + removeReference(reference: Learnroom): void; - getReferences(): ILearnroom[]; + getReferences(): Learnroom[]; - addReferences(anotherReference: ILearnroom[]): void; + addReferences(anotherReference: Learnroom[]): void; setGroupName(newGroupName: string): void; } @@ -39,7 +39,7 @@ export class GridElement implements GridElementInterface { title?: string; - private sortReferences = (a: ILearnroom, b: ILearnroom) => { + private sortReferences = (a: Learnroom, b: Learnroom) => { const titleA = a.getMetadata().title; const titleB = b.getMetadata().title; if (titleA < titleB) { @@ -51,29 +51,29 @@ export class GridElement implements GridElementInterface { return 0; }; - private constructor(props: { id?: EntityId; title?: string; references: ILearnroom[] }) { + private constructor(props: { id?: EntityId; title?: string; references: Learnroom[] }) { if (props.id) this.id = props.id; if (props.title) this.title = props.title; this.references = props.references.sort(this.sortReferences); } - static FromPersistedReference(id: EntityId, reference: ILearnroom): GridElement { + static FromPersistedReference(id: EntityId, reference: Learnroom): GridElement { return new GridElement({ id, references: [reference] }); } - static FromPersistedGroup(id: EntityId, title: string | undefined, group: ILearnroom[]): GridElement { + static FromPersistedGroup(id: EntityId, title: string | undefined, group: Learnroom[]): GridElement { return new GridElement({ id, title, references: group }); } - static FromSingleReference(reference: ILearnroom): GridElement { + static FromSingleReference(reference: Learnroom): GridElement { return new GridElement({ references: [reference] }); } - static FromGroup(title: string, references: ILearnroom[]): GridElement { + static FromGroup(title: string, references: Learnroom[]): GridElement { return new GridElement({ title, references }); } - references: ILearnroom[]; + references: Learnroom[]; hasId(): boolean { return !!this.id; @@ -83,7 +83,7 @@ export class GridElement implements GridElementInterface { return this.id; } - getReferences(): ILearnroom[] { + getReferences(): Learnroom[] { return this.references; } @@ -97,7 +97,7 @@ export class GridElement implements GridElementInterface { this.references.splice(index, 1); } - removeReference(reference: ILearnroom): void { + removeReference(reference: Learnroom): void { const index = this.references.indexOf(reference); if (index === -1) { throw new BadRequestException('reference not found.'); @@ -105,7 +105,7 @@ export class GridElement implements GridElementInterface { this.references.splice(index, 1); } - addReferences(anotherReference: ILearnroom[]): void { + addReferences(anotherReference: Learnroom[]): void { if (!this.isGroup()) { this.references = this.references.concat(anotherReference).sort(this.sortReferences); this.setGroupName(''); @@ -228,7 +228,7 @@ export class DashboardEntity { }; } - setLearnRooms(rooms: ILearnroom[]): void { + setLearnRooms(rooms: Learnroom[]): void { this.removeRoomsNotInList(rooms); const newRooms = this.determineNewRoomsIn(rooms); @@ -237,7 +237,7 @@ export class DashboardEntity { }); } - private removeRoomsNotInList(roomList: ILearnroom[]): void { + private removeRoomsNotInList(roomList: Learnroom[]): void { [...this.grid.keys()].forEach((key) => { const element = this.grid.get(key) as GridElementInterface; const currentRooms = element.getReferences(); @@ -252,8 +252,8 @@ export class DashboardEntity { }); } - private determineNewRoomsIn(rooms: ILearnroom[]): ILearnroom[] { - const result: ILearnroom[] = []; + private determineNewRoomsIn(rooms: Learnroom[]): Learnroom[] { + const result: Learnroom[] = []; const existingRooms = this.allRooms(); rooms.forEach((room) => { if (!existingRooms.includes(room)) { @@ -263,13 +263,13 @@ export class DashboardEntity { return result; } - private allRooms(): ILearnroom[] { + private allRooms(): Learnroom[] { const elements = [...this.grid.values()]; const references = elements.map((el) => el.getReferences()).flat(); return references; } - private addRoom(room: ILearnroom): void { + private addRoom(room: Learnroom): void { const index = this.getFirstOpenIndex(); const newElement = GridElement.FromSingleReference(room); this.grid.set(index, newElement); diff --git a/apps/server/src/shared/domain/interface/learnroom.ts b/apps/server/src/shared/domain/interface/learnroom.ts index 849493969a2..a0c8e794d68 100644 --- a/apps/server/src/shared/domain/interface/learnroom.ts +++ b/apps/server/src/shared/domain/interface/learnroom.ts @@ -1,6 +1,6 @@ import { LearnroomMetadata } from '@shared/domain/types'; -export interface ILearnroom { +export interface Learnroom { getMetadata: () => LearnroomMetadata; } diff --git a/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.ts b/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.ts index 4cac8dc0b10..e43f08d147d 100644 --- a/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.ts +++ b/apps/server/src/shared/repo/dashboard/dashboard.model.mapper.ts @@ -1,14 +1,14 @@ -import { wrap, EntityManager } from '@mikro-orm/core'; +import { EntityManager, wrap } from '@mikro-orm/core'; import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { + Course, DashboardEntity, + DashboardGridElementModel, + DashboardModelEntity, GridElement, GridElementWithPosition, - ILearnroom, + Learnroom, LearnroomTypes, - DashboardGridElementModel, - DashboardModelEntity, - Course, User, } from '@shared/domain'; @@ -39,7 +39,7 @@ export class DashboardModelMapper { return new DashboardEntity(modelEntity.id, { grid, userId: modelEntity.user.id }); } - mapReferenceToModel(reference: ILearnroom): Course { + mapReferenceToModel(reference: Learnroom): Course { const metadata = reference.getMetadata(); if (metadata.type === LearnroomTypes.Course) { const course = reference as Course; From 1762501b8805ecbab305d27aea3c57a85d838729 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:04:25 +0100 Subject: [PATCH 073/110] IImportUserScope -> ImportUserScopeInterface --- .../modules/user-import/mapper/import-user.mapper.ts | 8 ++++---- .../src/modules/user-import/uc/user-import.uc.ts | 6 +++--- .../src/shared/domain/types/importuser.types.ts | 2 +- .../src/shared/repo/importuser/importuser.repo.ts | 12 ++++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/user-import/mapper/import-user.mapper.ts b/apps/server/src/modules/user-import/mapper/import-user.mapper.ts index 6b19653f4de..5f154c58ef4 100644 --- a/apps/server/src/modules/user-import/mapper/import-user.mapper.ts +++ b/apps/server/src/modules/user-import/mapper/import-user.mapper.ts @@ -1,9 +1,9 @@ import { BadRequestException } from '@nestjs/common'; import { StringValidator } from '@shared/common'; -import { ImportUser, IImportUserScope, SortOrderMap } from '@shared/domain'; +import { ImportUser, ImportUserScopeInterface, SortOrderMap } from '@shared/domain'; import { - ImportUserResponse, FilterImportUserParams, + ImportUserResponse, ImportUserSortOrder, SortImportUserParams, } from '../controller/dto'; @@ -46,8 +46,8 @@ export class ImportUserMapper { return dto; } - static mapImportUserFilterQueryToDomain(query: FilterImportUserParams): IImportUserScope { - const dto: IImportUserScope = {}; + static mapImportUserFilterQueryToDomain(query: FilterImportUserParams): ImportUserScopeInterface { + const dto: ImportUserScopeInterface = {}; if (StringValidator.isNotEmptyString(query.firstName)) dto.firstName = query.firstName; if (StringValidator.isNotEmptyString(query.lastName)) dto.lastName = query.lastName; if (StringValidator.isNotEmptyString(query.loginName)) dto.loginName = query.loginName; diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index 92e87cf8348..7ed0a22370e 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -10,8 +10,8 @@ import { Counted, EntityId, FindOptions, - IImportUserScope, ImportUser, + ImportUserScopeInterface, INameMatch, LegacySchoolDo, MatchCreator, @@ -75,7 +75,7 @@ export class UserImportUc { */ async findAllImportUsers( currentUserId: EntityId, - query: IImportUserScope, + query: ImportUserScopeInterface, options?: FindOptions ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); @@ -179,7 +179,7 @@ export class UserImportUc { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_MIGRATE); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); this.checkFeatureEnabled(school); - const filters: IImportUserScope = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; + const filters: ImportUserScopeInterface = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; // TODO batch/paginated import? const options: FindOptions = {}; // TODO Change ImportUserRepo to DO to fix this workaround diff --git a/apps/server/src/shared/domain/types/importuser.types.ts b/apps/server/src/shared/domain/types/importuser.types.ts index 52edf935fb9..2148322c422 100644 --- a/apps/server/src/shared/domain/types/importuser.types.ts +++ b/apps/server/src/shared/domain/types/importuser.types.ts @@ -6,7 +6,7 @@ export enum MatchCreatorScope { NONE = 'none', } -export interface IImportUserScope { +export interface ImportUserScopeInterface { firstName?: string; lastName?: string; loginName?: string; diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.ts b/apps/server/src/shared/repo/importuser/importuser.repo.ts index 3bd0ca83f6b..e52ab86a494 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.ts @@ -2,7 +2,15 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { ObjectId } from '@mikro-orm/mongodb'; -import { Counted, EntityId, FindOptions, IImportUserScope, ImportUser, SchoolEntity, User } from '@shared/domain'; +import { + Counted, + EntityId, + FindOptions, + ImportUser, + ImportUserScopeInterface, + SchoolEntity, + User, +} from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { ImportUserScope } from './importuser.scope'; @@ -33,7 +41,7 @@ export class ImportUserRepo extends BaseRepo { async findImportUsers( school: SchoolEntity, - filters: IImportUserScope = {}, + filters: ImportUserScopeInterface = {}, options?: FindOptions ): Promise> { const scope = new ImportUserScope(); From da74cea66889593d41d0b06385eff82bd409f82a Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:05:51 +0100 Subject: [PATCH 074/110] INameMatch -> NameMatch --- .../src/modules/user-import/mapper/user-match.mapper.ts | 8 ++++---- apps/server/src/modules/user-import/uc/user-import.uc.ts | 4 ++-- apps/server/src/shared/domain/types/importuser.types.ts | 2 +- apps/server/src/shared/repo/user/user.repo.ts | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/modules/user-import/mapper/user-match.mapper.ts b/apps/server/src/modules/user-import/mapper/user-match.mapper.ts index 5d99bc1d860..8a826a613af 100644 --- a/apps/server/src/modules/user-import/mapper/user-match.mapper.ts +++ b/apps/server/src/modules/user-import/mapper/user-match.mapper.ts @@ -1,12 +1,12 @@ import { StringValidator } from '@shared/common'; -import { INameMatch, MatchCreator, User } from '@shared/domain'; -import { UserRole, UserMatchResponse } from '../controller/dto'; +import { MatchCreator, NameMatch, User } from '@shared/domain'; +import { UserMatchResponse, UserRole } from '../controller/dto'; import { FilterUserParams } from '../controller/dto/filter-user.params'; import { ImportUserMatchMapper } from './match.mapper'; export class UserMatchMapper { - static mapToDomain(query: FilterUserParams): INameMatch { - const scope: INameMatch = {}; + static mapToDomain(query: FilterUserParams): NameMatch { + const scope: NameMatch = {}; if (query.name) { if (StringValidator.isNotEmptyString(query.name, true)) { scope.name = query.name; diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index 7ed0a22370e..df1d069e3f8 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -12,10 +12,10 @@ import { FindOptions, ImportUser, ImportUserScopeInterface, - INameMatch, LegacySchoolDo, MatchCreator, MatchCreatorScope, + NameMatch, Permission, SchoolFeatures, SystemEntity, @@ -164,7 +164,7 @@ export class UserImportUc { */ async findAllUnmatchedUsers( currentUserId: EntityId, - query: INameMatch, + query: NameMatch, options?: FindOptions ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); diff --git a/apps/server/src/shared/domain/types/importuser.types.ts b/apps/server/src/shared/domain/types/importuser.types.ts index 2148322c422..bfd0d935177 100644 --- a/apps/server/src/shared/domain/types/importuser.types.ts +++ b/apps/server/src/shared/domain/types/importuser.types.ts @@ -16,7 +16,7 @@ export interface ImportUserScopeInterface { classes?: string; } -export interface INameMatch { +export interface NameMatch { /** * Match filter for lastName or firstName */ diff --git a/apps/server/src/shared/repo/user/user.repo.ts b/apps/server/src/shared/repo/user/user.repo.ts index a947c646f7b..7c5e7635f87 100644 --- a/apps/server/src/shared/repo/user/user.repo.ts +++ b/apps/server/src/shared/repo/user/user.repo.ts @@ -7,7 +7,7 @@ import { EntityId, FindOptions, ImportUser, - INameMatch, + NameMatch, Role, SchoolEntity, SortOrder, @@ -47,7 +47,7 @@ export class UserRepo extends BaseRepo { */ async findWithoutImportUser( school: SchoolEntity, - filters?: INameMatch, + filters?: NameMatch, options?: FindOptions ): Promise> { const { _id: schoolId } = school; From d89840a110a4b4d0e44f237fbaafeee3c054cb2c Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:07:41 +0100 Subject: [PATCH 075/110] ICreateNews -> CreateNews --- TODO.md | 2 +- apps/server/src/modules/news/mapper/news.mapper.spec.ts | 6 +++--- apps/server/src/modules/news/mapper/news.mapper.ts | 4 ++-- apps/server/src/modules/news/uc/news.uc.spec.ts | 8 ++++---- apps/server/src/modules/news/uc/news.uc.ts | 4 ++-- apps/server/src/shared/domain/types/news.types.ts | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TODO.md b/TODO.md index 90f2bcfd358..7fa92508759 100644 --- a/TODO.md +++ b/TODO.md @@ -88,4 +88,4 @@ - naming of dtos and dto-files: api vs domain, we leave out "dto" suffix for simplicity (we know that they are dtos) and instead append a specific suffix: e.g. api: , , - domain: , + domain: , diff --git a/apps/server/src/modules/news/mapper/news.mapper.spec.ts b/apps/server/src/modules/news/mapper/news.mapper.spec.ts index 07b613c68fe..40bd66d8130 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.spec.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.spec.ts @@ -1,7 +1,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { CourseNews, - ICreateNews, + CreateNews, INewsScope, IUpdateNews, News, @@ -204,8 +204,8 @@ describe('NewsMapper', () => { targetModel, targetId, }; - const result: ICreateNews = NewsMapper.mapCreateNewsToDomain(params); - const expected: ICreateNews = { + const result: CreateNews = NewsMapper.mapCreateNewsToDomain(params); + const expected: CreateNews = { title: params.title, content: params.content, displayAt: date, diff --git a/apps/server/src/modules/news/mapper/news.mapper.ts b/apps/server/src/modules/news/mapper/news.mapper.ts index aa064a97b1a..36c17f57607 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.ts @@ -1,4 +1,4 @@ -import { News, ICreateNews, INewsScope, IUpdateNews, NewsTargetModel } from '@shared/domain'; +import { CreateNews, INewsScope, IUpdateNews, News, NewsTargetModel } from '@shared/domain'; import { LogMessageData } from '@src/core/logger'; import { CreateNewsParams, FilterNewsParams, NewsResponse, UpdateNewsParams } from '../controller/dto'; import { SchoolInfoMapper } from './school-info.mapper'; @@ -49,7 +49,7 @@ export class NewsMapper { return dto; } - static mapCreateNewsToDomain(params: CreateNewsParams): ICreateNews { + static mapCreateNewsToDomain(params: CreateNewsParams): CreateNews { const dto = { title: params.title, content: params.content, diff --git a/apps/server/src/modules/news/uc/news.uc.spec.ts b/apps/server/src/modules/news/uc/news.uc.spec.ts index d0671dd4259..91166132320 100644 --- a/apps/server/src/modules/news/uc/news.uc.spec.ts +++ b/apps/server/src/modules/news/uc/news.uc.spec.ts @@ -1,12 +1,12 @@ import { createMock } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; +import { FeathersAuthorizationService } from '@modules/authorization'; import { UnauthorizedException } from '@nestjs/common'; import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; import { Test, TestingModule } from '@nestjs/testing'; -import { ICreateNews, NewsTargetModel, Permission } from '@shared/domain'; +import { CreateNews, NewsTargetModel, Permission } from '@shared/domain'; import { NewsRepo } from '@shared/repo'; import { Logger } from '@src/core/logger'; -import { FeathersAuthorizationService } from '@modules/authorization'; import { NewsUc } from './news.uc'; describe('NewsUc', () => { @@ -232,7 +232,7 @@ describe('NewsUc', () => { content: 'content', displayAt: new Date(), target: { targetModel: NewsTargetModel.School, targetId: schoolId }, - } as ICreateNews; + } as CreateNews; const createdNews = await service.create(userId, schoolId, params); expect(createdNews.school).toEqual(schoolId); expect(createdNews.creator).toEqual(userId); @@ -247,7 +247,7 @@ describe('NewsUc', () => { content: 'content', displayAt: new Date(), target: { targetModel: NewsTargetModel.School, targetId: schoolId }, - } as ICreateNews; + } as CreateNews; await service.create(userId, schoolId, params); expect(createSpy).toHaveBeenCalled(); }); diff --git a/apps/server/src/modules/news/uc/news.uc.ts b/apps/server/src/modules/news/uc/news.uc.ts index c3d6f917657..e6353f198d1 100644 --- a/apps/server/src/modules/news/uc/news.uc.ts +++ b/apps/server/src/modules/news/uc/news.uc.ts @@ -2,9 +2,9 @@ import { FeathersAuthorizationService } from '@modules/authorization'; import { Injectable } from '@nestjs/common'; import { Counted, + CreateNews, EntityId, FindOptions, - ICreateNews, INewsScope, IUpdateNews, News, @@ -36,7 +36,7 @@ export class NewsUc { * @param params * @returns */ - public async create(userId: EntityId, schoolId: EntityId, params: ICreateNews): Promise { + public async create(userId: EntityId, schoolId: EntityId, params: CreateNews): Promise { const { targetModel, targetId } = params.target; await this.authorizationService.checkEntityPermissions(userId, targetModel, targetId, [Permission.NEWS_CREATE]); diff --git a/apps/server/src/shared/domain/types/news.types.ts b/apps/server/src/shared/domain/types/news.types.ts index 241b4d90384..671545c8ceb 100644 --- a/apps/server/src/shared/domain/types/news.types.ts +++ b/apps/server/src/shared/domain/types/news.types.ts @@ -1,7 +1,7 @@ -import { EntityId } from './entity-id'; import type { Course } from '../entity/course.entity'; import type { SchoolEntity } from '../entity/school.entity'; import type { TeamEntity } from '../entity/team.entity'; +import { EntityId } from './entity-id'; export enum NewsTargetModel { 'School' = 'schools', @@ -10,7 +10,7 @@ export enum NewsTargetModel { } /** news interface for ceating news */ -export interface ICreateNews { +export interface CreateNews { title: string; content: string; displayAt?: Date; @@ -18,7 +18,7 @@ export interface ICreateNews { } /** news interface for updating news */ -export type IUpdateNews = Partial; +export type IUpdateNews = Partial; /** interface for finding news with optional targetId */ export interface INewsScope { From b68b0e7657dee70fb529ce5b8241af714637ce57 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:13:02 +0100 Subject: [PATCH 076/110] INewsScope -> NewsScopeInterface --- .../server/src/modules/news/mapper/news.mapper.spec.ts | 6 +++--- apps/server/src/modules/news/mapper/news.mapper.ts | 6 +++--- apps/server/src/modules/news/uc/news.uc.ts | 10 +++++++--- apps/server/src/shared/domain/types/news.types.ts | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/news/mapper/news.mapper.spec.ts b/apps/server/src/modules/news/mapper/news.mapper.spec.ts index 40bd66d8130..4eeb69df1d4 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.spec.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.spec.ts @@ -2,10 +2,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { CourseNews, CreateNews, - INewsScope, IUpdateNews, News, NewsProperties, + NewsScopeInterface, NewsTarget, NewsTargetModel, SchoolEntity, @@ -164,7 +164,7 @@ describe('NewsMapper', () => { targetId, }); const result = NewsMapper.mapNewsScopeToDomain(filterNewsParams); - const expected: INewsScope = {}; + const expected: NewsScopeInterface = {}; Object.assign(expected, { target: { targetModel: filterNewsParams.targetModel, @@ -182,7 +182,7 @@ describe('NewsMapper', () => { unpublished: true, }); const result = NewsMapper.mapNewsScopeToDomain(filterNewsParams); - const expected: INewsScope = {}; + const expected: NewsScopeInterface = {}; Object.assign(expected, { target: { targetModel: filterNewsParams.targetModel, diff --git a/apps/server/src/modules/news/mapper/news.mapper.ts b/apps/server/src/modules/news/mapper/news.mapper.ts index 36c17f57607..3a3b3ea1a8e 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.ts @@ -1,4 +1,4 @@ -import { CreateNews, INewsScope, IUpdateNews, News, NewsTargetModel } from '@shared/domain'; +import { CreateNews, IUpdateNews, News, NewsScopeInterface, NewsTargetModel } from '@shared/domain'; import { LogMessageData } from '@src/core/logger'; import { CreateNewsParams, FilterNewsParams, NewsResponse, UpdateNewsParams } from '../controller/dto'; import { SchoolInfoMapper } from './school-info.mapper'; @@ -35,8 +35,8 @@ export class NewsMapper { return dto; } - static mapNewsScopeToDomain(query: FilterNewsParams): INewsScope { - const dto: INewsScope = {}; + static mapNewsScopeToDomain(query: FilterNewsParams): NewsScopeInterface { + const dto: NewsScopeInterface = {}; if (query.targetModel) { dto.target = { targetModel: query.targetModel as NewsTargetModel, diff --git a/apps/server/src/modules/news/uc/news.uc.ts b/apps/server/src/modules/news/uc/news.uc.ts index e6353f198d1..631133c59ca 100644 --- a/apps/server/src/modules/news/uc/news.uc.ts +++ b/apps/server/src/modules/news/uc/news.uc.ts @@ -5,9 +5,9 @@ import { CreateNews, EntityId, FindOptions, - INewsScope, IUpdateNews, News, + NewsScopeInterface, NewsTargetModel, Permission, SortOrder, @@ -66,7 +66,7 @@ export class NewsUc { */ public async findAllForUser( userId: EntityId, - scope?: INewsScope, + scope?: NewsScopeInterface, options?: FindOptions ): Promise> { const unpublished = !!scope?.unpublished; // default is only published news @@ -156,7 +156,11 @@ export class NewsUc { return id; } - private async getPermittedTargets(userId: EntityId, scope: INewsScope | undefined, permissions: NewsPermission[]) { + private async getPermittedTargets( + userId: EntityId, + scope: NewsScopeInterface | undefined, + permissions: NewsPermission[] + ) { let targets: NewsTargetFilter[]; if (scope?.target == null) { diff --git a/apps/server/src/shared/domain/types/news.types.ts b/apps/server/src/shared/domain/types/news.types.ts index 671545c8ceb..0c0c11f77e7 100644 --- a/apps/server/src/shared/domain/types/news.types.ts +++ b/apps/server/src/shared/domain/types/news.types.ts @@ -21,7 +21,7 @@ export interface CreateNews { export type IUpdateNews = Partial; /** interface for finding news with optional targetId */ -export interface INewsScope { +export interface NewsScopeInterface { target?: { targetModel: NewsTargetModel; targetId?: EntityId }; unpublished?: boolean; } From db66c2b7f4650e564d80d89acfa6240ae2209359 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:13:46 +0100 Subject: [PATCH 077/110] ITaskUpdate -> TaskUpdate --- .../src/modules/task/controller/dto/task-update.params.ts | 6 +++--- apps/server/src/modules/task/mapper/task.mapper.spec.ts | 6 +++--- apps/server/src/modules/task/mapper/task.mapper.ts | 6 +++--- apps/server/src/shared/domain/types/task.types.ts | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/server/src/modules/task/controller/dto/task-update.params.ts b/apps/server/src/modules/task/controller/dto/task-update.params.ts index 5d906ca078c..7cefef35311 100644 --- a/apps/server/src/modules/task/controller/dto/task-update.params.ts +++ b/apps/server/src/modules/task/controller/dto/task-update.params.ts @@ -1,9 +1,9 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsDate, IsMongoId, IsOptional, IsString } from 'class-validator'; -import { InputFormat, ITaskUpdate } from '@shared/domain'; import { SanitizeHtml } from '@shared/controller'; +import { InputFormat, TaskUpdate } from '@shared/domain'; +import { IsDate, IsMongoId, IsOptional, IsString } from 'class-validator'; -export class TaskUpdateParams implements ITaskUpdate { +export class TaskUpdateParams implements TaskUpdate { @IsString() @IsMongoId() @IsOptional() diff --git a/apps/server/src/modules/task/mapper/task.mapper.spec.ts b/apps/server/src/modules/task/mapper/task.mapper.spec.ts index f53d383e07e..911e73cf923 100644 --- a/apps/server/src/modules/task/mapper/task.mapper.spec.ts +++ b/apps/server/src/modules/task/mapper/task.mapper.spec.ts @@ -1,5 +1,5 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { InputFormat, ITaskStatus, ITaskUpdate, Task, TaskParentDescriptions } from '@shared/domain'; +import { InputFormat, ITaskStatus, Task, TaskParentDescriptions, TaskUpdate } from '@shared/domain'; import { setupEntities, taskFactory } from '@shared/testing'; import { TaskCreateParams, TaskResponse, TaskStatusResponse, TaskUpdateParams } from '../controller/dto'; import { TaskMapper } from './task.mapper'; @@ -88,7 +88,7 @@ describe('task.mapper', () => { }; const result = TaskMapper.mapTaskUpdateToDomain(params); - const expected: ITaskUpdate = { + const expected: TaskUpdate = { name: params.name, courseId: params.courseId, lessonId: params.lessonId, @@ -112,7 +112,7 @@ describe('task.mapper', () => { }; const result = TaskMapper.mapTaskCreateToDomain(params); - const expected: ITaskUpdate = { + const expected: TaskUpdate = { name: params.name, courseId: params.courseId, lessonId: params.lessonId, diff --git a/apps/server/src/modules/task/mapper/task.mapper.ts b/apps/server/src/modules/task/mapper/task.mapper.ts index a8db8e59af4..3237f5b7291 100644 --- a/apps/server/src/modules/task/mapper/task.mapper.ts +++ b/apps/server/src/modules/task/mapper/task.mapper.ts @@ -1,4 +1,4 @@ -import { InputFormat, ITaskCreate, ITaskUpdate, RichText, TaskWithStatusVo } from '@shared/domain'; +import { InputFormat, ITaskCreate, RichText, TaskUpdate, TaskWithStatusVo } from '@shared/domain'; import { TaskCreateParams, TaskResponse, TaskUpdateParams } from '../controller/dto'; import { TaskStatusMapper } from './task-status.mapper'; @@ -36,8 +36,8 @@ export class TaskMapper { return dto; } - static mapTaskUpdateToDomain(params: TaskUpdateParams): ITaskUpdate { - const dto: ITaskUpdate = { + static mapTaskUpdateToDomain(params: TaskUpdateParams): TaskUpdate { + const dto: TaskUpdate = { name: params.name, courseId: params.courseId, lessonId: params.lessonId, diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index 3282fd24738..6744d61a05c 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -8,7 +8,7 @@ interface ITask { dueDate?: Date; } -export interface ITaskUpdate extends ITask { +export interface TaskUpdate extends ITask { courseId?: string; lessonId?: string; } From 761df720c64e4c5edab422834b7038da1c2d2475 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:34:59 +0100 Subject: [PATCH 078/110] ITaskCreate -> TaskCreate --- .../account/services/account-db.service.spec.ts | 12 ++++++------ .../account/services/account.service.spec.ts | 4 ++-- .../strategy/local.strategy.spec.ts | 10 +++++----- .../h5p-editor/entity/h5p-content.entity.spec.ts | 16 ++++++++-------- .../common-cartridge-file-builder.spec.ts | 4 ++-- .../task/controller/dto/task-create.params.ts | 6 +++--- .../src/modules/task/mapper/task.mapper.ts | 6 +++--- .../server/src/shared/domain/types/task.types.ts | 8 ++++---- 8 files changed, 33 insertions(+), 33 deletions(-) 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 107273797f9..e847cdf9eb7 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 @@ -1,14 +1,14 @@ -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { IdentityManagementService } from '@infra/identity-management/identity-management.service'; import { ObjectId } from '@mikro-orm/mongodb'; +import { AccountEntityToDtoMapper } from '@modules/account/mapper'; +import { AccountDto } from '@modules/account/services/dto'; +import { ServerConfig } from '@modules/server'; 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 '@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'; -import { IServerConfig } from '@modules/server'; import bcrypt from 'bcryptjs'; import { LegacyLogger } from '../../../core/logger'; import { AccountRepo } from '../repo/account.repo'; @@ -117,7 +117,7 @@ describe('AccountDbService', () => { }, { provide: ConfigService, - useValue: createMock>(), + useValue: createMock>(), }, { provide: IdentityManagementService, diff --git a/apps/server/src/modules/account/services/account.service.spec.ts b/apps/server/src/modules/account/services/account.service.spec.ts index 4cb95d96a36..1d7c7d43398 100644 --- a/apps/server/src/modules/account/services/account.service.spec.ts +++ b/apps/server/src/modules/account/services/account.service.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { ServerConfig } from '@modules/server'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { IServerConfig } from '@modules/server'; import { LegacyLogger } from '../../../core/logger'; import { AccountServiceDb } from './account-db.service'; import { AccountServiceIdm } from './account-idm.service'; @@ -40,7 +40,7 @@ describe('AccountService', () => { }, { provide: ConfigService, - useValue: createMock>(), + useValue: createMock>(), }, { provide: AccountValidationService, 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 121d2874fe9..44db3ea4b21 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.spec.ts @@ -1,13 +1,13 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { IdentityManagementOauthService } from '@infra/identity-management'; +import { AccountEntityToDtoMapper } from '@modules/account/mapper'; +import { AccountDto } from '@modules/account/services/dto'; +import { ServerConfig } from '@modules/server'; import { UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { RoleName, User } from '@shared/domain'; -import { IdentityManagementOauthService } from '@infra/identity-management'; import { UserRepo } from '@shared/repo'; import { accountFactory, setupEntities, userFactory } from '@shared/testing'; -import { AccountEntityToDtoMapper } from '@modules/account/mapper'; -import { AccountDto } from '@modules/account/services/dto'; -import { IServerConfig } from '@modules/server'; import bcrypt from 'bcryptjs'; import { AuthenticationService } from '../services/authentication.service'; import { LocalStrategy } from './local.strategy'; @@ -28,7 +28,7 @@ describe('LocalStrategy', () => { await setupEntities(); authenticationServiceMock = createMock(); idmOauthServiceMock = createMock(); - configServiceMock = createMock>(); + configServiceMock = createMock>(); userRepoMock = createMock(); strategy = new LocalStrategy(authenticationServiceMock, idmOauthServiceMock, configServiceMock, userRepoMock); mockUser = userFactory.withRoleByName(RoleName.STUDENT).buildWithId(); diff --git a/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.spec.ts b/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.spec.ts index cea707c8ccf..04655d5036a 100644 --- a/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.spec.ts +++ b/apps/server/src/modules/h5p-editor/entity/h5p-content.entity.spec.ts @@ -1,10 +1,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { ContentMetadata, H5PContent, H5PContentParentType, IH5PContentProperties } from './h5p-content.entity'; +import { ContentMetadata, H5PContent, H5PContentParentType, H5PContentProperties } from './h5p-content.entity'; describe('H5PContent class', () => { describe('when an H5PContent instance is created', () => { const setup = () => { - const dummyIH5PContentProperties: IH5PContentProperties = { + const dummyH5PContentProperties: H5PContentProperties = { creatorId: '507f1f77bcf86cd799439011', parentType: H5PContentParentType.Lesson, parentId: '507f1f77bcf86cd799439012', @@ -23,19 +23,19 @@ describe('H5PContent class', () => { content: {}, }; - const h5pContent = new H5PContent(dummyIH5PContentProperties); - return { h5pContent, dummyIH5PContentProperties }; + const h5pContent = new H5PContent(dummyH5PContentProperties); + return { h5pContent, dummyH5PContentProperties }; }; it('should correctly return the creatorId', () => { - const { h5pContent, dummyIH5PContentProperties } = setup(); - const expectedCreatorId = new ObjectId(dummyIH5PContentProperties.creatorId).toHexString(); + const { h5pContent, dummyH5PContentProperties } = setup(); + const expectedCreatorId = new ObjectId(dummyH5PContentProperties.creatorId).toHexString(); expect(h5pContent.creatorId).toBe(expectedCreatorId); }); it('should correctly return the schoolId', () => { - const { h5pContent, dummyIH5PContentProperties } = setup(); - const expectedSchoolId = new ObjectId(dummyIH5PContentProperties.schoolId).toHexString(); + const { h5pContent, dummyH5PContentProperties } = setup(); + const expectedSchoolId = new ObjectId(dummyH5PContentProperties.schoolId).toHexString(); expect(h5pContent.schoolId).toBe(expectedSchoolId); }); }); diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts index 9c44732c61e..7b5709f8a9e 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.spec.ts @@ -1,7 +1,7 @@ import AdmZip from 'adm-zip'; import { parseStringPromise } from 'xml2js'; -import { CommonCartridgeFileBuilder, ICommonCartridgeFileBuilderOptions } from './common-cartridge-file-builder'; import { CommonCartridgeResourceType, CommonCartridgeVersion } from './common-cartridge-enums'; +import { CommonCartridgeFileBuilder, CommonCartridgeFileBuilderOptions } from './common-cartridge-file-builder'; import { ICommonCartridgeOrganizationProps } from './common-cartridge-organization-item-element'; import { ICommonCartridgeResourceProps } from './common-cartridge-resource-item-element'; @@ -9,7 +9,7 @@ describe('CommonCartridgeFileBuilder', () => { let archive: AdmZip; const getFileContentAsString = (path: string): string | undefined => archive.getEntry(path)?.getData().toString(); - const fileBuilderOptions: ICommonCartridgeFileBuilderOptions = { + const fileBuilderOptions: CommonCartridgeFileBuilderOptions = { identifier: 'file-identifier', copyrightOwners: 'Placeholder Copyright', creationYear: 'Placeholder Creation Year', diff --git a/apps/server/src/modules/task/controller/dto/task-create.params.ts b/apps/server/src/modules/task/controller/dto/task-create.params.ts index 0fa020ad779..1489f208a37 100644 --- a/apps/server/src/modules/task/controller/dto/task-create.params.ts +++ b/apps/server/src/modules/task/controller/dto/task-create.params.ts @@ -1,9 +1,9 @@ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -import { IsDate, IsMongoId, IsOptional, IsString } from 'class-validator'; -import { InputFormat, ITaskCreate } from '@shared/domain'; import { SanitizeHtml } from '@shared/controller'; +import { InputFormat, TaskCreate } from '@shared/domain'; +import { IsDate, IsMongoId, IsOptional, IsString } from 'class-validator'; -export class TaskCreateParams implements ITaskCreate { +export class TaskCreateParams implements TaskCreate { @IsString() @IsMongoId() @IsOptional() diff --git a/apps/server/src/modules/task/mapper/task.mapper.ts b/apps/server/src/modules/task/mapper/task.mapper.ts index 3237f5b7291..2e8d02ae977 100644 --- a/apps/server/src/modules/task/mapper/task.mapper.ts +++ b/apps/server/src/modules/task/mapper/task.mapper.ts @@ -1,4 +1,4 @@ -import { InputFormat, ITaskCreate, RichText, TaskUpdate, TaskWithStatusVo } from '@shared/domain'; +import { InputFormat, RichText, TaskCreate, TaskUpdate, TaskWithStatusVo } from '@shared/domain'; import { TaskCreateParams, TaskResponse, TaskUpdateParams } from '../controller/dto'; import { TaskStatusMapper } from './task-status.mapper'; @@ -51,8 +51,8 @@ export class TaskMapper { return dto; } - static mapTaskCreateToDomain(params: TaskCreateParams): ITaskCreate { - const dto: ITaskCreate = { + static mapTaskCreateToDomain(params: TaskCreateParams): TaskCreate { + const dto: TaskCreate = { name: params.name || 'Draft', courseId: params.courseId, lessonId: params.lessonId, diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index 6744d61a05c..71658506f63 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -1,6 +1,6 @@ import type { Course, InputFormat, LessonEntity, SchoolEntity, Submission, User } from '@shared/domain/'; -interface ITask { +interface TaskInterface { name: string; description?: string; descriptionInputFormat?: InputFormat; @@ -8,17 +8,17 @@ interface ITask { dueDate?: Date; } -export interface TaskUpdate extends ITask { +export interface TaskUpdate extends TaskInterface { courseId?: string; lessonId?: string; } -export interface ITaskCreate extends ITask { +export interface TaskCreate extends TaskInterface { courseId?: string; lessonId?: string; } -export interface ITaskProperties extends ITask { +export interface ITaskProperties extends TaskInterface { course?: Course; lesson?: LessonEntity; creator: User; From 5b0a1cd131159a963dc85296497cc8dac5b44534 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:36:26 +0100 Subject: [PATCH 079/110] ITaskProperties -> TaskProperties --- apps/server/src/shared/domain/entity/task.entity.ts | 4 ++-- apps/server/src/shared/domain/types/task.types.ts | 2 +- .../src/shared/testing/factory/task.factory.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index 98f2bd2d5a9..8a6bc476798 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -5,7 +5,7 @@ import { InputFormat } from '@shared/domain/types/input-format.types'; import type { IEntityWithSchool } from '../interface'; import type { LearnroomElement } from '../interface/learnroom'; import type { EntityId } from '../types/entity-id'; -import type { ITaskProperties, ITaskStatus } from '../types/task.types'; +import type { ITaskStatus, TaskProperties } from '../types/task.types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import type { LessonEntity } from './lesson.entity'; @@ -89,7 +89,7 @@ export class Task extends BaseEntityWithTimestamps implements LearnroomElement, @ManyToMany('User', undefined, { fieldName: 'archived' }) finished = new Collection(this); - constructor(props: ITaskProperties) { + constructor(props: TaskProperties) { super(); this.name = props.name; this.description = props.description || ''; diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index 71658506f63..cf7d23832fb 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -18,7 +18,7 @@ export interface TaskCreate extends TaskInterface { lessonId?: string; } -export interface ITaskProperties extends TaskInterface { +export interface TaskProperties extends TaskInterface { course?: Course; lesson?: LessonEntity; creator: User; diff --git a/apps/server/src/shared/testing/factory/task.factory.ts b/apps/server/src/shared/testing/factory/task.factory.ts index 40162267dd2..c3860940163 100644 --- a/apps/server/src/shared/testing/factory/task.factory.ts +++ b/apps/server/src/shared/testing/factory/task.factory.ts @@ -1,4 +1,4 @@ -import { ITaskProperties, Task } from '@shared/domain'; +import { Task, TaskProperties } from '@shared/domain'; import { User } from '@shared/domain/entity'; import { DeepPartial } from 'fishery'; import { BaseFactory } from './base.factory'; @@ -7,27 +7,27 @@ import { userFactory } from './user.factory'; const yesterday = new Date(Date.now() - 86400000); -class TaskFactory extends BaseFactory { +class TaskFactory extends BaseFactory { draft(): this { - const params: DeepPartial = { private: true }; + const params: DeepPartial = { private: true }; return this.params(params); } isPlanned(): this { - const params: DeepPartial = { private: false, availableDate: new Date(Date.now() + 10000) }; + const params: DeepPartial = { private: false, availableDate: new Date(Date.now() + 10000) }; return this.params(params); } isPublished(): this { - const params: DeepPartial = { private: false, availableDate: new Date(Date.now() - 10000) }; + const params: DeepPartial = { private: false, availableDate: new Date(Date.now() - 10000) }; return this.params(params); } finished(user: User): this { - const params: DeepPartial = { finished: [user] }; + const params: DeepPartial = { finished: [user] }; return this.params(params); } } From 334af4b4c17d81559c7555cd67d2b6958447b6ef Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:38:33 +0100 Subject: [PATCH 080/110] ITaskStatus -> TaskStatus --- .../learnroom/mapper/board-taskStatus.mapper.ts | 4 ++-- .../src/modules/learnroom/uc/room-board-dto.factory.ts | 8 ++++---- .../src/modules/task/mapper/task-status.mapper.ts | 4 ++-- .../server/src/modules/task/mapper/task.mapper.spec.ts | 8 ++------ apps/server/src/modules/task/uc/task.uc.spec.ts | 6 +++--- apps/server/src/modules/task/uc/task.uc.ts | 4 ++-- apps/server/src/shared/domain/entity/task.entity.ts | 10 +++++----- apps/server/src/shared/domain/types/task.types.ts | 2 +- 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/apps/server/src/modules/learnroom/mapper/board-taskStatus.mapper.ts b/apps/server/src/modules/learnroom/mapper/board-taskStatus.mapper.ts index 623a2fe7627..b493f0de91e 100644 --- a/apps/server/src/modules/learnroom/mapper/board-taskStatus.mapper.ts +++ b/apps/server/src/modules/learnroom/mapper/board-taskStatus.mapper.ts @@ -1,8 +1,8 @@ -import { ITaskStatus } from '@shared/domain'; +import { TaskStatus } from '@shared/domain'; import { BoardTaskStatusResponse } from '../controller/dto'; export class BoardTaskStatusMapper { - static mapToResponse(status: ITaskStatus): BoardTaskStatusResponse { + static mapToResponse(status: TaskStatus): BoardTaskStatusResponse { const dto = new BoardTaskStatusResponse(status); return dto; diff --git a/apps/server/src/modules/learnroom/uc/room-board-dto.factory.ts b/apps/server/src/modules/learnroom/uc/room-board-dto.factory.ts index 91bd043d472..0a74a5a34e8 100644 --- a/apps/server/src/modules/learnroom/uc/room-board-dto.factory.ts +++ b/apps/server/src/modules/learnroom/uc/room-board-dto.factory.ts @@ -1,4 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; +import { Action, AuthorizationService } from '@modules/authorization'; import { Injectable } from '@nestjs/common'; import { Board, @@ -7,14 +8,13 @@ import { ColumnboardBoardElement, ColumnBoardTarget, Course, - ITaskStatus, LessonEntity, Permission, Task, + TaskStatus, TaskWithStatusVo, User, } from '@shared/domain'; -import { AuthorizationService, Action } from '@modules/authorization'; import { ColumnBoardMetaData, LessonMetaData, @@ -126,8 +126,8 @@ class DtoCreator { return { type: RoomBoardElementTypes.TASK, content }; } - private createTaskStatus(task: Task): ITaskStatus { - let status: ITaskStatus; + private createTaskStatus(task: Task): TaskStatus { + let status: TaskStatus; if (this.isTeacher()) { status = task.createTeacherStatusForUser(this.user); } else { diff --git a/apps/server/src/modules/task/mapper/task-status.mapper.ts b/apps/server/src/modules/task/mapper/task-status.mapper.ts index 56eda114a11..291ed270ba6 100644 --- a/apps/server/src/modules/task/mapper/task-status.mapper.ts +++ b/apps/server/src/modules/task/mapper/task-status.mapper.ts @@ -1,8 +1,8 @@ -import { ITaskStatus } from '@shared/domain'; +import { TaskStatus } from '@shared/domain'; import { TaskStatusResponse } from '../controller/dto/task-status.response'; export class TaskStatusMapper { - static mapToResponse(status: ITaskStatus): TaskStatusResponse { + static mapToResponse(status: TaskStatus): TaskStatusResponse { const dto = new TaskStatusResponse(status); return dto; diff --git a/apps/server/src/modules/task/mapper/task.mapper.spec.ts b/apps/server/src/modules/task/mapper/task.mapper.spec.ts index 911e73cf923..2513101eca3 100644 --- a/apps/server/src/modules/task/mapper/task.mapper.spec.ts +++ b/apps/server/src/modules/task/mapper/task.mapper.spec.ts @@ -1,14 +1,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { InputFormat, ITaskStatus, Task, TaskParentDescriptions, TaskUpdate } from '@shared/domain'; +import { InputFormat, Task, TaskParentDescriptions, TaskStatus, TaskUpdate } from '@shared/domain'; import { setupEntities, taskFactory } from '@shared/testing'; import { TaskCreateParams, TaskResponse, TaskStatusResponse, TaskUpdateParams } from '../controller/dto'; import { TaskMapper } from './task.mapper'; -const createExpectedResponse = ( - task: Task, - status: ITaskStatus, - descriptions: TaskParentDescriptions -): TaskResponse => { +const createExpectedResponse = (task: Task, status: TaskStatus, descriptions: TaskParentDescriptions): TaskResponse => { const expectedStatus = Object.create(TaskStatusResponse.prototype) as TaskStatusResponse; expectedStatus.graded = status.graded; expectedStatus.maxSubmissions = status.maxSubmissions; diff --git a/apps/server/src/modules/task/uc/task.uc.spec.ts b/apps/server/src/modules/task/uc/task.uc.spec.ts index 90bb29db444..0b56e82ad5a 100644 --- a/apps/server/src/modules/task/uc/task.uc.spec.ts +++ b/apps/server/src/modules/task/uc/task.uc.spec.ts @@ -1,8 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { Action, AuthorizationService } from '@modules/authorization'; import { ForbiddenException, UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { PaginationParams } from '@shared/controller'; -import { ITaskStatus, Permission, SortOrder } from '@shared/domain'; +import { Permission, SortOrder, TaskStatus } from '@shared/domain'; import { CourseRepo, LessonRepo, TaskRepo } from '@shared/repo'; import { courseFactory, @@ -13,7 +14,6 @@ import { taskFactory, userFactory, } from '@shared/testing'; -import { Action, AuthorizationService } from '@modules/authorization'; import { TaskService } from '../service'; import { TaskUC } from './task.uc'; @@ -615,7 +615,7 @@ describe('TaskUC', () => { }); describe('[method] changeFinishedForUser', () => { - const mockStatus: ITaskStatus = { + const mockStatus: TaskStatus = { submitted: 1, graded: 1, maxSubmissions: 1, diff --git a/apps/server/src/modules/task/uc/task.uc.ts b/apps/server/src/modules/task/uc/task.uc.ts index 2e6c392a2d4..a21fd6ba1d7 100644 --- a/apps/server/src/modules/task/uc/task.uc.ts +++ b/apps/server/src/modules/task/uc/task.uc.ts @@ -4,11 +4,11 @@ import { Counted, Course, EntityId, - ITaskStatus, LessonEntity, Pagination, Permission, SortOrder, + TaskStatus, TaskWithStatusVo, User, } from '@shared/domain'; @@ -53,7 +53,7 @@ export class TaskUC { ); const taskWithStatusVos = tasks.map((task) => { - let status: ITaskStatus; + let status: TaskStatus; if (this.authorizationService.hasPermission(user, task, AuthorizationContextBuilder.write([]))) { status = task.createTeacherStatusForUser(user); } else { diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index 8a6bc476798..9d9f347b740 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -5,7 +5,7 @@ import { InputFormat } from '@shared/domain/types/input-format.types'; import type { IEntityWithSchool } from '../interface'; import type { LearnroomElement } from '../interface/learnroom'; import type { EntityId } from '../types/entity-id'; -import type { ITaskStatus, TaskProperties } from '../types/task.types'; +import type { TaskProperties, TaskStatus } from '../types/task.types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import type { LessonEntity } from './lesson.entity'; @@ -15,9 +15,9 @@ import { User } from './user.entity'; export class TaskWithStatusVo { task!: Task; - status!: ITaskStatus; + status!: TaskStatus; - constructor(task: Task, status: ITaskStatus) { + constructor(task: Task, status: TaskStatus) { this.task = task; this.status = status; } @@ -234,7 +234,7 @@ export class Task extends BaseEntityWithTimestamps implements LearnroomElement, return isSubstitutionTeacher; } - public createTeacherStatusForUser(user: User): ITaskStatus { + public createTeacherStatusForUser(user: User): TaskStatus { const submittedSubmissions = this.getSubmittedSubmissions(); const gradedSubmissions = this.getGradedSubmissions(); @@ -257,7 +257,7 @@ export class Task extends BaseEntityWithTimestamps implements LearnroomElement, return status; } - public createStudentStatusForUser(user: User): ITaskStatus { + public createStudentStatusForUser(user: User): TaskStatus { const isSubmitted = this.isSubmittedForUser(user); const isGraded = this.isGradedForUser(user); const maxSubmissions = 1; diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index cf7d23832fb..ba30f915fbc 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -30,7 +30,7 @@ export interface TaskProperties extends TaskInterface { teamSubmissions?: boolean; } -export interface ITaskStatus { +export interface TaskStatus { submitted: number; maxSubmissions: number; graded: number; From 3618dff8f4af63dcce38d6d231e7bff9b8f1abe2 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:39:49 +0100 Subject: [PATCH 081/110] ITestEntityProperties -> TestEntityProperties --- .../repo/base.do.repo.integration.spec.ts | 20 +++++++++---------- apps/server/src/shared/repo/scope.spec.ts | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) 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 1ca91bd184e..b9683fbf1ea 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 @@ -1,12 +1,12 @@ +import { createMock } from '@golevelup/ts-jest'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { Entity, EntityName, Property } from '@mikro-orm/core'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Injectable } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Entity, EntityName, Property } from '@mikro-orm/core'; import { BaseDO, BaseEntityWithTimestamps } from '@shared/domain'; -import { MongoMemoryDatabaseModule } from '@infra/database'; -import { Injectable } from '@nestjs/common'; import { BaseDORepo } from '@shared/repo/base.do.repo'; import { LegacyLogger } from '@src/core/logger'; -import { createMock } from '@golevelup/ts-jest'; describe('BaseDORepo', () => { @Entity() @@ -14,7 +14,7 @@ describe('BaseDORepo', () => { @Property() name: string; - constructor(props: ITestEntityProperties = { name: 'test' }) { + constructor(props: TestEntityProperties = { name: 'test' }) { super(); this.name = props.name; } @@ -30,17 +30,17 @@ describe('BaseDORepo', () => { } } - interface ITestEntityProperties { + interface TestEntityProperties { name: string; } @Injectable() - class TestRepo extends BaseDORepo { + class TestRepo extends BaseDORepo { get entityName(): EntityName { return TestEntity; } - entityFactory(props: ITestEntityProperties): TestEntity { + entityFactory(props: TestEntityProperties): TestEntity { return new TestEntity(props); } @@ -48,7 +48,7 @@ describe('BaseDORepo', () => { return new TestDO({ id: entity.id, name: entity.name }); } - mapDOToEntityProperties(entityDO: TestDO): ITestEntityProperties { + mapDOToEntityProperties(entityDO: TestDO): TestEntityProperties { return { name: entityDO.name, }; @@ -95,7 +95,7 @@ describe('BaseDORepo', () => { }); describe('entityFactory', () => { - const props: ITestEntityProperties = { + const props: TestEntityProperties = { name: 'name', }; diff --git a/apps/server/src/shared/repo/scope.spec.ts b/apps/server/src/shared/repo/scope.spec.ts index cf0e88b4d3b..894f7c9fe65 100644 --- a/apps/server/src/shared/repo/scope.spec.ts +++ b/apps/server/src/shared/repo/scope.spec.ts @@ -2,7 +2,7 @@ import { Entity, Property } from '@mikro-orm/core'; import { EmptyResultQuery } from './query/empty-result.query'; import { Scope } from './scope'; -export interface ITestEntityProperties { +export interface TestEntityProperties { name: string; numbers?: number[]; } @@ -15,7 +15,7 @@ class TestEntity { @Property() numbers: number[]; - constructor(props: ITestEntityProperties) { + constructor(props: TestEntityProperties) { this.name = props.name; this.numbers = props.numbers || []; } From 7f2de120d5fb492a1ed44a3fb3f14cb57b2abd72 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 11:59:00 +0100 Subject: [PATCH 082/110] IDashboardRepo -> DashboardRepoInterface --- .../service/keycloak-seed.service.spec.ts | 22 +++++++++---------- .../api-test/h5p-editor-files.api.spec.ts | 6 ++--- .../controller/api-test/dashboard.api.spec.ts | 4 ++-- .../modules/learnroom/uc/dashboard.uc.spec.ts | 4 ++-- .../src/modules/learnroom/uc/dashboard.uc.ts | 8 +++---- .../external-tool-logo-service.spec.ts | 4 ++-- .../service/external-tool.service.spec.ts | 6 ++--- .../shared/repo/dashboard/dashboard.repo.ts | 8 +++---- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/apps/server/src/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 index 19a3b28326e..70e71bfc76f 100644 --- a/apps/server/src/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 @@ -1,28 +1,28 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { LegacyLogger } from '@src/core/logger'; import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRepresentation'; import { AuthenticationManagement } from '@keycloak/keycloak-admin-client/lib/resources/authenticationManagement'; import { Users } from '@keycloak/keycloak-admin-client/lib/resources/users'; import { Test, TestingModule } from '@nestjs/testing'; +import { LegacyLogger } from '@src/core/logger'; import { v1 } from 'uuid'; import { - IKeycloakSettings, KeycloakSettings, + KeycloakSettingsInterface, } from '../../keycloak-administration/interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; -import { IJsonAccount } from '../interface/json-account.interface'; -import { IJsonUser } from '../interface/json-user.interface'; +import { JsonAccount } from '../interface/json-account.interface'; +import { JsonUser } from '../interface/json-user.interface'; import { - IKeycloakConfigurationInputFiles, KeycloakConfigurationInputFiles, + KeycloakConfigurationInputFilesInterface, } from '../interface/keycloak-configuration-input-files.interface'; import { KeycloakSeedService } from './keycloak-seed.service'; const accountsFile = 'accounts.json'; const usersFile = 'users.json'; -let jsonAccounts: IJsonAccount[]; -let jsonUsers: IJsonUser[]; +let jsonAccounts: JsonAccount[]; +let jsonUsers: JsonUser[]; jest.mock('node:fs/promises', () => { return { @@ -42,7 +42,7 @@ describe('KeycloakSeedService', () => { let module: TestingModule; let serviceUnderTest: KeycloakSeedService; let logger: DeepMocked; - let settings: IKeycloakSettings; + let settings: KeycloakSettingsInterface; let infoLogSpy: jest.SpyInstance; let errorLogSpy: jest.SpyInstance; @@ -52,8 +52,8 @@ describe('KeycloakSeedService', () => { const kcApiAuthenticationManagementMock = createMock(); const adminUsername = 'admin'; - let validAccountsNoDuplicates: IJsonAccount[]; - let validAccounts: IJsonAccount[]; + let validAccountsNoDuplicates: JsonAccount[]; + let validAccounts: JsonAccount[]; const adminUser: UserRepresentation = { id: v1(), @@ -98,7 +98,7 @@ describe('KeycloakSeedService', () => { username: 'notUnique', }, ]; - const inputFiles: IKeycloakConfigurationInputFiles = { + const inputFiles: KeycloakConfigurationInputFilesInterface = { accountsFile: 'accounts.json', usersFile: 'users.json', }; 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 05132888f71..5ee9d7f15f7 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 @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { S3ClientAdapter } from '@infra/s3-client'; import { ILibraryName } from '@lumieducation/h5p-server'; import { ContentMetadata } from '@lumieducation/h5p-server/build/src/ContentMetadata'; import { EntityManager } from '@mikro-orm/mongodb'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; -import { S3ClientAdapter } from '@infra/s3-client'; import { courseFactory, h5pContentFactory, @@ -14,7 +14,7 @@ import { } from '@shared/testing'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; -import { H5PContent, H5PContentParentType, IH5PContentProperties, H5pEditorTempFile } from '../../entity'; +import { H5PContent, H5PContentParentType, H5PContentProperties, H5pEditorTempFile } from '../../entity'; import { H5PEditorTestModule } from '../../h5p-editor-test.module'; import { H5P_CONTENT_S3_CONNECTION, H5P_LIBRARIES_S3_CONNECTION } from '../../h5p-editor.config'; import { ContentStorage, LibraryStorage, TemporaryFileStorage } from '../../service'; @@ -45,7 +45,7 @@ const helpers = { const content = { data: `Data #${n}`, }; - const h5pContentProperties: IH5PContentProperties = { + const h5pContentProperties: H5PContentProperties = { creatorId: new ObjectID().toString(), parentId: new ObjectID().toString(), schoolId: new ObjectID().toString(), diff --git a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts index db4f2a421c2..e0b8476dde8 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts @@ -6,7 +6,7 @@ import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { DashboardEntity, GridElement, Permission, RoleName, User } from '@shared/domain'; -import { IDashboardRepo } from '@shared/repo'; +import { DashboardRepoInterface } from '@shared/repo'; import { courseFactory, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; import { Request } from 'express'; import request from 'supertest'; @@ -14,7 +14,7 @@ import request from 'supertest'; describe('Dashboard Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let dashboardRepo: IDashboardRepo; + let dashboardRepo: DashboardRepoInterface; let currentUser: CurrentUserInterface; beforeAll(async () => { diff --git a/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts b/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts index 309e139b7cd..5f359cf2ee9 100644 --- a/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts @@ -10,7 +10,7 @@ import { LearnroomTypes, SortOrder, } from '@shared/domain'; -import { CourseRepo, IDashboardRepo } from '@shared/repo'; +import { CourseRepo, DashboardRepoInterface } from '@shared/repo'; import { setupEntities } from '@shared/testing'; import { DashboardUc } from './dashboard.uc'; @@ -31,7 +31,7 @@ const learnroomMock = (id: string, name: string) => { describe('dashboard uc', () => { let module: TestingModule; let service: DashboardUc; - let repo: IDashboardRepo; + let repo: DashboardRepoInterface; let courseRepo: CourseRepo; afterAll(async () => { diff --git a/apps/server/src/modules/learnroom/uc/dashboard.uc.ts b/apps/server/src/modules/learnroom/uc/dashboard.uc.ts index 9bade9a6d71..b29e39bc5b3 100644 --- a/apps/server/src/modules/learnroom/uc/dashboard.uc.ts +++ b/apps/server/src/modules/learnroom/uc/dashboard.uc.ts @@ -1,12 +1,12 @@ -import { Injectable, Inject, NotFoundException } from '@nestjs/common'; -import { DashboardEntity, EntityId, GridPositionWithGroupIndex, GridPosition, SortOrder } from '@shared/domain'; -import { IDashboardRepo, CourseRepo } from '@shared/repo'; +import { Inject, Injectable, NotFoundException } from '@nestjs/common'; +import { DashboardEntity, EntityId, GridPosition, GridPositionWithGroupIndex, SortOrder } from '@shared/domain'; +import { CourseRepo, DashboardRepoInterface } from '@shared/repo'; // import { NotFound } from '@feathersjs/errors'; // wrong import? see NotFoundException @Injectable() export class DashboardUc { constructor( - @Inject('DASHBOARD_REPO') private readonly dashboardRepo: IDashboardRepo, + @Inject('DASHBOARD_REPO') private readonly dashboardRepo: DashboardRepoInterface, private readonly courseRepo: CourseRepo ) {} diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts index c53154098a5..bf787a9bdef 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { axiosResponseFactory, externalToolFactory } from '@shared/testing'; import { Logger } from '@src/core/logger'; import { of, throwError } from 'rxjs'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogo } from '../domain/external-tool-logo'; import { @@ -24,7 +24,7 @@ describe('ExternalToolLogoService', () => { let httpService: DeepMocked; let logger: DeepMocked; - let toolFeatures: IToolFeatures; + let toolFeatures: ToolFeaturesInterface; let externalToolService: DeepMocked; beforeAll(async () => { 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 c3b55d2db6b..7daab1341ec 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 @@ -1,5 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { DefaultEncryptionService, IEncryptionService } from '@infra/encryption'; +import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { UnprocessableEntityException } from '@nestjs/common'; @@ -28,7 +28,7 @@ describe('ExternalToolService', () => { let courseToolRepo: DeepMocked; let oauthProviderService: DeepMocked; let mapper: DeepMocked; - let encryptionService: DeepMocked; + let encryptionService: DeepMocked; let versionService: DeepMocked; beforeAll(async () => { @@ -49,7 +49,7 @@ describe('ExternalToolService', () => { }, { provide: DefaultEncryptionService, - useValue: createMock(), + useValue: createMock(), }, { provide: SchoolExternalToolRepo, diff --git a/apps/server/src/shared/repo/dashboard/dashboard.repo.ts b/apps/server/src/shared/repo/dashboard/dashboard.repo.ts index c0353719696..882062e96ca 100644 --- a/apps/server/src/shared/repo/dashboard/dashboard.repo.ts +++ b/apps/server/src/shared/repo/dashboard/dashboard.repo.ts @@ -1,6 +1,6 @@ -import { Injectable } from '@nestjs/common'; -import { EntityId, DashboardEntity, GridElementWithPosition, DashboardModelEntity } from '@shared/domain'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; +import { Injectable } from '@nestjs/common'; +import { DashboardEntity, DashboardModelEntity, EntityId, GridElementWithPosition } from '@shared/domain'; import { DashboardModelMapper } from './dashboard.model.mapper'; const generateEmptyDashboard = (userId: EntityId) => { @@ -10,14 +10,14 @@ const generateEmptyDashboard = (userId: EntityId) => { return dashboard; }; -export interface IDashboardRepo { +export interface DashboardRepoInterface { getUsersDashboard(userId: EntityId): Promise; getDashboardById(id: EntityId): Promise; persistAndFlush(entity: DashboardEntity): Promise; } @Injectable() -export class DashboardRepo implements IDashboardRepo { +export class DashboardRepo implements DashboardRepoInterface { constructor(protected readonly em: EntityManager, protected readonly mapper: DashboardModelMapper) {} // ToDo: refactor this to be in an abstract class (see baseRepo) From da116d018a1d04ee7c9ccc626b44d31e6cfdd436 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 12:09:42 +0100 Subject: [PATCH 083/110] IToolLaunchParams -> ToolLaunchParams --- .../abstract-launch.strategy.spec.ts | 4 ++-- .../basic-tool-launch.strategy.spec.ts | 4 ++-- .../lti11-tool-launch.strategy.spec.ts | 14 +++++++------- .../service/tool-launch.service.spec.ts | 8 ++++---- config/README.md | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.spec.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.spec.ts index 04868663671..7e170eb412b 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/abstract-launch.strategy.spec.ts @@ -30,7 +30,7 @@ import { AutoSchoolNumberStrategy, } from '../auto-parameter-strategy'; import { AbstractLaunchStrategy } from './abstract-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; const concreteConfigParameter: PropertyData = { location: PropertyLocation.QUERY, @@ -48,7 +48,7 @@ class TestLaunchStrategy extends AbstractLaunchStrategy { // eslint-disable-next-line @typescript-eslint/no-unused-vars userId: EntityId, // eslint-disable-next-line @typescript-eslint/no-unused-vars - config: IToolLaunchParams + config: ToolLaunchParams ): Promise { // Implement this method with your own logic for the mock launch strategy return Promise.resolve([concreteConfigParameter]); diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.spec.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.spec.ts index db80f78498f..32ca68a74f0 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/basic-tool-launch.strategy.spec.ts @@ -12,7 +12,7 @@ import { AutoSchoolNumberStrategy, } from '../auto-parameter-strategy'; import { BasicToolLaunchStrategy } from './basic-tool-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; describe('BasicToolLaunchStrategy', () => { let module: TestingModule; @@ -118,7 +118,7 @@ describe('BasicToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.build(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.build(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, diff --git a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.spec.ts b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.spec.ts index ee2932cd535..69ebd3e4d26 100644 --- a/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/service/launch-strategy/lti11-tool-launch.strategy.spec.ts @@ -26,7 +26,7 @@ import { } from '../auto-parameter-strategy'; import { Lti11EncryptionService } from '../lti11-encryption.service'; import { Lti11ToolLaunchStrategy } from './lti11-tool-launch.strategy'; -import { IToolLaunchParams } from './tool-launch-params.interface'; +import { ToolLaunchParams } from './tool-launch-params.interface'; describe('Lti11ToolLaunchStrategy', () => { let module: TestingModule; @@ -108,7 +108,7 @@ describe('Lti11ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.buildWithId(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.buildWithId(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, @@ -205,7 +205,7 @@ describe('Lti11ToolLaunchStrategy', () => { contextRef: { id: contextId, type: ToolContextType.COURSE }, }); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, @@ -252,7 +252,7 @@ describe('Lti11ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.buildWithId(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.buildWithId(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, @@ -301,7 +301,7 @@ describe('Lti11ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.buildWithId(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.buildWithId(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, @@ -352,7 +352,7 @@ describe('Lti11ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.buildWithId(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.buildWithId(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, @@ -390,7 +390,7 @@ describe('Lti11ToolLaunchStrategy', () => { const schoolExternalTool: SchoolExternalTool = schoolExternalToolFactory.buildWithId(); const contextExternalTool: ContextExternalTool = contextExternalToolFactory.buildWithId(); - const data: IToolLaunchParams = { + const data: ToolLaunchParams = { contextExternalTool, schoolExternalTool, externalTool, diff --git a/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.spec.ts b/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.spec.ts index e4f9eaa6113..adac0fbe024 100644 --- a/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/service/tool-launch.service.spec.ts @@ -18,9 +18,9 @@ import { ToolStatusOutdatedLoggableException } from '../error'; import { LaunchRequestMethod, ToolLaunchData, ToolLaunchDataType, ToolLaunchRequest } from '../types'; import { BasicToolLaunchStrategy, - IToolLaunchParams, Lti11ToolLaunchStrategy, OAuth2ToolLaunchStrategy, + ToolLaunchParams, } from './launch-strategy'; import { ToolLaunchService } from './tool-launch.service'; @@ -98,7 +98,7 @@ describe('ToolLaunchService', () => { openNewTab: false, }); - const launchParams: IToolLaunchParams = { + const launchParams: ToolLaunchParams = { externalTool, schoolExternalTool, contextExternalTool, @@ -157,7 +157,7 @@ describe('ToolLaunchService', () => { const externalTool: ExternalTool = externalToolFactory.build(); externalTool.config.type = 'unknown' as ToolConfigType; - const launchParams: IToolLaunchParams = { + const launchParams: ToolLaunchParams = { externalTool, schoolExternalTool, contextExternalTool, @@ -199,7 +199,7 @@ describe('ToolLaunchService', () => { openNewTab: false, }); - const launchParams: IToolLaunchParams = { + const launchParams: ToolLaunchParams = { externalTool, schoolExternalTool, contextExternalTool, diff --git a/config/README.md b/config/README.md index f55c442d036..69081ee6460 100644 --- a/config/README.md +++ b/config/README.md @@ -154,7 +154,7 @@ This code shows a minimal flow. } // server.config.ts - export interface IServerConfig extends ICoreModuleConfig, UserConfig, IFilesStorageClientConfig { + export interface ServerConfig extends ICoreModuleConfig, UserConfig, IFilesStorageClientConfig { NODE_ENV: string; } From 1423df19a1287220fea602b0f367d7f8b36aa2b8 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 12:18:47 +0100 Subject: [PATCH 084/110] IEntityWithSchool -> EntityWithSchool --- .../src/modules/files-storage/entity/filerecord.entity.ts | 2 +- apps/server/src/shared/domain/entity/course.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/coursegroup.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/import-user.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/task.entity.ts | 4 ++-- apps/server/src/shared/domain/entity/user.entity.ts | 4 ++-- apps/server/src/shared/domain/interface/entity.ts | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/server/src/modules/files-storage/entity/filerecord.entity.ts b/apps/server/src/modules/files-storage/entity/filerecord.entity.ts index a477a013e83..5f7c01ac2d8 100644 --- a/apps/server/src/modules/files-storage/entity/filerecord.entity.ts +++ b/apps/server/src/modules/files-storage/entity/filerecord.entity.ts @@ -87,7 +87,7 @@ interface ParentInfo { parentType: FileRecordParentType; } -// TODO: IEntityWithSchool +// TODO: EntityWithSchool /** * Note: The file record entity will not manage any entity relations by itself. diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 8766bb834cd..e0fb4d4bcc3 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -2,7 +2,7 @@ import { Collection, Entity, Enum, Index, ManyToMany, ManyToOne, OneToMany, Prop import { ClassEntity } from '@modules/class/entity/class.entity'; import { GroupEntity } from '@modules/group/entity/group.entity'; import { InternalServerErrorException } from '@nestjs/common/exceptions/internal-server-error.exception'; -import { IEntityWithSchool, Learnroom } from '@shared/domain/interface'; +import { EntityWithSchool, Learnroom } from '@shared/domain/interface'; import { EntityId, LearnroomMetadata, LearnroomTypes } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; @@ -49,7 +49,7 @@ export class UsersList { } @Entity({ tableName: 'courses' }) -export class Course extends BaseEntityWithTimestamps implements Learnroom, IEntityWithSchool, TaskParent, LessonParent { +export class Course extends BaseEntityWithTimestamps implements Learnroom, EntityWithSchool, TaskParent, LessonParent { @Property() name: string = DEFAULT.name; diff --git a/apps/server/src/shared/domain/entity/coursegroup.entity.ts b/apps/server/src/shared/domain/entity/coursegroup.entity.ts index b8b3d482ba4..8a2cade7aca 100644 --- a/apps/server/src/shared/domain/entity/coursegroup.entity.ts +++ b/apps/server/src/shared/domain/entity/coursegroup.entity.ts @@ -1,5 +1,5 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, Property } from '@mikro-orm/core'; -import { IEntityWithSchool } from '../interface'; +import { EntityWithSchool } from '../interface'; import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; @@ -16,7 +16,7 @@ export interface CourseGroupProperties { @Entity({ tableName: 'coursegroups' }) @Index({ properties: ['school', 'course'] }) -export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWithSchool, TaskParent, LessonParent { +export class CourseGroup extends BaseEntityWithTimestamps implements EntityWithSchool, TaskParent, LessonParent { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/import-user.entity.ts b/apps/server/src/shared/domain/entity/import-user.entity.ts index 22d05489da7..34d1f8b64e8 100644 --- a/apps/server/src/shared/domain/entity/import-user.entity.ts +++ b/apps/server/src/shared/domain/entity/import-user.entity.ts @@ -1,5 +1,5 @@ import { Entity, Enum, IdentifiedReference, ManyToOne, Property, Unique, wrap } from '@mikro-orm/core'; -import { IEntityWithSchool, RoleName } from '../interface'; +import { EntityWithSchool, RoleName } from '../interface'; import { BaseEntityReference, BaseEntityWithTimestamps } from './base.entity'; import { SchoolEntity } from './school.entity'; import { SystemEntity } from './system.entity'; @@ -34,7 +34,7 @@ export enum MatchCreator { @Unique({ properties: ['school', 'externalId'] }) @Unique({ properties: ['school', 'ldapDn'] }) @Unique({ properties: ['school', 'email'] }) -export class ImportUser extends BaseEntityWithTimestamps implements IEntityWithSchool { +export class ImportUser extends BaseEntityWithTimestamps implements EntityWithSchool { constructor(props: ImportUserProperties) { super(); this.school = wrap(props.school).toReference(); diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index 9d9f347b740..88af11a0a7d 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -2,7 +2,7 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, OneToMany, Property } import { InternalServerErrorException } from '@nestjs/common'; import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { InputFormat } from '@shared/domain/types/input-format.types'; -import type { IEntityWithSchool } from '../interface'; +import type { EntityWithSchool } from '../interface'; import type { LearnroomElement } from '../interface/learnroom'; import type { EntityId } from '../types/entity-id'; import type { TaskProperties, TaskStatus } from '../types/task.types'; @@ -40,7 +40,7 @@ export interface TaskParent { @Index({ properties: ['id', 'private'] }) @Index({ properties: ['finished', 'course'] }) @Index({ properties: ['finished', 'course'] }) -export class Task extends BaseEntityWithTimestamps implements LearnroomElement, IEntityWithSchool { +export class Task extends BaseEntityWithTimestamps implements LearnroomElement, EntityWithSchool { @Property() name: string; diff --git a/apps/server/src/shared/domain/entity/user.entity.ts b/apps/server/src/shared/domain/entity/user.entity.ts index 86ed68eea0f..c1d761193cd 100644 --- a/apps/server/src/shared/domain/entity/user.entity.ts +++ b/apps/server/src/shared/domain/entity/user.entity.ts @@ -1,5 +1,5 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, Property } from '@mikro-orm/core'; -import { IEntityWithSchool } from '../interface'; +import { EntityWithSchool } from '../interface'; import { BaseEntityWithTimestamps } from './base.entity'; import { Role } from './role.entity'; import { SchoolEntity } from './school.entity'; @@ -34,7 +34,7 @@ export interface UserProperties { @Index({ properties: ['externalId', 'school'] }) @Index({ properties: ['school', 'ldapDn'] }) @Index({ properties: ['school', 'roles'] }) -export class User extends BaseEntityWithTimestamps implements IEntityWithSchool { +export class User extends BaseEntityWithTimestamps implements EntityWithSchool { @Property() @Index() // @Unique() diff --git a/apps/server/src/shared/domain/interface/entity.ts b/apps/server/src/shared/domain/interface/entity.ts index dc28d8469d3..97618b0734d 100644 --- a/apps/server/src/shared/domain/interface/entity.ts +++ b/apps/server/src/shared/domain/interface/entity.ts @@ -11,6 +11,6 @@ export interface IEntityWithTimestamps extends IEntity { updatedAt: Date; } -export interface IEntityWithSchool extends IEntity { +export interface EntityWithSchool extends IEntity { school: SchoolEntity; } From e93ea0053f4a60ede7880113c5797b60ee5b9853 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 12:33:28 +0100 Subject: [PATCH 085/110] IEntity -> EntityInterface --- .../h5p-editor/service/contentStorage.service.spec.ts | 8 ++++---- apps/server/src/shared/domain/entity/base.entity.ts | 4 ++-- apps/server/src/shared/domain/interface/entity.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) 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 df19f05ae21..8ebc92cc6c5 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 @@ -1,10 +1,10 @@ import { HeadObjectCommandOutput } from '@aws-sdk/client-s3'; -import { DeepMocked, createMock } from '@golevelup/ts-jest'; +import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { S3ClientAdapter } from '@infra/s3-client'; import { IContentMetadata, ILibraryName, IUser, LibraryName } from '@lumieducation/h5p-server'; import { HttpException, InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { IEntity } from '@shared/domain'; -import { S3ClientAdapter } from '@infra/s3-client'; +import { EntityInterface } from '@shared/domain'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; import { GetH5PFileResponse } from '../controller/dto'; @@ -76,7 +76,7 @@ const helpers = { }; }, - repoSaveMock: async (entities: Entity | Entity[]) => { + repoSaveMock: async (entities: Entity | Entity[]) => { if (!Array.isArray(entities)) { entities = [entities]; } diff --git a/apps/server/src/shared/domain/entity/base.entity.ts b/apps/server/src/shared/domain/entity/base.entity.ts index fde2349ae36..108f60ce8ce 100644 --- a/apps/server/src/shared/domain/entity/base.entity.ts +++ b/apps/server/src/shared/domain/entity/base.entity.ts @@ -1,9 +1,9 @@ import { PrimaryKey, Property, SerializedPrimaryKey } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import type { AuthorizableObject } from '../domain-object'; -import type { IEntity } from '../interface'; +import type { EntityInterface } from '../interface'; -export abstract class BaseEntity implements IEntity, AuthorizableObject { +export abstract class BaseEntity implements EntityInterface, AuthorizableObject { @PrimaryKey() _id!: ObjectId; diff --git a/apps/server/src/shared/domain/interface/entity.ts b/apps/server/src/shared/domain/interface/entity.ts index 97618b0734d..ff7b1ef0c4a 100644 --- a/apps/server/src/shared/domain/interface/entity.ts +++ b/apps/server/src/shared/domain/interface/entity.ts @@ -1,16 +1,16 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { SchoolEntity } from '@shared/domain/entity/school.entity'; -export interface IEntity { +export interface EntityInterface { _id: ObjectId; id: string; } -export interface IEntityWithTimestamps extends IEntity { +export interface EntityInterfaceWithTimestamps extends EntityInterface { createdAt: Date; updatedAt: Date; } -export interface EntityWithSchool extends IEntity { +export interface EntityWithSchool extends EntityInterface { school: SchoolEntity; } From b60b401eae87be200aaf7226a8fe5ea395b4cc31 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 14:02:24 +0100 Subject: [PATCH 086/110] test adjusted --- .../service/contentStorage.service.spec.ts | 4 +-- .../video-conference/bbb/bbb.service.spec.ts | 4 +-- .../service/video-conference.service.spec.ts | 34 +++++++++---------- .../uc/video-conference-create.uc.spec.ts | 18 +++++----- .../uc/video-conference-deprecated.uc.spec.ts | 8 ++--- 5 files changed, 34 insertions(+), 34 deletions(-) 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 8ebc92cc6c5..b0bfe861c52 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 @@ -8,7 +8,7 @@ import { EntityInterface } from '@shared/domain'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; import { GetH5PFileResponse } from '../controller/dto'; -import { H5PContent, H5PContentParentType, IH5PContentProperties } from '../entity'; +import { H5PContent, H5PContentParentType, H5PContentProperties } from '../entity'; import { H5P_CONTENT_S3_CONNECTION } from '../h5p-editor.config'; import { H5PContentRepo } from '../repo'; import { H5PContentParentParams, LumiUserWithContentData } from '../types/lumi-types'; @@ -40,7 +40,7 @@ const helpers = { const content = { data: `Data #${n}`, }; - const h5pContentProperties: IH5PContentProperties = { + const h5pContentProperties: H5PContentProperties = { creatorId: new ObjectID().toString(), parentId: new ObjectID().toString(), schoolId: new ObjectID().toString(), diff --git a/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts b/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts index 1731d10ff8e..a0e9887107d 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts @@ -9,7 +9,7 @@ import { AxiosResponse } from 'axios'; import crypto, { Hash } from 'crypto'; import { of } from 'rxjs'; import { URLSearchParams } from 'url'; -import { BbbSettings, IBbbSettings } from './bbb-settings.interface'; +import { BbbSettings, BbbSettingsInterface } from './bbb-settings.interface'; import { BBBService } from './bbb.service'; import { BBBBaseMeetingConfig, BBBCreateConfig, BBBJoinConfig, BBBRole, GuestPolicy } from './request'; import { BBBBaseResponse, BBBCreateResponse, BBBMeetingInfoResponse, BBBResponse, BBBStatus } from './response'; @@ -118,7 +118,7 @@ describe('BBB Service', () => { BBBServiceTest, { provide: BbbSettings, - useValue: createMock({ + useValue: createMock({ host: 'https://bbb.de', salt: 'salt12345', presentationUrl: '', 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 28711a06c1a..ee6e599e5c2 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 @@ -1,6 +1,12 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { Test, TestingModule } from '@nestjs/testing'; +import { CalendarEventDto, CalendarService } from '@infra/calendar'; +import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; +import { CourseService } from '@modules/learnroom/service'; +import { LegacySchoolService } from '@modules/legacy-school'; +import { UserService } from '@modules/user'; import { BadRequestException, ForbiddenException } from '@nestjs/common'; +import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; +import { Test, TestingModule } from '@nestjs/testing'; import { Course, EntityId, @@ -12,23 +18,17 @@ import { VideoConferenceDO, VideoConferenceScope, } from '@shared/domain'; -import { CalendarEventDto, CalendarService } from '@infra/calendar'; import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; -import { AuthorizationContextBuilder, AuthorizationService } from '@modules/authorization'; -import { LegacySchoolService } from '@modules/legacy-school'; -import { UserService } from '@modules/user'; import { courseFactory, roleFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; -import { videoConferenceDOFactory } from '@shared/testing/factory/video-conference.do.factory'; -import { ObjectId } from 'bson'; import { teamFactory } from '@shared/testing/factory/team.factory'; -import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; import { teamUserFactory } from '@shared/testing/factory/teamuser.factory'; -import { CourseService } from '@modules/learnroom/service'; -import { VideoConferenceService } from './video-conference.service'; -import { ErrorStatus } from '../error'; +import { videoConferenceDOFactory } from '@shared/testing/factory/video-conference.do.factory'; +import { ObjectId } from 'bson'; import { BBBRole } from '../bbb'; -import { IScopeInfo, ScopeRef, VideoConferenceState } from '../uc/dto'; -import { IVideoConferenceSettings, VideoConferenceOptions, VideoConferenceSettings } from '../interface'; +import { ErrorStatus } from '../error'; +import { VideoConferenceOptions, VideoConferenceSettings, VideoConferenceSettingsInterface } from '../interface'; +import { ScopeInfo, ScopeRef, VideoConferenceState } from '../uc/dto'; +import { VideoConferenceService } from './video-conference.service'; describe('VideoConferenceService', () => { let service: DeepMocked; @@ -39,7 +39,7 @@ describe('VideoConferenceService', () => { let teamsRepo: DeepMocked; let userService: DeepMocked; let videoConferenceRepo: DeepMocked; - let videoConferenceSettings: DeepMocked; + let videoConferenceSettings: DeepMocked; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ @@ -47,7 +47,7 @@ describe('VideoConferenceService', () => { VideoConferenceService, { provide: VideoConferenceSettings, - useValue: createMock({ + useValue: createMock({ hostUrl: 'https://api.example.com', }), }, @@ -561,7 +561,7 @@ describe('VideoConferenceService', () => { course.id = scopeId; courseService.findById.mockResolvedValue(course); - const result: IScopeInfo = await service.getScopeInfo(userId, scopeId, conferenceScope); + const result: ScopeInfo = await service.getScopeInfo(userId, scopeId, conferenceScope); expect(result).toEqual({ scopeId, @@ -580,7 +580,7 @@ describe('VideoConferenceService', () => { const event: CalendarEventDto = { title: 'Event', teamId }; calendarService.findEvent.mockResolvedValue(event); - const result: IScopeInfo = await service.getScopeInfo(userId, scopeId, VideoConferenceScope.EVENT); + const result: ScopeInfo = await service.getScopeInfo(userId, scopeId, VideoConferenceScope.EVENT); expect(result).toEqual({ scopeId: teamId, diff --git a/apps/server/src/modules/video-conference/uc/video-conference-create.uc.spec.ts b/apps/server/src/modules/video-conference/uc/video-conference-create.uc.spec.ts index 4c38bf18467..1361cb053ad 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-create.uc.spec.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-create.uc.spec.ts @@ -1,16 +1,16 @@ -import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UserService } from '@modules/user'; -import { userDoFactory } from '@shared/testing'; +import { ForbiddenException } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; import { UserDO, VideoConferenceScope } from '@shared/domain'; +import { userDoFactory } from '@shared/testing'; import { ObjectId } from 'bson'; -import { ForbiddenException } from '@nestjs/common'; -import { VideoConferenceCreateUc } from './video-conference-create.uc'; -import { BBBService, VideoConferenceService } from '../service'; -import { VideoConferenceOptions } from '../interface'; import { BBBCreateResponse, BBBMeetingInfoResponse, BBBResponse, BBBRole, BBBStatus } from '../bbb'; -import { IScopeInfo, ScopeRef } from './dto'; import { ErrorStatus } from '../error/error-status.enum'; +import { VideoConferenceOptions } from '../interface'; +import { BBBService, VideoConferenceService } from '../service'; +import { ScopeInfo, ScopeRef } from './dto'; +import { VideoConferenceCreateUc } from './video-conference-create.uc'; describe('VideoConferenceCreateUc', () => { let module: TestingModule; @@ -87,7 +87,7 @@ describe('VideoConferenceCreateUc', () => { moderatorMustApproveJoinRequests: true, }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -162,7 +162,7 @@ describe('VideoConferenceCreateUc', () => { moderatorMustApproveJoinRequests: true, }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', 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 ad69aa95a03..0b745dfd90c 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 @@ -39,11 +39,11 @@ import { } from '../bbb'; import { ErrorStatus } from '../error/error-status.enum'; import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; -import { IScopeInfo, VideoConference, VideoConferenceJoin, VideoConferenceState } from './dto'; +import { ScopeInfo, VideoConference, VideoConferenceJoin, VideoConferenceState } from './dto'; import { VideoConferenceDeprecatedUc } from './video-conference-deprecated.uc'; class VideoConferenceDeprecatedUcSpec extends VideoConferenceDeprecatedUc { - async getScopeInfoSpec(userId: EntityId, conferenceScope: VideoConferenceScope, refId: string): Promise { + async getScopeInfoSpec(userId: EntityId, conferenceScope: VideoConferenceScope, refId: string): Promise { return this.getScopeInfo(userId, conferenceScope, refId); } @@ -198,7 +198,7 @@ describe('VideoConferenceUc', () => { describe('getScopeInfo', () => { it('should return scope info for courses', async () => { // Act - const scopeInfo: IScopeInfo = await useCase.getScopeInfoSpec('userId', VideoConferenceScope.COURSE, course.id); + const scopeInfo: ScopeInfo = await useCase.getScopeInfoSpec('userId', VideoConferenceScope.COURSE, course.id); // Assert expect(scopeInfo.scopeId).toEqual(course.id); @@ -209,7 +209,7 @@ describe('VideoConferenceUc', () => { it('should return scope info for teams', async () => { // Act - const scopeInfo: IScopeInfo = await useCase.getScopeInfoSpec('userId', VideoConferenceScope.EVENT, eventId); + const scopeInfo: ScopeInfo = await useCase.getScopeInfoSpec('userId', VideoConferenceScope.EVENT, eventId); // Assert expect(scopeInfo.scopeId).toEqual(event.teamId); From 7eaeb9314f27bc789dde2a4fde0dc525dcad1a58 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Tue, 14 Nov 2023 18:44:25 +0100 Subject: [PATCH 087/110] tests adjusted --- ...xternal-tool-configuration.service.spec.ts | 4 +-- .../uc/video-conference-end.uc.spec.ts | 16 ++++++------ .../uc/video-conference-info.uc.spec.ts | 26 +++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts index 6d0064c1136..b235370f151 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts @@ -11,7 +11,7 @@ import { CustomParameter } from '../../common/domain'; import { CustomParameterScope } from '../../common/enum'; import { ContextExternalTool } from '../../context-external-tool/domain'; import { SchoolExternalTool } from '../../school-external-tool/domain'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ContextExternalToolTemplateInfo } from '../uc'; import { ExternalToolConfigurationService } from './external-tool-configuration.service'; @@ -20,7 +20,7 @@ describe('ExternalToolConfigurationService', () => { let module: TestingModule; let service: ExternalToolConfigurationService; - let toolFeatures: IToolFeatures; + let toolFeatures: ToolFeaturesInterface; beforeAll(async () => { await setupEntities(); diff --git a/apps/server/src/modules/video-conference/uc/video-conference-end.uc.spec.ts b/apps/server/src/modules/video-conference/uc/video-conference-end.uc.spec.ts index d1dbfc18b9d..e18c7d7dc65 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-end.uc.spec.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-end.uc.spec.ts @@ -1,15 +1,15 @@ -import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UserService } from '@modules/user'; -import { userDoFactory } from '@shared/testing'; +import { ForbiddenException } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; import { UserDO, VideoConferenceScope } from '@shared/domain'; +import { userDoFactory } from '@shared/testing'; import { ObjectId } from 'bson'; -import { ForbiddenException } from '@nestjs/common'; -import { BBBService, VideoConferenceService } from '../service'; import { BBBBaseResponse, BBBResponse, BBBRole, BBBStatus } from '../bbb'; -import { IScopeInfo, VideoConference, VideoConferenceState } from './dto'; -import { VideoConferenceEndUc } from './video-conference-end.uc'; import { ErrorStatus } from '../error/error-status.enum'; +import { BBBService, VideoConferenceService } from '../service'; +import { ScopeInfo, VideoConference, VideoConferenceState } from './dto'; +import { VideoConferenceEndUc } from './video-conference-end.uc'; describe('VideoConferenceEndUc', () => { let module: TestingModule; @@ -57,7 +57,7 @@ describe('VideoConferenceEndUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -93,7 +93,7 @@ describe('VideoConferenceEndUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', diff --git a/apps/server/src/modules/video-conference/uc/video-conference-info.uc.spec.ts b/apps/server/src/modules/video-conference/uc/video-conference-info.uc.spec.ts index ebc8daa4084..3aac5d6e8ff 100644 --- a/apps/server/src/modules/video-conference/uc/video-conference-info.uc.spec.ts +++ b/apps/server/src/modules/video-conference/uc/video-conference-info.uc.spec.ts @@ -1,17 +1,17 @@ -import { Test, TestingModule } from '@nestjs/testing'; import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { UserService } from '@modules/user'; -import { userDoFactory } from '@shared/testing'; +import { ForbiddenException } from '@nestjs/common'; +import { Test, TestingModule } from '@nestjs/testing'; import { Permission, UserDO, VideoConferenceDO, VideoConferenceScope } from '@shared/domain'; -import { ObjectId } from 'bson'; +import { userDoFactory } from '@shared/testing'; import { videoConferenceDOFactory } from '@shared/testing/factory/video-conference.do.factory'; -import { ForbiddenException } from '@nestjs/common'; -import { BBBService, VideoConferenceService } from '../service'; +import { ObjectId } from 'bson'; import { BBBMeetingInfoResponse, BBBResponse, BBBRole, BBBStatus } from '../bbb'; -import { IScopeInfo, VideoConferenceInfo, VideoConferenceState } from './dto'; -import { VideoConferenceInfoUc } from './video-conference-info.uc'; -import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; import { ErrorStatus } from '../error/error-status.enum'; +import { defaultVideoConferenceOptions, VideoConferenceOptions } from '../interface'; +import { BBBService, VideoConferenceService } from '../service'; +import { ScopeInfo, VideoConferenceInfo, VideoConferenceState } from './dto'; +import { VideoConferenceInfoUc } from './video-conference-info.uc'; describe('VideoConferenceInfoUc', () => { let module: TestingModule; @@ -76,7 +76,7 @@ describe('VideoConferenceInfoUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -117,7 +117,7 @@ describe('VideoConferenceInfoUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -235,7 +235,7 @@ describe('VideoConferenceInfoUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -283,7 +283,7 @@ describe('VideoConferenceInfoUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', @@ -327,7 +327,7 @@ describe('VideoConferenceInfoUc', () => { const user: UserDO = userDoFactory.buildWithId(); const currentUserId: string = user.id as string; const scope = { scope: VideoConferenceScope.COURSE, id: new ObjectId().toHexString() }; - const scopeInfo: IScopeInfo = { + const scopeInfo: ScopeInfo = { scopeId: scope.id, scopeName: 'scopeName', title: 'title', From a81e636516f667a721d5dfa49fa8dfc15853f876 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 09:55:32 +0100 Subject: [PATCH 088/110] test adjusted --- .../service/keycloak-configuration.service.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/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 index 61e475fe3e3..4c24ad34e50 100644 --- a/apps/server/src/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 @@ -1,4 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; +import { SymetricKeyEncryptionService } from '@infra/encryption'; import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import IdentityProviderRepresentation from '@keycloak/keycloak-admin-client/lib/defs/identityProviderRepresentation'; import UserRepresentation from '@keycloak/keycloak-admin-client/lib/defs/userRepresentation'; @@ -6,20 +7,19 @@ import { AuthenticationManagement } from '@keycloak/keycloak-admin-client/lib/re import { Clients } from '@keycloak/keycloak-admin-client/lib/resources/clients'; import { IdentityProviders } from '@keycloak/keycloak-admin-client/lib/resources/identityProviders'; import { Realms } from '@keycloak/keycloak-admin-client/lib/resources/realms'; +import { SystemOidcMapper } from '@modules/system/mapper/system-oidc.mapper'; +import { SystemOidcService } from '@modules/system/service/system-oidc.service'; 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 '@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'; import { AxiosResponse } from 'axios'; import { of } from 'rxjs'; import { v1 } from 'uuid'; import { - IKeycloakSettings, KeycloakSettings, + KeycloakSettingsInterface, } from '../../keycloak-administration/interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; import { OidcIdentityProviderMapper } from '../mapper/identity-provider.mapper'; @@ -32,7 +32,7 @@ describe('KeycloakConfigurationService Unit', () => { let configService: DeepMocked; let systemOidcService: DeepMocked; let httpServiceMock: DeepMocked; - let settings: IKeycloakSettings; + let settings: KeycloakSettingsInterface; const kcApiClientIdentityProvidersMock = createMock(); const kcApiClientMock = createMock(); @@ -49,7 +49,7 @@ describe('KeycloakConfigurationService Unit', () => { username: adminUsername, }; - const getSettings = (): IKeycloakSettings => { + const getSettings = (): KeycloakSettingsInterface => { return { baseUrl: 'http://localhost:8080', realmName: 'master', From b5b2efde686e7ed8564416ba920a402810e1f93b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 10:25:02 +0100 Subject: [PATCH 089/110] Revert "IFindOptions -> FindOptions" This reverts commit 3ad7af309c44198c3cdedc4362c84fc6bf78f7a2. --- .../files-storage/repo/filerecord.repo.ts | 10 +++++----- apps/server/src/modules/news/uc/news.uc.ts | 4 ++-- .../repo/external-tool-pseudonym.repo.ts | 4 ++-- .../service/pseudonym.service.spec.ts | 6 +++--- .../pseudonym/service/pseudonym.service.ts | 6 +++--- .../src/modules/task/service/task.service.ts | 6 +++--- .../controller/tool.controller.ts | 4 ++-- .../service/external-tool.service.spec.ts | 4 ++-- .../service/external-tool.service.ts | 4 ++-- .../external-tool/uc/external-tool.uc.spec.ts | 4 ++-- .../tool/external-tool/uc/external-tool.uc.ts | 6 +++--- .../controller/import-user.controller.ts | 6 +++--- .../modules/user-import/uc/user-import.uc.ts | 20 ++++++++++++++----- .../modules/user/service/user.service.spec.ts | 12 +++++------ .../src/modules/user/service/user.service.ts | 4 ++-- .../shared/domain/interface/find-options.ts | 2 +- .../src/shared/repo/course/course.repo.ts | 6 +++--- .../external-tool.repo.integration.spec.ts | 14 ++++++------- .../repo/externaltool/external-tool.repo.ts | 4 ++-- .../shared/repo/importuser/importuser.repo.ts | 6 +++--- apps/server/src/shared/repo/news/news.repo.ts | 8 ++++---- apps/server/src/shared/repo/task/task.repo.ts | 10 +++++----- .../user/user-do.repo.integration.spec.ts | 5 +++-- .../src/shared/repo/user/user-do.repo.ts | 4 ++-- apps/server/src/shared/repo/user/user.repo.ts | 4 ++-- 25 files changed, 87 insertions(+), 76 deletions(-) diff --git a/apps/server/src/modules/files-storage/repo/filerecord.repo.ts b/apps/server/src/modules/files-storage/repo/filerecord.repo.ts index 6ee9d005962..2b87fe61707 100644 --- a/apps/server/src/modules/files-storage/repo/filerecord.repo.ts +++ b/apps/server/src/modules/files-storage/repo/filerecord.repo.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { Counted, EntityId, FindOptions, SortOrder } from '@shared/domain'; +import { Counted, EntityId, IFindOptions, SortOrder } from '@shared/domain'; import { BaseRepo } from '@shared/repo'; import { FileRecord } from '../entity'; import { FileRecordScope } from './filerecord-scope'; @@ -24,7 +24,7 @@ export class FileRecordRepo extends BaseRepo { return fileRecord; } - async findByParentId(parentId: EntityId, options?: FindOptions): Promise> { + async findByParentId(parentId: EntityId, options?: IFindOptions): Promise> { const scope = new FileRecordScope().byParentId(parentId).byMarkedForDelete(false); const result = await this.findAndCount(scope, options); @@ -34,7 +34,7 @@ export class FileRecordRepo extends BaseRepo { async findBySchoolIdAndParentId( schoolId: EntityId, parentId: EntityId, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new FileRecordScope().bySchoolId(schoolId).byParentId(parentId).byMarkedForDelete(false); const result = await this.findAndCount(scope, options); @@ -45,7 +45,7 @@ export class FileRecordRepo extends BaseRepo { async findBySchoolIdAndParentIdAndMarkedForDelete( schoolId: EntityId, parentId: EntityId, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new FileRecordScope().bySchoolId(schoolId).byParentId(parentId).byMarkedForDelete(true); const result = await this.findAndCount(scope, options); @@ -64,7 +64,7 @@ export class FileRecordRepo extends BaseRepo { private async findAndCount( scope: FileRecordScope, - options?: FindOptions + options?: IFindOptions ): Promise> { const { pagination } = options || {}; const order = { createdAt: SortOrder.desc, id: SortOrder.asc }; diff --git a/apps/server/src/modules/news/uc/news.uc.ts b/apps/server/src/modules/news/uc/news.uc.ts index 631133c59ca..b967fae8c85 100644 --- a/apps/server/src/modules/news/uc/news.uc.ts +++ b/apps/server/src/modules/news/uc/news.uc.ts @@ -4,7 +4,7 @@ import { Counted, CreateNews, EntityId, - FindOptions, + IFindOptions, IUpdateNews, News, NewsScopeInterface, @@ -67,7 +67,7 @@ export class NewsUc { public async findAllForUser( userId: EntityId, scope?: NewsScopeInterface, - options?: FindOptions + options?: IFindOptions ): Promise> { const unpublished = !!scope?.unpublished; // default is only published news const permissions: [NewsPermission] = NewsUc.getRequiredPermissions(unpublished); diff --git a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts index fc35ad9bd0d..65ef03cd539 100644 --- a/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts +++ b/apps/server/src/modules/pseudonym/repo/external-tool-pseudonym.repo.ts @@ -1,6 +1,6 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; -import { EntityId, FindOptions, Page, Pagination, Pseudonym } from '@shared/domain'; +import { EntityId, IFindOptions, Page, Pagination, Pseudonym } from '@shared/domain'; import { Scope } from '@shared/repo'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymEntity, ExternalToolPseudonymEntityProps } from '../entity'; @@ -109,7 +109,7 @@ export class ExternalToolPseudonymRepo { }; } - async findPseudonym(query: PseudonymSearchQuery, options?: FindOptions): Promise> { + async findPseudonym(query: PseudonymSearchQuery, options?: IFindOptions): Promise> { const pagination: Pagination = options?.pagination ?? {}; const scope: Scope = new PseudonymScope() .byPseudonym(query.pseudonym) diff --git a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts index fbf1867f985..026d28d039f 100644 --- a/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts +++ b/apps/server/src/modules/pseudonym/service/pseudonym.service.spec.ts @@ -1,10 +1,10 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; import { InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { FindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; +import { IFindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; import { externalToolFactory, ltiToolDOFactory, pseudonymFactory, userDoFactory } from '@shared/testing/factory'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymRepo, PseudonymsRepo } from '../repo'; import { PseudonymService } from './pseudonym.service'; @@ -474,7 +474,7 @@ describe('PseudonymService', () => { const query: PseudonymSearchQuery = { pseudonym: 'pseudonym', }; - const options: FindOptions = {}; + const options: IFindOptions = {}; const page: Page = new Page([pseudonymFactory.build()], 1); externalToolPseudonymRepo.findPseudonym.mockResolvedValueOnce(page); diff --git a/apps/server/src/modules/pseudonym/service/pseudonym.service.ts b/apps/server/src/modules/pseudonym/service/pseudonym.service.ts index 7257af6ec06..6d15d6a1ec9 100644 --- a/apps/server/src/modules/pseudonym/service/pseudonym.service.ts +++ b/apps/server/src/modules/pseudonym/service/pseudonym.service.ts @@ -1,8 +1,8 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { ObjectId } from '@mikro-orm/mongodb'; -import { ExternalTool } from '@modules/tool/external-tool/domain'; import { Injectable, InternalServerErrorException } from '@nestjs/common'; -import { FindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; +import { IFindOptions, LtiToolDO, Page, Pseudonym, UserDO } from '@shared/domain'; +import { ExternalTool } from '@modules/tool/external-tool/domain'; import { v4 as uuidv4 } from 'uuid'; import { PseudonymSearchQuery } from '../domain'; import { ExternalToolPseudonymRepo, PseudonymsRepo } from '../repo'; @@ -123,7 +123,7 @@ export class PseudonymService { return result; } - async findPseudonym(query: PseudonymSearchQuery, options: FindOptions): Promise> { + async findPseudonym(query: PseudonymSearchQuery, options: IFindOptions): Promise> { const result: Page = await this.externalToolPseudonymRepo.findPseudonym(query, options); return result; diff --git a/apps/server/src/modules/task/service/task.service.ts b/apps/server/src/modules/task/service/task.service.ts index 4b0490cf164..78f9dca9a51 100644 --- a/apps/server/src/modules/task/service/task.service.ts +++ b/apps/server/src/modules/task/service/task.service.ts @@ -1,7 +1,7 @@ -import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { Injectable } from '@nestjs/common'; -import { Counted, EntityId, FindOptions, Task } from '@shared/domain'; +import { Counted, EntityId, IFindOptions, Task } from '@shared/domain'; import { TaskRepo } from '@shared/repo'; +import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { SubmissionService } from './submission.service'; @Injectable() @@ -16,7 +16,7 @@ export class TaskService { creatorId: EntityId, courseId: EntityId, filters?: { draft?: boolean; noFutureAvailableDate?: boolean }, - options?: FindOptions + options?: IFindOptions ): Promise> { return this.taskRepo.findBySingleParent(creatorId, courseId, filters, options); } diff --git a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts index 44f0e0be075..ec102455d06 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts @@ -13,7 +13,7 @@ import { } from '@nestjs/swagger'; import { ValidationError } from '@shared/common'; import { PaginationParams } from '@shared/controller'; -import { FindOptions, Page } from '@shared/domain'; +import { IFindOptions, Page } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; import { Response } from 'express'; import { ExternalToolSearchQuery } from '../../common/interface'; @@ -76,7 +76,7 @@ export class ToolController { @Query() pagination: PaginationParams, @Query() sortingQuery: SortExternalToolParams ): Promise { - const options: FindOptions = { pagination }; + const options: IFindOptions = { pagination }; options.order = this.externalToolDOMapper.mapSortingQueryToDomain(sortingQuery); const query: ExternalToolSearchQuery = this.externalToolDOMapper.mapExternalToolFilterQueryToExternalToolSearchQuery(filterQuery); 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 7daab1341ec..88df8a3a2c6 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 @@ -4,7 +4,7 @@ import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { FindOptions, Page, SortOrder } from '@shared/domain'; +import { IFindOptions, Page, SortOrder } from '@shared/domain'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { externalToolFactory, @@ -223,7 +223,7 @@ describe('ExternalToolService', () => { const query: ExternalToolSearchQuery = { name: 'toolName', }; - const options: FindOptions = { + const options: IFindOptions = { order: { id: SortOrder.asc, name: SortOrder.asc, 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 a83ed5f3545..562ae443112 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 @@ -2,7 +2,7 @@ import { DefaultEncryptionService, EncryptionService } from '@infra/encryption'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { Inject, Injectable, UnprocessableEntityException } from '@nestjs/common'; -import { EntityId, FindOptions, Page } from '@shared/domain'; +import { EntityId, IFindOptions, Page } from '@shared/domain'; import { ContextExternalToolRepo, ExternalToolRepo, SchoolExternalToolRepo } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { TokenEndpointAuthMethod } from '../../common/enum'; @@ -50,7 +50,7 @@ export class ExternalToolService { async findExternalTools( query: ExternalToolSearchQuery, - options?: FindOptions + options?: IFindOptions ): Promise> { const tools: Page = await this.externalToolRepo.find(query, options); diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts index f4031b52bb0..56c0075ae97 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts @@ -3,7 +3,7 @@ import { CurrentUserInterface } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { FindOptions, Permission, SortOrder, User } from '@shared/domain'; +import { IFindOptions, Permission, SortOrder, User } from '@shared/domain'; import { Page } from '@shared/domain/domainobject/page'; import { setupEntities, userFactory } from '@shared/testing'; import { @@ -87,7 +87,7 @@ describe('ExternalToolUc', () => { const query: ExternalToolSearchQuery = { name: externalTool.name, }; - const options: FindOptions = { + const options: IFindOptions = { order: { id: SortOrder.asc, name: SortOrder.asc, diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts index a082d6a067d..2cf49867103 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.ts @@ -1,6 +1,6 @@ -import { AuthorizationService } from '@modules/authorization'; import { Injectable } from '@nestjs/common'; -import { EntityId, FindOptions, Page, Permission, User } from '@shared/domain'; +import { EntityId, IFindOptions, Page, Permission, User } from '@shared/domain'; +import { AuthorizationService } from '@modules/authorization'; import { ExternalToolSearchQuery } from '../../common/interface'; import { ExternalTool, ExternalToolConfig } from '../domain'; import { ExternalToolLogoService, ExternalToolService, ExternalToolValidationService } from '../service'; @@ -52,7 +52,7 @@ export class ExternalToolUc { async findExternalTool( userId: EntityId, query: ExternalToolSearchQuery, - options: FindOptions + options: IFindOptions ): Promise> { await this.ensurePermission(userId, Permission.TOOL_ADMIN); diff --git a/apps/server/src/modules/user-import/controller/import-user.controller.ts b/apps/server/src/modules/user-import/controller/import-user.controller.ts index 536b7e4c961..6f49104c425 100644 --- a/apps/server/src/modules/user-import/controller/import-user.controller.ts +++ b/apps/server/src/modules/user-import/controller/import-user.controller.ts @@ -2,7 +2,7 @@ import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authen import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; -import { FindOptions, ImportUser, User } from '@shared/domain'; +import { IFindOptions, ImportUser, User } from '@shared/domain'; import { ImportUserMapper } from '../mapper/import-user.mapper'; import { UserMatchMapper } from '../mapper/user-match.mapper'; import { UserImportUc } from '../uc/user-import.uc'; @@ -32,7 +32,7 @@ export class ImportUserController { @Query() sortingQuery: SortImportUserParams, @Query() pagination: PaginationParams ): Promise { - const options: FindOptions = { pagination }; + const options: IFindOptions = { pagination }; options.order = ImportUserMapper.mapSortingQueryToDomain(sortingQuery); const query = ImportUserMapper.mapImportUserFilterQueryToDomain(scope); const [importUserList, count] = await this.userImportUc.findAllImportUsers(currentUser.userId, query, options); @@ -84,7 +84,7 @@ export class ImportUserController { @Query() scope: FilterUserParams, @Query() pagination: PaginationParams ): Promise { - const options: FindOptions = { pagination }; + const options: IFindOptions = { pagination }; const query = UserMatchMapper.mapToDomain(scope); const [userList, total] = await this.userUc.findAllUnmatchedUsers(currentUser.userId, query, options); diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index df1d069e3f8..ef93ac0a6d4 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -9,7 +9,7 @@ import { Account, Counted, EntityId, - FindOptions, + IFindOptions, ImportUser, ImportUserScopeInterface, LegacySchoolDo, @@ -19,7 +19,7 @@ import { Permission, SchoolFeatures, SystemEntity, - User, + User } from '@shared/domain'; import { ImportUserRepo, SystemRepo, UserRepo } from '@shared/repo'; import { Logger } from '@src/core/logger'; @@ -30,12 +30,12 @@ import { SchoolIdDoesNotMatchWithUserSchoolId, SchoolInUserMigrationEndLoggable, SchoolInUserMigrationStartLoggable, - UserMigrationIsNotEnabled, + UserMigrationIsNotEnabled } from '../loggable'; import { LdapAlreadyPersistedException, MigrationAlreadyActivatedException, - MissingSchoolNumberException, + MissingSchoolNumberException } from './ldap-user-migration.error'; export type UserImportPermissions = @@ -75,8 +75,13 @@ export class UserImportUc { */ async findAllImportUsers( currentUserId: EntityId, +<<<<<<< HEAD query: ImportUserScopeInterface, options?: FindOptions +======= + query: IImportUserScope, + options?: IFindOptions +>>>>>>> parent of 3ad7af309 (IFindOptions -> FindOptions) ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); @@ -164,8 +169,13 @@ export class UserImportUc { */ async findAllUnmatchedUsers( currentUserId: EntityId, +<<<<<<< HEAD query: NameMatch, options?: FindOptions +======= + query: INameMatch, + options?: IFindOptions +>>>>>>> parent of 3ad7af309 (IFindOptions -> FindOptions) ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); @@ -181,7 +191,7 @@ export class UserImportUc { this.checkFeatureEnabled(school); const filters: ImportUserScopeInterface = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; // TODO batch/paginated import? - const options: FindOptions = {}; + const options: IFindOptions = {}; // TODO Change ImportUserRepo to DO to fix this workaround const [importUsers, total] = await this.importUserRepo.findImportUsers(currentUser.school, filters, options); let migratedUser = 0; diff --git a/apps/server/src/modules/user/service/user.service.spec.ts b/apps/server/src/modules/user/service/user.service.spec.ts index ad6dec2241a..f65d02c13a5 100644 --- a/apps/server/src/modules/user/service/user.service.spec.ts +++ b/apps/server/src/modules/user/service/user.service.spec.ts @@ -1,18 +1,18 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/core'; -import { AccountDto, AccountService } from '@modules/account'; -import { OauthCurrentUser } from '@modules/authentication/interface'; -import { RoleService } from '@modules/role'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; -import { EntityId, FindOptions, LanguageType, Permission, Role, RoleName, SortOrder, User } from '@shared/domain'; +import { EntityId, IFindOptions, LanguageType, Permission, Role, RoleName, SortOrder, User } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { UserRepo } from '@shared/repo'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; import { roleFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; +import { AccountService, AccountDto } from '@modules/account'; +import { RoleService } from '@modules/role'; +import { OauthCurrentUser } from '@modules/authentication/interface'; import { UserDto } from '../uc/dto/user.dto'; -import { UserQuery } from './user-query.type'; import { UserService } from './user.service'; +import { UserQuery } from './user-query.type'; describe('UserService', () => { let service: UserService; @@ -318,7 +318,7 @@ describe('UserService', () => { schoolId: 'schoolId', isOutdated: true, }; - const options: FindOptions = { order: { id: SortOrder.asc } }; + const options: IFindOptions = { order: { id: SortOrder.asc } }; await service.findUsers(query, options); diff --git a/apps/server/src/modules/user/service/user.service.ts b/apps/server/src/modules/user/service/user.service.ts index 06bc1754f8d..6ef014f8696 100644 --- a/apps/server/src/modules/user/service/user.service.ts +++ b/apps/server/src/modules/user/service/user.service.ts @@ -7,7 +7,7 @@ import { RoleDto } from '@modules/role/service/dto/role.dto'; import { RoleService } from '@modules/role/service/role.service'; import { BadRequestException, Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { EntityId, FindOptions, LanguageType, User } from '@shared/domain'; +import { EntityId, IFindOptions, LanguageType, User } from '@shared/domain'; import { Page, RoleReference, UserDO } from '@shared/domain/domainobject'; import { UserRepo } from '@shared/repo'; import { UserDORepo } from '@shared/repo/user/user-do.repo'; @@ -70,7 +70,7 @@ export class UserService { return savedUsers; } - async findUsers(query: UserQuery, options?: FindOptions): Promise> { + async findUsers(query: UserQuery, options?: IFindOptions): Promise> { const users: Page = await this.userDORepo.find(query, options); return users; diff --git a/apps/server/src/shared/domain/interface/find-options.ts b/apps/server/src/shared/domain/interface/find-options.ts index 5a3dbcb3d97..37fc49a5909 100644 --- a/apps/server/src/shared/domain/interface/find-options.ts +++ b/apps/server/src/shared/domain/interface/find-options.ts @@ -10,7 +10,7 @@ export enum SortOrder { export type SortOrderMap = Partial>; -export interface FindOptions { +export interface IFindOptions { pagination?: Pagination; order?: SortOrderMap; } diff --git a/apps/server/src/shared/repo/course/course.repo.ts b/apps/server/src/shared/repo/course/course.repo.ts index db8263d79d4..b673dbfded8 100644 --- a/apps/server/src/shared/repo/course/course.repo.ts +++ b/apps/server/src/shared/repo/course/course.repo.ts @@ -1,7 +1,7 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; -import { Counted, Course, EntityId, FindOptions } from '@shared/domain'; +import { Counted, Course, EntityId, IFindOptions } from '@shared/domain'; import { BaseRepo } from '../base.repo'; import { Scope } from '../scope'; @@ -71,7 +71,7 @@ export class CourseRepo extends BaseRepo { async findAllByUserId( userId: EntityId, filters?: { onlyActiveCourses?: boolean }, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new CourseScope(); scope.forAllGroupTypes(userId); @@ -95,7 +95,7 @@ export class CourseRepo extends BaseRepo { async findAllForTeacher( userId: EntityId, filters?: { onlyActiveCourses?: boolean }, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new CourseScope(); scope.forTeacher(userId); 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 d5e34d34732..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 @@ -1,6 +1,11 @@ import { createMock } from '@golevelup/ts-jest'; -import { MongoMemoryDatabaseModule } from '@infra/database'; import { EntityManager } from '@mikro-orm/mongodb'; +import { Test, TestingModule } from '@nestjs/testing'; +import { IFindOptions, Page, SortOrder } from '@shared/domain'; +import { MongoMemoryDatabaseModule } from '@infra/database'; +import { ExternalToolRepo, ExternalToolRepoMapper } from '@shared/repo'; +import { cleanupCollections, externalToolEntityFactory } from '@shared/testing'; +import { LegacyLogger } from '@src/core/logger'; import { ExternalToolSearchQuery } from '@modules/tool'; import { CustomParameter } from '@modules/tool/common/domain'; import { @@ -13,11 +18,6 @@ import { } from '@modules/tool/common/enum'; import { BasicToolConfig, ExternalTool, Lti11ToolConfig, Oauth2ToolConfig } from '@modules/tool/external-tool/domain'; import { ExternalToolEntity } from '@modules/tool/external-tool/entity'; -import { Test, TestingModule } from '@nestjs/testing'; -import { FindOptions, Page, SortOrder } from '@shared/domain'; -import { ExternalToolRepo, ExternalToolRepoMapper } from '@shared/repo'; -import { cleanupCollections, externalToolEntityFactory } from '@shared/testing'; -import { LegacyLogger } from '@src/core/logger'; describe('ExternalToolRepo', () => { let module: TestingModule; @@ -218,7 +218,7 @@ describe('ExternalToolRepo', () => { const { queryExternalToolDO } = await setup(); queryExternalToolDO.name = '.'; - const options: FindOptions = {}; + const options: IFindOptions = {}; await em.nativeDelete(ExternalToolEntity, {}); const ltiToolA: ExternalToolEntity = externalToolEntityFactory.withName('A').buildWithId(); diff --git a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts index a500e7127bc..3d071311d82 100644 --- a/apps/server/src/shared/repo/externaltool/external-tool.repo.ts +++ b/apps/server/src/shared/repo/externaltool/external-tool.repo.ts @@ -5,7 +5,7 @@ import { ExternalToolSearchQuery } from '@modules/tool/common/interface'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { ExternalToolEntity, IExternalToolProperties } from '@modules/tool/external-tool/entity'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; -import { FindOptions, Page, Pagination, SortOrder } from '@shared/domain'; +import { IFindOptions, Page, Pagination, SortOrder } from '@shared/domain'; import { BaseDORepo, ExternalToolRepoMapper, ExternalToolSortingMapper, Scope } from '@shared/repo'; import { LegacyLogger } from '@src/core/logger'; import { ExternalToolScope } from './external-tool.scope'; @@ -51,7 +51,7 @@ export class ExternalToolRepo extends BaseDORepo): Promise> { + async find(query: ExternalToolSearchQuery, options?: IFindOptions): Promise> { const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = ExternalToolSortingMapper.mapDOSortOrderToQueryOrder( options?.order || {} diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.ts b/apps/server/src/shared/repo/importuser/importuser.repo.ts index e52ab86a494..c77ecab2dd5 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.ts @@ -5,7 +5,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { Counted, EntityId, - FindOptions, + IFindOptions, ImportUser, ImportUserScopeInterface, SchoolEntity, @@ -42,7 +42,7 @@ export class ImportUserRepo extends BaseRepo { async findImportUsers( school: SchoolEntity, filters: ImportUserScopeInterface = {}, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new ImportUserScope(); scope.bySchool(school); @@ -59,7 +59,7 @@ export class ImportUserRepo extends BaseRepo { private async findImportUsersAndCount( query: FilterQuery, - options?: FindOptions + options?: IFindOptions ): Promise> { const { pagination, order } = options || {}; const queryOptions = { diff --git a/apps/server/src/shared/repo/news/news.repo.ts b/apps/server/src/shared/repo/news/news.repo.ts index 2d5c6e19183..f6ff97cfa9c 100644 --- a/apps/server/src/shared/repo/news/news.repo.ts +++ b/apps/server/src/shared/repo/news/news.repo.ts @@ -1,6 +1,6 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; -import { Counted, CourseNews, EntityId, FindOptions, News, SchoolNews, TeamNews } from '@shared/domain'; +import { Counted, CourseNews, EntityId, IFindOptions, News, SchoolNews, TeamNews } from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { NewsScope } from './news-scope'; import { NewsTargetFilter } from './news-target-filter'; @@ -18,7 +18,7 @@ export class NewsRepo extends BaseRepo { * @param targets * @param options */ - async findAllPublished(targets: NewsTargetFilter[], options?: FindOptions): Promise> { + async findAllPublished(targets: NewsTargetFilter[], options?: IFindOptions): Promise> { const scope = new NewsScope(); scope.byTargets(targets); scope.byPublished(); @@ -36,7 +36,7 @@ export class NewsRepo extends BaseRepo { async findAllUnpublishedByUser( targets: NewsTargetFilter[], creatorId: EntityId, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new NewsScope(); scope.byTargets(targets); @@ -55,7 +55,7 @@ export class NewsRepo extends BaseRepo { } /** resolves a news documents list with some elements (school, target, and updator/creator) populated already */ - private async findNewsAndCount(query: FilterQuery, options?: FindOptions): Promise> { + private async findNewsAndCount(query: FilterQuery, options?: IFindOptions): Promise> { const { pagination, order } = options || {}; const [newsEntities, count] = await this._em.findAndCount(News, query, { ...pagination, diff --git a/apps/server/src/shared/repo/task/task.repo.ts b/apps/server/src/shared/repo/task/task.repo.ts index a5ab4375284..094d21a8dc5 100644 --- a/apps/server/src/shared/repo/task/task.repo.ts +++ b/apps/server/src/shared/repo/task/task.repo.ts @@ -1,7 +1,7 @@ import { FilterQuery } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { Task } from '@shared/domain/entity'; -import { FindOptions, SortOrder } from '@shared/domain/interface'; +import { IFindOptions, SortOrder } from '@shared/domain/interface'; import { Counted, EntityId } from '@shared/domain/types'; import { BaseRepo } from '../base.repo'; import { TaskScope } from './task-scope'; @@ -43,7 +43,7 @@ export class TaskRepo extends BaseRepo { finishedCourseIds: EntityId[]; lessonIdsOfFinishedCourses: EntityId[]; }, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new TaskScope('$or'); @@ -114,7 +114,7 @@ export class TaskRepo extends BaseRepo { finished?: { userId: EntityId; value: boolean }; availableOn?: Date; }, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new TaskScope(); @@ -165,7 +165,7 @@ export class TaskRepo extends BaseRepo { creatorId: EntityId, courseId: EntityId, filters?: { draft?: boolean; noFutureAvailableDate?: boolean }, - options?: FindOptions + options?: IFindOptions ): Promise> { const scope = new TaskScope(); scope.byCourseIds([courseId]); @@ -187,7 +187,7 @@ export class TaskRepo extends BaseRepo { return countedTaskList; } - private async findTasksAndCount(query: FilterQuery, options?: FindOptions): Promise> { + private async findTasksAndCount(query: FilterQuery, options?: IFindOptions): Promise> { const pagination = options?.pagination || {}; const order = options?.order || {}; 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 c07e47d2453..324e07b2092 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 @@ -6,6 +6,7 @@ import { UserQuery } from '@modules/user/service/user-query.type'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; import { + IFindOptions, LanguageType, Role, RoleName, @@ -335,7 +336,7 @@ describe('UserRepo', () => { lastLoginSystemChangeBetweenStart: undefined, }; - const options: FindOptions = {}; + const options: IFindOptions = {}; await em.nativeDelete(User, {}); await em.nativeDelete(SchoolEntity, {}); @@ -459,7 +460,7 @@ describe('UserRepo', () => { lastLoginSystemChangeBetweenEnd: new Date(), }; - const options: FindOptions = {}; + const options: IFindOptions = {}; await em.nativeDelete(User, {}); await em.nativeDelete(SchoolEntity, {}); diff --git a/apps/server/src/shared/repo/user/user-do.repo.ts b/apps/server/src/shared/repo/user/user-do.repo.ts index 379f86be1d1..aa13193b0e6 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.ts @@ -4,7 +4,7 @@ import { Injectable } from '@nestjs/common'; import { EntityNotFoundError } from '@shared/common'; import { EntityId, - FindOptions, + IFindOptions, Pagination, Role, SchoolEntity, @@ -30,7 +30,7 @@ export class UserDORepo extends BaseDORepo { return new User(props); } - async find(query: UserQuery, options?: FindOptions) { + async find(query: UserQuery, options?: IFindOptions) { const pagination: Pagination = options?.pagination || {}; const order: QueryOrderMap = this.createQueryOrderMap(options?.order || {}); const scope: Scope = new UserScope() diff --git a/apps/server/src/shared/repo/user/user.repo.ts b/apps/server/src/shared/repo/user/user.repo.ts index 7c5e7635f87..44acafe6a80 100644 --- a/apps/server/src/shared/repo/user/user.repo.ts +++ b/apps/server/src/shared/repo/user/user.repo.ts @@ -5,7 +5,7 @@ import { StringValidator } from '@shared/common'; import { Counted, EntityId, - FindOptions, + IFindOptions, ImportUser, NameMatch, Role, @@ -48,7 +48,7 @@ export class UserRepo extends BaseRepo { async findWithoutImportUser( school: SchoolEntity, filters?: NameMatch, - options?: FindOptions + options?: IFindOptions ): Promise> { const { _id: schoolId } = school; if (!ObjectId.isValid(schoolId)) throw new Error('invalid school id'); From 5a680475f435b14ec7eb2397cc14fd66ec10b967 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 10:27:40 +0100 Subject: [PATCH 090/110] solved more conflicts caused by revert --- .../src/modules/user-import/uc/user-import.uc.ts | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index ef93ac0a6d4..618c60341cd 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -19,7 +19,7 @@ import { Permission, SchoolFeatures, SystemEntity, - User + User, } from '@shared/domain'; import { ImportUserRepo, SystemRepo, UserRepo } from '@shared/repo'; import { Logger } from '@src/core/logger'; @@ -30,12 +30,12 @@ import { SchoolIdDoesNotMatchWithUserSchoolId, SchoolInUserMigrationEndLoggable, SchoolInUserMigrationStartLoggable, - UserMigrationIsNotEnabled + UserMigrationIsNotEnabled, } from '../loggable'; import { LdapAlreadyPersistedException, MigrationAlreadyActivatedException, - MissingSchoolNumberException + MissingSchoolNumberException, } from './ldap-user-migration.error'; export type UserImportPermissions = @@ -75,13 +75,8 @@ export class UserImportUc { */ async findAllImportUsers( currentUserId: EntityId, -<<<<<<< HEAD query: ImportUserScopeInterface, - options?: FindOptions -======= - query: IImportUserScope, options?: IFindOptions ->>>>>>> parent of 3ad7af309 (IFindOptions -> FindOptions) ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); @@ -169,13 +164,8 @@ export class UserImportUc { */ async findAllUnmatchedUsers( currentUserId: EntityId, -<<<<<<< HEAD query: NameMatch, - options?: FindOptions -======= - query: INameMatch, options?: IFindOptions ->>>>>>> parent of 3ad7af309 (IFindOptions -> FindOptions) ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); From 184089d070f66c7a411c5b6776533df30fdff59b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 13:50:14 +0100 Subject: [PATCH 091/110] merged more conflicts caused by main-merge --- .../src/modules/authentication/index.ts | 1 + .../legacy-school.controller.spec.ts | 94 ------------------- .../controller/legacy-school.controller.ts | 61 ------------ .../oauth/controller/oauth-sso.controller.ts | 30 ------ .../service/tool-version-service.ts | 14 +-- ...school-external-tool-validation.service.ts | 4 +- .../service/school-external-tool.service.ts | 4 +- 7 files changed, 12 insertions(+), 196 deletions(-) delete mode 100644 apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts delete mode 100644 apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts diff --git a/apps/server/src/modules/authentication/index.ts b/apps/server/src/modules/authentication/index.ts index 84b6f96ae01..1a2212989b0 100644 --- a/apps/server/src/modules/authentication/index.ts +++ b/apps/server/src/modules/authentication/index.ts @@ -1,3 +1,4 @@ export { AuthenticationModule } from './authentication.module'; +export { Authenticate, CurrentUser, JWT } from './decorator'; export { CurrentUserInterface } from './interface'; export { AuthenticationService } from './services'; diff --git a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts deleted file mode 100644 index ff209d151a0..00000000000 --- a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.spec.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; -import { Test, TestingModule } from '@nestjs/testing'; -import { MigrationMapper } from '../mapper/migration.mapper'; -import { LegacySchoolUc } from '../uc'; -import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; -import { MigrationBody, MigrationResponse, SchoolParams } from './dto'; -import { LegacySchoolController } from './legacy-school.controller'; - -describe('Legacy School Controller', () => { - let module: TestingModule; - let controller: LegacySchoolController; - let schoolUc: DeepMocked; - let mapper: DeepMocked; - - beforeAll(async () => { - module = await Test.createTestingModule({ - controllers: [LegacySchoolController], - providers: [ - { - provide: LegacySchoolUc, - useValue: createMock(), - }, - { - provide: MigrationMapper, - useValue: createMock(), - }, - ], - }).compile(); - controller = module.get(LegacySchoolController); - schoolUc = module.get(LegacySchoolUc); - mapper = module.get(MigrationMapper); - }); - - afterAll(async () => { - await module.close(); - jest.clearAllMocks(); - }); - - it('should be defined', () => { - expect(controller).toBeDefined(); - }); - - const setupBasicData = () => { - const schoolParams: SchoolParams = { schoolId: new ObjectId().toHexString() }; - const testUser: CurrentUserInterface = { userId: 'testUser' } as CurrentUserInterface; - - const migrationResp: MigrationResponse = { - oauthMigrationMandatory: new Date(), - oauthMigrationPossible: new Date(), - oauthMigrationFinished: new Date(), - enableMigrationStart: true, - }; - const migrationDto: OauthMigrationDto = new OauthMigrationDto({ - oauthMigrationMandatory: new Date(), - oauthMigrationPossible: new Date(), - oauthMigrationFinished: new Date(), - enableMigrationStart: true, - }); - return { schoolParams, testUser, migrationDto, migrationResp }; - }; - - describe('setMigration', () => { - describe('when migrationflags exist and schoolId and userId are given', () => { - it('should call UC and recieve a response', async () => { - const { schoolParams, testUser, migrationDto, migrationResp } = setupBasicData(); - schoolUc.setMigration.mockResolvedValue(migrationDto); - mapper.mapDtoToResponse.mockReturnValue(migrationResp); - const body: MigrationBody = { oauthMigrationPossible: true, oauthMigrationMandatory: true }; - - const res: MigrationResponse = await controller.setMigration(schoolParams, body, testUser); - - expect(schoolUc.setMigration).toHaveBeenCalled(); - expect(res).toBe(migrationResp); - }); - }); - }); - - describe('getMigration', () => { - describe('when schoolId and UserId are given', () => { - it('should call UC and recieve a response', async () => { - const { schoolParams, testUser, migrationDto, migrationResp } = setupBasicData(); - schoolUc.getMigration.mockResolvedValue(migrationDto); - mapper.mapDtoToResponse.mockReturnValue(migrationResp); - - const res: MigrationResponse = await controller.getMigration(schoolParams, testUser); - - expect(schoolUc.getMigration).toHaveBeenCalled(); - expect(res).toBe(migrationResp); - }); - }); - }); -}); diff --git a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts b/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts deleted file mode 100644 index a3b3b93659a..00000000000 --- a/apps/server/src/modules/legacy-school/controller/legacy-school.controller.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; -import { Body, Controller, Get, Param, Put } from '@nestjs/common'; -import { - ApiFoundResponse, - ApiNotFoundResponse, - ApiOkResponse, - ApiTags, - ApiUnauthorizedResponse, -} from '@nestjs/swagger'; -import { MigrationMapper } from '../mapper/migration.mapper'; -import { LegacySchoolUc } from '../uc'; -import { OauthMigrationDto } from '../uc/dto/oauth-migration.dto'; -import { MigrationBody, MigrationResponse, SchoolParams } from './dto'; - -/** - * @deprecated because it uses the deprecated LegacySchoolDo. - */ -@ApiTags('School') -@Authenticate('jwt') -@Controller('school') -export class LegacySchoolController { - constructor(private readonly schoolUc: LegacySchoolUc, private readonly migrationMapper: MigrationMapper) {} - - @Put(':schoolId/migration') - @Authenticate('jwt') - @ApiOkResponse({ description: 'New migrationflags set', type: MigrationResponse }) - @ApiUnauthorizedResponse() - async setMigration( - @Param() schoolParams: SchoolParams, - @Body() migrationBody: MigrationBody, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { - const migrationDto: OauthMigrationDto = await this.schoolUc.setMigration( - schoolParams.schoolId, - !!migrationBody.oauthMigrationPossible, - !!migrationBody.oauthMigrationMandatory, - !!migrationBody.oauthMigrationFinished, - currentUser.userId - ); - - const result: MigrationResponse = this.migrationMapper.mapDtoToResponse(migrationDto); - - return result; - } - - @Get(':schoolId/migration') - @Authenticate('jwt') - @ApiFoundResponse({ description: 'Migrationflags have been found.', type: MigrationResponse }) - @ApiUnauthorizedResponse() - @ApiNotFoundResponse({ description: 'Migrationsflags could not be found for the given school' }) - async getMigration( - @Param() schoolParams: SchoolParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { - const migrationDto: OauthMigrationDto = await this.schoolUc.getMigration(schoolParams.schoolId, currentUser.userId); - - const result: MigrationResponse = this.migrationMapper.mapDtoToResponse(migrationDto); - - return result; - } -} diff --git a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts index b540aa6c5b1..85e73c67c00 100644 --- a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts +++ b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts @@ -7,7 +7,6 @@ import { OAuthTokenDto } from '../interface'; import { HydraOauthUc } from '../uc'; import { AuthorizationParams } from './dto'; import { StatelessAuthorizationParams } from './dto/stateless-authorization.params'; -import { UserMigrationResponse } from './dto/user-migration.response'; @ApiTags('SSO') @Controller('sso') @@ -44,33 +43,4 @@ export class OauthSSOController { } return this.hydraUc.requestAuthCode(currentUser.userId, jwt, oauthClientId); } -<<<<<<< HEAD - - @Get('oauth/migration') - @Authenticate('jwt') - @ApiOkResponse({ description: 'The User has been succesfully migrated.' }) - @ApiResponse({ type: InternalServerErrorException, description: 'The migration of the User was not possible. ' }) - async migrateUser( - @JWT() jwt: string, - @Session() session: ISession, - @CurrentUser() currentUser: CurrentUserInterface, - @Query() query: AuthorizationParams, - @Res() res: Response - ): Promise { - const oauthLoginState: OauthLoginStateDto = this.sessionHandler(session, query); - - if (!currentUser.systemId) { - throw new UnprocessableEntityException('Current user does not have a system.'); - } - - try { - const migration: MigrationDto = await this.oauthUc.migrate(jwt, currentUser.userId, query, oauthLoginState); - const response: UserMigrationResponse = UserMigrationMapper.mapDtoToResponse(migration); - res.redirect(response.redirect); - } catch (error) { - this.migrationErrorHandler(error, session, res); - } - } -======= ->>>>>>> main } diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts index 2ba0709372a..96d65acddea 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts @@ -1,13 +1,13 @@ -import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { Inject } from '@nestjs/common'; -import { ContextExternalToolValidationService } from './context-external-tool-validation.service'; -import { SchoolExternalToolValidationService } from '../../school-external-tool/service'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; +import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; +import { ToolConfigurationStatus } from '../../common/enum'; +import { CommonToolService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { SchoolExternalTool } from '../../school-external-tool/domain'; +import { SchoolExternalToolValidationService } from '../../school-external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ContextExternalTool } from '../domain'; -import { ToolConfigurationStatus } from '../../common/enum'; -import { CommonToolService } from '../../common/service'; +import { ContextExternalToolValidationService } from './context-external-tool-validation.service'; @Injectable() export class ToolVersionService { @@ -15,7 +15,7 @@ export class ToolVersionService { private readonly contextExternalToolValidationService: ContextExternalToolValidationService, private readonly schoolExternalToolValidationService: SchoolExternalToolValidationService, private readonly commonToolService: CommonToolService, - @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures + @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface ) {} async determineToolConfigurationStatus( diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts index 3474aa90f5e..4c511d264fb 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts @@ -3,15 +3,15 @@ import { ValidationError } from '@shared/common'; import { CommonToolValidationService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; @Injectable() export class SchoolExternalToolValidationService { constructor( private readonly externalToolService: ExternalToolService, private readonly commonToolValidationService: CommonToolValidationService, - @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures + @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface ) {} async validate(schoolExternalTool: SchoolExternalTool): Promise { diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts index e654f82f96a..e62d5cad0c6 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts @@ -4,10 +4,10 @@ import { SchoolExternalToolRepo } from '@shared/repo'; import { ToolConfigurationStatus } from '../../common/enum'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; import { SchoolExternalToolQuery } from '../uc/dto/school-external-tool.types'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; @Injectable() export class SchoolExternalToolService { @@ -15,7 +15,7 @@ export class SchoolExternalToolService { private readonly schoolExternalToolRepo: SchoolExternalToolRepo, private readonly externalToolService: ExternalToolService, private readonly schoolExternalToolValidationService: SchoolExternalToolValidationService, - @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures + @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface ) {} async findById(schoolExternalToolId: EntityId): Promise { From 3e482c45bf1a6f1dc1bc3c8484eb92a8a5e5d10d Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 14:16:19 +0100 Subject: [PATCH 092/110] adjusted tests --- .../controller/api-test/oauth-sso.api.spec.ts | 582 ------------------ .../school-external-tool.service.spec.ts | 8 +- .../service/school-migration.service.spec.ts | 13 +- 3 files changed, 5 insertions(+), 598 deletions(-) delete mode 100644 apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts 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 deleted file mode 100644 index 9dc197122b7..00000000000 --- a/apps/server/src/modules/oauth/controller/api-test/oauth-sso.api.spec.ts +++ /dev/null @@ -1,582 +0,0 @@ -import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { KeycloakAdministrationService } from '@infra/identity-management/keycloak-administration/service/keycloak-administration.service'; -import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; -import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; -import { SanisResponse, SanisRole } from '@modules/provisioning/strategy/sanis/response'; -import { ServerTestModule } from '@modules/server'; -import { ExecutionContext, INestApplication } from '@nestjs/common'; -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 { - accountFactory, - cleanupCollections, - mapUserToCurrentUser, - schoolFactory, - systemFactory, - userFactory, -} from '@shared/testing'; -import { JwtTestFactory } from '@shared/testing/factory/jwt.test.factory'; -import { userLoginMigrationFactory } from '@shared/testing/factory/user-login-migration.factory'; -import axios from 'axios'; -import MockAdapter from 'axios-mock-adapter'; -import { UUID } from 'bson'; -import { Request } from 'express'; -import request, { Response } from 'supertest'; -import { SSOAuthenticationError } from '../../interface/sso-authentication-error.enum'; -import { OauthTokenResponse } from '../../service/dto'; -import { AuthorizationParams, SSOLoginQuery } from '../dto'; - -jest.mock('jwks-rsa', () => () => { - return { - getKeys: jest.fn(), - getSigningKey: jest.fn().mockResolvedValue({ - kid: 'kid', - alg: 'RS256', - getPublicKey: jest.fn().mockReturnValue(JwtTestFactory.getPublicKey()), - rsaPublicKey: JwtTestFactory.getPublicKey(), - }), - getSigningKeys: jest.fn(), - }; -}); - -describe('OAuth SSO Controller (API)', () => { - let app: INestApplication; - let em: EntityManager; - let currentUser: CurrentUserInterface; - let axiosMock: MockAdapter; - - const sessionCookieName: string = Configuration.get('SESSION__NAME') as string; - beforeAll(async () => { - Configuration.set('PUBLIC_BACKEND_URL', 'http://localhost:3030/api'); - const schulcloudJwt: string = JwtTestFactory.createJwt(); - - const moduleRef: TestingModule = await Test.createTestingModule({ - imports: [ServerTestModule], - }) - .overrideGuard(JwtAuthGuard) - .useValue({ - canActivate(context: ExecutionContext) { - const req: Request = context.switchToHttp().getRequest(); - req.user = currentUser; - req.headers.authorization = schulcloudJwt; - return true; - }, - }) - .compile(); - - axiosMock = new MockAdapter(axios); - app = moduleRef.createNestApplication(); - await app.init(); - em = app.get(EntityManager); - const kcAdminService = app.get(KeycloakAdministrationService); - - axiosMock.onGet(kcAdminService.getWellKnownUrl()).reply(200, { - issuer: 'issuer', - token_endpoint: 'token_endpoint', - authorization_endpoint: 'authorization_endpoint', - end_session_endpoint: 'end_session_endpoint', - jwks_uri: 'jwks_uri', - }); - }); - - afterAll(async () => { - await app.close(); - }); - - afterEach(async () => { - await cleanupCollections(em); - }); - - const setupSessionState = async (systemId: EntityId, migration: boolean) => { - const query: SSOLoginQuery = { - migration, - }; - - const response: Response = await request(app.getHttpServer()) - .get(`/sso/login/${systemId}`) - .query(query) - .expect(302) - .expect('set-cookie', new RegExp(`^${sessionCookieName}`)); - - const cookies: string[] = response.get('Set-Cookie'); - const redirect: string = response.get('Location'); - const matchState: RegExpMatchArray | null = redirect.match(/(?<=state=)([^&]+)/); - const state = matchState ? matchState[0] : ''; - - return { - cookies, - state, - }; - }; - - const setup = async () => { - const externalUserId = 'externalUserId'; - const system: SystemEntity = systemFactory.withOauthConfig().buildWithId(); - const school: SchoolEntity = schoolFactory.buildWithId({ systems: [system] }); - const user: User = userFactory.buildWithId({ externalId: externalUserId, school }); - const account: Account = accountFactory.buildWithId({ systemId: system.id, userId: user.id }); - - await em.persistAndFlush([system, user, school, account]); - em.clear(); - - const query: AuthorizationParams = new AuthorizationParams(); - query.code = 'code'; - query.state = 'state'; - - return { - system, - user, - externalUserId, - school, - query, - }; - }; - - describe('[GET] sso/login/:systemId', () => { - describe('when no error occurs', () => { - it('should redirect to the authentication url and set a session cookie', async () => { - const { system } = await setup(); - - await request(app.getHttpServer()) - .get(`/sso/login/${system.id}`) - .expect(302) - .expect('set-cookie', new RegExp(`^${sessionCookieName}`)) - .expect( - 'Location', - /^http:\/\/mock.de\/auth\?client_id=12345&redirect_uri=http%3A%2F%2Flocalhost%3A3030%2Fapi%2Fv3%2Fsso%2Foauth&response_type=code&scope=openid\+uuid&state=\w*/ - ); - }); - }); - - describe('when an error occurs', () => { - it('should redirect to the login page', async () => { - const unknownSystemId: string = new ObjectId().toHexString(); - const clientUrl: string = Configuration.get('HOST') as string; - - await request(app.getHttpServer()) - .get(`/sso/login/${unknownSystemId}`) - .expect(302) - .expect('Location', `${clientUrl}/login?error=sso_login_failed`); - }); - }); - }); - - describe('[GET] sso/oauth', () => { - describe('when the session has no oauthLoginState', () => { - it('should return 401 Unauthorized', async () => { - await setup(); - const query: AuthorizationParams = new AuthorizationParams(); - query.code = 'code'; - query.state = 'state'; - - await request(app.getHttpServer()).get(`/sso/oauth`).query(query).expect(401); - }); - }); - - describe('when the session and the request have a different state', () => { - it('should return 401 Unauthorized', async () => { - const { system } = await setup(); - const { cookies } = await setupSessionState(system.id, false); - const query: AuthorizationParams = new AuthorizationParams(); - query.code = 'code'; - query.state = 'wrongState'; - - await request(app.getHttpServer()).get(`/sso/oauth`).set('Cookie', cookies).query(query).expect(401); - }); - }); - - describe('when code and state are valid', () => { - it('should set a jwt and redirect', async () => { - const { system, externalUserId, query } = await setup(); - const { state, cookies } = await setupSessionState(system.id, false); - const baseUrl: string = Configuration.get('HOST') as string; - query.code = 'code'; - query.state = state; - - const idToken: string = JwtTestFactory.createJwt({ - sub: 'testUser', - iss: system.oauthConfig?.issuer, - aud: system.oauthConfig?.clientId, - // For OIDC provisioning strategy - external_sub: externalUserId, - }); - - axiosMock.onPost(system.oauthConfig?.tokenEndpoint).reply(200, { - id_token: idToken, - refresh_token: 'refreshToken', - access_token: 'accessToken', - }); - - await request(app.getHttpServer()) - .get(`/sso/oauth`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect('Location', `${baseUrl}/dashboard`) - .expect( - (res: Response) => res.get('Set-Cookie').filter((value: string) => value.startsWith('jwt')).length === 1 - ); - }); - }); - - describe('when an error occurs during the login process', () => { - it('should redirect to the login page', async () => { - const { system, query } = await setup(); - const { state, cookies } = await setupSessionState(system.id, false); - const clientUrl: string = Configuration.get('HOST') as string; - query.error = SSOAuthenticationError.ACCESS_DENIED; - query.state = state; - - await request(app.getHttpServer()) - .get(`/sso/oauth`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect( - 'Location', - `${clientUrl}/login?error=access_denied&provider=${system.oauthConfig?.provider as string}` - ); - }); - }); - - describe('when a faulty query is passed', () => { - it('should redirect to the login page with an error', async () => { - const { system, query } = await setup(); - const { state, cookies } = await setupSessionState(system.id, false); - const clientUrl: string = Configuration.get('HOST') as string; - query.state = state; - query.code = undefined; - - await request(app.getHttpServer()) - .get(`/sso/oauth`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect( - 'Location', - `${clientUrl}/login?error=sso_auth_code_step&provider=${system.oauthConfig?.provider as string}` - ); - }); - }); - }); - - describe('[GET] sso/oauth/migration', () => { - const mockPostOauthTokenEndpoint = ( - idToken: string, - targetSystem: SystemEntity, - targetUserId: string, - schoolExternalId: string, - officialSchoolNumber: string - ) => { - axiosMock - .onPost(targetSystem.oauthConfig?.tokenEndpoint) - .replyOnce(200, { - id_token: idToken, - refresh_token: 'refreshToken', - access_token: 'accessToken', - }) - .onGet(targetSystem.provisioningUrl) - .replyOnce(200, { - pid: targetUserId, - person: { - name: { - familienname: 'familienName', - vorname: 'vorname', - }, - geschlecht: 'weiblich', - lokalisierung: 'not necessary', - vertrauensstufe: 'not necessary', - }, - personenkontexte: [ - { - id: new UUID('aef1f4fd-c323-466e-962b-a84354c0e713').toString(), - rolle: SanisRole.LEHR, - organisation: { - id: new UUID('aef1f4fd-c323-466e-962b-a84354c0e713').toString(), - kennung: officialSchoolNumber, - name: 'schulName', - typ: 'not necessary', - }, - personenstatus: 'not necessary', - }, - ], - }); - }; - - describe('when the session has no oauthLoginState', () => { - it('should return 401 Unauthorized', async () => { - const { query } = await setup(); - - await request(app.getHttpServer()).get(`/sso/oauth/migration`).query(query).expect(401); - }); - }); - - describe('when the migration is successful', () => { - const setupMigration = async () => { - const { externalUserId, query } = await setup(); - - const targetSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.SANIS }, new ObjectId().toHexString(), {}); - const sourceSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - - const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ - systems: [sourceSystem], - officialSchoolNumber: '11111', - externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', - }); - const userLoginMigration: UserLoginMigrationEntity = userLoginMigrationFactory.buildWithId({ - school: sourceSchool, - targetSystem, - sourceSystem, - startedAt: new Date('2022-12-17T03:24:00'), - }); - - const targetSchoolExternalId = 'aef1f4fd-c323-466e-962b-a84354c0e714'; - - const sourceUser: User = userFactory.buildWithId({ externalId: externalUserId, school: sourceSchool }); - - const sourceUserAccount: Account = accountFactory.buildWithId({ - userId: sourceUser.id, - systemId: sourceSystem.id, - username: sourceUser.email, - }); - - await em.persistAndFlush([sourceSystem, targetSystem, sourceUser, sourceUserAccount, userLoginMigration]); - - const { state, cookies } = await setupSessionState(targetSystem.id, true); - query.code = 'code'; - query.state = state; - - return { - targetSystem, - targetSchoolExternalId, - sourceSystem, - sourceUser, - externalUserId, - query, - cookies, - }; - }; - - it('should redirect to the success page', async () => { - const { query, sourceUser, targetSystem, externalUserId, cookies, sourceSystem, targetSchoolExternalId } = - await setupMigration(); - currentUser = mapUserToCurrentUser(sourceUser, undefined, sourceSystem.id); - const baseUrl: string = Configuration.get('HOST') as string; - - const idToken: string = JwtTestFactory.createJwt({ - sub: 'testUser', - iss: targetSystem.oauthConfig?.issuer, - aud: targetSystem.oauthConfig?.clientId, - external_sub: externalUserId, - }); - - mockPostOauthTokenEndpoint(idToken, targetSystem, currentUser.userId, targetSchoolExternalId, 'NI_11111'); - - await request(app.getHttpServer()) - .get(`/sso/oauth/migration`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect( - 'Location', - `${baseUrl}/migration/success?sourceSystem=${ - currentUser.systemId ? currentUser.systemId : '' - }&targetSystem=${targetSystem.id}` - ); - }); - }); - - describe('when currentUser has no systemId', () => { - const setupMigration = async () => { - const { externalUserId, query } = await setup(); - - const targetSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.SANIS }, new ObjectId().toHexString(), {}); - const sourceSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - - const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ - systems: [sourceSystem], - officialSchoolNumber: '11110', - externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', - }); - - const userLoginMigration: UserLoginMigrationEntity = userLoginMigrationFactory.buildWithId({ - school: sourceSchool, - targetSystem, - sourceSystem, - startedAt: new Date('2022-12-17T03:24:00'), - }); - - const sourceUser: User = userFactory.buildWithId({ externalId: externalUserId, school: sourceSchool }); - - await em.persistAndFlush([targetSystem, sourceUser, userLoginMigration]); - - const { state, cookies } = await setupSessionState(targetSystem.id, true); - query.code = 'code'; - query.state = state; - - return { - sourceUser, - query, - cookies, - }; - }; - - it('should throw UnprocessableEntityException', async () => { - const { sourceUser, query, cookies } = await setupMigration(); - currentUser = mapUserToCurrentUser(sourceUser, undefined, undefined); - query.error = SSOAuthenticationError.INVALID_REQUEST; - - await request(app.getHttpServer()).get(`/sso/oauth/migration`).set('Cookie', cookies).query(query).expect(422); - }); - }); - - describe('when invalid request', () => { - const setupMigration = async () => { - const { externalUserId, query } = await setup(); - - const targetSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.SANIS }, new ObjectId().toHexString(), {}); - const sourceSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - - const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ - systems: [sourceSystem], - officialSchoolNumber: '11111', - externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', - }); - - const userLoginMigration: UserLoginMigrationEntity = userLoginMigrationFactory.buildWithId({ - school: sourceSchool, - targetSystem, - sourceSystem, - startedAt: new Date('2022-12-17T03:24:00'), - }); - - const sourceUser: User = userFactory.buildWithId({ externalId: externalUserId, school: sourceSchool }); - - await em.persistAndFlush([sourceSystem, targetSystem, sourceSchool, sourceUser, userLoginMigration]); - - const { state, cookies } = await setupSessionState(targetSystem.id, true); - query.code = 'code'; - query.state = state; - - return { - targetSystem, - sourceSystem, - sourceUser, - query, - cookies, - }; - }; - - it('should redirect to the general migration error page', async () => { - const { sourceUser, sourceSystem, query, cookies } = await setupMigration(); - currentUser = mapUserToCurrentUser(sourceUser, undefined, sourceSystem.id); - const baseUrl: string = Configuration.get('HOST') as string; - query.error = SSOAuthenticationError.INVALID_REQUEST; - - await request(app.getHttpServer()) - .get(`/sso/oauth/migration`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect('Location', `${baseUrl}/migration/error`); - }); - }); - - describe('when schoolnumbers mismatch', () => { - const setupMigration = async () => { - const { externalUserId, query } = await setup(); - - const targetSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.SANIS }, new ObjectId().toHexString(), {}); - const sourceSystem: SystemEntity = systemFactory - .withOauthConfig() - .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - - const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ - systems: [sourceSystem], - officialSchoolNumber: '11111', - externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', - }); - - const userLoginMigration: UserLoginMigrationEntity = userLoginMigrationFactory.buildWithId({ - school: sourceSchool, - targetSystem, - sourceSystem, - startedAt: new Date('2022-12-17T03:24:00'), - }); - - const targetSchool: SchoolEntity = schoolFactory.buildWithId({ - systems: [targetSystem], - officialSchoolNumber: '22222', - externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', - }); - - const sourceUser: User = userFactory.buildWithId({ externalId: externalUserId, school: sourceSchool }); - - const targetUser: User = userFactory.buildWithId({ - externalId: 'differentExternalUserId', - school: targetSchool, - }); - - await em.persistAndFlush([sourceSystem, targetSystem, sourceUser, targetUser, userLoginMigration]); - - const { state, cookies } = await setupSessionState(targetSystem.id, true); - query.code = 'code'; - query.state = state; - - return { - targetSystem, - sourceSystem, - sourceUser, - targetUser, - targetSchoolExternalId: targetSchool.externalId as string, - query, - cookies, - }; - }; - - it('should redirect to the login page with an schoolnumber mismatch error', async () => { - const { targetSystem, sourceUser, targetUser, sourceSystem, targetSchoolExternalId, query, cookies } = - await setupMigration(); - currentUser = mapUserToCurrentUser(sourceUser, undefined, sourceSystem.id); - const baseUrl: string = Configuration.get('HOST') as string; - - const idToken: string = JwtTestFactory.createJwt({ - sub: 'differentExternalUserId', - iss: targetSystem.oauthConfig?.issuer, - aud: targetSystem.oauthConfig?.clientId, - external_sub: 'differentExternalUserId', - }); - - mockPostOauthTokenEndpoint(idToken, targetSystem, targetUser.id, targetSchoolExternalId, 'NI_22222'); - - await request(app.getHttpServer()) - .get(`/sso/oauth/migration`) - .set('Cookie', cookies) - .query(query) - .expect(302) - .expect('Location', `${baseUrl}/migration/error?sourceSchoolNumber=11111&targetSchoolNumber=22222`); - }); - }); - - afterAll(() => { - axiosMock.restore(); - }); - }); -}); diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts index b8c2789322d..9d25492ab52 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts @@ -1,16 +1,16 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; +import { ApiValidationError } from '@shared/common'; import { SchoolExternalToolRepo } from '@shared/repo'; import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; import { schoolExternalToolFactory } from '@shared/testing/factory/domainobject/tool/school-external-tool.factory'; -import { ApiValidationError } from '@shared/common'; import { ToolConfigurationStatus } from '../../common/enum'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; -import { SchoolExternalToolService } from './school-external-tool.service'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; +import { SchoolExternalToolService } from './school-external-tool.service'; describe('SchoolExternalToolService', () => { let module: TestingModule; @@ -19,7 +19,7 @@ describe('SchoolExternalToolService', () => { let schoolExternalToolRepo: DeepMocked; let externalToolService: DeepMocked; let schoolExternalToolValidationService: DeepMocked; - let toolFearures: DeepMocked; + let toolFearures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts index 4dca3839b45..c84339c9fbf 100644 --- a/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts +++ b/apps/server/src/modules/user-login-migration/service/school-migration.service.spec.ts @@ -9,7 +9,7 @@ import { legacySchoolDoFactory, setupEntities, userDoFactory, userLoginMigration import { LegacyLogger, Logger } from '@src/core/logger'; import { SchoolMigrationDatabaseOperationFailedLoggableException, - SchoolNumberMismatchLoggableException + SchoolNumberMismatchLoggableException, } from '../loggable'; import { SchoolMigrationService } from './school-migration.service'; @@ -75,19 +75,8 @@ describe(SchoolMigrationService.name, () => { externalId: 'firstExternalId', systems: undefined, }); -<<<<<<< HEAD - - const userDO: UserDO = userDoFactory.buildWithId({ schoolId: schoolDO.id }, new ObjectId().toHexString(), {}); - - const currentUser: CurrentUserInterface = { - userId: userDO.id, - schoolId: userDO.schoolId, - systemId: 'systemId', - } as CurrentUserInterface; -======= const targetSystemId = 'targetSystemId'; const targetExternalId = 'targetExternalId'; ->>>>>>> main return { school, From a5b511b7d3ce5847b642f4bfe36c67096b579853 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Wed, 15 Nov 2023 14:41:56 +0100 Subject: [PATCH 093/110] Adjusted more tests --- .../service/tool-version-service.spec.ts | 12 ++++++------ .../school-external-tool-validation.service.spec.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts index 33c77ecb7ea..1dcf15f91b5 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts @@ -1,13 +1,13 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; -import { contextExternalToolFactory, externalToolFactory, schoolExternalToolFactory } from '@shared/testing'; import { ApiValidationError } from '@shared/common'; +import { contextExternalToolFactory, externalToolFactory, schoolExternalToolFactory } from '@shared/testing'; +import { ToolConfigurationStatus } from '../../common/enum'; +import { CommonToolService } from '../../common/service'; import { SchoolExternalToolValidationService } from '../../school-external-tool/service'; -import { ToolVersionService } from './tool-version-service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ContextExternalToolValidationService } from './context-external-tool-validation.service'; -import { CommonToolService } from '../../common/service'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; -import { ToolConfigurationStatus } from '../../common/enum'; +import { ToolVersionService } from './tool-version-service'; describe('ToolVersionService', () => { let module: TestingModule; @@ -16,7 +16,7 @@ describe('ToolVersionService', () => { let contextExternalToolValidationService: DeepMocked; let schoolExternalToolValidationService: DeepMocked; let commonToolService: DeepMocked; - let toolFeatures: DeepMocked; + let toolFeatures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts index 6b4f69d6686..c8ed8100a4c 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts @@ -4,9 +4,9 @@ import { externalToolFactory, schoolExternalToolFactory } from '@shared/testing/ import { CommonToolValidationService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; describe('SchoolExternalToolValidationService', () => { let module: TestingModule; @@ -14,7 +14,7 @@ describe('SchoolExternalToolValidationService', () => { let externalToolService: DeepMocked; let commonToolValidationService: DeepMocked; - let toolFeatures: DeepMocked; + let toolFeatures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ From 4cb6514c68f83730384f22e8e7b09e9b72d88d48 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 08:55:26 +0100 Subject: [PATCH 094/110] specs adjusted --- .../service/external-tool-validation.service.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts index 42efcd6559a..8f730a97213 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { ValidationError } from '@shared/common'; import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; -import { IToolFeatures, ToolFeatures } from '../../tool-config'; +import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogoService } from './external-tool-logo.service'; import { ExternalToolParameterValidationService } from './external-tool-parameter-validation.service'; @@ -15,7 +15,7 @@ describe('ExternalToolValidationService', () => { let externalToolService: DeepMocked; let commonToolValidationService: DeepMocked; - let toolFeatures: IToolFeatures; + let toolFeatures: ToolFeaturesInterface; let logoService: DeepMocked; beforeAll(async () => { From e8460dfad20d4aa65b106e920d151e8a9ef0ca57 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:02:46 +0100 Subject: [PATCH 095/110] CurrentUserInterface -> ICurrentUser --- apps/server/doc/file-structure.md | 4 +- .../account/controller/account.controller.ts | 17 ++-- .../controller/api-test/account.api.spec.ts | 4 +- .../src/modules/account/uc/account.uc.spec.ts | 98 +++++++++---------- .../src/modules/account/uc/account.uc.ts | 15 ++- .../controllers/api-test/login.api.spec.ts | 4 +- .../controllers/login.controller.ts | 12 +-- .../decorator/auth.decorator.spec.ts | 6 +- .../decorator/auth.decorator.ts | 20 ++-- .../src/modules/authentication/index.ts | 2 +- .../interface/oauth-current-user.ts | 4 +- .../modules/authentication/interface/user.ts | 2 +- .../mapper/current-user.mapper.spec.ts | 35 +++---- .../mapper/current-user.mapper.ts | 13 +-- .../services/authentication.service.spec.ts | 4 +- .../authentication/strategy/jwt.strategy.ts | 6 +- .../strategy/ldap.strategy.spec.ts | 6 +- .../authentication/strategy/ldap.strategy.ts | 11 +-- .../authentication/strategy/local.strategy.ts | 6 +- .../strategy/oauth2.strategy.spec.ts | 6 +- .../strategy/oauth2.strategy.ts | 4 +- .../src/modules/authentication/uc/login.uc.ts | 4 +- .../api-test/board-delete.api.spec.ts | 4 +- .../api-test/board-lookup.api.spec.ts | 4 +- .../api-test/card-create.api.spec.ts | 4 +- .../api-test/card-delete.api.spec.ts | 4 +- .../api-test/card-lookup.api.spec.ts | 4 +- .../controller/api-test/card-move.api.spec.ts | 4 +- .../api-test/column-create.api.spec.ts | 4 +- .../api-test/column-delete.api.spec.ts | 4 +- .../api-test/column-move.api.spec.ts | 4 +- .../content-element-delete.api.spec.ts | 4 +- .../api-test/content-element-move.api.spec.ts | 4 +- .../controller/board-submission.controller.ts | 8 +- .../board/controller/board.controller.ts | 15 ++- .../board/controller/card.controller.ts | 14 +-- .../board/controller/column.controller.ts | 13 +-- .../board/controller/element.controller.ts | 10 +- .../collaborative-storage.controller.spec.ts | 4 +- .../collaborative-storage.controller.ts | 4 +- .../api-test/files-security.api.spec.ts | 4 +- .../files-storage-copy-files.api.spec.ts | 4 +- .../files-storage-delete-files.api.spec.ts | 4 +- .../files-storage-download-upload.api.spec.ts | 4 +- .../files-storage-list-files.api.spec.ts | 4 +- .../files-storage-preview.api.spec.ts | 4 +- .../files-storage-rename-file.api.spec.ts | 4 +- .../files-storage-restore-files.api.spec.ts | 4 +- .../controller/files-storage.controller.ts | 26 ++--- .../group/controller/group.controller.ts | 6 +- .../api-test/h5p-editor-delete.api.spec.ts | 4 +- .../h5p-editor-get-editor.api.spec.ts | 4 +- .../h5p-editor-get-player.api.spec.ts | 4 +- .../controller/h5p-editor.controller.ts | 24 ++--- .../h5p-editor/uc/h5p-delete.uc.spec.ts | 4 +- .../h5p-editor/uc/h5p-files.uc.spec.ts | 4 +- .../h5p-editor/uc/h5p-get-editor.uc.spec.ts | 4 +- .../h5p-editor/uc/h5p-get-player.uc.spec.ts | 4 +- .../h5p-editor/uc/h5p-save-create.uc.spec.ts | 4 +- .../src/modules/h5p-editor/uc/h5p.uc.ts | 34 +++---- .../controller/api-test/dashboard.api.spec.ts | 4 +- .../api-test/rooms-copy-timeout.api.spec.ts | 4 +- .../controller/api-test/rooms.api.spec.ts | 4 +- .../learnroom/controller/course.controller.ts | 6 +- .../controller/dashboard.controller.spec.ts | 18 ++-- .../controller/dashboard.controller.ts | 8 +- .../controller/rooms.controller.spec.ts | 12 +-- .../learnroom/controller/rooms.controller.ts | 12 +-- .../lesson/controller/lesson.controller.ts | 7 +- .../meta-tag-extractor.controller.ts | 4 +- .../news/controller/news.controller.ts | 18 ++-- .../news/controller/team-news.controller.ts | 4 +- .../oauth-provider.controller.spec.ts | 4 +- .../controller/oauth-provider.controller.ts | 23 ++--- .../uc/oauth-provider.client-crud.uc.spec.ts | 4 +- .../uc/oauth-provider.client-crud.uc.ts | 12 +-- .../uc/oauth-provider.consent-flow.uc.spec.ts | 6 +- .../uc/oauth-provider.consent-flow.uc.ts | 6 +- .../controller/oauth-sso.controller.spec.ts | 4 +- .../oauth/controller/oauth-sso.controller.ts | 4 +- .../controller/pseudonym.controller.ts | 4 +- .../api-test/sharing-create-token.api.spec.ts | 4 +- .../api-test/sharing-import-token.api.spec.ts | 4 +- .../controller/share-token.controller.spec.ts | 10 +- .../controller/share-token.controller.ts | 8 +- .../controller/api-test/system.api.spec.ts | 4 +- .../api-test/submission.api.spec.ts | 6 +- .../api-test/task-copy-timeout.api.spec.ts | 4 +- .../api-test/task-finished.api.spec.ts | 4 +- .../task/controller/submission.controller.ts | 9 +- .../task/controller/task.controller.spec.ts | 4 +- .../task/controller/task.controller.ts | 24 ++--- .../controller/tool-context.controller.ts | 12 +-- .../controller/tool-reference.controller.ts | 6 +- .../tool-configuration.controller.ts | 10 +- .../controller/tool.controller.ts | 12 +-- .../external-tool/uc/external-tool.uc.spec.ts | 10 +- .../controller/tool-school.controller.ts | 12 +-- .../controller/tool-launch.controller.ts | 4 +- .../api-test/import-user.api.spec.ts | 4 +- .../controller/import-user.controller.ts | 18 ++-- .../user-login-migration.controller.ts | 18 ++-- .../api-test/user-language.api.spec.ts | 6 +- .../controller/api-test/user-me.api.spec.ts | 4 +- .../user/controller/user.controller.ts | 6 +- ...o-conference-deprecated.controller.spec.ts | 4 +- .../video-conference-deprecated.controller.ts | 8 +- .../controller/video-conference.controller.ts | 13 +-- .../uc/video-conference-deprecated.uc.spec.ts | 4 +- .../uc/video-conference-deprecated.uc.ts | 20 ++-- .../request-logging.interceptor.ts | 4 +- .../testing/map-user-to-current-user.ts | 6 +- 112 files changed, 452 insertions(+), 527 deletions(-) diff --git a/apps/server/doc/file-structure.md b/apps/server/doc/file-structure.md index 9f63d339c30..8b0c2969a8c 100644 --- a/apps/server/doc/file-structure.md +++ b/apps/server/doc/file-structure.md @@ -158,7 +158,7 @@ The main responsibilities of a controller is to define the REST API interface as ```TypeScript @Post() - async create(@CurrentUser() currentUser: CurrentUserInterface, @Body() params: CreateNewsParams): Promise { + async create(@CurrentUser() currentUser: ICurrentUser, @Body() params: CreateNewsParams): Promise { const news = await this.newsUc.create( currentUser.userId, currentUser.schoolId, @@ -171,7 +171,7 @@ The main responsibilities of a controller is to define the REST API interface as #### JWT-Authentication -For **authentication**, use [guards](https://docs.nestjs.com/guards) like JwtAuthGuard. It can be applied to a whole controller or a single controller method only. Then, [CurrentUserInterface](/apps/server/src/modules/authentication/interface/jwt-payload.ts) can be injected using the `@CurrentUser()` decorator. +For **authentication**, use [guards](https://docs.nestjs.com/guards) like JwtAuthGuard. It can be applied to a whole controller or a single controller method only. Then, [ICurrentUser](/apps/server/src/modules/authentication/interface/jwt-payload.ts) can be injected using the `@CurrentUser()` decorator. #### Validation diff --git a/apps/server/src/modules/account/controller/account.controller.ts b/apps/server/src/modules/account/controller/account.controller.ts index c9d141cc4c3..3265693915c 100644 --- a/apps/server/src/modules/account/controller/account.controller.ts +++ b/apps/server/src/modules/account/controller/account.controller.ts @@ -1,7 +1,7 @@ import { Body, Controller, Delete, Get, Param, Patch, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; import { AccountUc } from '../uc/account.uc'; import { @@ -29,7 +29,7 @@ export class AccountController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero or administrator.' }) async searchAccounts( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() query: AccountSearchQueryParams ): Promise { return this.accountUc.searchAccounts(currentUser, query); @@ -42,7 +42,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async findAccountById( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: AccountByIdParams ): Promise { return this.accountUc.findAccountById(currentUser, params); @@ -57,10 +57,7 @@ export class AccountController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid password.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) - async updateMyAccount( - @CurrentUser() currentUser: CurrentUserInterface, - @Body() params: PatchMyAccountParams - ): Promise { + async updateMyAccount(@CurrentUser() currentUser: ICurrentUser, @Body() params: PatchMyAccountParams): Promise { return this.accountUc.updateMyAccount(currentUser.userId, params); } @@ -71,7 +68,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async updateAccountById( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: AccountByIdParams, @Body() body: AccountByIdBodyParams ): Promise { @@ -85,7 +82,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'User is not a superhero.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account not found.' }) async deleteAccountById( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: AccountByIdParams ): Promise { return this.accountUc.deleteAccountById(currentUser, params); @@ -98,7 +95,7 @@ export class AccountController { @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid password.' }) @ApiResponse({ status: 404, type: EntityNotFoundError, description: 'Account or user not found.' }) async replaceMyPassword( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() params: PatchMyPasswordParams ): Promise { return this.accountUc.replaceMyTemporaryPassword(currentUser.userId, params.password, params.confirmPassword); diff --git a/apps/server/src/modules/account/controller/api-test/account.api.spec.ts b/apps/server/src/modules/account/controller/api-test/account.api.spec.ts index 412ef54a2f4..7a920a40a97 100644 --- a/apps/server/src/modules/account/controller/api-test/account.api.spec.ts +++ b/apps/server/src/modules/account/controller/api-test/account.api.spec.ts @@ -10,7 +10,7 @@ import { PatchMyAccountParams, PatchMyPasswordParams, } from '@src/modules/account/controller/dto'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@src/modules/server/server.module'; import { Request } from 'express'; @@ -32,7 +32,7 @@ describe('Account Controller (API)', () => { let studentUser: User; let superheroUser: User; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; const defaultPassword = 'DummyPasswd!1'; const defaultPasswordHash = '$2a$10$/DsztV5o6P5piW2eWJsxw.4nHovmJGBA.QNwiTmuZ/uvUc40b.Uhu'; diff --git a/apps/server/src/modules/account/uc/account.uc.spec.ts b/apps/server/src/modules/account/uc/account.uc.spec.ts index f9a16fea991..6810c2baa5c 100644 --- a/apps/server/src/modules/account/uc/account.uc.spec.ts +++ b/apps/server/src/modules/account/uc/account.uc.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { AccountService } from '@modules/account/services/account.service'; import { AccountSaveDto } from '@modules/account/services/dto'; import { AccountDto } from '@modules/account/services/dto/account.dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { AuthorizationError, EntityNotFoundError, ForbiddenOperationError, ValidationError } from '@shared/common'; @@ -795,7 +795,7 @@ describe('AccountUc', () => { describe('searchAccounts', () => { it('should return one account, if search type is userId', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams ); const expected = new AccountSearchListResponse( @@ -808,7 +808,7 @@ describe('AccountUc', () => { }); it('should return empty list, if account is not found', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { type: AccountSearchType.USER_ID, value: mockUserWithoutAccount.id } as AccountSearchQueryParams ); const expected = new AccountSearchListResponse([], 0, 0, 0); @@ -816,7 +816,7 @@ describe('AccountUc', () => { }); it('should return one or more accounts, if search type is username', async () => { const accounts = await accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { type: AccountSearchType.USERNAME, value: '' } as AccountSearchQueryParams ); expect(accounts.skip).toEqual(0); @@ -827,21 +827,21 @@ describe('AccountUc', () => { it('should throw, if user has not the right permissions', async () => { await expect( accountUc.searchAccounts( - { userId: mockTeacherUser.id } as CurrentUserInterface, + { userId: mockTeacherUser.id } as ICurrentUser, { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); await expect( accountUc.searchAccounts( - { userId: mockStudentUser.id } as CurrentUserInterface, + { userId: mockStudentUser.id } as ICurrentUser, { type: AccountSearchType.USER_ID, value: mockOtherStudentUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); await expect( accountUc.searchAccounts( - { userId: mockStudentUser.id } as CurrentUserInterface, + { userId: mockStudentUser.id } as ICurrentUser, { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -849,7 +849,7 @@ describe('AccountUc', () => { it('should throw, if search type is unknown', async () => { await expect( accountUc.searchAccounts( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { type: '' as AccountSearchType } as AccountSearchQueryParams ) ).rejects.toThrow('Invalid search type.'); @@ -857,7 +857,7 @@ describe('AccountUc', () => { it('should throw, if user is no superhero', async () => { await expect( accountUc.searchAccounts( - { userId: mockTeacherUser.id } as CurrentUserInterface, + { userId: mockTeacherUser.id } as ICurrentUser, { type: AccountSearchType.USERNAME, value: mockStudentUser.id } as AccountSearchQueryParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -868,22 +868,22 @@ describe('AccountUc', () => { configService.get.mockReturnValue(false); }); it('admin can access teacher of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('admin can access student of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('admin can not access admin of the same school via user id', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('admin can not access any account of a foreign school via user id', async () => { - const currentUser = { userId: mockDifferentSchoolAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockDifferentSchoolAdminUser.id } as ICurrentUser; let params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -892,22 +892,22 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('teacher can access teacher of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockOtherTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('teacher can access student of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); }); it('teacher can not access admin of the same school via user id', async () => { - const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('teacher can not access any account of a foreign school via user id', async () => { - const currentUser = { userId: mockDifferentSchoolTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockDifferentSchoolTeacherUser.id } as ICurrentUser; let params = { type: AccountSearchType.USER_ID, value: mockTeacherUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -917,7 +917,7 @@ describe('AccountUc', () => { }); it('teacher can access student of the same school via user id if school has global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockTeacherNoUserPermissionUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherNoUserPermissionUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockStudentSchoolPermissionUser.id, @@ -926,14 +926,14 @@ describe('AccountUc', () => { }); it('teacher can not access student of the same school if school has no global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockTeacherNoUserNoSchoolPermissionUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherNoUserNoSchoolPermissionUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockStudentUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(ForbiddenOperationError); }); it('student can not access student of the same school if school has global permission', async () => { configService.get.mockReturnValue(true); - const currentUser = { userId: mockStudentSchoolPermissionUser.id } as CurrentUserInterface; + const currentUser = { userId: mockStudentSchoolPermissionUser.id } as ICurrentUser; const params = { type: AccountSearchType.USER_ID, value: mockOtherStudentSchoolPermissionUser.id, @@ -941,7 +941,7 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(ForbiddenOperationError); }); it('student can not access any other account via user id', async () => { - const currentUser = { userId: mockStudentUser.id } as CurrentUserInterface; + const currentUser = { userId: mockStudentUser.id } as ICurrentUser; let params = { type: AccountSearchType.USER_ID, value: mockAdminUser.id } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); @@ -953,7 +953,7 @@ describe('AccountUc', () => { await expect(accountUc.searchAccounts(currentUser, params)).rejects.toThrow(); }); it('superhero can access any account via username', async () => { - const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; + const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; let params = { type: AccountSearchType.USERNAME, value: mockAdminAccount.username } as AccountSearchQueryParams; await expect(accountUc.searchAccounts(currentUser, params)).resolves.not.toThrow(); @@ -988,7 +988,7 @@ describe('AccountUc', () => { describe('findAccountById', () => { it('should return an account, if the current user is a superhero', async () => { const account = await accountUc.findAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { id: mockStudentAccount.id } as AccountByIdParams ); expect(account).toStrictEqual( @@ -1003,25 +1003,19 @@ describe('AccountUc', () => { it('should throw, if the current user is no superhero', async () => { await expect( accountUc.findAccountById( - { userId: mockTeacherUser.id } as CurrentUserInterface, + { userId: mockTeacherUser.id } as ICurrentUser, { id: mockStudentAccount.id } as AccountByIdParams ) ).rejects.toThrow(ForbiddenOperationError); }); it('should throw, if no account matches the search term', async () => { await expect( - accountUc.findAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, - { id: 'xxx' } as AccountByIdParams - ) + accountUc.findAccountById({ userId: mockSuperheroUser.id } as ICurrentUser, { id: 'xxx' } as AccountByIdParams) ).rejects.toThrow(EntityNotFoundError); }); it('should throw, if target account has no user', async () => { await expect( - accountUc.findAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, - { id: 'xxx' } as AccountByIdParams - ) + accountUc.findAccountById({ userId: mockSuperheroUser.id } as ICurrentUser, { id: 'xxx' } as AccountByIdParams) ).rejects.toThrow(EntityNotFoundError); }); }); @@ -1048,20 +1042,20 @@ describe('AccountUc', () => { describe('updateAccountById', () => { it('should throw if executing user does not exist', async () => { - const currentUser = { userId: '000000000000000' } as CurrentUserInterface; + const currentUser = { userId: '000000000000000' } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should throw if target account does not exist', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: '000000000000000' } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should update target account password', async () => { const previousPasswordHash = mockStudentAccount.password; - const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; + const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { password: defaultPassword } as AccountByIdBodyParams; expect(mockStudentUser.forcePasswordChange).toBeFalsy(); @@ -1071,7 +1065,7 @@ describe('AccountUc', () => { }); it('should update target account username', async () => { const newUsername = 'newUsername'; - const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; + const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: newUsername } as AccountByIdBodyParams; expect(mockStudentAccount.username).not.toBe(newUsername); @@ -1079,20 +1073,20 @@ describe('AccountUc', () => { expect(mockStudentAccount.username).toBe(newUsername.toLowerCase()); }); it('should update target account activation state', async () => { - const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; + const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { activated: false } as AccountByIdBodyParams; await accountUc.updateAccountById(currentUser, params, body); expect(mockStudentAccount.activated).toBeFalsy(); }); it('should throw if account can not be updated', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: 'fail@to.update' } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); }); it('should throw if user can not be updated', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: 'user-fail@to.update' } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(EntityNotFoundError); @@ -1100,7 +1094,7 @@ describe('AccountUc', () => { it('should throw if target account has no user', async () => { await expect( accountUc.updateAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { id: mockAccountWithoutUser.id } as AccountByIdParams, { username: 'user-fail@to.update' } as AccountByIdBodyParams ) @@ -1109,7 +1103,7 @@ describe('AccountUc', () => { it('should throw if new username already in use', async () => { const accountIsUniqueEmailSpy = jest.spyOn(accountValidationService, 'isUniqueEmail'); accountIsUniqueEmailSpy.mockResolvedValueOnce(false); - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = { username: mockOtherTeacherAccount.username } as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ValidationError); @@ -1117,49 +1111,49 @@ describe('AccountUc', () => { describe('hasPermissionsToUpdateAccount', () => { it('admin can edit teacher', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('teacher can edit student', async () => { - const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('admin can edit student', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockStudentAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('teacher cannot edit other teacher', async () => { - const currentUser = { userId: mockTeacherUser.id } as CurrentUserInterface; + const currentUser = { userId: mockTeacherUser.id } as ICurrentUser; const params = { id: mockOtherTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it("other school's admin cannot edit teacher", async () => { - const currentUser = { userId: mockDifferentSchoolAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockDifferentSchoolAdminUser.id } as ICurrentUser; const params = { id: mockTeacherAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it('superhero can edit admin', async () => { - const currentUser = { userId: mockSuperheroUser.id } as CurrentUserInterface; + const currentUser = { userId: mockSuperheroUser.id } as ICurrentUser; const params = { id: mockAdminAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).resolves.not.toThrow(); }); it('undefined user role fails by default', async () => { - const currentUser = { userId: mockUnknownRoleUser.id } as CurrentUserInterface; + const currentUser = { userId: mockUnknownRoleUser.id } as ICurrentUser; const params = { id: mockAccountWithoutRole.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); }); it('user without role cannot be edited', async () => { - const currentUser = { userId: mockAdminUser.id } as CurrentUserInterface; + const currentUser = { userId: mockAdminUser.id } as ICurrentUser; const params = { id: mockUnknownRoleUserAccount.id } as AccountByIdParams; const body = {} as AccountByIdBodyParams; await expect(accountUc.updateAccountById(currentUser, params, body)).rejects.toThrow(ForbiddenOperationError); @@ -1171,7 +1165,7 @@ describe('AccountUc', () => { it('should delete an account, if current user is authorized', async () => { await expect( accountUc.deleteAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { id: mockStudentAccount.id } as AccountByIdParams ) ).resolves.not.toThrow(); @@ -1179,7 +1173,7 @@ describe('AccountUc', () => { it('should throw, if the current user is no superhero', async () => { await expect( accountUc.deleteAccountById( - { userId: mockAdminUser.id } as CurrentUserInterface, + { userId: mockAdminUser.id } as ICurrentUser, { id: mockStudentAccount.id } as AccountByIdParams ) ).rejects.toThrow(ForbiddenOperationError); @@ -1187,7 +1181,7 @@ describe('AccountUc', () => { it('should throw, if no account matches the search term', async () => { await expect( accountUc.deleteAccountById( - { userId: mockSuperheroUser.id } as CurrentUserInterface, + { userId: mockSuperheroUser.id } as ICurrentUser, { id: 'xxx' } as AccountByIdParams ) ).rejects.toThrow(EntityNotFoundError); diff --git a/apps/server/src/modules/account/uc/account.uc.ts b/apps/server/src/modules/account/uc/account.uc.ts index e3f33d20c14..dac0b936ba5 100644 --- a/apps/server/src/modules/account/uc/account.uc.ts +++ b/apps/server/src/modules/account/uc/account.uc.ts @@ -11,7 +11,7 @@ import { import { Account, EntityId, Permission, PermissionService, Role, RoleName, SchoolEntity, User } from '@shared/domain'; import { UserRepo } from '@shared/repo'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { BruteForcePrevention } from '@src/imports-from-feathers'; import { ObjectId } from 'bson'; import { AccountConfig } from '../account-config'; @@ -50,10 +50,7 @@ export class AccountUc { * @throws {ValidationError} * @throws {ForbiddenOperationError} */ - async searchAccounts( - currentUser: CurrentUserInterface, - query: AccountSearchQueryParams - ): Promise { + async searchAccounts(currentUser: ICurrentUser, query: AccountSearchQueryParams): Promise { const skip = query.skip ?? 0; const limit = query.limit ?? 10; const executingUser = await this.userRepo.findById(currentUser.userId, true); @@ -91,7 +88,7 @@ export class AccountUc { * @throws {ForbiddenOperationError} * @throws {EntityNotFoundError} */ - async findAccountById(currentUser: CurrentUserInterface, params: AccountByIdParams): Promise { + async findAccountById(currentUser: ICurrentUser, params: AccountByIdParams): Promise { if (!(await this.isSuperhero(currentUser))) { throw new ForbiddenOperationError('Current user is not authorized to search for accounts.'); } @@ -113,7 +110,7 @@ export class AccountUc { * @throws {EntityNotFoundError} */ async updateAccountById( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, params: AccountByIdParams, body: AccountByIdBodyParams ): Promise { @@ -176,7 +173,7 @@ export class AccountUc { * @throws {ForbiddenOperationError} * @throws {EntityNotFoundError} */ - async deleteAccountById(currentUser: CurrentUserInterface, params: AccountByIdParams): Promise { + async deleteAccountById(currentUser: ICurrentUser, params: AccountByIdParams): Promise { if (!(await this.isSuperhero(currentUser))) { throw new ForbiddenOperationError('Current user is not authorized to delete an account.'); } @@ -333,7 +330,7 @@ export class AccountUc { return user.roles.getItems().some((role) => role.name === roleName); } - private async isSuperhero(currentUser: CurrentUserInterface): Promise { + private async isSuperhero(currentUser: ICurrentUser): Promise { const user = await this.userRepo.findById(currentUser.userId, true); return user.roles.getItems().some((role) => role.name === RoleName.SUPERHERO); } 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 4f62addfebe..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 @@ -11,7 +11,7 @@ import MockAdapter from 'axios-mock-adapter'; import crypto, { KeyPairKeyObjectResult } from 'crypto'; import jwt from 'jsonwebtoken'; import request, { Response } from 'supertest'; -import { CurrentUserInterface } from '../../interface'; +import { ICurrentUser } from '../../interface'; import { LdapAuthorizationBodyParams, LocalAuthorizationBodyParams, OauthLoginResponse } from '../dto'; const ldapAccountUserName = 'ldapAccountUserName'; @@ -282,7 +282,7 @@ describe('Login Controller (api)', () => { expect(response.body.accessToken).toBeDefined(); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument const decodedToken = jwt.decode(response.body.accessToken); - expect(decodedToken).toMatchObject({ + expect(decodedToken).toMatchObject({ userId: user.id, systemId: system.id, roles: [studentRole.id], diff --git a/apps/server/src/modules/authentication/controllers/login.controller.ts b/apps/server/src/modules/authentication/controllers/login.controller.ts index a747358b6ee..68af396233e 100644 --- a/apps/server/src/modules/authentication/controllers/login.controller.ts +++ b/apps/server/src/modules/authentication/controllers/login.controller.ts @@ -3,7 +3,7 @@ import { AuthGuard } from '@nestjs/passport'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ForbiddenOperationError, ValidationError } from '@shared/common'; import { CurrentUser } from '../decorator'; -import type { CurrentUserInterface, OauthCurrentUser } from '../interface'; +import type { ICurrentUser, OauthCurrentUser } from '../interface'; import { LoginDto } from '../uc/dto'; import { LoginUc } from '../uc/login.uc'; import { @@ -28,10 +28,7 @@ export class LoginController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid user credentials.' }) // eslint-disable-next-line @typescript-eslint/no-unused-vars - async loginLdap( - @CurrentUser() user: CurrentUserInterface, - @Body() _: LdapAuthorizationBodyParams - ): Promise { + async loginLdap(@CurrentUser() user: ICurrentUser, @Body() _: LdapAuthorizationBodyParams): Promise { const loginDto: LoginDto = await this.loginUc.getLoginData(user); const mapped: LoginResponse = LoginResponseMapper.mapToLoginResponse(loginDto); @@ -47,10 +44,7 @@ export class LoginController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiResponse({ status: 403, type: ForbiddenOperationError, description: 'Invalid user credentials.' }) // eslint-disable-next-line @typescript-eslint/no-unused-vars - async loginLocal( - @CurrentUser() user: CurrentUserInterface, - @Body() _: LocalAuthorizationBodyParams - ): Promise { + async loginLocal(@CurrentUser() user: ICurrentUser, @Body() _: LocalAuthorizationBodyParams): Promise { const loginDto: LoginDto = await this.loginUc.getLoginData(user); const mapped: LoginResponse = LoginResponseMapper.mapToLoginResponse(loginDto); diff --git a/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts b/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts index 4cfc981f89d..cc6006228b8 100644 --- a/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts +++ b/apps/server/src/modules/authentication/decorator/auth.decorator.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { ServerTestModule } from '@modules/server/server.module'; import { Controller, ExecutionContext, ForbiddenException, Get, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -11,7 +11,7 @@ import { Authenticate, CurrentUser, JWT } from './auth.decorator'; @Controller('test_decorator_currentUser') export class TestDecoratorCurrentUserController { @Get('test') - async test(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async test(@CurrentUser() currentUser: ICurrentUser): Promise { return Promise.resolve(); } } @@ -27,7 +27,7 @@ export class TestDecoratorJWTController { describe('auth.decorator', () => { let app: INestApplication; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let module: TestingModule; beforeAll(async () => { diff --git a/apps/server/src/modules/authentication/decorator/auth.decorator.ts b/apps/server/src/modules/authentication/decorator/auth.decorator.ts index 48b069e97d1..6d36784af0d 100644 --- a/apps/server/src/modules/authentication/decorator/auth.decorator.ts +++ b/apps/server/src/modules/authentication/decorator/auth.decorator.ts @@ -10,7 +10,7 @@ import { ApiBearerAuth } from '@nestjs/swagger'; import { Request } from 'express'; import { ExtractJwt } from 'passport-jwt'; import { JwtAuthGuard } from '../guard/jwt-auth.guard'; -import { CurrentUserInterface } from '../interface/user'; +import { ICurrentUser } from '../interface/user'; import { JwtExtractor } from '../strategy/jwt-extractor'; const STRATEGIES = ['jwt'] as const; @@ -40,16 +40,14 @@ export const Authenticate = (...strategies: Strategies) => { * @requires Authenticated */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const CurrentUser = createParamDecorator( - (data: unknown, ctx: ExecutionContext) => { - const { user }: Request = ctx.switchToHttp().getRequest(); - if (!user) - throw new UnauthorizedException( - 'CurrentUser missing in request context. This route requires jwt authentication guard enabled.' - ); - return user as CurrentUserInterface; - } -); +export const CurrentUser = createParamDecorator((data: unknown, ctx: ExecutionContext) => { + const { user }: Request = ctx.switchToHttp().getRequest(); + if (!user) + throw new UnauthorizedException( + 'CurrentUser missing in request context. This route requires jwt authentication guard enabled.' + ); + return user as ICurrentUser; +}); /** * Returns the current JWT. diff --git a/apps/server/src/modules/authentication/index.ts b/apps/server/src/modules/authentication/index.ts index 1a2212989b0..80e9d64ab69 100644 --- a/apps/server/src/modules/authentication/index.ts +++ b/apps/server/src/modules/authentication/index.ts @@ -1,4 +1,4 @@ export { AuthenticationModule } from './authentication.module'; export { Authenticate, CurrentUser, JWT } from './decorator'; -export { CurrentUserInterface } from './interface'; +export { ICurrentUser } from './interface'; export { AuthenticationService } from './services'; diff --git a/apps/server/src/modules/authentication/interface/oauth-current-user.ts b/apps/server/src/modules/authentication/interface/oauth-current-user.ts index 22301f844ae..ddf15e1ca5d 100644 --- a/apps/server/src/modules/authentication/interface/oauth-current-user.ts +++ b/apps/server/src/modules/authentication/interface/oauth-current-user.ts @@ -1,6 +1,6 @@ -import { CurrentUserInterface } from './user'; +import { ICurrentUser } from './user'; -export interface OauthCurrentUser extends CurrentUserInterface { +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 5c57713742e..82b6d292d50 100644 --- a/apps/server/src/modules/authentication/interface/user.ts +++ b/apps/server/src/modules/authentication/interface/user.ts @@ -1,6 +1,6 @@ import { EntityId } from '@shared/domain'; -export interface CurrentUserInterface { +export interface ICurrentUser { /** authenticated users id */ userId: EntityId; /** users role ids as EntityId[] */ 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 1339d54cb4c..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 @@ -2,7 +2,7 @@ import { ValidationError } from '@shared/common'; import { Permission, RoleName } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { roleFactory, schoolFactory, setupEntities, userDoFactory, userFactory } from '@shared/testing'; -import { CurrentUserInterface, OauthCurrentUser } from '../interface'; +import { ICurrentUser, OauthCurrentUser } from '../interface'; import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from './current-user.mapper'; @@ -13,7 +13,7 @@ describe('CurrentUserMapper', () => { await setupEntities(); }); - describe('userToCurrentUserInterface', () => { + describe('userToICurrentUser', () => { describe('when mapping from a user entity to the current user object', () => { describe('when user has roles', () => { const setup = () => { @@ -34,11 +34,7 @@ describe('CurrentUserMapper', () => { it('should map with roles', () => { const { teacherRole, user } = setup(); - const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( - accountId, - user, - false - ); + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false); expect(currentUser).toMatchObject({ accountId, @@ -54,7 +50,7 @@ describe('CurrentUserMapper', () => { it('should map without roles', () => { const user = userFactory.buildWithId(); - const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface(accountId, user, true); + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, true); expect(currentUser).toMatchObject({ accountId, @@ -82,12 +78,7 @@ describe('CurrentUserMapper', () => { it('should map system and school', () => { const { user, systemId } = setup(); - const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( - accountId, - user, - false, - systemId - ); + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(accountId, user, false, systemId); expect(currentUser).toMatchObject({ accountId, @@ -169,7 +160,7 @@ describe('CurrentUserMapper', () => { }; }; - it('should return valid CurrentUserInterface instance with systemId', () => { + it('should return valid ICurrentUser instance with systemId', () => { const { user, userId, systemId, idToken } = setup(); const currentUser: OauthCurrentUser = CurrentUserMapper.mapToOauthCurrentUser( @@ -211,7 +202,7 @@ describe('CurrentUserMapper', () => { }; }; - it('should return valid CurrentUserInterface instance without systemId', () => { + it('should return valid ICurrentUser instance without systemId', () => { const { user } = setup(); const currentUser = CurrentUserMapper.mapToOauthCurrentUser(accountId, user, undefined, 'idToken'); @@ -227,7 +218,7 @@ describe('CurrentUserMapper', () => { }); }); - describe('jwtToCurrentUserInterface', () => { + describe('jwtToICurrentUser', () => { describe('when JWT is provided with all claims', () => { const setup = () => { const jwtPayload: JwtPayload = { @@ -254,7 +245,7 @@ describe('CurrentUserMapper', () => { it('should return current user', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); + const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); expect(currentUser).toMatchObject({ accountId: jwtPayload.accountId, @@ -269,7 +260,7 @@ describe('CurrentUserMapper', () => { it('should return current user with default for isExternalUser', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); + const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); expect(currentUser).toMatchObject({ isExternalUser: jwtPayload.isExternalUser, @@ -301,7 +292,7 @@ describe('CurrentUserMapper', () => { it('should return current user', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); + const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); expect(currentUser).toMatchObject({ accountId: jwtPayload.accountId, @@ -315,7 +306,7 @@ describe('CurrentUserMapper', () => { it('should return current user with default for isExternalUser', () => { const { jwtPayload } = setup(); - const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(jwtPayload); + const currentUser = CurrentUserMapper.jwtToICurrentUser(jwtPayload); expect(currentUser).toMatchObject({ isExternalUser: false, @@ -326,7 +317,7 @@ describe('CurrentUserMapper', () => { describe('mapCurrentUserToCreateJwtPayload', () => { it('should map current user to create jwt payload', () => { - const currentUser: CurrentUserInterface = { + const currentUser: ICurrentUser = { accountId: 'dummyAccountId', systemId: 'dummySystemId', roles: ['mockRoleId'], 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 61cf3dcf7da..35dd6c5fe7c 100644 --- a/apps/server/src/modules/authentication/mapper/current-user.mapper.ts +++ b/apps/server/src/modules/authentication/mapper/current-user.mapper.ts @@ -2,16 +2,11 @@ import { ValidationError } from '@shared/common'; import { Role, User } from '@shared/domain'; import { RoleReference } from '@shared/domain/domainobject'; import { UserDO } from '@shared/domain/domainobject/user.do'; -import { CurrentUserInterface, OauthCurrentUser } from '../interface'; +import { ICurrentUser, OauthCurrentUser } from '../interface'; import { CreateJwtPayload, JwtPayload } from '../interface/jwt-payload'; export class CurrentUserMapper { - static userToCurrentUserInterface( - accountId: string, - user: User, - isExternalUser: boolean, - systemId?: string - ): CurrentUserInterface { + static userToICurrentUser(accountId: string, user: User, isExternalUser: boolean, systemId?: string): ICurrentUser { return { accountId, systemId, @@ -43,7 +38,7 @@ export class CurrentUserMapper { }; } - static mapCurrentUserToCreateJwtPayload(currentUser: CurrentUserInterface): CreateJwtPayload { + static mapCurrentUserToCreateJwtPayload(currentUser: ICurrentUser): CreateJwtPayload { return { accountId: currentUser.accountId, userId: currentUser.userId, @@ -55,7 +50,7 @@ export class CurrentUserMapper { }; } - static jwtToCurrentUserInterface(jwtPayload: JwtPayload): CurrentUserInterface { + static jwtToICurrentUser(jwtPayload: JwtPayload): ICurrentUser { return { accountId: jwtPayload.accountId, systemId: jwtPayload.systemId, diff --git a/apps/server/src/modules/authentication/services/authentication.service.spec.ts b/apps/server/src/modules/authentication/services/authentication.service.spec.ts index 6c010e4cead..de80540a65a 100644 --- a/apps/server/src/modules/authentication/services/authentication.service.spec.ts +++ b/apps/server/src/modules/authentication/services/authentication.service.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { AccountService } from '@modules/account/services/account.service'; import { AccountDto } from '@modules/account/services/dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { UnauthorizedException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { JwtService } from '@nestjs/jwt'; @@ -94,7 +94,7 @@ describe('AuthenticationService', () => { describe('generateJwt', () => { describe('when generating new jwt', () => { it('should pass the correct parameters', async () => { - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/authentication/strategy/jwt.strategy.ts b/apps/server/src/modules/authentication/strategy/jwt.strategy.ts index 76a9b46ce17..6133cf28a69 100644 --- a/apps/server/src/modules/authentication/strategy/jwt.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/jwt.strategy.ts @@ -2,7 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common'; import { PassportStrategy } from '@nestjs/passport'; import { ExtractJwt, Strategy } from 'passport-jwt'; import { jwtConstants } from '../constants'; -import { CurrentUserInterface } from '../interface'; +import { ICurrentUser } from '../interface'; import { JwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from '../mapper'; import { JwtExtractor } from './jwt-extractor'; @@ -22,14 +22,14 @@ export class JwtStrategy extends PassportStrategy(Strategy) { }); } - async validate(payload: JwtPayload): Promise { + async validate(payload: JwtPayload): Promise { const { accountId, jti } = payload; // check user exists try { // TODO: check user/account is active and has one role // check jwt is whitelisted and extend whitelist entry await this.jwtValidationAdapter.isWhitelisted(accountId, jti); - const currentUser = CurrentUserMapper.jwtToCurrentUserInterface(payload); + const currentUser = CurrentUserMapper.jwtToICurrentUser(payload); return currentUser; } catch (err) { throw new UnauthorizedException('Unauthorized.', { cause: err as Error }); 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 5a1b7c7c676..b3067de04eb 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.spec.ts @@ -17,7 +17,7 @@ import { } from '@shared/testing'; import { Logger } from '@src/core/logger'; import { LdapAuthorizationBodyParams } from '../controllers/dto'; -import { CurrentUserInterface } from '../interface'; +import { ICurrentUser } from '../interface'; import { AuthenticationService } from '../services/authentication.service'; import { LdapService } from '../services/ldap.service'; import { LdapStrategy } from './ldap.strategy'; @@ -428,7 +428,7 @@ describe('LdapStrategy', () => { it('should authentication with LDAP successfully and return the user', async () => { const { request, user, school, account, system } = setup(); - const result: CurrentUserInterface = await strategy.validate(request); + const result: ICurrentUser = await strategy.validate(request); expect(result).toEqual({ userId: user.id, @@ -492,7 +492,7 @@ describe('LdapStrategy', () => { it('should authentication with LDAP successfully and return the user', async () => { const { request, user, school, account, system } = setup(); - const result: CurrentUserInterface = await strategy.validate(request); + const result: ICurrentUser = await strategy.validate(request); expect(authenticationServiceMock.loadAccount).toHaveBeenCalledTimes(2); expect(result).toEqual({ diff --git a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts index 3f7e9bf3f9f..6f33e92f21a 100644 --- a/apps/server/src/modules/authentication/strategy/ldap.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/ldap.strategy.ts @@ -7,7 +7,7 @@ import { ErrorLoggable } from '@src/core/error/loggable/error.loggable'; import { Logger } from '@src/core/logger'; import { Strategy } from 'passport-custom'; import { LdapAuthorizationBodyParams } from '../controllers/dto'; -import { CurrentUserInterface } from '../interface'; +import { ICurrentUser } from '../interface'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; import { LdapService } from '../services/ldap.service'; @@ -25,7 +25,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { super(); } - async validate(request: { body: LdapAuthorizationBodyParams }): Promise { + async validate(request: { body: LdapAuthorizationBodyParams }): Promise { const { username, password, systemId, schoolId } = this.extractParamsFromRequest(request); const system: SystemEntity = await this.systemRepo.findById(systemId); @@ -48,12 +48,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') { await this.checkCredentials(account, system, ldapDn, password); - const currentUser: CurrentUserInterface = CurrentUserMapper.userToCurrentUserInterface( - account.id, - user, - true, - systemId - ); + const currentUser: ICurrentUser = CurrentUserMapper.userToICurrentUser(account.id, user, true, systemId); return currentUser; } diff --git a/apps/server/src/modules/authentication/strategy/local.strategy.ts b/apps/server/src/modules/authentication/strategy/local.strategy.ts index cfceb6f4ed3..c423fc396ff 100644 --- a/apps/server/src/modules/authentication/strategy/local.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/local.strategy.ts @@ -7,7 +7,7 @@ import { GuardAgainst } from '@shared/common/utils/guard-against'; import { UserRepo } from '@shared/repo'; import bcrypt from 'bcryptjs'; import { Strategy } from 'passport-local'; -import { CurrentUserInterface } from '../interface'; +import { ICurrentUser } from '../interface'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; @@ -22,7 +22,7 @@ export class LocalStrategy extends PassportStrategy(Strategy) { super(); } - async validate(username?: string, password?: string): Promise { + async validate(username?: string, password?: string): Promise { ({ username, password } = this.cleanupInput(username, password)); const account = await this.authenticationService.loadAccount(username); @@ -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.userToCurrentUserInterface(account.id, user, false); + const currentUser = CurrentUserMapper.userToICurrentUser(account.id, user, false); return currentUser; } diff --git a/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts b/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts index 48e3e3f4174..9f47f0e1d6a 100644 --- a/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts +++ b/apps/server/src/modules/authentication/strategy/oauth2.strategy.spec.ts @@ -8,7 +8,7 @@ import { EntityId, RoleName } from '@shared/domain'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { userDoFactory } from '@shared/testing'; -import { CurrentUserInterface, OauthCurrentUser } from '../interface'; +import { ICurrentUser, OauthCurrentUser } from '../interface'; import { SchoolInMigrationLoggableException } from '../loggable'; @@ -76,10 +76,10 @@ describe('Oauth2Strategy', () => { return { systemId, user, account, idToken }; }; - it('should return the CurrentUserInterface', async () => { + it('should return the ICurrentUser', async () => { const { systemId, user, account, idToken } = setup(); - const result: CurrentUserInterface = await strategy.validate({ + const result: ICurrentUser = await strategy.validate({ body: { code: 'code', redirectUri: 'redirectUri', systemId }, }); diff --git a/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts b/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts index a8dc3517dbc..320387a7d00 100644 --- a/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts +++ b/apps/server/src/modules/authentication/strategy/oauth2.strategy.ts @@ -6,7 +6,7 @@ import { PassportStrategy } from '@nestjs/passport'; import { UserDO } from '@shared/domain/domainobject/user.do'; import { Strategy } from 'passport-custom'; import { Oauth2AuthorizationBodyParams } from '../controllers/dto'; -import { CurrentUserInterface, OauthCurrentUser } from '../interface'; +import { ICurrentUser, OauthCurrentUser } from '../interface'; import { SchoolInMigrationLoggableException } from '../loggable'; import { CurrentUserMapper } from '../mapper'; @@ -16,7 +16,7 @@ export class Oauth2Strategy extends PassportStrategy(Strategy, 'oauth2') { super(); } - async validate(request: { body: Oauth2AuthorizationBodyParams }): Promise { + async validate(request: { body: Oauth2AuthorizationBodyParams }): Promise { const { systemId, redirectUri, code } = request.body; const tokenDto: OAuthTokenDto = await this.oauthService.authenticateUser(systemId, redirectUri, code); diff --git a/apps/server/src/modules/authentication/uc/login.uc.ts b/apps/server/src/modules/authentication/uc/login.uc.ts index fbb50f6a693..2a6404b0a87 100644 --- a/apps/server/src/modules/authentication/uc/login.uc.ts +++ b/apps/server/src/modules/authentication/uc/login.uc.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { CurrentUserInterface } from '../interface'; +import { ICurrentUser } from '../interface'; import { CreateJwtPayload } from '../interface/jwt-payload'; import { CurrentUserMapper } from '../mapper'; import { AuthenticationService } from '../services/authentication.service'; @@ -9,7 +9,7 @@ import { LoginDto } from './dto'; export class LoginUc { constructor(private readonly authService: AuthenticationService) {} - async getLoginData(userInfo: CurrentUserInterface): Promise { + async getLoginData(userInfo: ICurrentUser): Promise { const createJwtPayload: CreateJwtPayload = CurrentUserMapper.mapCurrentUserToCreateJwtPayload(userInfo); const accessTokenDto: LoginDto = await this.authService.generateJwt(createJwtPayload); diff --git a/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts index 9875001374b..5d7633e4c99 100644 --- a/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/board-delete.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -43,7 +43,7 @@ class API { describe(`board delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts b/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts index 33ada0e8a18..c4f685b9a6a 100644 --- a/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/board-lookup.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -44,7 +44,7 @@ class API { describe(`board lookup (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts index c7b12b8e48a..de006926e8f 100644 --- a/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-create.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -44,7 +44,7 @@ class API { describe(`card create (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts index 8b21a8b0004..d2b9a02efda 100644 --- a/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-delete.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -43,7 +43,7 @@ class API { describe(`card delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts index cb7dce16180..f43fb954e68 100644 --- a/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-lookup.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -48,7 +48,7 @@ class API { describe(`card lookup (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts index ef35c254025..fa67220072a 100644 --- a/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/card-move.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -43,7 +43,7 @@ class API { describe(`card move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts index b0dfc362af9..dd63155d4a5 100644 --- a/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-create.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -42,7 +42,7 @@ class API { describe(`board create (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts index 0d978999022..8b7dc463f98 100644 --- a/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-delete.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -42,7 +42,7 @@ class API { describe(`column delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts index 46df08c17af..f467646766a 100644 --- a/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/column-move.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -43,7 +43,7 @@ class API { describe(`column move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts b/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts index 1ee2538781e..b19aa8ff11c 100644 --- a/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/content-element-delete.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -43,7 +43,7 @@ class API { describe(`content element delete (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts b/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts index ef6d43e422e..f913a547f59 100644 --- a/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts +++ b/apps/server/src/modules/board/controller/api-test/content-element-move.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -44,7 +44,7 @@ class API { describe(`content element move (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/board/controller/board-submission.controller.ts b/apps/server/src/modules/board/controller/board-submission.controller.ts index c575dc75404..bc6f7298668 100644 --- a/apps/server/src/modules/board/controller/board-submission.controller.ts +++ b/apps/server/src/modules/board/controller/board-submission.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, @@ -42,7 +42,7 @@ export class BoardSubmissionController { @ApiResponse({ status: 403, type: ForbiddenException }) @Get(':submissionContainerId') async getSubmissionItems( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: SubmissionContainerUrlParams ): Promise { const { submissionItems, users } = await this.submissionItemUc.findSubmissionItems( @@ -63,7 +63,7 @@ export class BoardSubmissionController { @HttpCode(204) @Patch(':submissionItemId') async updateSubmissionItem( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: SubmissionItemUrlParams, @Body() bodyParams: UpdateSubmissionItemBodyParams ) { @@ -89,7 +89,7 @@ export class BoardSubmissionController { async createElement( @Param() urlParams: SubmissionItemUrlParams, @Body() bodyParams: CreateContentElementBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const { type } = bodyParams; const element = await this.submissionItemUc.createElement(currentUser.userId, urlParams.submissionItemId, type); diff --git a/apps/server/src/modules/board/controller/board.controller.ts b/apps/server/src/modules/board/controller/board.controller.ts index 82bea1bccb0..55a54e8f77b 100644 --- a/apps/server/src/modules/board/controller/board.controller.ts +++ b/apps/server/src/modules/board/controller/board.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, @@ -32,7 +32,7 @@ export class BoardController { @Get(':boardId') async getBoardSkeleton( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const board = await this.boardUc.findBoard(currentUser.userId, urlParams.boardId); @@ -49,7 +49,7 @@ export class BoardController { @Get(':boardId/context') async getBoardContext( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const boardContext = await this.boardUc.findBoardContext(currentUser.userId, urlParams.boardId); @@ -68,7 +68,7 @@ export class BoardController { async updateBoardTitle( @Param() urlParams: BoardUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.boardUc.updateBoardTitle(currentUser.userId, urlParams.boardId, bodyParams.title); } @@ -80,10 +80,7 @@ export class BoardController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':boardId') - async deleteBoard( - @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async deleteBoard(@Param() urlParams: BoardUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { await this.boardUc.deleteBoard(currentUser.userId, urlParams.boardId); } @@ -95,7 +92,7 @@ export class BoardController { @Post(':boardId/columns') async createColumn( @Param() urlParams: BoardUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const column = await this.boardUc.createColumn(currentUser.userId, urlParams.boardId); diff --git a/apps/server/src/modules/board/controller/card.controller.ts b/apps/server/src/modules/board/controller/card.controller.ts index 573405d7c7a..71a6d2ab0f9 100644 --- a/apps/server/src/modules/board/controller/card.controller.ts +++ b/apps/server/src/modules/board/controller/card.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, @@ -45,7 +45,7 @@ export class CardController { @ApiResponse({ status: 403, type: ForbiddenException }) @Get() async getCards( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() cardIdParams: CardIdsParams ): Promise { const cardIds = Array.isArray(cardIdParams.ids) ? cardIdParams.ids : [cardIdParams.ids]; @@ -68,7 +68,7 @@ export class CardController { async moveCard( @Param() urlParams: CardUrlParams, @Body() bodyParams: MoveCardBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.columnUc.moveCard(currentUser.userId, urlParams.cardId, bodyParams.toColumnId, bodyParams.toPosition); } @@ -83,7 +83,7 @@ export class CardController { async updateCardHeight( @Param() urlParams: CardUrlParams, @Body() bodyParams: SetHeightBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.cardUc.updateCardHeight(currentUser.userId, urlParams.cardId, bodyParams.height); } @@ -98,7 +98,7 @@ export class CardController { async updateCardTitle( @Param() urlParams: CardUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.cardUc.updateCardTitle(currentUser.userId, urlParams.cardId, bodyParams.title); } @@ -110,7 +110,7 @@ export class CardController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':cardId') - async deleteCard(@Param() urlParams: CardUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { + async deleteCard(@Param() urlParams: CardUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { await this.cardUc.deleteCard(currentUser.userId, urlParams.cardId); } @@ -141,7 +141,7 @@ export class CardController { async createElement( @Param() urlParams: CardUrlParams, @Body() bodyParams: CreateContentElementBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const { type, toPosition } = bodyParams; const element = await this.cardUc.createElement(currentUser.userId, urlParams.cardId, type, toPosition); diff --git a/apps/server/src/modules/board/controller/column.controller.ts b/apps/server/src/modules/board/controller/column.controller.ts index 09cd7c5e61a..9a3da989159 100644 --- a/apps/server/src/modules/board/controller/column.controller.ts +++ b/apps/server/src/modules/board/controller/column.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, @@ -34,7 +34,7 @@ export class ColumnController { async moveColumn( @Param() urlParams: ColumnUrlParams, @Body() bodyParams: MoveColumnBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.boardUc.moveColumn(currentUser.userId, urlParams.columnId, bodyParams.toBoardId, bodyParams.toPosition); } @@ -49,7 +49,7 @@ export class ColumnController { async updateColumnTitle( @Param() urlParams: ColumnUrlParams, @Body() bodyParams: RenameBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.columnUc.updateColumnTitle(currentUser.userId, urlParams.columnId, bodyParams.title); } @@ -61,10 +61,7 @@ export class ColumnController { @ApiResponse({ status: 404, type: NotFoundException }) @HttpCode(204) @Delete(':columnId') - async deleteColumn( - @Param() urlParams: ColumnUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async deleteColumn(@Param() urlParams: ColumnUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { await this.columnUc.deleteColumn(currentUser.userId, urlParams.columnId); } @@ -77,7 +74,7 @@ export class ColumnController { @Post(':columnId/cards') async createCard( @Param() urlParams: ColumnUrlParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() createCardBodyParams?: CreateCardBodyParams ): Promise { const { requiredEmptyElements } = createCardBodyParams || {}; diff --git a/apps/server/src/modules/board/controller/element.controller.ts b/apps/server/src/modules/board/controller/element.controller.ts index 8c62ebbf493..71ade95db66 100644 --- a/apps/server/src/modules/board/controller/element.controller.ts +++ b/apps/server/src/modules/board/controller/element.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, @@ -51,7 +51,7 @@ export class ElementController { async moveElement( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: MoveContentElementBody, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.cardUc.moveElement( currentUser.userId, @@ -89,7 +89,7 @@ export class ElementController { async updateElement( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: UpdateElementContentBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const element = await this.elementUc.updateElementContent( currentUser.userId, @@ -109,7 +109,7 @@ export class ElementController { @Delete(':contentElementId') async deleteElement( @Param() urlParams: ContentElementUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.elementUc.deleteElement(currentUser.userId, urlParams.contentElementId); } @@ -125,7 +125,7 @@ export class ElementController { async createSubmissionItem( @Param() urlParams: ContentElementUrlParams, @Body() bodyParams: CreateSubmissionItemBodyParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const submissionItem = await this.elementUc.createSubmissionItem( currentUser.userId, diff --git a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts index 92cfb9042d2..77b958f9c7a 100644 --- a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts +++ b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.spec.ts @@ -1,5 +1,5 @@ import { createMock } from '@golevelup/ts-jest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { CollaborativeStorageController } from '@modules/collaborative-storage/controller/collaborative-storage.controller'; import { CollaborativeStorageUc } from '@modules/collaborative-storage/uc/collaborative-storage.uc'; import { Test, TestingModule } from '@nestjs/testing'; @@ -29,7 +29,7 @@ describe('CollaborativeStorage Controller', () => { describe('Update TeamPermissions For Role', () => { it('should call the UC', async () => { await controller.updateTeamPermissionsForRole( - { userId: 'userId' } as CurrentUserInterface, + { userId: 'userId' } as ICurrentUser, { teamId: 'testTeam', roleId: 'testRole' }, { read: false, write: false, create: false, delete: false, share: false } ); diff --git a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts index 81f2152b352..4e11b3c46bd 100644 --- a/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts +++ b/apps/server/src/modules/collaborative-storage/controller/collaborative-storage.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Param, Patch } from '@nestjs/common'; import { ApiResponse, ApiTags } from '@nestjs/swagger'; import { LegacyLogger } from '@src/core/logger'; @@ -30,7 +30,7 @@ export class CollaborativeStorageController { @ApiResponse({ status: 403, description: 'User does not have the correct permission' }) @ApiResponse({ status: 404, description: 'Team or Role not found!' }) updateTeamPermissionsForRole( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() teamRole: TeamRoleDto, @Body() permissionsBody: TeamPermissionsBody ): Promise { diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts index d449cb5f4b3..4694b1817ac 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-security.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -48,7 +48,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let validId: string; 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 6bf8d5f4fb8..1711acba050 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 @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { AntivirusService } from '@infra/antivirus'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -85,7 +85,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { 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 638f6634b07..ea85d9b656b 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 @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { AntivirusService } from '@infra/antivirus'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -84,7 +84,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { 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 ed272ef5d0b..8d8e7dbf912 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 @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { AntivirusService } from '@infra/antivirus'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -93,7 +93,7 @@ describe('files-storage controller (API)', () => { let app: INestApplication; let em: EntityManager; let s3ClientAdapter: DeepMocked; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let validId: EntityId; let appPort: number; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts index 65b8c285af7..35410d712c8 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-list-files.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -48,7 +48,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let validId: string; 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 609d6f62dec..6ccc6d0d5ea 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 @@ -3,7 +3,7 @@ import { AntivirusService } from '@infra/antivirus'; import { PreviewProducer } from '@infra/preview-generator'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication, NotFoundException, StreamableFile } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -104,7 +104,7 @@ describe('File Controller (API) - preview', () => { let em: EntityManager; let s3ClientAdapter: DeepMocked; let antivirusService: DeepMocked; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let schoolId: EntityId; let appPort: number; diff --git a/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts b/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts index bada5cf5723..fb1dfa866eb 100644 --- a/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts +++ b/apps/server/src/modules/files-storage/controller/api-test/files-storage-rename-file.api.spec.ts @@ -1,6 +1,6 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -47,7 +47,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let fileRecord: FileRecord; let fileRecords: FileRecord[]; 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 d3efedf02e9..7f56152f7da 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 @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { AntivirusService } from '@infra/antivirus'; import { S3ClientAdapter } from '@infra/s3-client'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -109,7 +109,7 @@ class API { describe(`${baseRouteName} (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts index 22926c2d01a..7269336c44c 100644 --- a/apps/server/src/modules/files-storage/controller/files-storage.controller.ts +++ b/apps/server/src/modules/files-storage/controller/files-storage.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { BadRequestException, Body, @@ -63,7 +63,7 @@ export class FilesStorageController { async uploadFromUrl( @Body() body: FileUrlParams, @Param() params: FileRecordParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const fileRecord = await this.filesStorageUC.uploadFromUrl(currentUser.userId, { ...body, ...params }); @@ -83,7 +83,7 @@ export class FilesStorageController { async upload( @Body() _: FileParams, @Param() params: FileRecordParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Req() req: Request ): Promise { const fileRecord = await this.filesStorageUC.upload(currentUser.userId, params, req); @@ -105,7 +105,7 @@ export class FilesStorageController { @Get('/download/:fileRecordId/:fileName') async download( @Param() params: DownloadFileParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Req() req: Request, @Res({ passthrough: true }) response: Response, @Headers('Range') bytesRange?: string @@ -131,7 +131,7 @@ export class FilesStorageController { @RequestTimeout(config().INCOMING_REQUEST_TIMEOUT) async downloadPreview( @Param() params: DownloadFileParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() previewParams: PreviewParams, @Req() req: Request, @Res({ passthrough: true }) response: Response, @@ -192,7 +192,7 @@ export class FilesStorageController { @Get('/list/:schoolId/:parentType/:parentId') async list( @Param() params: FileRecordParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() pagination: PaginationParams ): Promise { const [fileRecords, total] = await this.filesStorageUC.getFileRecordsOfParent(currentUser.userId, params); @@ -217,7 +217,7 @@ export class FilesStorageController { async patchFilename( @Param() params: SingleFileParams, @Body() renameFileParam: RenameFileParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const fileRecord = await this.filesStorageUC.patchFilename(currentUser.userId, params, renameFileParam); @@ -238,7 +238,7 @@ export class FilesStorageController { @UseInterceptors(RequestLoggingInterceptor) async deleteByParent( @Param() params: FileRecordParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const [fileRecords, total] = await this.filesStorageUC.deleteFilesOfParent(currentUser.userId, params); const response = FileRecordMapper.mapToFileRecordListResponse(fileRecords, total); @@ -255,7 +255,7 @@ export class FilesStorageController { @UseInterceptors(RequestLoggingInterceptor) async deleteFile( @Param() params: SingleFileParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const fileRecord = await this.filesStorageUC.deleteOneFile(currentUser.userId, params); @@ -271,7 +271,7 @@ export class FilesStorageController { @Post('/restore/:schoolId/:parentType/:parentId') async restore( @Param() params: FileRecordParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const [fileRecords, total] = await this.filesStorageUC.restoreFilesOfParent(currentUser.userId, params); @@ -287,7 +287,7 @@ export class FilesStorageController { @Post('/restore/:fileRecordId') async restoreFile( @Param() params: SingleFileParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const fileRecord = await this.filesStorageUC.restoreOneFile(currentUser.userId, params); @@ -305,7 +305,7 @@ export class FilesStorageController { async copy( @Param() params: FileRecordParams, @Body() copyFilesParam: CopyFilesOfParentParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const [response, count] = await this.filesStorageUC.copyFilesOfParent(currentUser.userId, params, copyFilesParam); @@ -322,7 +322,7 @@ export class FilesStorageController { async copyFile( @Param() params: SingleFileParams, @Body() copyFileParam: CopyFileParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const response = await this.filesStorageUC.copyOneFile(currentUser.userId, params, copyFileParam); diff --git a/apps/server/src/modules/group/controller/group.controller.ts b/apps/server/src/modules/group/controller/group.controller.ts index 4aba6ad39cf..2ae47b54552 100644 --- a/apps/server/src/modules/group/controller/group.controller.ts +++ b/apps/server/src/modules/group/controller/group.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, HttpStatus, Param, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; @@ -24,7 +24,7 @@ export class GroupController { @Query() pagination: PaginationParams, @Query() sortingQuery: ClassSortParams, @Query() filterParams: ClassFilterParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const board: Page = await this.groupUc.findAllClasses( currentUser.userId, @@ -51,7 +51,7 @@ export class GroupController { @ApiResponse({ status: '4XX', type: ErrorResponse }) @ApiResponse({ status: '5XX', type: ErrorResponse }) public async getGroup( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: GroupIdParams ): Promise { const group: ResolvedGroupDto = await this.groupUc.getGroup(currentUser.userId, params.groupId); 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 0306a5ee710..ff093b2c712 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 @@ -5,7 +5,7 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -35,7 +35,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let h5PEditorUc: DeepMocked; beforeAll(async () => { 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 51fd9bb90f3..c22c7394fab 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 @@ -5,7 +5,7 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -53,7 +53,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let h5PEditorUc: DeepMocked; beforeAll(async () => { 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 19a2002503d..cb5a3d487eb 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 @@ -6,7 +6,7 @@ import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test } from '@nestjs/testing'; import { Permission } from '@shared/domain'; import { cleanupCollections, mapUserToCurrentUser, roleFactory, schoolFactory, userFactory } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { JwtAuthGuard } from '@src/modules/authentication/guard/jwt-auth.guard'; import { Request } from 'express'; import request from 'supertest'; @@ -45,7 +45,7 @@ describe('H5PEditor Controller (api)', () => { let app: INestApplication; let api: API; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let h5PEditorUc: DeepMocked; beforeAll(async () => { diff --git a/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts b/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts index 7271ff6c551..c46c782da2d 100644 --- a/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts +++ b/apps/server/src/modules/h5p-editor/controller/h5p-editor.controller.ts @@ -1,4 +1,4 @@ -import { CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { CurrentUser, ICurrentUser } from '@modules/authentication'; import { Authenticate } from '@modules/authentication/decorator/auth.decorator'; import { BadRequestException, @@ -51,7 +51,7 @@ export class H5PEditorController { @ApiResponse({ status: 403, type: ForbiddenException }) @ApiResponse({ status: 500, type: InternalServerErrorException }) @Get('/play/:contentId') - async getPlayer(@CurrentUser() currentUser: CurrentUserInterface, @Param() params: GetH5PContentParams) { + async getPlayer(@CurrentUser() currentUser: ICurrentUser, @Param() params: GetH5PContentParams) { return this.h5pEditorUc.getH5pPlayer(currentUser, params.contentId); } @@ -73,7 +73,7 @@ export class H5PEditorController { } @Get('params/:id') - async getContentParameters(@Param('id') id: string, @CurrentUser() currentUser: CurrentUserInterface) { + async getContentParameters(@Param('id') id: string, @CurrentUser() currentUser: ICurrentUser) { const content = await this.h5pEditorUc.getContentParameters(id, currentUser); return content; @@ -84,7 +84,7 @@ export class H5PEditorController { @Param() params: ContentFileUrlParams, @Req() req: Request, @Res({ passthrough: true }) res: Response, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ) { const { data, contentType, contentLength, contentRange } = await this.h5pEditorUc.getContentFile( params.id, @@ -102,7 +102,7 @@ export class H5PEditorController { @Get('temp-files/:file(*)') async getTemporaryFile( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param('file') file: string, @Req() req: Request, @Res({ passthrough: true }) res: Response @@ -121,7 +121,7 @@ export class H5PEditorController { } @Get('ajax') - async getAjax(@Query() query: AjaxGetQueryParams, @CurrentUser() currentUser: CurrentUserInterface) { + async getAjax(@Query() query: AjaxGetQueryParams, @CurrentUser() currentUser: ICurrentUser) { const response = this.h5pEditorUc.getAjax(query, currentUser); return response; @@ -137,7 +137,7 @@ export class H5PEditorController { async postAjax( @Body(AjaxPostBodyParamsTransformPipe) body: AjaxPostBodyParams, @Query() query: AjaxPostQueryParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @UploadedFiles() files?: { file?: Express.Multer.File[]; h5p?: Express.Multer.File[] } ) { const contentFile = files?.file?.[0]; @@ -151,7 +151,7 @@ export class H5PEditorController { @Post('/delete/:contentId') async deleteH5pContent( @Param() params: GetH5PContentParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const deleteSuccessfull = this.h5pEditorUc.deleteH5pContent(currentUser, params.contentId); @@ -160,7 +160,7 @@ export class H5PEditorController { @Get('/edit/:language') @ApiResponse({ status: 200, type: H5PEditorModelResponse }) - async getNewH5PEditor(@Param() params: GetH5PEditorParamsCreate, @CurrentUser() currentUser: CurrentUserInterface) { + async getNewH5PEditor(@Param() params: GetH5PEditorParamsCreate, @CurrentUser() currentUser: ICurrentUser) { const editorModel = await this.h5pEditorUc.getEmptyH5pEditor(currentUser, params.language); return new H5PEditorModelResponse(editorModel); @@ -168,7 +168,7 @@ export class H5PEditorController { @Get('/edit/:contentId/:language') @ApiResponse({ status: 200, type: H5PEditorModelContentResponse }) - async getH5PEditor(@Param() params: GetH5PEditorParams, @CurrentUser() currentUser: CurrentUserInterface) { + async getH5PEditor(@Param() params: GetH5PEditorParams, @CurrentUser() currentUser: ICurrentUser) { const { editorModel, content } = await this.h5pEditorUc.getH5pEditor( currentUser, params.contentId, @@ -180,7 +180,7 @@ export class H5PEditorController { @Post('/edit') @ApiResponse({ status: 201, type: H5PSaveResponse }) - async createH5pContent(@Body() body: PostH5PContentCreateParams, @CurrentUser() currentUser: CurrentUserInterface) { + async createH5pContent(@Body() body: PostH5PContentCreateParams, @CurrentUser() currentUser: ICurrentUser) { const response = await this.h5pEditorUc.createH5pContentGetMetadata( currentUser, body.params.params, @@ -200,7 +200,7 @@ export class H5PEditorController { async saveH5pContent( @Body() body: PostH5PContentCreateParams, @Param() params: SaveH5PEditorParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ) { const response = await this.h5pEditorUc.saveH5pContentGetMetadata( params.contentId, diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts index e6a67661761..040d5817f8a 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-delete.uc.spec.ts @@ -3,7 +3,7 @@ import { H5PEditor, H5PPlayer } from '@lumieducation/h5p-server'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { H5PAjaxEndpointProvider } from '../provider'; @@ -14,7 +14,7 @@ import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts index 01666e42ebe..c1c7987ace8 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-files.uc.spec.ts @@ -3,7 +3,7 @@ import { H5PAjaxEndpoint, H5PEditor, IPlayerModel } from '@lumieducation/h5p-ser import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { Request } from 'express'; @@ -17,7 +17,7 @@ import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts index 02fdeebe80d..824b1f7de8a 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-get-editor.uc.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LanguageType } from '@shared/domain'; import { UserRepo } from '@shared/repo'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { H5PAjaxEndpointProvider } from '../provider'; @@ -16,7 +16,7 @@ import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts index e44ff01fc3d..c8648cb413c 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-get-player.uc.spec.ts @@ -3,7 +3,7 @@ import { H5PEditor, H5PPlayer, IPlayerModel } from '@lumieducation/h5p-server'; import { ForbiddenException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { H5PAjaxEndpointProvider } from '../provider'; @@ -14,7 +14,7 @@ import { H5PEditorUc } from './h5p.uc'; const createParams = () => { const content = h5pContentFactory.build(); - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts b/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts index efac96eeefa..2fba57f5bc2 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p-save-create.uc.spec.ts @@ -4,7 +4,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { ForbiddenException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { h5pContentFactory, setupEntities } from '@shared/testing'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContextBuilder, AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; import { H5PContentParentType } from '../entity'; @@ -22,7 +22,7 @@ const createParams = () => { const contentId = new ObjectId().toHexString(); const parentId = new ObjectId().toHexString(); - const mockCurrentUser: CurrentUserInterface = { + const mockCurrentUser: ICurrentUser = { accountId: 'mockAccountId', roles: ['student'], schoolId: 'mockSchoolId', diff --git a/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts b/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts index 0bafba101f6..f456491509a 100644 --- a/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts +++ b/apps/server/src/modules/h5p-editor/uc/h5p.uc.ts @@ -22,7 +22,7 @@ import { NotFoundException, } from '@nestjs/common'; import { EntityId, LanguageType } from '@shared/domain'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { AuthorizationContext, AuthorizationContextBuilder } from '@src/modules/authorization'; import { AuthorizationReferenceService } from '@src/modules/authorization/domain'; import { UserService } from '@src/modules/user'; @@ -92,7 +92,7 @@ export class H5PEditorUc { public async getAjax( query: AjaxGetQueryParams, - currentUser: CurrentUserInterface + currentUser: ICurrentUser ): Promise { const user = this.changeUserType(currentUser); const language = await this.getUserLanguage(currentUser); @@ -116,7 +116,7 @@ export class H5PEditorUc { } public async postAjax( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, query: AjaxPostQueryParams, body: AjaxPostBodyParams, contentFile?: Express.Multer.File, @@ -167,7 +167,7 @@ export class H5PEditorUc { } } - public async getContentParameters(contentId: string, currentUser: CurrentUserInterface) { + public async getContentParameters(contentId: string, currentUser: ICurrentUser) { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -186,7 +186,7 @@ export class H5PEditorUc { contentId: string, file: string, req: Request, - currentUser: CurrentUserInterface + currentUser: ICurrentUser ): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -227,11 +227,7 @@ export class H5PEditorUc { } } - public async getTemporaryFile( - file: string, - req: Request, - currentUser: CurrentUserInterface - ): Promise { + public async getTemporaryFile(file: string, req: Request, currentUser: ICurrentUser): Promise { const user = this.changeUserType(currentUser); try { @@ -266,7 +262,7 @@ export class H5PEditorUc { } } - public async getH5pPlayer(currentUser: CurrentUserInterface, contentId: string): Promise { + public async getH5pPlayer(currentUser: ICurrentUser, contentId: string): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.read([])); @@ -277,7 +273,7 @@ export class H5PEditorUc { return playerModel; } - public async getEmptyH5pEditor(currentUser: CurrentUserInterface, language: LanguageType) { + public async getEmptyH5pEditor(currentUser: ICurrentUser, language: LanguageType) { const user = this.changeUserType(currentUser); const fakeUndefinedString = this.fakeUndefinedAsString(); @@ -291,7 +287,7 @@ export class H5PEditorUc { return createdH5PEditor; } - public async getH5pEditor(currentUser: CurrentUserInterface, contentId: string, language: LanguageType) { + public async getH5pEditor(currentUser: ICurrentUser, contentId: string, language: LanguageType) { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.write([])); @@ -308,7 +304,7 @@ export class H5PEditorUc { }; } - public async deleteH5pContent(currentUser: CurrentUserInterface, contentId: string): Promise { + public async deleteH5pContent(currentUser: ICurrentUser, contentId: string): Promise { const { parentType, parentId } = await this.h5pContentRepo.findById(contentId); await this.checkContentPermission(currentUser.userId, parentType, parentId, AuthorizationContextBuilder.write([])); @@ -328,7 +324,7 @@ export class H5PEditorUc { } public async createH5pContentGetMetadata( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, params: unknown, metadata: IContentMetadata, mainLibraryUbername: string, @@ -353,7 +349,7 @@ export class H5PEditorUc { public async saveH5pContentGetMetadata( contentId: string, - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, params: unknown, metadata: IContentMetadata, mainLibraryUbername: string, @@ -375,7 +371,7 @@ export class H5PEditorUc { return newContentId; } - private changeUserType(currentUser: CurrentUserInterface): LumiIUser { + private changeUserType(currentUser: ICurrentUser): LumiIUser { const user: LumiIUser = { canCreateRestricted: false, canInstallRecommended: true, @@ -390,7 +386,7 @@ export class H5PEditorUc { } private createAugmentedLumiUser( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, contentParentType: H5PContentParentType, contentParentId: EntityId ) { @@ -403,7 +399,7 @@ export class H5PEditorUc { return user; } - private async getUserLanguage(currentUser: CurrentUserInterface): Promise { + private async getUserLanguage(currentUser: ICurrentUser): Promise { const languageUser = await this.userService.findById(currentUser.userId); let userLanguage = LanguageType.DE; if (languageUser?.language) { diff --git a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts index e0b8476dde8..18a9cc28acf 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { DashboardResponse } from '@modules/learnroom/controller/dto'; import { ServerTestModule } from '@modules/server/server.module'; @@ -15,7 +15,7 @@ describe('Dashboard Controller (API)', () => { let app: INestApplication; let em: EntityManager; let dashboardRepo: DashboardRepoInterface; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts index e76043d41de..c73b9861c1f 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/rooms-copy-timeout.api.spec.ts @@ -1,7 +1,7 @@ import { createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -30,7 +30,7 @@ import { ServerTestModule } from '@modules/server'; describe('Rooms copy (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts index 68fb3e5b3b9..ec6114f8f60 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/rooms.api.spec.ts @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { CopyApiResponse } from '@modules/copy-helper'; import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; @@ -26,7 +26,7 @@ import request from 'supertest'; describe('Rooms Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let filesStorageClientAdapterService: DeepMocked; const setConfig = () => { diff --git a/apps/server/src/modules/learnroom/controller/course.controller.ts b/apps/server/src/modules/learnroom/controller/course.controller.ts index cebb03a864a..7f026002ea7 100644 --- a/apps/server/src/modules/learnroom/controller/course.controller.ts +++ b/apps/server/src/modules/learnroom/controller/course.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, NotFoundException, Param, Query, Res, StreamableFile } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { ApiTags } from '@nestjs/swagger'; @@ -21,7 +21,7 @@ export class CourseController { @Get() async findForUser( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() pagination: PaginationParams ): Promise { const [courses, total] = await this.courseUc.findAllByUser(currentUser.userId, pagination); @@ -34,7 +34,7 @@ export class CourseController { @Get(':courseId/export') async exportCourse( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: CourseUrlParams, @Query() queryParams: CourseQueryParams, @Res({ passthrough: true }) response: Response diff --git a/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts b/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts index 9f12a182716..76ebe449829 100644 --- a/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts +++ b/apps/server/src/modules/learnroom/controller/dashboard.controller.spec.ts @@ -1,4 +1,4 @@ -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { Test, TestingModule } from '@nestjs/testing'; import { DashboardEntity, @@ -65,7 +65,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -76,7 +76,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -98,7 +98,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const response = await controller.findForUser(currentUser); expect(response instanceof DashboardResponse).toEqual(true); @@ -110,7 +110,7 @@ describe('dashboard uc', () => { const dashboard = new DashboardEntity('someid', { grid: [], userId: 'userId' }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; await controller.findForUser(currentUser); expect(spy).toHaveBeenCalledWith('userId'); @@ -133,7 +133,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; await controller.moveElement( { dashboardId: 'dashboardId' }, { from: { x: 1, y: 2 }, to: { x: 2, y: 1 } }, @@ -157,7 +157,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const response = await controller.moveElement( { dashboardId: 'dashboardId' }, { @@ -189,7 +189,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; await controller.patchGroup({ dashboardId: 'dashboardId' }, 3, 4, { title: 'groupTitle' }, currentUser); expect(spy).toHaveBeenCalledWith('dashboardId', { x: 3, y: 4 }, 'groupTitle', currentUser.userId); }); @@ -212,7 +212,7 @@ describe('dashboard uc', () => { }); return Promise.resolve(dashboard); }); - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const response = await controller.patchGroup( { dashboardId: 'dashboardId' }, 3, diff --git a/apps/server/src/modules/learnroom/controller/dashboard.controller.ts b/apps/server/src/modules/learnroom/controller/dashboard.controller.ts index 1559be97f59..c2c2ff6d9ee 100644 --- a/apps/server/src/modules/learnroom/controller/dashboard.controller.ts +++ b/apps/server/src/modules/learnroom/controller/dashboard.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Get, Param, Patch, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { DashboardMapper } from '../mapper/dashboard.mapper'; @@ -12,7 +12,7 @@ export class DashboardController { constructor(private readonly dashboardUc: DashboardUc) {} @Get() - async findForUser(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async findForUser(@CurrentUser() currentUser: ICurrentUser): Promise { const dashboard = await this.dashboardUc.getUsersDashboard(currentUser.userId); const dto = DashboardMapper.mapToResponse(dashboard); return dto; @@ -22,7 +22,7 @@ export class DashboardController { async moveElement( @Param() { dashboardId }: DashboardUrlParams, @Body() params: MoveElementParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const dashboard = await this.dashboardUc.moveElementOnDashboard( dashboardId, @@ -40,7 +40,7 @@ export class DashboardController { @Query('x') x: number, @Query('y') y: number, @Body() params: PatchGroupParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const dashboard = await this.dashboardUc.renameGroupOnDashboard( urlParams.dashboardId, diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts index c87462f3b2f..4e10bd706a3 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.spec.ts @@ -1,5 +1,5 @@ import { createMock } from '@golevelup/ts-jest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { CopyApiResponse, CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityId } from '@shared/domain'; @@ -73,7 +73,7 @@ describe('rooms controller', () => { describe('getRoomBoard', () => { describe('when simple room is fetched', () => { const setup = () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucResult = { roomId: 'id', @@ -123,7 +123,7 @@ describe('rooms controller', () => { describe('patchVisibility', () => { it('should call uc', async () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucSpy = jest.spyOn(uc, 'updateVisibilityOfBoardElement').mockImplementation(() => Promise.resolve()); await controller.patchElementVisibility( { roomId: 'roomid', elementId: 'elementId' }, @@ -136,7 +136,7 @@ describe('rooms controller', () => { describe('patchOrder', () => { it('should call uc', async () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucSpy = jest.spyOn(uc, 'reorderBoardElements').mockImplementation(() => Promise.resolve()); await controller.patchOrderingOfElements({ roomId: 'roomid' }, { elements: ['id', 'id', 'id'] }, currentUser); expect(ucSpy).toHaveBeenCalledWith('roomid', 'userId', ['id', 'id', 'id']); @@ -146,7 +146,7 @@ describe('rooms controller', () => { describe('copyCourse', () => { describe('when course should be copied via API call', () => { const setup = () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucResult = { title: 'example title', type: 'COURSE' as CopyElementType, @@ -175,7 +175,7 @@ describe('rooms controller', () => { describe('copyLesson', () => { describe('when lesson should be copied via API call', () => { const setup = () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucResult = { title: 'example title', type: 'LESSON' as CopyElementType, diff --git a/apps/server/src/modules/learnroom/controller/rooms.controller.ts b/apps/server/src/modules/learnroom/controller/rooms.controller.ts index 24a3dabc34d..c81b40d6bba 100644 --- a/apps/server/src/modules/learnroom/controller/rooms.controller.ts +++ b/apps/server/src/modules/learnroom/controller/rooms.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; import { serverConfig } from '@modules/server/server.config'; import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'; @@ -32,7 +32,7 @@ export class RoomsController { @Get(':roomId/board') async getRoomBoard( @Param() urlParams: RoomUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const board = await this.roomsUc.getBoard(urlParams.roomId, currentUser.userId); const mapped = this.mapper.mapToResponse(board); @@ -43,7 +43,7 @@ export class RoomsController { async patchElementVisibility( @Param() urlParams: RoomElementUrlParams, @Body() params: PatchVisibilityParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.roomsUc.updateVisibilityOfBoardElement( urlParams.roomId, @@ -57,7 +57,7 @@ export class RoomsController { async patchOrderingOfElements( @Param() urlParams: RoomUrlParams, @Body() params: PatchOrderParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { await this.roomsUc.reorderBoardElements(urlParams.roomId, currentUser.userId, params.elements); } @@ -65,7 +65,7 @@ export class RoomsController { @Post(':roomId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyCourse( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: RoomUrlParams ): Promise { const copyStatus = await this.courseCopyUc.copyCourse(currentUser.userId, urlParams.roomId); @@ -76,7 +76,7 @@ export class RoomsController { @Post('lessons/:lessonId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyLesson( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: LessonUrlParams, @Body() params: LessonCopyApiParams ): Promise { diff --git a/apps/server/src/modules/lesson/controller/lesson.controller.ts b/apps/server/src/modules/lesson/controller/lesson.controller.ts index edd926642e0..66e52b06478 100644 --- a/apps/server/src/modules/lesson/controller/lesson.controller.ts +++ b/apps/server/src/modules/lesson/controller/lesson.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Delete, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { LessonUC } from '../uc'; @@ -11,10 +11,7 @@ export class LessonController { constructor(private readonly lessonUC: LessonUC) {} @Delete(':lessonId') - async delete( - @Param() urlParams: LessonUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async delete(@Param() urlParams: LessonUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const result = await this.lessonUC.delete(currentUser.userId, urlParams.lessonId); return result; diff --git a/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts b/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts index 146513d1e38..8133c4c0b83 100644 --- a/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts +++ b/apps/server/src/modules/meta-tag-extractor/controller/meta-tag-extractor.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, InternalServerErrorException, Post, UnauthorizedException } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { CurrentUserInterface } from '@src/modules/authentication'; +import { ICurrentUser } from '@src/modules/authentication'; import { Authenticate, CurrentUser } from '@src/modules/authentication/decorator/auth.decorator'; import { MetaTagExtractorUc } from '../uc'; import { MetaTagExtractorResponse } from './dto'; @@ -18,7 +18,7 @@ export class MetaTagExtractorController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Post('') async getData( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() bodyParams: GetMetaTagDataBody ): Promise { const result = await this.metaTagExtractorUc.fetchMetaData(currentUser.userId, bodyParams.url); diff --git a/apps/server/src/modules/news/controller/news.controller.ts b/apps/server/src/modules/news/controller/news.controller.ts index dfad2718345..c2cf6ba4e98 100644 --- a/apps/server/src/modules/news/controller/news.controller.ts +++ b/apps/server/src/modules/news/controller/news.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; @@ -23,10 +23,7 @@ export class NewsController { * Create a news by a user in a given scope (school or team). */ @Post() - async create( - @CurrentUser() currentUser: CurrentUserInterface, - @Body() params: CreateNewsParams - ): Promise { + async create(@CurrentUser() currentUser: ICurrentUser, @Body() params: CreateNewsParams): Promise { const news = await this.newsUc.create( currentUser.userId, currentUser.schoolId, @@ -41,7 +38,7 @@ export class NewsController { */ @Get() async findAll( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() scope: FilterNewsParams, @Query() pagination: PaginationParams ): Promise { @@ -61,10 +58,7 @@ export class NewsController { * The news entity has school and user names populated. */ @Get(':newsId') - async findOne( - @Param() urlParams: NewsUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async findOne(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const news = await this.newsUc.findOneByIdForUser(urlParams.newsId, currentUser.userId); const dto = NewsMapper.mapToResponse(news); return dto; @@ -76,7 +70,7 @@ export class NewsController { @Patch(':newsId') async update( @Param() urlParams: NewsUrlParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() params: UpdateNewsParams ): Promise { const news = await this.newsUc.update( @@ -92,7 +86,7 @@ export class NewsController { * Delete a news. */ @Delete(':newsId') - async delete(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { + async delete(@Param() urlParams: NewsUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const deletedId = await this.newsUc.delete(urlParams.newsId, currentUser.userId); return deletedId; } diff --git a/apps/server/src/modules/news/controller/team-news.controller.ts b/apps/server/src/modules/news/controller/team-news.controller.ts index 71e66c6c34c..ac70748e439 100644 --- a/apps/server/src/modules/news/controller/team-news.controller.ts +++ b/apps/server/src/modules/news/controller/team-news.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; @@ -18,7 +18,7 @@ export class TeamNewsController { @Get(':teamId/news') async findAllForTeam( @Param() urlParams: TeamUrlParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() scope: FilterNewsParams, @Query() pagination: PaginationParams ): Promise { 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 7df890ee1f0..515f54f0a39 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 @@ -6,7 +6,7 @@ import { ProviderLoginResponse, ProviderRedirectResponse, } from '@infra/oauth-provider/dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AcceptQuery, ChallengeParams, @@ -40,7 +40,7 @@ describe('OauthProviderController', () => { let responseMapper: DeepMocked; const hydraUri = 'http://hydra.uri'; - const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; beforeAll(async () => { jest.spyOn(Configuration, 'get').mockReturnValue(hydraUri); 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 0eb5323d368..29644154a3a 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,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons'; -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Put, Query } from '@nestjs/common'; // import should be @infra/oauth-provider import { @@ -47,7 +47,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('clients/:id') async getOAuth2Client( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: IdParams ): Promise { const client: ProviderOauthClient = await this.crudUc.getOAuth2Client(currentUser, params.id); @@ -58,7 +58,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('clients') async listOAuth2Clients( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ListOauthClientsParams ): Promise { const clients: ProviderOauthClient[] = await this.crudUc.listOAuth2Clients( @@ -78,7 +78,7 @@ export class OauthProviderController { @Authenticate('jwt') @Post('clients') async createOAuth2Client( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: OauthClientBody ): Promise { const client: ProviderOauthClient = await this.crudUc.createOAuth2Client(currentUser, body); @@ -89,7 +89,7 @@ export class OauthProviderController { @Authenticate('jwt') @Put('clients/:id') async updateOAuth2Client( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: IdParams, @Body() body: OauthClientBody ): Promise { @@ -100,7 +100,7 @@ export class OauthProviderController { @Authenticate('jwt') @Delete('clients/:id') - deleteOAuth2Client(@CurrentUser() currentUser: CurrentUserInterface, @Param() params: IdParams): Promise { + deleteOAuth2Client(@CurrentUser() currentUser: ICurrentUser, @Param() params: IdParams): Promise { const promise: Promise = this.crudUc.deleteOAuth2Client(currentUser, params.id); return promise; } @@ -118,7 +118,7 @@ export class OauthProviderController { @Param() params: ChallengeParams, @Query() query: AcceptQuery, @Body() body: LoginRequestBody, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const redirectResponse: ProviderRedirectResponse = await this.oauthProviderLoginFlowUc.patchLoginRequest( currentUser.userId, @@ -152,7 +152,7 @@ export class OauthProviderController { @Param() params: ChallengeParams, @Query() query: AcceptQuery, @Body() body: ConsentRequestBody, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const redirectResponse: ProviderRedirectResponse = await this.consentFlowUc.patchConsentRequest( params.challenge, @@ -166,7 +166,7 @@ export class OauthProviderController { @Authenticate('jwt') @Get('auth/sessions/consent') - async listConsentSessions(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async listConsentSessions(@CurrentUser() currentUser: ICurrentUser): Promise { const sessions: ProviderConsentSessionResponse[] = await this.oauthProviderUc.listConsentSessions( currentUser.userId ); @@ -179,10 +179,7 @@ export class OauthProviderController { @Authenticate('jwt') @Delete('auth/sessions/consent') - revokeConsentSession( - @CurrentUser() currentUser: CurrentUserInterface, - @Param() params: RevokeConsentParams - ): Promise { + revokeConsentSession(@CurrentUser() currentUser: ICurrentUser, @Param() params: RevokeConsentParams): Promise { const promise: Promise = this.oauthProviderUc.revokeConsentSession(currentUser.userId, params.client); return promise; } 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 ad90d21c502..8e80da47969 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 @@ -1,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { OauthProviderService } from '@infra/oauth-provider'; import { ProviderOauthClient } from '@infra/oauth-provider/dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -19,7 +19,7 @@ describe('OauthProviderUc', () => { let user: User; - const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; const defaultOauthClientBody: ProviderOauthClient = { scope: 'openid offline', grant_types: ['authorization_code', 'refresh_token'], 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 e29c23249f7..84221847796 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,6 +1,6 @@ import { ProviderOauthClient } from '@infra/oauth-provider/dto'; import { OauthProviderService } from '@infra/oauth-provider/index'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; import { Injectable } from '@nestjs/common'; import { Permission, User } from '@shared/domain/index'; @@ -20,7 +20,7 @@ export class OauthProviderClientCrudUc { }; async listOAuth2Clients( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, limit?: number, offset?: number, client_name?: string, @@ -38,7 +38,7 @@ export class OauthProviderClientCrudUc { return client; } - async getOAuth2Client(currentUser: CurrentUserInterface, id: string): Promise { + async getOAuth2Client(currentUser: ICurrentUser, id: string): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_VIEW]); @@ -47,7 +47,7 @@ export class OauthProviderClientCrudUc { return client; } - async createOAuth2Client(currentUser: CurrentUserInterface, data: ProviderOauthClient): Promise { + async createOAuth2Client(currentUser: ICurrentUser, data: ProviderOauthClient): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_EDIT]); @@ -57,7 +57,7 @@ export class OauthProviderClientCrudUc { } async updateOAuth2Client( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, id: string, data: ProviderOauthClient ): Promise { @@ -69,7 +69,7 @@ export class OauthProviderClientCrudUc { return client; } - async deleteOAuth2Client(currentUser: CurrentUserInterface, id: string): Promise { + async deleteOAuth2Client(currentUser: ICurrentUser, id: string): Promise { const user: User = await this.authorizationService.getUserWithPermissions(currentUser.userId); this.authorizationService.checkAllPermissions(user, [Permission.OAUTH_CLIENT_EDIT]); 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 3a61544bb37..e1a1663818e 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,7 +1,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { OauthProviderService } from '@infra/oauth-provider'; import { AcceptConsentRequestBody, ProviderConsentResponse, ProviderRedirectResponse } from '@infra/oauth-provider/dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; import { IdToken } from '@modules/oauth-provider/interface/id-token'; import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; @@ -45,12 +45,12 @@ describe('OauthProviderConsentFlowUc', () => { describe('consent', () => { let challenge: string; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let consentResponse: ProviderConsentResponse; beforeEach(() => { challenge = 'challengexyz'; - currentUser = { userId: 'userId' } as CurrentUserInterface; + currentUser = { userId: 'userId' } as ICurrentUser; consentResponse = { challenge, subject: currentUser.userId, 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 a38cbcd6d5c..a9c54b4f502 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 @@ -5,7 +5,7 @@ import { ProviderRedirectResponse, RejectRequestBody, } from '@infra/oauth-provider/dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AcceptQuery, ConsentRequestBody } from '@modules/oauth-provider/controller/dto'; import { IdToken } from '@modules/oauth-provider/interface/id-token'; import { IdTokenService } from '@modules/oauth-provider/service/id-token.service'; @@ -27,7 +27,7 @@ export class OauthProviderConsentFlowUc { challenge: string, query: AcceptQuery, body: ConsentRequestBody, - currentUser: CurrentUserInterface + currentUser: ICurrentUser ): Promise { const consentResponse = await this.oauthProviderService.getConsentRequest(challenge); this.validateSubject(currentUser, consentResponse); @@ -77,7 +77,7 @@ export class OauthProviderConsentFlowUc { return redirectResponse; } - private validateSubject(currentUser: CurrentUserInterface, response: ProviderConsentResponse): void { + private validateSubject(currentUser: ICurrentUser, response: ProviderConsentResponse): void { if (response.subject !== currentUser.userId) { throw new ForbiddenException("You want to patch another user's consent"); } diff --git a/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts b/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts index 6f8c2fd5911..e98100d3e43 100644 --- a/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts +++ b/apps/server/src/modules/oauth/controller/oauth-sso.controller.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { HydraOauthUc } from '@modules/oauth/uc/hydra-oauth.uc'; import { UnauthorizedException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -85,7 +85,7 @@ describe('OAuthController', () => { }); describe('requestAuthToken', () => { - const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; const oauthClientId = 'clientId'; it('should call the hydraOauthUc', async () => { diff --git a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts index 85e73c67c00..61ed319d1cd 100644 --- a/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts +++ b/apps/server/src/modules/oauth/controller/oauth-sso.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param, Query, Req, UnauthorizedException } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { LegacyLogger } from '@src/core/logger'; @@ -28,7 +28,7 @@ export class OauthSSOController { @Get('auth/:oauthClientId') @Authenticate('jwt') async requestAuthToken( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Req() req: Request, @Param('oauthClientId') oauthClientId: string ): Promise { diff --git a/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts b/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts index 82e3dc9f584..993f3ba9ded 100644 --- a/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts +++ b/apps/server/src/modules/pseudonym/controller/pseudonym.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -26,7 +26,7 @@ export class PseudonymController { @ApiOperation({ summary: 'Returns the related user and tool information to a pseudonym' }) async getPseudonym( @Param() params: PseudonymParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const pseudonym: Pseudonym = await this.pseudonymUc.findPseudonymByPseudonym(currentUser.userId, params.pseudonym); diff --git a/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts b/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts index c9aae09c483..a79b02046ac 100644 --- a/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts +++ b/apps/server/src/modules/sharing/controller/api-test/sharing-create-token.api.spec.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, HttpStatus, INestApplication } from '@nestjs/common'; @@ -46,7 +46,7 @@ class API { describe(`share token creation (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts b/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts index 306c16fe118..9d8df39e195 100644 --- a/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts +++ b/apps/server/src/modules/sharing/controller/api-test/sharing-import-token.api.spec.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { CopyApiResponse, CopyElementType, CopyStatusEnum } from '@modules/copy-helper'; import { ServerTestModule } from '@modules/server'; @@ -49,7 +49,7 @@ class API { describe(`share token import (api)`, () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let shareTokenService: ShareTokenService; let api: API; diff --git a/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts b/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts index ca17e72738c..d37b8b435ff 100644 --- a/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts +++ b/apps/server/src/modules/sharing/controller/share-token.controller.spec.ts @@ -1,5 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { Test, TestingModule } from '@nestjs/testing'; import { courseFactory, setupEntities, shareTokenFactory } from '@shared/testing'; @@ -39,7 +39,7 @@ describe('ShareTokenController', () => { describe('creating a token', () => { const setup = () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const shareToken = shareTokenFactory.build({ token: 'ctuW1FG0RsTo' }); uc.createShareToken.mockResolvedValue(shareToken); const body = { @@ -84,7 +84,7 @@ describe('ShareTokenController', () => { describe('looking up a token', () => { it('should call the use case', async () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const token = 'ctuW1FG0RsTo'; await controller.lookupShareToken(currentUser, { token }); @@ -93,7 +93,7 @@ describe('ShareTokenController', () => { }); it('should return the token data', async () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const shareTokenInfo: ShareTokenInfoDto = { token: 'ctuW1FG0RsTo', parentType: ShareTokenParentType.Course, @@ -110,7 +110,7 @@ describe('ShareTokenController', () => { describe('importing a share token', () => { const setup = () => { - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const token = 'ctuW1FG0RsTo'; const course = courseFactory.buildWithId(); const status: CopyStatus = { diff --git a/apps/server/src/modules/sharing/controller/share-token.controller.ts b/apps/server/src/modules/sharing/controller/share-token.controller.ts index f5793033b9d..5d990e1d99f 100644 --- a/apps/server/src/modules/sharing/controller/share-token.controller.ts +++ b/apps/server/src/modules/sharing/controller/share-token.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; import { Body, @@ -38,7 +38,7 @@ export class ShareTokenController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Post() async createShareToken( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: ShareTokenBodyParams ): Promise { const shareToken = await this.shareTokenUC.createShareToken( @@ -65,7 +65,7 @@ export class ShareTokenController { @ApiResponse({ status: 500, type: InternalServerErrorException }) @Get(':token') async lookupShareToken( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: ShareTokenUrlParams ): Promise { const shareTokenInfo = await this.shareTokenUC.lookupShareToken(currentUser.userId, urlParams.token); @@ -84,7 +84,7 @@ export class ShareTokenController { @Post(':token/import') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async importShareToken( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: ShareTokenUrlParams, @Body() body: ShareTokenImportBodyParams ): Promise { diff --git a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts index 3657b4a92a7..3167558461d 100644 --- a/apps/server/src/modules/system/controller/api-test/system.api.spec.ts +++ b/apps/server/src/modules/system/controller/api-test/system.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -14,7 +14,7 @@ import { PublicSystemResponse } from '../dto/public-system-response'; describe('System (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; beforeAll(async () => { const moduleRef: TestingModule = await Test.createTestingModule({ diff --git a/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts b/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts index 27a6a7eb77e..aed731a86e8 100644 --- a/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/submission.api.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ServerTestModule } from '@modules/server/server.module'; @@ -58,7 +58,7 @@ class API { describe('Submission Controller (API)', () => { describe('find statuses by task', () => { let app: INestApplication; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let em: EntityManager; @@ -182,7 +182,7 @@ describe('Submission Controller (API)', () => { describe('delete submission', () => { let app: INestApplication; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; let em: EntityManager; let filesStorageClientAdapterService: DeepMocked; diff --git a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts index 7a69fbecdee..d5546c435da 100644 --- a/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/task-copy-timeout.api.spec.ts @@ -2,7 +2,7 @@ import { createMock } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { IConfig } from '@hpi-schul-cloud/commons/lib/interfaces/IConfig'; import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { FilesStorageClientAdapterService } from '@modules/files-storage-client'; import { ExecutionContext, INestApplication } from '@nestjs/common'; @@ -30,7 +30,7 @@ import { ServerTestModule } from '@modules/server/server.module'; describe('Task copy (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let configBefore: IConfig; beforeAll(async () => { diff --git a/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts b/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts index 4177ce1ed18..f8261f9649b 100644 --- a/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts +++ b/apps/server/src/modules/task/controller/api-test/task-finished.api.spec.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { TaskListResponse } from '@modules/task/controller/dto'; @@ -44,7 +44,7 @@ class API { describe('Task controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/task/controller/submission.controller.ts b/apps/server/src/modules/task/controller/submission.controller.ts index ccaed6fc403..48f0899b07e 100644 --- a/apps/server/src/modules/task/controller/submission.controller.ts +++ b/apps/server/src/modules/task/controller/submission.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Delete, Get, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { SubmissionMapper } from '../mapper'; @@ -13,7 +13,7 @@ export class SubmissionController { @Get('status/task/:taskId') async findStatusesByTask( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: TaskUrlParams ): Promise { const submissions = await this.submissionUc.findAllByTask(currentUser.userId, params.taskId); @@ -26,10 +26,7 @@ export class SubmissionController { } @Delete(':submissionId') - async delete( - @Param() urlParams: SubmissionUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async delete(@Param() urlParams: SubmissionUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const result = await this.submissionUc.delete(currentUser.userId, urlParams.submissionId); return result; diff --git a/apps/server/src/modules/task/controller/task.controller.spec.ts b/apps/server/src/modules/task/controller/task.controller.spec.ts index 219418c521b..b76bb66d4da 100644 --- a/apps/server/src/modules/task/controller/task.controller.spec.ts +++ b/apps/server/src/modules/task/controller/task.controller.spec.ts @@ -1,5 +1,5 @@ import { createMock } from '@golevelup/ts-jest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { CopyElementType, CopyStatus, CopyStatusEnum } from '@modules/copy-helper'; import { CopyApiResponse } from '@modules/copy-helper/dto/copy.response'; import { Test, TestingModule } from '@nestjs/testing'; @@ -42,7 +42,7 @@ describe('TaskController', () => { describe('when task should be copied via API call', () => { const setup = () => { // todo: why not use builder instead of as - const currentUser = { userId: 'userId' } as CurrentUserInterface; + const currentUser = { userId: 'userId' } as ICurrentUser; const ucResult = { title: 'example title', type: 'TASK' as CopyElementType, diff --git a/apps/server/src/modules/task/controller/task.controller.ts b/apps/server/src/modules/task/controller/task.controller.ts index b4dcf47724e..b8e7231a1b6 100644 --- a/apps/server/src/modules/task/controller/task.controller.ts +++ b/apps/server/src/modules/task/controller/task.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { CopyApiResponse, CopyMapper } from '@modules/copy-helper'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; @@ -20,7 +20,7 @@ export class TaskController { @Get() async findAll( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() pagination: PaginationParams ): Promise { return this.findAllTasks(currentUser, pagination); @@ -28,14 +28,14 @@ export class TaskController { @Get('finished') async findAllFinished( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() pagination: PaginationParams ): Promise { return this.findAllTasks(currentUser, pagination, true); } private async findAllTasks( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() pagination: PaginationParams, finished = false ): Promise { @@ -51,10 +51,7 @@ export class TaskController { } @Patch(':taskId/finish') - async finish( - @Param() urlParams: TaskUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async finish(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const task = await this.taskUc.changeFinishedForUser(currentUser.userId, urlParams.taskId, true); const response = TaskMapper.mapToResponse(task); @@ -63,10 +60,7 @@ export class TaskController { } @Patch(':taskId/restore') - async restore( - @Param() urlParams: TaskUrlParams, - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async restore(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const task = await this.taskUc.changeFinishedForUser(currentUser.userId, urlParams.taskId, false); const response = TaskMapper.mapToResponse(task); @@ -77,7 +71,7 @@ export class TaskController { @Patch(':taskId/revertPublished') async revertPublished( @Param() urlParams: TaskUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const task = await this.taskUc.revertPublished(currentUser.userId, urlParams.taskId); @@ -89,7 +83,7 @@ export class TaskController { @Post(':taskId/copy') @RequestTimeout(serverConfig().INCOMING_REQUEST_TIMEOUT_COPY_API) async copyTask( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() urlParams: TaskUrlParams, @Body() params: TaskCopyApiParams ): Promise { @@ -103,7 +97,7 @@ export class TaskController { } @Delete(':taskId') - async delete(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: CurrentUserInterface): Promise { + async delete(@Param() urlParams: TaskUrlParams, @CurrentUser() currentUser: ICurrentUser): Promise { const result = await this.taskUc.delete(currentUser.userId, urlParams.taskId); return result; diff --git a/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts b/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts index 68a75a57a60..20d8b96f795 100644 --- a/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts +++ b/apps/server/src/modules/tool/context-external-tool/controller/tool-context.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put } from '@nestjs/common'; import { ApiCreatedResponse, @@ -42,7 +42,7 @@ export class ToolContextController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates a ContextExternalTool' }) async createContextExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: ContextExternalToolPostParams ): Promise { const contextExternalTool: ContextExternalToolDto = @@ -68,7 +68,7 @@ export class ToolContextController { @ApiOperation({ summary: 'Deletes a ContextExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteContextExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolIdParams ): Promise { await this.contextExternalToolUc.deleteContextExternalTool(currentUser.userId, params.contextExternalToolId); @@ -87,7 +87,7 @@ export class ToolContextController { }) @ApiOperation({ summary: 'Returns a list of ContextExternalTools for the given context' }) async getContextExternalToolsForContext( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolContextParams ): Promise { const contextExternalTools: ContextExternalTool[] = @@ -120,7 +120,7 @@ export class ToolContextController { }) @ApiOperation({ summary: 'Searches a ContextExternalTool for the given id' }) async getContextExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolIdParams ): Promise { const contextExternalTool: ContextExternalTool = await this.contextExternalToolUc.getContextExternalTool( @@ -144,7 +144,7 @@ export class ToolContextController { @ApiUnprocessableEntityResponse() @ApiOperation({ summary: 'Updates a ContextExternalTool' }) async updateContextExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolIdParams, @Body() body: ContextExternalToolPostParams ): Promise { diff --git a/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts b/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts index 6b53af1ebfc..4f7b7ed2703 100644 --- a/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts +++ b/apps/server/src/modules/tool/context-external-tool/controller/tool-reference.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, ApiOkResponse, ApiOperation, ApiTags, ApiUnauthorizedResponse } from '@nestjs/swagger'; import { ToolReference } from '../domain'; @@ -26,7 +26,7 @@ export class ToolReferenceController { @ApiForbiddenResponse({ description: 'User is not allowed to access this resource.' }) @ApiUnauthorizedResponse({ description: 'User is not logged in.' }) async getToolReference( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolIdParams ): Promise { const toolReference: ToolReference = await this.toolReferenceUc.getToolReference( @@ -49,7 +49,7 @@ export class ToolReferenceController { @ApiForbiddenResponse({ description: 'User is not allowed to access this resource.' }) @ApiUnauthorizedResponse({ description: 'User is not logged in.' }) async getToolReferencesForContext( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolContextParams ): Promise { const toolReferences: ToolReference[] = await this.toolReferenceUc.getToolReferencesForContext( diff --git a/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts index 570bf1282ff..5dbe2db8e9b 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool-configuration.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -36,7 +36,7 @@ export class ToolConfigurationController { type: SchoolExternalToolConfigurationTemplateListResponse, }) public async getAvailableToolsForSchool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: SchoolIdParams ): Promise { const availableTools: ExternalTool[] = await this.externalToolConfigurationUc.getAvailableToolsForSchool( @@ -58,7 +58,7 @@ export class ToolConfigurationController { type: ContextExternalToolConfigurationTemplateListResponse, }) public async getAvailableToolsForContext( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextRefParams ): Promise { const availableTools: ContextExternalToolTemplateInfo[] = @@ -84,7 +84,7 @@ export class ToolConfigurationController { type: SchoolExternalToolConfigurationTemplateResponse, }) public async getConfigurationTemplateForSchool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: SchoolExternalToolIdParams ): Promise { const tool: ExternalTool = await this.externalToolConfigurationUc.getTemplateForSchoolExternalTool( @@ -107,7 +107,7 @@ export class ToolConfigurationController { type: ContextExternalToolConfigurationTemplateResponse, }) public async getConfigurationTemplateForContext( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ContextExternalToolIdParams ): Promise { const tool: ContextExternalToolTemplateInfo = diff --git a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts index ec102455d06..5977c67cfa6 100644 --- a/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts +++ b/apps/server/src/modules/tool/external-tool/controller/tool.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Query, Res } from '@nestjs/common'; import { ApiCreatedResponse, @@ -51,7 +51,7 @@ export class ToolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates an ExternalTool' }) async createExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() externalToolParams: ExternalToolCreateParams ): Promise { const externalTool: ExternalToolCreate = this.externalToolDOMapper.mapCreateRequest(externalToolParams); @@ -71,7 +71,7 @@ export class ToolController { @ApiForbiddenResponse() @ApiOperation({ summary: 'Returns a list of ExternalTools' }) async findExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() filterQuery: ExternalToolSearchParams, @Query() pagination: PaginationParams, @Query() sortingQuery: SortExternalToolParams @@ -99,7 +99,7 @@ export class ToolController { @Get(':externalToolId') @ApiOperation({ summary: 'Returns an ExternalTool for the given id' }) async getExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ExternalToolIdParams ): Promise { const externalTool: ExternalTool = await this.externalToolUc.getExternalTool( @@ -118,7 +118,7 @@ export class ToolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Updates an ExternalTool' }) async updateExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ExternalToolIdParams, @Body() externalToolParams: ExternalToolUpdateParams ): Promise { @@ -140,7 +140,7 @@ export class ToolController { @ApiOperation({ summary: 'Deletes an ExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ExternalToolIdParams ): Promise { const promise: Promise = this.externalToolUc.deleteExternalTool(currentUser.userId, params.externalToolId); diff --git a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts index 56c0075ae97..1c0899bd183 100644 --- a/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts +++ b/apps/server/src/modules/tool/external-tool/uc/external-tool.uc.spec.ts @@ -1,5 +1,5 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AuthorizationService } from '@modules/authorization'; import { UnauthorizedException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; @@ -68,7 +68,7 @@ describe('ExternalToolUc', () => { const setupAuthorization = () => { const user: User = userFactory.buildWithId(); - const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; authorizationService.getUserWithPermissions.mockResolvedValue(user); @@ -190,7 +190,7 @@ describe('ExternalToolUc', () => { describe('when fetching logo', () => { const setupLogo = () => { const user: User = userFactory.buildWithId(); - const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; const externalTool: ExternalTool = externalToolFactory.buildWithId(); @@ -414,7 +414,7 @@ describe('ExternalToolUc', () => { describe('when fetching logo', () => { const setupLogo = () => { const user: User = userFactory.buildWithId(); - const currentUser: CurrentUserInterface = { userId: user.id } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: user.id } as ICurrentUser; const externalTool: ExternalTool = externalToolFactory.buildWithId(); @@ -439,7 +439,7 @@ describe('ExternalToolUc', () => { describe('deleteExternalTool', () => { const setupDelete = () => { const toolId = 'toolId'; - const currentUser: CurrentUserInterface = { userId: 'userId' } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: 'userId' } as ICurrentUser; const user: User = userFactory.buildWithId(); authorizationService.getUserWithPermissions.mockResolvedValue(user); diff --git a/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts b/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts index 5ef5b4fd8d8..4361d452568 100644 --- a/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts +++ b/apps/server/src/modules/tool/school-external-tool/controller/tool-school.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { ApiBadRequestResponse, @@ -44,7 +44,7 @@ export class ToolSchoolController { @ApiUnauthorizedResponse() @ApiOperation({ summary: 'Returns a list of SchoolExternalTools for a given school' }) async getSchoolExternalTools( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() schoolExternalToolParams: SchoolExternalToolSearchParams ): Promise { const found: SchoolExternalTool[] = await this.schoolExternalToolUc.findSchoolExternalTools(currentUser.userId, { @@ -59,7 +59,7 @@ export class ToolSchoolController { @ApiUnauthorizedResponse() @ApiOperation({ summary: 'Returns a SchoolExternalTool for the given id' }) async getSchoolExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: SchoolExternalToolIdParams ): Promise { const schoolExternalTool: SchoolExternalTool = await this.schoolExternalToolUc.getSchoolExternalTool( @@ -77,7 +77,7 @@ export class ToolSchoolController { @ApiBadRequestResponse({ type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Updates a SchoolExternalTool' }) async updateSchoolExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: SchoolExternalToolIdParams, @Body() body: SchoolExternalToolPostParams ): Promise { @@ -99,7 +99,7 @@ export class ToolSchoolController { @ApiOperation({ summary: 'Deletes a SchoolExternalTool' }) @HttpCode(HttpStatus.NO_CONTENT) async deleteSchoolExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: SchoolExternalToolIdParams ): Promise { await this.schoolExternalToolUc.deleteSchoolExternalTool(currentUser.userId, params.schoolExternalToolId); @@ -119,7 +119,7 @@ export class ToolSchoolController { @ApiResponse({ status: 400, type: ValidationError, description: 'Request data has invalid format.' }) @ApiOperation({ summary: 'Creates a SchoolExternalTool' }) async createSchoolExternalTool( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: SchoolExternalToolPostParams ): Promise { const schoolExternalToolDto: SchoolExternalToolDto = this.requestMapper.mapSchoolExternalToolRequest(body); diff --git a/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts b/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts index a11a61468c0..3ac323b1000 100644 --- a/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts +++ b/apps/server/src/modules/tool/tool-launch/controller/tool-launch.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Controller, Get, Param } from '@nestjs/common'; import { ApiBadRequestResponse, @@ -26,7 +26,7 @@ export class ToolLaunchController { @ApiForbiddenResponse({ description: 'Forbidden' }) @ApiBadRequestResponse({ description: 'Outdated tools cannot be launched' }) async getToolLaunchRequest( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() params: ToolLaunchParams ): Promise { const toolLaunchRequest: ToolLaunchRequest = await this.toolLaunchUc.getToolLaunchRequest( diff --git a/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts b/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts index 2b4e8fc25ee..51bea6b1224 100644 --- a/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts +++ b/apps/server/src/modules/user-import/controller/api-test/import-user.api.spec.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { @@ -48,7 +48,7 @@ import request from 'supertest'; describe('ImportUser Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; const authenticatedUser = async (permissions: Permission[] = [], features: SchoolFeatures[] = []) => { const system = systemFactory.buildWithId(); // TODO no id? diff --git a/apps/server/src/modules/user-import/controller/import-user.controller.ts b/apps/server/src/modules/user-import/controller/import-user.controller.ts index 6f49104c425..bc29f09d6c9 100644 --- a/apps/server/src/modules/user-import/controller/import-user.controller.ts +++ b/apps/server/src/modules/user-import/controller/import-user.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PaginationParams } from '@shared/controller'; @@ -27,7 +27,7 @@ export class ImportUserController { @Get() async findAllImportUsers( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() scope: FilterImportUserParams, @Query() sortingQuery: SortImportUserParams, @Query() pagination: PaginationParams @@ -46,7 +46,7 @@ export class ImportUserController { @Patch(':importUserId/match') async setMatch( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() params: UpdateMatchParams ): Promise { const result = await this.userImportUc.setMatch(currentUser.userId, urlParams.importUserId, params.userId); @@ -58,7 +58,7 @@ export class ImportUserController { @Delete(':importUserId/match') async removeMatch( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const result = await this.userImportUc.removeMatch(currentUser.userId, urlParams.importUserId); const response = ImportUserMapper.mapToResponse(result); @@ -69,7 +69,7 @@ export class ImportUserController { @Patch(':importUserId/flag') async updateFlag( @Param() urlParams: ImportUserUrlParams, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() params: UpdateFlagParams ): Promise { const result = await this.userImportUc.updateFlag(currentUser.userId, urlParams.importUserId, params.flagged); @@ -80,7 +80,7 @@ export class ImportUserController { @Get('unassigned') async findAllUnmatchedUsers( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query() scope: FilterUserParams, @Query() pagination: PaginationParams ): Promise { @@ -96,20 +96,20 @@ export class ImportUserController { } @Post('migrate') - async saveAllUsersMatches(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async saveAllUsersMatches(@CurrentUser() currentUser: ICurrentUser): Promise { await this.userImportUc.saveAllUsersMatches(currentUser.userId); } @Post('startUserMigration') async startSchoolInUserMigration( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Query('useCentralLdap') useCentralLdap?: boolean ): Promise { await this.userImportUc.startSchoolInUserMigration(currentUser.userId, useCentralLdap); } @Post('startSync') - async endSchoolInMaintenance(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async endSchoolInMaintenance(@CurrentUser() currentUser: ICurrentUser): Promise { await this.userImportUc.endSchoolInMaintenance(currentUser.userId); } } diff --git a/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts b/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts index 3f218f2c7a2..5489e33e3a4 100644 --- a/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts +++ b/apps/server/src/modules/user-login-migration/controller/user-login-migration.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface, JWT } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser, JWT } from '@modules/authentication'; import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common'; import { ApiForbiddenResponse, @@ -57,7 +57,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'UserLoginMigrations has been found.', type: UserLoginMigrationSearchListResponse }) @ApiInternalServerErrorResponse({ description: 'Cannot find target system information.' }) async getMigrations( - @CurrentUser() user: CurrentUserInterface, + @CurrentUser() user: ICurrentUser, @Query() params: UserLoginMigrationSearchParams ): Promise { const userLoginMigrationQuery: UserLoginMigrationQuery = UserLoginMigrationMapper.mapSearchParamsToQuery(params); @@ -87,7 +87,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'UserLoginMigrations has been found', type: UserLoginMigrationResponse }) @ApiNotFoundResponse({ description: 'Cannot find UserLoginMigration' }) async findUserLoginMigrationBySchool( - @CurrentUser() user: CurrentUserInterface, + @CurrentUser() user: ICurrentUser, @Param() params: SchoolIdParams ): Promise { const userLoginMigration: UserLoginMigrationDO = await this.userLoginMigrationUc.findUserLoginMigrationBySchool( @@ -112,7 +112,7 @@ export class UserLoginMigrationController { }) @ApiOkResponse({ description: 'User login migration started', type: UserLoginMigrationResponse }) @ApiForbiddenResponse() - async startMigration(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async startMigration(@CurrentUser() currentUser: ICurrentUser): Promise { const migrationDto: UserLoginMigrationDO = await this.startUserLoginMigrationUc.startMigration( currentUser.userId, currentUser.schoolId @@ -136,7 +136,7 @@ export class UserLoginMigrationController { @ApiOkResponse({ description: 'User login migration started', type: UserLoginMigrationResponse }) @ApiUnauthorizedResponse() @ApiForbiddenResponse() - async restartMigration(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async restartMigration(@CurrentUser() currentUser: ICurrentUser): Promise { const migrationDto: UserLoginMigrationDO = await this.restartUserLoginMigrationUc.restartMigration( currentUser.userId, currentUser.schoolId @@ -165,7 +165,7 @@ export class UserLoginMigrationController { @ApiUnauthorizedResponse() @ApiForbiddenResponse() async setMigrationMandatory( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: UserLoginMigrationMandatoryParams ): Promise { const migrationDto: UserLoginMigrationDO = await this.toggleUserLoginMigrationUc.setMigrationMandatory( @@ -198,9 +198,7 @@ export class UserLoginMigrationController { @ApiUnauthorizedResponse() @ApiForbiddenResponse() @ApiNoContentResponse({ description: 'User login migration was reverted' }) - async closeMigration( - @CurrentUser() currentUser: CurrentUserInterface - ): Promise { + async closeMigration(@CurrentUser() currentUser: ICurrentUser): Promise { const userLoginMigration: UserLoginMigrationDO | undefined = await this.closeUserLoginMigrationUc.closeMigration( currentUser.userId, currentUser.schoolId @@ -219,7 +217,7 @@ export class UserLoginMigrationController { @ApiInternalServerErrorResponse({ description: 'The migration of the User was not possible.' }) async migrateUserLogin( @JWT() jwt: string, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Body() body: Oauth2MigrationParams ): Promise { await this.userLoginMigrationUc.migrate(jwt, currentUser.userId, body.systemId, body.code, body.redirectUri); diff --git a/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts b/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts index c8f19e289fb..50b1c08f8d9 100644 --- a/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts +++ b/apps/server/src/modules/user/controller/api-test/user-language.api.spec.ts @@ -2,7 +2,7 @@ import { EntityManager } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ApiValidationError } from '@shared/common'; @@ -85,7 +85,7 @@ describe(baseRouteName, () => { describe('with bad request data', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { @@ -139,7 +139,7 @@ describe(baseRouteName, () => { describe('without valid request data', () => { let app: INestApplication; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts b/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts index 3e89c362d0c..c77f23f2e59 100644 --- a/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts +++ b/apps/server/src/modules/user/controller/api-test/user-me.api.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { Request } from 'express'; import request from 'supertest'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { JwtAuthGuard } from '@modules/authentication/guard/jwt-auth.guard'; import { ServerTestModule } from '@modules/server/server.module'; import { ResolvedUserResponse } from '@modules/user/controller/dto'; @@ -87,7 +87,7 @@ describe(baseRouteName, () => { let app: INestApplication; let orm: MikroORM; let em: EntityManager; - let currentUser: CurrentUserInterface; + let currentUser: ICurrentUser; let api: API; beforeAll(async () => { diff --git a/apps/server/src/modules/user/controller/user.controller.ts b/apps/server/src/modules/user/controller/user.controller.ts index 5261898b3fa..1d3739b3144 100644 --- a/apps/server/src/modules/user/controller/user.controller.ts +++ b/apps/server/src/modules/user/controller/user.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Get, Patch } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { ResolvedUserMapper } from '../mapper'; @@ -12,7 +12,7 @@ export class UserController { constructor(private readonly userUc: UserUc) {} @Get('me') - async me(@CurrentUser() currentUser: CurrentUserInterface): Promise { + async me(@CurrentUser() currentUser: ICurrentUser): Promise { const [user, permissions] = await this.userUc.me(currentUser.userId); // only the root roles of the user get published @@ -24,7 +24,7 @@ export class UserController { @Patch('/language') async changeLanguage( @Body() params: ChangeLanguageParams, - @CurrentUser() currentUser: CurrentUserInterface + @CurrentUser() currentUser: ICurrentUser ): Promise { const result = await this.userUc.patchLanguage(currentUser.userId, params); diff --git a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts index a2411336426..01a62786582 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.spec.ts @@ -1,6 +1,6 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { Test, TestingModule } from '@nestjs/testing'; import { VideoConferenceScope } from '@shared/domain/interface'; import { BBBBaseResponse, BBBCreateResponse } from '../bbb'; @@ -18,7 +18,7 @@ describe('VideoConferenceDeprecatedController', () => { let controller: VideoConferenceDeprecatedController; let videoConferenceUc: DeepMocked; - const currentUser: CurrentUserInterface = { userId: new ObjectId().toHexString() } as CurrentUserInterface; + const currentUser: ICurrentUser = { userId: new ObjectId().toHexString() } as ICurrentUser; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts index db130c87288..d32273b98f7 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference-deprecated.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { BadRequestException, Body, @@ -44,7 +44,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async createAndJoin( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string, @Body() params: VideoConferenceCreateParams @@ -84,7 +84,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async info( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string ): Promise { @@ -104,7 +104,7 @@ export class VideoConferenceDeprecatedController { }) @ApiResponse({ status: 500, type: InternalServerErrorException, description: 'Unable to fetch required data.' }) async end( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param('scope') scope: VideoConferenceScope, @Param('scopeId') scopeId: string ): Promise { diff --git a/apps/server/src/modules/video-conference/controller/video-conference.controller.ts b/apps/server/src/modules/video-conference/controller/video-conference.controller.ts index 062b4c27ec5..b55eac17f64 100644 --- a/apps/server/src/modules/video-conference/controller/video-conference.controller.ts +++ b/apps/server/src/modules/video-conference/controller/video-conference.controller.ts @@ -1,4 +1,4 @@ -import { Authenticate, CurrentUser, CurrentUserInterface } from '@modules/authentication'; +import { Authenticate, CurrentUser, ICurrentUser } from '@modules/authentication'; import { Body, Controller, Get, HttpStatus, Param, Put, Req } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { Request } from 'express'; @@ -43,7 +43,7 @@ export class VideoConferenceController { @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async start( @Req() req: Request, - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() scopeParams: VideoConferenceScopeParams, @Body() params: VideoConferenceCreateParams ): Promise { @@ -75,7 +75,7 @@ export class VideoConferenceController { }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async join( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() scopeParams: VideoConferenceScopeParams ): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); @@ -103,7 +103,7 @@ export class VideoConferenceController { }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) async info( - @CurrentUser() currentUser: CurrentUserInterface, + @CurrentUser() currentUser: ICurrentUser, @Param() scopeParams: VideoConferenceScopeParams ): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); @@ -129,10 +129,7 @@ export class VideoConferenceController { description: 'User does not have the permission to end this conference.', }) @ApiResponse({ status: HttpStatus.INTERNAL_SERVER_ERROR, description: 'Unable to fetch required data.' }) - async end( - @CurrentUser() currentUser: CurrentUserInterface, - @Param() scopeParams: VideoConferenceScopeParams - ): Promise { + async end(@CurrentUser() currentUser: ICurrentUser, @Param() scopeParams: VideoConferenceScopeParams): Promise { const scopeRef = new ScopeRef(scopeParams.scopeId, scopeParams.scope); await this.videoConferenceEndUc.end(currentUser.userId, scopeRef); 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 0b745dfd90c..a8caf8f2dc9 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 @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { CalendarService } from '@infra/calendar'; import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { AuthorizationReferenceService } from '@modules/authorization/domain'; import { CourseService } from '@modules/learnroom/service'; import { LegacySchoolService } from '@modules/legacy-school'; @@ -81,7 +81,7 @@ describe('VideoConferenceUc', () => { teamId: 'teamId', }); let featureEnabled = false; - let defaultCurrentUser: CurrentUserInterface; + let defaultCurrentUser: ICurrentUser; let defaultOptions: VideoConferenceOptions; const userPermissions: Map> = new Map>(); 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 e0de32b730f..14d8b594fb9 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 @@ -1,7 +1,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { CalendarService } from '@infra/calendar'; import { CalendarEventDto } from '@infra/calendar/dto/calendar-event.dto'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { Action, AuthorizationContextBuilder } from '@modules/authorization'; import { AuthorizableReferenceType, AuthorizationReferenceService } from '@modules/authorization/domain'; import { CourseService } from '@modules/learnroom'; @@ -71,14 +71,14 @@ export class VideoConferenceDeprecatedUc { /** * Creates a new video conference. - * @param {CurrentUserInterface} currentUser + * @param {ICurrentUser} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @param {VideoConferenceOptions} options * @returns {Promise>} */ async create( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, conferenceScope: VideoConferenceScope, refId: EntityId, options: VideoConferenceOptions @@ -136,13 +136,13 @@ export class VideoConferenceDeprecatedUc { /** * Generates a join link for a video conference. - * @param {CurrentUserInterface} currentUser + * @param {ICurrentUser} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {Promise} */ async join( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise { @@ -191,13 +191,13 @@ export class VideoConferenceDeprecatedUc { /** * Retrieves information about a video conference. - * @param {CurrentUserInterface} currentUser + * @param {ICurrentUser} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {BBBResponse} */ async getMeetingInfo( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise { @@ -268,13 +268,13 @@ export class VideoConferenceDeprecatedUc { /** * Ends a video conference. - * @param {CurrentUserInterface} currentUser + * @param {ICurrentUser} currentUser * @param {VideoConferenceScope} conferenceScope * @param {EntityId} refId eventId or courseId, depending on scope. * @returns {Promise>} */ async end( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, conferenceScope: VideoConferenceScope, refId: EntityId ): Promise> { @@ -304,7 +304,7 @@ export class VideoConferenceDeprecatedUc { } protected async isExpert( - currentUser: CurrentUserInterface, + currentUser: ICurrentUser, conferenceScope: VideoConferenceScope, scopeId: string ): Promise { diff --git a/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts b/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts index 29eae6c3567..4e3c256733f 100644 --- a/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts +++ b/apps/server/src/shared/common/interceptor/request-logging.interceptor.ts @@ -1,4 +1,4 @@ -import { CurrentUserInterface } from '@modules/authentication/interface/user'; +import { ICurrentUser } from '@modules/authentication/interface/user'; import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; import { LegacyLogger, RequestLoggingBody } from '@src/core/logger'; import { Request } from 'express'; @@ -13,7 +13,7 @@ export class RequestLoggingInterceptor implements NestInterceptor { this.logger.setContext(`${context.getClass().name}::${context.getHandler().name}()`); const req: Request = context.switchToHttp().getRequest(); - const currentUser = req.user as CurrentUserInterface; + const currentUser = req.user as ICurrentUser; const logging: RequestLoggingBody = { userId: currentUser.userId, request: { diff --git a/apps/server/src/shared/testing/map-user-to-current-user.ts b/apps/server/src/shared/testing/map-user-to-current-user.ts index 7974894d1d2..3c6a1eadc27 100644 --- a/apps/server/src/shared/testing/map-user-to-current-user.ts +++ b/apps/server/src/shared/testing/map-user-to-current-user.ts @@ -1,5 +1,5 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { CurrentUserInterface } from '@modules/authentication'; +import { ICurrentUser } from '@modules/authentication'; import { Account, EntityId, User } from '@shared/domain'; export const mapUserToCurrentUser = ( @@ -7,8 +7,8 @@ export const mapUserToCurrentUser = ( account?: Account, systemId?: EntityId, impersonated?: boolean -): CurrentUserInterface => { - const currentUser: CurrentUserInterface = { +): ICurrentUser => { + const currentUser: ICurrentUser = { userId: user.id, roles: user.roles.getItems().map((r) => r.id), schoolId: user.school.id, From 1b9eeaea95d1218febe7ce8c70d36881db6deea6 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:04:57 +0100 Subject: [PATCH 096/110] LegacyLoggerInterface -> ILegacyLogger --- .../src/core/logger/interfaces/legacy-logger.interface.ts | 2 +- apps/server/src/core/logger/legacy-logger.service.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts b/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts index b27fb122991..5f88f503de1 100644 --- a/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts +++ b/apps/server/src/core/logger/interfaces/legacy-logger.interface.ts @@ -7,7 +7,7 @@ export type RequestLoggingBody = { /** * @deprecated The new logger for loggables should be used. */ -export interface LegacyLoggerInterface { +export interface ILegacyLogger { http(message: RequestLoggingBody, context?: string): void; log(message: unknown, context?: string): void; error(message: unknown, trace?: string, context?: string): void; diff --git a/apps/server/src/core/logger/legacy-logger.service.ts b/apps/server/src/core/logger/legacy-logger.service.ts index 91a6defc1f8..e8b8139e041 100644 --- a/apps/server/src/core/logger/legacy-logger.service.ts +++ b/apps/server/src/core/logger/legacy-logger.service.ts @@ -3,7 +3,7 @@ import { WINSTON_MODULE_PROVIDER } from 'nest-winston'; import util from 'util'; import { Logger as WinstonLogger } from 'winston'; import { RequestLoggingBody } from './interfaces'; -import { LegacyLoggerInterface } from './interfaces/legacy-logger.interface'; +import { ILegacyLogger } from './interfaces/legacy-logger.interface'; @Injectable({ scope: Scope.TRANSIENT }) /** @@ -12,7 +12,7 @@ import { LegacyLoggerInterface } from './interfaces/legacy-logger.interface'; * Must implement ILegacyLogger but must not extend ConsoleLogger (this can be changed). * Transient injection: Wherever injected, a separate instance will be created, that can be provided with a custom context. */ -export class LegacyLogger implements LegacyLoggerInterface { +export class LegacyLogger implements ILegacyLogger { /** * This Logger Service can be injected into every Class, * use setContext() with CustomProviderClass.name that will be added to every log. From bcc1c17b3a390ab700b3b478f8c43160f2c47b1c Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:06:13 +0100 Subject: [PATCH 097/110] KeycloakSettingsInterface -> IKeycloakSettings --- .../interface/keycloak-settings.interface.ts | 2 +- .../keycloak-administration/keycloak-config.ts | 6 +++--- .../service/keycloak-administration.service.spec.ts | 6 +++--- .../service/keycloak-administration.service.ts | 4 ++-- .../service/keycloak-configuration.service.spec.ts | 6 +++--- .../service/keycloak-seed.service.spec.ts | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts b/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts index ebb0c55521a..6c0b3205669 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/interface/keycloak-settings.interface.ts @@ -1,6 +1,6 @@ export const KeycloakSettings = Symbol('KeycloakSettings'); -export interface KeycloakSettingsInterface { +export interface IKeycloakSettings { baseUrl: string; realmName: string; clientId: string; diff --git a/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts index f90786ed287..0565ed0b2be 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/keycloak-config.ts @@ -1,5 +1,5 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { KeycloakSettingsInterface } from './interface/keycloak-settings.interface'; +import { IKeycloakSettings } from './interface/keycloak-settings.interface'; export default class KeycloakAdministration { static keycloakSettings = (Configuration.get('FEATURE_IDENTITY_MANAGEMENT_ENABLED') as boolean) @@ -13,6 +13,6 @@ export default class KeycloakAdministration { password: Configuration.get('IDENTITY_MANAGEMENT__ADMIN_PASSWORD') as string, clientId: Configuration.get('IDENTITY_MANAGEMENT__ADMIN_CLIENTID') as string, }, - } as KeycloakSettingsInterface) - : ({} as KeycloakSettingsInterface); + } as IKeycloakSettings) + : ({} as IKeycloakSettings); } diff --git a/apps/server/src/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 index cb153fb6ea7..77e372bdc45 100644 --- a/apps/server/src/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 @@ -2,18 +2,18 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import { Clients } from '@keycloak/keycloak-admin-client/lib/resources/clients'; import { Test, TestingModule } from '@nestjs/testing'; -import { KeycloakSettings, KeycloakSettingsInterface } from '../interface/keycloak-settings.interface'; +import { IKeycloakSettings, KeycloakSettings } from '../interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from './keycloak-administration.service'; describe('KeycloakAdministrationService', () => { let module: TestingModule; let kcAdminClient: DeepMocked; - let settings: KeycloakSettingsInterface; + let settings: IKeycloakSettings; let service: KeycloakAdministrationService; const kcApiClientMock = createMock(); - const getSettings = (): KeycloakSettingsInterface => { + const getSettings = (): IKeycloakSettings => { return { baseUrl: 'http://localhost:8080', realmName: 'master', diff --git a/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts index 3f087446d41..a953d0b558a 100644 --- a/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-administration/service/keycloak-administration.service.ts @@ -1,6 +1,6 @@ import KeycloakAdminClient from '@keycloak/keycloak-admin-client-cjs/keycloak-admin-client-cjs-index'; import { Inject, Injectable } from '@nestjs/common'; -import { KeycloakSettings, KeycloakSettingsInterface } from '../interface/keycloak-settings.interface'; +import { IKeycloakSettings, KeycloakSettings } from '../interface/keycloak-settings.interface'; @Injectable() export class KeycloakAdministrationService { @@ -10,7 +10,7 @@ export class KeycloakAdministrationService { public constructor( private readonly kcAdminClient: KeycloakAdminClient, - @Inject(KeycloakSettings) private readonly kcSettings: KeycloakSettingsInterface + @Inject(KeycloakSettings) private readonly kcSettings: IKeycloakSettings ) { this.kcAdminClient.setConfig({ baseUrl: kcSettings.baseUrl, diff --git a/apps/server/src/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 index 4c24ad34e50..0b47e876ba0 100644 --- a/apps/server/src/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 @@ -18,8 +18,8 @@ import { AxiosResponse } from 'axios'; import { of } from 'rxjs'; import { v1 } from 'uuid'; import { + IKeycloakSettings, KeycloakSettings, - KeycloakSettingsInterface, } from '../../keycloak-administration/interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; import { OidcIdentityProviderMapper } from '../mapper/identity-provider.mapper'; @@ -32,7 +32,7 @@ describe('KeycloakConfigurationService Unit', () => { let configService: DeepMocked; let systemOidcService: DeepMocked; let httpServiceMock: DeepMocked; - let settings: KeycloakSettingsInterface; + let settings: IKeycloakSettings; const kcApiClientIdentityProvidersMock = createMock(); const kcApiClientMock = createMock(); @@ -49,7 +49,7 @@ describe('KeycloakConfigurationService Unit', () => { username: adminUsername, }; - const getSettings = (): KeycloakSettingsInterface => { + const getSettings = (): IKeycloakSettings => { return { baseUrl: 'http://localhost:8080', realmName: 'master', diff --git a/apps/server/src/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 index 70e71bfc76f..29de0fba836 100644 --- a/apps/server/src/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 @@ -7,8 +7,8 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LegacyLogger } from '@src/core/logger'; import { v1 } from 'uuid'; import { + IKeycloakSettings, KeycloakSettings, - KeycloakSettingsInterface, } from '../../keycloak-administration/interface/keycloak-settings.interface'; import { KeycloakAdministrationService } from '../../keycloak-administration/service/keycloak-administration.service'; import { JsonAccount } from '../interface/json-account.interface'; @@ -42,7 +42,7 @@ describe('KeycloakSeedService', () => { let module: TestingModule; let serviceUnderTest: KeycloakSeedService; let logger: DeepMocked; - let settings: KeycloakSettingsInterface; + let settings: IKeycloakSettings; let infoLogSpy: jest.SpyInstance; let errorLogSpy: jest.SpyInstance; From 0787195ff8c5255baa3ac3a622bedc49726548bc Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:07:26 +0100 Subject: [PATCH 098/110] KeycloakConfigurationInputFilesInterface -> IKeycloakConfigurationInputFiles --- .../interface/keycloak-configuration-input-files.interface.ts | 2 +- .../keycloak-configuration/keycloak-config.ts | 4 ++-- .../service/keycloak-seed.service.spec.ts | 4 ++-- .../keycloak-configuration/service/keycloak-seed.service.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/server/src/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 index 5725f67714b..f5568c29481 100644 --- a/apps/server/src/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 @@ -1,6 +1,6 @@ export const KeycloakConfigurationInputFiles = Symbol('KeycloakConfigurationInputFiles'); -export interface KeycloakConfigurationInputFilesInterface { +export interface IKeycloakConfigurationInputFiles { accountsFile: string; usersFile: string; } diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts index 34842ab1d26..ed51cff7d8d 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/keycloak-config.ts @@ -1,7 +1,7 @@ -import { KeycloakConfigurationInputFilesInterface } from './interface/keycloak-configuration-input-files.interface'; +import { IKeycloakConfigurationInputFiles } from './interface/keycloak-configuration-input-files.interface'; export default class KeycloakConfiguration { - static keycloakInputFiles: KeycloakConfigurationInputFilesInterface = { + static keycloakInputFiles: IKeycloakConfigurationInputFiles = { accountsFile: './backup/setup/accounts.json', usersFile: './backup/setup/users.json', }; diff --git a/apps/server/src/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 index 29de0fba836..f94513c1bd5 100644 --- a/apps/server/src/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 @@ -14,8 +14,8 @@ import { KeycloakAdministrationService } from '../../keycloak-administration/ser import { JsonAccount } from '../interface/json-account.interface'; import { JsonUser } from '../interface/json-user.interface'; import { + IKeycloakConfigurationInputFiles, KeycloakConfigurationInputFiles, - KeycloakConfigurationInputFilesInterface, } from '../interface/keycloak-configuration-input-files.interface'; import { KeycloakSeedService } from './keycloak-seed.service'; @@ -98,7 +98,7 @@ describe('KeycloakSeedService', () => { username: 'notUnique', }, ]; - const inputFiles: KeycloakConfigurationInputFilesInterface = { + const inputFiles: IKeycloakConfigurationInputFiles = { accountsFile: 'accounts.json', usersFile: 'users.json', }; diff --git a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts index 6a435477f96..5ba3071c2b4 100644 --- a/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts +++ b/apps/server/src/infra/identity-management/keycloak-configuration/service/keycloak-seed.service.ts @@ -6,15 +6,15 @@ import { KeycloakAdministrationService } from '../../keycloak-administration/ser import { JsonAccount } from '../interface/json-account.interface'; import { JsonUser } from '../interface/json-user.interface'; import { + IKeycloakConfigurationInputFiles, KeycloakConfigurationInputFiles, - KeycloakConfigurationInputFilesInterface, } from '../interface/keycloak-configuration-input-files.interface'; export class KeycloakSeedService { constructor( private readonly kcAdmin: KeycloakAdministrationService, private readonly logger: LegacyLogger, - @Inject(KeycloakConfigurationInputFiles) private readonly inputFiles: KeycloakConfigurationInputFilesInterface + @Inject(KeycloakConfigurationInputFiles) private readonly inputFiles: IKeycloakConfigurationInputFiles ) {} async seed(): Promise { From e95966efdbd271572b34098cc1d540990f6a9be7 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:09:04 +0100 Subject: [PATCH 099/110] ErrorInterface -> IError --- .../src/core/error/filter/global-error.filter.ts | 4 ++-- apps/server/src/infra/rabbitmq/error.mapper.spec.ts | 10 +++++----- apps/server/src/infra/rabbitmq/error.mapper.ts | 4 ++-- apps/server/src/infra/rabbitmq/rpc-message.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) 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 7c3943b4e30..068e7bcca8a 100644 --- a/apps/server/src/core/error/filter/global-error.filter.ts +++ b/apps/server/src/core/error/filter/global-error.filter.ts @@ -1,4 +1,4 @@ -import { ErrorInterface, RpcMessage } from '@infra/rabbitmq/rpc-message'; +import { IError, RpcMessage } from '@infra/rabbitmq/rpc-message'; import { ArgumentsHost, Catch, ExceptionFilter, HttpException, InternalServerErrorException } from '@nestjs/common'; import { ApiValidationError, BusinessError } from '@shared/common'; import { ErrorLogger, Loggable } from '@src/core/logger'; @@ -12,7 +12,7 @@ import { ErrorLoggable } from '../loggable/error.loggable'; import { ErrorUtils } from '../utils'; @Catch() -export class GlobalErrorFilter implements ExceptionFilter { +export class GlobalErrorFilter implements ExceptionFilter { constructor(private readonly logger: ErrorLogger) {} // eslint-disable-next-line consistent-return diff --git a/apps/server/src/infra/rabbitmq/error.mapper.spec.ts b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts index 9ecdc45af5f..33dabb8acf8 100644 --- a/apps/server/src/infra/rabbitmq/error.mapper.spec.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.spec.ts @@ -1,4 +1,4 @@ -import { ErrorInterface } from '@infra/rabbitmq'; +import { IError } from '@infra/rabbitmq'; import { BadRequestException, ConflictException, @@ -13,7 +13,7 @@ describe('ErrorMapper', () => { it('Should map any 400 error to BadRequestException.', () => { const errorText = 'BadRequestException ABC'; const e = new BadRequestException(errorText); - const json = _.toPlainObject(e) as ErrorInterface; + const json = _.toPlainObject(e) as IError; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); @@ -22,7 +22,7 @@ describe('ErrorMapper', () => { it('Should map 403 error response to ForbiddenException.', () => { const errorText = 'ForbiddenException ABC'; - const rpcResponseError = _.toPlainObject(new ForbiddenException(errorText)) as ErrorInterface; + const rpcResponseError = _.toPlainObject(new ForbiddenException(errorText)) as IError; const result = ErrorMapper.mapRpcErrorResponseToDomainError(rpcResponseError); @@ -31,7 +31,7 @@ describe('ErrorMapper', () => { it('Should map 500 error response to InternalServerErrorException.', () => { const errorText = 'InternalServerErrorException ABC'; - const json = _.toPlainObject(new InternalServerErrorException(errorText)) as ErrorInterface; + const json = _.toPlainObject(new InternalServerErrorException(errorText)) as IError; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); @@ -40,7 +40,7 @@ describe('ErrorMapper', () => { it('Should map unknown error code to InternalServerErrorException.', () => { const errorText = 'Any error text'; - const json = _.toPlainObject(new ConflictException(errorText)) as ErrorInterface; + const json = _.toPlainObject(new ConflictException(errorText)) as IError; const result = ErrorMapper.mapRpcErrorResponseToDomainError(json); diff --git a/apps/server/src/infra/rabbitmq/error.mapper.ts b/apps/server/src/infra/rabbitmq/error.mapper.ts index cacd539cdc6..dcee0654e10 100644 --- a/apps/server/src/infra/rabbitmq/error.mapper.ts +++ b/apps/server/src/infra/rabbitmq/error.mapper.ts @@ -1,10 +1,10 @@ -import { ErrorInterface } from '@infra/rabbitmq'; +import { IError } from '@infra/rabbitmq'; import { BadRequestException, ForbiddenException, InternalServerErrorException } from '@nestjs/common'; import { ErrorUtils } from '@src/core/error/utils'; export class ErrorMapper { static mapRpcErrorResponseToDomainError( - errorObj: ErrorInterface + errorObj: IError ): BadRequestException | ForbiddenException | InternalServerErrorException { let error: BadRequestException | ForbiddenException | InternalServerErrorException; if (errorObj.status === 400) { diff --git a/apps/server/src/infra/rabbitmq/rpc-message.ts b/apps/server/src/infra/rabbitmq/rpc-message.ts index fefaf34c4e0..c7e0e7de41f 100644 --- a/apps/server/src/infra/rabbitmq/rpc-message.ts +++ b/apps/server/src/infra/rabbitmq/rpc-message.ts @@ -1,8 +1,8 @@ -export interface ErrorInterface extends Error { +export interface IError extends Error { status?: number; message: string; } export interface RpcMessage { message: T; - error?: ErrorInterface; + error?: IError; } From 1f191ce632907a9edd6e325da737bf71b73961f3 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:12:05 +0100 Subject: [PATCH 100/110] ICommonCartridgeOrganizationBuilderInterface -> ICommonCartridgeOrganizationBuilder --- .../common-cartridge-file-builder.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts index f0a13c98fdd..cc7ea429111 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts @@ -20,19 +20,19 @@ export type CommonCartridgeFileBuilderOptions = { version: CommonCartridgeVersion; }; -export interface CommonCartridgeOrganizationBuilderInterface { - addResourceToOrganization(props: ICommonCartridgeResourceProps): CommonCartridgeOrganizationBuilderInterface; +export interface ICommonCartridgeOrganizationBuilder { + addResourceToOrganization(props: ICommonCartridgeResourceProps): ICommonCartridgeOrganizationBuilder; } export interface CommonCartridgeFileBuilderInterface { - addOrganization(props: ICommonCartridgeOrganizationProps): CommonCartridgeOrganizationBuilderInterface; + addOrganization(props: ICommonCartridgeOrganizationProps): ICommonCartridgeOrganizationBuilder; addResourceToFile(props: ICommonCartridgeResourceProps): CommonCartridgeFileBuilderInterface; build(): Promise; } -class CommonCartridgeOrganizationBuilder implements CommonCartridgeOrganizationBuilderInterface { +class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganizationBuilder { constructor( private readonly props: ICommonCartridgeOrganizationProps, private readonly xmlBuilder: Builder, @@ -49,7 +49,7 @@ class CommonCartridgeOrganizationBuilder implements CommonCartridgeOrganizationB ); } - addResourceToOrganization(props: ICommonCartridgeResourceProps): CommonCartridgeOrganizationBuilderInterface { + addResourceToOrganization(props: ICommonCartridgeResourceProps): ICommonCartridgeOrganizationBuilder { const newResource = new CommonCartridgeResourceItemElement(props, this.xmlBuilder); this.props.resources.push(props); if (!newResource.canInline()) { @@ -70,7 +70,7 @@ export class CommonCartridgeFileBuilder implements CommonCartridgeFileBuilderInt constructor(private readonly options: CommonCartridgeFileBuilderOptions) {} - addOrganization(props: ICommonCartridgeOrganizationProps): CommonCartridgeOrganizationBuilderInterface { + addOrganization(props: ICommonCartridgeOrganizationProps): ICommonCartridgeOrganizationBuilder { const organizationBuilder = new CommonCartridgeOrganizationBuilder(props, this.xmlBuilder, this.zipBuilder); this.organizations.push(organizationBuilder); return organizationBuilder; From 1496805f6be092f6b4ae9ff03e9a595d26898c6f Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:13:05 +0100 Subject: [PATCH 101/110] CommonCartridgeFileBuilderInterface -> ICommonCartridgeFileBuilder --- .../common-cartridge/common-cartridge-file-builder.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts index cc7ea429111..5a40269c57b 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-file-builder.ts @@ -24,10 +24,10 @@ export interface ICommonCartridgeOrganizationBuilder { addResourceToOrganization(props: ICommonCartridgeResourceProps): ICommonCartridgeOrganizationBuilder; } -export interface CommonCartridgeFileBuilderInterface { +export interface ICommonCartridgeFileBuilder { addOrganization(props: ICommonCartridgeOrganizationProps): ICommonCartridgeOrganizationBuilder; - addResourceToFile(props: ICommonCartridgeResourceProps): CommonCartridgeFileBuilderInterface; + addResourceToFile(props: ICommonCartridgeResourceProps): ICommonCartridgeFileBuilder; build(): Promise; } @@ -59,7 +59,7 @@ class CommonCartridgeOrganizationBuilder implements ICommonCartridgeOrganization } } -export class CommonCartridgeFileBuilder implements CommonCartridgeFileBuilderInterface { +export class CommonCartridgeFileBuilder implements ICommonCartridgeFileBuilder { private readonly xmlBuilder = new Builder(); private readonly zipBuilder = new AdmZip(); @@ -76,7 +76,7 @@ export class CommonCartridgeFileBuilder implements CommonCartridgeFileBuilderInt return organizationBuilder; } - addResourceToFile(props: ICommonCartridgeResourceProps): CommonCartridgeFileBuilderInterface { + addResourceToFile(props: ICommonCartridgeResourceProps): ICommonCartridgeFileBuilder { const resource = new CommonCartridgeResourceItemElement(props, this.xmlBuilder); if (!resource.canInline()) { this.zipBuilder.addFile(props.href, Buffer.from(resource.content())); From a250f224c391df2a2c7cbdb1c27e94b8a6741f20 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:14:16 +0100 Subject: [PATCH 102/110] ToolFeaturesInterface -> IToolFeatures --- .../service/oauth-provider.login-flow.service.spec.ts | 4 ++-- .../service/oauth-provider.login-flow.service.ts | 4 ++-- .../service/tool-version-service.spec.ts | 4 ++-- .../context-external-tool/service/tool-version-service.ts | 4 ++-- .../service/external-tool-configuration.service.spec.ts | 4 ++-- .../service/external-tool-configuration.service.ts | 4 ++-- .../external-tool/service/external-tool-logo-service.spec.ts | 4 ++-- .../tool/external-tool/service/external-tool-logo.service.ts | 4 ++-- .../service/external-tool-validation.service.spec.ts | 4 ++-- .../service/school-external-tool-validation.service.spec.ts | 4 ++-- .../service/school-external-tool-validation.service.ts | 4 ++-- .../service/school-external-tool.service.spec.ts | 4 ++-- .../service/school-external-tool.service.ts | 4 ++-- apps/server/src/modules/tool/tool-config.ts | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts index b096b0bc1e6..052f3f1c6a2 100644 --- a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts +++ b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { LtiToolService } from '@modules/lti-tool'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { ExternalToolService } from '@modules/tool/external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '@modules/tool/tool-config'; +import { IToolFeatures, ToolFeatures } from '@modules/tool/tool-config'; import { NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { LtiToolDO } from '@shared/domain'; @@ -15,7 +15,7 @@ describe('OauthProviderLoginFlowService', () => { let ltiToolService: DeepMocked; let externalToolService: DeepMocked; - let toolFeatures: ToolFeaturesInterface; + let toolFeatures: IToolFeatures; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts index f82072ff847..adf363415fd 100644 --- a/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts +++ b/apps/server/src/modules/oauth-provider/service/oauth-provider.login-flow.service.ts @@ -1,7 +1,7 @@ import { LtiToolService } from '@modules/lti-tool/service'; import { ExternalTool } from '@modules/tool/external-tool/domain'; import { ExternalToolService } from '@modules/tool/external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '@modules/tool/tool-config'; +import { IToolFeatures, ToolFeatures } from '@modules/tool/tool-config'; import { Inject } from '@nestjs/common'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; import { NotFoundException } from '@nestjs/common/exceptions/not-found.exception'; @@ -12,7 +12,7 @@ export class OauthProviderLoginFlowService { constructor( private readonly ltiToolService: LtiToolService, private readonly externalToolService: ExternalToolService, - @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface + @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures ) {} public async findToolByClientId(clientId: string): Promise { diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts index 1dcf15f91b5..87f96a096d2 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.spec.ts @@ -5,7 +5,7 @@ import { contextExternalToolFactory, externalToolFactory, schoolExternalToolFact import { ToolConfigurationStatus } from '../../common/enum'; import { CommonToolService } from '../../common/service'; import { SchoolExternalToolValidationService } from '../../school-external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ContextExternalToolValidationService } from './context-external-tool-validation.service'; import { ToolVersionService } from './tool-version-service'; @@ -16,7 +16,7 @@ describe('ToolVersionService', () => { let contextExternalToolValidationService: DeepMocked; let schoolExternalToolValidationService: DeepMocked; let commonToolService: DeepMocked; - let toolFeatures: DeepMocked; + let toolFeatures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts index 96d65acddea..91c77a1aa98 100644 --- a/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts +++ b/apps/server/src/modules/tool/context-external-tool/service/tool-version-service.ts @@ -5,7 +5,7 @@ import { CommonToolService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { SchoolExternalTool } from '../../school-external-tool/domain'; import { SchoolExternalToolValidationService } from '../../school-external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ContextExternalTool } from '../domain'; import { ContextExternalToolValidationService } from './context-external-tool-validation.service'; @@ -15,7 +15,7 @@ export class ToolVersionService { private readonly contextExternalToolValidationService: ContextExternalToolValidationService, private readonly schoolExternalToolValidationService: SchoolExternalToolValidationService, private readonly commonToolService: CommonToolService, - @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface + @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures ) {} async determineToolConfigurationStatus( diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts index b235370f151..6d0064c1136 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.spec.ts @@ -11,7 +11,7 @@ import { CustomParameter } from '../../common/domain'; import { CustomParameterScope } from '../../common/enum'; import { ContextExternalTool } from '../../context-external-tool/domain'; import { SchoolExternalTool } from '../../school-external-tool/domain'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ContextExternalToolTemplateInfo } from '../uc'; import { ExternalToolConfigurationService } from './external-tool-configuration.service'; @@ -20,7 +20,7 @@ describe('ExternalToolConfigurationService', () => { let module: TestingModule; let service: ExternalToolConfigurationService; - let toolFeatures: ToolFeaturesInterface; + let toolFeatures: IToolFeatures; beforeAll(async () => { await setupEntities(); diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts index 7f6c7896bbd..3d021c592fc 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-configuration.service.ts @@ -4,13 +4,13 @@ import { CustomParameter } from '../../common/domain'; import { CustomParameterScope } from '../../common/enum'; import { ContextExternalTool } from '../../context-external-tool/domain'; import { SchoolExternalTool } from '../../school-external-tool/domain'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ContextExternalToolTemplateInfo } from '../uc/dto'; @Injectable() export class ExternalToolConfigurationService { - constructor(@Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface) {} + constructor(@Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures) {} public filterForAvailableTools(externalTools: Page, toolIdsInUse: EntityId[]): ExternalTool[] { const visibleTools: ExternalTool[] = externalTools.data.filter((tool: ExternalTool): boolean => !tool.isHidden); diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts index bf787a9bdef..c53154098a5 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-logo-service.spec.ts @@ -5,7 +5,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { axiosResponseFactory, externalToolFactory } from '@shared/testing'; import { Logger } from '@src/core/logger'; import { of, throwError } from 'rxjs'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogo } from '../domain/external-tool-logo'; import { @@ -24,7 +24,7 @@ describe('ExternalToolLogoService', () => { let httpService: DeepMocked; let logger: DeepMocked; - let toolFeatures: ToolFeaturesInterface; + let toolFeatures: IToolFeatures; let externalToolService: DeepMocked; beforeAll(async () => { diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts index f74e1fe3bae..b39684fbd1b 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-logo.service.ts @@ -4,7 +4,7 @@ import { EntityId } from '@shared/domain'; import { Logger } from '@src/core/logger'; import { AxiosResponse } from 'axios'; import { lastValueFrom } from 'rxjs'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogo } from '../domain/external-tool-logo'; import { @@ -25,7 +25,7 @@ const contentTypeDetector: Record = { export class ExternalToolLogoService { constructor( - @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface, + @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures, private readonly logger: Logger, private readonly httpService: HttpService, private readonly externalToolService: ExternalToolService diff --git a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts index 8f730a97213..42efcd6559a 100644 --- a/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts +++ b/apps/server/src/modules/tool/external-tool/service/external-tool-validation.service.spec.ts @@ -2,7 +2,7 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { ValidationError } from '@shared/common'; import { externalToolFactory } from '@shared/testing/factory/domainobject/tool/external-tool.factory'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { ExternalTool } from '../domain'; import { ExternalToolLogoService } from './external-tool-logo.service'; import { ExternalToolParameterValidationService } from './external-tool-parameter-validation.service'; @@ -15,7 +15,7 @@ describe('ExternalToolValidationService', () => { let externalToolService: DeepMocked; let commonToolValidationService: DeepMocked; - let toolFeatures: ToolFeaturesInterface; + let toolFeatures: IToolFeatures; let logoService: DeepMocked; beforeAll(async () => { diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts index 39fed2b7da6..1f2ba7f5eb9 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.spec.ts @@ -4,7 +4,7 @@ import { externalToolFactory, schoolExternalToolFactory } from '@shared/testing/ import { CommonToolValidationService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; @@ -14,7 +14,7 @@ describe('SchoolExternalToolValidationService', () => { let externalToolService: DeepMocked; let commonToolValidationService: DeepMocked; - let toolFeatures: DeepMocked; + let toolFeatures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts index fb2fc7897d3..899055e321f 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool-validation.service.ts @@ -3,7 +3,7 @@ import { ValidationError } from '@shared/common'; import { CommonToolValidationService } from '../../common/service'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; @Injectable() @@ -11,7 +11,7 @@ export class SchoolExternalToolValidationService { constructor( private readonly externalToolService: ExternalToolService, private readonly commonToolValidationService: CommonToolValidationService, - @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface + @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures ) {} async validate(schoolExternalTool: SchoolExternalTool): Promise { diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts index 9d25492ab52..1def9935806 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.spec.ts @@ -7,7 +7,7 @@ import { schoolExternalToolFactory } from '@shared/testing/factory/domainobject/ import { ToolConfigurationStatus } from '../../common/enum'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; import { SchoolExternalToolService } from './school-external-tool.service'; @@ -19,7 +19,7 @@ describe('SchoolExternalToolService', () => { let schoolExternalToolRepo: DeepMocked; let externalToolService: DeepMocked; let schoolExternalToolValidationService: DeepMocked; - let toolFearures: DeepMocked; + let toolFearures: DeepMocked; beforeAll(async () => { module = await Test.createTestingModule({ diff --git a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts index e62d5cad0c6..2ead0933582 100644 --- a/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts +++ b/apps/server/src/modules/tool/school-external-tool/service/school-external-tool.service.ts @@ -4,7 +4,7 @@ import { SchoolExternalToolRepo } from '@shared/repo'; import { ToolConfigurationStatus } from '../../common/enum'; import { ExternalTool } from '../../external-tool/domain'; import { ExternalToolService } from '../../external-tool/service'; -import { ToolFeatures, ToolFeaturesInterface } from '../../tool-config'; +import { IToolFeatures, ToolFeatures } from '../../tool-config'; import { SchoolExternalTool } from '../domain'; import { SchoolExternalToolQuery } from '../uc/dto/school-external-tool.types'; import { SchoolExternalToolValidationService } from './school-external-tool-validation.service'; @@ -15,7 +15,7 @@ export class SchoolExternalToolService { private readonly schoolExternalToolRepo: SchoolExternalToolRepo, private readonly externalToolService: ExternalToolService, private readonly schoolExternalToolValidationService: SchoolExternalToolValidationService, - @Inject(ToolFeatures) private readonly toolFeatures: ToolFeaturesInterface + @Inject(ToolFeatures) private readonly toolFeatures: IToolFeatures ) {} async findById(schoolExternalToolId: EntityId): Promise { diff --git a/apps/server/src/modules/tool/tool-config.ts b/apps/server/src/modules/tool/tool-config.ts index 6249fc3b964..1405f0c7a1d 100644 --- a/apps/server/src/modules/tool/tool-config.ts +++ b/apps/server/src/modules/tool/tool-config.ts @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; export const ToolFeatures = Symbol('ToolFeatures'); -export interface ToolFeaturesInterface { +export interface IToolFeatures { ctlToolsTabEnabled: boolean; ltiToolsTabEnabled: boolean; contextConfigurationEnabled: boolean; @@ -13,7 +13,7 @@ export interface ToolFeaturesInterface { } export default class ToolConfiguration { - static toolFeatures: ToolFeaturesInterface = { + static toolFeatures: IToolFeatures = { ctlToolsTabEnabled: Configuration.get('FEATURE_CTL_TOOLS_TAB_ENABLED') as boolean, ltiToolsTabEnabled: Configuration.get('FEATURE_LTI_TOOLS_TAB_ENABLED') as boolean, contextConfigurationEnabled: Configuration.get('FEATURE_CTL_CONTEXT_CONFIGURATION_ENABLED') as boolean, From 76aa032619a6f2d80c61d294e962eca19dbec797 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:15:14 +0100 Subject: [PATCH 103/110] BbbSettingsInterface -> IBbbSettings --- .../modules/video-conference/bbb/bbb-settings.interface.ts | 2 +- .../src/modules/video-conference/bbb/bbb.service.spec.ts | 4 ++-- apps/server/src/modules/video-conference/bbb/bbb.service.ts | 4 ++-- .../interface/video-conference-settings.interface.ts | 4 ++-- .../src/modules/video-conference/video-conference-config.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts b/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts index 97f7c9319ca..c250bebb929 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb-settings.interface.ts @@ -1,6 +1,6 @@ export const BbbSettings = Symbol('BbbSettings'); -export interface BbbSettingsInterface { +export interface IBbbSettings { host: string; salt: string; presentationUrl: string; diff --git a/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts b/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts index a0e9887107d..1731d10ff8e 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb.service.spec.ts @@ -9,7 +9,7 @@ import { AxiosResponse } from 'axios'; import crypto, { Hash } from 'crypto'; import { of } from 'rxjs'; import { URLSearchParams } from 'url'; -import { BbbSettings, BbbSettingsInterface } from './bbb-settings.interface'; +import { BbbSettings, IBbbSettings } from './bbb-settings.interface'; import { BBBService } from './bbb.service'; import { BBBBaseMeetingConfig, BBBCreateConfig, BBBJoinConfig, BBBRole, GuestPolicy } from './request'; import { BBBBaseResponse, BBBCreateResponse, BBBMeetingInfoResponse, BBBResponse, BBBStatus } from './response'; @@ -118,7 +118,7 @@ describe('BBB Service', () => { BBBServiceTest, { provide: BbbSettings, - useValue: createMock({ + useValue: createMock({ host: 'https://bbb.de', salt: 'salt12345', presentationUrl: '', diff --git a/apps/server/src/modules/video-conference/bbb/bbb.service.ts b/apps/server/src/modules/video-conference/bbb/bbb.service.ts index e6c645b9f38..2fcc3db9981 100644 --- a/apps/server/src/modules/video-conference/bbb/bbb.service.ts +++ b/apps/server/src/modules/video-conference/bbb/bbb.service.ts @@ -6,14 +6,14 @@ import { AxiosResponse } from 'axios'; import crypto from 'crypto'; import { firstValueFrom, Observable } from 'rxjs'; import { URL, URLSearchParams } from 'url'; -import { BbbSettings, BbbSettingsInterface } from './bbb-settings.interface'; +import { BbbSettings, IBbbSettings } from './bbb-settings.interface'; import { BBBBaseMeetingConfig, BBBCreateConfig, BBBJoinConfig } from './request'; import { BBBBaseResponse, BBBCreateResponse, BBBMeetingInfoResponse, BBBResponse, BBBStatus } from './response'; @Injectable() export class BBBService { constructor( - @Inject(BbbSettings) private readonly bbbSettings: BbbSettingsInterface, + @Inject(BbbSettings) private readonly bbbSettings: IBbbSettings, private readonly httpService: HttpService, private readonly converterUtil: ConverterUtil ) {} diff --git a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts index 64c687d6709..7d983a371e5 100644 --- a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts +++ b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts @@ -1,9 +1,9 @@ -import { BbbSettingsInterface } from '../bbb'; +import { IBbbSettings } from '../bbb'; export const VideoConferenceSettings = Symbol('VideoConferenceSettings'); export interface VideoConferenceSettingsInterface { enabled: boolean; hostUrl: string; - bbb: BbbSettingsInterface; + bbb: IBbbSettings; } diff --git a/apps/server/src/modules/video-conference/video-conference-config.ts b/apps/server/src/modules/video-conference/video-conference-config.ts index 9154a7884e7..df9e9ffc191 100644 --- a/apps/server/src/modules/video-conference/video-conference-config.ts +++ b/apps/server/src/modules/video-conference/video-conference-config.ts @@ -1,9 +1,9 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; -import { BbbSettingsInterface } from './bbb'; +import { IBbbSettings } from './bbb'; import { VideoConferenceSettingsInterface } from './interface'; export default class VideoConferenceConfiguration { - static bbb: BbbSettingsInterface = { + static bbb: IBbbSettings = { host: Configuration.get('VIDEOCONFERENCE_HOST') as string, salt: Configuration.get('VIDEOCONFERENCE_SALT') as string, presentationUrl: Configuration.get('VIDEOCONFERENCE_DEFAULT_PRESENTATION') as string, From 02b5679059f38454ff669113daa88f01955f7ebb Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:16:43 +0100 Subject: [PATCH 104/110] VideoConferenceSettingsInterface -> IVideoConferenceSettings --- .../interface/video-conference-settings.interface.ts | 2 +- .../service/video-conference.service.spec.ts | 6 +++--- .../video-conference/service/video-conference.service.ts | 4 ++-- .../src/modules/video-conference/video-conference-config.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts index 7d983a371e5..a1d07fb516a 100644 --- a/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts +++ b/apps/server/src/modules/video-conference/interface/video-conference-settings.interface.ts @@ -2,7 +2,7 @@ import { IBbbSettings } from '../bbb'; export const VideoConferenceSettings = Symbol('VideoConferenceSettings'); -export interface VideoConferenceSettingsInterface { +export interface IVideoConferenceSettings { enabled: boolean; hostUrl: string; bbb: IBbbSettings; 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 ee6e599e5c2..2a5d223b553 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 @@ -26,7 +26,7 @@ import { videoConferenceDOFactory } from '@shared/testing/factory/video-conferen import { ObjectId } from 'bson'; import { BBBRole } from '../bbb'; import { ErrorStatus } from '../error'; -import { VideoConferenceOptions, VideoConferenceSettings, VideoConferenceSettingsInterface } from '../interface'; +import { IVideoConferenceSettings, VideoConferenceOptions, VideoConferenceSettings } from '../interface'; import { ScopeInfo, ScopeRef, VideoConferenceState } from '../uc/dto'; import { VideoConferenceService } from './video-conference.service'; @@ -39,7 +39,7 @@ describe('VideoConferenceService', () => { let teamsRepo: DeepMocked; let userService: DeepMocked; let videoConferenceRepo: DeepMocked; - let videoConferenceSettings: DeepMocked; + let videoConferenceSettings: DeepMocked; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ @@ -47,7 +47,7 @@ describe('VideoConferenceService', () => { VideoConferenceService, { provide: VideoConferenceSettings, - useValue: createMock({ + useValue: createMock({ hostUrl: 'https://api.example.com', }), }, 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 d0d003c0347..706a00e6e3b 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 @@ -22,13 +22,13 @@ import { import { TeamsRepo, VideoConferenceRepo } from '@shared/repo'; import { BBBRole } from '../bbb'; import { ErrorStatus } from '../error'; -import { VideoConferenceOptions, VideoConferenceSettings, VideoConferenceSettingsInterface } from '../interface'; +import { IVideoConferenceSettings, VideoConferenceOptions, VideoConferenceSettings } from '../interface'; import { ScopeInfo, VideoConferenceState } from '../uc/dto'; @Injectable() export class VideoConferenceService { constructor( - @Inject(VideoConferenceSettings) private readonly vcSettings: VideoConferenceSettingsInterface, + @Inject(VideoConferenceSettings) private readonly vcSettings: IVideoConferenceSettings, private readonly courseService: CourseService, private readonly calendarService: CalendarService, private readonly authorizationService: AuthorizationService, diff --git a/apps/server/src/modules/video-conference/video-conference-config.ts b/apps/server/src/modules/video-conference/video-conference-config.ts index df9e9ffc191..7e65d0e7155 100644 --- a/apps/server/src/modules/video-conference/video-conference-config.ts +++ b/apps/server/src/modules/video-conference/video-conference-config.ts @@ -1,6 +1,6 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { IBbbSettings } from './bbb'; -import { VideoConferenceSettingsInterface } from './interface'; +import { IVideoConferenceSettings } from './interface'; export default class VideoConferenceConfiguration { static bbb: IBbbSettings = { @@ -9,7 +9,7 @@ export default class VideoConferenceConfiguration { presentationUrl: Configuration.get('VIDEOCONFERENCE_DEFAULT_PRESENTATION') as string, }; - static videoConference: VideoConferenceSettingsInterface = { + static videoConference: IVideoConferenceSettings = { enabled: Configuration.get('FEATURE_VIDEOCONFERENCE_ENABLED') as boolean, hostUrl: Configuration.get('HOST') as string, bbb: VideoConferenceConfiguration.bbb, From e70e5da137fd162364f463d6457b0f8d7621b6ce Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:18:05 +0100 Subject: [PATCH 105/110] GridElementInterface -> IGridElement --- .../shared/domain/entity/dashboard.entity.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/server/src/shared/domain/entity/dashboard.entity.ts b/apps/server/src/shared/domain/entity/dashboard.entity.ts index dc40c94323e..cb49032e9fc 100644 --- a/apps/server/src/shared/domain/entity/dashboard.entity.ts +++ b/apps/server/src/shared/domain/entity/dashboard.entity.ts @@ -4,7 +4,7 @@ import { EntityId, LearnroomMetadata } from '@shared/domain/types'; const defaultColumns = 4; -export interface GridElementInterface { +export interface IGridElement { hasId(): boolean; getId: () => EntityId | undefined; @@ -34,7 +34,7 @@ export type GridElementContent = { copyingSince?: Date; }; -export class GridElement implements GridElementInterface { +export class GridElement implements IGridElement { id?: EntityId; title?: string; @@ -151,7 +151,7 @@ export type GridPosition = { x: number; y: number }; export type GridPositionWithGroupIndex = { x: number; y: number; groupIndex?: number }; export type GridElementWithPosition = { - gridElement: GridElementInterface; + gridElement: IGridElement; pos: GridPosition; }; @@ -162,7 +162,7 @@ export class DashboardEntity { columns: number; - grid: Map; + grid: Map; userId: EntityId; @@ -181,7 +181,7 @@ export class DashboardEntity { constructor(id: string, props: DashboardProps) { this.columns = props.colums || defaultColumns; - this.grid = new Map(); + this.grid = new Map(); props.grid.forEach((element) => { this.grid.set(this.gridIndexFromPosition(element.pos), element.gridElement); }); @@ -201,7 +201,7 @@ export class DashboardEntity { getGrid(): GridElementWithPosition[] { const result = [...this.grid.keys()].map((key) => { const position = this.positionFromGridIndex(key); - const value = this.grid.get(key) as GridElementInterface; + const value = this.grid.get(key) as IGridElement; return { pos: position, gridElement: value, @@ -210,7 +210,7 @@ export class DashboardEntity { return result; } - getElement(position: GridPosition): GridElementInterface { + getElement(position: GridPosition): IGridElement { const element = this.grid.get(this.gridIndexFromPosition(position)); if (!element) { throw new NotFoundException('no element at grid position'); @@ -239,7 +239,7 @@ export class DashboardEntity { private removeRoomsNotInList(roomList: Learnroom[]): void { [...this.grid.keys()].forEach((key) => { - const element = this.grid.get(key) as GridElementInterface; + const element = this.grid.get(key) as IGridElement; const currentRooms = element.getReferences(); currentRooms.forEach((room) => { if (!roomList.includes(room)) { @@ -283,7 +283,7 @@ export class DashboardEntity { return i; } - private getReferencesFromPosition(position: GridPositionWithGroupIndex): GridElementInterface { + private getReferencesFromPosition(position: GridPositionWithGroupIndex): IGridElement { const elementToMove = this.getElement(position); if (typeof position.groupIndex === 'number' && elementToMove.isGroup()) { @@ -304,7 +304,7 @@ export class DashboardEntity { } } - private mergeElementIntoPosition(element: GridElementInterface, position: GridPosition): GridElementInterface { + private mergeElementIntoPosition(element: IGridElement, position: GridPosition): IGridElement { const targetElement = this.grid.get(this.gridIndexFromPosition(position)); if (targetElement) { targetElement.addReferences(element.getReferences()); From 991c351412dea8f69463c3ec42bfec309462d7c8 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:22:11 +0100 Subject: [PATCH 106/110] EntityInterface -> IEntity --- .../h5p-editor/service/contentStorage.service.spec.ts | 4 ++-- apps/server/src/shared/domain/entity/base.entity.ts | 4 ++-- apps/server/src/shared/domain/interface/entity.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) 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 b0bfe861c52..4fb094e8e5b 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 { S3ClientAdapter } from '@infra/s3-client'; import { IContentMetadata, ILibraryName, IUser, LibraryName } from '@lumieducation/h5p-server'; import { HttpException, InternalServerErrorException, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { EntityInterface } from '@shared/domain'; +import { IEntity } from '@shared/domain'; import { ObjectID } from 'bson'; import { Readable } from 'stream'; import { GetH5PFileResponse } from '../controller/dto'; @@ -76,7 +76,7 @@ const helpers = { }; }, - repoSaveMock: async (entities: Entity | Entity[]) => { + repoSaveMock: async (entities: Entity | Entity[]) => { if (!Array.isArray(entities)) { entities = [entities]; } diff --git a/apps/server/src/shared/domain/entity/base.entity.ts b/apps/server/src/shared/domain/entity/base.entity.ts index 108f60ce8ce..fde2349ae36 100644 --- a/apps/server/src/shared/domain/entity/base.entity.ts +++ b/apps/server/src/shared/domain/entity/base.entity.ts @@ -1,9 +1,9 @@ import { PrimaryKey, Property, SerializedPrimaryKey } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import type { AuthorizableObject } from '../domain-object'; -import type { EntityInterface } from '../interface'; +import type { IEntity } from '../interface'; -export abstract class BaseEntity implements EntityInterface, AuthorizableObject { +export abstract class BaseEntity implements IEntity, AuthorizableObject { @PrimaryKey() _id!: ObjectId; diff --git a/apps/server/src/shared/domain/interface/entity.ts b/apps/server/src/shared/domain/interface/entity.ts index ff7b1ef0c4a..97618b0734d 100644 --- a/apps/server/src/shared/domain/interface/entity.ts +++ b/apps/server/src/shared/domain/interface/entity.ts @@ -1,16 +1,16 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { SchoolEntity } from '@shared/domain/entity/school.entity'; -export interface EntityInterface { +export interface IEntity { _id: ObjectId; id: string; } -export interface EntityInterfaceWithTimestamps extends EntityInterface { +export interface IEntityWithTimestamps extends IEntity { createdAt: Date; updatedAt: Date; } -export interface EntityWithSchool extends EntityInterface { +export interface EntityWithSchool extends IEntity { school: SchoolEntity; } From b547df5d691ab946c0b486ec9196db562a1f64d8 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:33:16 +0100 Subject: [PATCH 107/110] ImportUserScopeInterface -> IImportUserScope --- .../modules/user-import/mapper/import-user.mapper.ts | 6 +++--- .../src/modules/user-import/uc/user-import.uc.ts | 6 +++--- .../src/shared/domain/types/importuser.types.ts | 2 +- .../src/shared/repo/importuser/importuser.repo.ts | 12 ++---------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/apps/server/src/modules/user-import/mapper/import-user.mapper.ts b/apps/server/src/modules/user-import/mapper/import-user.mapper.ts index 5f154c58ef4..e15b3f36b60 100644 --- a/apps/server/src/modules/user-import/mapper/import-user.mapper.ts +++ b/apps/server/src/modules/user-import/mapper/import-user.mapper.ts @@ -1,6 +1,6 @@ import { BadRequestException } from '@nestjs/common'; import { StringValidator } from '@shared/common'; -import { ImportUser, ImportUserScopeInterface, SortOrderMap } from '@shared/domain'; +import { IImportUserScope, ImportUser, SortOrderMap } from '@shared/domain'; import { FilterImportUserParams, ImportUserResponse, @@ -46,8 +46,8 @@ export class ImportUserMapper { return dto; } - static mapImportUserFilterQueryToDomain(query: FilterImportUserParams): ImportUserScopeInterface { - const dto: ImportUserScopeInterface = {}; + static mapImportUserFilterQueryToDomain(query: FilterImportUserParams): IImportUserScope { + const dto: IImportUserScope = {}; if (StringValidator.isNotEmptyString(query.firstName)) dto.firstName = query.firstName; if (StringValidator.isNotEmptyString(query.lastName)) dto.lastName = query.lastName; if (StringValidator.isNotEmptyString(query.loginName)) dto.loginName = query.loginName; diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.ts b/apps/server/src/modules/user-import/uc/user-import.uc.ts index 618c60341cd..a9290bb5e42 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.ts @@ -10,8 +10,8 @@ import { Counted, EntityId, IFindOptions, + IImportUserScope, ImportUser, - ImportUserScopeInterface, LegacySchoolDo, MatchCreator, MatchCreatorScope, @@ -75,7 +75,7 @@ export class UserImportUc { */ async findAllImportUsers( currentUserId: EntityId, - query: ImportUserScopeInterface, + query: IImportUserScope, options?: IFindOptions ): Promise> { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_VIEW); @@ -179,7 +179,7 @@ export class UserImportUc { const currentUser = await this.getCurrentUser(currentUserId, Permission.SCHOOL_IMPORT_USERS_MIGRATE); const school: LegacySchoolDo = await this.schoolService.getSchoolById(currentUser.school.id); this.checkFeatureEnabled(school); - const filters: ImportUserScopeInterface = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; + const filters: IImportUserScope = { matches: [MatchCreatorScope.MANUAL, MatchCreatorScope.AUTO] }; // TODO batch/paginated import? const options: IFindOptions = {}; // TODO Change ImportUserRepo to DO to fix this workaround diff --git a/apps/server/src/shared/domain/types/importuser.types.ts b/apps/server/src/shared/domain/types/importuser.types.ts index bfd0d935177..de189aed43e 100644 --- a/apps/server/src/shared/domain/types/importuser.types.ts +++ b/apps/server/src/shared/domain/types/importuser.types.ts @@ -6,7 +6,7 @@ export enum MatchCreatorScope { NONE = 'none', } -export interface ImportUserScopeInterface { +export interface IImportUserScope { firstName?: string; lastName?: string; loginName?: string; diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.ts b/apps/server/src/shared/repo/importuser/importuser.repo.ts index c77ecab2dd5..c09e5f9ee87 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.ts @@ -2,15 +2,7 @@ import { FilterQuery, QueryOrderMap } from '@mikro-orm/core'; import { Injectable } from '@nestjs/common'; import { ObjectId } from '@mikro-orm/mongodb'; -import { - Counted, - EntityId, - IFindOptions, - ImportUser, - ImportUserScopeInterface, - SchoolEntity, - User, -} from '@shared/domain'; +import { Counted, EntityId, IFindOptions, IImportUserScope, ImportUser, SchoolEntity, User } from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { ImportUserScope } from './importuser.scope'; @@ -41,7 +33,7 @@ export class ImportUserRepo extends BaseRepo { async findImportUsers( school: SchoolEntity, - filters: ImportUserScopeInterface = {}, + filters: IImportUserScope = {}, options?: IFindOptions ): Promise> { const scope = new ImportUserScope(); From 51ac47d39f0523451a63692cb61b8720a87c47cd Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:53:39 +0100 Subject: [PATCH 108/110] TaskInterface -> ITask --- apps/server/src/shared/domain/types/task.types.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index ba30f915fbc..8f77e209eed 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -1,6 +1,6 @@ import type { Course, InputFormat, LessonEntity, SchoolEntity, Submission, User } from '@shared/domain/'; -interface TaskInterface { +interface ITask { name: string; description?: string; descriptionInputFormat?: InputFormat; @@ -8,17 +8,17 @@ interface TaskInterface { dueDate?: Date; } -export interface TaskUpdate extends TaskInterface { +export interface TaskUpdate extends ITask { courseId?: string; lessonId?: string; } -export interface TaskCreate extends TaskInterface { +export interface TaskCreate extends ITask { courseId?: string; lessonId?: string; } -export interface TaskProperties extends TaskInterface { +export interface TaskProperties extends ITask { course?: Course; lesson?: LessonEntity; creator: User; From d7cc56d13c1d8c14b11c66733d27c771c9fe0d3b Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:54:45 +0100 Subject: [PATCH 109/110] NewsScopeInterface -> INewsScope --- .../server/src/modules/news/mapper/news.mapper.spec.ts | 6 +++--- apps/server/src/modules/news/mapper/news.mapper.ts | 6 +++--- apps/server/src/modules/news/uc/news.uc.ts | 10 +++------- apps/server/src/shared/domain/types/news.types.ts | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/apps/server/src/modules/news/mapper/news.mapper.spec.ts b/apps/server/src/modules/news/mapper/news.mapper.spec.ts index 4eeb69df1d4..40bd66d8130 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.spec.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.spec.ts @@ -2,10 +2,10 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { CourseNews, CreateNews, + INewsScope, IUpdateNews, News, NewsProperties, - NewsScopeInterface, NewsTarget, NewsTargetModel, SchoolEntity, @@ -164,7 +164,7 @@ describe('NewsMapper', () => { targetId, }); const result = NewsMapper.mapNewsScopeToDomain(filterNewsParams); - const expected: NewsScopeInterface = {}; + const expected: INewsScope = {}; Object.assign(expected, { target: { targetModel: filterNewsParams.targetModel, @@ -182,7 +182,7 @@ describe('NewsMapper', () => { unpublished: true, }); const result = NewsMapper.mapNewsScopeToDomain(filterNewsParams); - const expected: NewsScopeInterface = {}; + const expected: INewsScope = {}; Object.assign(expected, { target: { targetModel: filterNewsParams.targetModel, diff --git a/apps/server/src/modules/news/mapper/news.mapper.ts b/apps/server/src/modules/news/mapper/news.mapper.ts index 3a3b3ea1a8e..36c17f57607 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.ts @@ -1,4 +1,4 @@ -import { CreateNews, IUpdateNews, News, NewsScopeInterface, NewsTargetModel } from '@shared/domain'; +import { CreateNews, INewsScope, IUpdateNews, News, NewsTargetModel } from '@shared/domain'; import { LogMessageData } from '@src/core/logger'; import { CreateNewsParams, FilterNewsParams, NewsResponse, UpdateNewsParams } from '../controller/dto'; import { SchoolInfoMapper } from './school-info.mapper'; @@ -35,8 +35,8 @@ export class NewsMapper { return dto; } - static mapNewsScopeToDomain(query: FilterNewsParams): NewsScopeInterface { - const dto: NewsScopeInterface = {}; + static mapNewsScopeToDomain(query: FilterNewsParams): INewsScope { + const dto: INewsScope = {}; if (query.targetModel) { dto.target = { targetModel: query.targetModel as NewsTargetModel, diff --git a/apps/server/src/modules/news/uc/news.uc.ts b/apps/server/src/modules/news/uc/news.uc.ts index b967fae8c85..002eaa45819 100644 --- a/apps/server/src/modules/news/uc/news.uc.ts +++ b/apps/server/src/modules/news/uc/news.uc.ts @@ -5,9 +5,9 @@ import { CreateNews, EntityId, IFindOptions, + INewsScope, IUpdateNews, News, - NewsScopeInterface, NewsTargetModel, Permission, SortOrder, @@ -66,7 +66,7 @@ export class NewsUc { */ public async findAllForUser( userId: EntityId, - scope?: NewsScopeInterface, + scope?: INewsScope, options?: IFindOptions ): Promise> { const unpublished = !!scope?.unpublished; // default is only published news @@ -156,11 +156,7 @@ export class NewsUc { return id; } - private async getPermittedTargets( - userId: EntityId, - scope: NewsScopeInterface | undefined, - permissions: NewsPermission[] - ) { + private async getPermittedTargets(userId: EntityId, scope: INewsScope | undefined, permissions: NewsPermission[]) { let targets: NewsTargetFilter[]; if (scope?.target == null) { diff --git a/apps/server/src/shared/domain/types/news.types.ts b/apps/server/src/shared/domain/types/news.types.ts index 0c0c11f77e7..671545c8ceb 100644 --- a/apps/server/src/shared/domain/types/news.types.ts +++ b/apps/server/src/shared/domain/types/news.types.ts @@ -21,7 +21,7 @@ export interface CreateNews { export type IUpdateNews = Partial; /** interface for finding news with optional targetId */ -export interface NewsScopeInterface { +export interface INewsScope { target?: { targetModel: NewsTargetModel; targetId?: EntityId }; unpublished?: boolean; } From f9de09570f61fd4a2930ef1233db96afdbdd4b57 Mon Sep 17 00:00:00 2001 From: wolfganggreschus Date: Thu, 16 Nov 2023 11:57:01 +0100 Subject: [PATCH 110/110] DashboardRepoInterface -> IDashboardRepo --- .../learnroom/controller/api-test/dashboard.api.spec.ts | 4 ++-- apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts | 4 ++-- apps/server/src/modules/learnroom/uc/dashboard.uc.ts | 4 ++-- apps/server/src/shared/repo/dashboard/dashboard.repo.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts index 18a9cc28acf..be9b9fad583 100644 --- a/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts +++ b/apps/server/src/modules/learnroom/controller/api-test/dashboard.api.spec.ts @@ -6,7 +6,7 @@ import { ServerTestModule } from '@modules/server/server.module'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { DashboardEntity, GridElement, Permission, RoleName, User } from '@shared/domain'; -import { DashboardRepoInterface } from '@shared/repo'; +import { IDashboardRepo } from '@shared/repo'; import { courseFactory, mapUserToCurrentUser, roleFactory, userFactory } from '@shared/testing'; import { Request } from 'express'; import request from 'supertest'; @@ -14,7 +14,7 @@ import request from 'supertest'; describe('Dashboard Controller (API)', () => { let app: INestApplication; let em: EntityManager; - let dashboardRepo: DashboardRepoInterface; + let dashboardRepo: IDashboardRepo; let currentUser: ICurrentUser; beforeAll(async () => { diff --git a/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts b/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts index 5f359cf2ee9..309e139b7cd 100644 --- a/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts +++ b/apps/server/src/modules/learnroom/uc/dashboard.uc.spec.ts @@ -10,7 +10,7 @@ import { LearnroomTypes, SortOrder, } from '@shared/domain'; -import { CourseRepo, DashboardRepoInterface } from '@shared/repo'; +import { CourseRepo, IDashboardRepo } from '@shared/repo'; import { setupEntities } from '@shared/testing'; import { DashboardUc } from './dashboard.uc'; @@ -31,7 +31,7 @@ const learnroomMock = (id: string, name: string) => { describe('dashboard uc', () => { let module: TestingModule; let service: DashboardUc; - let repo: DashboardRepoInterface; + let repo: IDashboardRepo; let courseRepo: CourseRepo; afterAll(async () => { diff --git a/apps/server/src/modules/learnroom/uc/dashboard.uc.ts b/apps/server/src/modules/learnroom/uc/dashboard.uc.ts index b29e39bc5b3..1e1df78fcba 100644 --- a/apps/server/src/modules/learnroom/uc/dashboard.uc.ts +++ b/apps/server/src/modules/learnroom/uc/dashboard.uc.ts @@ -1,12 +1,12 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { DashboardEntity, EntityId, GridPosition, GridPositionWithGroupIndex, SortOrder } from '@shared/domain'; -import { CourseRepo, DashboardRepoInterface } from '@shared/repo'; +import { CourseRepo, IDashboardRepo } from '@shared/repo'; // import { NotFound } from '@feathersjs/errors'; // wrong import? see NotFoundException @Injectable() export class DashboardUc { constructor( - @Inject('DASHBOARD_REPO') private readonly dashboardRepo: DashboardRepoInterface, + @Inject('DASHBOARD_REPO') private readonly dashboardRepo: IDashboardRepo, private readonly courseRepo: CourseRepo ) {} diff --git a/apps/server/src/shared/repo/dashboard/dashboard.repo.ts b/apps/server/src/shared/repo/dashboard/dashboard.repo.ts index 882062e96ca..30b463e9344 100644 --- a/apps/server/src/shared/repo/dashboard/dashboard.repo.ts +++ b/apps/server/src/shared/repo/dashboard/dashboard.repo.ts @@ -10,14 +10,14 @@ const generateEmptyDashboard = (userId: EntityId) => { return dashboard; }; -export interface DashboardRepoInterface { +export interface IDashboardRepo { getUsersDashboard(userId: EntityId): Promise; getDashboardById(id: EntityId): Promise; persistAndFlush(entity: DashboardEntity): Promise; } @Injectable() -export class DashboardRepo implements DashboardRepoInterface { +export class DashboardRepo implements IDashboardRepo { constructor(protected readonly em: EntityManager, protected readonly mapper: DashboardModelMapper) {} // ToDo: refactor this to be in an abstract class (see baseRepo)