From d220545ded632a402947e7274a2211a387b01717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Fri, 14 Apr 2023 16:03:46 +0100 Subject: [PATCH 01/14] refactor: change type for constants on team module --- .../services/create.board.service.spec.ts | 2 +- .../boards/services/create.board.service.ts | 4 ++-- .../boards/services/get.board.service.spec.ts | 2 +- .../boards/services/get.board.service.ts | 4 ++-- .../applications/create.team.application.ts | 4 ++-- .../applications/delete.team.application.ts | 4 ++-- .../applications/get.team.application.ts | 4 ++-- backend/src/modules/teams/constants.ts | 13 ++++++++++ .../teams/controller/team.controller.ts | 12 ++++++---- backend/src/modules/teams/interfaces/types.ts | 17 ------------- backend/src/modules/teams/providers.ts | 24 ++++++++++++------- .../services/create.team.service.spec.ts | 2 +- .../teams/services/create.team.service.ts | 4 ++-- .../services/delete.team.service.spec.ts | 2 +- .../teams/services/delete.team.service.ts | 8 +++---- .../teams/services/get.team.service.spec.ts | 2 +- .../teams/services/get.team.service.ts | 8 +++---- 17 files changed, 62 insertions(+), 54 deletions(-) create mode 100644 backend/src/modules/teams/constants.ts delete mode 100644 backend/src/modules/teams/interfaces/types.ts diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 91a976d51..2dbe7495c 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Teams from 'src/modules/teams/interfaces/types'; +import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index 88588d7a7..7b08262da 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -17,7 +17,6 @@ import * as SchedulesType from 'src/modules/schedules/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; -import { TYPES as TeamType } from 'src/modules/teams/interfaces/types'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import User from 'src/modules/users/entities/user.schema'; @@ -38,6 +37,7 @@ import { import { Configs } from '../dto/configs.dto'; import { TEAM_NOT_FOUND, TEAM_USERS_NOT_FOUND } from 'src/libs/exceptions/messages'; import { CreateFailedException } from 'src/libs/exceptions/createFailedBadRequestException'; +import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; type CreateBoardAndUsers = { boardData: BoardDto; @@ -49,7 +49,7 @@ export default class CreateBoardService implements CreateBoardServiceInterface { private logger = new Logger(CreateBoardService.name); constructor( - @Inject(forwardRef(() => TeamType.services.GetTeamService)) + @Inject(forwardRef(() => GET_TEAM_SERVICE)) private getTeamService: GetTeamServiceInterface, @Inject(TeamUsers.TYPES.services.GetTeamUserService) private getTeamUserService: GetTeamUserServiceInterface, diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index fba3a1bf0..02d195023 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -11,7 +11,7 @@ import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Teams from 'src/modules/teams/interfaces/types'; +import * as Teams from 'src/modules/teams/constants'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; diff --git a/backend/src/modules/boards/services/get.board.service.ts b/backend/src/modules/boards/services/get.board.service.ts index d2d4c60f9..b67052753 100644 --- a/backend/src/modules/boards/services/get.board.service.ts +++ b/backend/src/modules/boards/services/get.board.service.ts @@ -2,7 +2,6 @@ import { GetBoardUserServiceInterface } from '../../boardUsers/interfaces/servic import { Inject, Injectable, NotFoundException, forwardRef } from '@nestjs/common'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; -import * as Teams from 'src/modules/teams/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { QueryType } from '../interfaces/findQuery'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; @@ -10,11 +9,12 @@ import { cleanBoard } from '../utils/clean-board'; import { TYPES } from '../interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import UserDto from 'src/modules/users/dto/user.dto'; +import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; @Injectable() export default class GetBoardService implements GetBoardServiceInterface { constructor( - @Inject(forwardRef(() => Teams.TYPES.services.GetTeamService)) + @Inject(forwardRef(() => GET_TEAM_SERVICE)) private getTeamService: GetTeamServiceInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) private getBoardUserService: GetBoardUserServiceInterface, diff --git a/backend/src/modules/teams/applications/create.team.application.ts b/backend/src/modules/teams/applications/create.team.application.ts index cdf154fcf..59adbbc9e 100644 --- a/backend/src/modules/teams/applications/create.team.application.ts +++ b/backend/src/modules/teams/applications/create.team.application.ts @@ -2,12 +2,12 @@ import { Inject, Injectable } from '@nestjs/common'; import TeamDto from '../dto/team.dto'; import { CreateTeamApplicationInterface } from '../interfaces/applications/create.team.application.interface'; import { CreateTeamServiceInterface } from '../interfaces/services/create.team.service.interface'; -import { TYPES } from '../interfaces/types'; +import { CREATE_TEAM_SERVICE } from '../constants'; @Injectable() export class CreateTeamApplication implements CreateTeamApplicationInterface { constructor( - @Inject(TYPES.services.CreateTeamService) + @Inject(CREATE_TEAM_SERVICE) private readonly createTeamService: CreateTeamServiceInterface ) {} diff --git a/backend/src/modules/teams/applications/delete.team.application.ts b/backend/src/modules/teams/applications/delete.team.application.ts index 1be6aabed..9ddfbc34a 100644 --- a/backend/src/modules/teams/applications/delete.team.application.ts +++ b/backend/src/modules/teams/applications/delete.team.application.ts @@ -1,11 +1,11 @@ import { Inject, Injectable } from '@nestjs/common'; import { DeleteTeamApplicationInterface } from '../interfaces/applications/delete.team.application.interface'; -import { TYPES } from '../interfaces/types'; +import { DELETE_TEAM_SERVICE } from '../constants'; @Injectable() export class DeleteTeamApplication implements DeleteTeamApplicationInterface { constructor( - @Inject(TYPES.services.DeleteTeamService) + @Inject(DELETE_TEAM_SERVICE) private deleteTeamServices: DeleteTeamApplicationInterface ) {} diff --git a/backend/src/modules/teams/applications/get.team.application.ts b/backend/src/modules/teams/applications/get.team.application.ts index 999e0c8d4..9e24d2fc5 100644 --- a/backend/src/modules/teams/applications/get.team.application.ts +++ b/backend/src/modules/teams/applications/get.team.application.ts @@ -2,12 +2,12 @@ import { Inject, Injectable } from '@nestjs/common'; import { TeamQueryParams } from '../../../libs/dto/param/team.query.params'; import { GetTeamApplicationInterface } from '../interfaces/applications/get.team.application.interface'; import { GetTeamServiceInterface } from '../interfaces/services/get.team.service.interface'; -import { TYPES } from '../interfaces/types'; +import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; @Injectable() export class GetTeamApplication implements GetTeamApplicationInterface { constructor( - @Inject(TYPES.services.GetTeamService) + @Inject(GET_TEAM_SERVICE) private getTeamService: GetTeamServiceInterface ) {} diff --git a/backend/src/modules/teams/constants.ts b/backend/src/modules/teams/constants.ts new file mode 100644 index 000000000..000a00b0b --- /dev/null +++ b/backend/src/modules/teams/constants.ts @@ -0,0 +1,13 @@ +export const CREATE_TEAM_SERVICE = 'CreateTeamService'; + +export const GET_TEAM_SERVICE = 'GetTeamService'; + +export const DELETE_TEAM_SERVICE = 'DeleteTeamService'; + +export const CREATE_TEAM_APPLICATION = 'CreateTeamApplication'; + +export const GET_TEAM_APPLICATION = 'GetTeamApplication'; + +export const DELETE_TEAM_APPLICATION = 'DeleteTeamApplication'; + +export const TEAM_REPOSITORY = 'TeamRepository'; diff --git a/backend/src/modules/teams/controller/team.controller.ts b/backend/src/modules/teams/controller/team.controller.ts index dd86e811f..78dbbf603 100644 --- a/backend/src/modules/teams/controller/team.controller.ts +++ b/backend/src/modules/teams/controller/team.controller.ts @@ -39,7 +39,11 @@ import { TeamUserGuard } from '../../../libs/guards/teamRoles.guard'; import { ForbiddenResponse } from '../../../libs/swagger/errors/forbidden.swagger'; import { CreateTeamDto } from '../dto/create-team.dto'; import TeamDto from '../dto/team.dto'; -import { TYPES } from '../interfaces/types'; +import { + CREATE_TEAM_APPLICATION, + DELETE_TEAM_APPLICATION, + GET_TEAM_APPLICATION +} from '../constants'; import { SuperAdminGuard } from 'src/libs/guards/superAdmin.guard'; import { CreateTeamApplicationInterface } from '../interfaces/applications/create.team.application.interface'; import { GetTeamApplicationInterface } from '../interfaces/applications/get.team.application.interface'; @@ -53,11 +57,11 @@ const TeamUserPermission = (permissions: string[]) => SetMetadata('permissions', @Controller('teams') export default class TeamsController { constructor( - @Inject(TYPES.applications.CreateTeamApplication) + @Inject(CREATE_TEAM_APPLICATION) private createTeamApp: CreateTeamApplicationInterface, - @Inject(TYPES.applications.GetTeamApplication) + @Inject(GET_TEAM_APPLICATION) private getTeamApp: GetTeamApplicationInterface, - @Inject(TYPES.applications.DeleteTeamApplication) + @Inject(DELETE_TEAM_APPLICATION) private deleteTeamApp: DeleteTeamApplicationInterface ) {} diff --git a/backend/src/modules/teams/interfaces/types.ts b/backend/src/modules/teams/interfaces/types.ts deleted file mode 100644 index 4bed984f0..000000000 --- a/backend/src/modules/teams/interfaces/types.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const TYPES = { - services: { - CreateTeamService: 'CreateTeamService', - GetTeamService: 'GetTeamService', - UpdateTeamService: 'UpdateTeamService', - DeleteTeamService: 'DeleteTeamService' - }, - applications: { - CreateTeamApplication: 'CreateTeamApplication', - GetTeamApplication: 'GetTeamApplication', - UpdateTeamApplication: 'UpdateTeamApplication', - DeleteTeamApplication: 'DeleteTeamApplication' - }, - repositories: { - TeamRepository: 'TeamRepository' - } -}; diff --git a/backend/src/modules/teams/providers.ts b/backend/src/modules/teams/providers.ts index 2d7fcce25..82a7077c7 100644 --- a/backend/src/modules/teams/providers.ts +++ b/backend/src/modules/teams/providers.ts @@ -1,43 +1,51 @@ import { CreateTeamApplication } from './applications/create.team.application'; import { DeleteTeamApplication } from './applications/delete.team.application'; import { GetTeamApplication } from './applications/get.team.application'; -import { TYPES } from './interfaces/types'; +import { + CREATE_TEAM_APPLICATION, + CREATE_TEAM_SERVICE, + DELETE_TEAM_APPLICATION, + DELETE_TEAM_SERVICE, + GET_TEAM_APPLICATION, + GET_TEAM_SERVICE, + TEAM_REPOSITORY +} from './constants'; import { TeamRepository } from './repositories/team.repository'; import CreateTeamService from './services/create.team.service'; import DeleteTeamService from './services/delete.team.service'; import GetTeamService from './services/get.team.service'; export const createTeamService = { - provide: TYPES.services.CreateTeamService, + provide: CREATE_TEAM_SERVICE, useClass: CreateTeamService }; export const createTeamApplication = { - provide: TYPES.applications.CreateTeamApplication, + provide: CREATE_TEAM_APPLICATION, useClass: CreateTeamApplication }; export const getTeamService = { - provide: TYPES.services.GetTeamService, + provide: GET_TEAM_SERVICE, useClass: GetTeamService }; export const getTeamApplication = { - provide: TYPES.applications.GetTeamApplication, + provide: GET_TEAM_APPLICATION, useClass: GetTeamApplication }; export const deleteTeamService = { - provide: TYPES.services.DeleteTeamService, + provide: DELETE_TEAM_SERVICE, useClass: DeleteTeamService }; export const deleteTeamApplication = { - provide: TYPES.applications.DeleteTeamApplication, + provide: DELETE_TEAM_APPLICATION, useClass: DeleteTeamApplication }; export const teamRepository = { - provide: TYPES.repositories.TeamRepository, + provide: TEAM_REPOSITORY, useClass: TeamRepository }; diff --git a/backend/src/modules/teams/services/create.team.service.spec.ts b/backend/src/modules/teams/services/create.team.service.spec.ts index d9b85d34e..66d6dffec 100644 --- a/backend/src/modules/teams/services/create.team.service.spec.ts +++ b/backend/src/modules/teams/services/create.team.service.spec.ts @@ -6,7 +6,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; import { createTeamService } from 'src/modules/teams/providers'; import { CreateTeamServiceInterface } from '../interfaces/services/create.team.service.interface'; -import * as Teams from 'src/modules/teams/interfaces/types'; +import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { CreateTeamDto } from '../dto/create-team.dto'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; diff --git a/backend/src/modules/teams/services/create.team.service.ts b/backend/src/modules/teams/services/create.team.service.ts index 0c0aff403..e6bedb55b 100644 --- a/backend/src/modules/teams/services/create.team.service.ts +++ b/backend/src/modules/teams/services/create.team.service.ts @@ -6,7 +6,7 @@ import isEmpty from 'src/libs/utils/isEmpty'; import { CreateTeamDto } from '../dto/create-team.dto'; import { CreateTeamServiceInterface } from '../interfaces/services/create.team.service.interface'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { TEAM_REPOSITORY } from '../constants'; import { TEAM_ALREADY_EXISTS } from 'src/libs/constants/team'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; @@ -14,7 +14,7 @@ import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; @Injectable() export default class CreateTeamService implements CreateTeamServiceInterface { constructor( - @Inject(TYPES.repositories.TeamRepository) + @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, @Inject(TeamUsers.TYPES.services.CreateTeamUserService) private readonly createTeamUserService: CreateTeamUserServiceInterface diff --git a/backend/src/modules/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index a801b25a2..a30e883e8 100644 --- a/backend/src/modules/teams/services/delete.team.service.spec.ts +++ b/backend/src/modules/teams/services/delete.team.service.spec.ts @@ -8,7 +8,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { deleteTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as Teams from 'src/modules/teams/interfaces/types'; +import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; diff --git a/backend/src/modules/teams/services/delete.team.service.ts b/backend/src/modules/teams/services/delete.team.service.ts index 584b860ef..c41c8ba07 100644 --- a/backend/src/modules/teams/services/delete.team.service.ts +++ b/backend/src/modules/teams/services/delete.team.service.ts @@ -1,7 +1,7 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { DeleteTeamServiceInterface } from '../interfaces/services/delete.team.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TEAM_REPOSITORY } from '../constants'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import * as Boards from '../../boards/interfaces/types'; import * as TeamUsers from '../../teamUsers/interfaces/types'; @@ -11,12 +11,12 @@ import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces @Injectable() export default class DeleteTeamService implements DeleteTeamServiceInterface { constructor( - @Inject(TYPES.repositories.TeamRepository) + @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, @Inject(Boards.TYPES.services.DeleteBoardService) - private deleteBoardService: DeleteBoardServiceInterface, + private readonly deleteBoardService: DeleteBoardServiceInterface, @Inject(TeamUsers.TYPES.services.DeleteTeamUserService) - private deleteTeamUserService: DeleteTeamUserServiceInterface + private readonly deleteTeamUserService: DeleteTeamUserServiceInterface ) {} async delete(teamId: string): Promise { diff --git a/backend/src/modules/teams/services/get.team.service.spec.ts b/backend/src/modules/teams/services/get.team.service.spec.ts index b994d2771..f54b222bd 100644 --- a/backend/src/modules/teams/services/get.team.service.spec.ts +++ b/backend/src/modules/teams/services/get.team.service.spec.ts @@ -14,7 +14,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { getTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as Teams from 'src/modules/teams/interfaces/types'; +import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; diff --git a/backend/src/modules/teams/services/get.team.service.ts b/backend/src/modules/teams/services/get.team.service.ts index 8f50ec97a..0883160fc 100644 --- a/backend/src/modules/teams/services/get.team.service.ts +++ b/backend/src/modules/teams/services/get.team.service.ts @@ -3,7 +3,7 @@ import { TEAM_NOT_FOUND } from 'src/libs/exceptions/messages'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { GetTeamServiceInterface } from '../interfaces/services/get.team.service.interface'; import Team from '../entities/team.schema'; -import { TYPES } from '../interfaces/types'; +import { TEAM_REPOSITORY } from '../constants'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; @@ -13,12 +13,12 @@ import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/se @Injectable() export default class GetTeamService implements GetTeamServiceInterface { constructor( - @Inject(TYPES.repositories.TeamRepository) + @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, @Inject(TeamUsers.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface, + private readonly getTeamUserService: GetTeamUserServiceInterface, @Inject(Boards.TYPES.services.GetBoardService) - private getBoardService: GetBoardServiceInterface + private readonly getBoardService: GetBoardServiceInterface ) {} countAllTeams() { From 53af6a4b6fed60c46b1bf7adfdf92afe7d4f82ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Fri, 14 Apr 2023 16:23:31 +0100 Subject: [PATCH 02/14] fix: fix imports of team constants on tests --- .../modules/boards/services/create.board.service.spec.ts | 6 +++--- .../src/modules/boards/services/get.board.service.spec.ts | 7 +++---- .../src/modules/teams/services/create.team.service.spec.ts | 6 +++--- .../src/modules/teams/services/delete.team.service.spec.ts | 6 +++--- .../src/modules/teams/services/get.team.service.spec.ts | 6 +++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 2dbe7495c..c5c90c115 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @@ -33,6 +32,7 @@ import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { Configs } from '../dto/configs.dto'; import { BadRequestException, NotFoundException } from '@nestjs/common'; import { TeamRoles } from 'src/libs/enum/team.roles'; +import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; const userId: string = faker.datatype.uuid(); @@ -204,7 +204,7 @@ describe('CreateBoardService', () => { providers: [ CreateBoardService, { - provide: Teams.TYPES.services.GetTeamService, + provide: GET_TEAM_SERVICE, useValue: createMock() }, { @@ -237,7 +237,7 @@ describe('CreateBoardService', () => { boardService = module.get(CreateBoardService); boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); - getTeamServiceMock = module.get(Teams.TYPES.services.GetTeamService); + getTeamServiceMock = module.get(GET_TEAM_SERVICE); getTeamUserServiceMock = module.get(TeamUsers.TYPES.services.GetTeamUserService); updateTeamUserServiceMock = module.get(TeamUsers.TYPES.services.UpdateTeamUserService); createSchedulesServiceMock = module.get(Schedules.TYPES.services.CreateSchedulesService); diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index 02d195023..3f3096fa4 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -4,14 +4,12 @@ import { getBoardService } from './../boards.providers'; import { getTokenAuthService } from './../../auth/auth.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; -import { getTeamService } from 'src/modules/teams/providers'; import { updateUserService } from 'src/modules/users/users.providers'; import { boardRepository } from '../boards.providers'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Teams from 'src/modules/teams/constants'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; @@ -25,6 +23,7 @@ import { createBoardUserService } from 'src/modules/boardUsers/boardusers.provid import { UserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/userDto-factory.mock'; import { NotFoundException } from '@nestjs/common'; import { hideVotesFromColumns } from '../utils/hideVotesFromColumns'; +import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; const userId = faker.datatype.uuid(); const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); @@ -48,7 +47,7 @@ describe('GetBoardService', () => { providers: [ getBoardService, { - provide: getTeamService.provide, + provide: GET_TEAM_SERVICE, useValue: createMock() }, { @@ -81,7 +80,7 @@ describe('GetBoardService', () => { boardService = module.get(getBoardService.provide); boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); - getTeamServiceMock = module.get(Teams.TYPES.services.GetTeamService); + getTeamServiceMock = module.get(GET_TEAM_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/teams/services/create.team.service.spec.ts b/backend/src/modules/teams/services/create.team.service.spec.ts index 66d6dffec..c4ff8b1d5 100644 --- a/backend/src/modules/teams/services/create.team.service.spec.ts +++ b/backend/src/modules/teams/services/create.team.service.spec.ts @@ -6,13 +6,13 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; import { createTeamService } from 'src/modules/teams/providers'; import { CreateTeamServiceInterface } from '../interfaces/services/create.team.service.interface'; -import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { CreateTeamDto } from '../dto/create-team.dto'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; import { BadRequestException, HttpException, HttpStatus } from '@nestjs/common'; import { TEAM_ALREADY_EXISTS } from 'src/libs/constants/team'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; +import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; const createTeamDto: CreateTeamDto = { name: faker.name.findName(), @@ -34,7 +34,7 @@ describe('CreateTeamService', () => { providers: [ createTeamService, { - provide: Teams.TYPES.repositories.TeamRepository, + provide: TEAM_REPOSITORY, useValue: createMock() }, { @@ -45,7 +45,7 @@ describe('CreateTeamService', () => { }).compile(); teamService = module.get(createTeamService.provide); - teamRepositoryMock = module.get(Teams.TYPES.repositories.TeamRepository); + teamRepositoryMock = module.get(TEAM_REPOSITORY); createTeamUserServiceMock = module.get(TeamUsers.TYPES.services.CreateTeamUserService); }); diff --git a/backend/src/modules/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index a30e883e8..a5b5a6d9b 100644 --- a/backend/src/modules/teams/services/delete.team.service.spec.ts +++ b/backend/src/modules/teams/services/delete.team.service.spec.ts @@ -8,13 +8,13 @@ import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { deleteTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; import { BadRequestException } from '@nestjs/common'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; +import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -43,7 +43,7 @@ describe('DeleteTeamService', () => { providers: [ deleteTeamService, { - provide: Teams.TYPES.repositories.TeamRepository, + provide: TEAM_REPOSITORY, useValue: createMock() }, { @@ -58,7 +58,7 @@ describe('DeleteTeamService', () => { }).compile(); teamService = module.get(deleteTeamService.provide); - teamRepositoryMock = module.get(Teams.TYPES.repositories.TeamRepository); + teamRepositoryMock = module.get(TEAM_REPOSITORY); deleteTeamUserServiceMock = module.get(TeamUsers.TYPES.services.DeleteTeamUserService); deleteBoardServiceMock = module.get(Boards.TYPES.services.DeleteBoardService); }); diff --git a/backend/src/modules/teams/services/get.team.service.spec.ts b/backend/src/modules/teams/services/get.team.service.spec.ts index f54b222bd..f22d24f4f 100644 --- a/backend/src/modules/teams/services/get.team.service.spec.ts +++ b/backend/src/modules/teams/services/get.team.service.spec.ts @@ -14,10 +14,10 @@ import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { getTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as Teams from 'src/modules/teams/constants'; import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; +import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -58,7 +58,7 @@ describe('GetTeamService', () => { providers: [ getTeamService, { - provide: Teams.TYPES.repositories.TeamRepository, + provide: TEAM_REPOSITORY, useValue: createMock() }, { @@ -73,7 +73,7 @@ describe('GetTeamService', () => { }).compile(); teamService = module.get(getTeamService.provide); - teamRepositoryMock = module.get(Teams.TYPES.repositories.TeamRepository); + teamRepositoryMock = module.get(TEAM_REPOSITORY); getTeamUserServiceMock = module.get(TeamUsers.TYPES.services.GetTeamUserService); getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); }); From 069032941fb055324c4b32d2d330c672ce27460d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Fri, 14 Apr 2023 17:15:05 +0100 Subject: [PATCH 03/14] refactor: change type for constants on team module --- backend/src/libs/guards/boardRoles.guard.ts | 10 +++--- backend/src/libs/guards/teamRoles.guard.ts | 4 +-- .../applications/statistics.auth.use-case.ts | 10 +++--- .../services/create.board.service.spec.ts | 12 +++---- .../boards/services/create.board.service.ts | 18 +++++----- ...add-and-remove-team-users.use-case.spec.ts | 21 ++++++------ .../add-and-remove-team-users.use-case.ts | 10 +++--- .../create-team-user.use-case.spec.ts | 12 +++---- .../applications/create-team-user.use-case.ts | 4 +-- .../create-team-users.use-case.spec.ts | 12 +++---- .../create-team-users.use-case.ts | 6 ++-- .../delete-team-user.use-case.spec.ts | 12 +++---- .../applications/delete-team-user.use-case.ts | 4 +-- .../update-team-user.use-case.spec.ts | 6 ++-- .../applications/update-team-user.use-case.ts | 4 +-- backend/src/modules/teamUsers/constants.ts | 19 +++++++++++ .../controller/teamUser.controller.ts | 18 ++++++---- .../src/modules/teamUsers/interfaces/types.ts | 18 ---------- .../services/create.team.user.service.spec.ts | 8 ++--- .../services/create.team.user.service.ts | 4 +-- .../services/delete.team.user.service.spec.ts | 8 ++--- .../services/delete.team.user.service.ts | 4 +-- .../services/get.team.user.service.spec.ts | 4 +-- .../services/get.team.user.service.ts | 4 +-- .../services/update.team.user.service.spec.ts | 16 +++++---- .../services/update.team.user.service.ts | 4 +-- .../modules/teamUsers/teamusers.providers.ts | 33 ++++++++++++------- .../services/create.team.service.spec.ts | 12 +++---- .../teams/services/create.team.service.ts | 4 +-- .../services/delete.team.service.spec.ts | 12 +++---- .../teams/services/delete.team.service.ts | 4 +-- .../teams/services/get.team.service.spec.ts | 12 +++---- .../teams/services/get.team.service.ts | 4 +-- .../applications/delete-user.use-case.ts | 10 +++--- .../get-all-users-with-teams.use-case.ts | 6 ++-- 35 files changed, 185 insertions(+), 164 deletions(-) create mode 100644 backend/src/modules/teamUsers/constants.ts delete mode 100644 backend/src/modules/teamUsers/interfaces/types.ts diff --git a/backend/src/libs/guards/boardRoles.guard.ts b/backend/src/libs/guards/boardRoles.guard.ts index b12c5b18b..3b7df19ca 100644 --- a/backend/src/libs/guards/boardRoles.guard.ts +++ b/backend/src/libs/guards/boardRoles.guard.ts @@ -9,21 +9,21 @@ import { Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export class BoardUserGuard implements CanActivate { constructor( - @Inject(TeamUsers.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface, + @Inject(GET_TEAM_USER_SERVICE) + private readonly getTeamUserService: GetTeamUserServiceInterface, private readonly reflector: Reflector, @Inject(Boards.TYPES.services.GetBoardService) - private getBoardService: GetBoardServiceInterface, + private readonly getBoardService: GetBoardServiceInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) - private getBoardUserService: GetBoardUserServiceInterface + private readonly getBoardUserService: GetBoardUserServiceInterface ) {} async canActivate(context: ExecutionContext) { diff --git a/backend/src/libs/guards/teamRoles.guard.ts b/backend/src/libs/guards/teamRoles.guard.ts index 09bc2941c..56ffdf686 100644 --- a/backend/src/libs/guards/teamRoles.guard.ts +++ b/backend/src/libs/guards/teamRoles.guard.ts @@ -7,13 +7,13 @@ import { Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export class TeamUserGuard implements CanActivate { constructor( private readonly reflector: Reflector, - @Inject(TeamUsers.TYPES.services.GetTeamUserService) + @Inject(GET_TEAM_USER_SERVICE) private getTeamUserService: GetTeamUserServiceInterface ) {} diff --git a/backend/src/modules/auth/applications/statistics.auth.use-case.ts b/backend/src/modules/auth/applications/statistics.auth.use-case.ts index ba6b27afd..291d5b934 100644 --- a/backend/src/modules/auth/applications/statistics.auth.use-case.ts +++ b/backend/src/modules/auth/applications/statistics.auth.use-case.ts @@ -1,21 +1,21 @@ import { Inject, Injectable } from '@nestjs/common'; import * as User from 'src/modules/users/interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/get.user.service.interface'; import { StatisticsAuthUserUseCaseInterface } from '../interfaces/applications/statistics.auth.use-case.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export default class StatisticsAuthUserUseCase implements StatisticsAuthUserUseCaseInterface { constructor( @Inject(User.TYPES.services.GetUserService) - private getUserService: GetUserServiceInterface, - @Inject(TeamUsers.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface, + private readonly getUserService: GetUserServiceInterface, + @Inject(GET_TEAM_USER_SERVICE) + private readonly getTeamUserService: GetTeamUserServiceInterface, @Inject(Boards.TYPES.services.GetBoardService) - private getBoardService: GetBoardServiceInterface + private readonly getBoardService: GetBoardServiceInterface ) {} public async execute(userId: string) { diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index c5c90c115..2fe199e99 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; @@ -33,6 +32,7 @@ import { Configs } from '../dto/configs.dto'; import { BadRequestException, NotFoundException } from '@nestjs/common'; import { TeamRoles } from 'src/libs/enum/team.roles'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; +import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; const userId: string = faker.datatype.uuid(); @@ -208,11 +208,11 @@ describe('CreateBoardService', () => { useValue: createMock() }, { - provide: TeamUsers.TYPES.services.GetTeamUserService, + provide: GET_TEAM_USER_SERVICE, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.UpdateTeamUserService, + provide: UPDATE_TEAM_USER_SERVICE, useValue: createMock() }, { @@ -234,12 +234,12 @@ describe('CreateBoardService', () => { ] }).compile(); - boardService = module.get(CreateBoardService); + boardService = module.get(CreateBoardService); boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); getTeamServiceMock = module.get(GET_TEAM_SERVICE); - getTeamUserServiceMock = module.get(TeamUsers.TYPES.services.GetTeamUserService); - updateTeamUserServiceMock = module.get(TeamUsers.TYPES.services.UpdateTeamUserService); + getTeamUserServiceMock = module.get(GET_TEAM_USER_SERVICE); + updateTeamUserServiceMock = module.get(UPDATE_TEAM_USER_SERVICE); createSchedulesServiceMock = module.get(Schedules.TYPES.services.CreateSchedulesService); slackCommunicationServiceMock = module.get( CommunicationsType.TYPES.services.SlackCommunicationService diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index 7b08262da..14624d793 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -17,7 +17,6 @@ import * as SchedulesType from 'src/modules/schedules/interfaces/types'; import * as Boards from 'src/modules/boards/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import User from 'src/modules/users/entities/user.schema'; import BoardDto from '../dto/board.dto'; @@ -38,6 +37,7 @@ import { Configs } from '../dto/configs.dto'; import { TEAM_NOT_FOUND, TEAM_USERS_NOT_FOUND } from 'src/libs/exceptions/messages'; import { CreateFailedException } from 'src/libs/exceptions/createFailedBadRequestException'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; +import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; type CreateBoardAndUsers = { boardData: BoardDto; @@ -50,19 +50,19 @@ export default class CreateBoardService implements CreateBoardServiceInterface { constructor( @Inject(forwardRef(() => GET_TEAM_SERVICE)) - private getTeamService: GetTeamServiceInterface, - @Inject(TeamUsers.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface, - @Inject(TeamUsers.TYPES.services.UpdateTeamUserService) - private updateTeamUserService: UpdateTeamUserServiceInterface, + private readonly getTeamService: GetTeamServiceInterface, + @Inject(GET_TEAM_USER_SERVICE) + private readonly getTeamUserService: GetTeamUserServiceInterface, + @Inject(UPDATE_TEAM_USER_SERVICE) + private readonly updateTeamUserService: UpdateTeamUserServiceInterface, @Inject(SchedulesType.TYPES.services.CreateSchedulesService) - private createSchedulesService: CreateSchedulesServiceInterface, + private readonly createSchedulesService: CreateSchedulesServiceInterface, @Inject(CommunicationsType.TYPES.services.SlackCommunicationService) - private slackCommunicationService: CommunicationServiceInterface, + private readonly slackCommunicationService: CommunicationServiceInterface, @Inject(Boards.TYPES.repositories.BoardRepository) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.CreateBoardUserService) - private createBoardUserService: CreateBoardUserServiceInterface + private readonly createBoardUserService: CreateBoardUserServiceInterface ) {} async create(boardData: BoardDto, userId: string, fromSchedule = false): Promise { diff --git a/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.spec.ts b/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.spec.ts index e315b37ea..0abd20a4d 100644 --- a/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.spec.ts +++ b/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.spec.ts @@ -1,8 +1,6 @@ -import { addAndRemoveTeamUsersUseCase } from './../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUserDto from '../dto/team.user.dto'; import TeamUser from '../entities/team.user.schema'; import { BadRequestException } from '@nestjs/common'; @@ -12,6 +10,11 @@ import UpdateTeamUserDto from '../dto/update.team.user.dto'; import { CreateTeamUserServiceInterface } from '../interfaces/services/create.team.user.service.interface'; import { DeleteTeamUserServiceInterface } from '../interfaces/services/delete.team.user.service.interface'; import faker from '@faker-js/faker'; +import { AddAndRemoveTeamUsersUseCase } from 'src/modules/teamUsers/applications/add-and-remove-team-users.use-case'; +import { + CREATE_TEAM_USER_SERVICE, + DELETE_TEAM_USER_SERVICE +} from 'src/modules/teamUsers/constants'; const createTeamUserDtos: TeamUserDto[] = TeamUserDtoFactory.createMany(4); @@ -46,24 +49,22 @@ describe('AddAndRemoveTeamUsersUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - addAndRemoveTeamUsersUseCase, + AddAndRemoveTeamUsersUseCase, { - provide: TeamUsers.TYPES.services.CreateTeamUserService, + provide: CREATE_TEAM_USER_SERVICE, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.DeleteTeamUserService, + provide: DELETE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - addAndRemoveTeamUser = module.get>( - addAndRemoveTeamUsersUseCase.provide - ); + addAndRemoveTeamUser = module.get(AddAndRemoveTeamUsersUseCase); - createTeamUserServiceMock = module.get(TeamUsers.TYPES.services.CreateTeamUserService); - deleteTeamUserServiceMock = module.get(TeamUsers.TYPES.services.DeleteTeamUserService); + createTeamUserServiceMock = module.get(CREATE_TEAM_USER_SERVICE); + deleteTeamUserServiceMock = module.get(DELETE_TEAM_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.ts b/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.ts index 251628afa..a1caf2da1 100644 --- a/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.ts +++ b/backend/src/modules/teamUsers/applications/add-and-remove-team-users.use-case.ts @@ -1,5 +1,5 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { CREATE_TEAM_USER_SERVICE, DELETE_TEAM_USER_SERVICE } from '../constants'; import { UPDATE_FAILED } from 'src/libs/exceptions/messages'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { CreateTeamUserServiceInterface } from '../interfaces/services/create.team.user.service.interface'; @@ -11,10 +11,10 @@ import TeamUserDto from '../dto/team.user.dto'; @Injectable() export class AddAndRemoveTeamUsersUseCase implements UseCase { constructor( - @Inject(TYPES.services.CreateTeamUserService) - private createTeamUserService: CreateTeamUserServiceInterface, - @Inject(TYPES.services.DeleteTeamUserService) - private deleteTeamUserService: DeleteTeamUserServiceInterface + @Inject(CREATE_TEAM_USER_SERVICE) + private readonly createTeamUserService: CreateTeamUserServiceInterface, + @Inject(DELETE_TEAM_USER_SERVICE) + private readonly deleteTeamUserService: DeleteTeamUserServiceInterface ) {} async execute({ addUsers, removeUsers }: UpdateTeamUserDto): Promise { diff --git a/backend/src/modules/teamUsers/applications/create-team-user.use-case.spec.ts b/backend/src/modules/teamUsers/applications/create-team-user.use-case.spec.ts index b60bde928..bfd05d89f 100644 --- a/backend/src/modules/teamUsers/applications/create-team-user.use-case.spec.ts +++ b/backend/src/modules/teamUsers/applications/create-team-user.use-case.spec.ts @@ -1,14 +1,14 @@ -import { createTeamUserUseCase } from './../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from 'src/modules/teamUsers/interfaces/repositories/team-user.repository.interface'; import TeamUserDto from '../dto/team.user.dto'; import TeamUser from '../entities/team.user.schema'; import { BadRequestException } from '@nestjs/common'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; +import { CreateTeamUserUseCase } from 'src/modules/teamUsers/applications/create-team-user.use-case'; +import { TEAM_USER_REPOSITORY } from 'src/modules/teamUsers/constants'; const createTeamUserDto: TeamUserDto = TeamUserDtoFactory.create(); @@ -21,17 +21,17 @@ describe('CreateTeamUserUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - createTeamUserUseCase, + CreateTeamUserUseCase, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() } ] }).compile(); - createTeamUser = module.get>(createTeamUserUseCase.provide); + createTeamUser = module.get(CreateTeamUserUseCase); - teamUserRepositoryMock = module.get(TeamUsers.TYPES.repositories.TeamUserRepository); + teamUserRepositoryMock = module.get(TEAM_USER_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/applications/create-team-user.use-case.ts b/backend/src/modules/teamUsers/applications/create-team-user.use-case.ts index 0b3f73170..54f5b8f94 100644 --- a/backend/src/modules/teamUsers/applications/create-team-user.use-case.ts +++ b/backend/src/modules/teamUsers/applications/create-team-user.use-case.ts @@ -1,7 +1,7 @@ import TeamUserDto from 'src/modules/teamUsers/dto/team.user.dto'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { INSERT_FAILED } from 'src/libs/exceptions/messages'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import TeamUser from '../entities/team.user.schema'; @@ -9,7 +9,7 @@ import TeamUser from '../entities/team.user.schema'; @Injectable() export class CreateTeamUserUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/applications/create-team-users.use-case.spec.ts b/backend/src/modules/teamUsers/applications/create-team-users.use-case.spec.ts index 056e6e0fa..4fad51f90 100644 --- a/backend/src/modules/teamUsers/applications/create-team-users.use-case.spec.ts +++ b/backend/src/modules/teamUsers/applications/create-team-users.use-case.spec.ts @@ -1,11 +1,11 @@ import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; -import { createTeamUsersUseCase } from './../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUserDto from '../dto/team.user.dto'; import TeamUser from '../entities/team.user.schema'; +import { CREATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { CreateTeamUsersUseCase } from 'src/modules/teamUsers/applications/create-team-users.use-case'; describe('CreateTeamUsersUseCase', () => { let createTeamUsers: UseCase; @@ -13,17 +13,15 @@ describe('CreateTeamUsersUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - createTeamUsersUseCase, + CreateTeamUsersUseCase, { - provide: TeamUsers.TYPES.services.CreateTeamUserService, + provide: CREATE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - createTeamUsers = module.get>( - createTeamUsersUseCase.provide - ); + createTeamUsers = module.get(CreateTeamUsersUseCase); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/applications/create-team-users.use-case.ts b/backend/src/modules/teamUsers/applications/create-team-users.use-case.ts index c5fdadcb6..bf0678bf7 100644 --- a/backend/src/modules/teamUsers/applications/create-team-users.use-case.ts +++ b/backend/src/modules/teamUsers/applications/create-team-users.use-case.ts @@ -1,15 +1,15 @@ import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; import TeamUserDto from 'src/modules/teamUsers/dto/team.user.dto'; import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; +import { CREATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export class CreateTeamUsersUseCase implements UseCase { constructor( - @Inject(TYPES.services.CreateTeamUserService) - private createTeamUserService: CreateTeamUserServiceInterface + @Inject(CREATE_TEAM_USER_SERVICE) + private readonly createTeamUserService: CreateTeamUserServiceInterface ) {} execute(teamUsers: TeamUserDto[]): Promise { diff --git a/backend/src/modules/teamUsers/applications/delete-team-user.use-case.spec.ts b/backend/src/modules/teamUsers/applications/delete-team-user.use-case.spec.ts index a6619ee68..b195d071f 100644 --- a/backend/src/modules/teamUsers/applications/delete-team-user.use-case.spec.ts +++ b/backend/src/modules/teamUsers/applications/delete-team-user.use-case.spec.ts @@ -1,13 +1,13 @@ import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { faker } from '@faker-js/faker'; -import { deleteTeamUserUseCase } from '../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from 'src/modules/teamUsers/interfaces/repositories/team-user.repository.interface'; import TeamUser from '../entities/team.user.schema'; import { BadRequestException } from '@nestjs/common/exceptions/bad-request.exception'; +import { DeleteTeamUserUseCase } from 'src/modules/teamUsers/applications/delete-team-user.use-case'; +import { TEAM_USER_REPOSITORY } from 'src/modules/teamUsers/constants'; const removeTeamUser: string = faker.datatype.uuid(); const deletedTeamUser: TeamUser = TeamUserFactory.create({ _id: removeTeamUser }); @@ -19,16 +19,16 @@ describe('DeleteTeamUserUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - deleteTeamUserUseCase, + DeleteTeamUserUseCase, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() } ] }).compile(); - deleteTeamUser = module.get>(deleteTeamUserUseCase.provide); - teamUserRepositoryMock = module.get(TeamUsers.TYPES.repositories.TeamUserRepository); + deleteTeamUser = module.get(DeleteTeamUserUseCase); + teamUserRepositoryMock = module.get(TEAM_USER_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/applications/delete-team-user.use-case.ts b/backend/src/modules/teamUsers/applications/delete-team-user.use-case.ts index 549d5f65a..90cbc6ee8 100644 --- a/backend/src/modules/teamUsers/applications/delete-team-user.use-case.ts +++ b/backend/src/modules/teamUsers/applications/delete-team-user.use-case.ts @@ -1,6 +1,6 @@ import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import TeamUser from '../entities/team.user.schema'; @@ -8,7 +8,7 @@ import TeamUser from '../entities/team.user.schema'; @Injectable() export class DeleteTeamUserUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/applications/update-team-user.use-case.spec.ts b/backend/src/modules/teamUsers/applications/update-team-user.use-case.spec.ts index e27d402ea..0f47dc935 100644 --- a/backend/src/modules/teamUsers/applications/update-team-user.use-case.spec.ts +++ b/backend/src/modules/teamUsers/applications/update-team-user.use-case.spec.ts @@ -3,9 +3,9 @@ import { updateTeamUserUseCase } from '../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUserDto from '../dto/team.user.dto'; import TeamUser from '../entities/team.user.schema'; +import { UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; describe('UpdateTeamUserUseCase', () => { let updateTeamUser: UseCase; @@ -15,13 +15,13 @@ describe('UpdateTeamUserUseCase', () => { providers: [ updateTeamUserUseCase, { - provide: TeamUsers.TYPES.services.UpdateTeamUserService, + provide: UPDATE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - updateTeamUser = module.get>(updateTeamUserUseCase.provide); + updateTeamUser = module.get(updateTeamUserUseCase.provide); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/applications/update-team-user.use-case.ts b/backend/src/modules/teamUsers/applications/update-team-user.use-case.ts index 95f2cc6bb..12bf8a86e 100644 --- a/backend/src/modules/teamUsers/applications/update-team-user.use-case.ts +++ b/backend/src/modules/teamUsers/applications/update-team-user.use-case.ts @@ -1,14 +1,14 @@ import { UpdateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/update.team.user.service.interface'; import TeamUserDto from 'src/modules/teamUsers/dto/team.user.dto'; import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; +import { UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export class UpdateTeamUserUseCase implements UseCase { constructor( - @Inject(TYPES.services.UpdateTeamUserService) + @Inject(UPDATE_TEAM_USER_SERVICE) private readonly updateTeamUserService: UpdateTeamUserServiceInterface ) {} diff --git a/backend/src/modules/teamUsers/constants.ts b/backend/src/modules/teamUsers/constants.ts new file mode 100644 index 000000000..86541e93f --- /dev/null +++ b/backend/src/modules/teamUsers/constants.ts @@ -0,0 +1,19 @@ +export const CREATE_TEAM_USER_USE_CASE = 'CreateTeamUserUseCase'; + +export const CREATE_TEAM_USERS_USE_CASE = 'CreateTeamUsersUseCase'; + +export const UPDATE_TEAM_USER_USE_CASE = 'UpdateTeamUserUseCase'; + +export const ADD_AND_REMOVE_TEAM_USER_USE_CASE = 'AddAndRemoveTeamUsersUseCase'; + +export const DELETE_TEAM_USER_USE_CASE = 'DeleteTeamUserUseCase'; + +export const CREATE_TEAM_USER_SERVICE = 'CreateTeamUserService'; + +export const GET_TEAM_USER_SERVICE = 'GetTeamUserService'; + +export const UPDATE_TEAM_USER_SERVICE = 'UpdateTeamUserService'; + +export const DELETE_TEAM_USER_SERVICE = 'DeleteTeamUserService'; + +export const TEAM_USER_REPOSITORY = 'TeamUserRepository'; diff --git a/backend/src/modules/teamUsers/controller/teamUser.controller.ts b/backend/src/modules/teamUsers/controller/teamUser.controller.ts index c1563dc3d..5b74296a6 100644 --- a/backend/src/modules/teamUsers/controller/teamUser.controller.ts +++ b/backend/src/modules/teamUsers/controller/teamUser.controller.ts @@ -33,9 +33,15 @@ import { ForbiddenResponse } from '../../../libs/swagger/errors/forbidden.swagge import { NotFoundResponse } from '../../../libs/swagger/errors/not-found.swagger'; import TeamUserDto from '../dto/team.user.dto'; import UpdateTeamUserDto from '../dto/update.team.user.dto'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { SuperAdminGuard } from 'src/libs/guards/superAdmin.guard'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; +import { + ADD_AND_REMOVE_TEAM_USER_USE_CASE, + CREATE_TEAM_USERS_USE_CASE, + CREATE_TEAM_USER_USE_CASE, + DELETE_TEAM_USER_USE_CASE, + UPDATE_TEAM_USER_USE_CASE +} from 'src/modules/teamUsers/constants'; const TeamUserPermission = (permissions: string[]) => SetMetadata('permissions', permissions); @@ -45,15 +51,15 @@ const TeamUserPermission = (permissions: string[]) => SetMetadata('permissions', @Controller('teams') export default class TeamUsersController { constructor( - @Inject(TeamUsers.TYPES.applications.CreateTeamUserUseCase) + @Inject(CREATE_TEAM_USER_USE_CASE) private createTeamUserUseCase: UseCase, - @Inject(TeamUsers.TYPES.applications.CreateTeamUsersUseCase) + @Inject(CREATE_TEAM_USERS_USE_CASE) private createTeamUsersUseCase: UseCase, - @Inject(TeamUsers.TYPES.applications.UpdateTeamUserUseCase) + @Inject(UPDATE_TEAM_USER_USE_CASE) private updateTeamUserUseCase: UseCase, - @Inject(TeamUsers.TYPES.applications.AddAndRemoveTeamUsersUseCase) + @Inject(ADD_AND_REMOVE_TEAM_USER_USE_CASE) private addAndRemoveTeamUsersUseCase: UseCase, - @Inject(TeamUsers.TYPES.applications.DeleteTeamUserUseCase) + @Inject(DELETE_TEAM_USER_USE_CASE) private deleteTeamUserUseCase: UseCase ) {} diff --git a/backend/src/modules/teamUsers/interfaces/types.ts b/backend/src/modules/teamUsers/interfaces/types.ts deleted file mode 100644 index 260f697e7..000000000 --- a/backend/src/modules/teamUsers/interfaces/types.ts +++ /dev/null @@ -1,18 +0,0 @@ -export const TYPES = { - applications: { - CreateTeamUsersUseCase: 'CreateTeamUsersUseCase', - CreateTeamUserUseCase: 'CreateTeamUserUseCase', - UpdateTeamUserUseCase: 'UpdateTeamUserUseCase', - AddAndRemoveTeamUsersUseCase: 'AddAndRemoveTeamUsersUseCase', - DeleteTeamUserUseCase: 'DeleteTeamUserUseCase' - }, - services: { - CreateTeamUserService: 'CreateTeamUserService', - GetTeamUserService: 'GetTeamUserService', - UpdateTeamUserService: 'UpdateTeamUserService', - DeleteTeamUserService: 'DeleteTeamUserService' - }, - repositories: { - TeamUserRepository: 'TeamUserRepository' - } -}; diff --git a/backend/src/modules/teamUsers/services/create.team.user.service.spec.ts b/backend/src/modules/teamUsers/services/create.team.user.service.spec.ts index 38efa6201..a3d6151cc 100644 --- a/backend/src/modules/teamUsers/services/create.team.user.service.spec.ts +++ b/backend/src/modules/teamUsers/services/create.team.user.service.spec.ts @@ -7,9 +7,9 @@ import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from 'src/modules/teamUsers/interfaces/repositories/team-user.repository.interface'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; +import { TEAM_USER_REPOSITORY } from 'src/modules/teamUsers/constants'; const createTeamUserDtos: TeamUserDto[] = TeamUserDtoFactory.createMany(4); @@ -31,14 +31,14 @@ describe('CreateTeamUserService', () => { providers: [ createTeamUserService, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() } ] }).compile(); - teamUserService = module.get(createTeamUserService.provide); - teamUserRepositoryMock = module.get(TeamUsers.TYPES.repositories.TeamUserRepository); + teamUserService = module.get(createTeamUserService.provide); + teamUserRepositoryMock = module.get(TEAM_USER_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/services/create.team.user.service.ts b/backend/src/modules/teamUsers/services/create.team.user.service.ts index 596955382..e247ddba6 100644 --- a/backend/src/modules/teamUsers/services/create.team.user.service.ts +++ b/backend/src/modules/teamUsers/services/create.team.user.service.ts @@ -1,5 +1,5 @@ import { CreateTeamUserServiceInterface } from '../interfaces/services/create.team.user.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import TeamUserDto from '../dto/team.user.dto'; @@ -9,7 +9,7 @@ import TeamUser from '../entities/team.user.schema'; @Injectable() export default class CreateTeamUserService implements CreateTeamUserServiceInterface { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/services/delete.team.user.service.spec.ts b/backend/src/modules/teamUsers/services/delete.team.user.service.spec.ts index 172f8ab69..8f4a1ce0d 100644 --- a/backend/src/modules/teamUsers/services/delete.team.user.service.spec.ts +++ b/backend/src/modules/teamUsers/services/delete.team.user.service.spec.ts @@ -3,9 +3,9 @@ import { BadRequestException } from '@nestjs/common'; import { deleteTeamUserService } from './../teamusers.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { DeleteTeamUserServiceInterface } from '../interfaces/services/delete.team.user.service.interface'; +import { TEAM_USER_REPOSITORY } from 'src/modules/teamUsers/constants'; const removeTeamUsers: string[] = [ faker.datatype.uuid(), @@ -29,14 +29,14 @@ describe('DeleteTeamUserService', () => { providers: [ deleteTeamUserService, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() } ] }).compile(); - teamUserService = module.get(deleteTeamUserService.provide); - teamUserRepositoryMock = module.get(TeamUsers.TYPES.repositories.TeamUserRepository); + teamUserService = module.get(deleteTeamUserService.provide); + teamUserRepositoryMock = module.get(TEAM_USER_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/services/delete.team.user.service.ts b/backend/src/modules/teamUsers/services/delete.team.user.service.ts index cd10c4d94..89c2ed3cd 100644 --- a/backend/src/modules/teamUsers/services/delete.team.user.service.ts +++ b/backend/src/modules/teamUsers/services/delete.team.user.service.ts @@ -1,13 +1,13 @@ import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { DeleteTeamUserServiceInterface } from '../interfaces/services/delete.team.user.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; @Injectable() export default class DeleteTeamUserService implements DeleteTeamUserServiceInterface { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/services/get.team.user.service.spec.ts b/backend/src/modules/teamUsers/services/get.team.user.service.spec.ts index 929f9dbd2..d220632cb 100644 --- a/backend/src/modules/teamUsers/services/get.team.user.service.spec.ts +++ b/backend/src/modules/teamUsers/services/get.team.user.service.spec.ts @@ -2,8 +2,8 @@ import { getTeamUserService } from 'src/modules/teamUsers/teamusers.providers'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; import { Test, TestingModule } from '@nestjs/testing'; import { createMock } from '@golevelup/ts-jest'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from 'src/modules/teamUsers/interfaces/repositories/team-user.repository.interface'; +import { TEAM_USER_REPOSITORY } from 'src/modules/teamUsers/constants'; describe('GetTeamUserService', () => { let teamUserService: GetTeamUserServiceInterface; @@ -13,7 +13,7 @@ describe('GetTeamUserService', () => { providers: [ getTeamUserService, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() } ] diff --git a/backend/src/modules/teamUsers/services/get.team.user.service.ts b/backend/src/modules/teamUsers/services/get.team.user.service.ts index e4e625302..3f09b31c8 100644 --- a/backend/src/modules/teamUsers/services/get.team.user.service.ts +++ b/backend/src/modules/teamUsers/services/get.team.user.service.ts @@ -1,5 +1,5 @@ import { GetTeamUserServiceInterface } from '../interfaces/services/get.team.user.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { Inject, Injectable } from '@nestjs/common'; import User from 'src/modules/users/entities/user.schema'; @@ -9,7 +9,7 @@ import { UserWithTeams } from 'src/modules/users/interfaces/type-user-with-teams @Injectable() export default class GetTeamUserService implements GetTeamUserServiceInterface { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/services/update.team.user.service.spec.ts b/backend/src/modules/teamUsers/services/update.team.user.service.spec.ts index 19952c457..57e6c5c16 100644 --- a/backend/src/modules/teamUsers/services/update.team.user.service.spec.ts +++ b/backend/src/modules/teamUsers/services/update.team.user.service.spec.ts @@ -9,9 +9,13 @@ import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UpdateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/update.team.user.service.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; +import { + CREATE_TEAM_USER_SERVICE, + DELETE_TEAM_USER_SERVICE, + TEAM_USER_REPOSITORY +} from 'src/modules/teamUsers/constants'; const teamUser: TeamUserDto = TeamUserDtoFactory.create(); @@ -33,22 +37,22 @@ describe('UpdateTeamUserService', () => { providers: [ updateTeamUserService, { - provide: TeamUsers.TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.CreateTeamUserService, + provide: CREATE_TEAM_USER_SERVICE, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.DeleteTeamUserService, + provide: DELETE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - teamUserService = module.get(updateTeamUserService.provide); - teamUserRepositoryMock = module.get(TeamUsers.TYPES.repositories.TeamUserRepository); + teamUserService = module.get(updateTeamUserService.provide); + teamUserRepositoryMock = module.get(TEAM_USER_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/teamUsers/services/update.team.user.service.ts b/backend/src/modules/teamUsers/services/update.team.user.service.ts index 964161e5c..ce73e137b 100644 --- a/backend/src/modules/teamUsers/services/update.team.user.service.ts +++ b/backend/src/modules/teamUsers/services/update.team.user.service.ts @@ -2,14 +2,14 @@ import { UpdateTeamUserServiceInterface } from '../interfaces/services/update.te import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import TeamUserDto from '../dto/team.user.dto'; import TeamUser from '../entities/team.user.schema'; -import { TYPES } from '../interfaces/types'; +import { TEAM_USER_REPOSITORY } from '../constants'; import { TeamUserRepositoryInterface } from '../interfaces/repositories/team-user.repository.interface'; import { UPDATE_FAILED } from 'src/libs/exceptions/messages'; @Injectable() export default class UpdateTeamUserService implements UpdateTeamUserServiceInterface { constructor( - @Inject(TYPES.repositories.TeamUserRepository) + @Inject(TEAM_USER_REPOSITORY) private readonly teamUserRepository: TeamUserRepositoryInterface ) {} diff --git a/backend/src/modules/teamUsers/teamusers.providers.ts b/backend/src/modules/teamUsers/teamusers.providers.ts index 69e56fa5a..ed8651467 100644 --- a/backend/src/modules/teamUsers/teamusers.providers.ts +++ b/backend/src/modules/teamUsers/teamusers.providers.ts @@ -3,7 +3,18 @@ import { UpdateTeamUserUseCase } from './applications/update-team-user.use-case' import { CreateTeamUsersUseCase } from './applications/create-team-users.use-case'; import { CreateTeamUserUseCase } from './applications/create-team-user.use-case'; import { TeamUserRepository } from './repositories/team-user.repository'; -import { TYPES } from './interfaces/types'; +import { + ADD_AND_REMOVE_TEAM_USER_USE_CASE, + CREATE_TEAM_USERS_USE_CASE, + CREATE_TEAM_USER_SERVICE, + CREATE_TEAM_USER_USE_CASE, + DELETE_TEAM_USER_SERVICE, + DELETE_TEAM_USER_USE_CASE, + GET_TEAM_USER_SERVICE, + TEAM_USER_REPOSITORY, + UPDATE_TEAM_USER_SERVICE, + UPDATE_TEAM_USER_USE_CASE +} from './constants'; import CreateTeamUserService from './services/create.team.user.service'; import DeleteTeamUserService from './services/delete.team.user.service'; import GetTeamUserService from './services/get.team.user.service'; @@ -11,51 +22,51 @@ import UpdateTeamUserService from './services/update.team.user.service'; import { DeleteTeamUserUseCase } from './applications/delete-team-user.use-case'; export const teamUserRepository = { - provide: TYPES.repositories.TeamUserRepository, + provide: TEAM_USER_REPOSITORY, useClass: TeamUserRepository }; export const createTeamUserService = { - provide: TYPES.services.CreateTeamUserService, + provide: CREATE_TEAM_USER_SERVICE, useClass: CreateTeamUserService }; export const getTeamUserService = { - provide: TYPES.services.GetTeamUserService, + provide: GET_TEAM_USER_SERVICE, useClass: GetTeamUserService }; export const updateTeamUserService = { - provide: TYPES.services.UpdateTeamUserService, + provide: UPDATE_TEAM_USER_SERVICE, useClass: UpdateTeamUserService }; export const deleteTeamUserService = { - provide: TYPES.services.DeleteTeamUserService, + provide: DELETE_TEAM_USER_SERVICE, useClass: DeleteTeamUserService }; export const createTeamUserUseCase = { - provide: TYPES.applications.CreateTeamUserUseCase, + provide: CREATE_TEAM_USER_USE_CASE, useClass: CreateTeamUserUseCase }; export const createTeamUsersUseCase = { - provide: TYPES.applications.CreateTeamUsersUseCase, + provide: CREATE_TEAM_USERS_USE_CASE, useClass: CreateTeamUsersUseCase }; export const updateTeamUserUseCase = { - provide: TYPES.applications.UpdateTeamUserUseCase, + provide: UPDATE_TEAM_USER_USE_CASE, useClass: UpdateTeamUserUseCase }; export const addAndRemoveTeamUsersUseCase = { - provide: TYPES.applications.AddAndRemoveTeamUsersUseCase, + provide: ADD_AND_REMOVE_TEAM_USER_USE_CASE, useClass: AddAndRemoveTeamUsersUseCase }; export const deleteTeamUserUseCase = { - provide: TYPES.applications.DeleteTeamUserUseCase, + provide: DELETE_TEAM_USER_USE_CASE, useClass: DeleteTeamUserUseCase }; diff --git a/backend/src/modules/teams/services/create.team.service.spec.ts b/backend/src/modules/teams/services/create.team.service.spec.ts index c4ff8b1d5..342f9c346 100644 --- a/backend/src/modules/teams/services/create.team.service.spec.ts +++ b/backend/src/modules/teams/services/create.team.service.spec.ts @@ -4,15 +4,15 @@ import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/create.team.user.service.interface'; -import { createTeamService } from 'src/modules/teams/providers'; import { CreateTeamServiceInterface } from '../interfaces/services/create.team.service.interface'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { CreateTeamDto } from '../dto/create-team.dto'; import { TeamUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamUserDto-factory.mock'; import { BadRequestException, HttpException, HttpStatus } from '@nestjs/common'; import { TEAM_ALREADY_EXISTS } from 'src/libs/constants/team'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; +import CreateTeamService from 'src/modules/teams/services/create.team.service'; +import { CREATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; const createTeamDto: CreateTeamDto = { name: faker.name.findName(), @@ -32,21 +32,21 @@ describe('CreateTeamService', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - createTeamService, + CreateTeamService, { provide: TEAM_REPOSITORY, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.CreateTeamUserService, + provide: CREATE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - teamService = module.get(createTeamService.provide); + teamService = module.get(CreateTeamService); teamRepositoryMock = module.get(TEAM_REPOSITORY); - createTeamUserServiceMock = module.get(TeamUsers.TYPES.services.CreateTeamUserService); + createTeamUserServiceMock = module.get(CREATE_TEAM_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/teams/services/create.team.service.ts b/backend/src/modules/teams/services/create.team.service.ts index e6bedb55b..8df61ec3a 100644 --- a/backend/src/modules/teams/services/create.team.service.ts +++ b/backend/src/modules/teams/services/create.team.service.ts @@ -8,15 +8,15 @@ import { CreateTeamServiceInterface } from '../interfaces/services/create.team.s import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from '../constants'; import { TEAM_ALREADY_EXISTS } from 'src/libs/constants/team'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; +import { CREATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export default class CreateTeamService implements CreateTeamServiceInterface { constructor( @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, - @Inject(TeamUsers.TYPES.services.CreateTeamUserService) + @Inject(CREATE_TEAM_USER_SERVICE) private readonly createTeamUserService: CreateTeamUserServiceInterface ) {} diff --git a/backend/src/modules/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index a5b5a6d9b..c895a8a75 100644 --- a/backend/src/modules/teams/services/delete.team.service.spec.ts +++ b/backend/src/modules/teams/services/delete.team.service.spec.ts @@ -6,15 +6,15 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import { deleteTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; import { BadRequestException } from '@nestjs/common'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; +import DeleteTeamService from 'src/modules/teams/services/delete.team.service'; +import { DELETE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -41,7 +41,7 @@ describe('DeleteTeamService', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - deleteTeamService, + DeleteTeamService, { provide: TEAM_REPOSITORY, useValue: createMock() @@ -51,15 +51,15 @@ describe('DeleteTeamService', () => { useValue: createMock() }, { - provide: TeamUsers.TYPES.services.DeleteTeamUserService, + provide: DELETE_TEAM_USER_SERVICE, useValue: createMock() } ] }).compile(); - teamService = module.get(deleteTeamService.provide); + teamService = module.get(DeleteTeamService); teamRepositoryMock = module.get(TEAM_REPOSITORY); - deleteTeamUserServiceMock = module.get(TeamUsers.TYPES.services.DeleteTeamUserService); + deleteTeamUserServiceMock = module.get(DELETE_TEAM_USER_SERVICE); deleteBoardServiceMock = module.get(Boards.TYPES.services.DeleteBoardService); }); diff --git a/backend/src/modules/teams/services/delete.team.service.ts b/backend/src/modules/teams/services/delete.team.service.ts index c41c8ba07..adde9582b 100644 --- a/backend/src/modules/teams/services/delete.team.service.ts +++ b/backend/src/modules/teams/services/delete.team.service.ts @@ -4,9 +4,9 @@ import { DeleteTeamServiceInterface } from '../interfaces/services/delete.team.s import { TEAM_REPOSITORY } from '../constants'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import * as Boards from '../../boards/interfaces/types'; -import * as TeamUsers from '../../teamUsers/interfaces/types'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; +import { DELETE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export default class DeleteTeamService implements DeleteTeamServiceInterface { @@ -15,7 +15,7 @@ export default class DeleteTeamService implements DeleteTeamServiceInterface { private readonly teamRepository: TeamRepositoryInterface, @Inject(Boards.TYPES.services.DeleteBoardService) private readonly deleteBoardService: DeleteBoardServiceInterface, - @Inject(TeamUsers.TYPES.services.DeleteTeamUserService) + @Inject(DELETE_TEAM_USER_SERVICE) private readonly deleteTeamUserService: DeleteTeamUserServiceInterface ) {} diff --git a/backend/src/modules/teams/services/get.team.service.spec.ts b/backend/src/modules/teams/services/get.team.service.spec.ts index f22d24f4f..54c08800d 100644 --- a/backend/src/modules/teams/services/get.team.service.spec.ts +++ b/backend/src/modules/teams/services/get.team.service.spec.ts @@ -12,12 +12,12 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import { getTeamService } from 'src/modules/teams/providers'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; +import GetTeamService from 'src/modules/teams/services/get.team.service'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -56,13 +56,13 @@ describe('GetTeamService', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - getTeamService, + GetTeamService, { provide: TEAM_REPOSITORY, useValue: createMock() }, { - provide: TeamUsers.TYPES.services.GetTeamUserService, + provide: GET_TEAM_USER_SERVICE, useValue: createMock() }, { @@ -72,9 +72,9 @@ describe('GetTeamService', () => { ] }).compile(); - teamService = module.get(getTeamService.provide); + teamService = module.get(GetTeamService); teamRepositoryMock = module.get(TEAM_REPOSITORY); - getTeamUserServiceMock = module.get(TeamUsers.TYPES.services.GetTeamUserService); + getTeamUserServiceMock = module.get(GET_TEAM_USER_SERVICE); getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); }); diff --git a/backend/src/modules/teams/services/get.team.service.ts b/backend/src/modules/teams/services/get.team.service.ts index 0883160fc..1d838949b 100644 --- a/backend/src/modules/teams/services/get.team.service.ts +++ b/backend/src/modules/teams/services/get.team.service.ts @@ -5,17 +5,17 @@ import { GetTeamServiceInterface } from '../interfaces/services/get.team.service import Team from '../entities/team.schema'; import { TEAM_REPOSITORY } from '../constants'; import * as Boards from 'src/modules/boards/interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export default class GetTeamService implements GetTeamServiceInterface { constructor( @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, - @Inject(TeamUsers.TYPES.services.GetTeamUserService) + @Inject(GET_TEAM_USER_SERVICE) private readonly getTeamUserService: GetTeamUserServiceInterface, @Inject(Boards.TYPES.services.GetBoardService) private readonly getBoardService: GetBoardServiceInterface diff --git a/backend/src/modules/users/applications/delete-user.use-case.ts b/backend/src/modules/users/applications/delete-user.use-case.ts index bca95912a..3b5da4e8f 100644 --- a/backend/src/modules/users/applications/delete-user.use-case.ts +++ b/backend/src/modules/users/applications/delete-user.use-case.ts @@ -2,20 +2,20 @@ import { DeleteUserUseCaseInterface } from '../interfaces/applications/delete-us import { Inject, Injectable } from '@nestjs/common'; import { TYPES } from '../interfaces/types'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; -import * as TeamUser from 'src/modules/teamUsers/interfaces/types'; import { GetTeamUserServiceInterface } from '../../teamUsers/interfaces/services/get.team.user.service.interface'; import UserDto from '../dto/user.dto'; import { UserRepositoryInterface } from '../repository/user.repository.interface'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; +import { DELETE_TEAM_USER_SERVICE, GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export class DeleteUserUseCase implements DeleteUserUseCaseInterface { constructor( @Inject(TYPES.repository) private readonly userRepository: UserRepositoryInterface, - @Inject(TeamUser.TYPES.services.DeleteTeamUserService) - private deleteTeamUserService: DeleteTeamUserServiceInterface, - @Inject(TeamUser.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface + @Inject(DELETE_TEAM_USER_SERVICE) + private readonly deleteTeamUserService: DeleteTeamUserServiceInterface, + @Inject(GET_TEAM_USER_SERVICE) + private readonly getTeamUserService: GetTeamUserServiceInterface ) {} async execute(user: UserDto, userId: string) { diff --git a/backend/src/modules/users/applications/get-all-users-with-teams.use-case.ts b/backend/src/modules/users/applications/get-all-users-with-teams.use-case.ts index 8e917b2fe..7b693aa6c 100644 --- a/backend/src/modules/users/applications/get-all-users-with-teams.use-case.ts +++ b/backend/src/modules/users/applications/get-all-users-with-teams.use-case.ts @@ -3,10 +3,10 @@ import { Inject, Injectable } from '@nestjs/common'; import { GetAllUsersWithTeamsUseCaseInterface } from '../interfaces/applications/get-all-users-with-teams.use-case.interface'; import { UserWithTeams } from '../interfaces/type-user-with-teams'; import { TYPES } from '../interfaces/types'; -import * as TeamUsers from 'src/modules/teamUsers/interfaces/types'; import { UserRepositoryInterface } from '../repository/user.repository.interface'; import { sortAlphabetically } from '../utils/sortings'; import { GetUserServiceInterface } from '../interfaces/services/get.user.service.interface'; +import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; @Injectable() export default class GetAllUsersWithTeamsUseCase implements GetAllUsersWithTeamsUseCaseInterface { @@ -15,8 +15,8 @@ export default class GetAllUsersWithTeamsUseCase implements GetAllUsersWithTeams private readonly userRepository: UserRepositoryInterface, @Inject(TYPES.services.GetUserService) private readonly getUserService: GetUserServiceInterface, - @Inject(TeamUsers.TYPES.services.GetTeamUserService) - private getTeamUserService: GetTeamUserServiceInterface + @Inject(GET_TEAM_USER_SERVICE) + private readonly getTeamUserService: GetTeamUserServiceInterface ) {} async execute(page = 0, size = 15, searchUser?: string) { From 3fdb3494291bd6b53cf4e0ae9000b3d4d62f401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 09:39:22 +0100 Subject: [PATCH 04/14] feat: remove CODEOWNERS file --- .github/CODEOWNERS | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index ac6e999db..000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# split codeowners - -* @nunocaseiro @dsousa12 @tutods - -/backend/* @mourabraz @CatiaAntunes96 \ No newline at end of file From d65910faef43d04159a304069ba2bf24ac8aeec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 10:25:42 +0100 Subject: [PATCH 05/14] refactor: extract types from interfaces --- backend/src/libs/guards/boardRoles.guard.ts | 2 +- backend/src/libs/guards/getBoardPermissions.guard.ts | 2 +- backend/src/libs/guards/updateBoardPermissions.guard.ts | 2 +- .../src/modules/auth/applications/statistics.auth.use-case.ts | 2 +- .../modules/boards/applications/create-board.use-case.spec.ts | 2 +- .../src/modules/boards/applications/create-board.use-case.ts | 2 +- .../modules/boards/applications/delete-board.use-case.spec.ts | 2 +- .../src/modules/boards/applications/delete-board.use-case.ts | 2 +- .../boards/applications/duplicate-board.use-case.spec.ts | 2 +- .../src/modules/boards/applications/duplicate-board.use-case.ts | 2 +- .../modules/boards/applications/get-all-boards.use-case.spec.ts | 2 +- .../src/modules/boards/applications/get-all-boards.use-case.ts | 2 +- .../src/modules/boards/applications/get-board.use-case.spec.ts | 2 +- backend/src/modules/boards/applications/get-board.use-case.ts | 2 +- .../applications/get-boards-for-dashboard.use-case.spec.ts | 2 +- .../boards/applications/get-boards-for-dashboard.use-case.ts | 2 +- .../boards/applications/get-personal-boards.use-case.spec.ts | 2 +- .../modules/boards/applications/get-personal-boards.use-case.ts | 2 +- .../boards/applications/is-board-public.use-case.spec.ts | 2 +- .../src/modules/boards/applications/is-board-public.use-case.ts | 2 +- .../modules/boards/applications/merge-board.use-case.spec.ts | 2 +- backend/src/modules/boards/applications/merge-board.use-case.ts | 2 +- .../boards/applications/update-board-phase.use-case.spec.ts | 2 +- .../modules/boards/applications/update-board-phase.use-case.ts | 2 +- .../modules/boards/applications/update-board.use-case.spec.ts | 2 +- .../src/modules/boards/applications/update-board.use-case.ts | 2 +- backend/src/modules/boards/boards.providers.ts | 2 +- backend/src/modules/boards/controller/boards.controller.ts | 2 +- .../src/modules/boards/controller/publicBoards.controller.ts | 2 +- .../src/modules/boards/services/create.board.service.spec.ts | 2 +- backend/src/modules/boards/services/create.board.service.ts | 2 +- .../src/modules/boards/services/delete.board.service.spec.ts | 2 +- backend/src/modules/boards/services/delete.board.service.ts | 2 +- backend/src/modules/boards/services/get.board.service.spec.ts | 2 +- backend/src/modules/boards/services/get.board.service.ts | 2 +- .../src/modules/boards/services/pause-board-timer.service.ts | 2 +- .../modules/boards/services/send-board-timer-state.service.ts | 2 +- .../src/modules/boards/services/start-board-timer.service.ts | 2 +- backend/src/modules/boards/services/stop-board-timer.service.ts | 2 +- .../boards/services/update-board-timer-duration.service.ts | 2 +- .../src/modules/boards/services/update.board.service.spec.ts | 2 +- backend/src/modules/boards/services/update.board.service.ts | 2 +- .../boards/subscribers/after-user-paused-timer.subscriber.ts | 2 +- .../subscribers/after-user-requested-timer-state.subscriber.ts | 2 +- .../boards/subscribers/after-user-started-timer.subscriber.ts | 2 +- .../boards/subscribers/after-user-stopped-timer.subscriber.ts | 2 +- .../subscribers/after-user-updated-duration.subscriber.ts | 2 +- backend/src/modules/boards/{interfaces => }/types.ts | 0 .../src/modules/columns/services/update.column.service.spec.ts | 2 +- backend/src/modules/columns/services/update.column.service.ts | 2 +- .../consumers/slack-communication.consumer.spec.ts | 2 +- .../communication/consumers/slack-communication.consumer.ts | 2 +- .../src/modules/schedules/services/create.schedules.service.ts | 2 +- backend/src/modules/teams/services/delete.team.service.spec.ts | 2 +- backend/src/modules/teams/services/delete.team.service.ts | 2 +- backend/src/modules/teams/services/get.team.service.spec.ts | 2 +- backend/src/modules/teams/services/get.team.service.ts | 2 +- backend/src/modules/votes/services/create.vote.service.spec.ts | 2 +- backend/src/modules/votes/services/create.vote.service.ts | 2 +- backend/src/modules/votes/services/delete.vote.service.spec.ts | 2 +- backend/src/modules/votes/services/delete.vote.service.ts | 2 +- 61 files changed, 60 insertions(+), 60 deletions(-) rename backend/src/modules/boards/{interfaces => }/types.ts (100%) diff --git a/backend/src/libs/guards/boardRoles.guard.ts b/backend/src/libs/guards/boardRoles.guard.ts index 3b7df19ca..2dd1ced66 100644 --- a/backend/src/libs/guards/boardRoles.guard.ts +++ b/backend/src/libs/guards/boardRoles.guard.ts @@ -9,7 +9,7 @@ import { Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; diff --git a/backend/src/libs/guards/getBoardPermissions.guard.ts b/backend/src/libs/guards/getBoardPermissions.guard.ts index 7618b387d..a90459150 100644 --- a/backend/src/libs/guards/getBoardPermissions.guard.ts +++ b/backend/src/libs/guards/getBoardPermissions.guard.ts @@ -5,7 +5,7 @@ import { Inject, Injectable } from '@nestjs/common'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import Team from 'src/modules/teams/entities/team.schema'; diff --git a/backend/src/libs/guards/updateBoardPermissions.guard.ts b/backend/src/libs/guards/updateBoardPermissions.guard.ts index 371905ac3..bfdaebfa9 100644 --- a/backend/src/libs/guards/updateBoardPermissions.guard.ts +++ b/backend/src/libs/guards/updateBoardPermissions.guard.ts @@ -7,7 +7,7 @@ import { Injectable, NotFoundException } from '@nestjs/common'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import User from 'src/modules/users/entities/user.schema'; import UpdateBoardUserDto from 'src/modules/boardUsers/dto/update-board-user.dto'; diff --git a/backend/src/modules/auth/applications/statistics.auth.use-case.ts b/backend/src/modules/auth/applications/statistics.auth.use-case.ts index 291d5b934..9823d6e49 100644 --- a/backend/src/modules/auth/applications/statistics.auth.use-case.ts +++ b/backend/src/modules/auth/applications/statistics.auth.use-case.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import * as User from 'src/modules/users/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/get.user.service.interface'; import { StatisticsAuthUserUseCaseInterface } from '../interfaces/applications/statistics.auth.use-case.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; diff --git a/backend/src/modules/boards/applications/create-board.use-case.spec.ts b/backend/src/modules/boards/applications/create-board.use-case.spec.ts index eaa52e9cb..70a95fbec 100644 --- a/backend/src/modules/boards/applications/create-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/create-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/boards/applications/create-board.use-case.ts b/backend/src/modules/boards/applications/create-board.use-case.ts index ba870d73e..e5469f14e 100644 --- a/backend/src/modules/boards/applications/create-board.use-case.ts +++ b/backend/src/modules/boards/applications/create-board.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import Board from '../entities/board.schema'; import { CreateBoardServiceInterface } from '../interfaces/services/create.board.service.interface'; diff --git a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts index 3460428e0..03d40095b 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/boards/applications/delete-board.use-case.ts b/backend/src/modules/boards/applications/delete-board.use-case.ts index 30960756f..05672715c 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; import { ObjectId } from 'mongoose'; diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts index 251932079..acee9d85d 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as Users from 'src/modules/users/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.ts index d0eac00c4..e15fa8a35 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.ts @@ -15,7 +15,7 @@ import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/g import * as Users from 'src/modules/users/interfaces/types'; import Board from '../entities/board.schema'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: string }; diff --git a/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts b/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts index eed3bef1b..7a5dc75ec 100644 --- a/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/boards/applications/get-all-boards.use-case.ts b/backend/src/modules/boards/applications/get-all-boards.use-case.ts index 2d696dee3..447864d33 100644 --- a/backend/src/modules/boards/applications/get-all-boards.use-case.ts +++ b/backend/src/modules/boards/applications/get-all-boards.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetAllBoardsUseCaseDto from '../dto/useCase/get-all-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() diff --git a/backend/src/modules/boards/applications/get-board.use-case.spec.ts b/backend/src/modules/boards/applications/get-board.use-case.spec.ts index c6e9d00ad..bb00f5815 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; diff --git a/backend/src/modules/boards/applications/get-board.use-case.ts b/backend/src/modules/boards/applications/get-board.use-case.ts index 4a171e59b..96798f6ce 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts index 18f8825c2..cbdf6796d 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts index 11f3e2608..bfdd40cb0 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts +++ b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() diff --git a/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts b/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts index 5b3881d88..217b31088 100644 --- a/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/boards/applications/get-personal-boards.use-case.ts b/backend/src/modules/boards/applications/get-personal-boards.use-case.ts index 9f684861a..f646eda61 100644 --- a/backend/src/modules/boards/applications/get-personal-boards.use-case.ts +++ b/backend/src/modules/boards/applications/get-personal-boards.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts index 81937ded8..bf099bd0f 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.ts b/backend/src/modules/boards/applications/is-board-public.use-case.ts index 28abad4c7..caf777156 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; diff --git a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts index 42b7409e7..15f3c704c 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import faker from '@faker-js/faker'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; diff --git a/backend/src/modules/boards/applications/merge-board.use-case.ts b/backend/src/modules/boards/applications/merge-board.use-case.ts index c146f7b88..edfb47040 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.ts @@ -6,7 +6,7 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { generateNewSubColumns } from '../utils/generate-subcolumns'; import { mergeCardsFromSubBoardColumnsIntoMainBoard } from '../utils/merge-cards-from-subboard'; diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts index f547f9e22..8162fc853 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts @@ -10,7 +10,7 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import { boardRepository } from '../boards.providers'; diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.ts index 8a3f5a699..9b9392885 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.ts @@ -13,7 +13,7 @@ import { SlackMessageDto } from 'src/modules/communication/dto/slack.message.dto import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import PhaseChangeEvent from 'src/modules/socket/events/user-updated-phase.event'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index d035737f4..717c50890 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import { boardRepository } from '../boards.providers'; diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index beacfe0f0..3a8547551 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -18,7 +18,7 @@ import * as Votes from 'src/modules/votes/interfaces/types'; import { UpdateBoardDto } from '../dto/update-board.dto'; import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/boards.providers.ts b/backend/src/modules/boards/boards.providers.ts index 1c63d3756..1c2e25b2d 100644 --- a/backend/src/modules/boards/boards.providers.ts +++ b/backend/src/modules/boards/boards.providers.ts @@ -18,7 +18,7 @@ import { GetBoardUseCase } from './applications/get-board.use-case'; import { GetBoardsForDashboardUseCase } from './applications/get-boards-for-dashboard.use-case'; import { GetPersonalBoardsUseCase } from './applications/get-personal-boards.use-case'; import { IsBoardPublicUseCase } from './applications/is-board-public.use-case'; -import { TYPES } from './interfaces/types'; +import { TYPES } from './types'; import { BoardRepository } from './repositories/board.repository'; import CreateBoardService from './services/create.board.service'; import DeleteBoardService from './services/delete.board.service'; diff --git a/backend/src/modules/boards/controller/boards.controller.ts b/backend/src/modules/boards/controller/boards.controller.ts index d4d9093cc..545a32340 100644 --- a/backend/src/modules/boards/controller/boards.controller.ts +++ b/backend/src/modules/boards/controller/boards.controller.ts @@ -61,7 +61,7 @@ import GetBoardUseCaseDto from '../dto/useCase/get-board.use-case.dto'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import BoardUseCasePresenter from '../presenter/board.use-case.presenter'; import DeleteBoardUseCaseDto from 'src/modules/boards/dto/useCase/delete-board.use-case'; import BoardsPaginatedPresenter from 'src/modules/boards/presenter/boards-paginated.presenter'; diff --git a/backend/src/modules/boards/controller/publicBoards.controller.ts b/backend/src/modules/boards/controller/publicBoards.controller.ts index 485cae0b0..997b7e2f2 100644 --- a/backend/src/modules/boards/controller/publicBoards.controller.ts +++ b/backend/src/modules/boards/controller/publicBoards.controller.ts @@ -11,7 +11,7 @@ import { ApiParam, ApiTags } from '@nestjs/swagger'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @ApiTags('PublicBoards') diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 2fe199e99..52356a67e 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index 14624d793..a8c5e6947 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -14,7 +14,7 @@ import * as CommunicationsType from 'src/modules/communication/interfaces/types' import { AddCronJobDto } from 'src/modules/schedules/dto/add.cronjob.dto'; import { CreateSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/create.schedules.service.interface'; import * as SchedulesType from 'src/modules/schedules/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; diff --git a/backend/src/modules/boards/services/delete.board.service.spec.ts b/backend/src/modules/boards/services/delete.board.service.spec.ts index 56c3df0cb..0a3dcc58f 100644 --- a/backend/src/modules/boards/services/delete.board.service.spec.ts +++ b/backend/src/modules/boards/services/delete.board.service.spec.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; diff --git a/backend/src/modules/boards/services/delete.board.service.ts b/backend/src/modules/boards/services/delete.board.service.ts index 8bc50a5fc..cfcfc985c 100644 --- a/backend/src/modules/boards/services/delete.board.service.ts +++ b/backend/src/modules/boards/services/delete.board.service.ts @@ -5,7 +5,7 @@ import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interface import * as Schedules from 'src/modules/schedules/interfaces/types'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import Board from '../entities/board.schema'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index 3f3096fa4..595e8b738 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -8,7 +8,7 @@ import { updateUserService } from 'src/modules/users/users.providers'; import { boardRepository } from '../boards.providers'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; diff --git a/backend/src/modules/boards/services/get.board.service.ts b/backend/src/modules/boards/services/get.board.service.ts index b67052753..2d1dfbe19 100644 --- a/backend/src/modules/boards/services/get.board.service.ts +++ b/backend/src/modules/boards/services/get.board.service.ts @@ -6,7 +6,7 @@ import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { QueryType } from '../interfaces/findQuery'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { cleanBoard } from '../utils/clean-board'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import UserDto from 'src/modules/users/dto/user.dto'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; diff --git a/backend/src/modules/boards/services/pause-board-timer.service.ts b/backend/src/modules/boards/services/pause-board-timer.service.ts index bd9f430a8..9c232bf3c 100644 --- a/backend/src/modules/boards/services/pause-board-timer.service.ts +++ b/backend/src/modules/boards/services/pause-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_PAUSED } from 'src/libs/constants/timer'; import BoardTimerTimeLeftDto from 'src/libs/dto/board-timer-time-left.dto'; import ServerPausedTimerEvent from 'src/modules/boards/events/server-paused-timer.event'; import PauseBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/pause-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/send-board-timer-state.service.ts b/backend/src/modules/boards/services/send-board-timer-state.service.ts index 105b1a00a..d119e32c6 100644 --- a/backend/src/modules/boards/services/send-board-timer-state.service.ts +++ b/backend/src/modules/boards/services/send-board-timer-state.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_SENT_TIMER_STATE } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerSentTimerStateEvent from 'src/modules/boards/events/server-sent-timer-state.event'; import SendBoardTimerStateServiceInterface from 'src/modules/boards/interfaces/services/send-board-timer-state.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/start-board-timer.service.ts b/backend/src/modules/boards/services/start-board-timer.service.ts index 25e886485..f2d7b2dff 100644 --- a/backend/src/modules/boards/services/start-board-timer.service.ts +++ b/backend/src/modules/boards/services/start-board-timer.service.ts @@ -11,7 +11,7 @@ import ServerStartedTimerEvent from 'src/modules/boards/events/server-started-ti import SendBoardTimerTimeLeftServiceInterface from 'src/modules/boards/interfaces/services/send-board-time-left.service.interface'; import StartBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/start-board-timer.service.interface'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/stop-board-timer.service.ts b/backend/src/modules/boards/services/stop-board-timer.service.ts index 84ab564bd..d723935d1 100644 --- a/backend/src/modules/boards/services/stop-board-timer.service.ts +++ b/backend/src/modules/boards/services/stop-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_STOPPED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerStoppedTimerEvent from 'src/modules/boards/events/server-stopped-timer.event'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/update-board-timer-duration.service.ts b/backend/src/modules/boards/services/update-board-timer-duration.service.ts index 6e2a08e19..7d26cb0a8 100644 --- a/backend/src/modules/boards/services/update-board-timer-duration.service.ts +++ b/backend/src/modules/boards/services/update-board-timer-duration.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_DURATION_UPDATED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import ServerUpdatedTimerDurationEvent from 'src/modules/boards/events/server-updated-timer-duration.event'; import UpdateBoardTimerDurationServiceInterface from 'src/modules/boards/interfaces/services/update-board-timer-duration.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; import { BoardTimerRepositoryInterface } from '../repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/update.board.service.spec.ts b/backend/src/modules/boards/services/update.board.service.spec.ts index 688fa2130..5150c636b 100644 --- a/backend/src/modules/boards/services/update.board.service.spec.ts +++ b/backend/src/modules/boards/services/update.board.service.spec.ts @@ -4,7 +4,7 @@ import { UpdateBoardServiceInterface } from '../interfaces/services/update.board import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { TeamCommunicationDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamDto-factory'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import UpdateBoardService from './update.board.service'; import Board from '../entities/board.schema'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; diff --git a/backend/src/modules/boards/services/update.board.service.ts b/backend/src/modules/boards/services/update.board.service.ts index d4d7733f9..6dfd803de 100644 --- a/backend/src/modules/boards/services/update.board.service.ts +++ b/backend/src/modules/boards/services/update.board.service.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { UpdateBoardServiceInterface } from '../interfaces/services/update.board.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; diff --git a/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts index e7c0c351d..ff4a22ee7 100644 --- a/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_PAUSED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import PauseBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/pause-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; @Injectable() export default class AfterUserPausedTimerSubscriber { diff --git a/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts index 0720a80fd..27a7df47a 100644 --- a/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_REQUESTED_TIMER_STATE } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import SendBoardTimerStateServiceInterface from 'src/modules/boards/interfaces/services/send-board-timer-state.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; @Injectable() export default class AfterUserRequestedTimerStateSubscriber { diff --git a/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts index ae74034cd..ed87b9a69 100644 --- a/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_STARTED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import StartBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/start-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; @Injectable() export default class AfterUserStartedTimerSubscriber { diff --git a/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts index 3d1559e52..da210fd51 100644 --- a/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_STOPPED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; @Injectable() export default class AfterUserStoppedTimerSubscriber { diff --git a/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts index ba91ae521..3d545be37 100644 --- a/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts @@ -3,7 +3,7 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_DURATION_UPDATED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import UpdateBoardTimerDurationServiceInterface from 'src/modules/boards/interfaces/services/update-board-timer-duration.service.interface'; -import { TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES } from 'src/modules/boards/types'; @Injectable() export default class AfterUserUpdatedDurationSubscriber { diff --git a/backend/src/modules/boards/interfaces/types.ts b/backend/src/modules/boards/types.ts similarity index 100% rename from backend/src/modules/boards/interfaces/types.ts rename to backend/src/modules/boards/types.ts diff --git a/backend/src/modules/columns/services/update.column.service.spec.ts b/backend/src/modules/columns/services/update.column.service.spec.ts index 7c8b1de73..a7d01923a 100644 --- a/backend/src/modules/columns/services/update.column.service.spec.ts +++ b/backend/src/modules/columns/services/update.column.service.spec.ts @@ -8,7 +8,7 @@ import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory. import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { updateColumnService } from '../columns.providers'; import * as Columns from '../interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import { ColumnRepository } from '../repositories/column.repository'; import GetBoardService from 'src/modules/boards/services/get.board.service'; diff --git a/backend/src/modules/columns/services/update.column.service.ts b/backend/src/modules/columns/services/update.column.service.ts index 31e3b3131..7faffbbda 100644 --- a/backend/src/modules/columns/services/update.column.service.ts +++ b/backend/src/modules/columns/services/update.column.service.ts @@ -1,6 +1,6 @@ import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; import { COLUMN_NOT_FOUND, UPDATE_FAILED } from 'src/libs/exceptions/messages'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import * as Columns from '../interfaces/types'; import { UpdateColumnServiceInterface } from '../interfaces/services/update.column.service.interface'; diff --git a/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts b/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts index fd940d018..b6fe07c24 100644 --- a/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts +++ b/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from 'src/modules/communication/interfaces/types'; -import { TYPES as BOARD_TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES as BOARD_TYPES } from 'src/modules/boards/types'; import { BoardType } from '../dto/types'; import { Job } from 'bull'; import { SlackCommunicationConsumer } from './slack-communication.consumer'; diff --git a/backend/src/modules/communication/consumers/slack-communication.consumer.ts b/backend/src/modules/communication/consumers/slack-communication.consumer.ts index 095f46254..09f6b8587 100644 --- a/backend/src/modules/communication/consumers/slack-communication.consumer.ts +++ b/backend/src/modules/communication/consumers/slack-communication.consumer.ts @@ -2,7 +2,7 @@ import { OnQueueCompleted, Process, Processor } from '@nestjs/bull'; import { Inject, Logger } from '@nestjs/common'; import { Job } from 'bull'; import { UpdateBoardServiceInterface } from 'src/modules/boards/interfaces/services/update.board.service.interface'; -import { TYPES as BOARD_TYPES } from 'src/modules/boards/interfaces/types'; +import { TYPES as BOARD_TYPES } from 'src/modules/boards/types'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; import { BoardType } from 'src/modules/communication/dto/types'; import { CommunicationApplicationInterface } from 'src/modules/communication/interfaces/communication.application.interface'; diff --git a/backend/src/modules/schedules/services/create.schedules.service.ts b/backend/src/modules/schedules/services/create.schedules.service.ts index 9fa7c40a5..46d01f38e 100644 --- a/backend/src/modules/schedules/services/create.schedules.service.ts +++ b/backend/src/modules/schedules/services/create.schedules.service.ts @@ -4,7 +4,7 @@ import { CronJob } from 'cron'; import { getDay, getNextMonth } from 'src/libs/utils/dates'; import { CreateBoardServiceInterface } from 'src/modules/boards/interfaces/services/create.board.service.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; -import * as BoardTypes from 'src/modules/boards/interfaces/types'; +import * as BoardTypes from 'src/modules/boards/types'; import Board from 'src/modules/boards/entities/board.schema'; import { ArchiveChannelDataOptions } from 'src/modules/communication/dto/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; diff --git a/backend/src/modules/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index c895a8a75..077b20a63 100644 --- a/backend/src/modules/teams/services/delete.team.service.spec.ts +++ b/backend/src/modules/teams/services/delete.team.service.spec.ts @@ -6,7 +6,7 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; diff --git a/backend/src/modules/teams/services/delete.team.service.ts b/backend/src/modules/teams/services/delete.team.service.ts index adde9582b..3b1e3e28e 100644 --- a/backend/src/modules/teams/services/delete.team.service.ts +++ b/backend/src/modules/teams/services/delete.team.service.ts @@ -3,7 +3,7 @@ import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { DeleteTeamServiceInterface } from '../interfaces/services/delete.team.service.interface'; import { TEAM_REPOSITORY } from '../constants'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; -import * as Boards from '../../boards/interfaces/types'; +import * as Boards from '../../boards/types'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; import { DELETE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; diff --git a/backend/src/modules/teams/services/get.team.service.spec.ts b/backend/src/modules/teams/services/get.team.service.spec.ts index 54c08800d..b85d257a6 100644 --- a/backend/src/modules/teams/services/get.team.service.spec.ts +++ b/backend/src/modules/teams/services/get.team.service.spec.ts @@ -12,7 +12,7 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; diff --git a/backend/src/modules/teams/services/get.team.service.ts b/backend/src/modules/teams/services/get.team.service.ts index 1d838949b..89d80ffdd 100644 --- a/backend/src/modules/teams/services/get.team.service.ts +++ b/backend/src/modules/teams/services/get.team.service.ts @@ -4,7 +4,7 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { GetTeamServiceInterface } from '../interfaces/services/get.team.service.interface'; import Team from '../entities/team.schema'; import { TEAM_REPOSITORY } from '../constants'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; diff --git a/backend/src/modules/votes/services/create.vote.service.spec.ts b/backend/src/modules/votes/services/create.vote.service.spec.ts index baf51e959..650b57abb 100644 --- a/backend/src/modules/votes/services/create.vote.service.spec.ts +++ b/backend/src/modules/votes/services/create.vote.service.spec.ts @@ -1,7 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import CreateVoteService from './create.vote.service'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; diff --git a/backend/src/modules/votes/services/create.vote.service.ts b/backend/src/modules/votes/services/create.vote.service.ts index 20712580a..bb50e7f31 100644 --- a/backend/src/modules/votes/services/create.vote.service.ts +++ b/backend/src/modules/votes/services/create.vote.service.ts @@ -3,7 +3,7 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { BOARD_NOT_FOUND, INSERT_VOTE_FAILED } from 'src/libs/exceptions/messages'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { InsertFailedException } from 'src/libs/exceptions/insertFailedBadRequestException'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 63d2a62d0..a23981ebf 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Cards from 'src/modules/cards/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index cc952d6ce..829fd21e8 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -6,7 +6,7 @@ import * as Cards from 'src/modules/cards/interfaces/types'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/interfaces/types'; +import * as Boards from 'src/modules/boards/types'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; From d47a65f2ccf2af41bee685c7869ef9b09cbbd6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 11:54:20 +0100 Subject: [PATCH 06/14] refactor: change TYPES to constants(services) --- backend/src/libs/guards/boardRoles.guard.ts | 4 +-- .../libs/guards/getBoardPermissions.guard.ts | 8 ++--- backend/src/libs/guards/teamRoles.guard.ts | 2 +- .../guards/updateBoardPermissions.guard.ts | 4 +-- .../applications/statistics.auth.use-case.ts | 4 +-- .../create-board.use-case.spec.ts | 6 ++-- .../applications/create-board.use-case.ts | 4 +-- .../delete-board.use-case.spec.ts | 6 ++-- .../applications/delete-board.use-case.ts | 4 +-- .../duplicate-board.use-case.spec.ts | 6 ++-- .../applications/duplicate-board.use-case.ts | 4 +-- .../get-all-boards.use-case.spec.ts | 6 ++-- .../applications/get-all-boards.use-case.ts | 4 +-- .../applications/get-board.use-case.spec.ts | 2 +- .../boards/applications/get-board.use-case.ts | 2 +- .../get-boards-for-dashboard.use-case.spec.ts | 6 ++-- .../get-boards-for-dashboard.use-case.ts | 4 +-- .../get-personal-boards.use-case.spec.ts | 6 ++-- .../get-personal-boards.use-case.ts | 4 +-- .../is-board-public.use-case.spec.ts | 2 +- .../applications/is-board-public.use-case.ts | 2 +- .../applications/merge-board.use-case.spec.ts | 2 +- .../applications/merge-board.use-case.ts | 2 +- .../update-board-phase.use-case.spec.ts | 2 +- .../update-board-phase.use-case.ts | 2 +- .../update-board.use-case.spec.ts | 2 +- .../applications/update-board.use-case.ts | 2 +- .../src/modules/boards/boards.providers.ts | 34 +++++++++++++------ .../modules/boards/{types.ts => constants.ts} | 32 ++++++++++------- .../boards/controller/boards.controller.ts | 2 +- .../controller/publicBoards.controller.ts | 2 +- .../services/create.board.service.spec.ts | 2 +- .../boards/services/create.board.service.ts | 2 +- .../services/delete.board.service.spec.ts | 2 +- .../boards/services/delete.board.service.ts | 2 +- .../boards/services/get.board.service.spec.ts | 2 +- .../boards/services/get.board.service.ts | 2 +- .../services/pause-board-timer.service.ts | 2 +- .../send-board-timer-state.service.ts | 2 +- .../services/start-board-timer.service.ts | 10 ++++-- .../services/stop-board-timer.service.ts | 2 +- .../update-board-timer-duration.service.ts | 2 +- .../services/update.board.service.spec.ts | 2 +- .../boards/services/update.board.service.ts | 2 +- .../after-user-paused-timer.subscriber.ts | 4 +-- ...r-user-requested-timer-state.subscriber.ts | 4 +-- .../after-user-started-timer.subscriber.ts | 4 +-- .../after-user-stopped-timer.subscriber.ts | 4 +-- .../after-user-updated-duration.subscriber.ts | 4 +-- .../services/update.column.service.spec.ts | 14 ++++---- .../columns/services/update.column.service.ts | 4 +-- .../slack-communication.consumer.spec.ts | 8 ++--- .../consumers/slack-communication.consumer.ts | 4 +-- .../services/create.schedules.service.ts | 16 ++++----- .../services/delete.team.service.spec.ts | 6 ++-- .../teams/services/delete.team.service.ts | 4 +-- .../teams/services/get.team.service.spec.ts | 8 ++--- .../teams/services/get.team.service.ts | 4 +-- .../services/create.vote.service.spec.ts | 6 ++-- .../votes/services/create.vote.service.ts | 4 +-- .../services/delete.vote.service.spec.ts | 6 ++-- .../votes/services/delete.vote.service.ts | 4 +-- 62 files changed, 169 insertions(+), 145 deletions(-) rename backend/src/modules/boards/{types.ts => constants.ts} (62%) diff --git a/backend/src/libs/guards/boardRoles.guard.ts b/backend/src/libs/guards/boardRoles.guard.ts index 2dd1ced66..53478b365 100644 --- a/backend/src/libs/guards/boardRoles.guard.ts +++ b/backend/src/libs/guards/boardRoles.guard.ts @@ -9,10 +9,10 @@ import { Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export class BoardUserGuard implements CanActivate { @@ -20,7 +20,7 @@ export class BoardUserGuard implements CanActivate { @Inject(GET_TEAM_USER_SERVICE) private readonly getTeamUserService: GetTeamUserServiceInterface, private readonly reflector: Reflector, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) private readonly getBoardUserService: GetBoardUserServiceInterface diff --git a/backend/src/libs/guards/getBoardPermissions.guard.ts b/backend/src/libs/guards/getBoardPermissions.guard.ts index a90459150..869d61b67 100644 --- a/backend/src/libs/guards/getBoardPermissions.guard.ts +++ b/backend/src/libs/guards/getBoardPermissions.guard.ts @@ -5,7 +5,6 @@ import { Inject, Injectable } from '@nestjs/common'; -import * as Boards from 'src/modules/boards/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import Team from 'src/modules/teams/entities/team.schema'; @@ -13,15 +12,16 @@ import User from 'src/modules/users/entities/user.schema'; import { Reflector } from '@nestjs/core'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export class GetBoardGuard implements CanActivate { constructor( private readonly reflector: Reflector, - @Inject(Boards.TYPES.services.GetBoardService) - private getBoardService: GetBoardServiceInterface, + @Inject(GET_BOARD_SERVICE) + private readonly getBoardService: GetBoardServiceInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) - private getBoardUserService: GetBoardUserServiceInterface + private readonly getBoardUserService: GetBoardUserServiceInterface ) {} async canActivate(context: ExecutionContext) { diff --git a/backend/src/libs/guards/teamRoles.guard.ts b/backend/src/libs/guards/teamRoles.guard.ts index 56ffdf686..3375e740a 100644 --- a/backend/src/libs/guards/teamRoles.guard.ts +++ b/backend/src/libs/guards/teamRoles.guard.ts @@ -14,7 +14,7 @@ export class TeamUserGuard implements CanActivate { constructor( private readonly reflector: Reflector, @Inject(GET_TEAM_USER_SERVICE) - private getTeamUserService: GetTeamUserServiceInterface + private readonly getTeamUserService: GetTeamUserServiceInterface ) {} async canActivate(context: ExecutionContext) { diff --git a/backend/src/libs/guards/updateBoardPermissions.guard.ts b/backend/src/libs/guards/updateBoardPermissions.guard.ts index bfdaebfa9..8debef232 100644 --- a/backend/src/libs/guards/updateBoardPermissions.guard.ts +++ b/backend/src/libs/guards/updateBoardPermissions.guard.ts @@ -7,14 +7,14 @@ import { Injectable, NotFoundException } from '@nestjs/common'; -import * as Boards from 'src/modules/boards/types'; import User from 'src/modules/users/entities/user.schema'; import UpdateBoardUserDto from 'src/modules/boardUsers/dto/update-board-user.dto'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export class UpdateBoardPermissionsGuard implements CanActivate { constructor( - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/auth/applications/statistics.auth.use-case.ts b/backend/src/modules/auth/applications/statistics.auth.use-case.ts index 9823d6e49..48087dcd0 100644 --- a/backend/src/modules/auth/applications/statistics.auth.use-case.ts +++ b/backend/src/modules/auth/applications/statistics.auth.use-case.ts @@ -1,11 +1,11 @@ import { Inject, Injectable } from '@nestjs/common'; import * as User from 'src/modules/users/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/get.user.service.interface'; import { StatisticsAuthUserUseCaseInterface } from '../interfaces/applications/statistics.auth.use-case.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class StatisticsAuthUserUseCase implements StatisticsAuthUserUseCaseInterface { @@ -14,7 +14,7 @@ export default class StatisticsAuthUserUseCase implements StatisticsAuthUserUseC private readonly getUserService: GetUserServiceInterface, @Inject(GET_TEAM_USER_SERVICE) private readonly getTeamUserService: GetTeamUserServiceInterface, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/create-board.use-case.spec.ts b/backend/src/modules/boards/applications/create-board.use-case.spec.ts index 70a95fbec..f5f94d86d 100644 --- a/backend/src/modules/boards/applications/create-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/create-board.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; import faker from '@faker-js/faker'; @@ -9,6 +8,7 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import CreateBoardUseCaseDto from '../dto/useCase/create-board.use-case.dto'; import Board from '../entities/board.schema'; import { CreateBoardUseCase } from './create-board.use-case'; +import { CREATE_BOARD_SERVICE } from 'src/modules/boards/constants'; describe('CreateBoardUseCase', () => { let useCase: UseCase; @@ -19,14 +19,14 @@ describe('CreateBoardUseCase', () => { providers: [ CreateBoardUseCase, { - provide: Boards.TYPES.services.CreateBoardService, + provide: CREATE_BOARD_SERVICE, useValue: createMock() } ] }).compile(); useCase = module.get(CreateBoardUseCase); - createBoardServiceMock = module.get(Boards.TYPES.services.CreateBoardService); + createBoardServiceMock = module.get(CREATE_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/create-board.use-case.ts b/backend/src/modules/boards/applications/create-board.use-case.ts index e5469f14e..39c01caca 100644 --- a/backend/src/modules/boards/applications/create-board.use-case.ts +++ b/backend/src/modules/boards/applications/create-board.use-case.ts @@ -1,14 +1,14 @@ import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../types'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import Board from '../entities/board.schema'; import { CreateBoardServiceInterface } from '../interfaces/services/create.board.service.interface'; import CreateBoardUseCaseDto from '../dto/useCase/create-board.use-case.dto'; +import { CREATE_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export class CreateBoardUseCase implements UseCase { constructor( - @Inject(TYPES.services.CreateBoardService) + @Inject(CREATE_BOARD_SERVICE) private readonly createBoardService: CreateBoardServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts index 03d40095b..6cb8be2a1 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @@ -24,7 +24,7 @@ describe('DeleteBoardUseCase', () => { providers: [ deleteBoardUseCase, { - provide: Boards.TYPES.services.DeleteBoardService, + provide: Boards.DELETE_BOARD_SERVICE, useValue: createMock() }, { @@ -35,7 +35,7 @@ describe('DeleteBoardUseCase', () => { }).compile(); useCase = module.get(Boards.TYPES.applications.DeleteBoardUseCase); - deleteBoardServiceMock = module.get(Boards.TYPES.services.DeleteBoardService); + deleteBoardServiceMock = module.get(Boards.DELETE_BOARD_SERVICE); boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); }); diff --git a/backend/src/modules/boards/applications/delete-board.use-case.ts b/backend/src/modules/boards/applications/delete-board.use-case.ts index 05672715c..094c66af6 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../types'; +import { DELETE_BOARD_SERVICE, TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; import { ObjectId } from 'mongoose'; @@ -13,7 +13,7 @@ export class DeleteBoardUseCase implements UseCase { useValue: createMock() }, { - provide: Boards.TYPES.services.GetBoardService, + provide: Boards.GET_BOARD_SERVICE, useValue: createMock() }, { @@ -60,7 +60,7 @@ describe('DuplicateBoardUseCase', () => { duplicateBoardMock = module.get(DuplicateBoardUseCase); getUserServiceMock = module.get(Users.TYPES.services.GetUserService); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(Boards.GET_BOARD_SERVICE); boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); }); diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.ts index e15fa8a35..66f9bca99 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.ts @@ -15,7 +15,7 @@ import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/g import * as Users from 'src/modules/users/interfaces/types'; import Board from '../entities/board.schema'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../types'; +import { GET_BOARD_SERVICE, TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: string }; @@ -23,7 +23,7 @@ export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: s @Injectable() export class DuplicateBoardUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, @Inject(Users.TYPES.services.GetUserService) private readonly getUserService: GetUserServiceInterface, diff --git a/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts b/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts index 7a5dc75ec..0a38fe869 100644 --- a/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; @@ -9,6 +8,7 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetAllBoardsUseCaseDto from '../dto/useCase/get-all-boards.use-case.dto'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; import { GetAllBoardsUseCase } from './get-all-boards.use-case'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const teams = TeamFactory.createMany(2); const teamIds = teams.map((team) => team._id); @@ -31,14 +31,14 @@ describe('GetAllBoardsUseCase', () => { providers: [ GetAllBoardsUseCase, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); useCase = module.get(GetAllBoardsUseCase); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/get-all-boards.use-case.ts b/backend/src/modules/boards/applications/get-all-boards.use-case.ts index 447864d33..9dbf5775c 100644 --- a/backend/src/modules/boards/applications/get-all-boards.use-case.ts +++ b/backend/src/modules/boards/applications/get-all-boards.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetAllBoardsUseCaseDto from '../dto/useCase/get-all-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../types'; +import { GET_BOARD_SERVICE } from '../constants'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() @@ -10,7 +10,7 @@ export class GetAllBoardsUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/get-board.use-case.spec.ts b/backend/src/modules/boards/applications/get-board.use-case.spec.ts index bb00f5815..45a372a3b 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; diff --git a/backend/src/modules/boards/applications/get-board.use-case.ts b/backend/src/modules/boards/applications/get-board.use-case.ts index 96798f6ce..70fa12779 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts index cbdf6796d..9ef02ac58 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; @@ -9,6 +8,7 @@ import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { GetBoardsForDashboardUseCase } from './get-boards-for-dashboard.use-case'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const userId = faker.datatype.uuid(); @@ -21,14 +21,14 @@ describe('GetBoardsForDashboardUseCase', () => { providers: [ GetBoardsForDashboardUseCase, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); useCase = module.get(GetBoardsForDashboardUseCase); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts index bfdd40cb0..7e1175506 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts +++ b/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../types'; +import { GET_BOARD_SERVICE } from '../constants'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() @@ -10,7 +10,7 @@ export class GetBoardsForDashboardUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts b/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts index 217b31088..da744093a 100644 --- a/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-personal-boards.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; @@ -9,6 +8,7 @@ import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { GetPersonalBoardsUseCase } from './get-personal-boards.use-case'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const userId = faker.datatype.uuid(); @@ -21,14 +21,14 @@ describe('GetPersonalBoardsUseCase', () => { providers: [ GetPersonalBoardsUseCase, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); useCase = module.get(GetPersonalBoardsUseCase); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/get-personal-boards.use-case.ts b/backend/src/modules/boards/applications/get-personal-boards.use-case.ts index f646eda61..5f0cae73a 100644 --- a/backend/src/modules/boards/applications/get-personal-boards.use-case.ts +++ b/backend/src/modules/boards/applications/get-personal-boards.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { TYPES } from '../types'; +import { GET_BOARD_SERVICE } from '../constants'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() @@ -10,7 +10,7 @@ export class GetPersonalBoardsUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts index bf099bd0f..16b4c97ea 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.ts b/backend/src/modules/boards/applications/is-board-public.use-case.ts index caf777156..b3a172f0e 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; diff --git a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts index 15f3c704c..820a18846 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import faker from '@faker-js/faker'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; diff --git a/backend/src/modules/boards/applications/merge-board.use-case.ts b/backend/src/modules/boards/applications/merge-board.use-case.ts index edfb47040..bc1b6c645 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.ts @@ -6,7 +6,7 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { generateNewSubColumns } from '../utils/generate-subcolumns'; import { mergeCardsFromSubBoardColumnsIntoMainBoard } from '../utils/merge-cards-from-subboard'; diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts index 8162fc853..39013fb0e 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts @@ -10,7 +10,7 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import { boardRepository } from '../boards.providers'; diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.ts index 9b9392885..e93987c0a 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.ts @@ -13,7 +13,7 @@ import { SlackMessageDto } from 'src/modules/communication/dto/slack.message.dto import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import PhaseChangeEvent from 'src/modules/socket/events/user-updated-phase.event'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index 717c50890..df55582a2 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import { boardRepository } from '../boards.providers'; diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index 3a8547551..a8e15088a 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -18,7 +18,7 @@ import * as Votes from 'src/modules/votes/interfaces/types'; import { UpdateBoardDto } from '../dto/update-board.dto'; import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/boards.providers.ts b/backend/src/modules/boards/boards.providers.ts index 1c2e25b2d..c700e02f0 100644 --- a/backend/src/modules/boards/boards.providers.ts +++ b/backend/src/modules/boards/boards.providers.ts @@ -18,7 +18,19 @@ import { GetBoardUseCase } from './applications/get-board.use-case'; import { GetBoardsForDashboardUseCase } from './applications/get-boards-for-dashboard.use-case'; import { GetPersonalBoardsUseCase } from './applications/get-personal-boards.use-case'; import { IsBoardPublicUseCase } from './applications/is-board-public.use-case'; -import { TYPES } from './types'; +import { + CREATE_BOARD_SERVICE, + DELETE_BOARD_SERVICE, + GET_BOARD_SERVICE, + PAUSE_BOARD_TIMER_SERVICE, + SEND_BOARD_TIMER_STATE_SERVICE, + SEND_BOARD_TIMER_TIME_LEFT_SERVICE, + START_BOARD_TIMER_SERVICE, + STOP_BOARD_TIMER_SERVICE, + TYPES, + UPDATE_BOARD_SERVICE, + UPDATE_BOARD_TIMER_DURATION_SERVICE +} from './constants'; import { BoardRepository } from './repositories/board.repository'; import CreateBoardService from './services/create.board.service'; import DeleteBoardService from './services/delete.board.service'; @@ -30,22 +42,22 @@ import { MergeBoardUseCase } from './applications/merge-board.use-case'; import { UpdateBoardPhaseUseCase } from './applications/update-board-phase.use-case'; export const createBoardService = { - provide: TYPES.services.CreateBoardService, + provide: CREATE_BOARD_SERVICE, useClass: CreateBoardService }; export const getBoardService = { - provide: TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useClass: GetBoardService }; export const updateBoardService = { - provide: TYPES.services.UpdateBoardService, + provide: UPDATE_BOARD_SERVICE, useClass: UpdateBoardService }; export const deleteBoardService = { - provide: TYPES.services.DeleteBoardService, + provide: DELETE_BOARD_SERVICE, useClass: DeleteBoardService }; @@ -110,32 +122,32 @@ export const boardTimerRepository = { }; export const sendBoardTimerStateService = { - provide: TYPES.services.SendBoardTimerStateService, + provide: SEND_BOARD_TIMER_STATE_SERVICE, useClass: SendBoardTimerStateService }; export const startBoardTimerService = { - provide: TYPES.services.StartBoardTimerService, + provide: START_BOARD_TIMER_SERVICE, useClass: StartBoardTimerService }; export const pauseBoardTimerService = { - provide: TYPES.services.PauseBoardTimerService, + provide: PAUSE_BOARD_TIMER_SERVICE, useClass: PauseBoardTimerService }; export const stopBoardTimerService = { - provide: TYPES.services.StopBoardTimerService, + provide: STOP_BOARD_TIMER_SERVICE, useClass: StopBoardTimerService }; export const updateBoardTimerDurationService = { - provide: TYPES.services.UpdateBoardTimerDurationService, + provide: UPDATE_BOARD_TIMER_DURATION_SERVICE, useClass: UpdateBoardTimerDurationService }; export const sendBoardTimerTimeLeftService = { - provide: TYPES.services.SendBardTimerTimeLeftService, + provide: SEND_BOARD_TIMER_TIME_LEFT_SERVICE, useClass: SendBoardTimerTimeLeftService }; diff --git a/backend/src/modules/boards/types.ts b/backend/src/modules/boards/constants.ts similarity index 62% rename from backend/src/modules/boards/types.ts rename to backend/src/modules/boards/constants.ts index 44ff2d4e3..34699141f 100644 --- a/backend/src/modules/boards/types.ts +++ b/backend/src/modules/boards/constants.ts @@ -1,16 +1,4 @@ export const TYPES = { - services: { - CreateBoardService: 'CreateBoardService', - DeleteBoardService: 'DeleteBoardService', - UpdateBoardService: 'UpdateBoardService', - GetBoardService: 'GetBoardService', - SendBoardTimerStateService: 'SendBoardTimerStateService', - StartBoardTimerService: 'StartBoardTimerService', - PauseBoardTimerService: 'PauseBoardTimerService', - StopBoardTimerService: 'StopBoardTimerService', - SendBardTimerTimeLeftService: 'SendBardTimerTimeLeftService', - UpdateBoardTimerDurationService: 'UpdateBoardTimerDurationService' - }, applications: { DuplicateBoardUseCase: 'DuplicateBoardUseCase', GetBoardsForDashboardUseCase: 'GetBoardsForDashboardUseCase', @@ -37,3 +25,23 @@ export const TYPES = { AfterUserRequestedTimerStateSubscriber: 'AfterUserRequestedTimerStateSubscriber' } }; + +export const CREATE_BOARD_SERVICE = 'CreateBoardService'; + +export const DELETE_BOARD_SERVICE = 'DeleteBoardService'; + +export const UPDATE_BOARD_SERVICE = 'UpdateBoardService'; + +export const GET_BOARD_SERVICE = 'GetBoardService'; + +export const SEND_BOARD_TIMER_STATE_SERVICE = 'SendBoardTimerStateService'; + +export const START_BOARD_TIMER_SERVICE = 'StartBoardTimerService'; + +export const PAUSE_BOARD_TIMER_SERVICE = 'PauseBoardTimerService'; + +export const STOP_BOARD_TIMER_SERVICE = 'StopBoardTimerService'; + +export const SEND_BOARD_TIMER_TIME_LEFT_SERVICE = 'SendBoardTimerTimeLeftService'; + +export const UPDATE_BOARD_TIMER_DURATION_SERVICE = 'UpdateBoardTimerDurationService'; diff --git a/backend/src/modules/boards/controller/boards.controller.ts b/backend/src/modules/boards/controller/boards.controller.ts index 545a32340..677cf07d8 100644 --- a/backend/src/modules/boards/controller/boards.controller.ts +++ b/backend/src/modules/boards/controller/boards.controller.ts @@ -61,7 +61,7 @@ import GetBoardUseCaseDto from '../dto/useCase/get-board.use-case.dto'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import BoardUseCasePresenter from '../presenter/board.use-case.presenter'; import DeleteBoardUseCaseDto from 'src/modules/boards/dto/useCase/delete-board.use-case'; import BoardsPaginatedPresenter from 'src/modules/boards/presenter/boards-paginated.presenter'; diff --git a/backend/src/modules/boards/controller/publicBoards.controller.ts b/backend/src/modules/boards/controller/publicBoards.controller.ts index 997b7e2f2..08c5fd7b2 100644 --- a/backend/src/modules/boards/controller/publicBoards.controller.ts +++ b/backend/src/modules/boards/controller/publicBoards.controller.ts @@ -11,7 +11,7 @@ import { ApiParam, ApiTags } from '@nestjs/swagger'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @ApiTags('PublicBoards') diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 52356a67e..01902e913 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index a8c5e6947..ec009cd1e 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -14,7 +14,7 @@ import * as CommunicationsType from 'src/modules/communication/interfaces/types' import { AddCronJobDto } from 'src/modules/schedules/dto/add.cronjob.dto'; import { CreateSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/create.schedules.service.interface'; import * as SchedulesType from 'src/modules/schedules/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; diff --git a/backend/src/modules/boards/services/delete.board.service.spec.ts b/backend/src/modules/boards/services/delete.board.service.spec.ts index 0a3dcc58f..27f3a2df8 100644 --- a/backend/src/modules/boards/services/delete.board.service.spec.ts +++ b/backend/src/modules/boards/services/delete.board.service.spec.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; diff --git a/backend/src/modules/boards/services/delete.board.service.ts b/backend/src/modules/boards/services/delete.board.service.ts index cfcfc985c..d6c8ef30e 100644 --- a/backend/src/modules/boards/services/delete.board.service.ts +++ b/backend/src/modules/boards/services/delete.board.service.ts @@ -5,7 +5,7 @@ import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interface import * as Schedules from 'src/modules/schedules/interfaces/types'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import Board from '../entities/board.schema'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index 595e8b738..e7649b141 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -8,7 +8,7 @@ import { updateUserService } from 'src/modules/users/users.providers'; import { boardRepository } from '../boards.providers'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; diff --git a/backend/src/modules/boards/services/get.board.service.ts b/backend/src/modules/boards/services/get.board.service.ts index 2d1dfbe19..395086c92 100644 --- a/backend/src/modules/boards/services/get.board.service.ts +++ b/backend/src/modules/boards/services/get.board.service.ts @@ -6,7 +6,7 @@ import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { QueryType } from '../interfaces/findQuery'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { cleanBoard } from '../utils/clean-board'; -import { TYPES } from '../types'; +import { TYPES } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import UserDto from 'src/modules/users/dto/user.dto'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; diff --git a/backend/src/modules/boards/services/pause-board-timer.service.ts b/backend/src/modules/boards/services/pause-board-timer.service.ts index 9c232bf3c..143bd00aa 100644 --- a/backend/src/modules/boards/services/pause-board-timer.service.ts +++ b/backend/src/modules/boards/services/pause-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_PAUSED } from 'src/libs/constants/timer'; import BoardTimerTimeLeftDto from 'src/libs/dto/board-timer-time-left.dto'; import ServerPausedTimerEvent from 'src/modules/boards/events/server-paused-timer.event'; import PauseBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/pause-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { TYPES } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/send-board-timer-state.service.ts b/backend/src/modules/boards/services/send-board-timer-state.service.ts index d119e32c6..3b2148514 100644 --- a/backend/src/modules/boards/services/send-board-timer-state.service.ts +++ b/backend/src/modules/boards/services/send-board-timer-state.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_SENT_TIMER_STATE } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerSentTimerStateEvent from 'src/modules/boards/events/server-sent-timer-state.event'; import SendBoardTimerStateServiceInterface from 'src/modules/boards/interfaces/services/send-board-timer-state.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { TYPES } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/start-board-timer.service.ts b/backend/src/modules/boards/services/start-board-timer.service.ts index f2d7b2dff..6727ae5dc 100644 --- a/backend/src/modules/boards/services/start-board-timer.service.ts +++ b/backend/src/modules/boards/services/start-board-timer.service.ts @@ -11,7 +11,11 @@ import ServerStartedTimerEvent from 'src/modules/boards/events/server-started-ti import SendBoardTimerTimeLeftServiceInterface from 'src/modules/boards/interfaces/services/send-board-time-left.service.interface'; import StartBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/start-board-timer.service.interface'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { + SEND_BOARD_TIMER_TIME_LEFT_SERVICE, + STOP_BOARD_TIMER_SERVICE, + TYPES +} from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() @@ -22,10 +26,10 @@ export default class StartBoardTimerService implements StartBoardTimerServiceInt @Inject(TYPES.repositories.BoardTimerRepository) private boardTimerRepository: BoardTimerRepositoryInterface, - @Inject(TYPES.services.StopBoardTimerService) + @Inject(STOP_BOARD_TIMER_SERVICE) private stopBoardTimerService: StopBoardTimerServiceInterface, - @Inject(TYPES.services.SendBardTimerTimeLeftService) + @Inject(SEND_BOARD_TIMER_TIME_LEFT_SERVICE) private updateBoardTimerService: SendBoardTimerTimeLeftServiceInterface, private eventEmitter: EventEmitter2 diff --git a/backend/src/modules/boards/services/stop-board-timer.service.ts b/backend/src/modules/boards/services/stop-board-timer.service.ts index d723935d1..486f5aa5e 100644 --- a/backend/src/modules/boards/services/stop-board-timer.service.ts +++ b/backend/src/modules/boards/services/stop-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_STOPPED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerStoppedTimerEvent from 'src/modules/boards/events/server-stopped-timer.event'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { TYPES } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/update-board-timer-duration.service.ts b/backend/src/modules/boards/services/update-board-timer-duration.service.ts index 7d26cb0a8..b40d9c3f9 100644 --- a/backend/src/modules/boards/services/update-board-timer-duration.service.ts +++ b/backend/src/modules/boards/services/update-board-timer-duration.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_DURATION_UPDATED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import ServerUpdatedTimerDurationEvent from 'src/modules/boards/events/server-updated-timer-duration.event'; import UpdateBoardTimerDurationServiceInterface from 'src/modules/boards/interfaces/services/update-board-timer-duration.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { TYPES } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from '../repositories/board-timer.repository.interface'; @Injectable() diff --git a/backend/src/modules/boards/services/update.board.service.spec.ts b/backend/src/modules/boards/services/update.board.service.spec.ts index 5150c636b..f1f700722 100644 --- a/backend/src/modules/boards/services/update.board.service.spec.ts +++ b/backend/src/modules/boards/services/update.board.service.spec.ts @@ -4,7 +4,7 @@ import { UpdateBoardServiceInterface } from '../interfaces/services/update.board import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { TeamCommunicationDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamDto-factory'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import UpdateBoardService from './update.board.service'; import Board from '../entities/board.schema'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; diff --git a/backend/src/modules/boards/services/update.board.service.ts b/backend/src/modules/boards/services/update.board.service.ts index 6dfd803de..872dfe9bd 100644 --- a/backend/src/modules/boards/services/update.board.service.ts +++ b/backend/src/modules/boards/services/update.board.service.ts @@ -1,6 +1,6 @@ import { Inject, Injectable } from '@nestjs/common'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; -import * as Boards from 'src/modules/boards/types'; +import * as Boards from 'src/modules/boards/constants'; import { UpdateBoardServiceInterface } from '../interfaces/services/update.board.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; diff --git a/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts index ff4a22ee7..04627cf4b 100644 --- a/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts @@ -3,14 +3,14 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_PAUSED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import PauseBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/pause-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { PAUSE_BOARD_TIMER_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class AfterUserPausedTimerSubscriber { private logger: Logger = new Logger(AfterUserPausedTimerSubscriber.name); constructor( - @Inject(TYPES.services.PauseBoardTimerService) + @Inject(PAUSE_BOARD_TIMER_SERVICE) private readonly pauseBoardTimerService: PauseBoardTimerServiceInterface ) {} diff --git a/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts index 27a7df47a..ca8b0e1b3 100644 --- a/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-requested-timer-state.subscriber.ts @@ -3,14 +3,14 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_REQUESTED_TIMER_STATE } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import SendBoardTimerStateServiceInterface from 'src/modules/boards/interfaces/services/send-board-timer-state.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { SEND_BOARD_TIMER_STATE_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class AfterUserRequestedTimerStateSubscriber { private logger: Logger = new Logger(AfterUserRequestedTimerStateSubscriber.name); constructor( - @Inject(TYPES.services.SendBoardTimerStateService) + @Inject(SEND_BOARD_TIMER_STATE_SERVICE) private readonly getBoardTimerStateService: SendBoardTimerStateServiceInterface ) {} diff --git a/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts index ed87b9a69..5be7d01a7 100644 --- a/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-started-timer.subscriber.ts @@ -3,14 +3,14 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_STARTED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import StartBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/start-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { START_BOARD_TIMER_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class AfterUserStartedTimerSubscriber { private logger: Logger = new Logger(AfterUserStartedTimerSubscriber.name); constructor( - @Inject(TYPES.services.StartBoardTimerService) + @Inject(START_BOARD_TIMER_SERVICE) private readonly startBoardTimerService: StartBoardTimerServiceInterface ) {} diff --git a/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts index da210fd51..a10e3b3f7 100644 --- a/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-stopped-timer.subscriber.ts @@ -3,14 +3,14 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_STOPPED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { STOP_BOARD_TIMER_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class AfterUserStoppedTimerSubscriber { private logger: Logger = new Logger(AfterUserStoppedTimerSubscriber.name); constructor( - @Inject(TYPES.services.StopBoardTimerService) + @Inject(STOP_BOARD_TIMER_SERVICE) private readonly stopBoardTimerService: StopBoardTimerServiceInterface ) {} diff --git a/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts index 3d545be37..a20948b76 100644 --- a/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts +++ b/backend/src/modules/boards/subscribers/after-user-updated-duration.subscriber.ts @@ -3,14 +3,14 @@ import { OnEvent } from '@nestjs/event-emitter'; import { BOARD_TIMER_USER_DURATION_UPDATED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import UpdateBoardTimerDurationServiceInterface from 'src/modules/boards/interfaces/services/update-board-timer-duration.service.interface'; -import { TYPES } from 'src/modules/boards/types'; +import { UPDATE_BOARD_TIMER_DURATION_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class AfterUserUpdatedDurationSubscriber { private logger: Logger = new Logger(AfterUserUpdatedDurationSubscriber.name); constructor( - @Inject(TYPES.services.UpdateBoardTimerDurationService) + @Inject(UPDATE_BOARD_TIMER_DURATION_SERVICE) private readonly updateBoardTimerDurationService: UpdateBoardTimerDurationServiceInterface ) {} diff --git a/backend/src/modules/columns/services/update.column.service.spec.ts b/backend/src/modules/columns/services/update.column.service.spec.ts index a7d01923a..726285a9a 100644 --- a/backend/src/modules/columns/services/update.column.service.spec.ts +++ b/backend/src/modules/columns/services/update.column.service.spec.ts @@ -8,13 +8,13 @@ import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory. import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { updateColumnService } from '../columns.providers'; import * as Columns from '../interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import { ColumnRepository } from '../repositories/column.repository'; import GetBoardService from 'src/modules/boards/services/get.board.service'; import UpdateColumnService from './update.column.service'; import DeleteVoteService from 'src/modules/votes/services/delete.vote.service'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const fakeBoards = BoardFactory.createMany(2); @@ -43,17 +43,17 @@ describe('UpdateColumnService', () => { useValue: createMock() }, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); - columnService = module.get(Columns.TYPES.services.UpdateColumnService); - deleteVoteService = module.get(Votes.TYPES.services.DeleteVoteService); - repositoryColumn = module.get(Columns.TYPES.repositories.ColumnRepository); - socketService = module.get(SocketGateway); - getBoardServiceImpl = module.get(Boards.TYPES.services.GetBoardService); + columnService = module.get(Columns.TYPES.services.UpdateColumnService); + deleteVoteService = module.get(Votes.TYPES.services.DeleteVoteService); + repositoryColumn = module.get(Columns.TYPES.repositories.ColumnRepository); + socketService = module.get(SocketGateway); + getBoardServiceImpl = module.get(GET_BOARD_SERVICE); jest.spyOn(Logger.prototype, 'error').mockImplementation(jest.fn); }); diff --git a/backend/src/modules/columns/services/update.column.service.ts b/backend/src/modules/columns/services/update.column.service.ts index 7faffbbda..f290cd46d 100644 --- a/backend/src/modules/columns/services/update.column.service.ts +++ b/backend/src/modules/columns/services/update.column.service.ts @@ -1,6 +1,5 @@ import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; import { COLUMN_NOT_FOUND, UPDATE_FAILED } from 'src/libs/exceptions/messages'; -import * as Boards from 'src/modules/boards/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import * as Columns from '../interfaces/types'; import { UpdateColumnServiceInterface } from '../interfaces/services/update.column.service.interface'; @@ -10,6 +9,7 @@ import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { ColumnRepositoryInterface } from '../repositories/column.repository.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class UpdateColumnService implements UpdateColumnServiceInterface { @@ -17,7 +17,7 @@ export default class UpdateColumnService implements UpdateColumnServiceInterface @Inject(Columns.TYPES.repositories.ColumnRepository) private readonly columnRepository: ColumnRepositoryInterface, private readonly socketService: SocketGateway, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, @Inject(Votes.TYPES.services.DeleteVoteService) private readonly deleteVoteService: DeleteVoteServiceInterface diff --git a/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts b/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts index b6fe07c24..a8e45f5fe 100644 --- a/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts +++ b/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts @@ -1,7 +1,6 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from 'src/modules/communication/interfaces/types'; -import { TYPES as BOARD_TYPES } from 'src/modules/boards/types'; import { BoardType } from '../dto/types'; import { Job } from 'bull'; import { SlackCommunicationConsumer } from './slack-communication.consumer'; @@ -10,6 +9,7 @@ import { UpdateBoardServiceInterface } from 'src/modules/boards/interfaces/servi import { Logger } from '@nestjs/common'; import { UserFactory } from 'src/libs/test-utils/mocks/factories/user-factory'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; +import { UPDATE_BOARD_SERVICE } from 'src/modules/boards/constants'; const BoardTypeMock = { id: 1, @@ -52,14 +52,14 @@ describe('SlackCommunicationConsumer', () => { useValue: createMock() }, { - provide: BOARD_TYPES.services.UpdateBoardService, + provide: UPDATE_BOARD_SERVICE, useValue: createMock() } ] }).compile(); - consumer = module.get(SlackCommunicationConsumer); + consumer = module.get(SlackCommunicationConsumer); communicationAppMock = module.get(TYPES.application.SlackCommunicationApplication); - updateBoardServiceMock = module.get(BOARD_TYPES.services.UpdateBoardService); + updateBoardServiceMock = module.get(UPDATE_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/communication/consumers/slack-communication.consumer.ts b/backend/src/modules/communication/consumers/slack-communication.consumer.ts index 09f6b8587..dcba36692 100644 --- a/backend/src/modules/communication/consumers/slack-communication.consumer.ts +++ b/backend/src/modules/communication/consumers/slack-communication.consumer.ts @@ -2,13 +2,13 @@ import { OnQueueCompleted, Process, Processor } from '@nestjs/bull'; import { Inject, Logger } from '@nestjs/common'; import { Job } from 'bull'; import { UpdateBoardServiceInterface } from 'src/modules/boards/interfaces/services/update.board.service.interface'; -import { TYPES as BOARD_TYPES } from 'src/modules/boards/types'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; import { BoardType } from 'src/modules/communication/dto/types'; import { CommunicationApplicationInterface } from 'src/modules/communication/interfaces/communication.application.interface'; import { TYPES } from 'src/modules/communication/interfaces/types'; import { SlackCommunicationProducer } from 'src/modules/communication/producers/slack-communication.producer'; import { SlackCommunicationEventListeners } from './slack-communication-event-listeners'; +import { UPDATE_BOARD_SERVICE } from 'src/modules/boards/constants'; @Processor(SlackCommunicationProducer.QUEUE_NAME) export class SlackCommunicationConsumer extends SlackCommunicationEventListeners< @@ -18,7 +18,7 @@ export class SlackCommunicationConsumer extends SlackCommunicationEventListeners constructor( @Inject(TYPES.application.SlackCommunicationApplication) private readonly application: CommunicationApplicationInterface, - @Inject(BOARD_TYPES.services.UpdateBoardService) + @Inject(UPDATE_BOARD_SERVICE) private updateBoardService: UpdateBoardServiceInterface ) { const logger = new Logger(SlackCommunicationConsumer.name); diff --git a/backend/src/modules/schedules/services/create.schedules.service.ts b/backend/src/modules/schedules/services/create.schedules.service.ts index 46d01f38e..b4a3229fd 100644 --- a/backend/src/modules/schedules/services/create.schedules.service.ts +++ b/backend/src/modules/schedules/services/create.schedules.service.ts @@ -4,7 +4,6 @@ import { CronJob } from 'cron'; import { getDay, getNextMonth } from 'src/libs/utils/dates'; import { CreateBoardServiceInterface } from 'src/modules/boards/interfaces/services/create.board.service.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; -import * as BoardTypes from 'src/modules/boards/types'; import Board from 'src/modules/boards/entities/board.schema'; import { ArchiveChannelDataOptions } from 'src/modules/communication/dto/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; @@ -20,6 +19,7 @@ import Schedules from '../entities/schedules.schema'; import { Configs } from 'src/modules/boards/dto/configs.dto'; import { ScheduleRepositoryInterface } from '../repository/schedule.repository.interface'; import Team from 'src/modules/teams/entities/team.schema'; +import { CREATE_BOARD_SERVICE, GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export class CreateSchedulesService implements CreateSchedulesServiceInterface { @@ -27,14 +27,14 @@ export class CreateSchedulesService implements CreateSchedulesServiceInterface { constructor( @Inject(forwardRef(() => TYPES.services.DeleteSchedulesService)) - private deleteSchedulesService: DeleteSchedulesServiceInterface, - @Inject(forwardRef(() => BoardTypes.TYPES.services.CreateBoardService)) - private createBoardService: CreateBoardServiceInterface, - @Inject(forwardRef(() => BoardTypes.TYPES.services.GetBoardService)) - private getBoardService: GetBoardServiceInterface, - private schedulerRegistry: SchedulerRegistry, + private readonly deleteSchedulesService: DeleteSchedulesServiceInterface, + @Inject(forwardRef(() => CREATE_BOARD_SERVICE)) + private readonly createBoardService: CreateBoardServiceInterface, + @Inject(forwardRef(() => GET_BOARD_SERVICE)) + private readonly getBoardService: GetBoardServiceInterface, + private readonly schedulerRegistry: SchedulerRegistry, @Inject(CommunicationTypes.TYPES.services.SlackArchiveChannelService) - private archiveChannelService: ArchiveChannelServiceInterface, + private readonly archiveChannelService: ArchiveChannelServiceInterface, @Inject(TYPES.repository.ScheduleRepository) private readonly scheduleRepository: ScheduleRepositoryInterface ) { diff --git a/backend/src/modules/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index 077b20a63..57d4a19bb 100644 --- a/backend/src/modules/teams/services/delete.team.service.spec.ts +++ b/backend/src/modules/teams/services/delete.team.service.spec.ts @@ -6,7 +6,6 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; @@ -15,6 +14,7 @@ import { TeamRepositoryInterface } from '../interfaces/repositories/team.reposit import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; import DeleteTeamService from 'src/modules/teams/services/delete.team.service'; import { DELETE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { DELETE_BOARD_SERVICE } from 'src/modules/boards/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -47,7 +47,7 @@ describe('DeleteTeamService', () => { useValue: createMock() }, { - provide: Boards.TYPES.services.DeleteBoardService, + provide: DELETE_BOARD_SERVICE, useValue: createMock() }, { @@ -60,7 +60,7 @@ describe('DeleteTeamService', () => { teamService = module.get(DeleteTeamService); teamRepositoryMock = module.get(TEAM_REPOSITORY); deleteTeamUserServiceMock = module.get(DELETE_TEAM_USER_SERVICE); - deleteBoardServiceMock = module.get(Boards.TYPES.services.DeleteBoardService); + deleteBoardServiceMock = module.get(DELETE_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/teams/services/delete.team.service.ts b/backend/src/modules/teams/services/delete.team.service.ts index 3b1e3e28e..6550f0f17 100644 --- a/backend/src/modules/teams/services/delete.team.service.ts +++ b/backend/src/modules/teams/services/delete.team.service.ts @@ -3,17 +3,17 @@ import { DELETE_FAILED } from 'src/libs/exceptions/messages'; import { DeleteTeamServiceInterface } from '../interfaces/services/delete.team.service.interface'; import { TEAM_REPOSITORY } from '../constants'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; -import * as Boards from '../../boards/types'; import { DeleteBoardServiceInterface } from 'src/modules/boards/interfaces/services/delete.board.service.interface'; import { DeleteTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/delete.team.user.service.interface'; import { DELETE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { DELETE_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class DeleteTeamService implements DeleteTeamServiceInterface { constructor( @Inject(TEAM_REPOSITORY) private readonly teamRepository: TeamRepositoryInterface, - @Inject(Boards.TYPES.services.DeleteBoardService) + @Inject(DELETE_BOARD_SERVICE) private readonly deleteBoardService: DeleteBoardServiceInterface, @Inject(DELETE_TEAM_USER_SERVICE) private readonly deleteTeamUserService: DeleteTeamUserServiceInterface diff --git a/backend/src/modules/teams/services/get.team.service.spec.ts b/backend/src/modules/teams/services/get.team.service.spec.ts index b85d257a6..a027d6ed1 100644 --- a/backend/src/modules/teams/services/get.team.service.spec.ts +++ b/backend/src/modules/teams/services/get.team.service.spec.ts @@ -12,12 +12,12 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import Team from 'src/modules/teams/entities/team.schema'; import { Test, TestingModule } from '@nestjs/testing'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/types'; import { TeamUserFactory } from 'src/libs/test-utils/mocks/factories/teamUser-factory.mock'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { TEAM_REPOSITORY } from 'src/modules/teams/constants'; import GetTeamService from 'src/modules/teams/services/get.team.service'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const teams: Team[] = TeamFactory.createMany(4); const teamUsers: TeamUser[] = TeamUserFactory.createMany(5); @@ -66,16 +66,16 @@ describe('GetTeamService', () => { useValue: createMock() }, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); - teamService = module.get(GetTeamService); + teamService = module.get(GetTeamService); teamRepositoryMock = module.get(TEAM_REPOSITORY); getTeamUserServiceMock = module.get(GET_TEAM_USER_SERVICE); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/teams/services/get.team.service.ts b/backend/src/modules/teams/services/get.team.service.ts index 89d80ffdd..301466ae0 100644 --- a/backend/src/modules/teams/services/get.team.service.ts +++ b/backend/src/modules/teams/services/get.team.service.ts @@ -4,11 +4,11 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { GetTeamServiceInterface } from '../interfaces/services/get.team.service.interface'; import Team from '../entities/team.schema'; import { TEAM_REPOSITORY } from '../constants'; -import * as Boards from 'src/modules/boards/types'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GetTeamUserServiceInterface } from 'src/modules/teamUsers/interfaces/services/get.team.user.service.interface'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class GetTeamService implements GetTeamServiceInterface { @@ -17,7 +17,7 @@ export default class GetTeamService implements GetTeamServiceInterface { private readonly teamRepository: TeamRepositoryInterface, @Inject(GET_TEAM_USER_SERVICE) private readonly getTeamUserService: GetTeamUserServiceInterface, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/votes/services/create.vote.service.spec.ts b/backend/src/modules/votes/services/create.vote.service.spec.ts index 650b57abb..31340fa43 100644 --- a/backend/src/modules/votes/services/create.vote.service.spec.ts +++ b/backend/src/modules/votes/services/create.vote.service.spec.ts @@ -1,7 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import CreateVoteService from './create.vote.service'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; @@ -18,6 +17,7 @@ import BoardUser from 'src/modules/boardUsers/entities/board.user.schema'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const userId: string = faker.datatype.uuid(); const board: Board = BoardFactory.create({ maxVotes: 3 }); @@ -47,7 +47,7 @@ describe('CreateVoteService', () => { useValue: createMock() }, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] @@ -55,7 +55,7 @@ describe('CreateVoteService', () => { voteService = module.get(CreateVoteService); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); }); diff --git a/backend/src/modules/votes/services/create.vote.service.ts b/backend/src/modules/votes/services/create.vote.service.ts index bb50e7f31..b97dcbf55 100644 --- a/backend/src/modules/votes/services/create.vote.service.ts +++ b/backend/src/modules/votes/services/create.vote.service.ts @@ -3,11 +3,11 @@ import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { BOARD_NOT_FOUND, INSERT_VOTE_FAILED } from 'src/libs/exceptions/messages'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { InsertFailedException } from 'src/libs/exceptions/insertFailedBadRequestException'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class CreateVoteService implements CreateVoteServiceInterface { @@ -16,7 +16,7 @@ export default class CreateVoteService implements CreateVoteServiceInterface { private readonly getBoardUserService: GetBoardUserServiceInterface, @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index a23981ebf..46d3501d6 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -2,7 +2,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Cards from 'src/modules/cards/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -23,6 +22,7 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; import { CardItemFactory } from 'src/libs/test-utils/mocks/factories/cardItem-factory.mock'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const userId: string = faker.datatype.uuid(); const board: Board = BoardFactory.create({ maxVotes: 3 }); @@ -60,14 +60,14 @@ describe('DeleteVoteService', () => { useValue: createMock() }, { - provide: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); voteService = module.get(DeleteVoteService); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); getCardServiceMock = module.get(Cards.TYPES.services.GetCardService); updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 829fd21e8..022071240 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -6,7 +6,6 @@ import * as Cards from 'src/modules/cards/interfaces/types'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { TYPES } from '../interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/types'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -19,6 +18,7 @@ import { mergeTwoUsersWithVotes } from 'src/modules/cards/utils/get-user-with-votes'; import { votesArrayVerification } from '../utils/votesArrayVerification'; +import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; @Injectable() export default class DeleteVoteService implements DeleteVoteServiceInterface { @@ -31,7 +31,7 @@ export default class DeleteVoteService implements DeleteVoteServiceInterface { private readonly updateBoardUserService: UpdateBoardUserServiceInterface, @Inject(Cards.TYPES.services.GetCardService) private readonly getCardService: GetCardServiceInterface, - @Inject(Boards.TYPES.services.GetBoardService) + @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface ) {} From 75e061e971198e289e0c283e6cf0cc55f353d118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 12:18:03 +0100 Subject: [PATCH 07/14] refactor: change TYPES to CONSTANTS(useCases) --- ... => get-dashboard-boards.use-case.spec.ts} | 8 +- ...se.ts => get-dashboard-boards.use-case.ts} | 2 +- backend/src/modules/boards/boards.module.ts | 4 +- .../src/modules/boards/boards.providers.ts | 134 ++++++++++-------- backend/src/modules/boards/constants.ts | 56 ++++++-- .../boards/controller/boards.controller.ts | 44 +++--- .../controller/publicBoards.controller.ts | 4 +- 7 files changed, 154 insertions(+), 98 deletions(-) rename backend/src/modules/boards/applications/{get-boards-for-dashboard.use-case.spec.ts => get-dashboard-boards.use-case.spec.ts} (92%) rename backend/src/modules/boards/applications/{get-boards-for-dashboard.use-case.ts => get-dashboard-boards.use-case.ts} (96%) diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts b/backend/src/modules/boards/applications/get-dashboard-boards.use-case.spec.ts similarity index 92% rename from backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts rename to backend/src/modules/boards/applications/get-dashboard-boards.use-case.spec.ts index 9ef02ac58..d6f8910a2 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-dashboard-boards.use-case.spec.ts @@ -7,19 +7,19 @@ import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mo import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { GetBoardsForDashboardUseCase } from './get-boards-for-dashboard.use-case'; +import { GetDashboardBoardsUseCase } from './get-dashboard-boards.use-case'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const userId = faker.datatype.uuid(); -describe('GetBoardsForDashboardUseCase', () => { +describe('GetDashboardBoardsUseCase', () => { let useCase: UseCase; let getBoardServiceMock: DeepMocked; beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - GetBoardsForDashboardUseCase, + GetDashboardBoardsUseCase, { provide: GET_BOARD_SERVICE, useValue: createMock() @@ -27,7 +27,7 @@ describe('GetBoardsForDashboardUseCase', () => { ] }).compile(); - useCase = module.get(GetBoardsForDashboardUseCase); + useCase = module.get(GetDashboardBoardsUseCase); getBoardServiceMock = module.get(GET_BOARD_SERVICE); }); diff --git a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts b/backend/src/modules/boards/applications/get-dashboard-boards.use-case.ts similarity index 96% rename from backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts rename to backend/src/modules/boards/applications/get-dashboard-boards.use-case.ts index 7e1175506..44dc80e67 100644 --- a/backend/src/modules/boards/applications/get-boards-for-dashboard.use-case.ts +++ b/backend/src/modules/boards/applications/get-dashboard-boards.use-case.ts @@ -6,7 +6,7 @@ import { GET_BOARD_SERVICE } from '../constants'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() -export class GetBoardsForDashboardUseCase +export class GetDashboardBoardsUseCase implements UseCase { constructor( diff --git a/backend/src/modules/boards/boards.module.ts b/backend/src/modules/boards/boards.module.ts index c339af572..c9394624f 100644 --- a/backend/src/modules/boards/boards.module.ts +++ b/backend/src/modules/boards/boards.module.ts @@ -27,7 +27,7 @@ import { getAllBoardsUseCase, getBoardService, getBoardUseCase, - getBoardsForDashboardUseCase, + getDashboardBoardsUseCase, getPersonalBoardsUseCase, isBoardPublicUseCase, mergeBoardUseCase, @@ -68,7 +68,7 @@ import { VotesModule } from '../votes/votes.module'; deleteBoardService, getBoardService, duplicateBoardUseCase, - getBoardsForDashboardUseCase, + getDashboardBoardsUseCase, getAllBoardsUseCase, getPersonalBoardsUseCase, getBoardUseCase, diff --git a/backend/src/modules/boards/boards.providers.ts b/backend/src/modules/boards/boards.providers.ts index c700e02f0..353a1fdfa 100644 --- a/backend/src/modules/boards/boards.providers.ts +++ b/backend/src/modules/boards/boards.providers.ts @@ -15,21 +15,33 @@ import { DeleteBoardUseCase } from './applications/delete-board.use-case'; import { DuplicateBoardUseCase } from './applications/duplicate-board.use-case'; import { GetAllBoardsUseCase } from './applications/get-all-boards.use-case'; import { GetBoardUseCase } from './applications/get-board.use-case'; -import { GetBoardsForDashboardUseCase } from './applications/get-boards-for-dashboard.use-case'; +import { GetDashboardBoardsUseCase } from './applications/get-dashboard-boards.use-case'; import { GetPersonalBoardsUseCase } from './applications/get-personal-boards.use-case'; import { IsBoardPublicUseCase } from './applications/is-board-public.use-case'; import { CREATE_BOARD_SERVICE, + CREATE_BOARD_USE_CASE, DELETE_BOARD_SERVICE, + DELETE_BOARD_USE_CASE, + DUPLICATE_BOARD_USE_CASE, + GET_ALL_BOARDS_USE_CASE, GET_BOARD_SERVICE, + GET_BOARD_USE_CASE, + GET_DASHBOARD_BOARDS_USE_CASE, + GET_PERSONAL_BOARDS_USE_CASE, + IS_BOARD_PUBLIC_USE_CASE, + MERGE_BOARD_USE_CASE, PAUSE_BOARD_TIMER_SERVICE, SEND_BOARD_TIMER_STATE_SERVICE, SEND_BOARD_TIMER_TIME_LEFT_SERVICE, START_BOARD_TIMER_SERVICE, STOP_BOARD_TIMER_SERVICE, TYPES, + UPDATE_BOARD_PARTICIPANTS_USE_CASE, + UPDATE_BOARD_PHASE_USE_CASE, UPDATE_BOARD_SERVICE, - UPDATE_BOARD_TIMER_DURATION_SERVICE + UPDATE_BOARD_TIMER_DURATION_SERVICE, + UPDATE_BOARD_USE_CASE } from './constants'; import { BoardRepository } from './repositories/board.repository'; import CreateBoardService from './services/create.board.service'; @@ -41,6 +53,8 @@ import { UpdateBoardParticipantsUseCase } from './applications/update-board-part import { MergeBoardUseCase } from './applications/merge-board.use-case'; import { UpdateBoardPhaseUseCase } from './applications/update-board-phase.use-case'; +/* SERVICES */ + export const createBoardService = { provide: CREATE_BOARD_SERVICE, useClass: CreateBoardService @@ -61,94 +75,101 @@ export const deleteBoardService = { useClass: DeleteBoardService }; -export const duplicateBoardUseCase = { - provide: TYPES.applications.DuplicateBoardUseCase, - useClass: DuplicateBoardUseCase +export const sendBoardTimerStateService = { + provide: SEND_BOARD_TIMER_STATE_SERVICE, + useClass: SendBoardTimerStateService }; -export const getBoardsForDashboardUseCase = { - provide: TYPES.applications.GetBoardsForDashboardUseCase, - useClass: GetBoardsForDashboardUseCase +export const startBoardTimerService = { + provide: START_BOARD_TIMER_SERVICE, + useClass: StartBoardTimerService }; -export const getAllBoardsUseCase = { - provide: TYPES.applications.GetAllBoardsUseCase, - useClass: GetAllBoardsUseCase +export const pauseBoardTimerService = { + provide: PAUSE_BOARD_TIMER_SERVICE, + useClass: PauseBoardTimerService }; -export const getPersonalBoardsUseCase = { - provide: TYPES.applications.GetPersonalBoardsUseCase, - useClass: GetPersonalBoardsUseCase +export const stopBoardTimerService = { + provide: STOP_BOARD_TIMER_SERVICE, + useClass: StopBoardTimerService }; -export const getBoardUseCase = { - provide: TYPES.applications.GetBoardUseCase, - useClass: GetBoardUseCase +export const updateBoardTimerDurationService = { + provide: UPDATE_BOARD_TIMER_DURATION_SERVICE, + useClass: UpdateBoardTimerDurationService }; -export const isBoardPublicUseCase = { - provide: TYPES.applications.IsBoardPublicUseCase, - useClass: IsBoardPublicUseCase +export const sendBoardTimerTimeLeftService = { + provide: SEND_BOARD_TIMER_TIME_LEFT_SERVICE, + useClass: SendBoardTimerTimeLeftService }; -export const updateBoardUseCase = { - provide: TYPES.applications.UpdateBoardUseCase, - useClass: UpdateBoardUseCase +/* USE CASES */ + +export const createBoardUseCase = { + provide: CREATE_BOARD_USE_CASE, + useClass: CreateBoardUseCase }; -export const updateBoardParticipantsUseCase = { - provide: TYPES.applications.UpdateBoardParticipantsUseCase, - useClass: UpdateBoardParticipantsUseCase +export const getDashboardBoardsUseCase = { + provide: GET_DASHBOARD_BOARDS_USE_CASE, + useClass: GetDashboardBoardsUseCase }; -export const mergeBoardUseCase = { - provide: TYPES.applications.MergeBoardUseCase, - useClass: MergeBoardUseCase +export const getAllBoardsUseCase = { + provide: GET_ALL_BOARDS_USE_CASE, + useClass: GetAllBoardsUseCase }; -export const updateBoardPhaseUseCase = { - provide: TYPES.applications.UpdateBoardPhaseUseCase, - useClass: UpdateBoardPhaseUseCase +export const getPersonalBoardsUseCase = { + provide: GET_PERSONAL_BOARDS_USE_CASE, + useClass: GetPersonalBoardsUseCase +}; + +export const updateBoardUseCase = { + provide: UPDATE_BOARD_USE_CASE, + useClass: UpdateBoardUseCase }; export const deleteBoardUseCase = { - provide: TYPES.applications.DeleteBoardUseCase, + provide: DELETE_BOARD_USE_CASE, useClass: DeleteBoardUseCase }; -export const boardTimerRepository = { - provide: TYPES.repositories.BoardTimerRepository, - useClass: BoardTimerRepository +export const getBoardUseCase = { + provide: GET_BOARD_USE_CASE, + useClass: GetBoardUseCase }; -export const sendBoardTimerStateService = { - provide: SEND_BOARD_TIMER_STATE_SERVICE, - useClass: SendBoardTimerStateService +export const duplicateBoardUseCase = { + provide: DUPLICATE_BOARD_USE_CASE, + useClass: DuplicateBoardUseCase }; -export const startBoardTimerService = { - provide: START_BOARD_TIMER_SERVICE, - useClass: StartBoardTimerService +export const isBoardPublicUseCase = { + provide: IS_BOARD_PUBLIC_USE_CASE, + useClass: IsBoardPublicUseCase }; -export const pauseBoardTimerService = { - provide: PAUSE_BOARD_TIMER_SERVICE, - useClass: PauseBoardTimerService +export const updateBoardParticipantsUseCase = { + provide: UPDATE_BOARD_PARTICIPANTS_USE_CASE, + useClass: UpdateBoardParticipantsUseCase }; -export const stopBoardTimerService = { - provide: STOP_BOARD_TIMER_SERVICE, - useClass: StopBoardTimerService +export const mergeBoardUseCase = { + provide: MERGE_BOARD_USE_CASE, + useClass: MergeBoardUseCase }; -export const updateBoardTimerDurationService = { - provide: UPDATE_BOARD_TIMER_DURATION_SERVICE, - useClass: UpdateBoardTimerDurationService +export const updateBoardPhaseUseCase = { + provide: UPDATE_BOARD_PHASE_USE_CASE, + useClass: UpdateBoardPhaseUseCase }; -export const sendBoardTimerTimeLeftService = { - provide: SEND_BOARD_TIMER_TIME_LEFT_SERVICE, - useClass: SendBoardTimerTimeLeftService +export const boardTimerRepository = { + provide: TYPES.repositories.BoardTimerRepository, + useClass: BoardTimerRepository }; export const afterUserUpdatedDurationSubscriber = { @@ -180,8 +201,3 @@ export const boardRepository = { provide: TYPES.repositories.BoardRepository, useClass: BoardRepository }; - -export const createBoardUseCase = { - provide: TYPES.applications.CreateBoardUseCase, - useClass: CreateBoardUseCase -}; diff --git a/backend/src/modules/boards/constants.ts b/backend/src/modules/boards/constants.ts index 34699141f..078ec0b4b 100644 --- a/backend/src/modules/boards/constants.ts +++ b/backend/src/modules/boards/constants.ts @@ -1,17 +1,17 @@ export const TYPES = { applications: { - DuplicateBoardUseCase: 'DuplicateBoardUseCase', - GetBoardsForDashboardUseCase: 'GetBoardsForDashboardUseCase', - GetAllBoardsUseCase: 'GetAllBoardUseCase', - GetPersonalBoardsUseCase: 'GetPersonalBoardsUseCase', - GetBoardUseCase: 'GetBoardUseCase', - CreateBoardUseCase: 'CreateBoardUseCase', - IsBoardPublicUseCase: 'IsBoardPublicUseCase', - DeleteBoardUseCase: 'DeleteBoardUseCase', - UpdateBoardUseCase: 'UpdateBoardUseCase', - UpdateBoardParticipantsUseCase: 'UpdateBoardParticipantsUseCase', - MergeBoardUseCase: 'MergeBoardUseCase', - UpdateBoardPhaseUseCase: 'UpdateBoardPhaseUseCase' + //DuplicateBoardUseCase: 'DuplicateBoardUseCase', + //GetBoardsForDashboardUseCase: 'GetBoardsForDashboardUseCase', + //GetAllBoardsUseCase: 'GetAllBoardUseCase', + //GetPersonalBoardsUseCase: 'GetPersonalBoardsUseCase', + //GetBoardUseCase: 'GetBoardUseCase', + //CreateBoardUseCase: 'CreateBoardUseCase', + //IsBoardPublicUseCase: 'IsBoardPublicUseCase', + //DeleteBoardUseCase: 'DeleteBoardUseCase', + //UpdateBoardUseCase: 'UpdateBoardUseCase', + //UpdateBoardParticipantsUseCase: 'UpdateBoardParticipantsUseCase', + //MergeBoardUseCase: 'MergeBoardUseCase', + //UpdateBoardPhaseUseCase: 'UpdateBoardPhaseUseCase' }, repositories: { BoardTimerRepository: 'BoardTimerRepository', @@ -26,13 +26,15 @@ export const TYPES = { } }; +/* SERVICES */ + export const CREATE_BOARD_SERVICE = 'CreateBoardService'; -export const DELETE_BOARD_SERVICE = 'DeleteBoardService'; +export const GET_BOARD_SERVICE = 'GetBoardService'; export const UPDATE_BOARD_SERVICE = 'UpdateBoardService'; -export const GET_BOARD_SERVICE = 'GetBoardService'; +export const DELETE_BOARD_SERVICE = 'DeleteBoardService'; export const SEND_BOARD_TIMER_STATE_SERVICE = 'SendBoardTimerStateService'; @@ -45,3 +47,29 @@ export const STOP_BOARD_TIMER_SERVICE = 'StopBoardTimerService'; export const SEND_BOARD_TIMER_TIME_LEFT_SERVICE = 'SendBoardTimerTimeLeftService'; export const UPDATE_BOARD_TIMER_DURATION_SERVICE = 'UpdateBoardTimerDurationService'; + +/* USE CASES */ + +export const CREATE_BOARD_USE_CASE = 'CreateBoardUseCase'; + +export const GET_DASHBOARD_BOARDS_USE_CASE = 'GetDashboardBoardsUseCase'; + +export const GET_ALL_BOARDS_USE_CASE = 'GetAllBoardUseCase'; + +export const GET_PERSONAL_BOARDS_USE_CASE = 'GetPersonalBoardsUseCase'; + +export const GET_BOARD_USE_CASE = 'GetBoardUseCase'; + +export const UPDATE_BOARD_USE_CASE = 'UpdateBoardUseCase'; + +export const DELETE_BOARD_USE_CASE = 'DeleteBoardUseCase'; + +export const IS_BOARD_PUBLIC_USE_CASE = 'IsBoardPublicUseCase'; + +export const DUPLICATE_BOARD_USE_CASE = 'DuplicateBoardUseCase'; + +export const UPDATE_BOARD_PARTICIPANTS_USE_CASE = 'UpdateBoardParticipantsUseCase'; + +export const MERGE_BOARD_USE_CASE = 'MergeBoardUseCase'; + +export const UPDATE_BOARD_PHASE_USE_CASE = 'UpdateBoardPhaseUseCase'; diff --git a/backend/src/modules/boards/controller/boards.controller.ts b/backend/src/modules/boards/controller/boards.controller.ts index 677cf07d8..67ce2b81d 100644 --- a/backend/src/modules/boards/controller/boards.controller.ts +++ b/backend/src/modules/boards/controller/boards.controller.ts @@ -61,7 +61,19 @@ import GetBoardUseCaseDto from '../dto/useCase/get-board.use-case.dto'; import GetBoardsUseCaseDto from '../dto/useCase/get-boards.use-case.dto'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../constants'; +import { + CREATE_BOARD_USE_CASE, + DELETE_BOARD_USE_CASE, + DUPLICATE_BOARD_USE_CASE, + GET_ALL_BOARDS_USE_CASE, + GET_BOARD_USE_CASE, + GET_DASHBOARD_BOARDS_USE_CASE, + GET_PERSONAL_BOARDS_USE_CASE, + MERGE_BOARD_USE_CASE, + UPDATE_BOARD_PARTICIPANTS_USE_CASE, + UPDATE_BOARD_PHASE_USE_CASE, + UPDATE_BOARD_USE_CASE +} from '../constants'; import BoardUseCasePresenter from '../presenter/board.use-case.presenter'; import DeleteBoardUseCaseDto from 'src/modules/boards/dto/useCase/delete-board.use-case'; import BoardsPaginatedPresenter from 'src/modules/boards/presenter/boards-paginated.presenter'; @@ -74,38 +86,38 @@ const BoardUser = (permissions: string[]) => SetMetadata('permissions', permissi @Controller('boards') export default class BoardsController { constructor( - @Inject(TYPES.applications.GetBoardsForDashboardUseCase) - private readonly getBoardsForDashboardUseCase: UseCase< + @Inject(GET_DASHBOARD_BOARDS_USE_CASE) + private readonly getDashboardBoardsUseCase: UseCase< GetBoardsUseCaseDto, BoardsPaginatedPresenter >, - @Inject(TYPES.applications.CreateBoardUseCase) + @Inject(CREATE_BOARD_USE_CASE) private readonly createBoardUseCase: UseCase, - @Inject(TYPES.applications.DuplicateBoardUseCase) + @Inject(DUPLICATE_BOARD_USE_CASE) private readonly duplicateBoardUseCase: UseCase, - @Inject(TYPES.applications.GetAllBoardsUseCase) + @Inject(GET_ALL_BOARDS_USE_CASE) private readonly getAllBoardsUseCase: UseCase, - @Inject(TYPES.applications.GetPersonalBoardsUseCase) + @Inject(GET_PERSONAL_BOARDS_USE_CASE) private readonly getPersonalBoardsUseCase: UseCase< GetBoardsUseCaseDto, BoardsPaginatedPresenter >, - @Inject(TYPES.applications.GetBoardUseCase) + @Inject(GET_BOARD_USE_CASE) private readonly getBoardUseCase: UseCase, - @Inject(TYPES.applications.UpdateBoardUseCase) + @Inject(UPDATE_BOARD_USE_CASE) private readonly updateBoardUseCase: UseCase, - @Inject(TYPES.applications.UpdateBoardParticipantsUseCase) + @Inject(UPDATE_BOARD_PARTICIPANTS_USE_CASE) private readonly updateBoardParticipantsUseCase: UseCase< UpdateBoardUserDto, BoardParticipantsPresenter >, - @Inject(TYPES.applications.MergeBoardUseCase) + @Inject(MERGE_BOARD_USE_CASE) private readonly mergeBoardUseCase: UseCase, - @Inject(TYPES.applications.UpdateBoardPhaseUseCase) + @Inject(UPDATE_BOARD_PHASE_USE_CASE) private readonly updateBoardPhaseUseCase: UseCase, - @Inject(TYPES.applications.DeleteBoardUseCase) - private deleteBoardUseCase: UseCase, - private socketService: SocketGateway + @Inject(DELETE_BOARD_USE_CASE) + private readonly deleteBoardUseCase: UseCase, + private readonly socketService: SocketGateway ) {} @ApiOperation({ summary: 'Create a new board' }) @@ -182,7 +194,7 @@ export default class BoardsController { }) @Get('/dashboard') getDashboardBoards(@Req() request: RequestWithUser, @Query() { page, size }: PaginationParams) { - return this.getBoardsForDashboardUseCase.execute({ userId: request.user._id, page, size }); + return this.getDashboardBoardsUseCase.execute({ userId: request.user._id, page, size }); } @ApiOperation({ summary: 'Retrieve all boards from database' }) diff --git a/backend/src/modules/boards/controller/publicBoards.controller.ts b/backend/src/modules/boards/controller/publicBoards.controller.ts index 08c5fd7b2..6748e69a6 100644 --- a/backend/src/modules/boards/controller/publicBoards.controller.ts +++ b/backend/src/modules/boards/controller/publicBoards.controller.ts @@ -11,14 +11,14 @@ import { ApiParam, ApiTags } from '@nestjs/swagger'; -import { TYPES } from '../constants'; +import { IS_BOARD_PUBLIC_USE_CASE } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @ApiTags('PublicBoards') @Controller('publicBoards') export default class PublicBoardsController { constructor( - @Inject(TYPES.applications.IsBoardPublicUseCase) + @Inject(IS_BOARD_PUBLIC_USE_CASE) private isBoardPublicUseCase: UseCase ) {} From f83c0bce494888829148217d5fcd27fe5eca5b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 15:05:37 +0100 Subject: [PATCH 08/14] refactor: change TYPES from CONSTANTS subscribers --- .../delete-board.use-case.spec.ts | 16 +++---- .../applications/delete-board.use-case.ts | 4 +- .../duplicate-board.use-case.spec.ts | 10 ++-- .../applications/duplicate-board.use-case.ts | 4 +- .../applications/get-board.use-case.spec.ts | 6 +-- .../boards/applications/get-board.use-case.ts | 4 +- .../is-board-public.use-case.spec.ts | 6 +-- .../applications/is-board-public.use-case.ts | 4 +- .../applications/merge-board.use-case.spec.ts | 7 ++- .../applications/merge-board.use-case.ts | 4 +- .../update-board-participants.spec.ts | 11 ++--- .../update-board-phase.use-case.spec.ts | 7 ++- .../update-board-phase.use-case.ts | 4 +- .../update-board.use-case.spec.ts | 15 ++---- .../applications/update-board.use-case.ts | 4 +- .../src/modules/boards/boards.providers.ts | 34 +++++++++----- backend/src/modules/boards/constants.ts | 46 ++++++++----------- .../controller/publicBoards.controller.ts | 2 +- .../services/create.board.service.spec.ts | 6 +-- .../boards/services/create.board.service.ts | 4 +- .../services/delete.board.service.spec.ts | 8 ++-- .../boards/services/delete.board.service.ts | 10 ++-- .../boards/services/get.board.service.spec.ts | 27 +++++------ .../boards/services/get.board.service.ts | 8 ++-- .../services/pause-board-timer.service.ts | 8 ++-- .../send-board-timer-state.service.ts | 8 ++-- .../send-board-timer-time-left.service.ts | 2 +- .../services/start-board-timer.service.ts | 14 +++--- .../services/stop-board-timer.service.ts | 8 ++-- .../update-board-timer-duration.service.ts | 8 ++-- .../services/update.board.service.spec.ts | 7 ++- .../boards/services/update.board.service.ts | 4 +- .../repository/schedule.repository.ts | 2 +- 33 files changed, 148 insertions(+), 164 deletions(-) diff --git a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts index 6cb8be2a1..f299484a4 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.spec.ts @@ -1,13 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { deleteBoardUseCase } from '../boards.providers'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { NotFoundException } from '@nestjs/common'; import DeleteBoardUseCaseDto from 'src/modules/boards/dto/useCase/delete-board.use-case'; +import { BOARD_REPOSITORY, DELETE_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { DeleteBoardUseCase } from 'src/modules/boards/applications/delete-board.use-case'; const board = BoardFactory.create({ dividedBoards: BoardFactory.createMany(2), @@ -22,21 +22,21 @@ describe('DeleteBoardUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - deleteBoardUseCase, + DeleteBoardUseCase, { - provide: Boards.DELETE_BOARD_SERVICE, + provide: DELETE_BOARD_SERVICE, useValue: createMock() }, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get(Boards.TYPES.applications.DeleteBoardUseCase); - deleteBoardServiceMock = module.get(Boards.DELETE_BOARD_SERVICE); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + useCase = module.get(DeleteBoardUseCase); + deleteBoardServiceMock = module.get(DELETE_BOARD_SERVICE); + boardRepositoryMock = module.get(BOARD_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/delete-board.use-case.ts b/backend/src/modules/boards/applications/delete-board.use-case.ts index 094c66af6..3ce0d3253 100644 --- a/backend/src/modules/boards/applications/delete-board.use-case.ts +++ b/backend/src/modules/boards/applications/delete-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { DELETE_BOARD_SERVICE, TYPES } from '../constants'; +import { BOARD_REPOSITORY, DELETE_BOARD_SERVICE } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; import { ObjectId } from 'mongoose'; @@ -11,7 +11,7 @@ import DeleteBoardUseCaseDto from 'src/modules/boards/dto/useCase/delete-board.u @Injectable() export class DeleteBoardUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(DELETE_BOARD_SERVICE) private readonly deleteBoardService: DeleteBoardServiceInterface diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts index d49af1801..34349d48a 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; -import * as Boards from 'src/modules/boards/constants'; import * as Users from 'src/modules/users/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @@ -16,6 +15,7 @@ import { UserFactory } from 'src/libs/test-utils/mocks/factories/user-factory'; import { DuplicateBoardDto, DuplicateBoardUseCase } from './duplicate-board.use-case'; import { BoardUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/boardUserDto-factory.mock'; import { CreateFailedException } from 'src/libs/exceptions/createFailedBadRequestException'; +import { BOARD_REPOSITORY, GET_BOARD_SERVICE } from 'src/modules/boards/constants'; const DEFAULT_PROPS = { boardId: faker.datatype.uuid(), @@ -43,11 +43,11 @@ describe('DuplicateBoardUseCase', () => { useValue: createMock() }, { - provide: Boards.GET_BOARD_SERVICE, + provide: GET_BOARD_SERVICE, useValue: createMock() }, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -60,8 +60,8 @@ describe('DuplicateBoardUseCase', () => { duplicateBoardMock = module.get(DuplicateBoardUseCase); getUserServiceMock = module.get(Users.TYPES.services.GetUserService); - getBoardServiceMock = module.get(Boards.GET_BOARD_SERVICE); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + getBoardServiceMock = module.get(GET_BOARD_SERVICE); + boardRepositoryMock = module.get(BOARD_REPOSITORY); createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); }); diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.ts index 66f9bca99..3368a8dd7 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.ts @@ -15,7 +15,7 @@ import { GetUserServiceInterface } from 'src/modules/users/interfaces/services/g import * as Users from 'src/modules/users/interfaces/types'; import Board from '../entities/board.schema'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { GET_BOARD_SERVICE, TYPES } from '../constants'; +import { BOARD_REPOSITORY, GET_BOARD_SERVICE } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: string }; @@ -27,7 +27,7 @@ export class DuplicateBoardUseCase implements UseCase private readonly getBoardService: GetBoardServiceInterface, @Inject(Users.TYPES.services.GetUserService) private readonly getUserService: GetUserServiceInterface, - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.CreateBoardUserService) private readonly createBoardUserService: CreateBoardUserServiceInterface diff --git a/backend/src/modules/boards/applications/get-board.use-case.spec.ts b/backend/src/modules/boards/applications/get-board.use-case.spec.ts index 45a372a3b..96fcb347d 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; @@ -20,6 +19,7 @@ import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser- import { Tokens } from 'src/libs/interfaces/jwt/tokens.interface'; import { hideVotesFromColumns } from '../utils/hideVotesFromColumns'; import { GetBoardUseCase } from './get-board.use-case'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); const subBoard = BoardFactory.create({ isSubBoard: true, isPublic: false }); @@ -37,7 +37,7 @@ describe('GetBoardUseCase', () => { providers: [ GetBoardUseCase, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -60,7 +60,7 @@ describe('GetBoardUseCase', () => { }).compile(); useCase = module.get(GetBoardUseCase); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); getTokenAuthServiceMock = module.get(Auth.TYPES.services.GetTokenAuthService); }); diff --git a/backend/src/modules/boards/applications/get-board.use-case.ts b/backend/src/modules/boards/applications/get-board.use-case.ts index 70fa12779..97ea76ed8 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.ts @@ -1,6 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; @@ -22,7 +22,7 @@ import BoardGuestUserDto from 'src/modules/boardUsers/dto/board.guest.user.dto'; @Injectable() export class GetBoardUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) private readonly getBoardUserService: GetBoardUserServiceInterface, diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts index 16b4c97ea..e2a7d63b9 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.spec.ts @@ -1,11 +1,11 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { NotFoundException } from '@nestjs/common'; import { IsBoardPublicUseCase } from './is-board-public.use-case'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); @@ -18,14 +18,14 @@ describe('IsBoardPublicUseCase', () => { providers: [ IsBoardPublicUseCase, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() } ] }).compile(); useCase = module.get(IsBoardPublicUseCase); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/is-board-public.use-case.ts b/backend/src/modules/boards/applications/is-board-public.use-case.ts index b3a172f0e..008dc784e 100644 --- a/backend/src/modules/boards/applications/is-board-public.use-case.ts +++ b/backend/src/modules/boards/applications/is-board-public.use-case.ts @@ -1,13 +1,13 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { Inject, Injectable, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; @Injectable() export class IsBoardPublicUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface ) {} diff --git a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts index 820a18846..e4b40db12 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import faker from '@faker-js/faker'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; @@ -8,13 +7,13 @@ import * as CommunicationsType from 'src/modules/communication/interfaces/types' import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; -import { boardRepository } from '../boards.providers'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { NotFoundException } from '@nestjs/common'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { generateNewSubColumns } from '../utils/generate-subcolumns'; import { mergeCardsFromSubBoardColumnsIntoMainBoard } from '../utils/merge-cards-from-subboard'; import { MergeBoardUseCase } from './merge-board.use-case'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const userId = faker.datatype.uuid(); const subBoards = BoardFactory.createMany(2, [ @@ -61,7 +60,7 @@ describe('MergeBoardUseCase', () => { providers: [ MergeBoardUseCase, { - provide: boardRepository.provide, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -72,7 +71,7 @@ describe('MergeBoardUseCase', () => { }).compile(); useCase = module.get(MergeBoardUseCase); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); slackCommunicationServiceMock = module.get( CommunicationsType.TYPES.services.SlackCommunicationService ); diff --git a/backend/src/modules/boards/applications/merge-board.use-case.ts b/backend/src/modules/boards/applications/merge-board.use-case.ts index bc1b6c645..9d51f2dce 100644 --- a/backend/src/modules/boards/applications/merge-board.use-case.ts +++ b/backend/src/modules/boards/applications/merge-board.use-case.ts @@ -6,7 +6,7 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import MergeBoardUseCaseDto from '../dto/useCase/merge-board.use-case.dto'; import Board from '../entities/board.schema'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { generateNewSubColumns } from '../utils/generate-subcolumns'; import { mergeCardsFromSubBoardColumnsIntoMainBoard } from '../utils/merge-cards-from-subboard'; @@ -16,7 +16,7 @@ export class MergeBoardUseCase implements UseCase { private logger = new Logger(MergeBoardUseCase.name); constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(CommunicationsType.TYPES.services.SlackCommunicationService) private readonly slackCommunicationService: CommunicationServiceInterface diff --git a/backend/src/modules/boards/applications/update-board-participants.spec.ts b/backend/src/modules/boards/applications/update-board-participants.spec.ts index 7c2b36224..88a3cef63 100644 --- a/backend/src/modules/boards/applications/update-board-participants.spec.ts +++ b/backend/src/modules/boards/applications/update-board-participants.spec.ts @@ -1,11 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; -import { - createBoardUserService, - deleteBoardUserService, - updateBoardUserService -} from 'src/modules/boardUsers/boardusers.providers'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { BoardRoles } from 'src/libs/enum/board.roles'; import { BoardUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/boardUserDto-factory.mock'; @@ -36,15 +31,15 @@ describe('UpdateBoardParticipantsUseCase', () => { providers: [ UpdateBoardParticipantsUseCase, { - provide: createBoardUserService.provide, + provide: BoardUsers.TYPES.services.CreateBoardUserService, useValue: createMock() }, { - provide: deleteBoardUserService.provide, + provide: BoardUsers.TYPES.services.DeleteBoardUserService, useValue: createMock() }, { - provide: updateBoardUserService.provide, + provide: BoardUsers.TYPES.services.UpdateBoardUserService, useValue: createMock() } ] diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts index 39013fb0e..ec2a23ea5 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.spec.ts @@ -10,12 +10,11 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; -import * as Boards from 'src/modules/boards/constants'; import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import { boardRepository } from '../boards.providers'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { UpdateBoardPhaseUseCase } from './update-board-phase.use-case'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; describe('UpdateBoardPhaseUseCase', () => { let useCase: UseCase; @@ -33,7 +32,7 @@ describe('UpdateBoardPhaseUseCase', () => { useValue: createMock() }, { - provide: boardRepository.provide, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -48,7 +47,7 @@ describe('UpdateBoardPhaseUseCase', () => { }).compile(); useCase = module.get(UpdateBoardPhaseUseCase); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); eventEmitterMock = module.get(EventEmitter2); configServiceMock = module.get(ConfigService); slackSendMessageServiceMock = module.get( diff --git a/backend/src/modules/boards/applications/update-board-phase.use-case.ts b/backend/src/modules/boards/applications/update-board-phase.use-case.ts index e93987c0a..485b68a3e 100644 --- a/backend/src/modules/boards/applications/update-board-phase.use-case.ts +++ b/backend/src/modules/boards/applications/update-board-phase.use-case.ts @@ -13,13 +13,13 @@ import { SlackMessageDto } from 'src/modules/communication/dto/slack.message.dto import { SendMessageServiceInterface } from 'src/modules/communication/interfaces/send-message.service.interface'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import PhaseChangeEvent from 'src/modules/socket/events/user-updated-phase.event'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() export class UpdateBoardPhaseUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(CommunicationsType.TYPES.services.SlackSendMessageService) private readonly slackSendMessageService: SendMessageServiceInterface, diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index df55582a2..ccfa77e9f 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,19 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Votes from 'src/modules/votes/interfaces/types'; -import { boardRepository } from '../boards.providers'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UpdateBoardDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/updateBoardDto-factory.mock'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { NotFoundException } from '@nestjs/common'; -import { - getBoardUserService, - updateBoardUserService -} from 'src/modules/boardUsers/boardusers.providers'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; import ColumnDto from 'src/modules/columns/dto/column.dto'; @@ -32,6 +26,7 @@ import Board from '../entities/board.schema'; import { UpdateBoardDto } from '../dto/update-board.dto'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { UpdateBoardUseCase } from './update-board.use-case'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const regularBoard = BoardFactory.create({ isSubBoard: false, dividedBoards: [] }); const userId = faker.datatype.uuid(); @@ -116,22 +111,22 @@ describe('UpdateBoardUseCase', () => { useValue: createMock() }, { - provide: getBoardUserService.provide, + provide: BoardUsers.TYPES.services.GetBoardUserService, useValue: createMock() }, { - provide: updateBoardUserService.provide, + provide: BoardUsers.TYPES.services.UpdateBoardUserService, useValue: createMock() }, { - provide: boardRepository.provide, + provide: BOARD_REPOSITORY, useValue: createMock() } ] }).compile(); useCase = module.get(UpdateBoardUseCase); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); deleteVoteServiceMock = module.get(Votes.TYPES.services.DeleteVoteService); diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index a8e15088a..9af5fbf25 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -18,13 +18,13 @@ import * as Votes from 'src/modules/votes/interfaces/types'; import { UpdateBoardDto } from '../dto/update-board.dto'; import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @Injectable() export class UpdateBoardUseCase implements UseCase { constructor( - @Inject(TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) private readonly getBoardUserService: GetBoardUserServiceInterface, diff --git a/backend/src/modules/boards/boards.providers.ts b/backend/src/modules/boards/boards.providers.ts index 353a1fdfa..5555e82ea 100644 --- a/backend/src/modules/boards/boards.providers.ts +++ b/backend/src/modules/boards/boards.providers.ts @@ -19,6 +19,13 @@ import { GetDashboardBoardsUseCase } from './applications/get-dashboard-boards.u import { GetPersonalBoardsUseCase } from './applications/get-personal-boards.use-case'; import { IsBoardPublicUseCase } from './applications/is-board-public.use-case'; import { + AFTER_USER_PAUSED_TIMER_SUBSCRIBER, + AFTER_USER_REQUESTED_TIMER_STATE_SUBSCRIBER, + AFTER_USER_STARTED_TIMER_SUBSCRIBER, + AFTER_USER_STOPPED_TIMER_SUBSCRIBER, + AFTER_USER_UPDATED_DURATION_SUBSCRIBER, + BOARD_REPOSITORY, + BOARD_TIMER_REPOSITORY, CREATE_BOARD_SERVICE, CREATE_BOARD_USE_CASE, DELETE_BOARD_SERVICE, @@ -36,7 +43,6 @@ import { SEND_BOARD_TIMER_TIME_LEFT_SERVICE, START_BOARD_TIMER_SERVICE, STOP_BOARD_TIMER_SERVICE, - TYPES, UPDATE_BOARD_PARTICIPANTS_USE_CASE, UPDATE_BOARD_PHASE_USE_CASE, UPDATE_BOARD_SERVICE, @@ -167,37 +173,41 @@ export const updateBoardPhaseUseCase = { useClass: UpdateBoardPhaseUseCase }; +/* REPOSITORIES */ + export const boardTimerRepository = { - provide: TYPES.repositories.BoardTimerRepository, + provide: BOARD_TIMER_REPOSITORY, useClass: BoardTimerRepository }; +export const boardRepository = { + provide: BOARD_REPOSITORY, + useClass: BoardRepository +}; + +/* SUBSCRIBERS */ + export const afterUserUpdatedDurationSubscriber = { - provide: TYPES.subscribers.AfterUserUpdatedDurationSubscriber, + provide: AFTER_USER_UPDATED_DURATION_SUBSCRIBER, useClass: AfterUserUpdatedDurationSubscriber }; export const afterUserPausedTimerSubscriber = { - provide: TYPES.subscribers.AfterUserPausedTimerSubscriber, + provide: AFTER_USER_PAUSED_TIMER_SUBSCRIBER, useClass: AfterUserPausedTimerSubscriber }; export const afterUserStartedTimerSubscriber = { - provide: TYPES.subscribers.AfterUserStartedTimerSubscriber, + provide: AFTER_USER_STARTED_TIMER_SUBSCRIBER, useClass: AfterUserStartedTimerSubscriber }; export const afterUserStoppedTimerSubscriber = { - provide: TYPES.subscribers.AfterUserStoppedTimerSubscriber, + provide: AFTER_USER_STOPPED_TIMER_SUBSCRIBER, useClass: AfterUserStoppedTimerSubscriber }; export const afterUserRequestedTimerStateSubscriber = { - provide: TYPES.subscribers.AfterUserRequestedTimerStateSubscriber, + provide: AFTER_USER_REQUESTED_TIMER_STATE_SUBSCRIBER, useClass: AfterUserRequestedTimerStateSubscriber }; - -export const boardRepository = { - provide: TYPES.repositories.BoardRepository, - useClass: BoardRepository -}; diff --git a/backend/src/modules/boards/constants.ts b/backend/src/modules/boards/constants.ts index 078ec0b4b..de6ba6c40 100644 --- a/backend/src/modules/boards/constants.ts +++ b/backend/src/modules/boards/constants.ts @@ -1,31 +1,3 @@ -export const TYPES = { - applications: { - //DuplicateBoardUseCase: 'DuplicateBoardUseCase', - //GetBoardsForDashboardUseCase: 'GetBoardsForDashboardUseCase', - //GetAllBoardsUseCase: 'GetAllBoardUseCase', - //GetPersonalBoardsUseCase: 'GetPersonalBoardsUseCase', - //GetBoardUseCase: 'GetBoardUseCase', - //CreateBoardUseCase: 'CreateBoardUseCase', - //IsBoardPublicUseCase: 'IsBoardPublicUseCase', - //DeleteBoardUseCase: 'DeleteBoardUseCase', - //UpdateBoardUseCase: 'UpdateBoardUseCase', - //UpdateBoardParticipantsUseCase: 'UpdateBoardParticipantsUseCase', - //MergeBoardUseCase: 'MergeBoardUseCase', - //UpdateBoardPhaseUseCase: 'UpdateBoardPhaseUseCase' - }, - repositories: { - BoardTimerRepository: 'BoardTimerRepository', - BoardRepository: 'BoardRepository' - }, - subscribers: { - AfterUserPausedTimerSubscriber: 'AfterUserPausedTimerSubscriber', - AfterUserStartedTimerSubscriber: 'AfterUserStartedTimerSubscriber', - AfterUserStoppedTimerSubscriber: 'AfterUserStoppedTimerSubscriber', - AfterUserUpdatedDurationSubscriber: 'AfterUserUpdatedDurationSubscriber', - AfterUserRequestedTimerStateSubscriber: 'AfterUserRequestedTimerStateSubscriber' - } -}; - /* SERVICES */ export const CREATE_BOARD_SERVICE = 'CreateBoardService'; @@ -73,3 +45,21 @@ export const UPDATE_BOARD_PARTICIPANTS_USE_CASE = 'UpdateBoardParticipantsUseCas export const MERGE_BOARD_USE_CASE = 'MergeBoardUseCase'; export const UPDATE_BOARD_PHASE_USE_CASE = 'UpdateBoardPhaseUseCase'; + +/* REPOSITORIES */ + +export const BOARD_TIMER_REPOSITORY = 'BoardTimerRepository'; + +export const BOARD_REPOSITORY = 'BoardRepository'; + +/* SUBSCRIBERS */ + +export const AFTER_USER_PAUSED_TIMER_SUBSCRIBER = 'AfterUserPausedTimerSubscriber'; + +export const AFTER_USER_STARTED_TIMER_SUBSCRIBER = 'AfterUserStartedTimerSubscriber'; + +export const AFTER_USER_STOPPED_TIMER_SUBSCRIBER = 'AfterUserStoppedTimerSubscriber'; + +export const AFTER_USER_UPDATED_DURATION_SUBSCRIBER = 'AfterUserUpdatedDurationSubscriber'; + +export const AFTER_USER_REQUESTED_TIMER_STATE_SUBSCRIBER = 'AfterUserRequestedTimerStateSubscriber'; diff --git a/backend/src/modules/boards/controller/publicBoards.controller.ts b/backend/src/modules/boards/controller/publicBoards.controller.ts index 6748e69a6..4f88efb9c 100644 --- a/backend/src/modules/boards/controller/publicBoards.controller.ts +++ b/backend/src/modules/boards/controller/publicBoards.controller.ts @@ -19,7 +19,7 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; export default class PublicBoardsController { constructor( @Inject(IS_BOARD_PUBLIC_USE_CASE) - private isBoardPublicUseCase: UseCase + private readonly isBoardPublicUseCase: UseCase ) {} @ApiOperation({ summary: 'Check if board is public' }) diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 01902e913..3dde6bd48 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; @@ -33,6 +32,7 @@ import { BadRequestException, NotFoundException } from '@nestjs/common'; import { TeamRoles } from 'src/libs/enum/team.roles'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const userId: string = faker.datatype.uuid(); @@ -224,7 +224,7 @@ describe('CreateBoardService', () => { useValue: createMock() }, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -235,7 +235,7 @@ describe('CreateBoardService', () => { }).compile(); boardService = module.get(CreateBoardService); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); getTeamServiceMock = module.get(GET_TEAM_SERVICE); getTeamUserServiceMock = module.get(GET_TEAM_USER_SERVICE); diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index ec009cd1e..467c13fc2 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -14,7 +14,6 @@ import * as CommunicationsType from 'src/modules/communication/interfaces/types' import { AddCronJobDto } from 'src/modules/schedules/dto/add.cronjob.dto'; import { CreateSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/create.schedules.service.interface'; import * as SchedulesType from 'src/modules/schedules/interfaces/types'; -import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; @@ -38,6 +37,7 @@ import { TEAM_NOT_FOUND, TEAM_USERS_NOT_FOUND } from 'src/libs/exceptions/messag import { CreateFailedException } from 'src/libs/exceptions/createFailedBadRequestException'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; type CreateBoardAndUsers = { boardData: BoardDto; @@ -59,7 +59,7 @@ export default class CreateBoardService implements CreateBoardServiceInterface { private readonly createSchedulesService: CreateSchedulesServiceInterface, @Inject(CommunicationsType.TYPES.services.SlackCommunicationService) private readonly slackCommunicationService: CommunicationServiceInterface, - @Inject(Boards.TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.CreateBoardUserService) private readonly createBoardUserService: CreateBoardUserServiceInterface diff --git a/backend/src/modules/boards/services/delete.board.service.spec.ts b/backend/src/modules/boards/services/delete.board.service.spec.ts index 27f3a2df8..182557c0a 100644 --- a/backend/src/modules/boards/services/delete.board.service.spec.ts +++ b/backend/src/modules/boards/services/delete.board.service.spec.ts @@ -1,7 +1,6 @@ import { faker } from '@faker-js/faker'; import { Test, TestingModule } from '@nestjs/testing'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; -import * as Boards from 'src/modules/boards/constants'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; @@ -13,6 +12,7 @@ import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory. import { DeleteBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/delete.board.user.service.interface'; import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/delete.schedules.service.interface'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; const boards = BoardFactory.createMany(2, [{ slackEnable: true }, { slackEnable: true }]); const board = BoardFactory.create({ @@ -41,7 +41,7 @@ describe('DeleteBoardService', () => { providers: [ deleteBoardService, { - provide: Boards.TYPES.repositories.BoardRepository, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -58,8 +58,8 @@ describe('DeleteBoardService', () => { } ] }).compile(); - service = module.get(deleteBoardService.provide); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + service = module.get(deleteBoardService.provide); + boardRepositoryMock = module.get(BOARD_REPOSITORY); deleteBoardUserServiceMock = module.get(BoardUsers.TYPES.services.DeleteBoardUserService); deleteSchedulesServiceMock = module.get(Schedules.TYPES.services.DeleteSchedulesService); archiveChannelServiceMock = module.get( diff --git a/backend/src/modules/boards/services/delete.board.service.ts b/backend/src/modules/boards/services/delete.board.service.ts index d6c8ef30e..683d50494 100644 --- a/backend/src/modules/boards/services/delete.board.service.ts +++ b/backend/src/modules/boards/services/delete.board.service.ts @@ -5,24 +5,24 @@ import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interface import * as Schedules from 'src/modules/schedules/interfaces/types'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import Board from '../entities/board.schema'; -import * as Boards from 'src/modules/boards/constants'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; import { ArchiveChannelDataOptions } from 'src/modules/communication/dto/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; @Injectable() export default class DeleteBoardService implements DeleteBoardServiceInterface { constructor( - @Inject(Boards.TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, @Inject(BoardUsers.TYPES.services.DeleteBoardUserService) - private deleteBoardUserService: DeleteBoardUserServiceInterface, + private readonly deleteBoardUserService: DeleteBoardUserServiceInterface, @Inject(Schedules.TYPES.services.DeleteSchedulesService) - private deleteScheduleService: DeleteSchedulesServiceInterface, + private readonly deleteScheduleService: DeleteSchedulesServiceInterface, @Inject(CommunicationTypes.TYPES.services.SlackArchiveChannelService) - private archiveChannelService: ArchiveChannelServiceInterface + private readonly archiveChannelService: ArchiveChannelServiceInterface ) {} async deleteBoardsByTeamId(teamId: string) { diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index e7649b141..8b4f7f9b1 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -1,14 +1,10 @@ import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; -import { getBoardUserService } from '../../boardUsers/boardusers.providers'; -import { getBoardService } from './../boards.providers'; -import { getTokenAuthService } from './../../auth/auth.providers'; import { Test, TestingModule } from '@nestjs/testing'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; -import { updateUserService } from 'src/modules/users/users.providers'; -import { boardRepository } from '../boards.providers'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/constants'; +import * as Users from 'src/modules/users/interfaces/types'; +import * as Auth from 'src/modules/auth/interfaces/types'; import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; @@ -19,11 +15,12 @@ import { UpdateUserServiceInterface } from 'src/modules/users/interfaces/service import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; -import { createBoardUserService } from 'src/modules/boardUsers/boardusers.providers'; import { UserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/userDto-factory.mock'; import { NotFoundException } from '@nestjs/common'; import { hideVotesFromColumns } from '../utils/hideVotesFromColumns'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import GetBoardService from 'src/modules/boards/services/get.board.service'; const userId = faker.datatype.uuid(); const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); @@ -45,29 +42,29 @@ describe('GetBoardService', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - getBoardService, + GetBoardService, { provide: GET_TEAM_SERVICE, useValue: createMock() }, { - provide: createBoardUserService.provide, + provide: BoardUsers.TYPES.services.CreateBoardUserService, useValue: createMock() }, { - provide: getTokenAuthService.provide, + provide: Auth.TYPES.services.GetTokenAuthService, useValue: createMock() }, { - provide: updateUserService.provide, + provide: Users.TYPES.services.UpdateUserService, useValue: createMock() }, { - provide: getBoardUserService.provide, + provide: BoardUsers.TYPES.services.GetBoardUserService, useValue: createMock() }, { - provide: boardRepository.provide, + provide: BOARD_REPOSITORY, useValue: createMock() }, { @@ -77,8 +74,8 @@ describe('GetBoardService', () => { ] }).compile(); - boardService = module.get(getBoardService.provide); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardService = module.get(GetBoardService); + boardRepositoryMock = module.get(BOARD_REPOSITORY); getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); getTeamServiceMock = module.get(GET_TEAM_SERVICE); }); diff --git a/backend/src/modules/boards/services/get.board.service.ts b/backend/src/modules/boards/services/get.board.service.ts index 395086c92..7ab9cc10a 100644 --- a/backend/src/modules/boards/services/get.board.service.ts +++ b/backend/src/modules/boards/services/get.board.service.ts @@ -6,7 +6,7 @@ import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { QueryType } from '../interfaces/findQuery'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { cleanBoard } from '../utils/clean-board'; -import { TYPES } from '../constants'; +import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import UserDto from 'src/modules/users/dto/user.dto'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; @@ -15,10 +15,10 @@ import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; export default class GetBoardService implements GetBoardServiceInterface { constructor( @Inject(forwardRef(() => GET_TEAM_SERVICE)) - private getTeamService: GetTeamServiceInterface, + private readonly getTeamService: GetTeamServiceInterface, @Inject(BoardUsers.TYPES.services.GetBoardUserService) - private getBoardUserService: GetBoardUserServiceInterface, - @Inject(TYPES.repositories.BoardRepository) + private readonly getBoardUserService: GetBoardUserServiceInterface, + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface ) {} diff --git a/backend/src/modules/boards/services/pause-board-timer.service.ts b/backend/src/modules/boards/services/pause-board-timer.service.ts index 143bd00aa..31ab0e0db 100644 --- a/backend/src/modules/boards/services/pause-board-timer.service.ts +++ b/backend/src/modules/boards/services/pause-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_PAUSED } from 'src/libs/constants/timer'; import BoardTimerTimeLeftDto from 'src/libs/dto/board-timer-time-left.dto'; import ServerPausedTimerEvent from 'src/modules/boards/events/server-paused-timer.event'; import PauseBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/pause-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/constants'; +import { BOARD_TIMER_REPOSITORY } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() @@ -12,10 +12,10 @@ export default class PauseBoardTimerService implements PauseBoardTimerServiceInt private logger: Logger = new Logger(PauseBoardTimerService.name); constructor( - @Inject(TYPES.repositories.BoardTimerRepository) - private boardTimerRepository: BoardTimerRepositoryInterface, + @Inject(BOARD_TIMER_REPOSITORY) + private readonly boardTimerRepository: BoardTimerRepositoryInterface, - private eventEmitter: EventEmitter2 + private readonly eventEmitter: EventEmitter2 ) {} pauseTimer(boardTimeLeftDto: BoardTimerTimeLeftDto) { diff --git a/backend/src/modules/boards/services/send-board-timer-state.service.ts b/backend/src/modules/boards/services/send-board-timer-state.service.ts index 3b2148514..ffef4994d 100644 --- a/backend/src/modules/boards/services/send-board-timer-state.service.ts +++ b/backend/src/modules/boards/services/send-board-timer-state.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_SENT_TIMER_STATE } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerSentTimerStateEvent from 'src/modules/boards/events/server-sent-timer-state.event'; import SendBoardTimerStateServiceInterface from 'src/modules/boards/interfaces/services/send-board-timer-state.service.interface'; -import { TYPES } from 'src/modules/boards/constants'; +import { BOARD_TIMER_REPOSITORY } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() @@ -12,10 +12,10 @@ export default class SendBoardTimerStateService implements SendBoardTimerStateSe private logger: Logger = new Logger(SendBoardTimerStateService.name); constructor( - @Inject(TYPES.repositories.BoardTimerRepository) - private boardTimerRepository: BoardTimerRepositoryInterface, + @Inject(BOARD_TIMER_REPOSITORY) + private readonly boardTimerRepository: BoardTimerRepositoryInterface, - private eventEmitter: EventEmitter2 + private readonly eventEmitter: EventEmitter2 ) {} sendBoardTimerState(boardTimerDto: BoardTimerDto) { diff --git a/backend/src/modules/boards/services/send-board-timer-time-left.service.ts b/backend/src/modules/boards/services/send-board-timer-time-left.service.ts index d38651558..ab8d99de0 100644 --- a/backend/src/modules/boards/services/send-board-timer-time-left.service.ts +++ b/backend/src/modules/boards/services/send-board-timer-time-left.service.ts @@ -11,7 +11,7 @@ export default class SendBoardTimerTimeLeftService { private logger: Logger = new Logger(SendBoardTimerTimeLeftService.name); - constructor(private eventEmitter: EventEmitter2) {} + constructor(private readonly eventEmitter: EventEmitter2) {} sendTimeLeft(boardTimeLeft: BoardTimerTimeLeftDto) { this.logger.log(`Will send time left. Board: "${boardTimeLeft.boardId})"`); diff --git a/backend/src/modules/boards/services/start-board-timer.service.ts b/backend/src/modules/boards/services/start-board-timer.service.ts index 6727ae5dc..ad508c6c8 100644 --- a/backend/src/modules/boards/services/start-board-timer.service.ts +++ b/backend/src/modules/boards/services/start-board-timer.service.ts @@ -12,9 +12,9 @@ import SendBoardTimerTimeLeftServiceInterface from 'src/modules/boards/interface import StartBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/start-board-timer.service.interface'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; import { + BOARD_TIMER_REPOSITORY, SEND_BOARD_TIMER_TIME_LEFT_SERVICE, - STOP_BOARD_TIMER_SERVICE, - TYPES + STOP_BOARD_TIMER_SERVICE } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @@ -23,16 +23,16 @@ export default class StartBoardTimerService implements StartBoardTimerServiceInt private logger: Logger = new Logger(StartBoardTimerService.name); constructor( - @Inject(TYPES.repositories.BoardTimerRepository) - private boardTimerRepository: BoardTimerRepositoryInterface, + @Inject(BOARD_TIMER_REPOSITORY) + private readonly boardTimerRepository: BoardTimerRepositoryInterface, @Inject(STOP_BOARD_TIMER_SERVICE) - private stopBoardTimerService: StopBoardTimerServiceInterface, + private readonly stopBoardTimerService: StopBoardTimerServiceInterface, @Inject(SEND_BOARD_TIMER_TIME_LEFT_SERVICE) - private updateBoardTimerService: SendBoardTimerTimeLeftServiceInterface, + private readonly updateBoardTimerService: SendBoardTimerTimeLeftServiceInterface, - private eventEmitter: EventEmitter2 + private readonly eventEmitter: EventEmitter2 ) {} startTimer(boardTimerDurationDto: BoardTimerDurationDto) { diff --git a/backend/src/modules/boards/services/stop-board-timer.service.ts b/backend/src/modules/boards/services/stop-board-timer.service.ts index 486f5aa5e..27a9fb9f6 100644 --- a/backend/src/modules/boards/services/stop-board-timer.service.ts +++ b/backend/src/modules/boards/services/stop-board-timer.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_STOPPED } from 'src/libs/constants/timer'; import BoardTimerDto from 'src/libs/dto/board-timer.dto'; import ServerStoppedTimerEvent from 'src/modules/boards/events/server-stopped-timer.event'; import StopBoardTimerServiceInterface from 'src/modules/boards/interfaces/services/stop-board-timer.service.interface'; -import { TYPES } from 'src/modules/boards/constants'; +import { BOARD_TIMER_REPOSITORY } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() @@ -12,10 +12,10 @@ export default class StopBoardTimerService implements StopBoardTimerServiceInter private logger: Logger = new Logger(StopBoardTimerService.name); constructor( - @Inject(TYPES.repositories.BoardTimerRepository) - private boardTimerRepository: BoardTimerRepositoryInterface, + @Inject(BOARD_TIMER_REPOSITORY) + private readonly boardTimerRepository: BoardTimerRepositoryInterface, - private eventEmitter: EventEmitter2 + private readonly eventEmitter: EventEmitter2 ) {} stopTimer(boardTimerDto: BoardTimerDto) { diff --git a/backend/src/modules/boards/services/update-board-timer-duration.service.ts b/backend/src/modules/boards/services/update-board-timer-duration.service.ts index b40d9c3f9..c4f455162 100644 --- a/backend/src/modules/boards/services/update-board-timer-duration.service.ts +++ b/backend/src/modules/boards/services/update-board-timer-duration.service.ts @@ -4,7 +4,7 @@ import { BOARD_TIMER_SERVER_DURATION_UPDATED } from 'src/libs/constants/timer'; import BoardTimerDurationDto from 'src/libs/dto/board-timer-duration.dto'; import ServerUpdatedTimerDurationEvent from 'src/modules/boards/events/server-updated-timer-duration.event'; import UpdateBoardTimerDurationServiceInterface from 'src/modules/boards/interfaces/services/update-board-timer-duration.service.interface'; -import { TYPES } from 'src/modules/boards/constants'; +import { BOARD_TIMER_REPOSITORY } from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from '../repositories/board-timer.repository.interface'; @Injectable() @@ -14,10 +14,10 @@ export default class UpdateBoardTimerDurationService private logger: Logger = new Logger(UpdateBoardTimerDurationService.name); constructor( - @Inject(TYPES.repositories.BoardTimerRepository) - private boardTimerRepository: BoardTimerRepositoryInterface, + @Inject(BOARD_TIMER_REPOSITORY) + private readonly boardTimerRepository: BoardTimerRepositoryInterface, - private eventEmitter: EventEmitter2 + private readonly eventEmitter: EventEmitter2 ) {} updateDuration(boardTimerDuration: BoardTimerDurationDto) { diff --git a/backend/src/modules/boards/services/update.board.service.spec.ts b/backend/src/modules/boards/services/update.board.service.spec.ts index f1f700722..012a00fd1 100644 --- a/backend/src/modules/boards/services/update.board.service.spec.ts +++ b/backend/src/modules/boards/services/update.board.service.spec.ts @@ -1,14 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { boardRepository } from '../boards.providers'; import { UpdateBoardServiceInterface } from '../interfaces/services/update.board.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { TeamCommunicationDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/teamDto-factory'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Boards from 'src/modules/boards/constants'; import UpdateBoardService from './update.board.service'; import Board from '../entities/board.schema'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import faker from '@faker-js/faker'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; describe('UpdateBoardService', () => { let boardService: UpdateBoardServiceInterface; @@ -20,14 +19,14 @@ describe('UpdateBoardService', () => { UpdateBoardService, { - provide: boardRepository.provide, + provide: BOARD_REPOSITORY, useValue: createMock() } ] }).compile(); boardService = module.get(UpdateBoardService); - boardRepositoryMock = module.get(Boards.TYPES.repositories.BoardRepository); + boardRepositoryMock = module.get(BOARD_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/boards/services/update.board.service.ts b/backend/src/modules/boards/services/update.board.service.ts index 872dfe9bd..c744849ae 100644 --- a/backend/src/modules/boards/services/update.board.service.ts +++ b/backend/src/modules/boards/services/update.board.service.ts @@ -1,13 +1,13 @@ import { Inject, Injectable } from '@nestjs/common'; import { TeamDto } from 'src/modules/communication/dto/team.dto'; -import * as Boards from 'src/modules/boards/constants'; import { UpdateBoardServiceInterface } from '../interfaces/services/update.board.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; +import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; @Injectable() export default class UpdateBoardService implements UpdateBoardServiceInterface { constructor( - @Inject(Boards.TYPES.repositories.BoardRepository) + @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface ) {} diff --git a/backend/src/modules/schedules/repository/schedule.repository.ts b/backend/src/modules/schedules/repository/schedule.repository.ts index 145cc8a55..d95c435e3 100644 --- a/backend/src/modules/schedules/repository/schedule.repository.ts +++ b/backend/src/modules/schedules/repository/schedule.repository.ts @@ -8,7 +8,7 @@ import { ScheduleRepositoryInterface } from './schedule.repository.interface'; @Injectable() export class ScheduleRepository - extends MongoGenericRepository + extends MongoGenericRepository implements ScheduleRepositoryInterface { constructor(@InjectModel(Schedules.name) private model: Model) { From 9906b04b64f5e0295630da4bfcd932af4de856c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Wed, 19 Apr 2023 18:38:44 +0100 Subject: [PATCH 09/14] refactor: change Document to Entity --- .../boardUsers/repositories/board-user.repository.ts | 6 +++--- backend/src/modules/boards/repositories/board.repository.ts | 6 +++--- backend/src/modules/cards/repository/card.repository.ts | 6 +++--- .../src/modules/columns/repositories/column.repository.ts | 6 +++--- .../src/modules/comments/repositories/comment.repository.ts | 6 +++--- .../src/modules/schedules/repository/schedule.repository.ts | 6 +++--- backend/src/modules/teams/repositories/team.repository.ts | 6 +++--- backend/src/modules/votes/repositories/vote.repository.ts | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/src/modules/boardUsers/repositories/board-user.repository.ts b/backend/src/modules/boardUsers/repositories/board-user.repository.ts index 1b6a3dfe9..e76983548 100644 --- a/backend/src/modules/boardUsers/repositories/board-user.repository.ts +++ b/backend/src/modules/boardUsers/repositories/board-user.repository.ts @@ -5,16 +5,16 @@ import { BoardRoles } from 'src/libs/enum/board.roles'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; import BoardUserDto from 'src/modules/boardUsers/dto/board.user.dto'; import Board from 'src/modules/boards/entities/board.schema'; -import BoardUser, { BoardUserDocument } from 'src/modules/boardUsers/entities/board.user.schema'; +import BoardUser from 'src/modules/boardUsers/entities/board.user.schema'; import { BoardUserRepositoryInterface } from '../interfaces/repositories/board-user.repository.interface'; import { BulkWriteResult } from 'mongodb'; @Injectable() export class BoardUserRepository - extends MongoGenericRepository + extends MongoGenericRepository implements BoardUserRepositoryInterface { - constructor(@InjectModel(BoardUser.name) private model: Model) { + constructor(@InjectModel(BoardUser.name) private model: Model) { super(model); } diff --git a/backend/src/modules/boards/repositories/board.repository.ts b/backend/src/modules/boards/repositories/board.repository.ts index 0453a7778..cb7aa567a 100644 --- a/backend/src/modules/boards/repositories/board.repository.ts +++ b/backend/src/modules/boards/repositories/board.repository.ts @@ -4,7 +4,7 @@ import { FilterQuery, ObjectId } from 'mongoose'; import { Model, PopulateOptions } from 'mongoose'; import { BoardPhases } from 'src/libs/enum/board.phases'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Board, { BoardDocument } from 'src/modules/boards/entities/board.schema'; +import Board from 'src/modules/boards/entities/board.schema'; import Column from 'src/modules/columns/entities/column.schema'; import { QueryType } from '../interfaces/findQuery'; import { BoardDataPopulate, GetBoardDataPopulate } from '../utils/populate-board'; @@ -12,10 +12,10 @@ import { BoardRepositoryInterface } from './board.repository.interface'; @Injectable() export class BoardRepository - extends MongoGenericRepository + extends MongoGenericRepository implements BoardRepositoryInterface { - constructor(@InjectModel(Board.name) private model: Model) { + constructor(@InjectModel(Board.name) private model: Model) { super(model); } diff --git a/backend/src/modules/cards/repository/card.repository.ts b/backend/src/modules/cards/repository/card.repository.ts index 45a6239c1..40040f4c7 100644 --- a/backend/src/modules/cards/repository/card.repository.ts +++ b/backend/src/modules/cards/repository/card.repository.ts @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model, ObjectId, Types } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Board, { BoardDocument } from 'src/modules/boards/entities/board.schema'; +import Board from 'src/modules/boards/entities/board.schema'; import { BoardDataPopulate, GetCardFromBoardPopulate @@ -17,10 +17,10 @@ import User from 'src/modules/users/entities/user.schema'; @Injectable() export class CardRepository - extends MongoGenericRepository + extends MongoGenericRepository implements CardRepositoryInterface { - constructor(@InjectModel(Board.name) private model: Model) { + constructor(@InjectModel(Board.name) private model: Model) { super(model); } diff --git a/backend/src/modules/columns/repositories/column.repository.ts b/backend/src/modules/columns/repositories/column.repository.ts index dcd579e0a..287064dde 100644 --- a/backend/src/modules/columns/repositories/column.repository.ts +++ b/backend/src/modules/columns/repositories/column.repository.ts @@ -2,17 +2,17 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Board, { BoardDocument } from 'src/modules/boards/entities/board.schema'; +import Board from 'src/modules/boards/entities/board.schema'; import { GetBoardDataPopulate } from 'src/modules/boards/utils/populate-board'; import { UpdateColumnDto } from '../dto/update-column.dto'; import { ColumnRepositoryInterface } from './column.repository.interface'; @Injectable() export class ColumnRepository - extends MongoGenericRepository + extends MongoGenericRepository implements ColumnRepositoryInterface { - constructor(@InjectModel(Board.name) private model: Model) { + constructor(@InjectModel(Board.name) private model: Model) { super(model); } diff --git a/backend/src/modules/comments/repositories/comment.repository.ts b/backend/src/modules/comments/repositories/comment.repository.ts index d555392e4..0f566d49f 100644 --- a/backend/src/modules/comments/repositories/comment.repository.ts +++ b/backend/src/modules/comments/repositories/comment.repository.ts @@ -3,15 +3,15 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Board, { BoardDocument } from 'src/modules/boards/entities/board.schema'; +import Board from 'src/modules/boards/entities/board.schema'; import { BoardDataPopulate } from 'src/modules/boards/utils/populate-board'; @Injectable() export class CommentRepository - extends MongoGenericRepository + extends MongoGenericRepository implements CommentRepositoryInterface { - constructor(@InjectModel(Board.name) private model: Model) { + constructor(@InjectModel(Board.name) private model: Model) { super(model); } diff --git a/backend/src/modules/schedules/repository/schedule.repository.ts b/backend/src/modules/schedules/repository/schedule.repository.ts index d95c435e3..a5f030c86 100644 --- a/backend/src/modules/schedules/repository/schedule.repository.ts +++ b/backend/src/modules/schedules/repository/schedule.repository.ts @@ -3,15 +3,15 @@ import { InjectModel } from '@nestjs/mongoose'; import { DeleteResult } from 'mongodb'; import { Model } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Schedules, { SchedulesDocument } from '../entities/schedules.schema'; +import Schedules from '../entities/schedules.schema'; import { ScheduleRepositoryInterface } from './schedule.repository.interface'; @Injectable() export class ScheduleRepository - extends MongoGenericRepository + extends MongoGenericRepository implements ScheduleRepositoryInterface { - constructor(@InjectModel(Schedules.name) private model: Model) { + constructor(@InjectModel(Schedules.name) private model: Model) { super(model); } getSchedules(): Promise { diff --git a/backend/src/modules/teams/repositories/team.repository.ts b/backend/src/modules/teams/repositories/team.repository.ts index 791144676..7cb88968b 100644 --- a/backend/src/modules/teams/repositories/team.repository.ts +++ b/backend/src/modules/teams/repositories/team.repository.ts @@ -2,15 +2,15 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Team, { TeamDocument } from '../entities/team.schema'; +import Team from '../entities/team.schema'; import { TeamRepositoryInterface } from '../interfaces/repositories/team.repository.interface'; @Injectable() export class TeamRepository - extends MongoGenericRepository + extends MongoGenericRepository implements TeamRepositoryInterface { - constructor(@InjectModel(Team.name) private model: Model) { + constructor(@InjectModel(Team.name) private model: Model) { super(model); } diff --git a/backend/src/modules/votes/repositories/vote.repository.ts b/backend/src/modules/votes/repositories/vote.repository.ts index efdbf3327..7612d838d 100644 --- a/backend/src/modules/votes/repositories/vote.repository.ts +++ b/backend/src/modules/votes/repositories/vote.repository.ts @@ -2,16 +2,16 @@ import { Injectable } from '@nestjs/common'; import { InjectModel } from '@nestjs/mongoose'; import { FilterQuery, Model, QueryOptions, UpdateQuery } from 'mongoose'; import { MongoGenericRepository } from 'src/libs/repositories/mongo/mongo-generic.repository'; -import Board, { BoardDocument } from 'src/modules/boards/entities/board.schema'; +import Board from 'src/modules/boards/entities/board.schema'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { PopulateType } from 'src/libs/repositories/interfaces/base.repository.interface'; @Injectable() export class VoteRepository - extends MongoGenericRepository + extends MongoGenericRepository implements VoteRepositoryInterface { - constructor(@InjectModel(Board.name) private model: Model) { + constructor(@InjectModel(Board.name) private model: Model) { super(model); } From e9ba35b6b3d2ed23b3a1ed76b9c4f6b335a07760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Thu, 20 Apr 2023 16:29:36 +0100 Subject: [PATCH 10/14] refactor: change TYPES for CONSTANTS (boardUser) --- backend/src/libs/guards/boardRoles.guard.ts | 4 +-- .../libs/guards/getBoardPermissions.guard.ts | 4 +-- .../boardUsers/boardusers.providers.ts | 18 ++++++++---- backend/src/modules/boardUsers/constants.ts | 13 +++++++++ .../modules/boardUsers/interfaces/types.ts | 11 ------- .../services/create.board.user.service.ts | 4 +-- .../services/delete.board.user.service.ts | 4 +-- .../services/get.board.user.service.ts | 4 +-- .../services/update.board.user.service.ts | 4 +-- .../duplicate-board.use-case.spec.ts | 6 ++-- .../applications/duplicate-board.use-case.ts | 4 +-- .../applications/get-board.use-case.spec.ts | 11 ++++--- .../boards/applications/get-board.use-case.ts | 9 ++++-- .../update-board-participants.spec.ts | 18 +++++++----- .../update-board-participants.use-case.ts | 12 +++++--- .../update-board.use-case.spec.ts | 13 +++++---- .../applications/update-board.use-case.ts | 9 ++++-- .../services/create.board.service.spec.ts | 6 ++-- .../boards/services/create.board.service.ts | 4 +-- .../services/delete.board.service.spec.ts | 6 ++-- .../boards/services/delete.board.service.ts | 4 +-- .../boards/services/get.board.service.spec.ts | 29 +++---------------- .../boards/services/get.board.service.ts | 4 +-- .../applications/delete-card.use-case.spec.ts | 6 ++-- .../applications/delete-card.use-case.ts | 4 +-- .../delete-from-card-group.use-case.spec.ts | 6 ++-- .../delete-from-card-group.use-case.ts | 4 +-- .../card-group-vote.use-case.spec.ts | 4 +-- .../applications/card-group-vote.use-case.ts | 4 +-- .../card-item-vote.use-case.spec.ts | 4 +-- .../applications/card-item-vote.use-case.ts | 4 +-- .../services/create.vote.service.spec.ts | 13 +++++---- .../votes/services/create.vote.service.ts | 9 ++++-- .../services/delete.vote.service.spec.ts | 13 +++++---- .../votes/services/delete.vote.service.ts | 9 ++++-- 35 files changed, 150 insertions(+), 131 deletions(-) create mode 100644 backend/src/modules/boardUsers/constants.ts delete mode 100644 backend/src/modules/boardUsers/interfaces/types.ts diff --git a/backend/src/libs/guards/boardRoles.guard.ts b/backend/src/libs/guards/boardRoles.guard.ts index 53478b365..d6b957c96 100644 --- a/backend/src/libs/guards/boardRoles.guard.ts +++ b/backend/src/libs/guards/boardRoles.guard.ts @@ -9,10 +9,10 @@ import { Injectable } from '@nestjs/common'; import { Reflector } from '@nestjs/core'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import { GET_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { GET_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class BoardUserGuard implements CanActivate { @@ -22,7 +22,7 @@ export class BoardUserGuard implements CanActivate { private readonly reflector: Reflector, @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface ) {} diff --git a/backend/src/libs/guards/getBoardPermissions.guard.ts b/backend/src/libs/guards/getBoardPermissions.guard.ts index 869d61b67..43449b2d2 100644 --- a/backend/src/libs/guards/getBoardPermissions.guard.ts +++ b/backend/src/libs/guards/getBoardPermissions.guard.ts @@ -5,7 +5,6 @@ import { Inject, Injectable } from '@nestjs/common'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import Team from 'src/modules/teams/entities/team.schema'; import User from 'src/modules/users/entities/user.schema'; @@ -13,6 +12,7 @@ import { Reflector } from '@nestjs/core'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { GET_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class GetBoardGuard implements CanActivate { @@ -20,7 +20,7 @@ export class GetBoardGuard implements CanActivate { private readonly reflector: Reflector, @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface ) {} diff --git a/backend/src/modules/boardUsers/boardusers.providers.ts b/backend/src/modules/boardUsers/boardusers.providers.ts index 9cddb40cf..dd3787658 100644 --- a/backend/src/modules/boardUsers/boardusers.providers.ts +++ b/backend/src/modules/boardUsers/boardusers.providers.ts @@ -1,31 +1,37 @@ import { BoardUserRepository } from './repositories/board-user.repository'; import CreateBoardUserService from './services/create.board.user.service'; -import { TYPES } from './interfaces/types'; +import { + BOARD_USER_REPOSITORY, + CREATE_BOARD_USER_SERVICE, + DELETE_BOARD_USER_SERVICE, + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from './constants'; import DeleteBoardUserService from './services/delete.board.user.service'; import GetBoardUserService from './services/get.board.user.service'; import UpdateBoardUserService from './services/update.board.user.service'; export const createBoardUserService = { - provide: TYPES.services.CreateBoardUserService, + provide: CREATE_BOARD_USER_SERVICE, useClass: CreateBoardUserService }; export const getBoardUserService = { - provide: TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useClass: GetBoardUserService }; export const updateBoardUserService = { - provide: TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useClass: UpdateBoardUserService }; export const deleteBoardUserService = { - provide: TYPES.services.DeleteBoardUserService, + provide: DELETE_BOARD_USER_SERVICE, useClass: DeleteBoardUserService }; export const boardUserRepository = { - provide: TYPES.repositories.BoardUserRepository, + provide: BOARD_USER_REPOSITORY, useClass: BoardUserRepository }; diff --git a/backend/src/modules/boardUsers/constants.ts b/backend/src/modules/boardUsers/constants.ts new file mode 100644 index 000000000..d504f94fb --- /dev/null +++ b/backend/src/modules/boardUsers/constants.ts @@ -0,0 +1,13 @@ +/* SERVICES */ + +export const CREATE_BOARD_USER_SERVICE = 'CreateBoardUserService'; + +export const GET_BOARD_USER_SERVICE = 'GetBoardUserService'; + +export const UPDATE_BOARD_USER_SERVICE = 'UpdateBoardUserService'; + +export const DELETE_BOARD_USER_SERVICE = 'DeleteBoardUserService'; + +/* REPOSITORY */ + +export const BOARD_USER_REPOSITORY = 'BoardUserRepository'; diff --git a/backend/src/modules/boardUsers/interfaces/types.ts b/backend/src/modules/boardUsers/interfaces/types.ts deleted file mode 100644 index 07c05aab1..000000000 --- a/backend/src/modules/boardUsers/interfaces/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const TYPES = { - services: { - CreateBoardUserService: 'CreateBoardUserService', - GetBoardUserService: 'GetBoardUserService', - UpdateBoardUserService: 'UpdateBoardUserService', - DeleteBoardUserService: 'DeleteBoardUserService' - }, - repositories: { - BoardUserRepository: 'BoardUserRepository' - } -}; diff --git a/backend/src/modules/boardUsers/services/create.board.user.service.ts b/backend/src/modules/boardUsers/services/create.board.user.service.ts index 1b9657df2..b7191740f 100644 --- a/backend/src/modules/boardUsers/services/create.board.user.service.ts +++ b/backend/src/modules/boardUsers/services/create.board.user.service.ts @@ -4,12 +4,12 @@ import { BOARD_USER_EXISTS, INSERT_FAILED } from 'src/libs/exceptions/messages'; import { CreateBoardUserServiceInterface } from '../interfaces/services/create.board.user.service.interface'; import BoardUserDto from '../dto/board.user.dto'; import { BoardUserRepositoryInterface } from '../interfaces/repositories/board-user.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { BOARD_USER_REPOSITORY } from '../constants'; @Injectable() export default class CreateBoardUserService implements CreateBoardUserServiceInterface { constructor( - @Inject(TYPES.repositories.BoardUserRepository) + @Inject(BOARD_USER_REPOSITORY) private readonly boardUserRepository: BoardUserRepositoryInterface ) {} diff --git a/backend/src/modules/boardUsers/services/delete.board.user.service.ts b/backend/src/modules/boardUsers/services/delete.board.user.service.ts index 2ef30cf24..696708235 100644 --- a/backend/src/modules/boardUsers/services/delete.board.user.service.ts +++ b/backend/src/modules/boardUsers/services/delete.board.user.service.ts @@ -1,7 +1,7 @@ import { DeleteBoardUserServiceInterface } from '../interfaces/services/delete.board.user.service.interface'; import { Inject, Injectable } from '@nestjs/common'; import { BoardUserRepositoryInterface } from '../interfaces/repositories/board-user.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { BOARD_USER_REPOSITORY } from '../constants'; import { Schema } from 'mongoose'; import Board from 'src/modules/boards/entities/board.schema'; import { DeleteResult } from 'mongodb'; @@ -9,7 +9,7 @@ import { DeleteResult } from 'mongodb'; @Injectable() export default class DeleteBoardUserService implements DeleteBoardUserServiceInterface { constructor( - @Inject(TYPES.repositories.BoardUserRepository) + @Inject(BOARD_USER_REPOSITORY) private readonly boardUserRepository: BoardUserRepositoryInterface ) {} diff --git a/backend/src/modules/boardUsers/services/get.board.user.service.ts b/backend/src/modules/boardUsers/services/get.board.user.service.ts index 95c10ba8c..6381ae2c3 100644 --- a/backend/src/modules/boardUsers/services/get.board.user.service.ts +++ b/backend/src/modules/boardUsers/services/get.board.user.service.ts @@ -1,13 +1,13 @@ import { BoardUserRepositoryInterface } from 'src/modules/boardUsers/interfaces/repositories/board-user.repository.interface'; import { GetBoardUserServiceInterface } from '../interfaces/services/get.board.user.service.interface'; import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { BOARD_USER_REPOSITORY } from '../constants'; import BoardUser from 'src/modules/boardUsers/entities/board.user.schema'; @Injectable() export default class GetBoardUserService implements GetBoardUserServiceInterface { constructor( - @Inject(TYPES.repositories.BoardUserRepository) + @Inject(BOARD_USER_REPOSITORY) private readonly boardUserRepository: BoardUserRepositoryInterface ) {} diff --git a/backend/src/modules/boardUsers/services/update.board.user.service.ts b/backend/src/modules/boardUsers/services/update.board.user.service.ts index cab355714..cda045272 100644 --- a/backend/src/modules/boardUsers/services/update.board.user.service.ts +++ b/backend/src/modules/boardUsers/services/update.board.user.service.ts @@ -1,13 +1,13 @@ import { Inject, Injectable } from '@nestjs/common'; import { BoardUserRepositoryInterface } from '../interfaces/repositories/board-user.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { BOARD_USER_REPOSITORY } from '../constants'; import { UpdateBoardUserServiceInterface } from '../interfaces/services/update.board.user.service.interface'; import BoardUser from 'src/modules/boardUsers/entities/board.user.schema'; @Injectable() export default class UpdateBoardUserService implements UpdateBoardUserServiceInterface { constructor( - @Inject(TYPES.repositories.BoardUserRepository) + @Inject(BOARD_USER_REPOSITORY) private readonly boardUserRepository: BoardUserRepositoryInterface ) {} diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts index 34349d48a..19237cede 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @@ -16,6 +15,7 @@ import { DuplicateBoardDto, DuplicateBoardUseCase } from './duplicate-board.use- import { BoardUserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/boardUserDto-factory.mock'; import { CreateFailedException } from 'src/libs/exceptions/createFailedBadRequestException'; import { BOARD_REPOSITORY, GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { CREATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const DEFAULT_PROPS = { boardId: faker.datatype.uuid(), @@ -51,7 +51,7 @@ describe('DuplicateBoardUseCase', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.CreateBoardUserService, + provide: CREATE_BOARD_USER_SERVICE, useValue: createMock() } ] @@ -62,7 +62,7 @@ describe('DuplicateBoardUseCase', () => { getUserServiceMock = module.get(Users.TYPES.services.GetUserService); getBoardServiceMock = module.get(GET_BOARD_SERVICE); boardRepositoryMock = module.get(BOARD_REPOSITORY); - createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); + createBoardUserServiceMock = module.get(CREATE_BOARD_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/duplicate-board.use-case.ts b/backend/src/modules/boards/applications/duplicate-board.use-case.ts index 3368a8dd7..c2758e6a0 100644 --- a/backend/src/modules/boards/applications/duplicate-board.use-case.ts +++ b/backend/src/modules/boards/applications/duplicate-board.use-case.ts @@ -6,7 +6,6 @@ import { UserNotFoundException } from 'src/libs/exceptions/userNotFoundException import { UseCase } from 'src/libs/interfaces/use-case.interface'; import BoardUserDto from 'src/modules/boardUsers/dto/board.user.dto'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import Card from 'src/modules/cards/entities/card.schema'; import Column from 'src/modules/columns/entities/column.schema'; import Team from 'src/modules/teams/entities/team.schema'; @@ -17,6 +16,7 @@ import Board from '../entities/board.schema'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { BOARD_REPOSITORY, GET_BOARD_SERVICE } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; +import { CREATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: string }; @@ -29,7 +29,7 @@ export class DuplicateBoardUseCase implements UseCase private readonly getUserService: GetUserServiceInterface, @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.CreateBoardUserService) + @Inject(CREATE_BOARD_USER_SERVICE) private readonly createBoardUserService: CreateBoardUserServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/get-board.use-case.spec.ts b/backend/src/modules/boards/applications/get-board.use-case.spec.ts index 96fcb347d..841080a88 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; @@ -20,6 +19,10 @@ import { Tokens } from 'src/libs/interfaces/jwt/tokens.interface'; import { hideVotesFromColumns } from '../utils/hideVotesFromColumns'; import { GetBoardUseCase } from './get-board.use-case'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { + CREATE_BOARD_USER_SERVICE, + GET_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); const subBoard = BoardFactory.create({ isSubBoard: true, isPublic: false }); @@ -41,11 +44,11 @@ describe('GetBoardUseCase', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.CreateBoardUserService, + provide: CREATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -61,7 +64,7 @@ describe('GetBoardUseCase', () => { useCase = module.get(GetBoardUseCase); boardRepositoryMock = module.get(BOARD_REPOSITORY); - getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); + getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getTokenAuthServiceMock = module.get(Auth.TYPES.services.GetTokenAuthService); }); diff --git a/backend/src/modules/boards/applications/get-board.use-case.ts b/backend/src/modules/boards/applications/get-board.use-case.ts index 97ea76ed8..88f57fbbb 100644 --- a/backend/src/modules/boards/applications/get-board.use-case.ts +++ b/backend/src/modules/boards/applications/get-board.use-case.ts @@ -1,7 +1,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; import { BOARD_REPOSITORY } from '../constants'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Auth from 'src/modules/auth/interfaces/types'; import * as Users from 'src/modules/users/interfaces/types'; import BoardUseCasePresenter from '../presenter/board.use-case.presenter'; @@ -18,15 +17,19 @@ import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfac import { GetTokenAuthServiceInterface } from 'src/modules/auth/interfaces/services/get-token.auth.service.interface'; import { UpdateUserServiceInterface } from 'src/modules/users/interfaces/services/update.user.service.interface'; import BoardGuestUserDto from 'src/modules/boardUsers/dto/board.guest.user.dto'; +import { + CREATE_BOARD_USER_SERVICE, + GET_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; @Injectable() export class GetBoardUseCase implements UseCase { constructor( @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.CreateBoardUserService) + @Inject(CREATE_BOARD_USER_SERVICE) private readonly createBoardUserService: CreateBoardUserServiceInterface, @Inject(Auth.TYPES.services.GetTokenAuthService) private readonly getTokenAuthService: GetTokenAuthServiceInterface, diff --git a/backend/src/modules/boards/applications/update-board-participants.spec.ts b/backend/src/modules/boards/applications/update-board-participants.spec.ts index 88a3cef63..4349d0f65 100644 --- a/backend/src/modules/boards/applications/update-board-participants.spec.ts +++ b/backend/src/modules/boards/applications/update-board-participants.spec.ts @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { BoardRoles } from 'src/libs/enum/board.roles'; @@ -14,6 +13,11 @@ import { import UpdateBoardUserDto from 'src/modules/boardUsers/dto/update-board-user.dto'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; import { DeleteBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/delete.board.user.service.interface'; +import { + CREATE_BOARD_USER_SERVICE, + DELETE_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; const addUsers = BoardUserDtoFactory.createMany(2); const boardUserToRemove = BoardUserFactory.create(); @@ -31,24 +35,24 @@ describe('UpdateBoardParticipantsUseCase', () => { providers: [ UpdateBoardParticipantsUseCase, { - provide: BoardUsers.TYPES.services.CreateBoardUserService, + provide: CREATE_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.DeleteBoardUserService, + provide: DELETE_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() } ] }).compile(); useCase = module.get(UpdateBoardParticipantsUseCase); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); - createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); - deleteBoardUserServiceMock = module.get(BoardUsers.TYPES.services.DeleteBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); + createBoardUserServiceMock = module.get(CREATE_BOARD_USER_SERVICE); + deleteBoardUserServiceMock = module.get(DELETE_BOARD_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/boards/applications/update-board-participants.use-case.ts b/backend/src/modules/boards/applications/update-board-participants.use-case.ts index af456bb03..c7f01b330 100644 --- a/backend/src/modules/boards/applications/update-board-participants.use-case.ts +++ b/backend/src/modules/boards/applications/update-board-participants.use-case.ts @@ -2,13 +2,17 @@ import { Inject, Injectable } from '@nestjs/common'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import isEmpty from 'src/libs/utils/isEmpty'; +import { + CREATE_BOARD_USER_SERVICE, + DELETE_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; import BoardUserDto from 'src/modules/boardUsers/dto/board.user.dto'; import UpdateBoardUserDto from 'src/modules/boardUsers/dto/update-board-user.dto'; import BoardUser from 'src/modules/boardUsers/entities/board.user.schema'; import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; import { DeleteBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/delete.board.user.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import User from 'src/modules/users/entities/user.schema'; export type BoardParticipantsPresenter = BoardUser | BoardUser[]; @@ -18,11 +22,11 @@ export class UpdateBoardParticipantsUseCase implements UseCase { constructor( - @Inject(BoardUsers.TYPES.services.CreateBoardUserService) + @Inject(CREATE_BOARD_USER_SERVICE) private readonly createBoardUserService: CreateBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.DeleteBoardUserService) + @Inject(DELETE_BOARD_USER_SERVICE) private readonly deleteBoardUserService: DeleteBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) + @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface ) {} diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index ccfa77e9f..6156f9ec2 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Votes from 'src/modules/votes/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; @@ -27,6 +26,10 @@ import { UpdateBoardDto } from '../dto/update-board.dto'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { UpdateBoardUseCase } from './update-board.use-case'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; const regularBoard = BoardFactory.create({ isSubBoard: false, dividedBoards: [] }); const userId = faker.datatype.uuid(); @@ -111,11 +114,11 @@ describe('UpdateBoardUseCase', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -127,8 +130,8 @@ describe('UpdateBoardUseCase', () => { useCase = module.get(UpdateBoardUseCase); boardRepositoryMock = module.get(BOARD_REPOSITORY); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); - getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); + getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); deleteVoteServiceMock = module.get(Votes.TYPES.services.DeleteVoteService); slackCommunicationServiceMock = module.get( CommunicationsType.TYPES.services.SlackCommunicationService diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index 9af5fbf25..920b08f0d 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -7,7 +7,6 @@ import isEmpty from 'src/libs/utils/isEmpty'; import BoardUserDto from 'src/modules/boardUsers/dto/board.user.dto'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import ColumnDto from 'src/modules/columns/dto/column.dto'; import Column from 'src/modules/columns/entities/column.schema'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; @@ -20,15 +19,19 @@ import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; +import { + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; @Injectable() export class UpdateBoardUseCase implements UseCase { constructor( @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) + @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, @Inject(Votes.TYPES.services.DeleteVoteService) private readonly deleteVoteService: DeleteVoteServiceInterface, diff --git a/backend/src/modules/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 3dde6bd48..7f46af001 100644 --- a/backend/src/modules/boards/services/create.board.service.spec.ts +++ b/backend/src/modules/boards/services/create.board.service.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; @@ -33,6 +32,7 @@ import { TeamRoles } from 'src/libs/enum/team.roles'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { CREATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const userId: string = faker.datatype.uuid(); @@ -228,7 +228,7 @@ describe('CreateBoardService', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.CreateBoardUserService, + provide: CREATE_BOARD_USER_SERVICE, useValue: createMock() } ] @@ -236,7 +236,7 @@ describe('CreateBoardService', () => { boardService = module.get(CreateBoardService); boardRepositoryMock = module.get(BOARD_REPOSITORY); - createBoardUserServiceMock = module.get(BoardUsers.TYPES.services.CreateBoardUserService); + createBoardUserServiceMock = module.get(CREATE_BOARD_USER_SERVICE); getTeamServiceMock = module.get(GET_TEAM_SERVICE); getTeamUserServiceMock = module.get(GET_TEAM_USER_SERVICE); updateTeamUserServiceMock = module.get(UPDATE_TEAM_USER_SERVICE); diff --git a/backend/src/modules/boards/services/create.board.service.ts b/backend/src/modules/boards/services/create.board.service.ts index 467c13fc2..9e8422727 100644 --- a/backend/src/modules/boards/services/create.board.service.ts +++ b/backend/src/modules/boards/services/create.board.service.ts @@ -14,7 +14,6 @@ import * as CommunicationsType from 'src/modules/communication/interfaces/types' import { AddCronJobDto } from 'src/modules/schedules/dto/add.cronjob.dto'; import { CreateSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/create.schedules.service.interface'; import * as SchedulesType from 'src/modules/schedules/interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; import TeamUser from 'src/modules/teamUsers/entities/team.user.schema'; import User from 'src/modules/users/entities/user.schema'; @@ -38,6 +37,7 @@ import { CreateFailedException } from 'src/libs/exceptions/createFailedBadReques import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; import { GET_TEAM_USER_SERVICE, UPDATE_TEAM_USER_SERVICE } from 'src/modules/teamUsers/constants'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { CREATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; type CreateBoardAndUsers = { boardData: BoardDto; @@ -61,7 +61,7 @@ export default class CreateBoardService implements CreateBoardServiceInterface { private readonly slackCommunicationService: CommunicationServiceInterface, @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.CreateBoardUserService) + @Inject(CREATE_BOARD_USER_SERVICE) private readonly createBoardUserService: CreateBoardUserServiceInterface ) {} diff --git a/backend/src/modules/boards/services/delete.board.service.spec.ts b/backend/src/modules/boards/services/delete.board.service.spec.ts index 182557c0a..944660280 100644 --- a/backend/src/modules/boards/services/delete.board.service.spec.ts +++ b/backend/src/modules/boards/services/delete.board.service.spec.ts @@ -3,7 +3,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import * as Schedules from 'src/modules/schedules/interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BadRequestException } from '@nestjs/common'; @@ -13,6 +12,7 @@ import { DeleteBoardUserServiceInterface } from 'src/modules/boardUsers/interfac import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interfaces/services/delete.schedules.service.interface'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { DELETE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const boards = BoardFactory.createMany(2, [{ slackEnable: true }, { slackEnable: true }]); const board = BoardFactory.create({ @@ -45,7 +45,7 @@ describe('DeleteBoardService', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.DeleteBoardUserService, + provide: DELETE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -60,7 +60,7 @@ describe('DeleteBoardService', () => { }).compile(); service = module.get(deleteBoardService.provide); boardRepositoryMock = module.get(BOARD_REPOSITORY); - deleteBoardUserServiceMock = module.get(BoardUsers.TYPES.services.DeleteBoardUserService); + deleteBoardUserServiceMock = module.get(DELETE_BOARD_USER_SERVICE); deleteSchedulesServiceMock = module.get(Schedules.TYPES.services.DeleteSchedulesService); archiveChannelServiceMock = module.get( CommunicationTypes.TYPES.services.SlackArchiveChannelService diff --git a/backend/src/modules/boards/services/delete.board.service.ts b/backend/src/modules/boards/services/delete.board.service.ts index 683d50494..10723cd68 100644 --- a/backend/src/modules/boards/services/delete.board.service.ts +++ b/backend/src/modules/boards/services/delete.board.service.ts @@ -5,19 +5,19 @@ import { DeleteSchedulesServiceInterface } from 'src/modules/schedules/interface import * as Schedules from 'src/modules/schedules/interfaces/types'; import { DeleteBoardServiceInterface } from '../interfaces/services/delete.board.service.interface'; import Board from '../entities/board.schema'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as CommunicationTypes from 'src/modules/communication/interfaces/types'; import { ArchiveChannelServiceInterface } from 'src/modules/communication/interfaces/archive-channel.service.interface'; import { ArchiveChannelDataOptions } from 'src/modules/communication/dto/types'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; +import { DELETE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export default class DeleteBoardService implements DeleteBoardServiceInterface { constructor( @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.DeleteBoardUserService) + @Inject(DELETE_BOARD_USER_SERVICE) private readonly deleteBoardUserService: DeleteBoardUserServiceInterface, @Inject(Schedules.TYPES.services.DeleteSchedulesService) private readonly deleteScheduleService: DeleteSchedulesServiceInterface, diff --git a/backend/src/modules/boards/services/get.board.service.spec.ts b/backend/src/modules/boards/services/get.board.service.spec.ts index 8b4f7f9b1..0f8f5f7d7 100644 --- a/backend/src/modules/boards/services/get.board.service.spec.ts +++ b/backend/src/modules/boards/services/get.board.service.spec.ts @@ -1,26 +1,20 @@ import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; import { Test, TestingModule } from '@nestjs/testing'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; -import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; -import * as Users from 'src/modules/users/interfaces/types'; -import * as Auth from 'src/modules/auth/interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import faker from '@faker-js/faker'; import { BoardUserFactory } from 'src/libs/test-utils/mocks/factories/boardUser-factory.mock'; import { TeamFactory } from 'src/libs/test-utils/mocks/factories/team-factory.mock'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; -import { GetTokenAuthServiceInterface } from 'src/modules/auth/interfaces/services/get-token.auth.service.interface'; -import { UpdateUserServiceInterface } from 'src/modules/users/interfaces/services/update.user.service.interface'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; -import { CreateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/create.board.user.service.interface'; import { UserDtoFactory } from 'src/libs/test-utils/mocks/factories/dto/userDto-factory.mock'; import { NotFoundException } from '@nestjs/common'; import { hideVotesFromColumns } from '../utils/hideVotesFromColumns'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; import { BOARD_REPOSITORY } from 'src/modules/boards/constants'; import GetBoardService from 'src/modules/boards/services/get.board.service'; +import { GET_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const userId = faker.datatype.uuid(); const mainBoard = BoardFactory.create({ isSubBoard: false, isPublic: false }); @@ -47,36 +41,21 @@ describe('GetBoardService', () => { provide: GET_TEAM_SERVICE, useValue: createMock() }, + { - provide: BoardUsers.TYPES.services.CreateBoardUserService, - useValue: createMock() - }, - { - provide: Auth.TYPES.services.GetTokenAuthService, - useValue: createMock() - }, - { - provide: Users.TYPES.services.UpdateUserService, - useValue: createMock() - }, - { - provide: BoardUsers.TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useValue: createMock() }, { provide: BOARD_REPOSITORY, useValue: createMock() - }, - { - provide: SocketGateway, - useValue: createMock() } ] }).compile(); boardService = module.get(GetBoardService); boardRepositoryMock = module.get(BOARD_REPOSITORY); - getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); + getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getTeamServiceMock = module.get(GET_TEAM_SERVICE); }); diff --git a/backend/src/modules/boards/services/get.board.service.ts b/backend/src/modules/boards/services/get.board.service.ts index 7ab9cc10a..1499c31fe 100644 --- a/backend/src/modules/boards/services/get.board.service.ts +++ b/backend/src/modules/boards/services/get.board.service.ts @@ -2,7 +2,6 @@ import { GetBoardUserServiceInterface } from '../../boardUsers/interfaces/servic import { Inject, Injectable, NotFoundException, forwardRef } from '@nestjs/common'; import { BOARD_NOT_FOUND } from 'src/libs/exceptions/messages'; import { GetTeamServiceInterface } from 'src/modules/teams/interfaces/services/get.team.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { QueryType } from '../interfaces/findQuery'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import { cleanBoard } from '../utils/clean-board'; @@ -10,13 +9,14 @@ import { BOARD_REPOSITORY } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import UserDto from 'src/modules/users/dto/user.dto'; import { GET_TEAM_SERVICE } from 'src/modules/teams/constants'; +import { GET_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export default class GetBoardService implements GetBoardServiceInterface { constructor( @Inject(forwardRef(() => GET_TEAM_SERVICE)) private readonly getTeamService: GetTeamServiceInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, @Inject(BOARD_REPOSITORY) private readonly boardRepository: BoardRepositoryInterface diff --git a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts index a905af3b2..e848df678 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts @@ -5,13 +5,13 @@ import { TYPES } from '../interfaces/types'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { DeleteCardUseCase } from './delete-card.use-case'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import DeleteCardUseCaseDto from '../dto/useCase/delete-card.use-case.dto'; import faker from '@faker-js/faker'; import { BulkWriteResult, UpdateResult } from 'mongodb'; import { CardFactory } from 'src/libs/test-utils/mocks/factories/card-factory.mock'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const deleteCardMock: DeleteCardUseCaseDto = { boardId: faker.datatype.uuid(), @@ -52,7 +52,7 @@ describe('DeleteCardUseCase', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -63,7 +63,7 @@ describe('DeleteCardUseCase', () => { }).compile(); useCase = module.get>(DeleteCardUseCase); cardRepositoryMock = module.get(TYPES.repository.CardRepository); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); getCardServiceMock = module.get(TYPES.services.GetCardService); cardRepositoryMock.updateCardsFromBoard.mockResolvedValue(updateResult); getCardServiceMock.getCardFromBoard.mockResolvedValue(cardMock); diff --git a/backend/src/modules/cards/applications/delete-card.use-case.ts b/backend/src/modules/cards/applications/delete-card.use-case.ts index dd13cbd15..dad727753 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.ts @@ -4,7 +4,6 @@ import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import DeleteCardUseCaseDto from '../dto/useCase/delete-card.use-case.dto'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; import { CARD_NOT_FOUND, @@ -17,6 +16,7 @@ import { getUserWithVotes } from '../utils/get-user-with-votes'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { CardNotFoundException } from 'src/libs/exceptions/cardNotFoundException'; import isEmpty from 'src/libs/utils/isEmpty'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class DeleteCardUseCase implements UseCase { @@ -25,7 +25,7 @@ export class DeleteCardUseCase implements UseCase { private readonly getCardService: GetCardServiceInterface, @Inject(TYPES.repository.CardRepository) private readonly cardRepository: CardRepositoryInterface, - @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) + @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface ) {} diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts index ede9f48b4..ffa2c7ba5 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts @@ -4,7 +4,6 @@ import { CardRepositoryInterface } from '../repository/card.repository.interface import { TYPES } from '../interfaces/types'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import faker from '@faker-js/faker'; import { BulkWriteResult, UpdateResult } from 'mongodb'; import { CardFactory } from 'src/libs/test-utils/mocks/factories/card-factory.mock'; @@ -13,6 +12,7 @@ import { DeleteFromCardGroupUseCase } from './delete-from-card-group.use-case'; import DeleteFromCardGroupUseCaseDto from '../dto/useCase/delete-fom-card-group.use-case.dto'; import { CardItemFactory } from 'src/libs/test-utils/mocks/factories/cardItem-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; const deleteFromCardGroupMock: DeleteFromCardGroupUseCaseDto = { boardId: faker.datatype.uuid(), @@ -64,7 +64,7 @@ describe('DeleteFromCardGroupUseCase', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -75,7 +75,7 @@ describe('DeleteFromCardGroupUseCase', () => { }).compile(); useCase = module.get>(DeleteFromCardGroupUseCase); cardRepositoryMock = module.get(TYPES.repository.CardRepository); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); getCardServiceMock = module.get(TYPES.services.GetCardService); updateBoardUserServiceMock.updateManyUserVotes.mockResolvedValue( diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts index 52ae70994..ce4c648eb 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts @@ -12,7 +12,6 @@ import { } from 'src/libs/exceptions/messages'; import DeleteFromCardGroupUseCaseDto from '../dto/useCase/delete-fom-card-group.use-case.dto'; import CardItem from '../entities/card.item.schema'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { getUserWithVotes } from '../utils/get-user-with-votes'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; @@ -20,6 +19,7 @@ import Card from '../entities/card.schema'; import { CardNotFoundException } from 'src/libs/exceptions/cardNotFoundException'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { isEmpty } from 'class-validator'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class DeleteFromCardGroupUseCase implements UseCase { @@ -28,7 +28,7 @@ export class DeleteFromCardGroupUseCase implements UseCase { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() } ] diff --git a/backend/src/modules/votes/applications/card-group-vote.use-case.ts b/backend/src/modules/votes/applications/card-group-vote.use-case.ts index b4c49c8c2..e9ef415b0 100644 --- a/backend/src/modules/votes/applications/card-group-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-group-vote.use-case.ts @@ -1,6 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import { TYPES } from '../interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -15,6 +14,7 @@ import Card from 'src/modules/cards/entities/card.schema'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; import { arrayIdToString } from 'src/libs/utils/arrayIdToString'; import { getVotesFromCardItem } from '../utils/getVotesFromCardItem'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class CardGroupVoteUseCase implements UseCase { @@ -24,7 +24,7 @@ export class CardGroupVoteUseCase implements UseCase { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() } ] diff --git a/backend/src/modules/votes/applications/card-item-vote.use-case.ts b/backend/src/modules/votes/applications/card-item-vote.use-case.ts index a1cbefc54..409a752b2 100644 --- a/backend/src/modules/votes/applications/card-item-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-item-vote.use-case.ts @@ -1,6 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import { TYPES } from '../interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -12,6 +11,7 @@ import CardItemVoteUseCaseDto from '../dto/useCase/card-item-vote.use-case.dto'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { getVotesFromCardItem } from '../utils/getVotesFromCardItem'; import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; +import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class CardItemVoteUseCase implements UseCase { @@ -23,7 +23,7 @@ export class CardItemVoteUseCase implements UseCase { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -54,9 +57,9 @@ describe('CreateVoteService', () => { }).compile(); voteService = module.get(CreateVoteService); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); - getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); + getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getBoardServiceMock = module.get(GET_BOARD_SERVICE); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/votes/services/create.vote.service.ts b/backend/src/modules/votes/services/create.vote.service.ts index b97dcbf55..303db0a32 100644 --- a/backend/src/modules/votes/services/create.vote.service.ts +++ b/backend/src/modules/votes/services/create.vote.service.ts @@ -2,19 +2,22 @@ import { GetBoardUserServiceInterface } from '../../boardUsers/interfaces/servic import { Inject, Injectable, NotFoundException } from '@nestjs/common'; import { BOARD_NOT_FOUND, INSERT_VOTE_FAILED } from 'src/libs/exceptions/messages'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { InsertFailedException } from 'src/libs/exceptions/insertFailedBadRequestException'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; @Injectable() export default class CreateVoteService implements CreateVoteServiceInterface { constructor( - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) + @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 46d3501d6..8167db99e 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import * as Cards from 'src/modules/cards/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; @@ -23,6 +22,10 @@ import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadRequestException'; import { CardItemFactory } from 'src/libs/test-utils/mocks/factories/cardItem-factory.mock'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; const userId: string = faker.datatype.uuid(); const board: Board = BoardFactory.create({ maxVotes: 3 }); @@ -48,11 +51,11 @@ describe('DeleteVoteService', () => { useValue: createMock() }, { - provide: BoardUsers.TYPES.services.GetBoardUserService, + provide: GET_BOARD_USER_SERVICE, useValue: createMock() }, { - provide: BoardUsers.TYPES.services.UpdateBoardUserService, + provide: UPDATE_BOARD_USER_SERVICE, useValue: createMock() }, { @@ -68,9 +71,9 @@ describe('DeleteVoteService', () => { voteService = module.get(DeleteVoteService); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); getBoardServiceMock = module.get(GET_BOARD_SERVICE); - getBoardUserServiceMock = module.get(BoardUsers.TYPES.services.GetBoardUserService); + getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getCardServiceMock = module.get(Cards.TYPES.services.GetCardService); - updateBoardUserServiceMock = module.get(BoardUsers.TYPES.services.UpdateBoardUserService); + updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 022071240..6a67bbd97 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -5,7 +5,6 @@ import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/g import * as Cards from 'src/modules/cards/interfaces/types'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { TYPES } from '../interfaces/types'; -import * as BoardUsers from 'src/modules/boardUsers/interfaces/types'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -19,15 +18,19 @@ import { } from 'src/modules/cards/utils/get-user-with-votes'; import { votesArrayVerification } from '../utils/votesArrayVerification'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { + GET_BOARD_USER_SERVICE, + UPDATE_BOARD_USER_SERVICE +} from 'src/modules/boardUsers/constants'; @Injectable() export default class DeleteVoteService implements DeleteVoteServiceInterface { constructor( @Inject(TYPES.repositories.VoteRepository) private readonly voteRepository: VoteRepositoryInterface, - @Inject(BoardUsers.TYPES.services.GetBoardUserService) + @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, - @Inject(BoardUsers.TYPES.services.UpdateBoardUserService) + @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, @Inject(Cards.TYPES.services.GetCardService) private readonly getCardService: GetCardServiceInterface, From 0a98951c7482fc4db8d486f2c0f9ba90a0eaacc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Thu, 20 Apr 2023 17:29:10 +0100 Subject: [PATCH 11/14] refactor: change filename to constants --- .../applications/create-card.use-case.spec.ts | 2 +- .../applications/create-card.use-case.ts | 2 +- .../applications/delete-card.use-case.spec.ts | 2 +- .../applications/delete-card.use-case.ts | 2 +- .../delete-from-card-group.use-case.spec.ts | 2 +- .../delete-from-card-group.use-case.ts | 2 +- .../applications/merge-card.use-case.spec.ts | 2 +- .../cards/applications/merge-card.use-case.ts | 2 +- .../unmerge-card.use-case.spec.ts | 2 +- .../applications/unmerge-card.use-case.ts | 2 +- .../update-card-group-text.use-case.spec.ts | 2 +- .../update/update-card-group-text.use-case.ts | 2 +- .../update-card-position.use-case.spec.ts | 2 +- .../update/update-card-position.use-case.ts | 2 +- .../update/update-card-text.use-case.spec.ts | 2 +- .../update/update-card-text.use-case.ts | 2 +- backend/src/modules/cards/cards.providers.ts | 10 +++- backend/src/modules/cards/constants.ts | 47 +++++++++++++++++++ .../cards/controller/cards.controller.ts | 2 +- backend/src/modules/cards/interfaces/types.ts | 19 -------- .../cards/services/get.card.service.spec.ts | 2 +- .../cards/services/get.card.service.ts | 2 +- .../services/delete.vote.service.spec.ts | 2 +- .../votes/services/delete.vote.service.ts | 2 +- 24 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 backend/src/modules/cards/constants.ts delete mode 100644 backend/src/modules/cards/interfaces/types.ts diff --git a/backend/src/modules/cards/applications/create-card.use-case.spec.ts b/backend/src/modules/cards/applications/create-card.use-case.spec.ts index d91038ea9..914a0da11 100644 --- a/backend/src/modules/cards/applications/create-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/create-card.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/cards/applications/create-card.use-case.ts b/backend/src/modules/cards/applications/create-card.use-case.ts index 961c0b59b..3471d127f 100644 --- a/backend/src/modules/cards/applications/create-card.use-case.ts +++ b/backend/src/modules/cards/applications/create-card.use-case.ts @@ -1,5 +1,5 @@ import { BadRequestException, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import CreateCardUseCaseDto from '../dto/useCase/create-card.use-case.dto'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; diff --git a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts index e848df678..953306464 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { DeleteCardUseCase } from './delete-card.use-case'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; diff --git a/backend/src/modules/cards/applications/delete-card.use-case.ts b/backend/src/modules/cards/applications/delete-card.use-case.ts index dad727753..33c9655fc 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import DeleteCardUseCaseDto from '../dto/useCase/delete-card.use-case.dto'; diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts index ffa2c7ba5..4acc85077 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts index ce4c648eb..c0040b132 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; diff --git a/backend/src/modules/cards/applications/merge-card.use-case.spec.ts b/backend/src/modules/cards/applications/merge-card.use-case.spec.ts index 3476864d4..cf27deca6 100644 --- a/backend/src/modules/cards/applications/merge-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/merge-card.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import MergeCardUseCaseDto from '../dto/useCase/merge-card.use-case.dto'; import faker from '@faker-js/faker'; diff --git a/backend/src/modules/cards/applications/merge-card.use-case.ts b/backend/src/modules/cards/applications/merge-card.use-case.ts index 6c0ad2597..8f1bf4442 100644 --- a/backend/src/modules/cards/applications/merge-card.use-case.ts +++ b/backend/src/modules/cards/applications/merge-card.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import MergeCardUseCaseDto from '../dto/useCase/merge-card.use-case.dto'; import { CARD_NOT_FOUND, CARD_NOT_REMOVED, UPDATE_FAILED } from 'src/libs/exceptions/messages'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; diff --git a/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts b/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts index 440dea056..80fb297fe 100644 --- a/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; diff --git a/backend/src/modules/cards/applications/unmerge-card.use-case.ts b/backend/src/modules/cards/applications/unmerge-card.use-case.ts index 10ec1c82c..60ae71799 100644 --- a/backend/src/modules/cards/applications/unmerge-card.use-case.ts +++ b/backend/src/modules/cards/applications/unmerge-card.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; diff --git a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts index f6468efef..90941b091 100644 --- a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts index 3c290dcf1..d98251196 100644 --- a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; diff --git a/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts index 75a340f9d..a21d599a6 100644 --- a/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/cards/applications/update/update-card-position.use-case.ts b/backend/src/modules/cards/applications/update/update-card-position.use-case.ts index 24fe5fd51..4cd63e05c 100644 --- a/backend/src/modules/cards/applications/update/update-card-position.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-position.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { GetCardServiceInterface } from '../../interfaces/services/get.card.service.interface'; import { diff --git a/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts index dc99e7d0c..2883a5fce 100644 --- a/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/cards/applications/update/update-card-text.use-case.ts b/backend/src/modules/cards/applications/update/update-card-text.use-case.ts index 341c7d365..32de89e72 100644 --- a/backend/src/modules/cards/applications/update/update-card-text.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-text.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../../interfaces/types'; +import { TYPES } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import UpdateCardTextUseCaseDto from '../../dto/useCase/update-card-text.use-case.dto'; diff --git a/backend/src/modules/cards/cards.providers.ts b/backend/src/modules/cards/cards.providers.ts index 825d6bfc4..4c95c02be 100644 --- a/backend/src/modules/cards/cards.providers.ts +++ b/backend/src/modules/cards/cards.providers.ts @@ -3,23 +3,29 @@ import { DeleteCardUseCase } from './applications/delete-card.use-case'; import { DeleteFromCardGroupUseCase } from './applications/delete-from-card-group.use-case'; import { UnmergeCardUseCase } from './applications/unmerge-card.use-case'; import { MergeCardUseCase } from './applications/merge-card.use-case'; -import { TYPES } from './interfaces/types'; +import { GET_CARD_SERVICE, TYPES } from './constants'; import { CardRepository } from './repository/card.repository'; import GetCardService from './services/get.card.service'; import { UpdateCardPositionUseCase } from './applications/update/update-card-position.use-case'; import { UpdateCardTextUseCase } from './applications/update/update-card-text.use-case'; import { UpdateCardGroupTextUseCase } from './applications/update/update-card-group-text.use-case'; +/* SERVICE */ + export const getCardService = { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useClass: GetCardService }; +/* REPOSITORY */ + export const cardRepository = { provide: TYPES.repository.CardRepository, useClass: CardRepository }; +/* USE CASES */ + export const createCardUseCase = { provide: TYPES.applications.CreateCardUseCase, useClass: CreateCardUseCase diff --git a/backend/src/modules/cards/constants.ts b/backend/src/modules/cards/constants.ts new file mode 100644 index 000000000..3d9342d2d --- /dev/null +++ b/backend/src/modules/cards/constants.ts @@ -0,0 +1,47 @@ +export const TYPES = { + services: { + //GetCardService: 'GetCardService', + DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' + }, + applications: { + CreateCardUseCase: 'CreateCardUseCase', + UnmergeCardUseCase: 'UnmergeCardUseCase', + MergeCardUseCase: 'MergeCardUseCase', + UpdateCardPositionUseCase: 'UpdateCardPositionUseCase', + UpdateCardTextUseCase: 'UpdateCardTextUseCase', + UpdateCardGroupTextUseCase: 'UpdateCardGroupTextUseCase', + DeleteCardUseCase: 'DeleteCardUseCase', + DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' + }, + repository: { + CardRepository: 'CardRepository' + } +}; + +/* SERVICE */ + +export const GET_CARD_SERVICE = 'GetCardService'; + +/* USE CASES */ + +export const DELETE_FROM_CARD_GROUP_USE_CASE = 'DeleteFromCardGroupUseCase'; + +export const CREATE_CARD_USE_CASE = 'CreateCardUseCase'; + +export const UNMERGE_CARD_USE_CASE = 'UnmergeCardUseCase'; + +export const MERGE_CARD_USE_CASE = 'MergeCardUseCase'; + +export const UPDATE_CARD_POSITION_USE_CASE = 'UpdateCardPositionUseCase'; + +export const UPDATE_CARD_TEXT_USE_CASE = 'UpdateCardTextUseCase'; + +export const UPDATE_CARD_GROUP_TEXT_USE_CASE = 'UpdateCardGroupTextUseCase'; + +export const DELETE_CARD_USE_CASE = 'DeleteCardUseCase'; + +export const DELETE_CARD_FROM_GROUP_USE_CASE = 'DeleteCardFromGroupUseCase'; + +/* REPOSITORY */ + +export const CARD_REPOSITORY = 'CardRepository'; diff --git a/backend/src/modules/cards/controller/cards.controller.ts b/backend/src/modules/cards/controller/cards.controller.ts index 7d338e254..79112d1f2 100644 --- a/backend/src/modules/cards/controller/cards.controller.ts +++ b/backend/src/modules/cards/controller/cards.controller.ts @@ -39,7 +39,7 @@ import DeleteCardDto from '../dto/delete.card.dto'; import UnmergeCardsDto from '../dto/unmerge.dto'; import UpdateCardDto from '../dto/update.card.dto'; import { UpdateCardPositionDto } from '../dto/update-position.card.dto'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { MergeCardDto } from '../dto/group/merge.card.dto'; import CreateCardUseCaseDto from '../dto/useCase/create-card.use-case.dto'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; diff --git a/backend/src/modules/cards/interfaces/types.ts b/backend/src/modules/cards/interfaces/types.ts deleted file mode 100644 index 598102d7f..000000000 --- a/backend/src/modules/cards/interfaces/types.ts +++ /dev/null @@ -1,19 +0,0 @@ -export const TYPES = { - services: { - GetCardService: 'GetCardService', - DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' - }, - applications: { - CreateCardUseCase: 'CreateCardUseCase', - UnmergeCardUseCase: 'UnmergeCardUseCase', - MergeCardUseCase: 'MergeCardUseCase', - UpdateCardPositionUseCase: 'UpdateCardPositionUseCase', - UpdateCardTextUseCase: 'UpdateCardTextUseCase', - UpdateCardGroupTextUseCase: 'UpdateCardGroupTextUseCase', - DeleteCardUseCase: 'DeleteCardUseCase', - DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' - }, - repository: { - CardRepository: 'CardRepository' - } -}; diff --git a/backend/src/modules/cards/services/get.card.service.spec.ts b/backend/src/modules/cards/services/get.card.service.spec.ts index af4a42a0e..fb7d429b1 100644 --- a/backend/src/modules/cards/services/get.card.service.spec.ts +++ b/backend/src/modules/cards/services/get.card.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; diff --git a/backend/src/modules/cards/services/get.card.service.ts b/backend/src/modules/cards/services/get.card.service.ts index df4a48a19..832cf1ec6 100644 --- a/backend/src/modules/cards/services/get.card.service.ts +++ b/backend/src/modules/cards/services/get.card.service.ts @@ -1,7 +1,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { isEmpty } from 'class-validator'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; -import * as Cards from 'src/modules/cards/interfaces/types'; +import * as Cards from 'src/modules/cards/constants'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; @Injectable() diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 8167db99e..3212ce6ad 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; -import * as Cards from 'src/modules/cards/interfaces/types'; +import * as Cards from 'src/modules/cards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 6a67bbd97..6e124cf80 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import { DELETE_VOTE_FAILED, UPDATE_FAILED } from 'src/libs/exceptions/messages'; import isEmpty from 'src/libs/utils/isEmpty'; import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/get.card.service.interface'; -import * as Cards from 'src/modules/cards/interfaces/types'; +import * as Cards from 'src/modules/cards/constants'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { TYPES } from '../interfaces/types'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; From b1d4046e70560f43da3ebe532b71fbbc65b8d248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Thu, 20 Apr 2023 18:04:44 +0100 Subject: [PATCH 12/14] refactor: change TYPES for CONSTANTS (cards) --- .../applications/create-card.use-case.spec.ts | 14 ++++---- .../applications/create-card.use-case.ts | 4 +-- .../applications/delete-card.use-case.spec.ts | 12 +++---- .../applications/delete-card.use-case.ts | 6 ++-- .../delete-from-card-group.use-case.spec.ts | 12 +++---- .../delete-from-card-group.use-case.ts | 6 ++-- .../applications/merge-card.use-case.spec.ts | 18 +++++----- .../cards/applications/merge-card.use-case.ts | 6 ++-- .../unmerge-card.use-case.spec.ts | 18 +++++----- .../applications/unmerge-card.use-case.ts | 6 ++-- .../update-card-group-text.use-case.spec.ts | 14 ++++---- .../update/update-card-group-text.use-case.ts | 4 +-- .../update-card-position.use-case.spec.ts | 18 +++++----- .../update/update-card-position.use-case.ts | 6 ++-- .../update/update-card-text.use-case.spec.ts | 14 ++++---- .../update/update-card-text.use-case.ts | 4 +-- backend/src/modules/cards/cards.module.ts | 4 +-- backend/src/modules/cards/cards.providers.ts | 33 ++++++++++++------- backend/src/modules/cards/constants.ts | 22 ++++++------- .../cards/controller/cards.controller.ts | 31 ++++++++++------- .../cards/services/get.card.service.spec.ts | 8 ++--- .../cards/services/get.card.service.ts | 4 +-- .../services/delete.vote.service.spec.ts | 8 ++--- .../votes/services/delete.vote.service.ts | 4 +-- 24 files changed, 141 insertions(+), 135 deletions(-) diff --git a/backend/src/modules/cards/applications/create-card.use-case.spec.ts b/backend/src/modules/cards/applications/create-card.use-case.spec.ts index 914a0da11..10298895d 100644 --- a/backend/src/modules/cards/applications/create-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/create-card.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import faker from '@faker-js/faker'; @@ -14,7 +14,7 @@ import User from 'src/modules/users/entities/user.schema'; import { BadRequestException, HttpException } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import CardCreationPresenter from '../dto/useCase/presenters/create-card-res.use-case.dto'; -import { createCardUseCase } from '../cards.providers'; +import { CreateCardUseCase } from 'src/modules/cards/applications/create-card.use-case'; //Create Card Items Mocks const cardIdtemDto = CardItemDtoFactory.create({ text: 'New Card', comments: [] }); @@ -54,17 +54,15 @@ describe('CreateCardUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - createCardUseCase, + CreateCardUseCase, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.CreateCardUseCase - ); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(CreateCardUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); }); beforeEach(() => { diff --git a/backend/src/modules/cards/applications/create-card.use-case.ts b/backend/src/modules/cards/applications/create-card.use-case.ts index 3471d127f..fc6c64bcc 100644 --- a/backend/src/modules/cards/applications/create-card.use-case.ts +++ b/backend/src/modules/cards/applications/create-card.use-case.ts @@ -1,5 +1,5 @@ import { BadRequestException, HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import CreateCardUseCaseDto from '../dto/useCase/create-card.use-case.dto'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; @@ -15,7 +15,7 @@ import CardDto from '../dto/card.dto'; @Injectable() export class CreateCardUseCase implements UseCase { constructor( - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} diff --git a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts index 953306464..a62ae7b55 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { DeleteCardUseCase } from './delete-card.use-case'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -48,7 +48,7 @@ describe('DeleteCardUseCase', () => { providers: [ DeleteCardUseCase, { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { @@ -56,15 +56,15 @@ describe('DeleteCardUseCase', () => { useValue: createMock() }, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>(DeleteCardUseCase); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(DeleteCardUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); - getCardServiceMock = module.get(TYPES.services.GetCardService); + getCardServiceMock = module.get(GET_CARD_SERVICE); cardRepositoryMock.updateCardsFromBoard.mockResolvedValue(updateResult); getCardServiceMock.getCardFromBoard.mockResolvedValue(cardMock); updateBoardUserServiceMock.updateManyUserVotes.mockResolvedValue( diff --git a/backend/src/modules/cards/applications/delete-card.use-case.ts b/backend/src/modules/cards/applications/delete-card.use-case.ts index 33c9655fc..2ad9ff289 100644 --- a/backend/src/modules/cards/applications/delete-card.use-case.ts +++ b/backend/src/modules/cards/applications/delete-card.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import DeleteCardUseCaseDto from '../dto/useCase/delete-card.use-case.dto'; @@ -21,9 +21,9 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class DeleteCardUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly getCardService: GetCardServiceInterface, - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface, @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts index 4acc85077..5ff607a0d 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import faker from '@faker-js/faker'; @@ -60,7 +60,7 @@ describe('DeleteFromCardGroupUseCase', () => { providers: [ DeleteFromCardGroupUseCase, { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { @@ -68,15 +68,15 @@ describe('DeleteFromCardGroupUseCase', () => { useValue: createMock() }, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>(DeleteFromCardGroupUseCase); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(DeleteFromCardGroupUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); - getCardServiceMock = module.get(TYPES.services.GetCardService); + getCardServiceMock = module.get(GET_CARD_SERVICE); updateBoardUserServiceMock.updateManyUserVotes.mockResolvedValue( bulkWriteResult as unknown as BulkWriteResult diff --git a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts index c0040b132..70403a2b5 100644 --- a/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts +++ b/backend/src/modules/cards/applications/delete-from-card-group.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; @@ -24,9 +24,9 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; @Injectable() export class DeleteFromCardGroupUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly getCardService: GetCardServiceInterface, - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface, @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface diff --git a/backend/src/modules/cards/applications/merge-card.use-case.spec.ts b/backend/src/modules/cards/applications/merge-card.use-case.spec.ts index cf27deca6..624082a02 100644 --- a/backend/src/modules/cards/applications/merge-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/merge-card.use-case.spec.ts @@ -1,7 +1,7 @@ import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { Test, TestingModule } from '@nestjs/testing'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import MergeCardUseCaseDto from '../dto/useCase/merge-card.use-case.dto'; import faker from '@faker-js/faker'; @@ -10,7 +10,7 @@ import { CardFactory } from 'src/libs/test-utils/mocks/factories/card-factory.mo import { UpdateResult } from 'mongodb'; import { CardItemFactory } from 'src/libs/test-utils/mocks/factories/cardItem-factory.mock'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { mergeCardUseCase } from '../cards.providers'; +import { MergeCardUseCase } from 'src/modules/cards/applications/merge-card.use-case'; const mergeCardDtoMock: MergeCardUseCaseDto = { boardId: faker.datatype.uuid(), @@ -36,22 +36,20 @@ describe('MergeCardUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - mergeCardUseCase, + MergeCardUseCase, { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.MergeCardUseCase - ); - getCardServiceMock = module.get(TYPES.services.GetCardService); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(MergeCardUseCase); + getCardServiceMock = module.get(GET_CARD_SERVICE); + cardRepositoryMock = module.get(CARD_REPOSITORY); getCardServiceMock.getCardFromBoard .mockResolvedValue(cardMock[0]) diff --git a/backend/src/modules/cards/applications/merge-card.use-case.ts b/backend/src/modules/cards/applications/merge-card.use-case.ts index 8f1bf4442..a908fcef7 100644 --- a/backend/src/modules/cards/applications/merge-card.use-case.ts +++ b/backend/src/modules/cards/applications/merge-card.use-case.ts @@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import MergeCardUseCaseDto from '../dto/useCase/merge-card.use-case.dto'; import { CARD_NOT_FOUND, CARD_NOT_REMOVED, UPDATE_FAILED } from 'src/libs/exceptions/messages'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; @@ -10,9 +10,9 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques @Injectable() export class MergeCardUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly getCardService: GetCardServiceInterface, - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} diff --git a/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts b/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts index 80fb297fe..567c323c6 100644 --- a/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts +++ b/backend/src/modules/cards/applications/unmerge-card.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; @@ -9,7 +9,7 @@ import { CardFactory } from 'src/libs/test-utils/mocks/factories/card-factory.mo import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { BadRequestException } from '@nestjs/common'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { unmergeCardUseCase } from '../cards.providers'; +import { UnmergeCardUseCase } from 'src/modules/cards/applications/unmerge-card.use-case'; const unmergeCardDto: UnmergeCardUseCaseDto = { boardId: faker.datatype.uuid(), @@ -37,22 +37,20 @@ describe('UnmergeCardUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - unmergeCardUseCase, + UnmergeCardUseCase, { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.UnmergeCardUseCase - ); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); - cardServiceMock = module.get(TYPES.services.GetCardService); + useCase = module.get(UnmergeCardUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); + cardServiceMock = module.get(GET_CARD_SERVICE); cardServiceMock.getCardItemFromGroup.mockResolvedValue(cardMock); cardServiceMock.getCardFromBoard.mockResolvedValue(cardMock); cardRepositoryMock.pullItem.mockResolvedValue(updateResultMock); diff --git a/backend/src/modules/cards/applications/unmerge-card.use-case.ts b/backend/src/modules/cards/applications/unmerge-card.use-case.ts index 60ae71799..4e9e1d861 100644 --- a/backend/src/modules/cards/applications/unmerge-card.use-case.ts +++ b/backend/src/modules/cards/applications/unmerge-card.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable } from '@nestjs/common'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; @@ -15,9 +15,9 @@ import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadReques @Injectable() export class UnmergeCardUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly cardService: GetCardServiceInterface, - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} diff --git a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts index 90941b091..c5adc12b1 100644 --- a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.spec.ts @@ -1,15 +1,15 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { updateCardGroupTextUseCase } from '../../cards.providers'; import faker from '@faker-js/faker'; import { UpdateResult } from 'mongodb'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { Logger } from '@nestjs/common'; import UpdateCardGroupTextUseCaseDto from '../../dto/useCase/update-card-group-text.use-case.dto'; +import { UpdateCardGroupTextUseCase } from 'src/modules/cards/applications/update/update-card-group-text.use-case'; const updateCardGroupTextDto: UpdateCardGroupTextUseCaseDto = { boardId: faker.datatype.uuid(), @@ -38,17 +38,15 @@ describe('UpdateCardGroupTextUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - updateCardGroupTextUseCase, + UpdateCardGroupTextUseCase, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.UpdateCardGroupTextUseCase - ); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(UpdateCardGroupTextUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); cardRepositoryMock.updateCardGroupText.mockResolvedValue(board); jest.spyOn(Logger.prototype, 'error').mockImplementation(jest.fn); diff --git a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts index d98251196..c82b6ea22 100644 --- a/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-group-text.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; @@ -9,7 +9,7 @@ import UpdateCardGroupTextUseCaseDto from '../../dto/useCase/update-card-group-t @Injectable() export class UpdateCardGroupTextUseCase implements UseCase { constructor( - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} private logger = new Logger(UpdateCardGroupTextUseCase.name); diff --git a/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts index a21d599a6..2ea3ee06e 100644 --- a/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-position.use-case.spec.ts @@ -1,9 +1,8 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { updateCardPositionUseCase } from '../../cards.providers'; import UpdateCardPositionUseCaseDto from '../../dto/useCase/update-card-position.use-case.dto'; import { GetCardServiceInterface } from '../../interfaces/services/get.card.service.interface'; import faker from '@faker-js/faker'; @@ -12,6 +11,7 @@ import { UpdateResult } from 'mongodb'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { Logger } from '@nestjs/common'; +import { UpdateCardPositionUseCase } from 'src/modules/cards/applications/update/update-card-position.use-case'; const updateCardPosition: UpdateCardPositionUseCaseDto = { boardId: faker.datatype.uuid(), @@ -41,22 +41,20 @@ describe('UpdateCardPositionUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - updateCardPositionUseCase, + UpdateCardPositionUseCase, { - provide: TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.UpdateCardPositionUseCase - ); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); - getCardServiceMock = module.get(TYPES.services.GetCardService); + useCase = module.get(UpdateCardPositionUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); + getCardServiceMock = module.get(GET_CARD_SERVICE); getCardServiceMock.getCardFromBoard.mockResolvedValue(card); cardRepositoryMock.pushCard.mockResolvedValue(board); diff --git a/backend/src/modules/cards/applications/update/update-card-position.use-case.ts b/backend/src/modules/cards/applications/update/update-card-position.use-case.ts index 4cd63e05c..7485fa45f 100644 --- a/backend/src/modules/cards/applications/update/update-card-position.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-position.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY, GET_CARD_SERVICE } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { GetCardServiceInterface } from '../../interfaces/services/get.card.service.interface'; import { @@ -17,9 +17,9 @@ import { DeleteFailedException } from 'src/libs/exceptions/deleteFailedBadReques @Injectable() export class UpdateCardPositionUseCase implements UseCase { constructor( - @Inject(TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly cardService: GetCardServiceInterface, - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} private logger = new Logger(UpdateCardPositionUseCase.name); diff --git a/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts b/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts index 2883a5fce..81957e0b6 100644 --- a/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts +++ b/backend/src/modules/cards/applications/update/update-card-text.use-case.spec.ts @@ -1,15 +1,15 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY } from '../../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; -import { updateCardTextUseCase } from '../../cards.providers'; import faker from '@faker-js/faker'; import { UpdateResult } from 'mongodb'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import { UpdateFailedException } from 'src/libs/exceptions/updateFailedBadRequestException'; import { Logger } from '@nestjs/common'; import UpdateCardTextUseCaseDto from '../../dto/useCase/update-card-text.use-case.dto'; +import { UpdateCardTextUseCase } from 'src/modules/cards/applications/update/update-card-text.use-case'; const updateCardTextDto: UpdateCardTextUseCaseDto = { boardId: faker.datatype.uuid(), @@ -39,17 +39,15 @@ describe('UpdateCardTextUseCase', () => { beforeAll(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ - updateCardTextUseCase, + UpdateCardTextUseCase, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - useCase = module.get>( - TYPES.applications.UpdateCardTextUseCase - ); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + useCase = module.get(UpdateCardTextUseCase); + cardRepositoryMock = module.get(CARD_REPOSITORY); cardRepositoryMock.updateCardText.mockResolvedValue(board); jest.spyOn(Logger.prototype, 'error').mockImplementation(jest.fn); diff --git a/backend/src/modules/cards/applications/update/update-card-text.use-case.ts b/backend/src/modules/cards/applications/update/update-card-text.use-case.ts index 32de89e72..5026848e7 100644 --- a/backend/src/modules/cards/applications/update/update-card-text.use-case.ts +++ b/backend/src/modules/cards/applications/update/update-card-text.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../../constants'; +import { CARD_REPOSITORY } from '../../constants'; import { CardRepositoryInterface } from '../../repository/card.repository.interface'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import UpdateCardTextUseCaseDto from '../../dto/useCase/update-card-text.use-case.dto'; @@ -9,7 +9,7 @@ import { UPDATE_FAILED } from 'src/libs/exceptions/messages'; @Injectable() export class UpdateCardTextUseCase implements UseCase { constructor( - @Inject(TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} diff --git a/backend/src/modules/cards/cards.module.ts b/backend/src/modules/cards/cards.module.ts index b965f3fa1..4be12d863 100644 --- a/backend/src/modules/cards/cards.module.ts +++ b/backend/src/modules/cards/cards.module.ts @@ -6,8 +6,8 @@ import { VotesModule } from '../votes/votes.module'; import { cardRepository, createCardUseCase, + deleteCardFromGroupUseCase, deleteCardUseCase, - deleteFromCardGroupUseCase, getCardService, mergeCardUseCase, unmergeCardUseCase, @@ -35,7 +35,7 @@ import CardsController from './controller/cards.controller'; updateCardTextUseCase, updateCardGroupTextUseCase, deleteCardUseCase, - deleteFromCardGroupUseCase + deleteCardFromGroupUseCase ], exports: [getCardService] }) diff --git a/backend/src/modules/cards/cards.providers.ts b/backend/src/modules/cards/cards.providers.ts index 4c95c02be..91a4ac658 100644 --- a/backend/src/modules/cards/cards.providers.ts +++ b/backend/src/modules/cards/cards.providers.ts @@ -3,7 +3,18 @@ import { DeleteCardUseCase } from './applications/delete-card.use-case'; import { DeleteFromCardGroupUseCase } from './applications/delete-from-card-group.use-case'; import { UnmergeCardUseCase } from './applications/unmerge-card.use-case'; import { MergeCardUseCase } from './applications/merge-card.use-case'; -import { GET_CARD_SERVICE, TYPES } from './constants'; +import { + CARD_REPOSITORY, + CREATE_CARD_USE_CASE, + DELETE_CARD_FROM_GROUP_USE_CASE, + DELETE_CARD_USE_CASE, + GET_CARD_SERVICE, + MERGE_CARD_USE_CASE, + UNMERGE_CARD_USE_CASE, + UPDATE_CARD_GROUP_TEXT_USE_CASE, + UPDATE_CARD_POSITION_USE_CASE, + UPDATE_CARD_TEXT_USE_CASE +} from './constants'; import { CardRepository } from './repository/card.repository'; import GetCardService from './services/get.card.service'; import { UpdateCardPositionUseCase } from './applications/update/update-card-position.use-case'; @@ -20,48 +31,48 @@ export const getCardService = { /* REPOSITORY */ export const cardRepository = { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useClass: CardRepository }; /* USE CASES */ export const createCardUseCase = { - provide: TYPES.applications.CreateCardUseCase, + provide: CREATE_CARD_USE_CASE, useClass: CreateCardUseCase }; export const mergeCardUseCase = { - provide: TYPES.applications.MergeCardUseCase, + provide: MERGE_CARD_USE_CASE, useClass: MergeCardUseCase }; export const deleteCardUseCase = { - provide: TYPES.applications.DeleteCardUseCase, + provide: DELETE_CARD_USE_CASE, useClass: DeleteCardUseCase }; -export const deleteFromCardGroupUseCase = { - provide: TYPES.applications.DeleteFromCardGroupUseCase, +export const deleteCardFromGroupUseCase = { + provide: DELETE_CARD_FROM_GROUP_USE_CASE, useClass: DeleteFromCardGroupUseCase }; export const unmergeCardUseCase = { - provide: TYPES.applications.UnmergeCardUseCase, + provide: UNMERGE_CARD_USE_CASE, useClass: UnmergeCardUseCase }; export const updateCardPositionUseCase = { - provide: TYPES.applications.UpdateCardPositionUseCase, + provide: UPDATE_CARD_POSITION_USE_CASE, useClass: UpdateCardPositionUseCase }; export const updateCardTextUseCase = { - provide: TYPES.applications.UpdateCardTextUseCase, + provide: UPDATE_CARD_TEXT_USE_CASE, useClass: UpdateCardTextUseCase }; export const updateCardGroupTextUseCase = { - provide: TYPES.applications.UpdateCardGroupTextUseCase, + provide: UPDATE_CARD_GROUP_TEXT_USE_CASE, useClass: UpdateCardGroupTextUseCase }; diff --git a/backend/src/modules/cards/constants.ts b/backend/src/modules/cards/constants.ts index 3d9342d2d..31874663a 100644 --- a/backend/src/modules/cards/constants.ts +++ b/backend/src/modules/cards/constants.ts @@ -1,20 +1,20 @@ export const TYPES = { services: { //GetCardService: 'GetCardService', - DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' + //DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' }, applications: { - CreateCardUseCase: 'CreateCardUseCase', - UnmergeCardUseCase: 'UnmergeCardUseCase', - MergeCardUseCase: 'MergeCardUseCase', - UpdateCardPositionUseCase: 'UpdateCardPositionUseCase', - UpdateCardTextUseCase: 'UpdateCardTextUseCase', - UpdateCardGroupTextUseCase: 'UpdateCardGroupTextUseCase', - DeleteCardUseCase: 'DeleteCardUseCase', - DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' + //CreateCardUseCase: 'CreateCardUseCase', + //UnmergeCardUseCase: 'UnmergeCardUseCase', + //MergeCardUseCase: 'MergeCardUseCase', + //UpdateCardPositionUseCase: 'UpdateCardPositionUseCase', + //UpdateCardTextUseCase: 'UpdateCardTextUseCase', + //UpdateCardGroupTextUseCase: 'UpdateCardGroupTextUseCase', + //DeleteCardUseCase: 'DeleteCardUseCase', + //DeleteFromCardGroupUseCase: 'DeleteFromCardGroupUseCase' }, repository: { - CardRepository: 'CardRepository' + //CardRepository: 'CardRepository' } }; @@ -24,8 +24,6 @@ export const GET_CARD_SERVICE = 'GetCardService'; /* USE CASES */ -export const DELETE_FROM_CARD_GROUP_USE_CASE = 'DeleteFromCardGroupUseCase'; - export const CREATE_CARD_USE_CASE = 'CreateCardUseCase'; export const UNMERGE_CARD_USE_CASE = 'UnmergeCardUseCase'; diff --git a/backend/src/modules/cards/controller/cards.controller.ts b/backend/src/modules/cards/controller/cards.controller.ts index 79112d1f2..b19417b7d 100644 --- a/backend/src/modules/cards/controller/cards.controller.ts +++ b/backend/src/modules/cards/controller/cards.controller.ts @@ -39,7 +39,16 @@ import DeleteCardDto from '../dto/delete.card.dto'; import UnmergeCardsDto from '../dto/unmerge.dto'; import UpdateCardDto from '../dto/update.card.dto'; import { UpdateCardPositionDto } from '../dto/update-position.card.dto'; -import { TYPES } from '../constants'; +import { + CREATE_CARD_USE_CASE, + DELETE_CARD_FROM_GROUP_USE_CASE, + DELETE_CARD_USE_CASE, + MERGE_CARD_USE_CASE, + UNMERGE_CARD_USE_CASE, + UPDATE_CARD_GROUP_TEXT_USE_CASE, + UPDATE_CARD_POSITION_USE_CASE, + UPDATE_CARD_TEXT_USE_CASE +} from '../constants'; import { MergeCardDto } from '../dto/group/merge.card.dto'; import CreateCardUseCaseDto from '../dto/useCase/create-card.use-case.dto'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; @@ -58,22 +67,22 @@ import DeleteFromCardGroupUseCaseDto from '../dto/useCase/delete-fom-card-group. @Controller('boards') export default class CardsController { constructor( - @Inject(TYPES.applications.CreateCardUseCase) + @Inject(CREATE_CARD_USE_CASE) private readonly createCardUseCase: UseCase, - @Inject(TYPES.applications.UpdateCardPositionUseCase) + @Inject(UPDATE_CARD_POSITION_USE_CASE) private readonly updateCardPositionUseCase: UseCase, - @Inject(TYPES.applications.UpdateCardTextUseCase) + @Inject(UPDATE_CARD_TEXT_USE_CASE) private readonly updateCardTextUseCase: UseCase, - @Inject(TYPES.applications.UpdateCardGroupTextUseCase) + @Inject(UPDATE_CARD_GROUP_TEXT_USE_CASE) private readonly updateCardGroupTextUseCase: UseCase, - @Inject(TYPES.applications.UnmergeCardUseCase) + @Inject(UNMERGE_CARD_USE_CASE) private readonly unmergeCardUseCase: UseCase, - @Inject(TYPES.applications.MergeCardUseCase) + @Inject(MERGE_CARD_USE_CASE) private readonly mergeCardUseCase: UseCase, - @Inject(TYPES.applications.DeleteCardUseCase) + @Inject(DELETE_CARD_USE_CASE) private readonly deleteCardUseCase: UseCase, - @Inject(TYPES.applications.DeleteFromCardGroupUseCase) - private readonly deleteFromCardGroupUseCase: UseCase, + @Inject(DELETE_CARD_FROM_GROUP_USE_CASE) + private readonly deleteCardFromGroupUseCase: UseCase, private readonly socketService: SocketGateway ) {} @@ -177,7 +186,7 @@ export default class CardsController { this.socketService.sendDeleteCard(deleteCardDto.socketId, deleteCardDto); }; - return this.deleteFromCardGroupUseCase.execute({ + return this.deleteCardFromGroupUseCase.execute({ boardId, cardId, cardItemId, diff --git a/backend/src/modules/cards/services/get.card.service.spec.ts b/backend/src/modules/cards/services/get.card.service.spec.ts index fb7d429b1..9b81a36b3 100644 --- a/backend/src/modules/cards/services/get.card.service.spec.ts +++ b/backend/src/modules/cards/services/get.card.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../constants'; +import { CARD_REPOSITORY } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; @@ -21,13 +21,13 @@ describe('GetCardService', () => { providers: [ GetCardService, { - provide: TYPES.repository.CardRepository, + provide: CARD_REPOSITORY, useValue: createMock() } ] }).compile(); - service = module.get(GetCardService); - cardRepositoryMock = module.get(TYPES.repository.CardRepository); + service = module.get(GetCardService); + cardRepositoryMock = module.get(CARD_REPOSITORY); cardRepositoryMock.getCardFromBoard.mockResolvedValue(cards); cardRepositoryMock.getCardItemFromGroup.mockResolvedValue(cardItem); }); diff --git a/backend/src/modules/cards/services/get.card.service.ts b/backend/src/modules/cards/services/get.card.service.ts index 832cf1ec6..77c3b1f61 100644 --- a/backend/src/modules/cards/services/get.card.service.ts +++ b/backend/src/modules/cards/services/get.card.service.ts @@ -1,13 +1,13 @@ import { Inject, Injectable } from '@nestjs/common'; import { isEmpty } from 'class-validator'; import { GetCardServiceInterface } from '../interfaces/services/get.card.service.interface'; -import * as Cards from 'src/modules/cards/constants'; import { CardRepositoryInterface } from '../repository/card.repository.interface'; +import { CARD_REPOSITORY } from 'src/modules/cards/constants'; @Injectable() export default class GetCardService implements GetCardServiceInterface { constructor( - @Inject(Cards.TYPES.repository.CardRepository) + @Inject(CARD_REPOSITORY) private readonly cardRepository: CardRepositoryInterface ) {} diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 3212ce6ad..883fd5c6a 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import { TYPES } from '../interfaces/types'; -import * as Cards from 'src/modules/cards/constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -26,6 +25,7 @@ import { GET_BOARD_USER_SERVICE, UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; +import { GET_CARD_SERVICE } from 'src/modules/cards/constants'; const userId: string = faker.datatype.uuid(); const board: Board = BoardFactory.create({ maxVotes: 3 }); @@ -59,7 +59,7 @@ describe('DeleteVoteService', () => { useValue: createMock() }, { - provide: Cards.TYPES.services.GetCardService, + provide: GET_CARD_SERVICE, useValue: createMock() }, { @@ -68,11 +68,11 @@ describe('DeleteVoteService', () => { } ] }).compile(); - voteService = module.get(DeleteVoteService); + voteService = module.get(DeleteVoteService); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); getBoardServiceMock = module.get(GET_BOARD_SERVICE); getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); - getCardServiceMock = module.get(Cards.TYPES.services.GetCardService); + getCardServiceMock = module.get(GET_CARD_SERVICE); updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); }); diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 6e124cf80..65bc1c4be 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -2,7 +2,6 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import { DELETE_VOTE_FAILED, UPDATE_FAILED } from 'src/libs/exceptions/messages'; import isEmpty from 'src/libs/utils/isEmpty'; import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/get.card.service.interface'; -import * as Cards from 'src/modules/cards/constants'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; import { TYPES } from '../interfaces/types'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; @@ -22,6 +21,7 @@ import { GET_BOARD_USER_SERVICE, UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; +import { GET_CARD_SERVICE } from 'src/modules/cards/constants'; @Injectable() export default class DeleteVoteService implements DeleteVoteServiceInterface { @@ -32,7 +32,7 @@ export default class DeleteVoteService implements DeleteVoteServiceInterface { private readonly getBoardUserService: GetBoardUserServiceInterface, @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, - @Inject(Cards.TYPES.services.GetCardService) + @Inject(GET_CARD_SERVICE) private readonly getCardService: GetCardServiceInterface, @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface From e9bc588fac8d894c8a7652cb9f23430767b41375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Thu, 20 Apr 2023 18:17:11 +0100 Subject: [PATCH 13/14] refactor: change filename to constants --- .../update-board.use-case.spec.ts | 2 +- .../applications/update-board.use-case.ts | 2 +- .../services/update.column.service.spec.ts | 2 +- .../columns/services/update.column.service.ts | 2 +- .../card-group-vote.use-case.spec.ts | 6 ++-- .../applications/card-group-vote.use-case.ts | 4 +-- .../card-item-vote.use-case.spec.ts | 6 ++-- .../applications/card-item-vote.use-case.ts | 4 +-- backend/src/modules/votes/constants.ts | 29 +++++++++++++++++++ .../votes/controller/votes.controller.ts | 2 +- backend/src/modules/votes/interfaces/types.ts | 13 --------- .../services/create.vote.service.spec.ts | 2 +- .../services/delete.vote.service.spec.ts | 2 +- .../votes/services/delete.vote.service.ts | 2 +- backend/src/modules/votes/votes.providers.ts | 10 +++++-- 15 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 backend/src/modules/votes/constants.ts delete mode 100644 backend/src/modules/votes/interfaces/types.ts diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index 6156f9ec2..4e28bb691 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,6 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Votes from 'src/modules/votes/interfaces/types'; +import * as Votes from 'src/modules/votes/constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index 920b08f0d..4462a02ef 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -13,7 +13,7 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import User from 'src/modules/users/entities/user.schema'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; -import * as Votes from 'src/modules/votes/interfaces/types'; +import * as Votes from 'src/modules/votes/constants'; import { UpdateBoardDto } from '../dto/update-board.dto'; import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; diff --git a/backend/src/modules/columns/services/update.column.service.spec.ts b/backend/src/modules/columns/services/update.column.service.spec.ts index 726285a9a..dcf2f5792 100644 --- a/backend/src/modules/columns/services/update.column.service.spec.ts +++ b/backend/src/modules/columns/services/update.column.service.spec.ts @@ -8,7 +8,7 @@ import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory. import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import { updateColumnService } from '../columns.providers'; import * as Columns from '../interfaces/types'; -import * as Votes from 'src/modules/votes/interfaces/types'; +import * as Votes from 'src/modules/votes/constants'; import { ColumnRepository } from '../repositories/column.repository'; import GetBoardService from 'src/modules/boards/services/get.board.service'; import UpdateColumnService from './update.column.service'; diff --git a/backend/src/modules/columns/services/update.column.service.ts b/backend/src/modules/columns/services/update.column.service.ts index f290cd46d..f88ffc62e 100644 --- a/backend/src/modules/columns/services/update.column.service.ts +++ b/backend/src/modules/columns/services/update.column.service.ts @@ -1,6 +1,6 @@ import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; import { COLUMN_NOT_FOUND, UPDATE_FAILED } from 'src/libs/exceptions/messages'; -import * as Votes from 'src/modules/votes/interfaces/types'; +import * as Votes from 'src/modules/votes/constants'; import * as Columns from '../interfaces/types'; import { UpdateColumnServiceInterface } from '../interfaces/services/update.column.service.interface'; import { UpdateColumnDto } from '../dto/update-column.dto'; diff --git a/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts b/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts index 7c4a5f7f0..f89583e60 100644 --- a/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts +++ b/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; @@ -51,7 +51,7 @@ describe('CardGroupVoteUseCase', () => { useValue: createMock() }, { - provide: TYPES.services.CreateVoteService, + provide: CREATE_VOTE_SERVICE, useValue: createMock() }, { @@ -63,7 +63,7 @@ describe('CardGroupVoteUseCase', () => { useCase = module.get(CardGroupVoteUseCase); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); - createVoteServiceMock = module.get(TYPES.services.CreateVoteService); + createVoteServiceMock = module.get(CREATE_VOTE_SERVICE); deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService); }); diff --git a/backend/src/modules/votes/applications/card-group-vote.use-case.ts b/backend/src/modules/votes/applications/card-group-vote.use-case.ts index e9ef415b0..740f74a60 100644 --- a/backend/src/modules/votes/applications/card-group-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-group-vote.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -20,7 +20,7 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; export class CardGroupVoteUseCase implements UseCase { private logger: Logger = new Logger('CreateVoteService'); constructor( - @Inject(TYPES.services.CreateVoteService) + @Inject(CREATE_VOTE_SERVICE) private readonly createVoteService: CreateVoteServiceInterface, @Inject(TYPES.repositories.VoteRepository) private readonly voteRepository: VoteRepositoryInterface, diff --git a/backend/src/modules/votes/applications/card-item-vote.use-case.spec.ts b/backend/src/modules/votes/applications/card-item-vote.use-case.spec.ts index e74567891..5c3d826e8 100644 --- a/backend/src/modules/votes/applications/card-item-vote.use-case.spec.ts +++ b/backend/src/modules/votes/applications/card-item-vote.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; @@ -52,7 +52,7 @@ describe('CardItemVoteUseCase', () => { useValue: createMock() }, { - provide: TYPES.services.CreateVoteService, + provide: CREATE_VOTE_SERVICE, useValue: createMock() }, { @@ -64,7 +64,7 @@ describe('CardItemVoteUseCase', () => { useCase = module.get(CardItemVoteUseCase); voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); - createVoteServiceMock = module.get(TYPES.services.CreateVoteService); + createVoteServiceMock = module.get(CREATE_VOTE_SERVICE); deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService); }); diff --git a/backend/src/modules/votes/applications/card-item-vote.use-case.ts b/backend/src/modules/votes/applications/card-item-vote.use-case.ts index 409a752b2..a71463326 100644 --- a/backend/src/modules/votes/applications/card-item-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-item-vote.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { TYPES } from '../interfaces/types'; +import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -17,7 +17,7 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; export class CardItemVoteUseCase implements UseCase { private logger: Logger = new Logger('CreateVoteService'); constructor( - @Inject(TYPES.services.CreateVoteService) + @Inject(CREATE_VOTE_SERVICE) private readonly createVoteService: CreateVoteServiceInterface, @Inject(TYPES.services.DeleteVoteService) private readonly deleteVoteService: DeleteVoteServiceInterface, diff --git a/backend/src/modules/votes/constants.ts b/backend/src/modules/votes/constants.ts new file mode 100644 index 000000000..6f84ba78a --- /dev/null +++ b/backend/src/modules/votes/constants.ts @@ -0,0 +1,29 @@ +export const TYPES = { + services: { + //CreateVoteService: 'CreateVoteService', + DeleteVoteService: 'DeleteVoteService' + }, + repositories: { + VoteRepository: 'VoteRepository' + }, + applications: { + CardItemVoteUseCase: 'CardItemVoteUseCase', + CardGroupVoteUseCase: 'CardGroupVoteUseCase' + } +}; + +/* SERVICES */ + +export const CREATE_VOTE_SERVICE = 'CreateVoteService'; + +export const DELETE_VOTE_SERVICE = 'DeleteVoteService'; + +/* USE CASES */ + +export const CARD_ITEM_VOTE_USE_CASE = 'CardItemVoteUseCase'; + +export const CARD_GROUP_VOTE_USE_CASE = 'CardGroupVoteUseCase'; + +/* REPOSITORY */ + +export const VOTE_REPOSITORY = 'VoteRepository'; diff --git a/backend/src/modules/votes/controller/votes.controller.ts b/backend/src/modules/votes/controller/votes.controller.ts index 60fbcc58f..3678c7235 100644 --- a/backend/src/modules/votes/controller/votes.controller.ts +++ b/backend/src/modules/votes/controller/votes.controller.ts @@ -21,7 +21,7 @@ import { UnauthorizedResponse } from 'src/libs/swagger/errors/unauthorized.swagg import BoardDto from 'src/modules/boards/dto/board.dto'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; import VoteDto from '../dto/vote.dto'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import CardItemVoteUseCaseDto from '../dto/useCase/card-item-vote.use-case.dto'; import CardGroupVoteUseCaseDto from '../dto/useCase/card-group-vote.use-case.dto'; diff --git a/backend/src/modules/votes/interfaces/types.ts b/backend/src/modules/votes/interfaces/types.ts deleted file mode 100644 index fef6b1a71..000000000 --- a/backend/src/modules/votes/interfaces/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const TYPES = { - services: { - CreateVoteService: 'CreateVoteService', - DeleteVoteService: 'DeleteVoteService' - }, - repositories: { - VoteRepository: 'VoteRepository' - }, - applications: { - CardItemVoteUseCase: 'CardItemVoteUseCase', - CardGroupVoteUseCase: 'CardGroupVoteUseCase' - } -}; diff --git a/backend/src/modules/votes/services/create.vote.service.spec.ts b/backend/src/modules/votes/services/create.vote.service.spec.ts index f068636da..4e64be01c 100644 --- a/backend/src/modules/votes/services/create.vote.service.spec.ts +++ b/backend/src/modules/votes/services/create.vote.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import CreateVoteService from './create.vote.service'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 883fd5c6a..2c41f8d0b 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 65bc1c4be..090145c43 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -3,7 +3,7 @@ import { DELETE_VOTE_FAILED, UPDATE_FAILED } from 'src/libs/exceptions/messages' import isEmpty from 'src/libs/utils/isEmpty'; import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/get.card.service.interface'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; -import { TYPES } from '../interfaces/types'; +import { TYPES } from '../constants'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; diff --git a/backend/src/modules/votes/votes.providers.ts b/backend/src/modules/votes/votes.providers.ts index e01d7e98f..66835261e 100644 --- a/backend/src/modules/votes/votes.providers.ts +++ b/backend/src/modules/votes/votes.providers.ts @@ -1,12 +1,14 @@ import { VoteRepository } from './repositories/vote.repository'; -import { TYPES } from './interfaces/types'; +import { CREATE_VOTE_SERVICE, TYPES } from './constants'; import CreateVoteService from './services/create.vote.service'; import DeleteVoteService from './services/delete.vote.service'; import { CardItemVoteUseCase } from './applications/card-item-vote.use-case'; import { CardGroupVoteUseCase } from './applications/card-group-vote.use-case'; +/* SERVICES */ + export const createVoteService = { - provide: TYPES.services.CreateVoteService, + provide: CREATE_VOTE_SERVICE, useClass: CreateVoteService }; @@ -15,6 +17,8 @@ export const deleteVoteService = { useClass: DeleteVoteService }; +/* USE CASES */ + export const cardItemVoteUseCase = { provide: TYPES.applications.CardItemVoteUseCase, useClass: CardItemVoteUseCase @@ -25,6 +29,8 @@ export const cardGroupVoteUseCase = { useClass: CardGroupVoteUseCase }; +/* REPOSITORY */ + export const voteRepository = { provide: TYPES.repositories.VoteRepository, useClass: VoteRepository From 61f8d76a6a090bed601735129ab34530eb61993d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1tia=20Antunes?= Date: Thu, 20 Apr 2023 18:29:24 +0100 Subject: [PATCH 14/14] refactor: change TYPES for CONSTANTS (votes) --- .../applications/update-board.use-case.spec.ts | 6 +++--- .../boards/applications/update-board.use-case.ts | 4 ++-- .../services/update.column.service.spec.ts | 11 +++++------ .../columns/services/update.column.service.ts | 4 ++-- .../card-group-vote.use-case.spec.ts | 10 +++++----- .../applications/card-group-vote.use-case.ts | 6 +++--- .../applications/card-item-vote.use-case.spec.ts | 10 +++++----- .../applications/card-item-vote.use-case.ts | 6 +++--- backend/src/modules/votes/constants.ts | 14 -------------- .../modules/votes/controller/votes.controller.ts | 6 +++--- .../votes/services/create.vote.service.spec.ts | 8 ++++---- .../votes/services/delete.vote.service.spec.ts | 6 +++--- .../votes/services/delete.vote.service.ts | 4 ++-- backend/src/modules/votes/votes.providers.ts | 16 +++++++++++----- 14 files changed, 51 insertions(+), 60 deletions(-) diff --git a/backend/src/modules/boards/applications/update-board.use-case.spec.ts b/backend/src/modules/boards/applications/update-board.use-case.spec.ts index 4e28bb691..23c054dbe 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.spec.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.spec.ts @@ -1,6 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; import * as CommunicationsType from 'src/modules/communication/interfaces/types'; -import * as Votes from 'src/modules/votes/constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; @@ -30,6 +29,7 @@ import { GET_BOARD_USER_SERVICE, UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; +import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants'; const regularBoard = BoardFactory.create({ isSubBoard: false, dividedBoards: [] }); const userId = faker.datatype.uuid(); @@ -110,7 +110,7 @@ describe('UpdateBoardUseCase', () => { useValue: createMock() }, { - provide: Votes.TYPES.services.DeleteVoteService, + provide: DELETE_VOTE_SERVICE, useValue: createMock() }, { @@ -132,7 +132,7 @@ describe('UpdateBoardUseCase', () => { boardRepositoryMock = module.get(BOARD_REPOSITORY); updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); - deleteVoteServiceMock = module.get(Votes.TYPES.services.DeleteVoteService); + deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE); slackCommunicationServiceMock = module.get( CommunicationsType.TYPES.services.SlackCommunicationService ); diff --git a/backend/src/modules/boards/applications/update-board.use-case.ts b/backend/src/modules/boards/applications/update-board.use-case.ts index 4462a02ef..136d9b7be 100644 --- a/backend/src/modules/boards/applications/update-board.use-case.ts +++ b/backend/src/modules/boards/applications/update-board.use-case.ts @@ -13,7 +13,6 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa import * as CommunicationsType from 'src/modules/communication/interfaces/types'; import User from 'src/modules/users/entities/user.schema'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; -import * as Votes from 'src/modules/votes/constants'; import { UpdateBoardDto } from '../dto/update-board.dto'; import Board from '../entities/board.schema'; import { ResponsibleType } from '../interfaces/responsible.interface'; @@ -23,6 +22,7 @@ import { GET_BOARD_USER_SERVICE, UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants'; +import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants'; @Injectable() export class UpdateBoardUseCase implements UseCase { @@ -33,7 +33,7 @@ export class UpdateBoardUseCase implements UseCase { private readonly getBoardUserService: GetBoardUserServiceInterface, @Inject(UPDATE_BOARD_USER_SERVICE) private readonly updateBoardUserService: UpdateBoardUserServiceInterface, - @Inject(Votes.TYPES.services.DeleteVoteService) + @Inject(DELETE_VOTE_SERVICE) private readonly deleteVoteService: DeleteVoteServiceInterface, @Inject(CommunicationsType.TYPES.services.SlackCommunicationService) private readonly slackCommunicationService: CommunicationServiceInterface diff --git a/backend/src/modules/columns/services/update.column.service.spec.ts b/backend/src/modules/columns/services/update.column.service.spec.ts index dcf2f5792..e10027517 100644 --- a/backend/src/modules/columns/services/update.column.service.spec.ts +++ b/backend/src/modules/columns/services/update.column.service.spec.ts @@ -6,15 +6,14 @@ import { BadRequestException, Logger, NotFoundException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock'; import SocketGateway from 'src/modules/socket/gateway/socket.gateway'; -import { updateColumnService } from '../columns.providers'; import * as Columns from '../interfaces/types'; -import * as Votes from 'src/modules/votes/constants'; import { ColumnRepository } from '../repositories/column.repository'; import GetBoardService from 'src/modules/boards/services/get.board.service'; import UpdateColumnService from './update.column.service'; import DeleteVoteService from 'src/modules/votes/services/delete.vote.service'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants'; const fakeBoards = BoardFactory.createMany(2); @@ -29,7 +28,7 @@ describe('UpdateColumnService', () => { const module: TestingModule = await Test.createTestingModule({ imports: [EventEmitterModule.forRoot()], providers: [ - updateColumnService, + UpdateColumnService, { provide: Columns.TYPES.repositories.ColumnRepository, useValue: createMock() @@ -39,7 +38,7 @@ describe('UpdateColumnService', () => { useValue: createMock() }, { - provide: Votes.TYPES.services.DeleteVoteService, + provide: DELETE_VOTE_SERVICE, useValue: createMock() }, { @@ -49,8 +48,8 @@ describe('UpdateColumnService', () => { ] }).compile(); - columnService = module.get(Columns.TYPES.services.UpdateColumnService); - deleteVoteService = module.get(Votes.TYPES.services.DeleteVoteService); + columnService = module.get(UpdateColumnService); + deleteVoteService = module.get(DELETE_VOTE_SERVICE); repositoryColumn = module.get(Columns.TYPES.repositories.ColumnRepository); socketService = module.get(SocketGateway); getBoardServiceImpl = module.get(GET_BOARD_SERVICE); diff --git a/backend/src/modules/columns/services/update.column.service.ts b/backend/src/modules/columns/services/update.column.service.ts index f88ffc62e..d410dc196 100644 --- a/backend/src/modules/columns/services/update.column.service.ts +++ b/backend/src/modules/columns/services/update.column.service.ts @@ -1,6 +1,5 @@ import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common'; import { COLUMN_NOT_FOUND, UPDATE_FAILED } from 'src/libs/exceptions/messages'; -import * as Votes from 'src/modules/votes/constants'; import * as Columns from '../interfaces/types'; import { UpdateColumnServiceInterface } from '../interfaces/services/update.column.service.interface'; import { UpdateColumnDto } from '../dto/update-column.dto'; @@ -10,6 +9,7 @@ import { ColumnRepositoryInterface } from '../repositories/column.repository.int import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface'; import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface'; import { GET_BOARD_SERVICE } from 'src/modules/boards/constants'; +import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants'; @Injectable() export default class UpdateColumnService implements UpdateColumnServiceInterface { @@ -19,7 +19,7 @@ export default class UpdateColumnService implements UpdateColumnServiceInterface private readonly socketService: SocketGateway, @Inject(GET_BOARD_SERVICE) private readonly getBoardService: GetBoardServiceInterface, - @Inject(Votes.TYPES.services.DeleteVoteService) + @Inject(DELETE_VOTE_SERVICE) private readonly deleteVoteService: DeleteVoteServiceInterface ) {} diff --git a/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts b/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts index f89583e60..f0202de4f 100644 --- a/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts +++ b/backend/src/modules/votes/applications/card-group-vote.use-case.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; +import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; @@ -43,11 +43,11 @@ describe('CardGroupVoteUseCase', () => { providers: [ CardGroupVoteUseCase, { - provide: TYPES.repositories.VoteRepository, + provide: VOTE_REPOSITORY, useValue: createMock() }, { - provide: TYPES.services.DeleteVoteService, + provide: DELETE_VOTE_SERVICE, useValue: createMock() }, { @@ -62,9 +62,9 @@ describe('CardGroupVoteUseCase', () => { }).compile(); useCase = module.get(CardGroupVoteUseCase); - voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); + voteRepositoryMock = module.get(VOTE_REPOSITORY); createVoteServiceMock = module.get(CREATE_VOTE_SERVICE); - deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService); + deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/votes/applications/card-group-vote.use-case.ts b/backend/src/modules/votes/applications/card-group-vote.use-case.ts index 740f74a60..36751a6ce 100644 --- a/backend/src/modules/votes/applications/card-group-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-group-vote.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; +import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -22,11 +22,11 @@ export class CardGroupVoteUseCase implements UseCase { providers: [ CardItemVoteUseCase, { - provide: TYPES.repositories.VoteRepository, + provide: VOTE_REPOSITORY, useValue: createMock() }, { - provide: TYPES.services.DeleteVoteService, + provide: DELETE_VOTE_SERVICE, useValue: createMock() }, { @@ -63,9 +63,9 @@ describe('CardItemVoteUseCase', () => { }).compile(); useCase = module.get(CardItemVoteUseCase); - voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); + voteRepositoryMock = module.get(VOTE_REPOSITORY); createVoteServiceMock = module.get(CREATE_VOTE_SERVICE); - deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService); + deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE); }); beforeEach(() => { diff --git a/backend/src/modules/votes/applications/card-item-vote.use-case.ts b/backend/src/modules/votes/applications/card-item-vote.use-case.ts index a71463326..c6c831fa2 100644 --- a/backend/src/modules/votes/applications/card-item-vote.use-case.ts +++ b/backend/src/modules/votes/applications/card-item-vote.use-case.ts @@ -1,5 +1,5 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; -import { CREATE_VOTE_SERVICE, TYPES } from '../constants'; +import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants'; import { UseCase } from 'src/libs/interfaces/use-case.interface'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; @@ -19,9 +19,9 @@ export class CardItemVoteUseCase implements UseCase, - @Inject(TYPES.applications.CardGroupVoteUseCase) + @Inject(CARD_GROUP_VOTE_USE_CASE) private readonly cardGroupVoteUseCase: UseCase, private readonly socketService: SocketGateway ) {} diff --git a/backend/src/modules/votes/services/create.vote.service.spec.ts b/backend/src/modules/votes/services/create.vote.service.spec.ts index 4e64be01c..c3d21eab8 100644 --- a/backend/src/modules/votes/services/create.vote.service.spec.ts +++ b/backend/src/modules/votes/services/create.vote.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../constants'; +import { VOTE_REPOSITORY } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import CreateVoteService from './create.vote.service'; import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface'; @@ -38,7 +38,7 @@ describe('CreateVoteService', () => { providers: [ CreateVoteService, { - provide: TYPES.repositories.VoteRepository, + provide: VOTE_REPOSITORY, useValue: createMock() }, { @@ -55,8 +55,8 @@ describe('CreateVoteService', () => { } ] }).compile(); - voteService = module.get(CreateVoteService); - voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); + voteService = module.get(CreateVoteService); + voteRepositoryMock = module.get(VOTE_REPOSITORY); getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getBoardServiceMock = module.get(GET_BOARD_SERVICE); updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE); diff --git a/backend/src/modules/votes/services/delete.vote.service.spec.ts b/backend/src/modules/votes/services/delete.vote.service.spec.ts index 2c41f8d0b..2fb0722e1 100644 --- a/backend/src/modules/votes/services/delete.vote.service.spec.ts +++ b/backend/src/modules/votes/services/delete.vote.service.spec.ts @@ -1,5 +1,5 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TYPES } from '../constants'; +import { VOTE_REPOSITORY } from '../constants'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -47,7 +47,7 @@ describe('DeleteVoteService', () => { providers: [ DeleteVoteService, { - provide: TYPES.repositories.VoteRepository, + provide: VOTE_REPOSITORY, useValue: createMock() }, { @@ -69,7 +69,7 @@ describe('DeleteVoteService', () => { ] }).compile(); voteService = module.get(DeleteVoteService); - voteRepositoryMock = module.get(TYPES.repositories.VoteRepository); + voteRepositoryMock = module.get(VOTE_REPOSITORY); getBoardServiceMock = module.get(GET_BOARD_SERVICE); getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE); getCardServiceMock = module.get(GET_CARD_SERVICE); diff --git a/backend/src/modules/votes/services/delete.vote.service.ts b/backend/src/modules/votes/services/delete.vote.service.ts index 090145c43..6370426e2 100644 --- a/backend/src/modules/votes/services/delete.vote.service.ts +++ b/backend/src/modules/votes/services/delete.vote.service.ts @@ -3,7 +3,7 @@ import { DELETE_VOTE_FAILED, UPDATE_FAILED } from 'src/libs/exceptions/messages' import isEmpty from 'src/libs/utils/isEmpty'; import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/get.card.service.interface'; import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface'; -import { TYPES } from '../constants'; +import { VOTE_REPOSITORY } from '../constants'; import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface'; import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface'; import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface'; @@ -26,7 +26,7 @@ import { GET_CARD_SERVICE } from 'src/modules/cards/constants'; @Injectable() export default class DeleteVoteService implements DeleteVoteServiceInterface { constructor( - @Inject(TYPES.repositories.VoteRepository) + @Inject(VOTE_REPOSITORY) private readonly voteRepository: VoteRepositoryInterface, @Inject(GET_BOARD_USER_SERVICE) private readonly getBoardUserService: GetBoardUserServiceInterface, diff --git a/backend/src/modules/votes/votes.providers.ts b/backend/src/modules/votes/votes.providers.ts index 66835261e..dc35428b1 100644 --- a/backend/src/modules/votes/votes.providers.ts +++ b/backend/src/modules/votes/votes.providers.ts @@ -1,5 +1,11 @@ import { VoteRepository } from './repositories/vote.repository'; -import { CREATE_VOTE_SERVICE, TYPES } from './constants'; +import { + CARD_GROUP_VOTE_USE_CASE, + CARD_ITEM_VOTE_USE_CASE, + CREATE_VOTE_SERVICE, + DELETE_VOTE_SERVICE, + VOTE_REPOSITORY +} from './constants'; import CreateVoteService from './services/create.vote.service'; import DeleteVoteService from './services/delete.vote.service'; import { CardItemVoteUseCase } from './applications/card-item-vote.use-case'; @@ -13,25 +19,25 @@ export const createVoteService = { }; export const deleteVoteService = { - provide: TYPES.services.DeleteVoteService, + provide: DELETE_VOTE_SERVICE, useClass: DeleteVoteService }; /* USE CASES */ export const cardItemVoteUseCase = { - provide: TYPES.applications.CardItemVoteUseCase, + provide: CARD_ITEM_VOTE_USE_CASE, useClass: CardItemVoteUseCase }; export const cardGroupVoteUseCase = { - provide: TYPES.applications.CardGroupVoteUseCase, + provide: CARD_GROUP_VOTE_USE_CASE, useClass: CardGroupVoteUseCase }; /* REPOSITORY */ export const voteRepository = { - provide: TYPES.repositories.VoteRepository, + provide: VOTE_REPOSITORY, useClass: VoteRepository };