From b9935d22b3747a1479065556f82d1c77293b3efc Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 26 Jul 2026 01:37:12 +0200 Subject: [PATCH] Adopted Swift 6.2 tools version at the Package in the library target to drop legacy conditional code. --- Package.swift | 2 +- .../Public/Clients/AmiiboLiveClient.swift | 73 +-------- .../Public/Protocols/AmiiboClient.swift | 37 ----- .../Public/Services/AmiiboService.swift | 59 ------- .../Services/AmiiboServiceLiveTests.swift | 151 ------------------ .../Helpers/Clients/AmiiboMockClient.swift | 48 +----- 6 files changed, 14 insertions(+), 356 deletions(-) diff --git a/Package.swift b/Package.swift index 3a1822c..031e02e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.10 +// swift-tools-version: 6.2 // ===----------------------------------------------------------------------=== // diff --git a/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift b/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift index 700b70f..c5ff26d 100644 --- a/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift +++ b/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift @@ -58,7 +58,6 @@ extension AmiiboLiveClient: AmiiboClient { // MARK: Functions -#if swift(>=6.0) /// Gets a list of amiibo items based on a given filter. /// - Parameter filter: A filter to remove unwanted items from the result. /// - Returns: A list of filtered amiibo items. @@ -115,64 +114,6 @@ extension AmiiboLiveClient: AmiiboClient { public func getLastUpdated() async throws(AmiiboServiceError) -> Date { try await fetchLastUpdated() } -#else - /// Gets a list of amiibo items based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo items. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiibos( - by filter: AmiiboFilter - ) async throws -> [Amiibo] { - try await fetchAmiibos(filter) - } - - /// Gets a list of amiibo series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiiboSeries( - by filter: AmiiboSeriesFilter - ) async throws -> [AmiiboSeries] { - try await fetchAmiiboSeries(filter) - } - - /// Gets a list of amiibo types based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo types. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiiboTypes( - by filter: AmiiboTypeFilter - ) async throws -> [AmiiboType] { - try await fetchAmiiboTypes(filter) - } - - /// Gets a list of game characters based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game characters. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getGameCharacters( - by filter: GameCharacterFilter - ) async throws -> [GameCharacter] { - try await fetchGameCharacters(filter) - } - - /// Gets a list of game series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getGameSeries( - by filter: GameSeriesFilter - ) async throws -> [GameSeries] { - try await fetchGameSeries(filter) - } - - /// Gets the date when the data was last updated. - /// - Returns: A last updated date. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getLastUpdated() async throws -> Date { - try await fetchLastUpdated() - } -#endif } @@ -188,7 +129,7 @@ private extension AmiiboLiveClient { /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func fetchAmiibos( _ filter: AmiiboFilter - ) async throws -> [Amiibo] { + ) async throws(AmiiboServiceError) -> [Amiibo] { let response: Operations.getAmiibos.Output do { @@ -240,7 +181,7 @@ private extension AmiiboLiveClient { /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func fetchAmiiboSeries( _ filter: AmiiboSeriesFilter - ) async throws -> [AmiiboSeries] { + ) async throws(AmiiboServiceError) -> [AmiiboSeries] { let response: Operations.getAmiiboSeries.Output do { @@ -282,7 +223,7 @@ private extension AmiiboLiveClient { /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func fetchAmiiboTypes( _ filter: AmiiboTypeFilter - ) async throws -> [AmiiboType] { + ) async throws(AmiiboServiceError) -> [AmiiboType] { let response: Operations.getAmiiboTypes.Output do { @@ -324,7 +265,7 @@ private extension AmiiboLiveClient { /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func fetchGameCharacters( _ filter: GameCharacterFilter - ) async throws -> [GameCharacter] { + ) async throws(AmiiboServiceError) -> [GameCharacter] { let response: Operations.getGameCharacters.Output do { @@ -366,7 +307,7 @@ private extension AmiiboLiveClient { /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func fetchGameSeries( _ filter: GameSeriesFilter - ) async throws -> [GameSeries] { + ) async throws(AmiiboServiceError) -> [GameSeries] { let response: Operations.getGameSeries.Output do { @@ -405,7 +346,7 @@ private extension AmiiboLiveClient { /// Fetches the date when the data was last updated. /// - Returns: A fetched last updated date. /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func fetchLastUpdated() async throws -> Date { + func fetchLastUpdated() async throws(AmiiboServiceError) -> Date { let response: Operations.getLastUpdated.Output do { @@ -430,7 +371,7 @@ private extension AmiiboLiveClient { /// Maps a given error to an ``AmiiboServiceError`` error. /// - Parameter error: An error to map. /// - Throws: An ``AmiiboServiceError`` error that corresponds to the given error. - func handle(error: any Error) throws -> Never { + func handle(error: any Error) throws(AmiiboServiceError) -> Never { switch error { case is CancellationError: throw AmiiboServiceError.cancelled diff --git a/Sources/AmiiboService/Public/Protocols/AmiiboClient.swift b/Sources/AmiiboService/Public/Protocols/AmiiboClient.swift index 6cd3c5f..22078e7 100644 --- a/Sources/AmiiboService/Public/Protocols/AmiiboClient.swift +++ b/Sources/AmiiboService/Public/Protocols/AmiiboClient.swift @@ -21,7 +21,6 @@ public protocol AmiiboClient: Sendable { // MARK: Functions -#if swift(>=6.0) /// Gets a list of amiibo items based on a given filter. /// - Parameter filter: A filter to remove unwanted items from the result. /// - Returns: A list of filtered amiibo items. @@ -56,41 +55,5 @@ public protocol AmiiboClient: Sendable { /// - Returns: A last updated date. /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. func getLastUpdated() async throws(AmiiboServiceError) -> Date -#else - /// Gets a list of amiibo items based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo items. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getAmiibos(by filter: AmiiboFilter) async throws -> [Amiibo] - - /// Gets a list of amiibo series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws -> [AmiiboSeries] - - /// Gets a list of amiibo types based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo types. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws -> [AmiiboType] - - /// Gets a list of game characters based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game characters. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getGameCharacters(by filter: GameCharacterFilter) async throws -> [GameCharacter] - - /// Gets a list of game series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getGameSeries(by filter: GameSeriesFilter) async throws -> [GameSeries] - - /// Gets the date when the data was last updated. - /// - Returns: A last updated date. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - func getLastUpdated() async throws -> Date -#endif } diff --git a/Sources/AmiiboService/Public/Services/AmiiboService.swift b/Sources/AmiiboService/Public/Services/AmiiboService.swift index 608d045..1584b9c 100644 --- a/Sources/AmiiboService/Public/Services/AmiiboService.swift +++ b/Sources/AmiiboService/Public/Services/AmiiboService.swift @@ -32,7 +32,6 @@ public struct AmiiboService: Sendable { // MARK: Functions -#if swift(>=6.0) /// Gets a list of amiibo items based on a given filter. /// - Parameter filter: A filter to remove unwanted items from the result. /// - Returns: A list of filtered amiibo items. @@ -89,63 +88,5 @@ public struct AmiiboService: Sendable { public func getLastUpdated() async throws(AmiiboServiceError) -> Date { try await client.getLastUpdated() } -#else - /// Gets a list of amiibo items based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo items. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiibos( - _ filter: AmiiboFilter = .init() - ) async throws -> [Amiibo] { - try await client.getAmiibos(by: filter) - } - - /// Gets a list of amiibo series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiiboSeries( - _ filter: AmiiboSeriesFilter = .init() - ) async throws -> [AmiiboSeries] { - try await client.getAmiiboSeries(by: filter) - } - - /// Gets a list of amiibo types based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered amiibo types. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getAmiiboTypes( - _ filter: AmiiboTypeFilter = .init() - ) async throws -> [AmiiboType] { - try await client.getAmiiboTypes(by: filter) - } - - /// Gets a list of game characters based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game characters. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getGameCharacters( - _ filter: GameCharacterFilter = .init() - ) async throws -> [GameCharacter] { - try await client.getGameCharacters(by: filter) - } - - /// Gets a list of game series based on a given filter. - /// - Parameter filter: A filter to remove unwanted items from the result. - /// - Returns: A list of filtered game series. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getGameSeries( - _ filter: GameSeriesFilter = .init() - ) async throws -> [GameSeries] { - try await client.getGameSeries(by: filter) - } - - /// Gets the date when the data was last updated. - /// - Returns: A last updated date. - /// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result. - public func getLastUpdated() async throws -> Date { - try await client.getLastUpdated() - } -#endif } diff --git a/Tests/AmiiboService/Cases/Public/Services/AmiiboServiceLiveTests.swift b/Tests/AmiiboService/Cases/Public/Services/AmiiboServiceLiveTests.swift index edea4af..de55694 100644 --- a/Tests/AmiiboService/Cases/Public/Services/AmiiboServiceLiveTests.swift +++ b/Tests/AmiiboService/Cases/Public/Services/AmiiboServiceLiveTests.swift @@ -31,7 +31,6 @@ struct AmiiboServiceLiveTests { // MARK: Functions tests -#if swift(>=6.2) @Test(arguments: zip( Input.amiibos, Output.amiibos @@ -180,156 +179,6 @@ struct AmiiboServiceLiveTests { year: 2026 ) } -#else - @Test("get amiibos", arguments: zip( - Input.amiibos, - Output.amiibos - )) - func getAmiibos( - filter: AmiiboFilter, - expects numberOfItems: Int - ) async throws { - try await assertAmiibos( - with: filter, - expects: numberOfItems - ) - } - - @Test("get amiibos throws", arguments: zip( - Input.amiibosThrows, - Output.amiibosThrows - )) - func getAmiibosThrows( - filter: AmiiboFilter, - expects error: AmiiboServiceError - ) async throws { - try await assertsAmiibosThrows( - error: error, - when: filter - ) - } - - @Test("get amiibo series", arguments: zip( - Input.amiiboSeries, - Output.amiiboSeries - )) - func getAmiiboSeries( - filter: AmiiboSeriesFilter, - expects numberOfItems: Int - ) async throws { - try await assertAmiiboSeries( - with: filter, - expects: numberOfItems - ) - } - - @Test("get amiibo series throws", arguments: zip( - Input.amiiboSeriesThrows, - Output.amiiboSeriesThrows - )) - func getAmiiboSeriesThrows( - filter: AmiiboSeriesFilter, - expects error: AmiiboServiceError - ) async throws { - try await assertsAmiiboSeriesThrows( - error: error, - when: filter - ) - } - - @Test("get amiibo types", arguments: zip( - Input.amiiboTypes, - Output.amiiboTypes - )) - func getAmiiboTypes( - filter: AmiiboTypeFilter, - expects numberOfItems: Int - ) async throws { - try await assertAmiiboTypes( - with: filter, - expects: numberOfItems - ) - } - - @Test("get amiibo types throws", arguments: zip( - Input.amiiboTypesThrows, - Output.amiiboTypesThrows - )) - func getAmiiboTypesThrows( - filter: AmiiboTypeFilter, - expects error: AmiiboServiceError - ) async throws { - try await assertsAmiiboTypesThrows( - error: error, - when: filter - ) - } - - @Test("get game characters", arguments: zip( - Input.gameCharacters, - Output.gameCharacters - )) - func getGameCharacters( - filter: GameCharacterFilter, - expects numberOfItems: Int - ) async throws { - try await assertGameCharacters( - with: filter, - expects: numberOfItems - ) - } - - @Test("get game characters throws", arguments: zip( - Input.gameCharactersThrows, - Output.gameCharactersThrows - )) - func getGameCharactersThrows( - filter: GameCharacterFilter, - expects error: AmiiboServiceError - ) async throws { - try await assertsGameCharactersThrows( - error: error, - when: filter - ) - } - - @Test("get game series", arguments: zip( - Input.gameSeries, - Output.gameSeries - )) - func getGameSeries( - filter: GameSeriesFilter, - expects numberOfItems: Int - ) async throws { - try await assertGameSeries( - with: filter, - expects: numberOfItems - ) - } - - @Test("get game series throws", arguments: zip( - Input.gameSeriesThrows, - Output.gameSeriesThrows - )) - func getGameSeriesThrows( - filter: GameSeriesFilter, - expects error: AmiiboServiceError - ) async throws { - try await assertsGameSeriesThrows( - error: error, - when: filter - ) - } - - @Test("get last updated timestamp") - func getLastUpdated() async throws { - try await assertLastUpdated( - day: 24, - month: 7, - year: 2026 - ) - } -#endif } diff --git a/Tests/AmiiboService/Helpers/Clients/AmiiboMockClient.swift b/Tests/AmiiboService/Helpers/Clients/AmiiboMockClient.swift index f8563a4..629245f 100644 --- a/Tests/AmiiboService/Helpers/Clients/AmiiboMockClient.swift +++ b/Tests/AmiiboService/Helpers/Clients/AmiiboMockClient.swift @@ -78,7 +78,6 @@ extension AmiiboMockClient: AmiiboClient { // MARK: Functions -#if swift(>=6.0) func getAmiibos( by filter: AmiiboFilter ) async throws(AmiiboServiceError) -> [Amiibo] { @@ -110,43 +109,8 @@ extension AmiiboMockClient: AmiiboClient { } func getLastUpdated() async throws(AmiiboServiceError) -> Date { - fetchLastUpdatedIfAny() - } -#else - func getAmiibos( - by filter: AmiiboFilter - ) async throws -> [Amiibo] { - try fetchAmiibosIfAny() - } - - func getAmiiboSeries( - by filter: AmiiboSeriesFilter - ) async throws -> [AmiiboSeries] { - try fetchAmiiboSeriesIfAny() - } - - func getAmiiboTypes( - by filter: AmiiboTypeFilter - ) async throws -> [AmiiboType] { - try fetchAmiiboTypesIfAny() - } - - func getGameCharacters( - by filter: GameCharacterFilter - ) async throws -> [GameCharacter] { - try fetchGameCharactersIfAny() - } - - func getGameSeries( - by filter: GameSeriesFilter - ) async throws -> [GameSeries] { - try fetchGameSeriesIfAny() - } - - func getLastUpdated() async throws -> Date { try fetchLastUpdatedIfAny() } -#endif } @@ -159,7 +123,7 @@ private extension AmiiboMockClient { /// Fetches a list of amiibo items, if any. /// - Returns: A list of amiibo items. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchAmiibosIfAny() throws -> [Amiibo] { + func fetchAmiibosIfAny() throws(AmiiboServiceError) -> [Amiibo] { try throwErrorIfExists() guard let amiibos else { @@ -172,7 +136,7 @@ private extension AmiiboMockClient { /// Fetches a list of amiibo series, if any. /// - Returns: A list of amiibo series. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchAmiiboSeriesIfAny() throws -> [AmiiboSeries] { + func fetchAmiiboSeriesIfAny() throws(AmiiboServiceError) -> [AmiiboSeries] { try throwErrorIfExists() guard let amiiboSeries else { @@ -185,7 +149,7 @@ private extension AmiiboMockClient { /// Fetches a list of amiibo types, if any. /// - Returns: A list of amiibo types. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchAmiiboTypesIfAny() throws -> [AmiiboType] { + func fetchAmiiboTypesIfAny() throws(AmiiboServiceError) -> [AmiiboType] { try throwErrorIfExists() guard let amiiboTypes else { @@ -198,7 +162,7 @@ private extension AmiiboMockClient { /// Fetches a list of game characters, if any. /// - Returns: A list of game characters. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchGameCharactersIfAny() throws -> [GameCharacter] { + func fetchGameCharactersIfAny() throws(AmiiboServiceError) -> [GameCharacter] { try throwErrorIfExists() guard let gameCharacters else { @@ -211,7 +175,7 @@ private extension AmiiboMockClient { /// Fetches a list of game series, if any. /// - Returns: A list of game series, if any. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchGameSeriesIfAny() throws -> [GameSeries] { + func fetchGameSeriesIfAny() throws(AmiiboServiceError) -> [GameSeries] { try throwErrorIfExists() guard let gameSeries else { @@ -224,7 +188,7 @@ private extension AmiiboMockClient { /// Fetches a last updated date, if any. /// - Returns: A last updated date. /// - Throws: An ``AmiiboServiceError`` error in case an error has been provided. - func fetchLastUpdatedIfAny() throws -> Date { + func fetchLastUpdatedIfAny() throws(AmiiboServiceError) -> Date { try throwErrorIfExists() guard let lastUpdated else {