From 8948d70a3598486c92c8771c653206591dbc73e5 Mon Sep 17 00:00:00 2001 From: slamhan Date: Sun, 11 Oct 2026 10:56:19 +0800 Subject: [PATCH] fix(build): compile the asset-library adapters with Swift 6.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI and release builds use Swift 6.2.4, which can't infer `.init(rawValue:)` inside `value.flatMap { .init(…) }.map { [$0] }` (Swift 6.4 can), so main has failed to build on CI since #32. Route the eight filter parameters through a generic `sdkFilter(_:)` whose SDK type comes from the parameter. Co-Authored-By: Claude Opus 5.5 --- .../Images/SDKLibraryImageRepository.swift | 4 ++-- .../Placements/SDKAssetPlacementRepository.swift | 8 ++++---- .../Videos/SDKLibraryVideoRepository.swift | 4 ++-- Sources/Infrastructure/Shared/SDKFilter.swift | 10 ++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 Sources/Infrastructure/Shared/SDKFilter.swift diff --git a/Sources/Infrastructure/Apps/AssetLibrary/Images/SDKLibraryImageRepository.swift b/Sources/Infrastructure/Apps/AssetLibrary/Images/SDKLibraryImageRepository.swift index 1b7f1335..625b9d36 100644 --- a/Sources/Infrastructure/Apps/AssetLibrary/Images/SDKLibraryImageRepository.swift +++ b/Sources/Infrastructure/Apps/AssetLibrary/Images/SDKLibraryImageRepository.swift @@ -18,8 +18,8 @@ public struct SDKLibraryImageRepository: LibraryImageRepository, @unchecked Send category: AssetCategory? ) async throws -> [LibraryImage] { let sdk = APIEndpoint.v1.appAssetLibraries.id(libraryId).images.get(parameters: .init( - filterCategory: category.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, - filterState: state.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterCategory: sdkFilter(category), + filterState: sdkFilter(state), filterID: imageId.map { [$0] }, limit: 200 )) diff --git a/Sources/Infrastructure/Apps/AssetLibrary/Placements/SDKAssetPlacementRepository.swift b/Sources/Infrastructure/Apps/AssetLibrary/Placements/SDKAssetPlacementRepository.swift index def8e357..3ace294d 100644 --- a/Sources/Infrastructure/Apps/AssetLibrary/Placements/SDKAssetPlacementRepository.swift +++ b/Sources/Infrastructure/Apps/AssetLibrary/Placements/SDKAssetPlacementRepository.swift @@ -117,25 +117,25 @@ public struct SDKAssetPlacementRepository: AssetPlacementRepository, @unchecked switch surface { case .appStoreVersionLocalization: let r = APIEndpoint.v1.appStoreVersionLocalizations.id(localizationId).placements.get(parameters: .init( - filterPlacementType: placementType.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterPlacementType: sdkFilter(placementType), filterPlacementGroup: groups, sort: [.placementGroupPosition], limit: 200, include: [.image, .video] )) sdk = (r.path, r.query) case .experimentTreatmentLocalization: let r = APIEndpoint.v1.appStoreVersionExperimentTreatmentLocalizations.id(localizationId).placements.get(parameters: .init( - filterPlacementType: placementType.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterPlacementType: sdkFilter(placementType), filterPlacementGroup: groups, sort: [.placementGroupPosition], limit: 200, include: [.image, .video] )) sdk = (r.path, r.query) case .customProductPageLocalization: let r = APIEndpoint.v1.appCustomProductPageLocalizations.id(localizationId).placements.get(parameters: .init( - filterPlacementType: placementType.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterPlacementType: sdkFilter(placementType), filterPlacementGroup: groups, sort: [.placementGroupPosition], limit: 200, include: [.image, .video] )) sdk = (r.path, r.query) case .eventLocalization: let r = APIEndpoint.v1.appEventLocalizations.id(localizationId).placements.get(parameters: .init( - filterPlacementType: placementType.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterPlacementType: sdkFilter(placementType), filterPlacementGroup: groups, sort: [.placementGroupPosition], limit: 200, include: [.image, .video] )) sdk = (r.path, r.query) diff --git a/Sources/Infrastructure/Apps/AssetLibrary/Videos/SDKLibraryVideoRepository.swift b/Sources/Infrastructure/Apps/AssetLibrary/Videos/SDKLibraryVideoRepository.swift index f8efb908..14c46bdd 100644 --- a/Sources/Infrastructure/Apps/AssetLibrary/Videos/SDKLibraryVideoRepository.swift +++ b/Sources/Infrastructure/Apps/AssetLibrary/Videos/SDKLibraryVideoRepository.swift @@ -18,8 +18,8 @@ public struct SDKLibraryVideoRepository: LibraryVideoRepository, @unchecked Send category: AssetCategory? ) async throws -> [LibraryVideo] { let sdk = APIEndpoint.v1.appAssetLibraries.id(libraryId).videos.get(parameters: .init( - filterCategory: category.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, - filterState: state.flatMap { .init(rawValue: $0.rawValue) }.map { [$0] }, + filterCategory: sdkFilter(category), + filterState: sdkFilter(state), filterID: videoId.map { [$0] }, limit: 200 )) diff --git a/Sources/Infrastructure/Shared/SDKFilter.swift b/Sources/Infrastructure/Shared/SDKFilter.swift new file mode 100644 index 00000000..70cb20fc --- /dev/null +++ b/Sources/Infrastructure/Shared/SDKFilter.swift @@ -0,0 +1,10 @@ +/// Turns an optional domain enum into the one-element SDK filter array a query parameter takes, +/// or `nil` when there is no value (or the SDK has no matching case). +/// +/// The SDK type comes from the parameter being filled. Spelled as a generic function because +/// Swift 6.2 can't infer `.init(rawValue:)` through `value.flatMap { .init(…) }.map { [$0] }`. +func sdkFilter( + _ value: DomainValue? +) -> [SDKValue]? where SDKValue.RawValue == String, DomainValue.RawValue == String { + value.flatMap { SDKValue(rawValue: $0.rawValue) }.map { [$0] } +}