diff --git a/src/domain/index.ts b/src/domain/index.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/data/protocols/ai/aiClient.protocol.ts b/src/domain/protocols/ai/aiClient.protocol.ts similarity index 100% rename from src/data/protocols/ai/aiClient.protocol.ts rename to src/domain/protocols/ai/aiClient.protocol.ts diff --git a/src/data/protocols/ai/index.ts b/src/domain/protocols/ai/index.ts similarity index 100% rename from src/data/protocols/ai/index.ts rename to src/domain/protocols/ai/index.ts diff --git a/src/data/protocols/http/httpClient.protocol.ts b/src/domain/protocols/http/httpClient.protocol.ts similarity index 100% rename from src/data/protocols/http/httpClient.protocol.ts rename to src/domain/protocols/http/httpClient.protocol.ts diff --git a/src/data/protocols/http/index.ts b/src/domain/protocols/http/index.ts similarity index 100% rename from src/data/protocols/http/index.ts rename to src/domain/protocols/http/index.ts diff --git a/src/domain/services/ai.service.ts b/src/domain/services/ai.service.ts index c76635e..1870a7e 100644 --- a/src/domain/services/ai.service.ts +++ b/src/domain/services/ai.service.ts @@ -1,5 +1,3 @@ -import { ListMoviesEntity, MovieEntity } from "../entities"; - export interface AiService { generateResponse: (prompt: AiService.Params) => Promise; } diff --git a/src/infrastructure/ai/chatGPTAiClient.infra.ts b/src/infrastructure/ai/chatGPTAiClient.infra.ts index d473f09..ce9d9b2 100644 --- a/src/infrastructure/ai/chatGPTAiClient.infra.ts +++ b/src/infrastructure/ai/chatGPTAiClient.infra.ts @@ -1,4 +1,4 @@ -import { AiClient, AiPrompt, AiResponse } from "@/data/protocols/ai"; +import { AiClient, AiPrompt, AiResponse } from "@/domain/protocols/ai"; import { chunkProcessor, G4F } from "g4f"; export class ChatGPTAiClient implements AiClient { diff --git a/src/helpers/index.ts b/src/infrastructure/helpers/index.ts similarity index 100% rename from src/helpers/index.ts rename to src/infrastructure/helpers/index.ts diff --git a/src/helpers/movieEntity.helper.ts b/src/infrastructure/helpers/movieEntity.helper.ts similarity index 100% rename from src/helpers/movieEntity.helper.ts rename to src/infrastructure/helpers/movieEntity.helper.ts diff --git a/src/infrastructure/http/axiosHttpClient.infra.ts b/src/infrastructure/http/axiosHttpClient.infra.ts index d497b8f..78fc2db 100644 --- a/src/infrastructure/http/axiosHttpClient.infra.ts +++ b/src/infrastructure/http/axiosHttpClient.infra.ts @@ -1,4 +1,4 @@ -import { HttpRequest, HttpResponse, HttpClient } from "@/data/protocols/http"; +import { HttpRequest, HttpResponse, HttpClient } from "@/domain/protocols/http"; import axios, { AxiosResponse } from "axios"; diff --git a/src/data/repositories/index.ts b/src/infrastructure/repositories/index.ts similarity index 100% rename from src/data/repositories/index.ts rename to src/infrastructure/repositories/index.ts diff --git a/src/data/repositories/moviesImpl.repository.ts b/src/infrastructure/repositories/moviesImpl.repository.ts similarity index 89% rename from src/data/repositories/moviesImpl.repository.ts rename to src/infrastructure/repositories/moviesImpl.repository.ts index c7d55d8..386091f 100644 --- a/src/data/repositories/moviesImpl.repository.ts +++ b/src/infrastructure/repositories/moviesImpl.repository.ts @@ -1,13 +1,13 @@ import { ListMoviesEntity, MovieEntity } from "@/domain/entities"; import { MoviesRepository } from "@/domain/repositories"; -import { HttpClient, HttpStatusCode } from "../protocols/http"; +import { HttpClient, HttpStatusCode } from "../../domain/protocols/http"; import { Environment } from "@/main/config"; import { AccessDeniedError, NotFoundError, UnexpectedError, } from "@/domain/errors"; -import { movieFromJson, moviesFromJsonList } from "@/helpers"; +import { movieFromJson, moviesFromJsonList } from "@/infrastructure/helpers"; export class MoviesRepositoryImpl implements MoviesRepository { constructor(private readonly httpClient: HttpClient) {} diff --git a/src/data/services/aiImpl.service.ts b/src/infrastructure/services/aiImpl.service.ts similarity index 89% rename from src/data/services/aiImpl.service.ts rename to src/infrastructure/services/aiImpl.service.ts index 6be8151..45a9daf 100644 --- a/src/data/services/aiImpl.service.ts +++ b/src/infrastructure/services/aiImpl.service.ts @@ -4,7 +4,7 @@ import { NotFoundError, UnexpectedError, } from "@/domain/errors"; -import { HttpClient, HttpStatusCode } from "../protocols/http"; +import { HttpClient, HttpStatusCode } from "../../domain/protocols/http"; import { AiService } from "./../../domain/services/ai.service"; export class AiServiceImpl implements AiService { diff --git a/src/data/services/index.ts b/src/infrastructure/services/index.ts similarity index 100% rename from src/data/services/index.ts rename to src/infrastructure/services/index.ts diff --git a/src/usecases/getMovie.usecase.ts b/src/infrastructure/usecases/getMovie.usecase.ts similarity index 100% rename from src/usecases/getMovie.usecase.ts rename to src/infrastructure/usecases/getMovie.usecase.ts diff --git a/src/usecases/getMovieSuggestion.usecase.ts b/src/infrastructure/usecases/getMovieSuggestion.usecase.ts similarity index 100% rename from src/usecases/getMovieSuggestion.usecase.ts rename to src/infrastructure/usecases/getMovieSuggestion.usecase.ts diff --git a/src/usecases/getMovies.usecase.ts b/src/infrastructure/usecases/getMovies.usecase.ts similarity index 100% rename from src/usecases/getMovies.usecase.ts rename to src/infrastructure/usecases/getMovies.usecase.ts diff --git a/src/usecases/index.ts b/src/infrastructure/usecases/index.ts similarity index 100% rename from src/usecases/index.ts rename to src/infrastructure/usecases/index.ts diff --git a/src/main/factories/repositories/movies.factory.ts b/src/main/factories/repositories/movies.factory.ts index 7e90d1c..f846b61 100644 --- a/src/main/factories/repositories/movies.factory.ts +++ b/src/main/factories/repositories/movies.factory.ts @@ -1,4 +1,4 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; import { MoviesRepository } from "@/domain/repositories"; import { makeAxiosHttpClient } from "../http/axiosHttpClient.factory"; diff --git a/src/main/factories/services/ai.factory.ts b/src/main/factories/services/ai.factory.ts index b19d89f..32fa6a8 100644 --- a/src/main/factories/services/ai.factory.ts +++ b/src/main/factories/services/ai.factory.ts @@ -1,7 +1,7 @@ -import { AiServiceImpl } from "@/data/services"; import { AiService } from "@/domain/services"; import { makeAxiosHttpClient } from "../http/axiosHttpClient.factory"; import { Environment } from "@/main/config"; +import { AiServiceImpl } from "@/infrastructure/services"; export const makeAiService = (): AiService => new AiServiceImpl(makeAxiosHttpClient(), Environment.baseUrlAi); diff --git a/src/main/factories/usecases/getMovie.factory.ts b/src/main/factories/usecases/getMovie.factory.ts index 94de9d3..01df307 100644 --- a/src/main/factories/usecases/getMovie.factory.ts +++ b/src/main/factories/usecases/getMovie.factory.ts @@ -1,6 +1,6 @@ import { GetMovieUsecase } from "@/domain/usecases"; -import { GetMovieUsecaseImpl } from "@/usecases"; import { makeMoviesRepository } from "../repositories/movies.factory"; +import { GetMovieUsecaseImpl } from "@/infrastructure/usecases"; export const makeGetMovieUsecase = (): GetMovieUsecase => new GetMovieUsecaseImpl(makeMoviesRepository()); diff --git a/src/main/factories/usecases/getMovieSuggestion.factory.ts b/src/main/factories/usecases/getMovieSuggestion.factory.ts index 4120ad3..cb0d163 100644 --- a/src/main/factories/usecases/getMovieSuggestion.factory.ts +++ b/src/main/factories/usecases/getMovieSuggestion.factory.ts @@ -1,8 +1,8 @@ import { GetMovieSuggestionUsecase } from "@/domain/usecases"; import { makeMoviesRepository } from "../repositories/movies.factory"; -import { GetMovieSuggestionUsecaseImpl } from "@/usecases/getMovieSuggestion.usecase"; import { makeAiService } from "../services/ai.factory"; +import { GetMovieSuggestionUsecaseImpl } from "@/infrastructure/usecases/getMovieSuggestion.usecase"; export const makeGetMovieSuggestionUsecase = (): GetMovieSuggestionUsecase => new GetMovieSuggestionUsecaseImpl(makeMoviesRepository(), makeAiService()); diff --git a/src/main/factories/usecases/getMovies.factory.ts b/src/main/factories/usecases/getMovies.factory.ts index de1a991..95297d9 100644 --- a/src/main/factories/usecases/getMovies.factory.ts +++ b/src/main/factories/usecases/getMovies.factory.ts @@ -1,6 +1,6 @@ import { GetMoviesUsecase } from "@/domain/usecases"; -import { GetMoviesUsecaseImpl } from "@/usecases"; import { makeMoviesRepository } from "../repositories/movies.factory"; +import { GetMoviesUsecaseImpl } from "@/infrastructure/usecases"; export const makeGetMoviesUsecase = (): GetMoviesUsecase => new GetMoviesUsecaseImpl(makeMoviesRepository()); diff --git a/src/pages/api/chat.ts b/src/pages/api/chat.ts index c9e610d..23db91e 100644 --- a/src/pages/api/chat.ts +++ b/src/pages/api/chat.ts @@ -1,4 +1,3 @@ -import { ChatGPTAiClient } from "@/infrastructure/ai/chatGPTAiClient.infra"; import { makeChatGptAiClient } from "@/main/factories/ai/chatGPTAiClient.factory"; import { NextApiRequest, NextApiResponse } from "next"; diff --git a/tests/data/mocks/index.ts b/tests/data/mocks/index.ts deleted file mode 100644 index b46e1f5..0000000 --- a/tests/data/mocks/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./http.mock"; -export * from "./moviesRepositoryImpl.mock"; -export * from "./aiServiceImpl.mock"; diff --git a/tests/domain/mocks/index.ts b/tests/domain/mocks/index.ts deleted file mode 100644 index a5e07af..0000000 --- a/tests/domain/mocks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./movie.mock"; diff --git a/tests/infrastructure/http/axiosHttpClient.spec.ts b/tests/infrastructure/http/axiosHttpClient.spec.ts index 3aa93a3..929a198 100644 --- a/tests/infrastructure/http/axiosHttpClient.spec.ts +++ b/tests/infrastructure/http/axiosHttpClient.spec.ts @@ -1,6 +1,5 @@ import { AxiosHttpClient } from "@/infrastructure/http"; -import { mockAxios, mockHttpResponse } from "../mocks"; -import { mockHttpRequest } from "../../data/mocks"; +import { mockAxios, mockHttpRequest, mockHttpResponse } from "../mocks"; import axios from "axios"; diff --git a/tests/data/mocks/aiServiceImpl.mock.ts b/tests/infrastructure/mocks/aiServiceImpl.mock.ts similarity index 100% rename from tests/data/mocks/aiServiceImpl.mock.ts rename to tests/infrastructure/mocks/aiServiceImpl.mock.ts diff --git a/tests/usecases/mocks/getMovieSuggestionUsecaseImpl.mock.ts b/tests/infrastructure/mocks/getMovieSuggestionUsecaseImpl.mock.ts similarity index 100% rename from tests/usecases/mocks/getMovieSuggestionUsecaseImpl.mock.ts rename to tests/infrastructure/mocks/getMovieSuggestionUsecaseImpl.mock.ts diff --git a/tests/usecases/mocks/getMovieUsecaseImpl.mock.ts b/tests/infrastructure/mocks/getMovieUsecaseImpl.mock.ts similarity index 100% rename from tests/usecases/mocks/getMovieUsecaseImpl.mock.ts rename to tests/infrastructure/mocks/getMovieUsecaseImpl.mock.ts diff --git a/tests/data/mocks/http.mock.ts b/tests/infrastructure/mocks/http.mock.ts similarity index 91% rename from tests/data/mocks/http.mock.ts rename to tests/infrastructure/mocks/http.mock.ts index ef6f21b..ca8ea8d 100644 --- a/tests/data/mocks/http.mock.ts +++ b/tests/infrastructure/mocks/http.mock.ts @@ -3,7 +3,7 @@ import { HttpResponse, HttpStatusCode, HttpClient, -} from "@/data/protocols/http"; +} from "@/domain/protocols/http"; import { faker } from "@faker-js/faker"; diff --git a/tests/infrastructure/mocks/index.ts b/tests/infrastructure/mocks/index.ts index 08aec45..7451c71 100644 --- a/tests/infrastructure/mocks/index.ts +++ b/tests/infrastructure/mocks/index.ts @@ -1 +1,5 @@ export * from "./axios.mock"; +export * from "./http.mock"; +export * from "./moviesRepositoryImpl.mock"; +export * from "./aiServiceImpl.mock"; +export * from "./movie.mock"; diff --git a/tests/domain/mocks/movie.mock.ts b/tests/infrastructure/mocks/movie.mock.ts similarity index 100% rename from tests/domain/mocks/movie.mock.ts rename to tests/infrastructure/mocks/movie.mock.ts diff --git a/tests/data/mocks/moviesRepositoryImpl.mock.ts b/tests/infrastructure/mocks/moviesRepositoryImpl.mock.ts similarity index 100% rename from tests/data/mocks/moviesRepositoryImpl.mock.ts rename to tests/infrastructure/mocks/moviesRepositoryImpl.mock.ts diff --git a/tests/data/repositories/moviesRepositoryImpl.spec.ts b/tests/infrastructure/repositories/moviesRepositoryImpl.spec.ts similarity index 93% rename from tests/data/repositories/moviesRepositoryImpl.spec.ts rename to tests/infrastructure/repositories/moviesRepositoryImpl.spec.ts index f06caff..49d71c3 100644 --- a/tests/data/repositories/moviesRepositoryImpl.spec.ts +++ b/tests/infrastructure/repositories/moviesRepositoryImpl.spec.ts @@ -1,10 +1,10 @@ -import { MoviesRepositoryImpl } from "@/data/repositories/moviesImpl.repository"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories/moviesImpl.repository"; import { HttpClientSpy, mockGetMovieRepositoryImpl, mockGetMoviesRepositoryImpl, } from "../mocks"; -import { HttpStatusCode } from "@/data/protocols/http"; +import { HttpStatusCode } from "@/domain/protocols/http"; import { Environment } from "@/main/config"; import { AccessDeniedError, diff --git a/tests/data/services/aiServiceImpl.spec.ts b/tests/infrastructure/services/aiServiceImpl.spec.ts similarity index 92% rename from tests/data/services/aiServiceImpl.spec.ts rename to tests/infrastructure/services/aiServiceImpl.spec.ts index a4118e8..d8f0d14 100644 --- a/tests/data/services/aiServiceImpl.spec.ts +++ b/tests/infrastructure/services/aiServiceImpl.spec.ts @@ -1,12 +1,12 @@ -import { AiServiceImpl } from "@/data/services"; import { HttpClientSpy, mockGenerateResponse } from "../mocks"; import { Environment } from "@/main/config"; -import { HttpStatusCode } from "@/data/protocols/http"; +import { HttpStatusCode } from "@/domain/protocols/http"; import { BadRequestError, NotFoundError, UnexpectedError, } from "@/domain/errors"; +import { AiServiceImpl } from "@/infrastructure/services"; type SutTypes = { sut: AiServiceImpl; diff --git a/tests/usecases/getMovieSuggestionUsecaseImpl.spec.ts b/tests/infrastructure/usecases/getMovieSuggestionUsecaseImpl.spec.ts similarity index 88% rename from tests/usecases/getMovieSuggestionUsecaseImpl.spec.ts rename to tests/infrastructure/usecases/getMovieSuggestionUsecaseImpl.spec.ts index 01aebed..0014ad2 100644 --- a/tests/usecases/getMovieSuggestionUsecaseImpl.spec.ts +++ b/tests/infrastructure/usecases/getMovieSuggestionUsecaseImpl.spec.ts @@ -1,14 +1,15 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; -import { AiServiceImpl } from "@/data/services"; -import { GetMovieSuggestionUsecaseImpl } from "@/usecases/getMovieSuggestion.usecase"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; + import { mock } from "jest-mock-extended"; import { listMoviesMock, mockGenerateResponse, movieMock, -} from "./mocks/getMovieSuggestionUsecaseImpl.mock"; +} from "../mocks/getMovieSuggestionUsecaseImpl.mock"; import { ListMoviesEntity } from "@/domain/entities"; import { UnexpectedError } from "@/domain/errors"; +import { AiServiceImpl } from "@/infrastructure/services"; +import { GetMovieSuggestionUsecaseImpl } from "@/infrastructure/usecases/getMovieSuggestion.usecase"; type SutTypes = { repository: ReturnType>; diff --git a/tests/usecases/getMovieUsecaseImpl.spec.ts b/tests/infrastructure/usecases/getMovieUsecaseImpl.spec.ts similarity index 84% rename from tests/usecases/getMovieUsecaseImpl.spec.ts rename to tests/infrastructure/usecases/getMovieUsecaseImpl.spec.ts index 9135d34..1e2d0fe 100644 --- a/tests/usecases/getMovieUsecaseImpl.spec.ts +++ b/tests/infrastructure/usecases/getMovieUsecaseImpl.spec.ts @@ -1,7 +1,8 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; -import { GetMovieUsecaseImpl } from "@/usecases"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; + import { mock } from "jest-mock-extended"; -import { movieMock } from "./mocks/getMovieUsecaseImpl.mock"; +import { movieMock } from "../mocks/getMovieUsecaseImpl.mock"; +import { GetMovieUsecaseImpl } from "@/infrastructure/usecases"; type SutTypes = { movieRepository: ReturnType>; diff --git a/tests/usecases/getMoviesUsecaseImpl.spec.ts b/tests/infrastructure/usecases/getMoviesUsecaseImpl.spec.ts similarity index 84% rename from tests/usecases/getMoviesUsecaseImpl.spec.ts rename to tests/infrastructure/usecases/getMoviesUsecaseImpl.spec.ts index 8a071cf..b7c3150 100644 --- a/tests/usecases/getMoviesUsecaseImpl.spec.ts +++ b/tests/infrastructure/usecases/getMoviesUsecaseImpl.spec.ts @@ -1,7 +1,8 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; -import { GetMoviesUsecaseImpl } from "@/usecases"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; + import { mock } from "jest-mock-extended"; -import { listMoviesMock, movieMock } from "./mocks/getMovieUsecaseImpl.mock"; +import { listMoviesMock, movieMock } from "../mocks/getMovieUsecaseImpl.mock"; +import { GetMoviesUsecaseImpl } from "@/infrastructure/usecases"; type SutTypes = { movieRepository: ReturnType>; diff --git a/tests/main/factories/repositories/movies.spec.ts b/tests/main/factories/repositories/movies.spec.ts index 0024184..3a79560 100644 --- a/tests/main/factories/repositories/movies.spec.ts +++ b/tests/main/factories/repositories/movies.spec.ts @@ -1,4 +1,4 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; import { MoviesRepository } from "@/domain/repositories"; import { AxiosHttpClient } from "@/infrastructure/http"; diff --git a/tests/main/factories/services/ai.spec.ts b/tests/main/factories/services/ai.spec.ts index ec756a9..7d8c4f0 100644 --- a/tests/main/factories/services/ai.spec.ts +++ b/tests/main/factories/services/ai.spec.ts @@ -1,6 +1,6 @@ -import { AiServiceImpl } from "@/data/services"; import { AiService } from "@/domain/services"; import { AxiosHttpClient } from "@/infrastructure/http"; +import { AiServiceImpl } from "@/infrastructure/services"; import { Environment } from "@/main/config"; type SutTypes = { diff --git a/tests/main/factories/usecases/getMovie.spec.ts b/tests/main/factories/usecases/getMovie.spec.ts index b60fdef..a2ce5dd 100644 --- a/tests/main/factories/usecases/getMovie.spec.ts +++ b/tests/main/factories/usecases/getMovie.spec.ts @@ -1,8 +1,8 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; import { MoviesRepository } from "@/domain/repositories"; import { GetMovieUsecase } from "@/domain/usecases"; import { AxiosHttpClient } from "@/infrastructure/http"; -import { GetMovieUsecaseImpl } from "@/usecases"; +import { GetMovieUsecaseImpl } from "@/infrastructure/usecases"; type SutTypes = { axiosHttpClient: AxiosHttpClient; diff --git a/tests/main/factories/usecases/getMovieSuggestion.spec.ts b/tests/main/factories/usecases/getMovieSuggestion.spec.ts index 609fc86..7036477 100644 --- a/tests/main/factories/usecases/getMovieSuggestion.spec.ts +++ b/tests/main/factories/usecases/getMovieSuggestion.spec.ts @@ -1,11 +1,12 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; -import { AiServiceImpl } from "@/data/services"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; + import { MoviesRepository } from "@/domain/repositories"; import { AiService } from "@/domain/services"; import { GetMovieSuggestionUsecase, GetMoviesUsecase } from "@/domain/usecases"; import { AxiosHttpClient } from "@/infrastructure/http"; import { Environment } from "@/main/config"; -import { GetMovieSuggestionUsecaseImpl } from "@/usecases/getMovieSuggestion.usecase"; +import { AiServiceImpl } from "@/infrastructure/services"; +import { GetMovieSuggestionUsecaseImpl } from "@/infrastructure/usecases/getMovieSuggestion.usecase"; type SutTypes = { axiosHttpClient: AxiosHttpClient; diff --git a/tests/main/factories/usecases/getMovies.spec.ts b/tests/main/factories/usecases/getMovies.spec.ts index 1bf66b3..fc433af 100644 --- a/tests/main/factories/usecases/getMovies.spec.ts +++ b/tests/main/factories/usecases/getMovies.spec.ts @@ -1,8 +1,8 @@ -import { MoviesRepositoryImpl } from "@/data/repositories"; +import { MoviesRepositoryImpl } from "@/infrastructure/repositories"; import { MoviesRepository } from "@/domain/repositories"; import { GetMoviesUsecase } from "@/domain/usecases"; import { AxiosHttpClient } from "@/infrastructure/http"; -import { GetMoviesUsecaseImpl } from "@/usecases"; +import { GetMoviesUsecaseImpl } from "@/infrastructure/usecases"; type SutTypes = { axiosHttpClient: AxiosHttpClient;