From 51c5e82b78c789cd95eeac55587ca0d8ecd9a773 Mon Sep 17 00:00:00 2001 From: Tuan Pham Date: Tue, 3 Sep 2024 13:07:43 -0500 Subject: [PATCH] chore(predictions): resolve swiftformat errors and warnings --- .../AWSPredictionsPlugin+Configure.swift | 4 +- .../AWSPredictionsPlugin+Convert.swift | 14 ++- .../AWSPredictionsPlugin+Identify.swift | 6 +- .../AWSPredictionsPlugin+Interpret.swift | 6 +- .../AWSPredictionsPlugin+Reset.swift | 6 +- .../AWSPredictionsPlugin.swift | 4 +- .../Configuration/IdentifyConfiguration.swift | 4 +- .../AWSTranscribeStreamingAdapter.swift | 8 +- .../AWSTranscribeStreamingBehavior.swift | 2 +- .../Liveness/Events/Date+EpochMillis.swift | 2 +- .../Events/LivenessFinalCientEvent.swift | 4 +- .../Events/LivenessFreshnessEvent.swift | 4 +- .../Events/LivenessInitialClientEvent.swift | 4 +- .../Liveness/Events/LivenessVideoEvent.swift | 4 +- .../Liveness/Model/DTOMapping.swift | 4 +- .../FaceLivenessSession+BoundingBox.swift | 4 +- .../FaceLivenessSession+ColorChallenge.swift | 10 +- ...ceLivenessSession+OvalMatchChallenge.swift | 12 +- ...LivenessSession+SessionConfiguration.swift | 4 +- .../SPI/AWSPredictionsPlugin+Liveness.swift | 10 +- .../Liveness/SPI/LivenessCredentials.swift | 4 +- .../Service/FaceLivenessSession.swift | 12 +- .../FaceLivenessSessionRepresentable.swift | 6 +- .../Liveness/Service/WebSocketSession.swift | 2 +- .../CoreML/CoreMLPredictionService.swift | 2 +- .../MultiService/IdentifyMultiService.swift | 5 +- .../InterpretTextMultiService.swift | 12 +- .../Predictions/AWSPollyServiceBehavior.swift | 2 +- .../AWSPredictionsService+Comprehend.swift | 6 +- .../AWSPredictionsService+Polly.swift | 2 +- .../AWSPredictionsService+Textract.swift | 2 +- .../AWSPredictionsService+Transcribe.swift | 4 +- .../Predictions/AWSPredictionsService.swift | 16 +-- ...WSTranscribeStreamingServiceBehavior.swift | 2 +- .../Signing/HexDigest.swift | 2 +- .../Signing/SigV4Signer+HashedEmptyBody.swift | 2 +- .../Signing/SigV4Signer+PayloadSigning.swift | 2 +- .../Signing/SigV4Signer+RequestBody.swift | 2 +- .../Signing/SigV4Signer.swift | 6 +- .../Streaming/Data+Bytes.swift | 4 +- .../Streaming/EventStream+Decoder.swift | 12 +- .../Streaming/EventStream+Encoder.swift | 4 +- ...mprehend+PredictionsErrorConvertible.swift | 2 +- .../ErrorHandling/PluginErrorMessage.swift | 4 +- .../Polly+PredictionsErrorConvertible.swift | 2 +- .../PredictionsError+Service.swift | 2 +- ...ognition+PredictionsErrorConvertible.swift | 2 +- ...Textract+PredictionsErrorConvertible.swift | 2 +- ...ranslate+PredictionsErrorConvertible.swift | 2 +- .../Support/PredictionsAWSServices.swift | 28 ++--- ...dentifyCelebritiesResultTransformers.swift | 7 +- .../IdentifyEntitiesResultTransformers.swift | 9 +- .../IdentifyLabelsResultTransformers.swift | 8 +- .../Utils/IdentifyResultTransformers.swift | 14 ++- ...fyTextResultTransformers+KeyValueSet.swift | 11 +- ...dentifyTextResultTransformers+Tables.swift | 11 +- .../IdentifyTextResultTransformers.swift | 13 +- .../Support/Voice+AWSExtension.swift | 118 +++++++++--------- ...reMLPredictionsPlugin+ClientBehavior.swift | 25 ++-- .../CoreMLPredictionsPlugin+Configure.swift | 3 +- .../CoreMLPredictionsPlugin+Reset.swift | 6 +- .../CoreMLPredictionsPlugin.swift | 4 +- .../CoreMLNaturalLanguageAdapter.swift | 6 +- .../CoreMLNaturalLanguageBehavior.swift | 2 +- .../Dependency/CoreMLSpeechAdapter.swift | 6 +- .../Dependency/CoreMLSpeechBehavior.swift | 2 +- .../Dependency/CoreMLVisionBehavior.swift | 2 +- .../Constants/CoreMLPluginErrorString.swift | 4 +- .../PredictionsPluginConfigurationTests.swift | 3 +- .../PollyErrorMappingTestCase.swift | 7 +- .../TextractErrorMappingTestCase.swift | 7 +- .../MockTranscribeStreamingBehavior.swift | 4 +- .../PredictionsPluginInit.swift | 1 + .../PredictionsServiceComprehendTests.swift | 6 +- .../PredictionsServiceRekognitionTests.swift | 4 +- .../PredictionsServiceTextractTests.swift | 4 +- .../PredictionsServiceTranscribeTests.swift | 4 +- .../PredictionsServiceTranslateTests.swift | 4 +- .../SigV4URLSigningTestCase.swift | 2 +- .../Signing+EncodingTestCase.swift | 2 +- ...ictionsPluginAmplifyVersionableTests.swift | 2 +- ...PredictionsPluginClientBehaviorTests.swift | 3 +- .../CoreMLPredictionsPluginConfigTests.swift | 4 +- .../CoreMLPredictionsPluginTestBase.swift | 3 +- .../CoreMLVisionAdapterTests.swift | 2 +- .../MockCoreMLNaturalLanguageAdapter.swift | 2 +- .../Mocks/MockCoreMLSpeechAdapter.swift | 2 +- .../Mocks/MockCoreMLVisionAdapter.swift | 2 +- .../Mocks/MockOperationQueue.swift | 1 + .../AWSPredictionsPluginTestBase.swift | 6 +- .../ConvertBasicIntegrationTests.swift | 4 +- .../IdentifyBasicIntegrationTests.swift | 2 +- ...reMLPredictionsPluginIntegrationTest.swift | 4 +- .../CoreMLPredictionsPluginTestBase.swift | 2 +- .../PredictionsHostApp/ContentView.swift | 8 +- .../PredictionsHostAppApp.swift | 6 +- 96 files changed, 323 insertions(+), 300 deletions(-) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Configure.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Configure.swift index 42ddda79bb..abf055688d 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Configure.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Configure.swift @@ -6,8 +6,8 @@ // @_spi(InternalAmplifyConfiguration) import Amplify -import Foundation import AWSPluginsCore +import Foundation extension AWSPredictionsPlugin { /// Configures AWSPredictionsPlugin with the specified configuration. @@ -68,7 +68,7 @@ extension AWSPredictionsPlugin { config: PredictionsPluginConfiguration ) { self.predictionsService = predictionsService - self.coreMLService = coreMLSerivce + coreMLService = coreMLSerivce self.authService = authService self.config = config } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift index d343a516a8..68e6806e92 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift @@ -5,15 +5,15 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsConvertRequestKind) import Amplify import AWSPolly extension AWSPredictionsPlugin { - public func convert( - _ request: Predictions.Convert.Request, + public func convert( + _ request: Predictions.Convert.Request, options: Options? ) async throws -> Output { switch request.kind { @@ -102,13 +102,15 @@ extension AWSPredictionsPlugin { voice: Predictions.Voice?, config: PredictionsPluginConfiguration ) -> PollyClientTypes.VoiceId { - if let voice = voice, - let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: voice.id) { + if let voice, + let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: voice.id) + { return pollyVoiceID } if let configVoice = config.convert.speechGenerator?.voiceID, - let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: configVoice) { + let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: configVoice) + { return pollyVoiceID } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Identify.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Identify.swift index b7e70f6a12..95135bcccf 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Identify.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Identify.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsConvertRequestKind) import Amplify import AWSPolly -extension AWSPredictionsPlugin { - public func identify( +public extension AWSPredictionsPlugin { + func identify( _ request: Predictions.Identify.Request, in image: URL, options: Predictions.Identify.Options? diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Interpret.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Interpret.swift index 08b92a4b8b..4d395ad8ac 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Interpret.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Interpret.swift @@ -5,17 +5,17 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsConvertRequestKind) import Amplify -extension AWSPredictionsPlugin { +public extension AWSPredictionsPlugin { /// Interprets the input text and detects sentiment, language, syntax, and key phrases /// /// - Parameter text: input text /// - Parameter options: Option for the plugin /// - Parameter resultListener: Listener to which events are send - public func interpret( + func interpret( text: String, options: Predictions.Interpret.Options? ) async throws -> Predictions.Interpret.Result { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Reset.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Reset.swift index 0ed449bde0..30d3df0048 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Reset.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Reset.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation -extension AWSPredictionsPlugin { - public func reset() async { +public extension AWSPredictionsPlugin { + func reset() async { if predictionsService != nil { let resettable = predictionsService as Resettable await resettable.reset() diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin.swift index ad5a9d957b..f7ca6327b9 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin.swift @@ -6,10 +6,10 @@ // import Amplify -import Foundation import AWSPluginsCore +import Foundation -final public class AWSPredictionsPlugin: PredictionsCategoryPlugin { +public final class AWSPredictionsPlugin: PredictionsCategoryPlugin { let awsPredictionsPluginKey = "awsPredictionsPlugin" /// An instance of the predictions service diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Configuration/IdentifyConfiguration.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Configuration/IdentifyConfiguration.swift index b44e23b6b5..dfdb61f98a 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Configuration/IdentifyConfiguration.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Configuration/IdentifyConfiguration.swift @@ -119,7 +119,7 @@ extension IdentifyLabelsConfiguration: Decodable { public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - type = try values.decode(Predictions.LabelType.self, forKey: .type) + self.type = try values.decode(Predictions.LabelType.self, forKey: .type) } } @@ -151,7 +151,7 @@ extension IdentifyTextConfiguration: Decodable { public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - format = try values.decode(Predictions.TextFormatType.self, forKey: .format) + self.format = try values.decode(Predictions.TextFormatType.self, forKey: .format) } } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Dependency/AWSTranscribeStreamingAdapter.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Dependency/AWSTranscribeStreamingAdapter.swift index ec0cbeb219..54cefd1747 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Dependency/AWSTranscribeStreamingAdapter.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Dependency/AWSTranscribeStreamingAdapter.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import AWSClientRuntime import AWSPluginsCore import AWSTranscribeStreaming -import AWSClientRuntime +import Foundation class AWSTranscribeStreamingAdapter: AWSTranscribeStreamingBehavior { @@ -62,7 +62,7 @@ class AWSTranscribeStreamingAdapter: AWSTranscribeStreamingBehavior { var components = URLComponents() components.scheme = "wss" components.host = "transcribestreaming.\(region).amazonaws.com" - components.port = 8443 + components.port = 8_443 components.path = "/stream-transcription-websocket" components.queryItems = [ @@ -95,7 +95,7 @@ class AWSTranscribeStreamingAdapter: AWSTranscribeStreamingBehavior { var currentEnd = min(chunkSize, audioDataSize - currentStart) while currentStart < audioDataSize { - let dataChunk = input.audioStream[currentStart.. Self { + static func final(event: FinalClientEvent) throws -> Self { let clientEvent = ClientSessionInformationEvent( challenge: .init( diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessFreshnessEvent.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessFreshnessEvent.swift index 7bd2d22887..69554a4dee 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessFreshnessEvent.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessFreshnessEvent.swift @@ -24,9 +24,9 @@ public struct FreshnessEvent { } } -extension LivenessEvent where T == FreshnessEvent { +public extension LivenessEvent where T == FreshnessEvent { @_spi(PredictionsFaceLiveness) - public static func freshness(event: FreshnessEvent) throws -> Self { + static func freshness(event: FreshnessEvent) throws -> Self { let clientEvent = ClientSessionInformationEvent( challenge: .init( faceMovementAndLightChallenge: .init( diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessInitialClientEvent.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessInitialClientEvent.swift index 9b522f9680..13482215a5 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessInitialClientEvent.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessInitialClientEvent.swift @@ -24,9 +24,9 @@ public struct InitialClientEvent { let videoStartTimestamp: UInt64 } -extension LivenessEvent where T == InitialClientEvent { +public extension LivenessEvent where T == InitialClientEvent { @_spi(PredictionsFaceLiveness) - public static func initialFaceDetected(event: InitialClientEvent) throws -> Self { + static func initialFaceDetected(event: InitialClientEvent) throws -> Self { let initialFace = InitialFace( boundingBox: .init(boundingBox: event.initialFaceLocation.boundingBox), initialFaceDetectedTimeStamp: event.initialFaceLocation.startTimestamp diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessVideoEvent.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessVideoEvent.swift index 82c09aab85..9e50b666c5 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessVideoEvent.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Events/LivenessVideoEvent.swift @@ -18,9 +18,9 @@ public struct VideoEvent { } } -extension LivenessEvent where T == VideoEvent { +public extension LivenessEvent where T == VideoEvent { @_spi(PredictionsFaceLiveness) - public static func video(event: VideoEvent) throws -> Self { + static func video(event: VideoEvent) throws -> Self { let clientEvent = LivenessVideoEvent( timestampMillis: event.timestamp, videoChunk: event.chunk diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/DTOMapping.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/DTOMapping.swift index 9fc9cca08a..816300f4cb 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/DTOMapping.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/DTOMapping.swift @@ -40,7 +40,7 @@ func ovalChallenge(from event: ServerSessionInformationEvent) -> FaceLivenessSes func colorChallenge(from event: ServerSessionInformationEvent) -> FaceLivenessSession.ColorChallenge { let displayColors = event.sessionInformation.challenge .faceMovementAndLightChallenge.colorSequences - .map({ color -> FaceLivenessSession.DisplayColor in + .map { color -> FaceLivenessSession.DisplayColor in let duration: Double let shouldScroll: Bool @@ -71,7 +71,7 @@ func colorChallenge(from event: ServerSessionInformationEvent) -> FaceLivenessSe duration: duration, shouldScroll: shouldScroll ) - }) + } return .init( colors: displayColors ) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+BoundingBox.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+BoundingBox.swift index 613808940b..bfd0c34c26 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+BoundingBox.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+BoundingBox.swift @@ -8,9 +8,9 @@ import Foundation // swiftlint:disable identifier_name -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct BoundingBox: Codable { + struct BoundingBox: Codable { public let x: Double public let y: Double public let width: Double diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+ColorChallenge.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+ColorChallenge.swift index 78c5b4a156..5f66cfa600 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+ColorChallenge.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+ColorChallenge.swift @@ -7,9 +7,9 @@ import Foundation -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct ColorChallenge { + struct ColorChallenge { public let colors: [DisplayColor] public init(colors: [DisplayColor]) { @@ -18,9 +18,9 @@ extension FaceLivenessSession { } } // swiftlint:disable identifier_name -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct DisplayColor { + struct DisplayColor { public let rgb: RGB public let duration: Double public let shouldScroll: Bool @@ -33,7 +33,7 @@ extension FaceLivenessSession { } @_spi(PredictionsFaceLiveness) - public struct RGB { + struct RGB { public let _values: [Int] public let red: Double public let green: Double diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+OvalMatchChallenge.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+OvalMatchChallenge.swift index f4e886de6b..9fabec6dd5 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+OvalMatchChallenge.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+OvalMatchChallenge.swift @@ -7,9 +7,9 @@ import Foundation -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct OvalMatchChallenge { + struct OvalMatchChallenge { public let faceDetectionThreshold: Double public let face: Face public let oval: Oval @@ -22,9 +22,9 @@ extension FaceLivenessSession { } } -extension FaceLivenessSession.OvalMatchChallenge { +public extension FaceLivenessSession.OvalMatchChallenge { @_spi(PredictionsFaceLiveness) - public struct Face { + struct Face { public let distanceThreshold: Double public let distanceThresholdMax: Double public let distanceThresholdMin: Double @@ -47,9 +47,9 @@ extension FaceLivenessSession.OvalMatchChallenge { } } -extension FaceLivenessSession.OvalMatchChallenge { +public extension FaceLivenessSession.OvalMatchChallenge { @_spi(PredictionsFaceLiveness) - public struct Oval { + struct Oval { public let boundingBox: FaceLivenessSession.BoundingBox public let heightWidthRatio: Double public let iouThreshold: Double diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+SessionConfiguration.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+SessionConfiguration.swift index 139e28f0ed..7f94c6670e 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+SessionConfiguration.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Model/FaceLivenessSession+SessionConfiguration.swift @@ -7,9 +7,9 @@ import Foundation -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct SessionConfiguration { + struct SessionConfiguration { public let colorChallenge: ColorChallenge public let ovalMatchChallenge: OvalMatchChallenge diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/AWSPredictionsPlugin+Liveness.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/AWSPredictionsPlugin+Liveness.swift index d2eec8d96e..208a42afdf 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/AWSPredictionsPlugin+Liveness.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/AWSPredictionsPlugin+Liveness.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSPluginsCore +import Foundation -extension AWSPredictionsPlugin { +public extension AWSPredictionsPlugin { @_spi(PredictionsFaceLiveness) - public static func startFaceLivenessSession( + static func startFaceLivenessSession( withID sessionID: String, credentialsProvider: AWSCredentialsProvider? = nil, region: String, @@ -45,9 +45,9 @@ extension AWSPredictionsPlugin { } } -extension FaceLivenessSession { +public extension FaceLivenessSession { @_spi(PredictionsFaceLiveness) - public struct Options { + struct Options { public init() {} } } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessCredentials.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessCredentials.swift index 24ac34ce76..911d22e13b 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessCredentials.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/SPI/LivenessCredentials.swift @@ -5,14 +5,14 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSPluginsCore +import Foundation func credential(from credentialsProvider: AWSCredentialsProvider?) async throws -> SigV4Signer.Credential { let credentials: AWSCredentials - if let credentialsProvider = credentialsProvider { + if let credentialsProvider { let providedCredentials = try await credentialsProvider.fetchAWSCredentials() credentials = providedCredentials } else { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift index ffc2a9abac..5370950447 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsFaceLiveness) public final class FaceLivenessSession: LivenessService { @@ -17,7 +17,7 @@ public final class FaceLivenessSession: LivenessService { let baseURL: URL var serverEventListeners: [LivenessEventKind.Server: (FaceLivenessSession.SessionConfiguration) -> Void] = [:] var onComplete: (ServerDisconnection) -> Void = { _ in } - + private let livenessServiceDispatchQueue = DispatchQueue( label: "com.amazon.aws.amplify.liveness.service", qos: .userInteractive) @@ -79,8 +79,8 @@ public final class FaceLivenessSession: LivenessService { websocket.open(url: signedConnectionURL) } - public func send( - _ event: LivenessEvent, + public func send( + _ event: LivenessEvent, eventDate: @escaping () -> Date = Date.init ) { livenessServiceDispatchQueue.sync { @@ -121,7 +121,7 @@ public final class FaceLivenessSession: LivenessService { // We'll try to decode each of these events if let payload = try? JSONDecoder().decode(ServerSessionInformationEvent.self, from: message.payload) { let sessionConfiguration = sessionConfiguration(from: payload) - self.serverEventListeners[.challenge]?(sessionConfiguration) + serverEventListeners[.challenge]?(sessionConfiguration) } else if (try? JSONDecoder().decode(DisconnectEvent.self, from: message.payload)) != nil { onComplete(.disconnectionEvent) return false @@ -133,7 +133,7 @@ public final class FaceLivenessSession: LivenessService { switch result { case .success(.data(let data)): do { - let message = try self.eventStreamDecoder.decode(data: data) + let message = try eventStreamDecoder.decode(data: data) if let eventType = message.headers.first(where: { $0.name == ":event-type" }) { let serverEvent = LivenessEventKind.Server(rawValue: eventType.value) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSessionRepresentable.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSessionRepresentable.swift index 896ef5769b..19f06f08e3 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSessionRepresentable.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSessionRepresentable.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsFaceLiveness) public protocol LivenessService { - func send( - _ event: LivenessEvent, + func send( + _ event: LivenessEvent, eventDate: @escaping () -> Date ) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/WebSocketSession.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/WebSocketSession.swift index c0c96f3c17..4d67e2c08e 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/WebSocketSession.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/WebSocketSession.swift @@ -24,7 +24,7 @@ final class WebSocketSession { } func onMessageReceived(_ receive: @escaping (Result) -> Bool) { - self.receiveMessage = receive + receiveMessage = receive } func onSocketClosed(_ onClose: @escaping (URLSessionWebSocketTask.CloseCode) -> Void) { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/CoreML/CoreMLPredictionService.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/CoreML/CoreMLPredictionService.swift index 2d5e62fbd3..e867fd3987 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/CoreML/CoreMLPredictionService.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/CoreML/CoreMLPredictionService.swift @@ -6,9 +6,9 @@ // #if canImport(Speech) && canImport(Vision) -import Foundation import Amplify import CoreMLPredictionsPlugin +import Foundation class CoreMLPredictionService: CoreMLPredictionBehavior { let coreMLPlugin: CoreMLPredictionsPlugin diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/IdentifyMultiService.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/IdentifyMultiService.swift index 1d15c1cb1a..98ce8a5120 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/IdentifyMultiService.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/IdentifyMultiService.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation @_spi(PredictionsIdentifyRequestKind) import Amplify class IdentifyMultiService { @@ -179,7 +179,8 @@ extension Predictions.Label: Hashable { func higherConfidence(compareTo: Predictions.Label) -> Predictions.Label { guard let firstMetadata = metadata, - let secondMetadata = compareTo.metadata else { + let secondMetadata = compareTo.metadata + else { return self } return max(firstMetadata, secondMetadata) == firstMetadata ? self : compareTo diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift index f3d1167e41..ada6ad34e8 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift @@ -97,7 +97,8 @@ class InterpretTextMultiService: MultiServiceBehavior { offlineResult: Predictions.Sentiment? ) -> Predictions.Sentiment? { guard let onlineSentiment = onlineResult, - onlineSentiment.predominantSentiment != .unknown else { + onlineSentiment.predominantSentiment != .unknown + else { return offlineResult } return onlineSentiment @@ -108,7 +109,8 @@ class InterpretTextMultiService: MultiServiceBehavior { offlineResult: [Predictions.KeyPhrase]? ) -> [Predictions.KeyPhrase]? { if let onlineKeyPhrases = onlineResult, - let offlineKeyPhrases = offlineResult { + let offlineKeyPhrases = offlineResult + { let onlineKeyPhraseSet = Set(onlineKeyPhrases) let offlineKeyPhraseSet = Set(offlineKeyPhrases) return Array(onlineKeyPhraseSet.union(offlineKeyPhraseSet)) @@ -124,7 +126,8 @@ class InterpretTextMultiService: MultiServiceBehavior { offlineResult: [Predictions.Entity.DetectionResult]? ) -> [Predictions.Entity.DetectionResult]? { if let onlineEntities = onlineResult, - let offlineEntities = offlineResult { + let offlineEntities = offlineResult + { let onlineEntitiesSet = Set(onlineEntities) let offlineEntitiesSet = Set(offlineEntities) return Array(onlineEntitiesSet.union(offlineEntitiesSet)) @@ -140,7 +143,8 @@ class InterpretTextMultiService: MultiServiceBehavior { offlineResult: [Predictions.SyntaxToken]? ) -> [Predictions.SyntaxToken]? { if let onlineSyntax = onlineResult, - let offlineSyntax = offlineResult { + let offlineSyntax = offlineResult + { let onlineSyntaxSet = Set(onlineSyntax) let offlineSyntaxSet = Set(offlineSyntax) return Array(onlineSyntaxSet.union(offlineSyntaxSet)) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPollyServiceBehavior.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPollyServiceBehavior.swift index d899971eb6..3a49de47f6 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPollyServiceBehavior.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPollyServiceBehavior.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSPolly +import Foundation protocol AWSPollyServiceBehavior { func synthesizeText( diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Comprehend.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Comprehend.swift index d44e7729f3..179138c8e6 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Comprehend.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Comprehend.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import AWSComprehend import Amplify +import AWSComprehend +import Foundation extension AWSPredictionsService: AWSComprehendServiceBehavior { func comprehend(text: String) async throws -> Predictions.Interpret.Result { @@ -211,7 +211,7 @@ extension AWSPredictionsService: AWSComprehendServiceBehavior { } } -extension Array where Element == ComprehendClientTypes.DominantLanguage { +extension [ComprehendClientTypes.DominantLanguage] { func getDominantLanguage() -> ComprehendClientTypes.DominantLanguage? { // SwiftFormat removes `self` below, but that leads to ambiguity between the instance method on Array and the diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Polly.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Polly.swift index 62dbf18308..a7daf6a506 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Polly.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Polly.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSPolly +import Foundation extension AWSPredictionsService: AWSPollyServiceBehavior { func synthesizeText( diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Textract.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Textract.swift index 89fd4ea695..18aabe9cfa 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Textract.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Textract.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSTextract import Amplify +import AWSTextract import Foundation extension AWSPredictionsService: AWSTextractServiceBehavior { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Transcribe.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Transcribe.swift index 7a37b757cd..fb3a6b4f97 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Transcribe.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService+Transcribe.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSPluginsCore import AWSTranscribeStreaming +import Foundation extension AWSPredictionsService: AWSTranscribeStreamingServiceBehavior { func transcribe( @@ -28,7 +28,7 @@ extension AWSPredictionsService: AWSTranscribeStreamingServiceBehavior { audioStream: audioData, languageCode: language, mediaEncoding: .pcm, - mediaSampleRateHertz: 8000 + mediaSampleRateHertz: 8_000 ) // map each `TranscribeStreamingClientTypes.TranscriptEvent` received from the service diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService.swift index 9470da9c2b..482615c379 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSPredictionsService.swift @@ -6,17 +6,17 @@ // import Amplify -import AWSRekognition -import AWSTranslate -import AWSTextract +import AWSClientRuntime import AWSComprehend -import AWSPolly import AWSPluginsCore -@_spi(PluginHTTPClientEngine) import InternalAmplifyCredentials -import Foundation -import ClientRuntime -import AWSClientRuntime +import AWSPolly +import AWSRekognition +import AWSTextract import AWSTranscribeStreaming +import AWSTranslate +import ClientRuntime +import Foundation +@_spi(PluginHTTPClientEngine) import InternalAmplifyCredentials class AWSPredictionsService { var identifier: String! diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSTranscribeStreamingServiceBehavior.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSTranscribeStreamingServiceBehavior.swift index d98d518d9a..5cbedad5f9 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSTranscribeStreamingServiceBehavior.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/Predictions/AWSTranscribeStreamingServiceBehavior.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation protocol AWSTranscribeStreamingServiceBehavior { func transcribe( diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/HexDigest.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/HexDigest.swift index 74c763b268..ddf6909a09 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/HexDigest.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/HexDigest.swift @@ -7,7 +7,7 @@ import Foundation -extension Sequence where Element == UInt8 { +extension Sequence { func hexDigest() -> String { map { String(format: "%02x", $0) }.joined() } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+HashedEmptyBody.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+HashedEmptyBody.swift index 1c07ef055a..b2ebd25ec7 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+HashedEmptyBody.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+HashedEmptyBody.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import CryptoKit +import Foundation extension SigV4Signer { static let hashedEmptyBody = SHA256.hash(data: [UInt8]()).hexDigest() diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+PayloadSigning.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+PayloadSigning.swift index 2f88467b0b..b2a8803e3d 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+PayloadSigning.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+PayloadSigning.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import CryptoKit +import Foundation extension SigV4Signer { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+RequestBody.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+RequestBody.swift index 466fd01141..fc00239c1d 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+RequestBody.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer+RequestBody.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import CryptoKit +import Foundation extension SigV4Signer { struct RequestBody { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift index a78970295d..97216a5227 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import CryptoKit +import Foundation /** SigV4 Signing Process @@ -362,9 +362,9 @@ struct SigV4Signer { func _data(_ s: String) -> Data { .init(s.utf8) } // HMAC SHA256 Hash of data using a key - func _hash( + func _hash( data: Data, - key: D + key: some ContiguousBytes ) -> HashedAuthenticationCode { HMAC.authenticationCode( for: data, diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/Data+Bytes.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/Data+Bytes.swift index 4cefc07a09..e12ce79dc2 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/Data+Bytes.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/Data+Bytes.swift @@ -25,8 +25,8 @@ extension Data { /// - Returns: First byte (`UInt8`) in `self` (`Data`) @discardableResult mutating func readByte() throws -> UInt8 { - guard let first = first else { throw ReadByteError.malformed } - self.removeFirst() + guard let first else { throw ReadByteError.malformed } + removeFirst() return first } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Decoder.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Decoder.swift index c9b05f6034..e93bae4366 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Decoder.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Decoder.swift @@ -50,8 +50,8 @@ extension EventStream { .bigEndianFixedWidth() // bytes of all headers determined by the headerByteLength - let headerBytes = Data( - try data.readBytes( + let headerBytes = try Data( + data.readBytes( count: Int(headerByteLength) ) ) @@ -61,7 +61,7 @@ extension EventStream { // bytes of the payload // variable length based on total length - constant length - headers length - let payloadBytes = Data(try data.readBytes(count: data.count - 4)) + let payloadBytes = try Data(data.readBytes(count: data.count - 4)) // last 4 bytes of messagee make up the CRC for the whole message. let messageCRC: Int32 = Data(data).bigEndianFixedWidth() @@ -136,7 +136,7 @@ extension EventStream { let valueLength: Int16 = try Data(data.readBytes(count: 2)) .bigEndianFixedWidth() - let headerValueBytes = Data(try data.readBytes(count: Int(valueLength))) + let headerValueBytes = try Data(data.readBytes(count: Int(valueLength))) let headerValue = String(decoding: headerValueBytes, as: UTF8.self) let header = Header( @@ -160,9 +160,9 @@ extension EventStream { } } -fileprivate extension Data { +private extension Data { func bigEndianFixedWidth(_ type: T.Type = T.self) -> T { - self.withUnsafeBytes { $0.load(as: type) }.bigEndian + withUnsafeBytes { $0.load(as: type) }.bigEndian } } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Encoder.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Encoder.swift index cceded6c64..b5fd4b4c0c 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Encoder.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Streaming/EventStream+Encoder.swift @@ -63,7 +63,7 @@ extension EventStream { resultData.append(contentsOf: headerLengthToEncodeBytes) // extract the first 8 bytes of the encoded message (prelude) - let preludeData = [UInt8](resultData[0..<8]) + let preludeData = [UInt8](resultData[0 ..< 8]) // generate crc based on the prelude let crc = crc32(0, preludeData, 8) @@ -87,7 +87,7 @@ extension EventStream { // ┗───────────┸───────────────┸──────────┸────────────┸─────────────────┛ for (key, value) in headers { // Header Name Byte Length - let headerKeyLen: UInt8 = UInt8(Data(key.utf8).count) + let headerKeyLen = UInt8(Data(key.utf8).count) // Value String Byte Length as big endian var headerValLen = UInt16(value.data.count).bigEndian diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Comprehend+PredictionsErrorConvertible.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Comprehend+PredictionsErrorConvertible.swift index d1ad4a9911..45cd3af09c 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Comprehend+PredictionsErrorConvertible.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Comprehend+PredictionsErrorConvertible.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSComprehend import Amplify +import AWSComprehend protocol PredictionsErrorConvertible { var predictionsError: PredictionsError { get } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift index e0e8c4ce0e..c09c67cecc 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift @@ -5,12 +5,12 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation typealias PluginErrorString = (errorDescription: ErrorDescription, recoverySuggestion: RecoverySuggestion) -struct PluginErrorMessage { +enum PluginErrorMessage { static let decodeConfigurationError: PluginErrorString = ( "Unable to decode configuration", "Make sure the plugin configuration is JSONValue" diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Polly+PredictionsErrorConvertible.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Polly+PredictionsErrorConvertible.swift index dd3d6f8087..edc4a4b340 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Polly+PredictionsErrorConvertible.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Polly+PredictionsErrorConvertible.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSPolly import Amplify +import AWSPolly extension AWSPolly.InvalidSampleRateException: PredictionsErrorConvertible { var predictionsError: PredictionsError { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PredictionsError+Service.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PredictionsError+Service.swift index 95b6cfe5a4..d14807c451 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PredictionsError+Service.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PredictionsError+Service.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation extension PredictionsError { static func unexpectedServiceErrorType(_ underlyingError: Error?) -> Self { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Rekognition+PredictionsErrorConvertible.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Rekognition+PredictionsErrorConvertible.swift index 0afa93d4fa..714daf2c54 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Rekognition+PredictionsErrorConvertible.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Rekognition+PredictionsErrorConvertible.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSRekognition import Amplify +import AWSRekognition import ClientRuntime extension AWSRekognition.HumanLoopQuotaExceededException: PredictionsErrorConvertible { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Textract+PredictionsErrorConvertible.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Textract+PredictionsErrorConvertible.swift index f6e0a56e8e..3d4d1f75c1 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Textract+PredictionsErrorConvertible.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Textract+PredictionsErrorConvertible.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSTextract import Amplify +import AWSTextract import ClientRuntime extension AWSTextract.HumanLoopQuotaExceededException: PredictionsErrorConvertible { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Translate+PredictionsErrorConvertible.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Translate+PredictionsErrorConvertible.swift index d24f73510c..ef630e1c44 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Translate+PredictionsErrorConvertible.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/Translate+PredictionsErrorConvertible.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSTranslate import Amplify +import AWSTranslate extension AWSTranslate.DetectedLanguageLowConfidenceException: PredictionsErrorConvertible { var predictionsError: PredictionsError { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/PredictionsAWSServices.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/PredictionsAWSServices.swift index c1d79925ba..ad37a8406a 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/PredictionsAWSServices.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/PredictionsAWSServices.swift @@ -5,33 +5,33 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import AWSTranslate -import AWSRekognition -import AWSPolly import AWSComprehend +import AWSPolly +import AWSRekognition import AWSTextract +import AWSTranslate +import Foundation public struct PredictionsAWSService { let fetch: (AWSPredictionsService) -> Client } -extension PredictionsAWSService where Client == RekognitionClientProtocol { - public static let rekognition = Self(fetch: \.awsRekognition) +public extension PredictionsAWSService where Client == RekognitionClientProtocol { + static let rekognition = Self(fetch: \.awsRekognition) } -extension PredictionsAWSService where Client == TranslateClientProtocol { - public static let translate = Self(fetch: \.awsTranslate) +public extension PredictionsAWSService where Client == TranslateClientProtocol { + static let translate = Self(fetch: \.awsTranslate) } -extension PredictionsAWSService where Client == PollyClientProtocol { - public static let polly = Self(fetch: \.awsPolly) +public extension PredictionsAWSService where Client == PollyClientProtocol { + static let polly = Self(fetch: \.awsPolly) } -extension PredictionsAWSService where Client == ComprehendClientProtocol { - public static let comprehend = Self(fetch: \.awsComprehend) +public extension PredictionsAWSService where Client == ComprehendClientProtocol { + static let comprehend = Self(fetch: \.awsComprehend) } -extension PredictionsAWSService where Client == TextractClientProtocol { - public static let textract = Self(fetch: \.awsTextract) +public extension PredictionsAWSService where Client == TextractClientProtocol { + static let textract = Self(fetch: \.awsTextract) } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyCelebritiesResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyCelebritiesResultTransformers.swift index a82ad23f20..a992fcd06a 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyCelebritiesResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyCelebritiesResultTransformers.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import AWSRekognition import Amplify +import AWSRekognition +import Foundation enum IdentifyCelebritiesResultTransformers { static func processCelebs( @@ -19,7 +19,8 @@ enum IdentifyCelebritiesResultTransformers { guard let name = rekognitionCeleb.name, let identifier = rekognitionCeleb.id, let face = rekognitionCeleb.face, - let stringUrls = rekognitionCeleb.urls else { + let stringUrls = rekognitionCeleb.urls + else { continue } var urls = [URL]() diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyEntitiesResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyEntitiesResultTransformers.swift index ddd6f53065..2aaa464c3b 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyEntitiesResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyEntitiesResultTransformers.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSRekognition import Amplify +import AWSRekognition enum IdentifyEntitiesResultTransformers { static func processFaces( @@ -20,7 +20,7 @@ enum IdentifyEntitiesResultTransformers { } let landmarks = IdentifyResultTransformers.processLandmarks(rekognitionFace.landmarks) let emotions = processEmotions(rekognitionFace.emotions) - let ageRange = (rekognitionFace.ageRange?.low ?? 0)...(rekognitionFace.ageRange?.high ?? 0) + let ageRange = (rekognitionFace.ageRange?.low ?? 0) ... (rekognitionFace.ageRange?.high ?? 0) let genderAttribute = Predictions.GenderAttribute( gender: mapGender( @@ -32,7 +32,8 @@ enum IdentifyEntitiesResultTransformers { guard let pitch = rekognitionFace.pose?.pitch, let roll = rekognitionFace.pose?.roll, - let yaw = rekognitionFace.pose?.yaw else { + let yaw = rekognitionFace.pose?.yaw + else { continue } @@ -92,7 +93,7 @@ enum IdentifyEntitiesResultTransformers { _ rekognitionEmotions: [RekognitionClientTypes.Emotion]? ) -> [Predictions.Emotion] { var emotions = [Predictions.Emotion]() - guard let rekognitionEmotions = rekognitionEmotions + guard let rekognitionEmotions else { return emotions } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyLabelsResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyLabelsResultTransformers.swift index 451f3d56d0..eff789a4da 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyLabelsResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyLabelsResultTransformers.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import AWSRekognition import Amplify +import AWSRekognition +import Foundation enum IdentifyLabelsResultTransformers { static func processLabels( @@ -69,7 +69,7 @@ enum IdentifyLabelsResultTransformers { _ rekognitionParents: [RekognitionClientTypes.Parent]? ) -> [Predictions.Parent] { var parents = [Predictions.Parent]() - guard let rekognitionParents = rekognitionParents else { + guard let rekognitionParents else { return parents } @@ -85,7 +85,7 @@ enum IdentifyLabelsResultTransformers { _ rekognitionInstances: [RekognitionClientTypes.Instance]? ) -> [CGRect] { var boundingBoxes = [CGRect]() - guard let rekognitionInstances = rekognitionInstances else { + guard let rekognitionInstances else { return boundingBoxes } for rekognitionInstance in rekognitionInstances { diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift index 85f60dd384..163c404995 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSRekognition import AWSTextract import CoreGraphics +import Foundation enum IdentifyResultTransformers { static func processBoundingBox(_ rekognitionBoundingBox: RekognitionClientTypes.BoundingBox?) -> CGRect? { @@ -31,13 +31,14 @@ enum IdentifyResultTransformers { } static func processPolygon(_ rekognitionPolygonPoints: [RekognitionClientTypes.Point]?) -> Predictions.Polygon? { - guard let rekognitionPolygonPoints = rekognitionPolygonPoints else { + guard let rekognitionPolygonPoints else { return nil } var points = [CGPoint]() for rekognitionPoint in rekognitionPolygonPoints { guard let xPosition = rekognitionPoint.x, - let yPosition = rekognitionPoint.y else { + let yPosition = rekognitionPoint.y + else { continue } let point = CGPoint(x: Double(xPosition), y: Double(yPosition)) // TODO: What about Truncating??? @@ -47,7 +48,7 @@ enum IdentifyResultTransformers { } static func processPolygon(_ textractPolygonPoints: [TextractClientTypes.Point]?) -> Predictions.Polygon? { - guard let textractPolygonPoints = textractPolygonPoints else { + guard let textractPolygonPoints else { return nil } @@ -65,7 +66,7 @@ enum IdentifyResultTransformers { // swiftlint:disable cyclomatic_complexity static func processLandmarks(_ rekognitionLandmarks: [RekognitionClientTypes.Landmark]?) -> [Predictions.Landmark] { var landmarks = [Predictions.Landmark]() - guard let rekognitionLandmarks = rekognitionLandmarks else { + guard let rekognitionLandmarks else { return landmarks } @@ -82,7 +83,8 @@ enum IdentifyResultTransformers { var faceContourPoints: [CGPoint] = [] for rekognitionLandmark in rekognitionLandmarks { guard let xPosition = rekognitionLandmark.x.map(Double.init), - let yPosition = rekognitionLandmark.y.map(Double.init) else { + let yPosition = rekognitionLandmark.y.map(Double.init) + else { continue } let point = CGPoint(x: xPosition, y: yPosition) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+KeyValueSet.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+KeyValueSet.swift index a2d6eaa741..8b1c501bd2 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+KeyValueSet.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+KeyValueSet.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSTextract +import Foundation extension IdentifyTextResultTransformers { @@ -30,7 +30,8 @@ extension IdentifyTextResultTransformers { ) -> Predictions.BoundedKeyValue? { guard keyBlock.blockType == .keyValueSet, keyBlock.entityTypes?.contains(.key) ?? false, - let relationships = keyBlock.relationships else { + let relationships = keyBlock.relationships + else { return nil } @@ -80,7 +81,8 @@ extension IdentifyTextResultTransformers { for keyId in ids { guard let keyBlock = blockMap[keyId], let text = keyBlock.text, - case .word = keyBlock.blockType else { + case .word = keyBlock.blockType + else { continue } keyText += text + " " @@ -99,7 +101,8 @@ extension IdentifyTextResultTransformers { for valueId in ids { guard let valueBlock = blockMap[valueId], - let valueBlockRelations = valueBlock.relationships else { + let valueBlockRelations = valueBlock.relationships + else { continue } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift index 3419f5b2d8..acc509be8d 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify import AWSTextract +import Foundation extension IdentifyTextResultTransformers { @@ -30,7 +30,8 @@ extension IdentifyTextResultTransformers { ) -> Predictions.Table? { guard let relationships = tableBlock.relationships, - case .table = tableBlock.blockType else { + case .table = tableBlock.blockType + else { return nil } var table = Predictions.Table() @@ -56,7 +57,8 @@ extension IdentifyTextResultTransformers { if !rows.contains(row), !cols.contains(row), - let cell = constructTableCell(cellBlock, blockMap) { + let cell = constructTableCell(cellBlock, blockMap) + { table.cells.append(cell) rows.insert(row) cols.insert(col) @@ -120,7 +122,8 @@ extension IdentifyTextResultTransformers { } guard let boundingBox = IdentifyResultTransformers.processBoundingBox(textractBoundingBox), - let polygon = IdentifyResultTransformers.processPolygon(texttractPolygon) else { + let polygon = IdentifyResultTransformers.processPolygon(texttractPolygon) + else { return nil } diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift index 3b0f5a1824..99e746c1a2 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import AWSRekognition import Amplify +import AWSRekognition import AWSTextract +import Foundation enum IdentifyTextResultTransformers { @@ -125,7 +125,8 @@ enum IdentifyTextResultTransformers { static func processLineBlock(block: TextractClientTypes.Block) -> Predictions.IdentifiedLine? { guard let text = block.text, let boundingBox = IdentifyResultTransformers.processBoundingBox(block.geometry?.boundingBox), - let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) else { + let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) + else { return nil } @@ -140,7 +141,8 @@ enum IdentifyTextResultTransformers { static func processWordBlock(block: TextractClientTypes.Block) -> Predictions.IdentifiedWord? { guard let text = block.text, let boundingBox = IdentifyResultTransformers.processBoundingBox(block.geometry?.boundingBox), - let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) else { + let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) + else { return nil } @@ -154,7 +156,8 @@ enum IdentifyTextResultTransformers { static func processSelectionElementBlock(block: TextractClientTypes.Block) -> Predictions.Selection? { guard let boundingBox = IdentifyResultTransformers.processBoundingBox(block.geometry?.boundingBox), - let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) else { + let polygon = IdentifyResultTransformers.processPolygon(block.geometry?.polygon) + else { return nil } let selectionStatus = block.selectionStatus == .selected diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Voice+AWSExtension.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Voice+AWSExtension.swift index e3bab2832d..4bd2bc5672 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Voice+AWSExtension.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Voice+AWSExtension.swift @@ -8,63 +8,63 @@ import Amplify import AWSPolly -extension Predictions.Voice { - public static let arabicFemaleZeina = Self(id: "Zeina") - public static let chineseFemaleZhiyu = Self(id: "Zhiyu") - public static let danishFemaleNaja = Self(id: "Naja") - public static let danishMaleMads = Self(id: "Mads") - public static let dutchFemaleLotte = Self(id: "Lotte") - public static let dutchMaleRuben = Self(id: "Ruben") - public static let ausEnglishFemaleNicole = Self(id: "Nicole") - public static let ausEnglishMaleRussell = Self(id: "Russell") - public static let britEnglishFemaleAmy = Self(id: "Amy") - public static let britEnglishFemaleEmma = Self(id: "Emma") - public static let britEnglishMaleBrian = Self(id: "Brian") - public static let indiEnglishAndHindFemaleAditi = Self(id: "Aditi") - public static let indiEnglishFemaleRaveena = Self(id: "Raveena") - public static let englishFemaleIvy = Self(id: "Ivy") - public static let englishFemaleJoanna = Self(id: "Joanna") - public static let englishFemaleKendra = Self(id: "Kendra") - public static let englishFemaleKimberly = Self(id: "Kimberly") - public static let englishFemaleSalli = Self(id: "Salli") - public static let englishMaleJoey = Self(id: "Joey") - public static let englishMaleJustin = Self(id: "Justin") - public static let englishMaleMatthew = Self(id: "Matthew") - public static let welshEnglishMaleGeraint = Self(id: "Geraint") - public static let frenchFemaleCeline = Self(id: "Celine") - public static let frenchFemaleLea = Self(id: "Lea") - public static let frenchMaleMathieu = Self(id: "Mathieu") - public static let canadianFrenchFemaleChantal = Self(id: "Chantal") - public static let germanFemaleMarlene = Self(id: "Marlene") - public static let germanFemaleVicki = Self(id: "Vicki") - public static let germanMaleHans = Self(id: "Hans") - public static let icelandicFemaleDora = Self(id: "Dora") - public static let icelandicMaleKarl = Self(id: "Karl") - public static let italianFemaleCarla = Self(id: "Carla") - public static let italianFemaleBianca = Self(id: "Bianca") - public static let italianMaleGiorgio = Self(id: "Giorgio") - public static let japaneseFemaleMizuki = Self(id: "Mizuki") - public static let japaneseMaleTakumi = Self(id: "Takumi") - public static let koreanFemaleSeoyeon = Self(id: "Seoyeon") - public static let norwegianFemaleLiv = Self(id: "Liv") - public static let polishFemaleEwa = Self(id: "Ewa") - public static let polishFemaleMaja = Self(id: "Maja") - public static let polishMaleJacek = Self(id: "Jacek") - public static let polishMaleJan = Self(id: "Jan") - public static let brazPortugueseFemaleVitoria = Self(id: "Vitoria") - public static let brazPortugueseMaleRicardo = Self(id: "Ricardo") - public static let euroPortugueseFemaleInes = Self(id: "Ines") - public static let euroPortugueseMaleCristiano = Self(id: "Cristiano") - public static let romanianFemaleCarmen = Self(id: "Carmen") - public static let russianFemaleTatyana = Self(id: "Tatyana") - public static let russianMaleMaxim = Self(id: "Maxim") - public static let euroSpanishFemaleConchita = Self(id: "Conchita") - public static let euroSpanishFemaleLucia = Self(id: "Lucia") - public static let euroSpanishMaleEnrique = Self(id: "Enrique") - public static let mexSpanishFemaleMia = Self(id: "Mia") - public static let usSpanishFemalePenelope = Self(id: "Peneleope") - public static let usSpanishMaleMiguel = Self(id: "Miguel") - public static let swedishFemaleAstrid = Self(id: "Astrid") - public static let turkishFemaleFiliz = Self(id: "Filiz") - public static let welshFemaleGwyneth = Self(id: "Gwyneth") +public extension Predictions.Voice { + static let arabicFemaleZeina = Self(id: "Zeina") + static let chineseFemaleZhiyu = Self(id: "Zhiyu") + static let danishFemaleNaja = Self(id: "Naja") + static let danishMaleMads = Self(id: "Mads") + static let dutchFemaleLotte = Self(id: "Lotte") + static let dutchMaleRuben = Self(id: "Ruben") + static let ausEnglishFemaleNicole = Self(id: "Nicole") + static let ausEnglishMaleRussell = Self(id: "Russell") + static let britEnglishFemaleAmy = Self(id: "Amy") + static let britEnglishFemaleEmma = Self(id: "Emma") + static let britEnglishMaleBrian = Self(id: "Brian") + static let indiEnglishAndHindFemaleAditi = Self(id: "Aditi") + static let indiEnglishFemaleRaveena = Self(id: "Raveena") + static let englishFemaleIvy = Self(id: "Ivy") + static let englishFemaleJoanna = Self(id: "Joanna") + static let englishFemaleKendra = Self(id: "Kendra") + static let englishFemaleKimberly = Self(id: "Kimberly") + static let englishFemaleSalli = Self(id: "Salli") + static let englishMaleJoey = Self(id: "Joey") + static let englishMaleJustin = Self(id: "Justin") + static let englishMaleMatthew = Self(id: "Matthew") + static let welshEnglishMaleGeraint = Self(id: "Geraint") + static let frenchFemaleCeline = Self(id: "Celine") + static let frenchFemaleLea = Self(id: "Lea") + static let frenchMaleMathieu = Self(id: "Mathieu") + static let canadianFrenchFemaleChantal = Self(id: "Chantal") + static let germanFemaleMarlene = Self(id: "Marlene") + static let germanFemaleVicki = Self(id: "Vicki") + static let germanMaleHans = Self(id: "Hans") + static let icelandicFemaleDora = Self(id: "Dora") + static let icelandicMaleKarl = Self(id: "Karl") + static let italianFemaleCarla = Self(id: "Carla") + static let italianFemaleBianca = Self(id: "Bianca") + static let italianMaleGiorgio = Self(id: "Giorgio") + static let japaneseFemaleMizuki = Self(id: "Mizuki") + static let japaneseMaleTakumi = Self(id: "Takumi") + static let koreanFemaleSeoyeon = Self(id: "Seoyeon") + static let norwegianFemaleLiv = Self(id: "Liv") + static let polishFemaleEwa = Self(id: "Ewa") + static let polishFemaleMaja = Self(id: "Maja") + static let polishMaleJacek = Self(id: "Jacek") + static let polishMaleJan = Self(id: "Jan") + static let brazPortugueseFemaleVitoria = Self(id: "Vitoria") + static let brazPortugueseMaleRicardo = Self(id: "Ricardo") + static let euroPortugueseFemaleInes = Self(id: "Ines") + static let euroPortugueseMaleCristiano = Self(id: "Cristiano") + static let romanianFemaleCarmen = Self(id: "Carmen") + static let russianFemaleTatyana = Self(id: "Tatyana") + static let russianMaleMaxim = Self(id: "Maxim") + static let euroSpanishFemaleConchita = Self(id: "Conchita") + static let euroSpanishFemaleLucia = Self(id: "Lucia") + static let euroSpanishMaleEnrique = Self(id: "Enrique") + static let mexSpanishFemaleMia = Self(id: "Mia") + static let usSpanishFemalePenelope = Self(id: "Peneleope") + static let usSpanishMaleMiguel = Self(id: "Miguel") + static let swedishFemaleAstrid = Self(id: "Astrid") + static let turkishFemaleFiliz = Self(id: "Filiz") + static let welshFemaleGwyneth = Self(id: "Gwyneth") } diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+ClientBehavior.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+ClientBehavior.swift index 388226e743..c13cff129a 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+ClientBehavior.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+ClientBehavior.swift @@ -6,14 +6,14 @@ // #if canImport(Speech) && canImport(Vision) -import Foundation -import CoreGraphics import Amplify +import CoreGraphics +import Foundation @_spi(PredictionsIdentifyRequestKind) import Amplify @_spi(PredictionsConvertRequestKind) import Amplify -extension CoreMLPredictionsPlugin { - public func identify( +public extension CoreMLPredictionsPlugin { + func identify( _ request: Predictions.Identify.Request, in image: URL, options: Predictions.Identify.Options? @@ -66,8 +66,8 @@ extension CoreMLPredictionsPlugin { } } - public func convert( - _ request: Predictions.Convert.Request, + func convert( + _ request: Predictions.Convert.Request, options: Options? ) async throws -> Output { var predictionsError: PredictionsError { @@ -111,7 +111,7 @@ extension CoreMLPredictionsPlugin { } } - public func interpret( + func interpret( text: String, options: Predictions.Interpret.Options? ) async throws -> Predictions.Interpret.Result { @@ -131,16 +131,15 @@ extension CoreMLPredictionsPlugin { let entities = naturalLanguageAdapter.getEntities(for: text) let sentiment = naturalLanguageAdapter.getSentiment(for: text) - let predictionsSentiment: Predictions.Sentiment - switch sentiment { + let predictionsSentiment = switch sentiment { case 0.0: - predictionsSentiment = Predictions.Sentiment(predominantSentiment: .neutral, sentimentScores: nil) + Predictions.Sentiment(predominantSentiment: .neutral, sentimentScores: nil) case -1.0 ..< 0.0: - predictionsSentiment = Predictions.Sentiment(predominantSentiment: .negative, sentimentScores: nil) + Predictions.Sentiment(predominantSentiment: .negative, sentimentScores: nil) case 0.0 ... 1.0: - predictionsSentiment = Predictions.Sentiment(predominantSentiment: .positive, sentimentScores: nil) + Predictions.Sentiment(predominantSentiment: .positive, sentimentScores: nil) default: - predictionsSentiment = Predictions.Sentiment(predominantSentiment: .mixed, sentimentScores: nil) + Predictions.Sentiment(predominantSentiment: .mixed, sentimentScores: nil) } let result = Predictions.Interpret.Result( diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift index 19edc1c7d2..3fb1c61e19 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift @@ -25,7 +25,8 @@ extension CoreMLPredictionsPlugin { func configure(naturalLanguageBehavior: CoreMLNaturalLanguageBehavior, visionBehavior: CoreMLVisionBehavior, speechBehavior: CoreMLSpeechBehavior, - queue: OperationQueue = OperationQueue()) { + queue: OperationQueue = OperationQueue()) + { coreMLNaturalLanguage = naturalLanguageBehavior coreMLVision = visionBehavior coreMLSpeech = speechBehavior diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Reset.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Reset.swift index e28e2164da..af0fc211e7 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Reset.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Reset.swift @@ -6,12 +6,12 @@ // #if canImport(Speech) && canImport(Vision) -import Foundation import Amplify +import Foundation -extension CoreMLPredictionsPlugin { +public extension CoreMLPredictionsPlugin { - public func reset() async { + func reset() async { queue = nil coreMLNaturalLanguage = nil coreMLSpeech = nil diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin.swift index ce0e42b318..f3573c7728 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin.swift @@ -6,11 +6,11 @@ // #if canImport(Speech) && canImport(Vision) -import Foundation import Amplify +import Foundation /// Predictions plugin that uses CoreML service to get results. -final public class CoreMLPredictionsPlugin: PredictionsCategoryPlugin { +public final class CoreMLPredictionsPlugin: PredictionsCategoryPlugin { let coreMLPredictionsPluginKey = "CoreMLPredictionsPlugin" diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageAdapter.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageAdapter.swift index 495e5b915a..f0f79d4aa3 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageAdapter.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageAdapter.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation import NaturalLanguage class CoreMLNaturalLanguageAdapter: CoreMLNaturalLanguageBehavior { @@ -30,7 +30,7 @@ class CoreMLNaturalLanguageAdapter: CoreMLNaturalLanguageBehavior { options: options ) { tag, tokenRange in - if let tag = tag { + if let tag { let partOfSpeech = Predictions.PartOfSpeech.DetectionResult( partOfSpeech: tag.getSpeechType(), score: nil @@ -62,7 +62,7 @@ class CoreMLNaturalLanguageAdapter: CoreMLNaturalLanguageBehavior { scheme: .nameType, options: options ) { tag, tokenRange in - if let tag = tag, tags.contains(tag) { + if let tag, tags.contains(tag) { let entity = Predictions.Entity.DetectionResult( type: tag.getEntityType(), targetText: String(text[tokenRange]), diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageBehavior.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageBehavior.swift index 3da38ee235..fd346824e2 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageBehavior.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLNaturalLanguageBehavior.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation protocol CoreMLNaturalLanguageBehavior: AnyObject { diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechAdapter.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechAdapter.swift index 218da5d860..56b7672835 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechAdapter.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechAdapter.swift @@ -25,13 +25,13 @@ class CoreMLSpeechAdapter: CoreMLSpeechBehavior { let result = try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in recognizer.recognitionTask( with: request, - resultHandler: { (result, error) in - if let error = error { + resultHandler: { result, error in + if let error { continuation.resume(with: .failure(error)) return } - guard let result = result else { + guard let result else { continuation.resume(with: .failure( PredictionsError.client( .init( diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechBehavior.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechBehavior.swift index ce36746b91..97bf27eb96 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechBehavior.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLSpeechBehavior.swift @@ -6,8 +6,8 @@ // #if canImport(Speech) -import Foundation import Amplify +import Foundation import Speech protocol CoreMLSpeechBehavior: AnyObject { diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionBehavior.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionBehavior.swift index 731d3e80bc..3d51284bef 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionBehavior.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionBehavior.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation protocol CoreMLVisionBehavior: AnyObject { func detectLabels(_ imageURL: URL) throws -> Predictions.Identify.Labels.Result? diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift index aab7adca9c..a229579494 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift @@ -5,12 +5,12 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation typealias PluginErrorString = (errorDescription: ErrorDescription, recoverySuggestion: RecoverySuggestion) -struct CoreMLPluginErrorString { +enum CoreMLPluginErrorString { static let decodeConfigurationError: PluginErrorString = ( "Unable to decode configuration", "Make sure the plugin configuration is JSONValue") diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift index 942712c8f6..819c27c397 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift @@ -224,7 +224,8 @@ class PredictionsPluginConfigurationTests: XCTestCase { XCTFail("Predictions configuration should not succeed") } catch { guard let pluginError = error as? PluginError, - case .pluginConfigurationError = pluginError else { + case .pluginConfigurationError = pluginError + else { XCTFail("Should throw invalidConfiguration exception. But received \(error) ") return } diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/PollyErrorMappingTestCase.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/PollyErrorMappingTestCase.swift index 62133dac70..cd22b26020 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/PollyErrorMappingTestCase.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/PollyErrorMappingTestCase.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -import AWSPolly import Amplify +import AWSPolly +import XCTest @testable import AWSPredictionsPlugin final class PollyErrorMappingTestCase: XCTestCase { @@ -27,8 +27,7 @@ final class PollyErrorMappingTestCase: XCTestCase { guard case .service(expectedServiceError) = error.predictionsError else { return XCTFail(unexpected(error.predictionsError)) } - } - catch { + } catch { XCTFail(unexpected(error)) } diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/TextractErrorMappingTestCase.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/TextractErrorMappingTestCase.swift index 526b3d37ae..d47d212082 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/TextractErrorMappingTestCase.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ErrorMapping/TextractErrorMappingTestCase.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -import AWSTextract import Amplify +import AWSTextract +import XCTest @testable import AWSPredictionsPlugin final class TextractErrorMappingTestCase: XCTestCase { @@ -26,8 +26,7 @@ final class TextractErrorMappingTestCase: XCTestCase { guard case .service(expectedServiceError) = error.predictionsError else { return XCTFail(unexpected(error.predictionsError)) } - } - catch { + } catch { XCTFail(unexpected(error)) } diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Mocks/Service/MockTranscribeStreamingBehavior.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Mocks/Service/MockTranscribeStreamingBehavior.swift index fd6b6a6051..2727406250 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Mocks/Service/MockTranscribeStreamingBehavior.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Mocks/Service/MockTranscribeStreamingBehavior.swift @@ -5,16 +5,16 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify import AWSTranscribeStreaming +import XCTest @testable import AWSPredictionsPlugin class MockTranscribeBehavior: AWSTranscribeStreamingBehavior { var startStreamingResult: ((AWSTranscribeStreamingAdapter.StartStreamInput) async throws -> AsyncThrowingStream)? = nil func startStreamTranscription(input: AWSTranscribeStreamingAdapter.StartStreamInput) async throws -> AsyncThrowingStream { - guard let startStreamingResult = startStreamingResult else { throw MockBehaviorDefaultError() } + guard let startStreamingResult else { throw MockBehaviorDefaultError() } return try await startStreamingResult(input) } } diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/PredictionsPluginInit.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/PredictionsPluginInit.swift index ffee75eb9a..30711c3762 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/PredictionsPluginInit.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/PredictionsPluginInit.swift @@ -6,6 +6,7 @@ // import XCTest + // This import statement needs to stay as it is. // Do not add @testable import AWSPredictionsPlugin diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceComprehendTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceComprehendTests.swift index 47e8dfc2b2..653966669e 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceComprehendTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceComprehendTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -import AWSComprehend import Amplify +import AWSComprehend +import XCTest @testable import AWSPredictionsPlugin class PredictionsServiceComprehendTests: XCTestCase { @@ -21,7 +21,7 @@ class PredictionsServiceComprehendTests: XCTestCase { "defaultRegion": "us_east_1" } """ - + do { let mockConfiguration = try JSONDecoder().decode( PredictionsPluginConfiguration.self, diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceRekognitionTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceRekognitionTests.swift index 548b1e1e20..fb6f73a9bf 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceRekognitionTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceRekognitionTests.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest +import Amplify import AWSRekognition import CoreML -import Amplify import Foundation +import XCTest @testable import AWSPredictionsPlugin // swiftlint:disable file_length type_body_length diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTextractTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTextractTests.swift index affe295d76..51cec07800 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTextractTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTextractTests.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest +import Amplify import AWSTextract import CoreML -import Amplify import Foundation +import XCTest @testable import AWSPredictionsPlugin class PredictionsServiceTextractTests: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranscribeTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranscribeTests.swift index 51bbfc8370..7df565d644 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranscribeTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranscribeTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -import AWSTranscribeStreaming import Amplify +import AWSTranscribeStreaming +import XCTest @testable import AWSPredictionsPlugin class PredictionsServiceTranscribeTests: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranslateTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranslateTests.swift index b2ac13dcdf..aa7c006b11 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranslateTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Service/PredictionsTest/PredictionsServiceTranslateTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -import AWSTranslate import Amplify +import AWSTranslate +import XCTest @testable import AWSPredictionsPlugin class PredictionsServiceTranslateTests: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/SigV4SignerTests/SigV4URLSigningTestCase.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/SigV4SignerTests/SigV4URLSigningTestCase.swift index b3b1d5f701..635050abe6 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/SigV4SignerTests/SigV4URLSigningTestCase.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/SigV4SignerTests/SigV4URLSigningTestCase.swift @@ -24,7 +24,7 @@ class SigV4URLSigningTestCase: XCTestCase { ) // 20230327T201815Z - let date = Date(timeIntervalSince1970: 1679948295) + let date = Date(timeIntervalSince1970: 1_679_948_295) func testSignWSSURL() throws { let url = try url() diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Signing+EncodingTests/Signing+EncodingTestCase.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Signing+EncodingTests/Signing+EncodingTestCase.swift index 796144ff8a..8d6e2c2e45 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Signing+EncodingTests/Signing+EncodingTestCase.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/Signing+EncodingTests/Signing+EncodingTestCase.swift @@ -24,7 +24,7 @@ final class SigningEncodingTestCase: XCTestCase { ) // 20230327T201815Z - let date = Date(timeIntervalSince1970: 1679948295) + let date = Date(timeIntervalSince1970: 1_679_948_295) /// Given: A payload and credentials. /// When: A SigV4 signed url is created with credentials, diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginAmplifyVersionableTests.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginAmplifyVersionableTests.swift index ed189bf931..316500739e 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginAmplifyVersionableTests.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginAmplifyVersionableTests.swift @@ -6,8 +6,8 @@ // #if canImport(Speech) && canImport(Vision) -import XCTest import CoreMLPredictionsPlugin +import XCTest // swiftlint:disable:next type_name class CoreMLPredictionsPluginAmplifyVersionableTests: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginClientBehaviorTests.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginClientBehaviorTests.swift index 2b1470d3be..299dfa0692 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginClientBehaviorTests.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginClientBehaviorTests.swift @@ -4,9 +4,10 @@ // // SPDX-License-Identifier: Apache-2.0 // + #if canImport(Speech) && canImport(Vision) -import XCTest import Amplify +import XCTest @testable import CoreMLPredictionsPlugin class CoreMLPredictionsPluginTests: CoreMLPredictionsPluginTestBase { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginConfigTests.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginConfigTests.swift index 68c0ed2afc..63fe38a30c 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginConfigTests.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginConfigTests.swift @@ -6,16 +6,16 @@ // #if canImport(Speech) && canImport(Vision) +import CoreMLPredictionsPlugin import XCTest @_spi(InternalAmplifyConfiguration) @testable import Amplify -import CoreMLPredictionsPlugin class CoreMLPredictionsPluginConfigTests: XCTestCase { override func setUp() async throws { await Amplify.reset() } - + func testThrowsOnMissingConfig() throws { let plugin = CoreMLPredictionsPlugin() try Amplify.add(plugin: plugin) diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginTestBase.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginTestBase.swift index c5698ec22f..a2c4ea880b 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginTestBase.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/CoreMLPredictionsPluginTestBase.swift @@ -4,9 +4,10 @@ // // SPDX-License-Identifier: Apache-2.0 // + #if canImport(Speech) && canImport(Vision) -import XCTest import Amplify +import XCTest @testable import CoreMLPredictionsPlugin class CoreMLPredictionsPluginTestBase: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/DependencyTests/CoreMLVisionAdapterTests.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/DependencyTests/CoreMLVisionAdapterTests.swift index fc8bf9c4a6..8e42496e49 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/DependencyTests/CoreMLVisionAdapterTests.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/DependencyTests/CoreMLVisionAdapterTests.swift @@ -6,8 +6,8 @@ // #if canImport(Vision) -import XCTest import Vision +import XCTest @testable import CoreMLPredictionsPlugin class CoreMLVisionAdapterTests: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLNaturalLanguageAdapter.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLNaturalLanguageAdapter.swift index e59e002b79..0b5602dcb8 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLNaturalLanguageAdapter.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLNaturalLanguageAdapter.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest @testable import CoreMLPredictionsPlugin class MockCoreMLNaturalLanguageAdapter: CoreMLNaturalLanguageBehavior { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLSpeechAdapter.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLSpeechAdapter.swift index 6010cfa447..367ebc06a0 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLSpeechAdapter.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLSpeechAdapter.swift @@ -6,9 +6,9 @@ // #if canImport(Speech) -import XCTest import Amplify import Speech +import XCTest @testable import CoreMLPredictionsPlugin class MockCoreMLSpeechAdapter: CoreMLSpeechBehavior { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLVisionAdapter.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLVisionAdapter.swift index 298bcfcc9e..a3fff472fa 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLVisionAdapter.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockCoreMLVisionAdapter.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest @testable import CoreMLPredictionsPlugin class MockCoreMLVisionAdapter: CoreMLVisionBehavior { diff --git a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockOperationQueue.swift b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockOperationQueue.swift index 54635fe020..de6fc30667 100644 --- a/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockOperationQueue.swift +++ b/AmplifyPlugins/Predictions/Tests/CoreMLPredictionsPluginUnitTests/Mocks/MockOperationQueue.swift @@ -6,6 +6,7 @@ // import Foundation + public class MockOperationQueue: OperationQueue { public var size = 0 diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/AWSPredictionsPluginTestBase.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/AWSPredictionsPluginTestBase.swift index 4b5945b080..9db64ede23 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/AWSPredictionsPluginTestBase.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/AWSPredictionsPluginTestBase.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest -@testable import AWSPredictionsPlugin import AWSCognitoAuthPlugin -@testable import Amplify import Foundation +import XCTest +@testable import Amplify +@testable import AWSPredictionsPlugin class AWSPredictionsPluginTestBase: XCTestCase { diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/ConvertBasicIntegrationTests.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/ConvertBasicIntegrationTests.swift index 62df5a4767..1cee1883bf 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/ConvertBasicIntegrationTests.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/ConvertBasicIntegrationTests.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // +import AVFoundation import XCTest @testable import Amplify @testable import AWSPredictionsPlugin -import AVFoundation import Combine @@ -26,7 +26,7 @@ class ConvertBasicIntegrationTests: AWSPredictionsPluginTestBase { .speechToText(url: url), options: options ) let responses = result.map(\.transcription) - + for try await response in responses { print("Response in test", response) } diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift index 3b8762e00d..132e92de45 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // +import Combine import Foundation import UIKit import XCTest -import Combine @testable import Amplify @testable import AWSPredictionsPlugin @testable import AWSRekognition diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginIntegrationTest.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginIntegrationTest.swift index ff1f8d1a55..657253f279 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginIntegrationTest.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginIntegrationTest.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify -import XCTest import AVFoundation +import XCTest +import XCTest class CoreMLPredictionsPluginIntegrationTest: AWSPredictionsPluginTestBase { diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginTestBase.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginTestBase.swift index 9bb62218a7..bd98936ef4 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginTestBase.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/CoreMLPredictionsPluginIntegrationTests/CoreMLPredictionsPluginTestBase.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // +import CoreMLPredictionsPlugin import XCTest @testable import Amplify -import CoreMLPredictionsPlugin class AWSPredictionsPluginTestBase: XCTestCase { let region: JSONValue = "us-east-1" diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/ContentView.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/ContentView.swift index f5b0b64765..4790e0408d 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/ContentView.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/ContentView.swift @@ -1,12 +1,12 @@ // -// ContentView.swift -// PredictionsHostApp +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. // -// Created by Saultz, Ian on 11/3/22. +// SPDX-License-Identifier: Apache-2.0 // -import SwiftUI import Amplify +import SwiftUI struct ContentView: View { var body: some View { diff --git a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/PredictionsHostAppApp.swift b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/PredictionsHostAppApp.swift index 9c22a1903d..516d99c273 100644 --- a/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/PredictionsHostAppApp.swift +++ b/AmplifyPlugins/Predictions/Tests/PredictionsHostApp/PredictionsHostApp/PredictionsHostAppApp.swift @@ -1,8 +1,8 @@ // -// PredictionsHostAppApp.swift -// PredictionsHostApp +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. // -// Created by Saultz, Ian on 11/3/22. +// SPDX-License-Identifier: Apache-2.0 // import SwiftUI