Skip to content

Commit ba32f0b

Browse files
More explicit dependencies (#215)
* More explicit dependencies to help with test support library. * revert * fix --------- Co-authored-by: Stephen Celis <[email protected]>
1 parent 61e9e06 commit ba32f0b

File tree

12 files changed

+218
-194
lines changed

12 files changed

+218
-194
lines changed

Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let package = Package(
2929
dependencies: [
3030
.package(url: "https://github.com/apple/swift-collections", from: "1.0.0"),
3131
.package(url: "https://github.com/groue/GRDB.swift", from: "7.6.0"),
32+
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
3233
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
3334
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
3435
.package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"),
@@ -47,6 +48,7 @@ let package = Package(
4748
.target(
4849
name: "SQLiteData",
4950
dependencies: [
51+
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
5052
.product(name: "Dependencies", package: "swift-dependencies"),
5153
.product(name: "GRDB", package: "GRDB.swift"),
5254
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
@@ -64,7 +66,9 @@ let package = Package(
6466
name: "SQLiteDataTestSupport",
6567
dependencies: [
6668
"SQLiteData",
69+
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
6770
.product(name: "CustomDump", package: "swift-custom-dump"),
71+
.product(name: "Dependencies", package: "swift-dependencies"),
6872
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
6973
.product(name: "StructuredQueriesTestSupport", package: "swift-structured-queries"),
7074
]

[email protected]

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ let package = Package(
2323
dependencies: [
2424
.package(url: "https://github.com/apple/swift-collections", from: "1.0.0"),
2525
.package(url: "https://github.com/groue/GRDB.swift", from: "7.6.0"),
26+
.package(url: "https://github.com/pointfreeco/swift-concurrency-extras", from: "1.0.0"),
2627
.package(url: "https://github.com/pointfreeco/swift-custom-dump", from: "1.3.3"),
2728
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.9.0"),
2829
.package(url: "https://github.com/pointfreeco/swift-sharing", from: "2.3.0"),
@@ -34,6 +35,7 @@ let package = Package(
3435
.target(
3536
name: "SQLiteData",
3637
dependencies: [
38+
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
3739
.product(name: "Dependencies", package: "swift-dependencies"),
3840
.product(name: "GRDB", package: "GRDB.swift"),
3941
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
@@ -46,7 +48,9 @@ let package = Package(
4648
name: "SQLiteDataTestSupport",
4749
dependencies: [
4850
"SQLiteData",
51+
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
4952
.product(name: "CustomDump", package: "swift-custom-dump"),
53+
.product(name: "Dependencies", package: "swift-dependencies"),
5054
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
5155
.product(name: "StructuredQueriesTestSupport", package: "swift-structured-queries"),
5256
]

Sources/SQLiteData/CloudKit/CloudKit+StructuredQueries.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if canImport(CloudKit)
22
import CloudKit
33
import CryptoKit
4-
import CustomDump
54
import StructuredQueriesCore
65

76
extension _CKRecord where Self == CKRecord {

Sources/SQLiteData/CloudKit/Internal/Logging.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
case .serverResponseLost: "serverResponseLost"
213213
case .assetNotAvailable: "assetNotAvailable"
214214
case .accountTemporarilyUnavailable: "accountTemporarilyUnavailable"
215+
#if canImport(FoundationModels)
216+
case .participantAlreadyInvited:
217+
"participantAlreadyInvited"
218+
#endif
215219
@unknown default: "unknown"
216220
}
217221
}

Sources/SQLiteData/CloudKit/Internal/MockCloudContainer.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import CloudKit
2-
import CustomDump
32

43
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
5-
package final class MockCloudContainer: CloudContainer, CustomDumpReflectable {
4+
package final class MockCloudContainer: CloudContainer {
65
package let _accountStatus: LockIsolated<CKAccountStatus>
76
package let containerIdentifier: String?
87
package let privateCloudDatabase: MockCloudDatabase
@@ -103,17 +102,6 @@ package final class MockCloudContainer: CloudContainer, CustomDumpReflectable {
103102
package func hash(into hasher: inout Hasher) {
104103
hasher.combine(ObjectIdentifier(self))
105104
}
106-
107-
package var customDumpMirror: Mirror {
108-
Mirror(
109-
self,
110-
children: [
111-
("privateCloudDatabase", privateCloudDatabase),
112-
("sharedCloudDatabase", sharedCloudDatabase),
113-
],
114-
displayStyle: .struct
115-
)
116-
}
117105
}
118106

119107
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)

Sources/SQLiteData/CloudKit/Internal/MockCloudDatabase.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import CloudKit
2-
import CustomDump
32
import IssueReporting
43

54
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
@@ -288,25 +287,6 @@ package final class MockCloudDatabase: CloudDatabase {
288287
}
289288
}
290289

291-
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
292-
extension MockCloudDatabase: CustomDumpReflectable {
293-
package var customDumpMirror: Mirror {
294-
Mirror(
295-
self,
296-
children: [
297-
"databaseScope": databaseScope,
298-
"storage": storage
299-
.value
300-
.flatMap { _, value in value.values }
301-
.sorted {
302-
($0.recordType, $0.recordID.recordName) < ($1.recordType, $1.recordID.recordName)
303-
},
304-
],
305-
displayStyle: .struct
306-
)
307-
}
308-
}
309-
310290
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
311291
private func ckError(forAccountStatus accountStatus: CKAccountStatus) -> CKError {
312292
switch accountStatus {

Sources/SQLiteData/CloudKit/Internal/MockSyncEngine.swift

Lines changed: 5 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import CloudKit
2-
import CustomDump
32
import OrderedCollections
43

54
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
65
package final class MockSyncEngine: SyncEngineProtocol {
76
package let database: MockCloudDatabase
87
package let parentSyncEngine: SyncEngine
98
private let _state: LockIsolated<MockSyncEngineState>
10-
private let _fetchChangesScopes = LockIsolated<[CKSyncEngine.FetchChangesOptions.Scope]>([])
11-
private let _acceptedShareMetadata = LockIsolated<Set<ShareMetadata>>([])
9+
package let _fetchChangesScopes = LockIsolated<[CKSyncEngine.FetchChangesOptions.Scope]>([])
10+
package let _acceptedShareMetadata = LockIsolated<Set<ShareMetadata>>([])
1211

1312
package init(
1413
database: MockCloudDatabase,
@@ -95,57 +94,17 @@ package final class MockSyncEngine: SyncEngineProtocol {
9594
)
9695
}
9796

98-
package func assertFetchChangesScopes(
99-
_ scopes: [CKSyncEngine.FetchChangesOptions.Scope],
100-
fileID: StaticString = #fileID,
101-
filePath: StaticString = #filePath,
102-
line: UInt = #line,
103-
column: UInt = #column
104-
) {
105-
_fetchChangesScopes.withValue {
106-
expectNoDifference(
107-
scopes,
108-
$0,
109-
fileID: fileID,
110-
filePath: filePath,
111-
line: line,
112-
column: column
113-
)
114-
$0.removeAll()
115-
}
116-
}
117-
118-
package func assertAcceptedShareMetadata(
119-
_ sharedMetadata: Set<ShareMetadata>,
120-
fileID: StaticString = #fileID,
121-
filePath: StaticString = #filePath,
122-
line: UInt = #line,
123-
column: UInt = #column
124-
) {
125-
_acceptedShareMetadata.withValue {
126-
expectNoDifference(
127-
sharedMetadata,
128-
$0,
129-
fileID: fileID,
130-
filePath: filePath,
131-
line: line,
132-
column: column
133-
)
134-
$0.removeAll()
135-
}
136-
}
137-
13897
package func cancelOperations() async {
13998
}
14099
}
141100

142101
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
143-
package final class MockSyncEngineState: CKSyncEngineStateProtocol, CustomDumpReflectable {
144-
private let _pendingRecordZoneChanges = LockIsolated<
102+
package final class MockSyncEngineState: CKSyncEngineStateProtocol {
103+
package let _pendingRecordZoneChanges = LockIsolated<
145104
OrderedSet<CKSyncEngine.PendingRecordZoneChange>
146105
>([]
147106
)
148-
private let _pendingDatabaseChanges = LockIsolated<
107+
package let _pendingDatabaseChanges = LockIsolated<
149108
OrderedSet<CKSyncEngine.PendingDatabaseChange>
150109
>([])
151110
private let fileID: StaticString
@@ -165,46 +124,6 @@ package final class MockSyncEngineState: CKSyncEngineStateProtocol, CustomDumpRe
165124
self.column = column
166125
}
167126

168-
package func assertPendingRecordZoneChanges(
169-
_ changes: OrderedSet<CKSyncEngine.PendingRecordZoneChange>,
170-
fileID: StaticString = #fileID,
171-
filePath: StaticString = #filePath,
172-
line: UInt = #line,
173-
column: UInt = #column
174-
) {
175-
_pendingRecordZoneChanges.withValue {
176-
expectNoDifference(
177-
Set(changes),
178-
Set($0),
179-
fileID: fileID,
180-
filePath: filePath,
181-
line: line,
182-
column: column
183-
)
184-
$0.removeAll()
185-
}
186-
}
187-
188-
package func assertPendingDatabaseChanges(
189-
_ changes: OrderedSet<CKSyncEngine.PendingDatabaseChange>,
190-
fileID: StaticString = #fileID,
191-
filePath: StaticString = #filePath,
192-
line: UInt = #line,
193-
column: UInt = #column
194-
) {
195-
_pendingDatabaseChanges.withValue {
196-
expectNoDifference(
197-
Set(changes),
198-
Set($0),
199-
fileID: fileID,
200-
filePath: filePath,
201-
line: line,
202-
column: column
203-
)
204-
$0.removeAll()
205-
}
206-
}
207-
208127
package var pendingRecordZoneChanges: [CKSyncEngine.PendingRecordZoneChange] {
209128
_pendingRecordZoneChanges.withValue { Array($0) }
210129
}
@@ -241,63 +160,6 @@ package final class MockSyncEngineState: CKSyncEngineStateProtocol, CustomDumpRe
241160
$0.subtract(pendingDatabaseChanges)
242161
}
243162
}
244-
245-
package var customDumpMirror: Mirror {
246-
return Mirror(
247-
self,
248-
children: [
249-
(
250-
"pendingRecordZoneChanges",
251-
_pendingRecordZoneChanges.withValue(\.self)
252-
.sorted(by: comparePendingRecordZoneChange)
253-
as Any
254-
),
255-
(
256-
"pendingDatabaseChanges",
257-
_pendingDatabaseChanges.withValue(\.self)
258-
.sorted(by: comparePendingDatabaseChange) as Any
259-
),
260-
],
261-
displayStyle: .struct
262-
)
263-
}
264-
}
265-
266-
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
267-
private func comparePendingRecordZoneChange(
268-
_ lhs: CKSyncEngine.PendingRecordZoneChange,
269-
_ rhs: CKSyncEngine.PendingRecordZoneChange
270-
) -> Bool {
271-
switch (lhs, rhs) {
272-
case (.saveRecord(let lhs), .saveRecord(let rhs)),
273-
(.deleteRecord(let lhs), .deleteRecord(let rhs)):
274-
lhs.recordName < rhs.recordName
275-
case (.deleteRecord, .saveRecord):
276-
true
277-
case (.saveRecord, .deleteRecord):
278-
false
279-
default:
280-
false
281-
}
282-
}
283-
284-
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
285-
private func comparePendingDatabaseChange(
286-
_ lhs: CKSyncEngine.PendingDatabaseChange,
287-
_ rhs: CKSyncEngine.PendingDatabaseChange
288-
) -> Bool {
289-
switch (lhs, rhs) {
290-
case (.saveZone(let lhs), .saveZone(let rhs)):
291-
lhs.zoneID.zoneName < rhs.zoneID.zoneName
292-
case (.deleteZone(let lhs), .deleteZone(let rhs)):
293-
lhs.zoneName < rhs.zoneName
294-
case (.deleteZone, .saveZone):
295-
true
296-
case (.saveZone, .deleteZone):
297-
false
298-
default:
299-
false
300-
}
301163
}
302164

303165
@available(iOS 17, macOS 14, tvOS 17, watchOS 10, *)
Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import CustomDump
21

32
@Table("sqlitedata_icloud_recordTypes")
43
package struct RecordType: Hashable {
@@ -8,17 +7,3 @@ package struct RecordType: Hashable {
87
@Column(as: Set<TableInfo>.JSONRepresentation.self)
98
package let tableInfo: Set<TableInfo>
109
}
11-
12-
extension RecordType: CustomDumpReflectable {
13-
package var customDumpMirror: Mirror {
14-
Mirror(
15-
self,
16-
children: [
17-
("tableName", tableName as Any),
18-
("schema", schema),
19-
("tableInfo", tableInfo.sorted(by: { $0.name < $1.name })),
20-
],
21-
displayStyle: .struct
22-
)
23-
}
24-
}

Sources/SQLiteData/CloudKit/Internal/TableInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import StructuredQueriesCore
44
package struct TableInfo: Codable, Hashable, QueryDecodable, QueryRepresentable {
55
let defaultValue: String?
66
let isPrimaryKey: Bool
7-
let name: String
7+
package let name: String
88
let isNotNull: Bool
99
let type: String
1010
}

Sources/SQLiteData/CloudKit/SyncEngine.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if canImport(CloudKit)
22
import CloudKit
33
import ConcurrencyExtras
4-
import CustomDump
54
import Dependencies
65
import OrderedCollections
76
import OSLog
@@ -1492,6 +1491,10 @@
14921491
.alreadyShared, .managedAccountRestricted, .participantMayNeedVerification,
14931492
.serverResponseLost, .assetNotAvailable, .accountTemporarilyUnavailable:
14941493
continue
1494+
#if canImport(FoundationModels)
1495+
case .participantAlreadyInvited:
1496+
continue
1497+
#endif
14951498
@unknown default:
14961499
continue
14971500
}

0 commit comments

Comments
 (0)