diff --git a/Projects/App/Project.swift b/Projects/App/Project.swift index 6c2a70219..7e124e60a 100644 --- a/Projects/App/Project.swift +++ b/Projects/App/Project.swift @@ -34,8 +34,9 @@ let targets: [Target] = [ .Project.Features.RootFeature, .Project.Module.ThirdPartyLib, .Project.Service.Data, - TargetDependency.domain(target: .AppDomain), - TargetDependency.domain(target: .ArtistDomain) + .domain(target: .AppDomain), + .domain(target: .ArtistDomain), + .domain(target: .AuthDomain) ], settings: .settings( base: env.baseSetting, diff --git a/Projects/App/Sources/Application/AppComponent+Auth.swift b/Projects/App/Sources/Application/AppComponent+Auth.swift index 5be7f3408..9729a7364 100644 --- a/Projects/App/Sources/Application/AppComponent+Auth.swift +++ b/Projects/App/Sources/Application/AppComponent+Auth.swift @@ -6,10 +6,9 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // +import AuthDomain +import AuthDomainInterface import CommonFeature -import DataModule -import DomainModule -import NetworkModule import SignInFeature import StorageFeature diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index 09f3ff1ce..15e7faaa5 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -5,6 +5,8 @@ import AppDomainInterface import ArtistDomain import ArtistDomainInterface import ArtistFeature +import AuthDomain +import AuthDomainInterface import BaseFeature import ChartFeature import CommonFeature diff --git a/Projects/Domains/AppDomain/Sources/AppAPI/AppAPI.swift b/Projects/Domains/AppDomain/Sources/API/AppAPI.swift similarity index 100% rename from Projects/Domains/AppDomain/Sources/AppAPI/AppAPI.swift rename to Projects/Domains/AppDomain/Sources/API/AppAPI.swift diff --git a/Projects/Domains/ArtistDomain/Sources/ArtistAPI/ArtistAPI.swift b/Projects/Domains/ArtistDomain/Sources/API/ArtistAPI.swift similarity index 100% rename from Projects/Domains/ArtistDomain/Sources/ArtistAPI/ArtistAPI.swift rename to Projects/Domains/ArtistDomain/Sources/API/ArtistAPI.swift diff --git a/Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSource.swift b/Projects/Domains/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift similarity index 80% rename from Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSource.swift rename to Projects/Domains/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift index 9130efcf5..f6e0298f4 100644 --- a/Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSource.swift +++ b/Projects/Domains/AuthDomain/Interface/DataSource/RemoteAuthDataSource.swift @@ -1,6 +1,3 @@ -import DataMappingModule -import DomainModule -import ErrorModule import Foundation import RxSwift diff --git a/Projects/Services/DomainModule/Sources/Auth/Entitiy/AuthLoginEntity.swift b/Projects/Domains/AuthDomain/Interface/Entity/AuthLoginEntity.swift similarity index 100% rename from Projects/Services/DomainModule/Sources/Auth/Entitiy/AuthLoginEntity.swift rename to Projects/Domains/AuthDomain/Interface/Entity/AuthLoginEntity.swift diff --git a/Projects/Services/DomainModule/Sources/Auth/Entitiy/NaverUserInfoEntity.swift b/Projects/Domains/AuthDomain/Interface/Entity/NaverUserInfoEntity.swift similarity index 100% rename from Projects/Services/DomainModule/Sources/Auth/Entitiy/NaverUserInfoEntity.swift rename to Projects/Domains/AuthDomain/Interface/Entity/NaverUserInfoEntity.swift diff --git a/Projects/Services/DataMappingModule/Sources/Base/ProviderType.swift b/Projects/Domains/AuthDomain/Interface/Enum/ProviderType.swift similarity index 90% rename from Projects/Services/DataMappingModule/Sources/Base/ProviderType.swift rename to Projects/Domains/AuthDomain/Interface/Enum/ProviderType.swift index b602c5d0a..8b160b8ca 100644 --- a/Projects/Services/DataMappingModule/Sources/Base/ProviderType.swift +++ b/Projects/Domains/AuthDomain/Interface/Enum/ProviderType.swift @@ -8,7 +8,7 @@ import Foundation -public enum ProviderType: String, Codable { +public enum ProviderType: String { case naver case apple case google diff --git a/Projects/Services/DomainModule/Sources/Auth/Repository/AuthRepository.swift b/Projects/Domains/AuthDomain/Interface/Repository/AuthRepository.swift similarity index 85% rename from Projects/Services/DomainModule/Sources/Auth/Repository/AuthRepository.swift rename to Projects/Domains/AuthDomain/Interface/Repository/AuthRepository.swift index 999c408af..f4ba2c24a 100644 --- a/Projects/Services/DomainModule/Sources/Auth/Repository/AuthRepository.swift +++ b/Projects/Domains/AuthDomain/Interface/Repository/AuthRepository.swift @@ -1,5 +1,3 @@ -import DataMappingModule -import ErrorModule import Foundation import RxSwift diff --git a/Projects/Services/DomainModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCase.swift b/Projects/Domains/AuthDomain/Interface/UseCase/FetchNaverUserInfoUseCase.swift similarity index 87% rename from Projects/Services/DomainModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCase.swift rename to Projects/Domains/AuthDomain/Interface/UseCase/FetchNaverUserInfoUseCase.swift index 7dca84fae..b46dea17d 100644 --- a/Projects/Services/DomainModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCase.swift +++ b/Projects/Domains/AuthDomain/Interface/UseCase/FetchNaverUserInfoUseCase.swift @@ -1,4 +1,3 @@ -import DataMappingModule import Foundation import RxSwift diff --git a/Projects/Services/DomainModule/Sources/Auth/UseCases/FetchTokenUseCase.swift b/Projects/Domains/AuthDomain/Interface/UseCase/FetchTokenUseCase.swift similarity index 85% rename from Projects/Services/DomainModule/Sources/Auth/UseCases/FetchTokenUseCase.swift rename to Projects/Domains/AuthDomain/Interface/UseCase/FetchTokenUseCase.swift index 7e57cd994..a17b210a3 100644 --- a/Projects/Services/DomainModule/Sources/Auth/UseCases/FetchTokenUseCase.swift +++ b/Projects/Domains/AuthDomain/Interface/UseCase/FetchTokenUseCase.swift @@ -1,4 +1,3 @@ -import DataMappingModule import Foundation import RxSwift diff --git a/Projects/Domains/AuthDomain/Project.swift b/Projects/Domains/AuthDomain/Project.swift new file mode 100644 index 000000000..83c4528f9 --- /dev/null +++ b/Projects/Domains/AuthDomain/Project.swift @@ -0,0 +1,21 @@ +import DependencyPlugin +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project.module( + name: ModulePaths.Domain.AuthDomain.rawValue, + targets: [ + .interface(module: .domain(.AuthDomain)), + .implements( + module: .domain(.AuthDomain), + dependencies: [ + .domain(target: .BaseDomain), + .domain(target: .AuthDomain, type: .interface) + ] + ), + .tests( + module: .domain(.AuthDomain), + dependencies: [.domain(target: .AuthDomain)] + ) + ] +) diff --git a/Projects/Services/APIKit/Sources/API/AuthAPI.swift b/Projects/Domains/AuthDomain/Sources/API/AuthAPI.swift similarity index 93% rename from Projects/Services/APIKit/Sources/API/AuthAPI.swift rename to Projects/Domains/AuthDomain/Sources/API/AuthAPI.swift index 4ec9de5ac..9c01248eb 100644 --- a/Projects/Services/APIKit/Sources/API/AuthAPI.swift +++ b/Projects/Domains/AuthDomain/Sources/API/AuthAPI.swift @@ -1,7 +1,7 @@ -import DataMappingModule +import AuthDomainInterface +import BaseDomain import ErrorModule import Foundation -import KeychainModule import Moya public enum AuthAPI { @@ -53,7 +53,7 @@ extension AuthAPI: WMAPI { public var headers: [String: String]? { switch self { - case let .fetchNaverUserInfo(tokenType: tokenType, accessToken: accessToken): + case let .fetchNaverUserInfo(tokenType, accessToken): return ["Authorization": "\(tokenType) \(accessToken)"] default: return ["Content-Type": "application/json"] diff --git a/Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSourceImpl.swift b/Projects/Domains/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift similarity index 79% rename from Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSourceImpl.swift rename to Projects/Domains/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift index 8445b465d..442cd9e45 100644 --- a/Projects/Services/NetworkModule/Sources/Auth/Remote/RemoteAuthDataSourceImpl.swift +++ b/Projects/Domains/AuthDomain/Sources/DataSource/RemoteAuthDataSourceImpl.swift @@ -1,7 +1,5 @@ -import APIKit -import DataMappingModule -import DomainModule -import ErrorModule +import AuthDomainInterface +import BaseDomain import Foundation import RxSwift @@ -12,8 +10,7 @@ public final class RemoteAuthDataSourceImpl: BaseRemoteDataSource, Remo .map { $0.toDomain() } } - public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> RxSwift - .Single { + public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single { request(.fetchNaverUserInfo(tokenType: tokenType, accessToken: accessToken)) .map(NaverUserInfoResponseDTO.self) .map { $0.toDomain() } diff --git a/Projects/Services/DataModule/Sources/Auth/Repositories/AuthRepositoryImpl.swift b/Projects/Domains/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift similarity index 74% rename from Projects/Services/DataModule/Sources/Auth/Repositories/AuthRepositoryImpl.swift rename to Projects/Domains/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift index 2886eac92..07f12eae4 100644 --- a/Projects/Services/DataModule/Sources/Auth/Repositories/AuthRepositoryImpl.swift +++ b/Projects/Domains/AuthDomain/Sources/Repository/AuthRepositoryImpl.swift @@ -6,14 +6,10 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // -import DatabaseModule -import DataMappingModule -import DomainModule -import ErrorModule -import NetworkModule +import AuthDomainInterface import RxSwift -public struct AuthRepositoryImpl: AuthRepository { +public final class AuthRepositoryImpl: AuthRepository { private let remoteAuthDataSource: any RemoteAuthDataSource public init(remoteAuthDataSource: RemoteAuthDataSource) { @@ -24,8 +20,7 @@ public struct AuthRepositoryImpl: AuthRepository { remoteAuthDataSource.fetchToken(token: token, type: type) } - public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> RxSwift - .Single { + public func fetchNaverUserInfo(tokenType: String, accessToken: String) -> Single { remoteAuthDataSource.fetchNaverUserInfo(tokenType: tokenType, accessToken: accessToken) } } diff --git a/Projects/Services/DataMappingModule/Sources/Auth/Response/AuthLoginResponseDTO.swift b/Projects/Domains/AuthDomain/Sources/ResponseDTO/AuthLoginResponseDTO.swift similarity index 56% rename from Projects/Services/DataMappingModule/Sources/Auth/Response/AuthLoginResponseDTO.swift rename to Projects/Domains/AuthDomain/Sources/ResponseDTO/AuthLoginResponseDTO.swift index 86b51a698..bf89a42cd 100644 --- a/Projects/Services/DataMappingModule/Sources/Auth/Response/AuthLoginResponseDTO.swift +++ b/Projects/Domains/AuthDomain/Sources/ResponseDTO/AuthLoginResponseDTO.swift @@ -6,11 +6,21 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // +import AuthDomainInterface import Foundation -public struct AuthLoginResponseDTO: Codable, Equatable { +public struct AuthLoginResponseDTO: Decodable, Equatable { public let token: String + public static func == (lhs: Self, rhs: Self) -> Bool { return lhs.token == rhs.token } } + +public extension AuthLoginResponseDTO { + func toDomain() -> AuthLoginEntity { + AuthLoginEntity( + token: token + ) + } +} diff --git a/Projects/Services/DataMappingModule/Sources/Auth/Response/NaverUserInfoResponseDTO.swift b/Projects/Domains/AuthDomain/Sources/ResponseDTO/NaverUserInfoResponseDTO.swift similarity index 67% rename from Projects/Services/DataMappingModule/Sources/Auth/Response/NaverUserInfoResponseDTO.swift rename to Projects/Domains/AuthDomain/Sources/ResponseDTO/NaverUserInfoResponseDTO.swift index 38d7c16dd..ab794a055 100644 --- a/Projects/Services/DataMappingModule/Sources/Auth/Response/NaverUserInfoResponseDTO.swift +++ b/Projects/Domains/AuthDomain/Sources/ResponseDTO/NaverUserInfoResponseDTO.swift @@ -6,19 +6,24 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // +import AuthDomainInterface import Foundation -public struct NaverUserInfoResponseDTO: Codable, Equatable { +public struct NaverUserInfoResponseDTO: Decodable, Equatable { + public let resultcode, message: String + public let response: Response + public static func == (lhs: NaverUserInfoResponseDTO, rhs: NaverUserInfoResponseDTO) -> Bool { lhs.response.id == rhs.response.id } - - public let resultcode, message: String - public let response: Response } public extension NaverUserInfoResponseDTO { struct Response: Codable { public let id, nickname: String } + + func toDomain() -> NaverUserInfoEntity { + NaverUserInfoEntity(resultcode: resultcode, message: message, id: response.id, nickname: response.nickname) + } } diff --git a/Projects/Services/DataModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCaseImpl.swift b/Projects/Domains/AuthDomain/Sources/UseCase/FetchNaverUserInfoUseCaseImpl.swift similarity index 90% rename from Projects/Services/DataModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCaseImpl.swift rename to Projects/Domains/AuthDomain/Sources/UseCase/FetchNaverUserInfoUseCaseImpl.swift index 5afd48ee6..727bb7886 100644 --- a/Projects/Services/DataModule/Sources/Auth/UseCases/FetchNaverUserInfoUseCaseImpl.swift +++ b/Projects/Domains/AuthDomain/Sources/UseCase/FetchNaverUserInfoUseCaseImpl.swift @@ -6,9 +6,7 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // -import DataMappingModule -import DomainModule -import ErrorModule +import AuthDomainInterface import Foundation import RxSwift diff --git a/Projects/Services/DataModule/Sources/Auth/UseCases/FetchTokenUseCaseImpl.swift b/Projects/Domains/AuthDomain/Sources/UseCase/FetchTokenUseCaseImpl.swift similarity index 89% rename from Projects/Services/DataModule/Sources/Auth/UseCases/FetchTokenUseCaseImpl.swift rename to Projects/Domains/AuthDomain/Sources/UseCase/FetchTokenUseCaseImpl.swift index 7d94e4e9e..9f3c458e2 100644 --- a/Projects/Services/DataModule/Sources/Auth/UseCases/FetchTokenUseCaseImpl.swift +++ b/Projects/Domains/AuthDomain/Sources/UseCase/FetchTokenUseCaseImpl.swift @@ -6,9 +6,7 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // -import DataMappingModule -import DomainModule -import ErrorModule +import AuthDomainInterface import Foundation import RxSwift diff --git a/Projects/Domains/AuthDomain/Tests/AuthDomainTest.swift b/Projects/Domains/AuthDomain/Tests/AuthDomainTest.swift new file mode 100644 index 000000000..2e2cca093 --- /dev/null +++ b/Projects/Domains/AuthDomain/Tests/AuthDomainTest.swift @@ -0,0 +1,11 @@ +import XCTest + +final class AuthDomainTests: XCTestCase { + override func setUpWithError() throws {} + + override func tearDownWithError() throws {} + + func testExample() { + XCTAssertEqual(1, 1) + } +} diff --git a/Projects/Features/SignInFeature/Project.swift b/Projects/Features/SignInFeature/Project.swift index 9ac370fc9..290a85624 100644 --- a/Projects/Features/SignInFeature/Project.swift +++ b/Projects/Features/SignInFeature/Project.swift @@ -1,11 +1,20 @@ +import DependencyPlugin import ProjectDescription import ProjectDescriptionHelpers -let project = Project.makeModule( - name: "SignInFeature", - product: .staticFramework, - dependencies: [ - .Project.Features.PlayerFeature - ], - resources: ["Resources/**"] +let project = Project.module( + name: ModulePaths.Feature.SignInFeature.rawValue, + targets: [ + .implements( + module: .feature(.SignInFeature), + product: .staticFramework, + spec: .init( + resources: ["Resources/**"], + dependencies: [ + .feature(target: .PlayerFeature), + .domain(target: .AuthDomain, type: .interface) + ] + ) + ) + ] ) diff --git a/Projects/Features/SignInFeature/Sources/Components/SignInComponent.swift b/Projects/Features/SignInFeature/Sources/Components/SignInComponent.swift index 317da1398..dd6e1a29b 100644 --- a/Projects/Features/SignInFeature/Sources/Components/SignInComponent.swift +++ b/Projects/Features/SignInFeature/Sources/Components/SignInComponent.swift @@ -6,6 +6,7 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // +import AuthDomainInterface import DomainModule import Foundation import NeedleFoundation diff --git a/Projects/Features/SignInFeature/Sources/ViewModels/LoginViewModel.swift b/Projects/Features/SignInFeature/Sources/ViewModels/LoginViewModel.swift index 09a474f62..4942406f7 100644 --- a/Projects/Features/SignInFeature/Sources/ViewModels/LoginViewModel.swift +++ b/Projects/Features/SignInFeature/Sources/ViewModels/LoginViewModel.swift @@ -6,13 +6,14 @@ // Copyright © 2023 yongbeomkwak. All rights reserved. // +import AuthDomainInterface import AuthenticationServices import BaseFeature import CryptoSwift -import DataMappingModule import DomainModule import KeychainModule import NaverThirdPartyLogin +import RxCocoa import RxRelay import RxSwift import Utility diff --git a/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchNaverUserInfoTransfer.swift b/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchNaverUserInfoTransfer.swift deleted file mode 100644 index 1c23167b3..000000000 --- a/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchNaverUserInfoTransfer.swift +++ /dev/null @@ -1,23 +0,0 @@ -// -// FetchArtistListTransfer.swift -// NetworkModuleTests -// -// Created by KTH on 2023/02/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - -import DataMappingModule -import DomainModule -import Foundation -import Utility - -public extension NaverUserInfoResponseDTO { - func toDomain() -> NaverUserInfoEntity { - NaverUserInfoEntity( - resultcode: resultcode, - message: message, - id: response.id, - nickname: response.nickname - ) - } -} diff --git a/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchTokenTransfer.swift b/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchTokenTransfer.swift deleted file mode 100644 index f7d0fa731..000000000 --- a/Projects/Services/NetworkModule/Sources/Auth/DataTransfer/FetchTokenTransfer.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// FetchArtistListTransfer.swift -// NetworkModuleTests -// -// Created by KTH on 2023/02/08. -// Copyright © 2023 yongbeomkwak. All rights reserved. -// - -import DataMappingModule -import DomainModule -import Foundation -import Utility - -public extension AuthLoginResponseDTO { - func toDomain() -> AuthLoginEntity { - AuthLoginEntity( - token: token - ) - } -} diff --git a/graph.png b/graph.png index 2c6e53fbc..3e47628ca 100644 Binary files a/graph.png and b/graph.png differ