Skip to content

Commit 0bbb195

Browse files
authored
[#454] Infra 레이어에서 Domain 레이어 의존성을 제거한다 (#469)
* chore: TodoService의 Domain 의존성 제거 * chore: WebPage 데이터 흐름에서 Domain 에러 의존성 제거 * refactor: 도메인쪽 에러로 매핑하는 메서드이므로 toDomain()으로 수정 * refactor: 불필요 import문 제거 * refactor: 공통 설정 모델을 Core로 이동 * refactor: 인증 에러를 Data와 Domain 경계에서 매핑하도록 정리 * refactor: PushNotificationService의 Domain 의존성 제거 * refactor: TodoCategoryService 응답을 Data 모델로 분리하여 Domain 의존성 제거 * chore: Infra 레이어에서 Domain 레이어 의존성 완전 제거 * refactor: TodoCategory 선호도 중복 확인 로직 개선
1 parent 7bb3983 commit 0bbb195

73 files changed

Lines changed: 565 additions & 316 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Application/DevLogDomain/Sources/Entity/PushNotificationQuery.swift renamed to Application/DevLogCore/Sources/PushNotificationQuery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// PushNotificationQuery.swift
3-
// DevLogDomain
3+
// DevLogCore
44
//
55
// Created by opfic on 2/18/26.
66
//

Application/DevLogDomain/Sources/Entity/SystemTheme.swift renamed to Application/DevLogCore/Sources/SystemTheme.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// SystemTheme.swift
3-
// DevLogDomain
3+
// DevLogCore
44
//
55
// Created by opfic on 5/6/25.
66
//

Application/DevLogDomain/Sources/Entity/TodayDisplayOptions.swift renamed to Application/DevLogCore/Sources/TodayDisplayOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// TodayDisplayOptions.swift
3-
// DevLogDomain
3+
// DevLogCore
44
//
55
// Created by opfic on 3/6/26.
66
//

Application/DevLogDomain/Sources/Entity/TodoQuery.swift renamed to Application/DevLogCore/Sources/TodoQuery.swift

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// TodoQuery.swift
3-
// DevLogDomain
3+
// DevLogCore
44
//
55
// Created by opfic on 2/21/26.
66
//
@@ -14,47 +14,17 @@ public struct TodoQuery: Equatable {
1414
case deletedAt
1515
case updatedAt
1616
case dueDate
17-
18-
public var fieldName: String {
19-
switch self {
20-
case .createdAt:
21-
return "createdAt"
22-
case .completedAt:
23-
return "completedAt"
24-
case .deletedAt:
25-
return "deletedAt"
26-
case .updatedAt:
27-
return "updatedAt"
28-
case .dueDate:
29-
return "dueDate"
30-
}
31-
}
3217
}
3318

3419
public enum SortOrder: Equatable, Hashable {
3520
case latest
3621
case oldest
37-
38-
public var isDescending: Bool {
39-
self == .latest
40-
}
4122
}
4223

4324
public enum CompletionFilter: Equatable, Hashable {
4425
case all
4526
case incomplete
4627
case completed
47-
48-
public var isCompletedValue: Bool? {
49-
switch self {
50-
case .all:
51-
return nil
52-
case .incomplete:
53-
return false
54-
case .completed:
55-
return true
56-
}
57-
}
5828
}
5929

6030
public enum DueDateFilter: Equatable, Hashable {
@@ -63,7 +33,7 @@ public struct TodoQuery: Equatable {
6333
case withoutDueDate
6434
}
6535

66-
public var category: TodoCategory?
36+
public var categoryId: String?
6737
public var keyword: String?
6838
public var isPinned: Bool?
6939
public var completionFilter: CompletionFilter
@@ -77,7 +47,7 @@ public struct TodoQuery: Equatable {
7747
public var fetchAllPages: Bool
7848

7949
public init(
80-
category: TodoCategory? = nil,
50+
categoryId: String? = nil,
8151
keyword: String? = nil,
8252
isPinned: Bool? = nil,
8353
completionFilter: CompletionFilter = .all,
@@ -90,7 +60,7 @@ public struct TodoQuery: Equatable {
9060
pageSize: Int = 20,
9161
fetchAllPages: Bool = false
9262
) {
93-
self.category = category
63+
self.categoryId = categoryId
9464
self.keyword = keyword
9565
self.isPinned = isPinned
9666
self.completionFilter = completionFilter

Application/DevLogData/Sources/Common/DataLayerError.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public enum DataError: Error {
4444
}
4545
}
4646

47+
public enum DataLayerError: Error {
48+
case notAuthenticated
49+
case linkCredentialAlreadyInUse
50+
}
51+
4752
public extension Error {
4853
var isSocialLoginCancelled: Bool {
4954
switch self {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// TodoCategoryPreferenceResponse.swift
3+
// DevLogData
4+
//
5+
// Created by opfic on 5/16/26.
6+
//
7+
8+
import Foundation
9+
10+
public struct TodoCategoryPreferenceResponse: Equatable {
11+
public enum Category: Equatable {
12+
case system(String)
13+
case user(UserCategory)
14+
}
15+
16+
public struct UserCategory: Equatable {
17+
public let id: String
18+
public let name: String
19+
public let colorHex: String
20+
21+
public init(
22+
id: String,
23+
name: String,
24+
colorHex: String
25+
) {
26+
self.id = id
27+
self.name = name
28+
self.colorHex = colorHex
29+
}
30+
}
31+
32+
public let category: Category
33+
public let isVisible: Bool
34+
35+
public init(
36+
category: Category,
37+
isVisible: Bool
38+
) {
39+
self.category = category
40+
self.isVisible = isVisible
41+
}
42+
}

Application/DevLogData/Sources/DTO/TodoCursorDTO.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
//
77

88
import Foundation
9-
import DevLogDomain
109

1110
public struct TodoCursorDTO {
1211
public let primarySortDate: Date?
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// ErrorMapping.swift
3+
// DevLogData
4+
//
5+
// Created by opfic on 5/16/26.
6+
//
7+
8+
import DevLogDomain
9+
10+
extension Error {
11+
func toDomain() -> Error {
12+
switch self as? DataLayerError {
13+
case .notAuthenticated:
14+
return AuthError.notAuthenticated
15+
case .linkCredentialAlreadyInUse:
16+
return AuthError.linkCredentialAlreadyInUse
17+
case .none:
18+
return self
19+
}
20+
}
21+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
//
2+
// TodoCategoryMapping.swift
3+
// DevLogData
4+
//
5+
// Created by opfic on 5/16/26.
6+
//
7+
8+
import DevLogDomain
9+
10+
extension TodoCategoryPreferenceResponse {
11+
static func fromDomain(_ preference: TodoCategoryPreference) -> Self {
12+
switch preference.category {
13+
case .system(let systemTodoCategory):
14+
return TodoCategoryPreferenceResponse(
15+
category: .system(systemTodoCategory.rawValue),
16+
isVisible: preference.isVisible
17+
)
18+
case .user(let userTodoCategory):
19+
return TodoCategoryPreferenceResponse(
20+
category: .user(
21+
UserCategory(
22+
id: userTodoCategory.id,
23+
name: userTodoCategory.name,
24+
colorHex: userTodoCategory.colorHex
25+
)
26+
),
27+
isVisible: preference.isVisible
28+
)
29+
}
30+
}
31+
32+
func toDomain() -> TodoCategoryPreference? {
33+
switch category {
34+
case .system(let rawValue):
35+
guard let systemTodoCategory = SystemTodoCategory(rawValue: rawValue) else {
36+
return nil
37+
}
38+
39+
return TodoCategoryPreference(
40+
category: .system(systemTodoCategory),
41+
isVisible: isVisible
42+
)
43+
case .user(let userCategory):
44+
return TodoCategoryPreference(
45+
category: .user(
46+
UserTodoCategory(
47+
id: userCategory.id,
48+
name: userCategory.name,
49+
colorHex: userCategory.colorHex
50+
)
51+
),
52+
isVisible: isVisible
53+
)
54+
}
55+
}
56+
}
57+
58+
extension Array where Element == TodoCategoryPreferenceResponse {
59+
func toDomain() -> [TodoCategoryPreference] {
60+
let preferences = compactMap { $0.toDomain() }
61+
guard !preferences.isEmpty else {
62+
return defaultTodoCategoryPreferences()
63+
}
64+
65+
return mergedTodoCategoryPreferences(preferences)
66+
}
67+
}
68+
69+
private func defaultTodoCategoryPreferences() -> [TodoCategoryPreference] {
70+
SystemTodoCategory.allCases.map {
71+
TodoCategoryPreference(category: .system($0), isVisible: true)
72+
}
73+
}
74+
75+
private func mergedTodoCategoryPreferences(
76+
_ preferences: [TodoCategoryPreference]
77+
) -> [TodoCategoryPreference] {
78+
var mergedPreferences = preferences
79+
let existingSystemTodoCategories = Set<SystemTodoCategory>(
80+
preferences.compactMap { preference in
81+
guard case .system(let systemTodoCategory) = preference.category else {
82+
return nil
83+
}
84+
85+
return systemTodoCategory
86+
}
87+
)
88+
89+
for systemTodoCategory in SystemTodoCategory.allCases {
90+
if existingSystemTodoCategories.contains(systemTodoCategory) { continue }
91+
92+
mergedPreferences.append(
93+
TodoCategoryPreference(
94+
category: .system(systemTodoCategory),
95+
isVisible: true
96+
)
97+
)
98+
}
99+
100+
return mergedPreferences
101+
}

Application/DevLogData/Sources/Protocol/PushNotificationService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Combine
99
import Foundation
10-
import DevLogDomain
10+
import DevLogCore
1111

1212
public protocol PushNotificationService {
1313
func fetchPushNotificationEnabled() async throws -> Bool

0 commit comments

Comments
 (0)