From f13eb0e72a12d0c61916eb5488554f1145fe2393 Mon Sep 17 00:00:00 2001 From: Max <53796487+dyedwiper@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:55:05 +0200 Subject: [PATCH] BC-5180 Rename school entity (#4418) --- .../services/account-db.service.spec.ts | 4 +- .../src/modules/account/uc/account.uc.spec.ts | 8 ++-- .../src/modules/account/uc/account.uc.ts | 4 +- .../controllers/api-test/login.api.spec.ts | 4 +- .../fwu-learning-contents-test.module.ts | 4 +- .../fwu-learning-contents.module.ts | 4 +- .../src/modules/group/entity/group.entity.ts | 8 ++-- .../modules/group/repo/group-domain.mapper.ts | 4 +- .../h5p-editor/h5p-editor-test.module.ts | 4 +- .../modules/h5p-editor/h5p-editor.module.ts | 4 +- .../modules/news/mapper/news.mapper.spec.ts | 6 +-- .../modules/news/mapper/school-info.mapper.ts | 4 +- .../controller/api-test/oauth-sso.api.spec.ts | 14 +++--- .../api-test/tool-context.api.spec.ts | 24 +++++----- .../api-test/tool-configuration.api.spec.ts | 26 +++++------ .../controller/api-test/tool.api.spec.ts | 8 ++-- .../api-test/tool-school.api.spec.ts | 12 ++--- .../entity/school-external-tool.entity.ts | 8 ++-- .../tool-launch.controller.api.spec.ts | 10 ++-- .../api-test/import-user.api.spec.ts | 16 +++---- .../user-import/uc/user-import.uc.spec.ts | 10 ++-- .../api-test/user-login-migration.api.spec.ts | 46 +++++++++---------- .../api-test/video-conference.api.spec.ts | 32 ++++++------- .../src/shared/domain/entity/all-entities.ts | 4 +- .../src/shared/domain/entity/course.entity.ts | 8 ++-- .../domain/entity/coursegroup.entity.ts | 6 +-- .../domain/entity/import-user.entity.ts | 8 ++-- .../src/shared/domain/entity/news.entity.ts | 12 ++--- .../src/shared/domain/entity/school.entity.ts | 2 +- .../shared/domain/entity/submission.entity.ts | 8 ++-- .../src/shared/domain/entity/task.entity.ts | 6 +-- .../src/shared/domain/entity/team.entity.ts | 12 ++--- .../entity/user-login-migration.entity.ts | 6 +-- .../src/shared/domain/entity/user.entity.ts | 8 ++-- .../src/shared/domain/interface/entity.ts | 4 +- .../src/shared/domain/types/news.types.ts | 4 +- .../src/shared/domain/types/task.types.ts | 4 +- ...ext-external-tool.repo.integration.spec.ts | 4 +- .../importuser.repo.integration.spec.ts | 10 ++-- .../shared/repo/importuser/importuser.repo.ts | 6 +-- .../repo/importuser/importuser.scope.ts | 4 +- .../legacy-school.repo.integration.spec.ts | 20 ++++---- .../shared/repo/school/legacy-school.repo.ts | 18 ++++---- ...ool-external-tool.repo.integration.spec.ts | 4 +- .../school-external-tool.repo.ts | 4 +- .../user/user-do.repo.integration.spec.ts | 12 ++--- .../src/shared/repo/user/user-do.repo.ts | 4 +- apps/server/src/shared/repo/user/user.repo.ts | 14 +++++- ...r-login-migration.repo.integration.spec.ts | 8 ++-- .../user-login-migration.repo.ts | 4 +- .../shared/testing/factory/school.factory.ts | 4 +- .../factory/user-and-account.test.factory.ts | 4 +- 52 files changed, 243 insertions(+), 233 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 ddea45d19ca..777ab61a1ad 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 @@ -3,7 +3,7 @@ import { ObjectId } from '@mikro-orm/mongodb'; import { ConfigService } from '@nestjs/config'; import { Test, TestingModule } from '@nestjs/testing'; import { EntityNotFoundError } from '@shared/common'; -import { Account, EntityId, Permission, Role, RoleName, School, User } from '@shared/domain'; +import { Account, EntityId, Permission, Role, RoleName, SchoolEntity, User } from '@shared/domain'; import { IdentityManagementService } from '@shared/infra/identity-management/identity-management.service'; import { accountFactory, schoolFactory, setupEntities, userFactory } from '@shared/testing'; import { AccountEntityToDtoMapper } from '@src/modules/account/mapper'; @@ -25,7 +25,7 @@ describe('AccountDbService', () => { const defaultPassword = 'DummyPasswd!1'; - let mockSchool: School; + let mockSchool: SchoolEntity; let mockTeacherUser: User; let mockStudentUser: User; 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 05cedccf5b1..0df73ab93d9 100644 --- a/apps/server/src/modules/account/uc/account.uc.spec.ts +++ b/apps/server/src/modules/account/uc/account.uc.spec.ts @@ -10,7 +10,7 @@ import { PermissionService, Role, RoleName, - School, + SchoolEntity, SchoolRolePermission, SchoolRoles, User, @@ -42,9 +42,9 @@ describe('AccountUc', () => { let accountValidationService: AccountValidationService; let configService: DeepMocked; - let mockSchool: School; - let mockOtherSchool: School; - let mockSchoolWithStudentVisibility: School; + let mockSchool: SchoolEntity; + let mockOtherSchool: SchoolEntity; + let mockSchoolWithStudentVisibility: SchoolEntity; let mockSuperheroUser: User; let mockAdminUser: User; diff --git a/apps/server/src/modules/account/uc/account.uc.ts b/apps/server/src/modules/account/uc/account.uc.ts index b416f6e804e..fa1d7ca4c60 100644 --- a/apps/server/src/modules/account/uc/account.uc.ts +++ b/apps/server/src/modules/account/uc/account.uc.ts @@ -6,7 +6,7 @@ import { ForbiddenOperationError, ValidationError, } from '@shared/common/error'; -import { Account, EntityId, Permission, PermissionService, Role, RoleName, School, User } from '@shared/domain'; +import { Account, EntityId, Permission, PermissionService, Role, RoleName, SchoolEntity, User } from '@shared/domain'; import { UserRepo } from '@shared/repo'; import { AccountService } from '@src/modules/account/services/account.service'; import { AccountDto } from '@src/modules/account/services/dto/account.dto'; @@ -409,7 +409,7 @@ export class AccountUc { ); } - private schoolPermissionExists(roles: string[], school: School, permissions: string[]): boolean { + private schoolPermissionExists(roles: string[], school: SchoolEntity, permissions: string[]): boolean { if ( roles.find((role) => role === RoleName.TEACHER) && permissions.find((permission) => permission === Permission.STUDENT_LIST) 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 ebdd7c7ea11..6bc8959e936 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 @@ -1,7 +1,7 @@ import { EntityManager } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Account, RoleName, School, System, User } from '@shared/domain'; +import { Account, RoleName, SchoolEntity, System, User } from '@shared/domain'; import { accountFactory, roleFactory, schoolFactory, systemFactory, userFactory } from '@shared/testing'; import { SSOErrorCode } from '@src/modules/oauth/error/sso-error-code.enum'; import { OauthTokenResponse } from '@src/modules/oauth/service/dto'; @@ -146,7 +146,7 @@ describe('Login Controller (api)', () => { describe('loginLdap', () => { let account: Account; let user: User; - let school: School; + let school: SchoolEntity; let system: System; beforeAll(async () => { diff --git a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts index 4e633ca4e1b..c6fe6fc6d73 100644 --- a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts +++ b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents-test.module.ts @@ -1,7 +1,7 @@ import { HttpModule } from '@nestjs/axios'; import { DynamicModule, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { Account, Role, School, SchoolYear, System, User } from '@shared/domain'; +import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types'; import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; @@ -16,7 +16,7 @@ import { config, s3Config } from './fwu-learning-contents.config'; import { FwuLearningContentsUc } from './uc/fwu-learning-contents.uc'; const imports = [ - MongoMemoryDatabaseModule.forRoot({ entities: [User, Account, Role, School, System, SchoolYear] }), + MongoMemoryDatabaseModule.forRoot({ entities: [User, Account, Role, SchoolEntity, System, SchoolYear] }), AuthorizationModule, AuthenticationModule, ConfigModule.forRoot(createConfigModuleOptions(config)), diff --git a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts index 55c083b3061..ddb8d04fb35 100644 --- a/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts +++ b/apps/server/src/modules/fwu-learning-contents/fwu-learning-contents.module.ts @@ -3,7 +3,7 @@ import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; import { HttpModule } from '@nestjs/axios'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { Account, Role, School, SchoolYear, System, User } from '@shared/domain'; +import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain'; import { RabbitMQWrapperModule } from '@shared/infra/rabbitmq'; import { S3ClientModule } from '@shared/infra/s3-client'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; @@ -36,7 +36,7 @@ const defaultMikroOrmOptions: MikroOrmModuleSyncOptions = { clientUrl: DB_URL, password: DB_PASSWORD, user: DB_USERNAME, - entities: [User, Account, Role, School, System, SchoolYear], + entities: [User, Account, Role, SchoolEntity, System, SchoolYear], // debug: true, // use it for locally debugging of querys }), diff --git a/apps/server/src/modules/group/entity/group.entity.ts b/apps/server/src/modules/group/entity/group.entity.ts index 0abd954c329..1d55aec991c 100644 --- a/apps/server/src/modules/group/entity/group.entity.ts +++ b/apps/server/src/modules/group/entity/group.entity.ts @@ -1,7 +1,7 @@ import { Embedded, Entity, Enum, ManyToOne, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; import { ExternalSourceEntity } from '@shared/domain/entity/external-source.entity'; -import { School } from '@shared/domain/entity/school.entity'; +import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { EntityId } from '@shared/domain/types'; import { GroupUserEntity } from './group-user.entity'; import { GroupValidPeriodEntity } from './group-valid-period.entity'; @@ -23,7 +23,7 @@ export interface GroupEntityProps { users: GroupUserEntity[]; - organization?: School; + organization?: SchoolEntity; } @Entity({ tableName: 'groups' }) @@ -43,8 +43,8 @@ export class GroupEntity extends BaseEntityWithTimestamps { @Embedded(() => GroupUserEntity, { array: true }) users: GroupUserEntity[]; - @ManyToOne(() => School, { nullable: true }) - organization?: School; + @ManyToOne(() => SchoolEntity, { nullable: true }) + organization?: SchoolEntity; constructor(props: GroupEntityProps) { super(); diff --git a/apps/server/src/modules/group/repo/group-domain.mapper.ts b/apps/server/src/modules/group/repo/group-domain.mapper.ts index 7b9802e8d46..e203f7a2d46 100644 --- a/apps/server/src/modules/group/repo/group-domain.mapper.ts +++ b/apps/server/src/modules/group/repo/group-domain.mapper.ts @@ -1,5 +1,5 @@ import { EntityManager } from '@mikro-orm/mongodb'; -import { ExternalSource, ExternalSourceEntity, Role, School, System, User } from '@shared/domain'; +import { ExternalSource, ExternalSourceEntity, Role, SchoolEntity, System, User } from '@shared/domain'; import { Group, GroupProps, GroupTypes, GroupUser } from '../domain'; import { GroupEntity, GroupEntityProps, GroupEntityTypes, GroupUserEntity, GroupValidPeriodEntity } from '../entity'; @@ -34,7 +34,7 @@ export class GroupDomainMapper { (groupUser): GroupUserEntity => GroupDomainMapper.mapGroupUserToGroupUserEntity(groupUser, em) ), validPeriod, - organization: props.organizationId ? em.getReference(School, props.organizationId) : undefined, + organization: props.organizationId ? em.getReference(SchoolEntity, props.organizationId) : undefined, }; return mapped; diff --git a/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts b/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts index bdd421258be..e33f5484b8a 100644 --- a/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts +++ b/apps/server/src/modules/h5p-editor/h5p-editor-test.module.ts @@ -1,5 +1,5 @@ import { DynamicModule, Module } from '@nestjs/common'; -import { Account, Role, School, SchoolYear, User } from '@shared/domain'; +import { Account, Role, SchoolEntity, SchoolYear, User } from '@shared/domain'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; import { MongoDatabaseModuleOptions } from '@shared/infra/database/mongo-memory-database/types'; import { RabbitMQWrapperTestModule } from '@shared/infra/rabbitmq'; @@ -12,7 +12,7 @@ import { H5PEditorModule } from './h5p-editor.module'; const imports = [ H5PEditorModule, - MongoMemoryDatabaseModule.forRoot({ entities: [Account, Role, School, SchoolYear, User] }), + MongoMemoryDatabaseModule.forRoot({ entities: [Account, Role, SchoolEntity, SchoolYear, User] }), AuthenticationApiModule, AuthorizationModule, AuthenticationModule, diff --git a/apps/server/src/modules/h5p-editor/h5p-editor.module.ts b/apps/server/src/modules/h5p-editor/h5p-editor.module.ts index 638723787e5..12a1c09b477 100644 --- a/apps/server/src/modules/h5p-editor/h5p-editor.module.ts +++ b/apps/server/src/modules/h5p-editor/h5p-editor.module.ts @@ -2,7 +2,7 @@ import { Dictionary, IPrimaryKey } from '@mikro-orm/core'; import { MikroOrmModule, MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs'; import { Module, NotFoundException } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; -import { Account, Role, School, SchoolYear, System, User } from '@shared/domain'; +import { Account, Role, SchoolEntity, SchoolYear, System, User } from '@shared/domain'; import { DB_PASSWORD, DB_URL, DB_USERNAME, createConfigModuleOptions } from '@src/config'; import { CoreModule } from '@src/core'; import { Logger } from '@src/core/logger'; @@ -28,7 +28,7 @@ const imports = [ clientUrl: DB_URL, password: DB_PASSWORD, user: DB_USERNAME, - entities: [User, Account, Role, School, System, SchoolYear], + entities: [User, Account, Role, SchoolEntity, System, SchoolYear], // debug: true, // use it for locally debugging of querys }), 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 eaa4635abc6..1ca549bfe74 100644 --- a/apps/server/src/modules/news/mapper/news.mapper.spec.ts +++ b/apps/server/src/modules/news/mapper/news.mapper.spec.ts @@ -3,7 +3,7 @@ import { CourseNews, INewsProperties, News, - School, + SchoolEntity, SchoolNews, TeamEntity, TeamNews, @@ -43,7 +43,7 @@ const date = new Date(2021, 1, 1, 0, 0, 0); const createNews = ( newsProps, NewsType: { new (props: INewsProperties): T }, - school: School, + school: SchoolEntity, creator: User, target: NewsTarget ): T => { @@ -70,7 +70,7 @@ const createNews = ( }; const getExpectedNewsResponse = ( - school: School, + school: SchoolEntity, creator: User, news: News, newsProps: { title: string; content: string }, diff --git a/apps/server/src/modules/news/mapper/school-info.mapper.ts b/apps/server/src/modules/news/mapper/school-info.mapper.ts index 937a3e2f7c1..b4a982966f7 100644 --- a/apps/server/src/modules/news/mapper/school-info.mapper.ts +++ b/apps/server/src/modules/news/mapper/school-info.mapper.ts @@ -1,8 +1,8 @@ -import { School } from '@shared/domain'; +import { SchoolEntity } from '@shared/domain'; import { SchoolInfoResponse } from '../controller/dto'; export class SchoolInfoMapper { - static mapToResponse(schoolInfo: School): SchoolInfoResponse { + static mapToResponse(schoolInfo: SchoolEntity): SchoolInfoResponse { const dto = new SchoolInfoResponse({ id: schoolInfo.id, name: schoolInfo.name }); return dto; } 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 af29ff68b08..3f72fea25f5 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 @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { ExecutionContext, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Account, EntityId, School, System, User } from '@shared/domain'; +import { Account, EntityId, SchoolEntity, System, User } from '@shared/domain'; import { UserLoginMigration } from '@shared/domain/entity/user-login-migration.entity'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; import { KeycloakAdministrationService } from '@shared/infra/identity-management/keycloak-administration/service/keycloak-administration.service'; @@ -115,7 +115,7 @@ describe('OAuth SSO Controller (API)', () => { const setup = async () => { const externalUserId = 'externalUserId'; const system: System = systemFactory.withOauthConfig().buildWithId(); - const school: School = schoolFactory.buildWithId({ systems: [system] }); + 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 }); @@ -325,7 +325,7 @@ describe('OAuth SSO Controller (API)', () => { .withOauthConfig() .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - const sourceSchool: School = schoolFactory.buildWithId({ + const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '11111', externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', @@ -404,7 +404,7 @@ describe('OAuth SSO Controller (API)', () => { .withOauthConfig() .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - const sourceSchool: School = schoolFactory.buildWithId({ + const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '11110', externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', @@ -452,7 +452,7 @@ describe('OAuth SSO Controller (API)', () => { .withOauthConfig() .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - const sourceSchool: School = schoolFactory.buildWithId({ + const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '11111', externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', @@ -508,7 +508,7 @@ describe('OAuth SSO Controller (API)', () => { .withOauthConfig() .buildWithId({ provisioningStrategy: SystemProvisioningStrategy.ISERV }, new ObjectId().toHexString(), {}); - const sourceSchool: School = schoolFactory.buildWithId({ + const sourceSchool: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '11111', externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', @@ -521,7 +521,7 @@ describe('OAuth SSO Controller (API)', () => { startedAt: new Date('2022-12-17T03:24:00'), }); - const targetSchool: School = schoolFactory.buildWithId({ + const targetSchool: SchoolEntity = schoolFactory.buildWithId({ systems: [targetSystem], officialSchoolNumber: '22222', externalId: 'aef1f4fd-c323-466e-962b-a84354c0e713', diff --git a/apps/server/src/modules/tool/context-external-tool/controller/api-test/tool-context.api.spec.ts b/apps/server/src/modules/tool/context-external-tool/controller/api-test/tool-context.api.spec.ts index 8991d84dcfc..6e8ca18253f 100644 --- a/apps/server/src/modules/tool/context-external-tool/controller/api-test/tool-context.api.spec.ts +++ b/apps/server/src/modules/tool/context-external-tool/controller/api-test/tool-context.api.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, MikroORM } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Account, Course, Permission, School, User } from '@shared/domain'; +import { Account, Course, Permission, SchoolEntity, User } from '@shared/domain'; import { accountFactory, contextExternalToolEntityFactory, @@ -59,7 +59,7 @@ describe('ToolContextController (API)', () => { describe('[POST] tools/context-external-tools', () => { describe('when creation of contextExternalTool is successfully', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, ]); @@ -158,7 +158,7 @@ describe('ToolContextController (API)', () => { describe('[DELETE] tools/context-external-tools/:contextExternalToolId', () => { describe('when deletion of contextExternalTool is successfully', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, ]); @@ -240,8 +240,8 @@ describe('ToolContextController (API)', () => { describe('[GET] tools/context-external-tools/:contextType/:contextId', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); - const otherSchool: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); + const otherSchool: SchoolEntity = schoolFactory.buildWithId(); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -410,7 +410,7 @@ describe('ToolContextController (API)', () => { describe('[GET] tools/context-external-tools/:contextExternalToolId', () => { describe('when the tool exists', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -474,7 +474,7 @@ describe('ToolContextController (API)', () => { describe('when the tool does not exist', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -504,7 +504,7 @@ describe('ToolContextController (API)', () => { describe('when user is not authorized', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const course: Course = courseFactory.buildWithId({ school, @@ -543,7 +543,7 @@ describe('ToolContextController (API)', () => { describe('when user has not the required permission', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { studentUser, studentAccount } = UserAndAccountTestFactory.buildStudent({ school }); @@ -598,7 +598,7 @@ describe('ToolContextController (API)', () => { describe('[PUT] tools/context-external-tools/:contextExternalToolId', () => { describe('when update of contextExternalTool is successfully', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -694,7 +694,7 @@ describe('ToolContextController (API)', () => { teacherUser.roles.set([roleWithoutPermission]); - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const course: Course = courseFactory.buildWithId({ teachers: [teacherUser], school }); @@ -766,7 +766,7 @@ describe('ToolContextController (API)', () => { describe('when the user is not authenticated', () => { const setup = async () => { const { teacherUser } = UserAndAccountTestFactory.buildTeacher(); - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const course: Course = courseFactory.buildWithId({ teachers: [teacherUser], school }); const contextParameter = customParameterEntityFactory.build({ diff --git a/apps/server/src/modules/tool/external-tool/controller/api-test/tool-configuration.api.spec.ts b/apps/server/src/modules/tool/external-tool/controller/api-test/tool-configuration.api.spec.ts index 82d72d7e86f..70ec7d4be67 100644 --- a/apps/server/src/modules/tool/external-tool/controller/api-test/tool-configuration.api.spec.ts +++ b/apps/server/src/modules/tool/external-tool/controller/api-test/tool-configuration.api.spec.ts @@ -2,7 +2,7 @@ import { EntityManager, MikroORM } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Account, Course, Permission, School, User } from '@shared/domain'; +import { Account, Course, Permission, SchoolEntity, User } from '@shared/domain'; import { accountFactory, contextExternalToolEntityFactory, @@ -59,7 +59,7 @@ describe('ToolConfigurationController (API)', () => { describe('[GET] tools/:contextType/:contextId/available-tools', () => { describe('when the user is not authorized', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { studentUser, studentAccount } = UserAndAccountTestFactory.buildStudent({ school }); @@ -114,7 +114,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tools are available for a course', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -183,7 +183,7 @@ describe('ToolConfigurationController (API)', () => { describe('when no tools are available for a course', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({}, [ Permission.CONTEXT_TOOL_ADMIN, @@ -219,7 +219,7 @@ describe('ToolConfigurationController (API)', () => { describe('[GET] tools/school/:schoolId/available-tools', () => { describe('when the user is not authorized', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const user: User = userFactory.buildWithId({ school, roles: [] }); const account: Account = accountFactory.buildWithId({ userId: user.id }); @@ -258,7 +258,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tools are available for a school', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({}, [Permission.TOOL_ADMIN]); @@ -316,7 +316,7 @@ describe('ToolConfigurationController (API)', () => { describe('when no tools are available for a school', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({}, [Permission.SCHOOL_TOOL_ADMIN]); @@ -346,7 +346,7 @@ describe('ToolConfigurationController (API)', () => { describe('GET tools/school-external-tools/:schoolExternalToolId/configuration-template', () => { describe('when the user is not authorized', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const user: User = userFactory.buildWithId({ school, roles: [] }); const account: Account = accountFactory.buildWithId({ userId: user.id }); @@ -382,7 +382,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tool is not hidden', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, @@ -444,7 +444,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tool is hidden', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({}, [Permission.SCHOOL_TOOL_ADMIN]); @@ -477,7 +477,7 @@ describe('ToolConfigurationController (API)', () => { describe('GET tools/context-external-tools/:contextExternalToolId/configuration-template', () => { describe('when the user is not authorized', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const course: Course = courseFactory.buildWithId(); @@ -527,7 +527,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tool is not hidden', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, @@ -607,7 +607,7 @@ describe('ToolConfigurationController (API)', () => { describe('when tool is hidden', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_ADMIN, diff --git a/apps/server/src/modules/tool/external-tool/controller/api-test/tool.api.spec.ts b/apps/server/src/modules/tool/external-tool/controller/api-test/tool.api.spec.ts index 4f844fed7b0..6498f66fc1f 100644 --- a/apps/server/src/modules/tool/external-tool/controller/api-test/tool.api.spec.ts +++ b/apps/server/src/modules/tool/external-tool/controller/api-test/tool.api.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Course, Permission, School } from '@shared/domain'; +import { Course, Permission, SchoolEntity } from '@shared/domain'; import { cleanupCollections, contextExternalToolEntityFactory, @@ -608,8 +608,8 @@ describe('ToolController (API)', () => { describe('when user has no access to a tool', () => { const setup = async () => { - const schoolWithoutTool: School = schoolFactory.buildWithId(); - const school: School = schoolFactory.buildWithId(); + const schoolWithoutTool: SchoolEntity = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school: schoolWithoutTool }); const course: Course = courseFactory.buildWithId({ school, teachers: [adminUser] }); const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId(); @@ -656,7 +656,7 @@ describe('ToolController (API)', () => { describe('when user has access for a tool', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.CONTEXT_TOOL_USER, ]); diff --git a/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts b/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts index b9f4241cedd..89bbe0c2cb7 100644 --- a/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts +++ b/apps/server/src/modules/tool/school-external-tool/controller/api-test/tool-school.api.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, MikroORM } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Account, Permission, School, User } from '@shared/domain'; +import { Account, Permission, SchoolEntity, User } from '@shared/domain'; import { accountFactory, externalToolEntityFactory, @@ -53,7 +53,7 @@ describe('ToolSchoolController (API)', () => { describe('[POST] tools/school-external-tools', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, @@ -142,7 +142,7 @@ describe('ToolSchoolController (API)', () => { describe('[DELETE] tools/school-external-tools/:schoolExternalToolId', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, @@ -207,7 +207,7 @@ describe('ToolSchoolController (API)', () => { describe('[GET] tools/school-external-tools/', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, @@ -298,7 +298,7 @@ describe('ToolSchoolController (API)', () => { describe('[GET] tools/school-external-tools/:schoolExternalToolId', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, @@ -379,7 +379,7 @@ describe('ToolSchoolController (API)', () => { describe('[PUT] tools/school-external-tools/:schoolExternalToolId', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminUser, adminAccount } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.SCHOOL_TOOL_ADMIN, 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 b72ef8df76b..a1682e3b7cd 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 @@ -1,12 +1,12 @@ import { Embedded, Entity, ManyToOne, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; -import { School } from '@shared/domain/entity/school.entity'; +import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { CustomParameterEntryEntity } from '../../common/entity'; import { ExternalToolEntity } from '../../external-tool/entity'; export interface ISchoolExternalToolProperties { tool: ExternalToolEntity; - school: School; + school: SchoolEntity; schoolParameters?: CustomParameterEntryEntity[]; toolVersion: number; } @@ -16,8 +16,8 @@ export class SchoolExternalToolEntity extends BaseEntityWithTimestamps { @ManyToOne() tool: ExternalToolEntity; - @ManyToOne(() => School, { eager: true }) - school: School; + @ManyToOne(() => SchoolEntity, { eager: true }) + school: SchoolEntity; @Embedded(() => CustomParameterEntryEntity, { array: true }) schoolParameters: CustomParameterEntryEntity[]; diff --git a/apps/server/src/modules/tool/tool-launch/controller/api-test/tool-launch.controller.api.spec.ts b/apps/server/src/modules/tool/tool-launch/controller/api-test/tool-launch.controller.api.spec.ts index c1d4bd74cef..33512062711 100644 --- a/apps/server/src/modules/tool/tool-launch/controller/api-test/tool-launch.controller.api.spec.ts +++ b/apps/server/src/modules/tool/tool-launch/controller/api-test/tool-launch.controller.api.spec.ts @@ -1,7 +1,7 @@ import { EntityManager, MikroORM } from '@mikro-orm/core'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Course, Permission, School } from '@shared/domain'; +import { Course, Permission, SchoolEntity } from '@shared/domain'; import { basicToolConfigFactory, contextExternalToolFactory, @@ -55,7 +55,7 @@ describe('ToolLaunchController (API)', () => { describe('[GET] tools/context/{contextExternalToolId}/launch', () => { describe('when valid data is given', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_USER, ]); @@ -111,7 +111,7 @@ describe('ToolLaunchController (API)', () => { describe('when user wants to launch an outdated tool', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.CONTEXT_TOOL_USER, ]); @@ -162,8 +162,8 @@ describe('ToolLaunchController (API)', () => { describe('when user wants to launch tool from another school', () => { const setup = async () => { - const toolSchool: School = schoolFactory.buildWithId(); - const usersSchool: School = schoolFactory.buildWithId(); + const toolSchool: SchoolEntity = schoolFactory.buildWithId(); + const usersSchool: SchoolEntity = schoolFactory.buildWithId(); const { teacherUser, teacherAccount } = UserAndAccountTestFactory.buildTeacher({ school: usersSchool }, [ Permission.CONTEXT_TOOL_USER, 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 7b5071defad..215bc5acdba 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 @@ -8,7 +8,7 @@ import { MatchCreator, Permission, RoleName, - School, + SchoolEntity, SchoolFeatures, SortOrder, System, @@ -200,7 +200,7 @@ describe('ImportUser Controller (API)', () => { describe('When school is LDAP Migration Pilot School', () => { let user: User; - let school: School; + let school: SchoolEntity; let system: System; beforeEach(async () => { ({ school, system, user } = await authenticatedUser( @@ -221,7 +221,7 @@ describe('ImportUser Controller (API)', () => { describe('When current user has permission Permission.SCHOOL_IMPORT_USERS_VIEW', () => { let user: User; - let school: School; + let school: SchoolEntity; let system: System; beforeEach(async () => { ({ school, system, user } = await authenticatedUser([Permission.SCHOOL_IMPORT_USERS_VIEW])); @@ -264,7 +264,7 @@ describe('ImportUser Controller (API)', () => { }); describe('When current user has permission Permission.SCHOOL_IMPORT_USERS_UPDATE', () => { let user: User; - let school: School; + let school: SchoolEntity; let system: System; beforeEach(async () => { ({ user, school, system } = await authenticatedUser([Permission.SCHOOL_IMPORT_USERS_UPDATE])); @@ -355,7 +355,7 @@ describe('ImportUser Controller (API)', () => { describe('Business Errors', () => { let user: User; - let school: School; + let school: SchoolEntity; beforeEach(async () => { ({ user, school } = await authenticatedUser([Permission.SCHOOL_IMPORT_USERS_UPDATE])); currentUser = mapUserToCurrentUser(user); @@ -457,7 +457,7 @@ describe('ImportUser Controller (API)', () => { }; describe('find', () => { let user: User; - let school: School; + let school: SchoolEntity; beforeEach(async () => { await cleanupCollections(em); @@ -805,7 +805,7 @@ describe('ImportUser Controller (API)', () => { describe('updates', () => { let user: User; - let school: School; + let school: SchoolEntity; beforeEach(async () => { ({ user, school } = await authenticatedUser([Permission.SCHOOL_IMPORT_USERS_UPDATE])); currentUser = mapUserToCurrentUser(user); @@ -926,7 +926,7 @@ describe('ImportUser Controller (API)', () => { describe('[migrate]', () => { let user: User; - let school: School; + let school: SchoolEntity; beforeEach(async () => { ({ user, school } = await authenticatedUser([Permission.SCHOOL_IMPORT_USERS_MIGRATE])); school.officialSchoolNumber = 'foo'; diff --git a/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts b/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts index 0f2311da1b4..5e718058d37 100644 --- a/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts +++ b/apps/server/src/modules/user-import/uc/user-import.uc.spec.ts @@ -11,7 +11,7 @@ import { MatchCreator, MatchCreatorScope, Permission, - School, + SchoolEntity, SchoolFeatures, System, User, @@ -114,7 +114,7 @@ describe('[ImportUserModule]', () => { }); }; - const createMockSchoolDo = (school?: School): LegacySchoolDo => { + const createMockSchoolDo = (school?: SchoolEntity): LegacySchoolDo => { const name = school ? school.name : 'testSchool'; const id = school ? school.id : 'someId'; const features = school ? school.features ?? [SchoolFeatures.LDAP_UNIVENTION_MIGRATION] : []; @@ -453,7 +453,7 @@ describe('[ImportUserModule]', () => { describe('[saveAllUsersMatches]', () => { let system: System; - let school: School; + let school: SchoolEntity; let currentUser: User; let userMatch1: User; let userMatch2: User; @@ -590,7 +590,7 @@ describe('[ImportUserModule]', () => { describe('[startSchoolInUserMigration]', () => { let system: System; - let school: School; + let school: SchoolEntity; let currentUser: User; let userRepoByIdSpy: jest.SpyInstance; let permissionServiceSpy: jest.SpyInstance; @@ -694,7 +694,7 @@ describe('[ImportUserModule]', () => { }); describe('[endSchoolMaintenance]', () => { - let school: School; + let school: SchoolEntity; let currentUser: User; let userRepoByIdSpy: jest.SpyInstance; let permissionServiceSpy: jest.SpyInstance; diff --git a/apps/server/src/modules/user-login-migration/controller/api-test/user-login-migration.api.spec.ts b/apps/server/src/modules/user-login-migration/controller/api-test/user-login-migration.api.spec.ts index 9193d58d4fa..9f19a3ae71b 100644 --- a/apps/server/src/modules/user-login-migration/controller/api-test/user-login-migration.api.spec.ts +++ b/apps/server/src/modules/user-login-migration/controller/api-test/user-login-migration.api.spec.ts @@ -2,7 +2,7 @@ import { Configuration } from '@hpi-schul-cloud/commons/lib'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { HttpStatus, INestApplication } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; -import { Permission, School, System, User } from '@shared/domain'; +import { Permission, SchoolEntity, System, User } from '@shared/domain'; import { UserLoginMigration } from '@shared/domain/entity/user-login-migration.entity'; import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy'; import { @@ -71,7 +71,7 @@ describe('UserLoginMigrationController (API)', () => { const date: Date = new Date(2023, 5, 4); const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], }); const userLoginMigration: UserLoginMigration = userLoginMigrationFactory.buildWithId({ @@ -135,7 +135,7 @@ describe('UserLoginMigrationController (API)', () => { const date: Date = new Date(2023, 5, 4); const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], }); const userLoginMigration: UserLoginMigration = userLoginMigrationFactory.buildWithId({ @@ -183,7 +183,7 @@ describe('UserLoginMigrationController (API)', () => { describe('when no user login migration is found', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const { adminAccount, adminUser } = UserAndAccountTestFactory.buildAdmin({ school }, [ Permission.USER_LOGIN_MIGRATION_ADMIN, ]); @@ -221,7 +221,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -283,7 +283,7 @@ describe('UserLoginMigrationController (API)', () => { const date: Date = new Date(2023, 5, 4); const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -324,7 +324,7 @@ describe('UserLoginMigrationController (API)', () => { const date: Date = new Date(2023, 5, 4); const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -366,7 +366,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], }); @@ -453,7 +453,7 @@ describe('UserLoginMigrationController (API)', () => { const officialSchoolNumber = '12345'; const externalId = 'aef1f4fd-c323-466e-962b-a84354c0e713'; - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber, externalId, @@ -520,7 +520,7 @@ describe('UserLoginMigrationController (API)', () => { const officialSchoolNumber = '12345'; const externalId = 'aef1f4fd-c323-466e-962b-a84354c0e713'; - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber, externalId, @@ -595,7 +595,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -679,7 +679,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -719,7 +719,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -764,7 +764,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -807,7 +807,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -851,7 +851,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -883,7 +883,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -933,7 +933,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -975,7 +975,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -1040,7 +1040,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -1072,7 +1072,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -1118,7 +1118,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); @@ -1168,7 +1168,7 @@ describe('UserLoginMigrationController (API)', () => { const setup = async () => { const sourceSystem: System = systemFactory.withLdapConfig().buildWithId({ alias: 'SourceSystem' }); const targetSystem: System = systemFactory.withOauthConfig().buildWithId({ alias: 'SANIS' }); - const school: School = schoolFactory.buildWithId({ + const school: SchoolEntity = schoolFactory.buildWithId({ systems: [sourceSystem], officialSchoolNumber: '12345', }); diff --git a/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts b/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts index 38b5355f5e8..fad7295bee3 100644 --- a/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts +++ b/apps/server/src/modules/video-conference/controller/api-test/video-conference.api.spec.ts @@ -7,7 +7,7 @@ import { Permission, Role, RoleName, - School, + SchoolEntity, SchoolFeatures, TargetModels, User, @@ -161,7 +161,7 @@ describe('VideoConferenceController (API)', () => { describe('when the logoutUrl is from a wrong origin', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -201,7 +201,7 @@ describe('VideoConferenceController (API)', () => { describe('when conference params are given', () => { describe('when school has not enabled the school feature videoconference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -240,7 +240,7 @@ describe('VideoConferenceController (API)', () => { describe('when user has not the required permission', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const studentRole: Role = roleFactory.buildWithId({ name: RoleName.STUDENT, permissions: [Permission.JOIN_MEETING], @@ -282,7 +282,7 @@ describe('VideoConferenceController (API)', () => { describe('when user has the required permission', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -321,7 +321,7 @@ describe('VideoConferenceController (API)', () => { describe('when conference is for scope and scopeId is already running', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -372,7 +372,7 @@ describe('VideoConferenceController (API)', () => { describe('when scope and scopeId are given', () => { describe('when school has not enabled the school feature videoconference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -409,7 +409,7 @@ describe('VideoConferenceController (API)', () => { describe('when user has the required permission', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -449,7 +449,7 @@ describe('VideoConferenceController (API)', () => { describe('when conference is not running', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -498,7 +498,7 @@ describe('VideoConferenceController (API)', () => { describe('when scope and scopeId are given', () => { describe('when school has not enabled the school feature videoconference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -534,7 +534,7 @@ describe('VideoConferenceController (API)', () => { describe('when user has the required permission', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -571,7 +571,7 @@ describe('VideoConferenceController (API)', () => { describe('when guest want meeting info of conference without waiting room', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const expertRole: Role = roleFactory.buildWithId({ name: RoleName.EXPERT, @@ -612,7 +612,7 @@ describe('VideoConferenceController (API)', () => { describe('when conference is not running', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -661,7 +661,7 @@ describe('VideoConferenceController (API)', () => { describe('when scope and scopeId are given', () => { describe('when school has not enabled the school feature videoconference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, @@ -698,7 +698,7 @@ describe('VideoConferenceController (API)', () => { describe('when a user without required permission wants to end a conference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { studentAccount, studentUser } = UserAndAccountTestFactory.buildStudent({ school }, [ Permission.JOIN_MEETING, @@ -732,7 +732,7 @@ describe('VideoConferenceController (API)', () => { describe('when a user with required permission wants to end a conference', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); + const school: SchoolEntity = schoolFactory.buildWithId({ features: [SchoolFeatures.VIDEOCONFERENCE] }); const { teacherAccount, teacherUser } = UserAndAccountTestFactory.buildTeacher({ school }, [ Permission.START_MEETING, diff --git a/apps/server/src/shared/domain/entity/all-entities.ts b/apps/server/src/shared/domain/entity/all-entities.ts index 97069d23f8e..2b136fea610 100644 --- a/apps/server/src/shared/domain/entity/all-entities.ts +++ b/apps/server/src/shared/domain/entity/all-entities.ts @@ -34,7 +34,7 @@ import { LtiTool } from './ltitool.entity'; import { Material } from './materials.entity'; import { CourseNews, News, SchoolNews, TeamNews } from './news.entity'; import { Role } from './role.entity'; -import { School, SchoolRolePermission, SchoolRoles } from './school.entity'; +import { SchoolEntity, SchoolRolePermission, SchoolRoles } from './school.entity'; import { SchoolYear } from './schoolyear.entity'; import { StorageProviderEntity } from './storageprovider.entity'; import { Submission } from './submission.entity'; @@ -77,7 +77,7 @@ export const ALL_ENTITIES = [ PseudonymEntity, ExternalToolPseudonymEntity, Role, - School, + SchoolEntity, SchoolExternalToolEntity, SchoolNews, SchoolRolePermission, diff --git a/apps/server/src/shared/domain/entity/course.entity.ts b/apps/server/src/shared/domain/entity/course.entity.ts index 99d9304b4a3..7873772d38d 100644 --- a/apps/server/src/shared/domain/entity/course.entity.ts +++ b/apps/server/src/shared/domain/entity/course.entity.ts @@ -5,14 +5,14 @@ import { EntityId, LearnroomMetadata, LearnroomTypes } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import { CourseGroup } from './coursegroup.entity'; import type { ILessonParent } from './lesson.entity'; -import type { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; export interface ICourseProperties { name?: string; description?: string; - school: School; + school: SchoolEntity; students?: User[]; teachers?: User[]; substitutionTeachers?: User[]; @@ -48,8 +48,8 @@ export class Course description: string = DEFAULT.description; @Index() - @ManyToOne('School', { fieldName: 'schoolId' }) - school: School; + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) + school: SchoolEntity; @Index() @ManyToMany('User', undefined, { fieldName: 'userIds' }) diff --git a/apps/server/src/shared/domain/entity/coursegroup.entity.ts b/apps/server/src/shared/domain/entity/coursegroup.entity.ts index dc69180cd4f..52d357e3f57 100644 --- a/apps/server/src/shared/domain/entity/coursegroup.entity.ts +++ b/apps/server/src/shared/domain/entity/coursegroup.entity.ts @@ -4,7 +4,7 @@ import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; import type { ILessonParent } from './lesson.entity'; -import { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; import type { ITaskParent } from './task.entity'; import type { User } from './user.entity'; @@ -28,9 +28,9 @@ export class CourseGroup extends BaseEntityWithTimestamps implements IEntityWith @ManyToOne('Course', { fieldName: 'courseId' }) course: Course; - @ManyToOne('School', { fieldName: 'schoolId' }) + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) @Index() - school: School; + school: SchoolEntity; constructor(props: ICourseGroupProperties) { super(); 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 663ca6f8c86..6ff9eb22938 100644 --- a/apps/server/src/shared/domain/entity/import-user.entity.ts +++ b/apps/server/src/shared/domain/entity/import-user.entity.ts @@ -1,7 +1,7 @@ import { Entity, Enum, IdentifiedReference, ManyToOne, Property, Unique, wrap } from '@mikro-orm/core'; import { IEntityWithSchool, RoleName } from '../interface'; import { BaseEntityReference, BaseEntityWithTimestamps } from './base.entity'; -import type { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; import { System } from './system.entity'; import type { User } from './user.entity'; @@ -9,7 +9,7 @@ export type IImportUserRoleName = RoleName.ADMINISTRATOR | RoleName.TEACHER | Ro export interface IImportUserProperties { // references - school: School; + school: SchoolEntity; system: System; // external identifiers ldapDn: string; @@ -50,8 +50,8 @@ export class ImportUser extends BaseEntityWithTimestamps implements IEntityWithS if (props.flagged && props.flagged === true) this.flagged = true; } - @ManyToOne(() => 'School', { fieldName: 'schoolId', wrappedReference: true, eager: true }) - school: IdentifiedReference; + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId', wrappedReference: true, eager: true }) + school: IdentifiedReference; @ManyToOne(() => 'System', { wrappedReference: true }) system: IdentifiedReference; diff --git a/apps/server/src/shared/domain/entity/news.entity.ts b/apps/server/src/shared/domain/entity/news.entity.ts index 9bdcfdd03b8..7b22c38f364 100644 --- a/apps/server/src/shared/domain/entity/news.entity.ts +++ b/apps/server/src/shared/domain/entity/news.entity.ts @@ -1,7 +1,7 @@ import { Entity, Enum, Index, ManyToOne, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from './base.entity'; import type { Course } from './course.entity'; -import type { School } from './school.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'; @@ -11,7 +11,7 @@ export interface INewsProperties { title: string; content: string; displayAt: Date; - school: EntityId | School; + school: EntityId | SchoolEntity; creator: EntityId | User; target: EntityId | NewsTarget; @@ -58,8 +58,8 @@ export abstract class News extends BaseEntityWithTimestamps { @Enum() targetModel!: NewsTargetModel; - @ManyToOne('School', { fieldName: 'schoolId' }) - school!: School; + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) + school!: SchoolEntity; @ManyToOne('User', { fieldName: 'creatorId' }) creator!: User; @@ -98,8 +98,8 @@ export abstract class News extends BaseEntityWithTimestamps { @Entity({ discriminatorValue: NewsTargetModel.School }) export class SchoolNews extends News { - @ManyToOne('School') - target!: School; + @ManyToOne(() => SchoolEntity) + target!: SchoolEntity; constructor(props: INewsProperties) { super(props); diff --git a/apps/server/src/shared/domain/entity/school.entity.ts b/apps/server/src/shared/domain/entity/school.entity.ts index 072d7d78a21..eb746bfeafb 100644 --- a/apps/server/src/shared/domain/entity/school.entity.ts +++ b/apps/server/src/shared/domain/entity/school.entity.ts @@ -61,7 +61,7 @@ export class SchoolRoles { @Entity({ tableName: 'schools' }) @Index({ properties: ['externalId', 'systems'] }) -export class School extends BaseEntity { +export class SchoolEntity extends BaseEntity { @Property({ nullable: true }) features?: SchoolFeatures[]; diff --git a/apps/server/src/shared/domain/entity/submission.entity.ts b/apps/server/src/shared/domain/entity/submission.entity.ts index ab5761e1d0a..de86ba9f814 100644 --- a/apps/server/src/shared/domain/entity/submission.entity.ts +++ b/apps/server/src/shared/domain/entity/submission.entity.ts @@ -4,12 +4,12 @@ import { InternalServerErrorException } from '@nestjs/common'; import { EntityId } from '../types'; import { BaseEntityWithTimestamps } from './base.entity'; import type { CourseGroup } from './coursegroup.entity'; -import { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; import type { Task } from './task.entity'; import type { User } from './user.entity'; export interface ISubmissionProperties { - school: School; + school: SchoolEntity; task: Task; student: User; courseGroup?: CourseGroup; @@ -25,9 +25,9 @@ export interface ISubmissionProperties { @Index({ properties: ['student', 'teamMembers'] }) @Unique({ properties: ['student', 'task'] }) export class Submission extends BaseEntityWithTimestamps { - @ManyToOne('School', { fieldName: 'schoolId' }) + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) @Index() - school: School; + school: SchoolEntity; @ManyToOne('Task', { fieldName: 'homeworkId' }) @Index() diff --git a/apps/server/src/shared/domain/entity/task.entity.ts b/apps/server/src/shared/domain/entity/task.entity.ts index 1aa04aa45bd..f2cf9ebd73c 100644 --- a/apps/server/src/shared/domain/entity/task.entity.ts +++ b/apps/server/src/shared/domain/entity/task.entity.ts @@ -1,6 +1,6 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, OneToMany, Property } from '@mikro-orm/core'; import { InternalServerErrorException } from '@nestjs/common'; -import { School } from '@shared/domain/entity/school.entity'; +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'; @@ -75,8 +75,8 @@ export class Task extends BaseEntityWithTimestamps implements ILearnroomElement, course?: Course; @Index() - @ManyToOne('School', { fieldName: 'schoolId' }) - school: School; + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) + school: SchoolEntity; @Index() @ManyToOne('Lesson', { fieldName: 'lessonId', nullable: true }) diff --git a/apps/server/src/shared/domain/entity/team.entity.ts b/apps/server/src/shared/domain/entity/team.entity.ts index f1109d404d5..70e7d142885 100644 --- a/apps/server/src/shared/domain/entity/team.entity.ts +++ b/apps/server/src/shared/domain/entity/team.entity.ts @@ -1,7 +1,7 @@ import { Embeddable, Embedded, Entity, ManyToOne, Property } from '@mikro-orm/core'; import { BaseEntityWithTimestamps } from './base.entity'; import { Role } from './role.entity'; -import { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; import { User } from './user.entity'; export interface ITeamProperties { @@ -12,7 +12,7 @@ export interface ITeamProperties { export interface ITeamUserProperties { user: User; role: Role; - school: School; + school: SchoolEntity; } @Embeddable() @@ -29,8 +29,8 @@ export class TeamUserEntity { @ManyToOne(() => Role) role: Role; - @ManyToOne(() => School) - private schoolId: School; + @ManyToOne(() => SchoolEntity) + private schoolId: SchoolEntity; // fieldName cannot be used in ManyToOne on Embeddable due to a mikro-orm bug (https://github.com/mikro-orm/mikro-orm/issues/2165) get user(): User { @@ -41,11 +41,11 @@ export class TeamUserEntity { this.userId = value; } - get school(): School { + get school(): SchoolEntity { return this.schoolId; } - set school(value: School) { + set school(value: SchoolEntity) { this.schoolId = value; } } diff --git a/apps/server/src/shared/domain/entity/user-login-migration.entity.ts b/apps/server/src/shared/domain/entity/user-login-migration.entity.ts index 6e24e7338e6..15703688aff 100644 --- a/apps/server/src/shared/domain/entity/user-login-migration.entity.ts +++ b/apps/server/src/shared/domain/entity/user-login-migration.entity.ts @@ -1,5 +1,5 @@ import { Entity, ManyToOne, OneToOne, Property } from '@mikro-orm/core'; -import { School } from '@shared/domain/entity/school.entity'; +import { SchoolEntity } from '@shared/domain/entity/school.entity'; import { System } from '@shared/domain/entity/system.entity'; import { BaseEntityWithTimestamps } from './base.entity'; @@ -7,8 +7,8 @@ export type IUserLoginMigration = Readonly School, undefined, { nullable: false }) - school: School; + @OneToOne(() => SchoolEntity, undefined, { nullable: false }) + school: SchoolEntity; // undefined, if migrating from 'local' @ManyToOne(() => System, { nullable: true }) diff --git a/apps/server/src/shared/domain/entity/user.entity.ts b/apps/server/src/shared/domain/entity/user.entity.ts index 09ae4d2a65a..2d1918e1d61 100644 --- a/apps/server/src/shared/domain/entity/user.entity.ts +++ b/apps/server/src/shared/domain/entity/user.entity.ts @@ -2,7 +2,7 @@ import { Collection, Entity, Index, ManyToMany, ManyToOne, Property } from '@mik import { IEntityWithSchool } from '../interface'; import { BaseEntityWithTimestamps } from './base.entity'; import { Role } from './role.entity'; -import type { School } from './school.entity'; +import { SchoolEntity } from './school.entity'; export enum LanguageType { DE = 'de', @@ -15,7 +15,7 @@ export interface IUserProperties { email: string; firstName: string; lastName: string; - school: School; + school: SchoolEntity; roles: Role[]; ldapDn?: string; externalId?: string; @@ -51,8 +51,8 @@ export class User extends BaseEntityWithTimestamps implements IEntityWithSchool roles = new Collection(this); @Index() - @ManyToOne('School', { fieldName: 'schoolId' }) - school: School; + @ManyToOne(() => SchoolEntity, { fieldName: 'schoolId' }) + school: SchoolEntity; @Property({ nullable: true }) @Index() diff --git a/apps/server/src/shared/domain/interface/entity.ts b/apps/server/src/shared/domain/interface/entity.ts index a5f243c356b..dc28d8469d3 100644 --- a/apps/server/src/shared/domain/interface/entity.ts +++ b/apps/server/src/shared/domain/interface/entity.ts @@ -1,5 +1,5 @@ import { ObjectId } from '@mikro-orm/mongodb'; -import { School } from '@shared/domain/entity/school.entity'; +import { SchoolEntity } from '@shared/domain/entity/school.entity'; export interface IEntity { _id: ObjectId; @@ -12,5 +12,5 @@ export interface IEntityWithTimestamps extends IEntity { } export interface IEntityWithSchool extends IEntity { - school: School; + school: SchoolEntity; } diff --git a/apps/server/src/shared/domain/types/news.types.ts b/apps/server/src/shared/domain/types/news.types.ts index fbffcfa3710..241b4d90384 100644 --- a/apps/server/src/shared/domain/types/news.types.ts +++ b/apps/server/src/shared/domain/types/news.types.ts @@ -1,6 +1,6 @@ import { EntityId } from './entity-id'; import type { Course } from '../entity/course.entity'; -import type { School } from '../entity/school.entity'; +import type { SchoolEntity } from '../entity/school.entity'; import type { TeamEntity } from '../entity/team.entity'; export enum NewsTargetModel { @@ -26,4 +26,4 @@ export interface INewsScope { unpublished?: boolean; } -export type NewsTarget = School | TeamEntity | Course; +export type NewsTarget = SchoolEntity | TeamEntity | Course; diff --git a/apps/server/src/shared/domain/types/task.types.ts b/apps/server/src/shared/domain/types/task.types.ts index 5d33ef4a9d3..af524f34a9d 100644 --- a/apps/server/src/shared/domain/types/task.types.ts +++ b/apps/server/src/shared/domain/types/task.types.ts @@ -1,4 +1,4 @@ -import type { Course, InputFormat, Lesson, School, Submission, User } from '@shared/domain/'; +import type { Course, InputFormat, Lesson, SchoolEntity, Submission, User } from '@shared/domain/'; interface ITask { name: string; @@ -22,7 +22,7 @@ export interface ITaskProperties extends ITask { course?: Course; lesson?: Lesson; creator: User; - school: School; + school: SchoolEntity; finished?: User[]; private?: boolean; submissions?: Submission[]; diff --git a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts index ddff5660b2b..7c02cbc8a75 100644 --- a/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/contextexternaltool/context-external-tool.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager, ObjectId } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { School } from '@shared/domain'; +import { SchoolEntity } from '@shared/domain'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; import { ExternalToolRepoMapper } from '@shared/repo/externaltool/external-tool.repo.mapper'; import { @@ -51,7 +51,7 @@ describe('ContextExternalToolRepo', () => { }); const createExternalTools = () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const schoolExternalTool1: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({ school }); const schoolExternalTool2: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({ school }); const contextExternalTool1: ContextExternalToolEntity = contextExternalToolEntityFactory.buildWithId({ diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts b/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts index 9981f610413..7f02bf4ea01 100644 --- a/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/importuser/importuser.repo.integration.spec.ts @@ -9,7 +9,7 @@ import { MatchCreator, MatchCreatorScope, RoleName, - School, + SchoolEntity, User, } from '@shared/domain'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; @@ -132,16 +132,16 @@ describe('ImportUserRepo', () => { const importUser = importUserFactory.build({ school }); const otherSchoolsImportUser = importUserFactory.build(); await em.persistAndFlush([school, importUser, otherSchoolsImportUser]); - await expect(async () => repo.findImportUsers({ _id: 'invalid_id' } as unknown as School)).rejects.toThrowError( - 'invalid school id' - ); + await expect(async () => + repo.findImportUsers({ _id: 'invalid_id' } as unknown as SchoolEntity) + ).rejects.toThrowError('invalid school id'); }); it('should not respond with any school for wrong id given', async () => { const school = schoolFactory.build(); const importUser = importUserFactory.build({ school }); const otherSchoolsImportUser = importUserFactory.build(); await em.persistAndFlush([school, importUser, otherSchoolsImportUser]); - await expect(async () => repo.findImportUsers({} as unknown as School)).rejects.toThrowError( + await expect(async () => repo.findImportUsers({} as unknown as SchoolEntity)).rejects.toThrowError( 'invalid school id' ); }); diff --git a/apps/server/src/shared/repo/importuser/importuser.repo.ts b/apps/server/src/shared/repo/importuser/importuser.repo.ts index 0a911a7cfd3..c09e5f9ee87 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, School, 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'; @@ -32,7 +32,7 @@ export class ImportUserRepo extends BaseRepo { } async findImportUsers( - school: School, + school: SchoolEntity, filters: IImportUserScope = {}, options?: IFindOptions ): Promise> { @@ -66,7 +66,7 @@ export class ImportUserRepo extends BaseRepo { return [importUserEntities, count]; } - async deleteImportUsersBySchool(school: School): Promise { + async deleteImportUsersBySchool(school: SchoolEntity): Promise { await this._em.nativeDelete(ImportUser, { school }); } } diff --git a/apps/server/src/shared/repo/importuser/importuser.scope.ts b/apps/server/src/shared/repo/importuser/importuser.scope.ts index bb310fe251d..025d562f5f4 100644 --- a/apps/server/src/shared/repo/importuser/importuser.scope.ts +++ b/apps/server/src/shared/repo/importuser/importuser.scope.ts @@ -2,12 +2,12 @@ import { FilterQuery } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import { StringValidator } from '@shared/common'; -import { ImportUser, MatchCreatorScope, RoleName, School, User } from '@shared/domain'; +import { ImportUser, MatchCreatorScope, RoleName, SchoolEntity, User } from '@shared/domain'; import { MongoPatterns } from '../mongo.patterns'; import { Scope } from '../scope'; export class ImportUserScope extends Scope { - bySchool(school: School): ImportUserScope { + bySchool(school: SchoolEntity): ImportUserScope { const schoolId = school._id; if (!ObjectId.isValid(schoolId)) throw new Error('invalid school id'); this.addQuery({ school }); 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 5cd81119d20..09c00d14171 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 @@ -6,7 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { ISchoolProperties, LegacySchoolDo, - School, + SchoolEntity, SchoolRolePermission, SchoolRoles, SchoolYear, @@ -45,7 +45,7 @@ describe('LegacySchoolRepo', () => { }); beforeEach(async () => { - await em.nativeDelete(School, {}); + await em.nativeDelete(SchoolEntity, {}); await em.nativeDelete(SchoolYear, {}); em.clear(); jest.resetAllMocks(); @@ -56,7 +56,7 @@ describe('LegacySchoolRepo', () => { }); it('should implement entityName getter', () => { - expect(repo.entityName).toBe(School); + expect(repo.entityName).toBe(SchoolEntity); }); describe('save is called', () => { @@ -99,7 +99,7 @@ describe('LegacySchoolRepo', () => { expect(storedSchoolYears).toHaveLength(1); expect(storedSchoolYears[0]).toEqual(schoolYear); - const storedSchools = await em.find(School, {}); + const storedSchools = await em.find(SchoolEntity, {}); expect(storedSchools).toHaveLength(1); const storedSchool = storedSchools[0]; @@ -115,7 +115,7 @@ describe('LegacySchoolRepo', () => { describe('findByExternalId', () => { it('should find school by external ID', async () => { const system: System = systemFactory.buildWithId(); - const schoolEntity: School = schoolFactory.build({ externalId: 'externalId' }); + const schoolEntity: SchoolEntity = schoolFactory.build({ externalId: 'externalId' }); schoolEntity.systems.add(system); await em.persistAndFlush(schoolEntity); @@ -140,7 +140,7 @@ describe('LegacySchoolRepo', () => { describe('findBySchoolNumber', () => { it('should find school by schoolnumber', async () => { - const schoolEntity: School = schoolFactory.build({ officialSchoolNumber: '12345' }); + const schoolEntity: SchoolEntity = schoolFactory.build({ officialSchoolNumber: '12345' }); await em.persistAndFlush(schoolEntity); @@ -158,8 +158,8 @@ describe('LegacySchoolRepo', () => { describe('when there is more than school with the same officialSchoolNumber', () => { const setup = async () => { const officialSchoolNumber = '12345'; - const schoolEntity: School = schoolFactory.build({ officialSchoolNumber }); - const schoolEntity2: School = schoolFactory.build({ officialSchoolNumber }); + const schoolEntity: SchoolEntity = schoolFactory.build({ officialSchoolNumber }); + const schoolEntity2: SchoolEntity = schoolFactory.build({ officialSchoolNumber }); await em.persistAndFlush([schoolEntity, schoolEntity2]); @@ -184,7 +184,7 @@ describe('LegacySchoolRepo', () => { it('should map school entity to school domain object', () => { const system: System = systemFactory.buildWithId(); const schoolYear: SchoolYear = schoolYearFactory.buildWithId(); - const schoolEntity: School = schoolFactory.buildWithId({ systems: [system], features: [], schoolYear }); + const schoolEntity: SchoolEntity = schoolFactory.buildWithId({ systems: [system], features: [], schoolYear }); const userLoginMigration: UserLoginMigration = userLoginMigrationFactory.build({ school: schoolEntity }); schoolEntity.userLoginMigration = userLoginMigration; @@ -209,7 +209,7 @@ describe('LegacySchoolRepo', () => { }); it('should return an empty array for systems when entity systems is not initialized', () => { - const schoolEntity: School = schoolFactory.buildWithId({ systems: undefined }); + const schoolEntity: SchoolEntity = schoolFactory.buildWithId({ systems: undefined }); const schoolDO = repo.mapEntityToDO(schoolEntity); 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 f305d145125..3c8018c63aa 100644 --- a/apps/server/src/shared/repo/school/legacy-school.repo.ts +++ b/apps/server/src/shared/repo/school/legacy-school.repo.ts @@ -1,7 +1,7 @@ import { EntityName } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; import { Injectable, InternalServerErrorException } from '@nestjs/common'; -import { EntityId, ISchoolProperties, LegacySchoolDo, School, System, UserLoginMigration } from '@shared/domain'; +import { EntityId, ISchoolProperties, LegacySchoolDo, SchoolEntity, System, UserLoginMigration } from '@shared/domain'; import { LegacyLogger } from '@src/core/logger'; import { BaseDORepo } from '../base.do.repo'; @@ -9,24 +9,24 @@ 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); } - get entityName(): EntityName { - return School; + get entityName(): EntityName { + return SchoolEntity; } async findByExternalId(externalId: string, systemId: string): Promise { - const school: School | null = await this._em.findOne(School, { externalId, systems: systemId }); + const school: SchoolEntity | null = await this._em.findOne(SchoolEntity, { externalId, systems: systemId }); const schoolDo: LegacySchoolDo | null = school ? this.mapEntityToDO(school) : null; return schoolDo; } async findBySchoolNumber(officialSchoolNumber: string): Promise { - const [schools, count] = await this._em.findAndCount(School, { officialSchoolNumber }); + const [schools, count] = await this._em.findAndCount(SchoolEntity, { officialSchoolNumber }); if (count > 1) { throw new InternalServerErrorException(`Multiple schools found for officialSchoolNumber ${officialSchoolNumber}`); } @@ -35,11 +35,11 @@ export class LegacySchoolRepo extends BaseDORepo { const createTools = () => { const externalToolEntity: ExternalToolEntity = externalToolEntityFactory.buildWithId(); - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const schoolExternalTool1: SchoolExternalToolEntity = schoolExternalToolEntityFactory.buildWithId({ tool: externalToolEntity, 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 e53221fe370..bc9ab0cc868 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,7 +1,7 @@ import { EntityName } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common/decorators/core/injectable.decorator'; -import { School } from '@shared/domain'; +import { SchoolEntity } from '@shared/domain'; import { BaseDORepo } from '@shared/repo/base.do.repo'; import { LegacyLogger } from '@src/core/logger'; import { SchoolExternalToolQuery } from '@src/modules/tool/school-external-tool/uc/dto/school-external-tool.types'; @@ -83,7 +83,7 @@ export class SchoolExternalToolRepo extends BaseDORepo< mapDOToEntityProperties(entityDO: SchoolExternalTool): ISchoolExternalToolProperties { return { - school: this._em.getReference(School, entityDO.schoolId), + school: this._em.getReference(SchoolEntity, entityDO.schoolId), tool: this._em.getReference(ExternalToolEntity, entityDO.toolId), toolVersion: entityDO.toolVersion, schoolParameters: ExternalToolRepoMapper.mapCustomParameterEntryDOsToEntities(entityDO.parameters), 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 b4432d0e5cc..c6eff493b85 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 @@ -9,7 +9,7 @@ import { LanguageType, Role, RoleName, - School, + SchoolEntity, SortOrder, System, User, @@ -142,7 +142,7 @@ describe('UserRepo', () => { describe('findByExternalId', () => { const externalId = 'externalId'; let system: System; - let school: School; + let school: SchoolEntity; let user: User; beforeEach(async () => { @@ -186,7 +186,7 @@ describe('UserRepo', () => { describe('findByExternalIdOrFail', () => { const externalId = 'externalId'; let system: System; - let school: School; + let school: SchoolEntity; let user: User; beforeEach(async () => { @@ -310,7 +310,7 @@ describe('UserRepo', () => { firstName: testDO.firstName, lastName: testDO.lastName, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - school: expect.objectContaining>({ id: testDO.schoolId }), + school: expect.objectContaining>({ id: testDO.schoolId }), // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment roles: [expect.objectContaining>({ id: testDO.roles[0].id })], ldapDn: testDO.ldapDn, @@ -339,7 +339,7 @@ describe('UserRepo', () => { const options: IFindOptions = {}; await em.nativeDelete(User, {}); - await em.nativeDelete(School, {}); + await em.nativeDelete(SchoolEntity, {}); const userA: User = userFactory.buildWithId({ firstName: 'A' }); const userB: User = userFactory.buildWithId({ firstName: 'B' }); @@ -463,7 +463,7 @@ describe('UserRepo', () => { const options: IFindOptions = {}; await em.nativeDelete(User, {}); - await em.nativeDelete(School, {}); + await em.nativeDelete(SchoolEntity, {}); const userA: User = userFactory.buildWithId({ firstName: 'A' }); const userB: User = userFactory.buildWithId({ firstName: 'B' }); 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 99b3a294c38..f220195f46c 100644 --- a/apps/server/src/shared/repo/user/user-do.repo.ts +++ b/apps/server/src/shared/repo/user/user-do.repo.ts @@ -7,7 +7,7 @@ import { IPagination, IUserProperties, Role, - School, + SchoolEntity, SortOrder, SortOrderMap, System, @@ -125,7 +125,7 @@ export class UserDORepo extends BaseDORepo { email: entityDO.email, firstName: entityDO.firstName, lastName: entityDO.lastName, - school: this._em.getReference(School, entityDO.schoolId), + school: this._em.getReference(SchoolEntity, entityDO.schoolId), roles: entityDO.roles.map((roleRef: RoleReference) => this._em.getReference(Role, roleRef.id)), ldapDn: entityDO.ldapDn, externalId: entityDO.externalId, diff --git a/apps/server/src/shared/repo/user/user.repo.ts b/apps/server/src/shared/repo/user/user.repo.ts index b0e5887c60e..32aa38578a0 100644 --- a/apps/server/src/shared/repo/user/user.repo.ts +++ b/apps/server/src/shared/repo/user/user.repo.ts @@ -2,7 +2,17 @@ import { QueryOrderMap, QueryOrderNumeric } from '@mikro-orm/core'; import { ObjectId } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; import { StringValidator } from '@shared/common'; -import { Counted, EntityId, IFindOptions, ImportUser, INameMatch, Role, School, SortOrder, User } from '@shared/domain'; +import { + Counted, + EntityId, + IFindOptions, + ImportUser, + INameMatch, + Role, + SchoolEntity, + SortOrder, + User, +} from '@shared/domain'; import { BaseRepo } from '@shared/repo/base.repo'; import { MongoPatterns } from '../mongo.patterns'; @@ -36,7 +46,7 @@ export class UserRepo extends BaseRepo { * used for importusers module to request users not referenced in importusers */ async findWithoutImportUser( - school: School, + school: SchoolEntity, filters?: INameMatch, options?: IFindOptions ): Promise> { diff --git a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts index 287a38c64ec..be24029a942 100644 --- a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts +++ b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.integration.spec.ts @@ -1,7 +1,7 @@ import { createMock } from '@golevelup/ts-jest'; import { EntityManager } from '@mikro-orm/mongodb'; import { Test, TestingModule } from '@nestjs/testing'; -import { School, System, UserLoginMigrationDO } from '@shared/domain'; +import { SchoolEntity, System, UserLoginMigrationDO } from '@shared/domain'; import { UserLoginMigration } from '@shared/domain/entity/user-login-migration.entity'; import { MongoMemoryDatabaseModule } from '@shared/infra/database'; import { cleanupCollections, schoolFactory, systemFactory } from '@shared/testing'; @@ -41,7 +41,7 @@ describe('UserLoginMigrationRepo', () => { describe('save', () => { describe('when saving a UserLoginMigrationDO', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId(); + const school: SchoolEntity = schoolFactory.buildWithId(); const sourceSystem: System = systemFactory.buildWithId(); const targetSystem: System = systemFactory.buildWithId(); @@ -97,7 +97,7 @@ describe('UserLoginMigrationRepo', () => { await repo.delete(domainObject); - await em.findOneOrFail(School, { id: school.id }); + await em.findOneOrFail(SchoolEntity, { id: school.id }); }); }); }); @@ -129,7 +129,7 @@ describe('UserLoginMigrationRepo', () => { describe('when searching for a UserLoginMigration by an unknown school id', () => { const setup = async () => { - const school: School = schoolFactory.buildWithId({ userLoginMigration: undefined }); + const school: SchoolEntity = schoolFactory.buildWithId({ userLoginMigration: undefined }); await em.persistAndFlush(school); em.clear(); diff --git a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.ts b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.ts index 8b9a7270a8f..f404a7b7209 100644 --- a/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.ts +++ b/apps/server/src/shared/repo/userloginmigration/user-login-migration.repo.ts @@ -1,7 +1,7 @@ import { EntityName } from '@mikro-orm/core'; import { EntityManager } from '@mikro-orm/mongodb'; import { Injectable } from '@nestjs/common'; -import { EntityId, School, System, UserLoginMigrationDO } from '@shared/domain'; +import { EntityId, SchoolEntity, System, UserLoginMigrationDO } from '@shared/domain'; import { IUserLoginMigration, UserLoginMigration } from '@shared/domain/entity/user-login-migration.entity'; import { LegacyLogger } from '@src/core/logger'; import { BaseDORepo } from '../base.do.repo'; @@ -50,7 +50,7 @@ export class UserLoginMigrationRepo extends BaseDORepo(School, ({ sequence }) => { +export const schoolFactory = BaseFactory.define(SchoolEntity, ({ sequence }) => { return { name: `school #${sequence}`, schoolYear: schoolYearFactory.build(), diff --git a/apps/server/src/shared/testing/factory/user-and-account.test.factory.ts b/apps/server/src/shared/testing/factory/user-and-account.test.factory.ts index 7896e1870a2..a59bd25d1ea 100644 --- a/apps/server/src/shared/testing/factory/user-and-account.test.factory.ts +++ b/apps/server/src/shared/testing/factory/user-and-account.test.factory.ts @@ -1,4 +1,4 @@ -import { Account, EntityId, Permission, School, User } from '@shared/domain'; +import { Account, EntityId, Permission, SchoolEntity, User } from '@shared/domain'; import { ObjectId } from 'bson'; import _ from 'lodash'; import { accountFactory } from './account.factory'; @@ -8,7 +8,7 @@ interface UserParams { firstName?: string; lastName?: string; email?: string; - school?: School; + school?: SchoolEntity; externalId?: string; }