diff --git a/backend/src/libs/guards/boardRoles.guard.ts b/backend/src/libs/guards/boardRoles.guard.ts index 3b7df19ca..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/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'; +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 7618b387d..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/interfaces/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 371905ac3..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/interfaces/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 291d5b934..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/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'; +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/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/applications/create-board.use-case.spec.ts b/backend/src/modules/boards/applications/create-board.use-case.spec.ts index eaa52e9cb..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/interfaces/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 ba870d73e..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 '../interfaces/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 3460428e0..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/interfaces/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'; -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.TYPES.services.DeleteBoardService, + 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.TYPES.services.DeleteBoardService); - 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 30960756f..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 { TYPES } from '../interfaces/types'; +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,9 +11,9 @@ 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(TYPES.services.DeleteBoardService) + @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 251932079..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/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 { 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.TYPES.services.GetBoardService, + 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.TYPES.services.GetBoardService); - 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 d0eac00c4..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 { TYPES } from '../interfaces/types'; +import { BOARD_REPOSITORY, GET_BOARD_SERVICE } from '../constants'; import { BoardRepositoryInterface } from '../repositories/board.repository.interface'; export type DuplicateBoardDto = { boardId: string; userId: string; boardTitle: string }; @@ -23,11 +23,11 @@ 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, - @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-all-boards.use-case.spec.ts b/backend/src/modules/boards/applications/get-all-boards.use-case.spec.ts index eed3bef1b..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/interfaces/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 2d696dee3..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 '../interfaces/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 c6e9d00ad..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/interfaces/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'; @@ -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 4a171e59b..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 '../interfaces/types'; +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/get-boards-for-dashboard.use-case.spec.ts b/backend/src/modules/boards/applications/get-dashboard-boards.use-case.spec.ts similarity index 85% 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 18f8825c2..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 @@ -1,5 +1,4 @@ import { Test, TestingModule } from '@nestjs/testing'; -import * as Boards from 'src/modules/boards/interfaces/types'; import { DeepMocked, createMock } from '@golevelup/ts-jest'; import { GetBoardServiceInterface } from '../interfaces/services/get.board.service.interface'; import faker from '@faker-js/faker'; @@ -8,27 +7,28 @@ 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: Boards.TYPES.services.GetBoardService, + provide: GET_BOARD_SERVICE, useValue: createMock() } ] }).compile(); - useCase = module.get(GetBoardsForDashboardUseCase); - getBoardServiceMock = module.get(Boards.TYPES.services.GetBoardService); + useCase = module.get(GetDashboardBoardsUseCase); + 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-dashboard-boards.use-case.ts similarity index 88% 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 11f3e2608..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 @@ -2,15 +2,15 @@ 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 { GET_BOARD_SERVICE } from '../constants'; import BoardsPaginatedPresenter from '../presenter/boards-paginated.presenter'; @Injectable() -export class GetBoardsForDashboardUseCase +export class GetDashboardBoardsUseCase 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 5b3881d88..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/interfaces/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 9f684861a..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 '../interfaces/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 81937ded8..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/interfaces/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'; 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 28abad4c7..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 '../interfaces/types'; +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 42b7409e7..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/interfaces/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'; @@ -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 c146f7b88..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 '../interfaces/types'; +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 f547f9e22..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/interfaces/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'; 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 8a3f5a699..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 '../interfaces/types'; +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 d035737f4..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/interfaces/types'; 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 beacfe0f0..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 '../interfaces/types'; +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.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 1c63d3756..5555e82ea 100644 --- a/backend/src/modules/boards/boards.providers.ts +++ b/backend/src/modules/boards/boards.providers.ts @@ -15,10 +15,40 @@ 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 { TYPES } from './interfaces/types'; +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, + 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, + UPDATE_BOARD_PARTICIPANTS_USE_CASE, + UPDATE_BOARD_PHASE_USE_CASE, + UPDATE_BOARD_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'; import DeleteBoardService from './services/delete.board.service'; @@ -29,147 +59,155 @@ 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: 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 }; -export const duplicateBoardUseCase = { - provide: TYPES.applications.DuplicateBoardUseCase, - useClass: DuplicateBoardUseCase +export const sendBoardTimerStateService = { + provide: SEND_BOARD_TIMER_STATE_SERVICE, + useClass: SendBoardTimerStateService +}; + +export const startBoardTimerService = { + provide: START_BOARD_TIMER_SERVICE, + useClass: StartBoardTimerService +}; + +export const pauseBoardTimerService = { + provide: PAUSE_BOARD_TIMER_SERVICE, + useClass: PauseBoardTimerService +}; + +export const stopBoardTimerService = { + provide: STOP_BOARD_TIMER_SERVICE, + useClass: StopBoardTimerService +}; + +export const updateBoardTimerDurationService = { + provide: UPDATE_BOARD_TIMER_DURATION_SERVICE, + useClass: UpdateBoardTimerDurationService +}; + +export const sendBoardTimerTimeLeftService = { + provide: SEND_BOARD_TIMER_TIME_LEFT_SERVICE, + useClass: SendBoardTimerTimeLeftService +}; + +/* USE CASES */ + +export const createBoardUseCase = { + provide: CREATE_BOARD_USE_CASE, + useClass: CreateBoardUseCase }; -export const getBoardsForDashboardUseCase = { - provide: TYPES.applications.GetBoardsForDashboardUseCase, - useClass: GetBoardsForDashboardUseCase +export const getDashboardBoardsUseCase = { + provide: GET_DASHBOARD_BOARDS_USE_CASE, + useClass: GetDashboardBoardsUseCase }; export const getAllBoardsUseCase = { - provide: TYPES.applications.GetAllBoardsUseCase, + provide: GET_ALL_BOARDS_USE_CASE, useClass: GetAllBoardsUseCase }; export const getPersonalBoardsUseCase = { - provide: TYPES.applications.GetPersonalBoardsUseCase, + provide: GET_PERSONAL_BOARDS_USE_CASE, useClass: GetPersonalBoardsUseCase }; +export const updateBoardUseCase = { + provide: UPDATE_BOARD_USE_CASE, + useClass: UpdateBoardUseCase +}; + +export const deleteBoardUseCase = { + provide: DELETE_BOARD_USE_CASE, + useClass: DeleteBoardUseCase +}; + export const getBoardUseCase = { - provide: TYPES.applications.GetBoardUseCase, + provide: GET_BOARD_USE_CASE, useClass: GetBoardUseCase }; -export const isBoardPublicUseCase = { - provide: TYPES.applications.IsBoardPublicUseCase, - useClass: IsBoardPublicUseCase +export const duplicateBoardUseCase = { + provide: DUPLICATE_BOARD_USE_CASE, + useClass: DuplicateBoardUseCase }; -export const updateBoardUseCase = { - provide: TYPES.applications.UpdateBoardUseCase, - useClass: UpdateBoardUseCase +export const isBoardPublicUseCase = { + provide: IS_BOARD_PUBLIC_USE_CASE, + useClass: IsBoardPublicUseCase }; export const updateBoardParticipantsUseCase = { - provide: TYPES.applications.UpdateBoardParticipantsUseCase, + provide: UPDATE_BOARD_PARTICIPANTS_USE_CASE, useClass: UpdateBoardParticipantsUseCase }; export const mergeBoardUseCase = { - provide: TYPES.applications.MergeBoardUseCase, + provide: MERGE_BOARD_USE_CASE, useClass: MergeBoardUseCase }; export const updateBoardPhaseUseCase = { - provide: TYPES.applications.UpdateBoardPhaseUseCase, + provide: UPDATE_BOARD_PHASE_USE_CASE, useClass: UpdateBoardPhaseUseCase }; -export const deleteBoardUseCase = { - provide: TYPES.applications.DeleteBoardUseCase, - useClass: DeleteBoardUseCase -}; +/* REPOSITORIES */ export const boardTimerRepository = { - provide: TYPES.repositories.BoardTimerRepository, + provide: BOARD_TIMER_REPOSITORY, useClass: BoardTimerRepository }; -export const sendBoardTimerStateService = { - provide: TYPES.services.SendBoardTimerStateService, - useClass: SendBoardTimerStateService -}; - -export const startBoardTimerService = { - provide: TYPES.services.StartBoardTimerService, - useClass: StartBoardTimerService -}; - -export const pauseBoardTimerService = { - provide: TYPES.services.PauseBoardTimerService, - useClass: PauseBoardTimerService -}; - -export const stopBoardTimerService = { - provide: TYPES.services.StopBoardTimerService, - useClass: StopBoardTimerService -}; - -export const updateBoardTimerDurationService = { - provide: TYPES.services.UpdateBoardTimerDurationService, - useClass: UpdateBoardTimerDurationService +export const boardRepository = { + provide: BOARD_REPOSITORY, + useClass: BoardRepository }; -export const sendBoardTimerTimeLeftService = { - provide: TYPES.services.SendBardTimerTimeLeftService, - useClass: SendBoardTimerTimeLeftService -}; +/* 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 -}; - -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 new file mode 100644 index 000000000..de6ba6c40 --- /dev/null +++ b/backend/src/modules/boards/constants.ts @@ -0,0 +1,65 @@ +/* SERVICES */ + +export const CREATE_BOARD_SERVICE = 'CreateBoardService'; + +export const GET_BOARD_SERVICE = 'GetBoardService'; + +export const UPDATE_BOARD_SERVICE = 'UpdateBoardService'; + +export const DELETE_BOARD_SERVICE = 'DeleteBoardService'; + +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'; + +/* 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'; + +/* 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/boards.controller.ts b/backend/src/modules/boards/controller/boards.controller.ts index d4d9093cc..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 '../interfaces/types'; +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 485cae0b0..4f88efb9c 100644 --- a/backend/src/modules/boards/controller/publicBoards.controller.ts +++ b/backend/src/modules/boards/controller/publicBoards.controller.ts @@ -11,15 +11,15 @@ import { ApiParam, ApiTags } from '@nestjs/swagger'; -import { TYPES } from '../interfaces/types'; +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) - private isBoardPublicUseCase: UseCase + @Inject(IS_BOARD_PUBLIC_USE_CASE) + private readonly isBoardPublicUseCase: UseCase ) {} @ApiOperation({ summary: 'Check if board is public' }) diff --git a/backend/src/modules/boards/interfaces/types.ts b/backend/src/modules/boards/interfaces/types.ts deleted file mode 100644 index 44ff2d4e3..000000000 --- a/backend/src/modules/boards/interfaces/types.ts +++ /dev/null @@ -1,39 +0,0 @@ -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', - 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' - } -}; 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/boards/services/create.board.service.spec.ts b/backend/src/modules/boards/services/create.board.service.spec.ts index 2fe199e99..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/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'; @@ -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 14624d793..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/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'; @@ -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 56c3df0cb..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/interfaces/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'; @@ -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 8bc50a5fc..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/interfaces/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'; 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 3f3096fa4..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/interfaces/types'; +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 b67052753..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 '../interfaces/types'; +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 bd9f430a8..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/interfaces/types'; +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 105b1a00a..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/interfaces/types'; +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 25e886485..ad508c6c8 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/interfaces/types'; +import { + BOARD_TIMER_REPOSITORY, + SEND_BOARD_TIMER_TIME_LEFT_SERVICE, + STOP_BOARD_TIMER_SERVICE +} from 'src/modules/boards/constants'; import { BoardTimerRepositoryInterface } from 'src/modules/boards/repositories/board-timer.repository.interface'; @Injectable() @@ -19,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(TYPES.services.StopBoardTimerService) - private stopBoardTimerService: StopBoardTimerServiceInterface, + @Inject(STOP_BOARD_TIMER_SERVICE) + private readonly stopBoardTimerService: StopBoardTimerServiceInterface, - @Inject(TYPES.services.SendBardTimerTimeLeftService) - private updateBoardTimerService: SendBoardTimerTimeLeftServiceInterface, + @Inject(SEND_BOARD_TIMER_TIME_LEFT_SERVICE) + 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 84ab564bd..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/interfaces/types'; +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 6e2a08e19..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/interfaces/types'; +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 688fa2130..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/interfaces/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'; 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 d4d7733f9..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/interfaces/types'; 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/boards/subscribers/after-user-paused-timer.subscriber.ts b/backend/src/modules/boards/subscribers/after-user-paused-timer.subscriber.ts index e7c0c351d..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/interfaces/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 0720a80fd..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/interfaces/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 ae74034cd..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/interfaces/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 3d1559e52..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/interfaces/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 ba91ae521..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/interfaces/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/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/columns/services/update.column.service.spec.ts b/backend/src/modules/columns/services/update.column.service.spec.ts index 7c8b1de73..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/interfaces/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 31e3b3131..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/interfaces/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/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/communication/consumers/slack-communication.consumer.spec.ts b/backend/src/modules/communication/consumers/slack-communication.consumer.spec.ts index fd940d018..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/interfaces/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 095f46254..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/interfaces/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/repository/schedule.repository.ts b/backend/src/modules/schedules/repository/schedule.repository.ts index 145cc8a55..a5f030c86 100644 --- a/backend/src/modules/schedules/repository/schedule.repository.ts +++ b/backend/src/modules/schedules/repository/schedule.repository.ts @@ -3,7 +3,7 @@ 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() @@ -11,7 +11,7 @@ export class ScheduleRepository 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/schedules/services/create.schedules.service.ts b/backend/src/modules/schedules/services/create.schedules.service.ts index 9fa7c40a5..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/interfaces/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/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/teams/services/delete.team.service.spec.ts b/backend/src/modules/teams/services/delete.team.service.spec.ts index c895a8a75..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/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'; @@ -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 adde9582b..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/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'; +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 54c08800d..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/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'; +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 1d838949b..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/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'; +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/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); } 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..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/interfaces/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 20712580a..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/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'; @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 63d2a62d0..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/interfaces/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 cc952d6ce..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/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,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 ) {}