@@ -15,7 +15,7 @@ import TSCBasic
15
15
public struct PackageCollections : PackageCollectionsProtocol {
16
16
private let configuration : Configuration
17
17
private let storageContainer : ( storage: Storage , owned: Bool )
18
- private let collectionProviders : [ PackageCollectionsModel . CollectionSourceType : PackageCollectionProvider ]
18
+ private let collectionProviders : [ Model . CollectionSourceType : PackageCollectionProvider ]
19
19
private let metadataProvider : PackageMetadataProvider
20
20
21
21
private var storage : Storage {
@@ -26,7 +26,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
26
26
public init ( configuration: Configuration = . init( ) ) {
27
27
let storage = Storage ( sources: FilePackageCollectionsSourcesStorage ( ) ,
28
28
collections: SQLitePackageCollectionsStorage ( ) )
29
- let collectionProviders = [ PackageCollectionsModel . CollectionSourceType. json: JSONPackageCollectionProvider ( ) ]
29
+ let collectionProviders = [ Model . CollectionSourceType. json: JSONPackageCollectionProvider ( ) ]
30
30
let metadataProvider = GitHubPackageMetadataProvider ( )
31
31
32
32
self . configuration = configuration
@@ -38,7 +38,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
38
38
// internal initializer for testing
39
39
init ( configuration: Configuration = . init( ) ,
40
40
storage: Storage ,
41
- collectionProviders: [ PackageCollectionsModel . CollectionSourceType : PackageCollectionProvider ] ,
41
+ collectionProviders: [ Model . CollectionSourceType : PackageCollectionProvider ] ,
42
42
metadataProvider: PackageMetadataProvider ) {
43
43
self . configuration = configuration
44
44
self . storageContainer = ( storage, false )
@@ -65,7 +65,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
65
65
if identifiers. isEmpty {
66
66
return callback ( . success( [ ] ) )
67
67
}
68
- let collectionOrder = identifiers. enumerated ( ) . reduce ( [ PackageCollectionsModel . CollectionIdentifier: Int] ( ) ) { partial, element in
68
+ let collectionOrder = identifiers. enumerated ( ) . reduce ( [ Model . CollectionIdentifier: Int] ( ) ) { partial, element in
69
69
var dictionary = partial
70
70
dictionary [ element. element] = element. offset
71
71
return dictionary
@@ -94,7 +94,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
94
94
return callback ( . success( [ ] ) )
95
95
}
96
96
let lock = Lock ( )
97
- var refreshResults = [ Result < PackageCollectionsModel . Collection , Error > ] ( )
97
+ var refreshResults = [ Result < Model . Collection , Error > ] ( )
98
98
sources. forEach { source in
99
99
self . refreshCollectionFromSource ( source: source) { refreshResult in
100
100
lock. withLock { refreshResults. append ( refreshResult) }
@@ -181,7 +181,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
181
181
case . success( let sources) :
182
182
let identifiers = sources. map { . init( from: $0) } . filter { collections? . contains ( $0) ?? true }
183
183
if identifiers. isEmpty {
184
- return callback ( . success( PackageCollectionsModel . PackageSearchResult ( items: [ ] ) ) )
184
+ return callback ( . success( Model . PackageSearchResult ( items: [ ] ) ) )
185
185
}
186
186
self . storage. collections. searchPackages ( identifiers: identifiers, query: query, callback: callback)
187
187
}
@@ -202,7 +202,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
202
202
self . metadataProvider. get ( reference) { result in
203
203
switch result {
204
204
case . failure( let error) where error is NotFoundError :
205
- let metadata = PackageCollectionsModel . PackageMetadata (
205
+ let metadata = Model . PackageMetadata (
206
206
package : Self . mergedPackageMetadata ( package : packageSearchResult. package , basicMetadata: nil ) ,
207
207
collections: packageSearchResult. collections
208
208
)
@@ -211,7 +211,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
211
211
callback ( . failure( error) )
212
212
case . success( let basicMetadata) :
213
213
// finally merge the results
214
- let metadata = PackageCollectionsModel . PackageMetadata (
214
+ let metadata = Model . PackageMetadata (
215
215
package : Self . mergedPackageMetadata ( package : packageSearchResult. package , basicMetadata: basicMetadata) ,
216
216
collections: packageSearchResult. collections
217
217
)
@@ -267,7 +267,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
267
267
// This helps avoid network access in normal operations
268
268
private func refreshCollectionFromSource( source: PackageCollectionsModel . CollectionSource ,
269
269
order _: Int ? = nil ,
270
- callback: @escaping ( Result < PackageCollectionsModel . Collection , Error > ) -> Void ) {
270
+ callback: @escaping ( Result < Model . Collection , Error > ) -> Void ) {
271
271
if let errors = source. validate ( ) {
272
272
return callback ( . failure( MultipleErrors ( errors) ) )
273
273
}
@@ -293,7 +293,7 @@ public struct PackageCollections: PackageCollectionsProtocol {
293
293
case . failure( let error) :
294
294
callback ( . failure( error) )
295
295
case . success( let sources) :
296
- let identifiers = sources. map { PackageCollectionsModel . CollectionIdentifier ( from: $0) }
296
+ let identifiers = sources. map { Model . CollectionIdentifier ( from: $0) }
297
297
if identifiers. isEmpty {
298
298
return callback ( . failure( NotFoundError ( " \( identifier) " ) ) )
299
299
}
@@ -302,9 +302,9 @@ public struct PackageCollections: PackageCollectionsProtocol {
302
302
}
303
303
}
304
304
305
- private func targetListResultFromCollections( _ collections: [ PackageCollectionsModel . Collection ] ) -> PackageCollectionsModel . TargetListResult {
306
- var packageCollections = [ PackageReference : ( package : PackageCollectionsModel . Package , collections: Set < PackageCollectionsModel . CollectionIdentifier > ) ] ( )
307
- var targetsPackages = [ String : ( target: PackageCollectionsModel . Target , packages: Set < PackageReference > ) ] ( )
305
+ private func targetListResultFromCollections( _ collections: [ Model . Collection ] ) -> Model . TargetListResult {
306
+ var packageCollections = [ PackageReference : ( package : Model . Package , collections: Set < Model . CollectionIdentifier > ) ] ( )
307
+ var targetsPackages = [ String : ( target: Model . Target , packages: Set < PackageReference > ) ] ( )
308
308
309
309
collections. forEach { collection in
310
310
collection. packages. forEach { package in
@@ -327,21 +327,21 @@ public struct PackageCollections: PackageCollectionsProtocol {
327
327
return targetsPackages. map { _, pair in
328
328
let targetPackages = pair. packages
329
329
. compactMap { packageCollections [ $0] }
330
- . map { pair -> PackageCollectionsModel . TargetListResult . Package in
331
- let versions = pair. package . versions. map { PackageCollectionsModel . TargetListResult. PackageVersion ( version: $0. version, packageName: $0. packageName) }
330
+ . map { pair -> Model . TargetListResult . Package in
331
+ let versions = pair. package . versions. map { Model . TargetListResult. PackageVersion ( version: $0. version, packageName: $0. packageName) }
332
332
return . init( repository: pair. package . repository,
333
333
summary: pair. package . summary,
334
334
versions: versions,
335
335
collections: Array ( pair. collections) )
336
336
}
337
337
338
- return PackageCollectionsModel . TargetListItem ( target: pair. target, packages: targetPackages)
338
+ return Model . TargetListItem ( target: pair. target, packages: targetPackages)
339
339
}
340
340
}
341
341
342
- internal static func mergedPackageMetadata( package : PackageCollectionsModel . Package ,
343
- basicMetadata: PackageCollectionsModel . PackageBasicMetadata ? ) -> PackageCollectionsModel . Package {
344
- var versions = package . versions. map { packageVersion -> PackageCollectionsModel . Package . Version in
342
+ internal static func mergedPackageMetadata( package : Model . Package ,
343
+ basicMetadata: Model . PackageBasicMetadata ? ) -> Model . Package {
344
+ var versions = package . versions. map { packageVersion -> Model . Package . Version in
345
345
. init( version: packageVersion. version,
346
346
packageName: packageVersion. packageName,
347
347
targets: packageVersion. targets,
@@ -371,9 +371,9 @@ public struct PackageCollections: PackageCollectionsProtocol {
371
371
}
372
372
373
373
private struct UnknownProvider : Error {
374
- let sourceType : PackageCollectionsModel . CollectionSourceType
374
+ let sourceType : Model . CollectionSourceType
375
375
376
- init ( _ sourceType: PackageCollectionsModel . CollectionSourceType ) {
376
+ init ( _ sourceType: Model . CollectionSourceType ) {
377
377
self . sourceType = sourceType
378
378
}
379
379
}
0 commit comments