Skip to content

Commit

Permalink
chore(predictions): resolve swiftformat errors and warnings (#3851)
Browse files Browse the repository at this point in the history
* chore(predictions): resolve swiftformat errors and warnings

* updated swiftformat rules

* remove duplicate import statement
  • Loading branch information
phantumcode authored Oct 11, 2024
1 parent b10caf8 commit 6c28586
Show file tree
Hide file tree
Showing 97 changed files with 371 additions and 329 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

@_spi(InternalAmplifyConfiguration) import Amplify
import Foundation
import AWSPluginsCore
import Foundation

extension AWSPredictionsPlugin {
/// Configures AWSPredictionsPlugin with the specified configuration.
Expand Down Expand Up @@ -68,7 +68,7 @@ extension AWSPredictionsPlugin {
config: PredictionsPluginConfiguration
) {
self.predictionsService = predictionsService
self.coreMLService = coreMLSerivce
coreMLService = coreMLSerivce
self.authService = authService
self.config = config
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Input, Options, Output>(
_ request: Predictions.Convert.Request<Input, Options, Output>,
public func convert<Options, Output>(
_ request: Predictions.Convert.Request<some Any, Options, Output>,
options: Options?
) async throws -> Output {
switch request.kind {
Expand Down Expand Up @@ -102,7 +102,7 @@ extension AWSPredictionsPlugin {
voice: Predictions.Voice?,
config: PredictionsPluginConfiguration
) -> PollyClientTypes.VoiceId {
if let voice = voice,
if let voice,
let pollyVoiceID = PollyClientTypes.VoiceId(rawValue: voice.id) {
return pollyVoiceID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Output>(
public extension AWSPredictionsPlugin {
func identify<Output>(
_ request: Predictions.Identify.Request<Output>,
in image: URL,
options: Predictions.Identify.Options?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -95,7 +95,7 @@ class AWSTranscribeStreamingAdapter: AWSTranscribeStreamingBehavior {
var currentEnd = min(chunkSize, audioDataSize - currentStart)

while currentStart < audioDataSize {
let dataChunk = input.audioStream[currentStart..<currentEnd]
let dataChunk = input.audioStream[currentStart ..< currentEnd]
let encodedChunk = EventStream.Encoder().encode(payload: dataChunk, headers: headers)

webSocket.send(message: .data(encodedChunk), onError: { _ in })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// SPDX-License-Identifier: Apache-2.0
//

import Foundation
import Amplify
import AWSTranscribeStreaming
import Foundation

protocol AWSTranscribeStreamingBehavior {
func startStreamTranscription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import Foundation

extension Date {
var epochMilliseconds: UInt64 {
UInt64(self.timeIntervalSince1970 * 1_000)
UInt64(timeIntervalSince1970 * 1_000)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public struct FinalClientEvent {
let videoEndTimeStamp: UInt64
}

extension LivenessEvent where T == FinalClientEvent {
public extension LivenessEvent where T == FinalClientEvent {
@_spi(PredictionsFaceLiveness)
public static func final(event: FinalClientEvent) throws -> Self {
static func final(event: FinalClientEvent) throws -> Self {

let clientEvent = ClientSessionInformationEvent(
challenge: .init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +71,7 @@ func colorChallenge(from event: ServerSessionInformationEvent) -> FaceLivenessSe
duration: duration,
shouldScroll: shouldScroll
)
})
}
return .init(
colors: displayColors
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -45,9 +45,9 @@ extension AWSPredictionsPlugin {
}
}

extension FaceLivenessSession {
public extension FaceLivenessSession {
@_spi(PredictionsFaceLiveness)
public struct Options {
struct Options {
public init() {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 6c28586

Please sign in to comment.