diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift index 68e6806e92..5f7fab56df 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/AWSPredictionsPlugin+Convert.swift @@ -103,14 +103,12 @@ extension AWSPredictionsPlugin { config: PredictionsPluginConfiguration ) -> PollyClientTypes.VoiceId { if let voice, - let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: voice.id) - { + 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/Liveness/Service/FaceLivenessSession.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift index 5370950447..4c6a110496 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Liveness/Service/FaceLivenessSession.swift @@ -20,7 +20,8 @@ public final class FaceLivenessSession: LivenessService { private let livenessServiceDispatchQueue = DispatchQueue( label: "com.amazon.aws.amplify.liveness.service", - qos: .userInteractive) + qos: .userInteractive + ) init( websocket: WebSocketSession, diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift index ada6ad34e8..9fbecc7cbe 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Service/MultiService/InterpretTextMultiService.swift @@ -109,8 +109,7 @@ 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)) @@ -126,8 +125,7 @@ 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)) @@ -143,8 +141,7 @@ 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/Signing/SigV4Signer.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift index 97216a5227..0ce1f5a9d9 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Signing/SigV4Signer.swift @@ -178,7 +178,8 @@ struct SigV4Signer { hostHeader, uniquingKeysWith: { _, host in host - }) + } + ) let url = url.path.isEmpty ? url.appendingPathComponent("/") diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift index c09c67cecc..ff43f77b0f 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Internal/ErrorHandling/PluginErrorMessage.swift @@ -48,7 +48,8 @@ enum PluginErrorMessage { static let invalidRegion: PluginErrorString = ( "The region is invalid", - "Make sure the region is one of the AWS regions, like 'us-east-1', etc...") + "Make sure the region is one of the AWS regions, like 'us-east-1', etc..." + ) static let serviceConfigurationInitializationError: PluginErrorString = ( "Could not initialize service configuration", diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift index acc509be8d..5aa9118005 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers+Tables.swift @@ -57,8 +57,7 @@ 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) diff --git a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift index 99e746c1a2..667c13967c 100644 --- a/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift +++ b/AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift @@ -151,7 +151,7 @@ enum IdentifyTextResultTransformers { boundingBox: boundingBox, polygon: polygon, page: block.page ?? 0 - ) + ) } static func processSelectionElementBlock(block: TextractClientTypes.Block) -> Predictions.Selection? { diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift index 3fb1c61e19..a085cf9326 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/CoreMLPredictionsPlugin+Configure.swift @@ -17,16 +17,19 @@ extension CoreMLPredictionsPlugin { let recoverySuggestion = CoreMLPluginErrorString.decodeConfigurationError.recoverySuggestion throw PluginError.pluginConfigurationError(errorDescription, recoverySuggestion) } - configure(naturalLanguageBehavior: CoreMLNaturalLanguageAdapter(), - visionBehavior: CoreMLVisionAdapter(), - speechBehavior: CoreMLSpeechAdapter()) + configure( + naturalLanguageBehavior: CoreMLNaturalLanguageAdapter(), + visionBehavior: CoreMLVisionAdapter(), + speechBehavior: CoreMLSpeechAdapter() + ) } - func configure(naturalLanguageBehavior: CoreMLNaturalLanguageBehavior, - visionBehavior: CoreMLVisionBehavior, - speechBehavior: CoreMLSpeechBehavior, - queue: OperationQueue = OperationQueue()) - { + func configure( + naturalLanguageBehavior: CoreMLNaturalLanguageBehavior, + visionBehavior: CoreMLVisionBehavior, + speechBehavior: CoreMLSpeechBehavior, + queue: OperationQueue = OperationQueue() + ) { coreMLNaturalLanguage = naturalLanguageBehavior coreMLVision = visionBehavior coreMLSpeech = speechBehavior diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionAdapter.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionAdapter.swift index acd9d8a8eb..cc670bc591 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionAdapter.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Dependency/CoreMLVisionAdapter.swift @@ -80,11 +80,15 @@ class CoreMLVisionAdapter: CoreMLVisionBehavior { var entities: [Predictions.Entity] = [] for observation in observations { - let pose = Predictions.Pose(pitch: 0.0, // CoreML doesnot return pitch - roll: observation.roll?.doubleValue ?? 0.0, - yaw: observation.yaw?.doubleValue ?? 0.0) - let entityMetaData = Predictions.Entity.Metadata(confidence: Double(observation.confidence), - pose: pose) + let pose = Predictions.Pose( + pitch: 0.0, // CoreML doesnot return pitch + roll: observation.roll?.doubleValue ?? 0.0, + yaw: observation.yaw?.doubleValue ?? 0.0 + ) + let entityMetaData = Predictions.Entity.Metadata( + confidence: Double(observation.confidence), + pose: pose + ) let entity = Predictions.Entity( boundingBox: observation.boundingBox, landmarks: mapLandmarks(observation.landmarks), diff --git a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift index a229579494..9a22952f01 100644 --- a/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift +++ b/AmplifyPlugins/Predictions/CoreMLPredictionsPlugin/Support/Constants/CoreMLPluginErrorString.swift @@ -13,34 +13,42 @@ typealias PluginErrorString = (errorDescription: ErrorDescription, recoverySugge enum CoreMLPluginErrorString { static let decodeConfigurationError: PluginErrorString = ( "Unable to decode configuration", - "Make sure the plugin configuration is JSONValue") + "Make sure the plugin configuration is JSONValue" + ) static let configurationObjectExpected: PluginErrorString = ( "Configuration was not a dictionary literal", - "Make sure the value for the plugin is a dictionary literal with keys 'Bucket' and 'Region'") + "Make sure the value for the plugin is a dictionary literal with keys 'Bucket' and 'Region'" + ) static let operationNotSupported: PluginErrorString = ( "This operation is not supported.", - "Operation is not currently supported by offline mode.") + "Operation is not currently supported by offline mode." + ) static let detectTextNoResult: PluginErrorString = ( "Detect text return with no result", - "The input might not have enough data points to find text") + "The input might not have enough data points to find text" + ) static let detectLabelsNoResult: PluginErrorString = ( "Detect labels return with no result", - "The input might not have enough data points to find labels") + "The input might not have enough data points to find labels" + ) static let detectEntitiesNoResult: PluginErrorString = ( "Detect entities returned with no result", - "The input might not have enough data points to find entities") + "The input might not have enough data points to find entities" + ) static let transcriptionNoResult: PluginErrorString = ( "Speech to text returned with no result", - "The audio file may be corrupt or hard to understand.") + "The audio file may be corrupt or hard to understand." + ) static let requestObjectExpected: PluginErrorString = ( "The object sent over doesn't match the request object for this type of request", - "Make sure you are sending over the correct type for the data needed for this request.") + "Make sure you are sending over the correct type for the data needed for this request." + ) } diff --git a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift index 819c27c397..c429c675d2 100644 --- a/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift +++ b/AmplifyPlugins/Predictions/Tests/AWSPredictionsPluginUnitTests/ConfigurationTests/PredictionsPluginConfigurationTests.swift @@ -167,18 +167,26 @@ class PredictionsPluginConfigurationTests: XCTestCase { do { let configuration = try JSONDecoder().decode(PredictionsPluginConfiguration.self, from: inputJsonData) XCTAssertNotNil(configuration, "Configuration should not be nil") - XCTAssertEqual(configuration.defaultRegion, - "us-west-2", - "Default value should be equal to the input") - XCTAssertEqual(configuration.identify.region, - "us-west-2", - "Region value for identify should be equal to the input") - XCTAssertEqual(configuration.interpret.region, - "us-west-2", - "Region value for interpret should be equal to the input") - XCTAssertEqual(configuration.convert.region, - "us-west-2", - "Region value for convert should be equal to the input") + XCTAssertEqual( + configuration.defaultRegion, + "us-west-2", + "Default value should be equal to the input" + ) + XCTAssertEqual( + configuration.identify.region, + "us-west-2", + "Region value for identify should be equal to the input" + ) + XCTAssertEqual( + configuration.interpret.region, + "us-west-2", + "Region value for interpret should be equal to the input" + ) + XCTAssertEqual( + configuration.convert.region, + "us-west-2", + "Region value for convert should be equal to the input" + ) } catch { XCTFail("Decoding the json data should not produce any error \(error)") }