Skip to content

Commit

Permalink
chore: resolve SwiftLint errors and warnings (#3451)
Browse files Browse the repository at this point in the history
* chore: resolve swiftlint errors and warnings in amplify categories and amplify core (#3440)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings for Amplify API plugin (#3441)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings for Amplify Auth plugin (#3442)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings for Amplify Datastore plugin (#3443)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings in Amplify Storage plugin (#3444)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings for Analytics plugin (#3445)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings for Amplify Push Notifications plugin (#3446)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings for Amplify Predictions plugin (#3447)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings for Amplify Logging plugin (#3448)

* chore: resolve swiftlint errors

* chore: resolve swiftlint warnings

* chore: resolve swiftlint warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve swiftlint errors and warnings

* chore: resolve merge conflicts
  • Loading branch information
phantumcode authored Jan 4, 2024
1 parent 2b47321 commit 659e861
Show file tree
Hide file tree
Showing 332 changed files with 1,143 additions and 1,081 deletions.
4 changes: 2 additions & 2 deletions Amplify/Categories/API/APICategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final public class APICategory: Category {
public var categoryType: CategoryType {
.api
}

var plugins = [PluginKey: APICategoryPlugin]()

/// Returns the plugin added to the category, if only one plugin is added. Accessing this property if no plugins
Expand Down Expand Up @@ -49,7 +49,7 @@ final public class APICategory: Category {
public var isConfigured = false

// MARK: - Plugin handling

/// Adds `plugin` to the list of Plugins that implement functionality for this category.
///
/// - Parameter plugin: The Plugin to add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
//

extension APICategory: APICategoryGraphQLBehavior {

// MARK: - Request-based GraphQL operations
public func query<R: Decodable>(request: GraphQLRequest<R>) async throws -> GraphQLTask<R>.Success {
try await plugin.query(request: request)
}

public func mutate<R: Decodable>(request: GraphQLRequest<R>) async throws -> GraphQLTask<R>.Success {
try await plugin.mutate(request: request)
}

public func subscribe<R>(request: GraphQLRequest<R>) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>> {
plugin.subscribe(request: request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

extension APICategory: APICategoryRESTBehavior {

public func get(request: RESTRequest) async throws -> RESTTask.Success {
try await plugin.get(request: request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public protocol APICategoryGraphQLBehavior: AnyObject {
/// - listener: The event listener for the operation
/// - Returns: The AmplifyOperation being enqueued
func query<R: Decodable>(request: GraphQLRequest<R>) async throws -> GraphQLTask<R>.Success

/// Perform a GraphQL mutate operation against a previously configured API. This operation
/// will be asynchronous, with the callback accessible both locally and via the Hub.
///
Expand All @@ -36,5 +36,7 @@ public protocol APICategoryGraphQLBehavior: AnyObject {
/// - valueListener: Invoked when the GraphQL subscription receives a new value from the service
/// - completionListener: Invoked when the subscription has terminated
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
func subscribe<R: Decodable>(request: GraphQLRequest<R>) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>
func subscribe<R: Decodable>(
request: GraphQLRequest<R>
) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public protocol APICategoryRESTBehavior {
/// - Parameter request: Contains information such as path, query parameters, body.
/// - Returns: An operation that can be observed for its value
func post(request: RESTRequest) async throws -> RESTTask.Success

/// Perform an HTTP DELETE operation
///
/// - Parameter request: Contains information such as path, query parameters, body.
/// - Returns: An operation that can be observed for its value
func delete(request: RESTRequest) async throws -> RESTTask.Success

/// Perform an HTTP HEAD operation
///
/// - Parameter request: Contains information such as path, query parameters, body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public final class RetryableGraphQLOperation<Payload: Decodable>: Operation, Ret
self.operationFactory = operationFactory
self.resultListener = resultListener
}

public override func main() {
Task {
start(request: await requestFactory())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension AnalyticsCategory {
public func unregisterGlobalProperties(_ keys: String...) {
plugin.unregisterGlobalProperties(keys.isEmpty ? nil : Set<String>(keys))
}

/// Registered global properties can be unregistered though this method. In case no keys are provided, *all*
/// registered global properties will be unregistered. Duplicate keys will be ignored. This method can be called
/// from `Amplify.Analytics` and is a wrapper for `unregisterGlobalProperties(_ keys: Set<String>? = nil)`
Expand Down
32 changes: 25 additions & 7 deletions Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import Foundation

extension AuthCategory: AuthCategoryBehavior {

public func signUp( username: String, password: String? = nil, options: AuthSignUpRequest.Options? = nil) async throws -> AuthSignUpResult {
public func signUp(
username: String,
password: String? = nil,
options: AuthSignUpRequest.Options? = nil
) async throws -> AuthSignUpResult {
return try await plugin.signUp(username: username, password: password, options: options)
}

Expand All @@ -19,7 +23,10 @@ extension AuthCategory: AuthCategoryBehavior {
return try await plugin.confirmSignUp(for: username, confirmationCode: confirmationCode, options: options)
}

public func resendSignUpCode(for username: String, options: AuthResendSignUpCodeRequest.Options? = nil) async throws -> AuthCodeDeliveryDetails {
public func resendSignUpCode(
for username: String,
options: AuthResendSignUpCodeRequest.Options? = nil
) async throws -> AuthCodeDeliveryDetails {
return try await plugin.resendSignUpCode(for: username, options: options)
}

Expand All @@ -46,14 +53,17 @@ extension AuthCategory: AuthCategoryBehavior {
}
#endif

public func confirmSignIn(challengeResponse: String, options: AuthConfirmSignInRequest.Options? = nil) async throws -> AuthSignInResult {
public func confirmSignIn(
challengeResponse: String,
options: AuthConfirmSignInRequest.Options? = nil
) async throws -> AuthSignInResult {
return try await plugin.confirmSignIn(challengeResponse: challengeResponse, options: options)
}

public func signOut(options: AuthSignOutRequest.Options? = nil) async -> AuthSignOutResult {
return await plugin.signOut(options: options)
}

public func deleteUser() async throws {
try await plugin.deleteUser()
}
Expand All @@ -62,8 +72,11 @@ extension AuthCategory: AuthCategoryBehavior {
return try await plugin.fetchAuthSession(options: options)
}

public func resetPassword(for username: String, options: AuthResetPasswordRequest.Options? = nil) async throws -> AuthResetPasswordResult {
return try await plugin.resetPassword(for: username,options: options)
public func resetPassword(
for username: String,
options: AuthResetPasswordRequest.Options? = nil
) async throws -> AuthResetPasswordResult {
return try await plugin.resetPassword(for: username, options: options)
}

public func confirmResetPassword(
Expand All @@ -72,7 +85,12 @@ extension AuthCategory: AuthCategoryBehavior {
confirmationCode: String,
options: AuthConfirmResetPasswordRequest.Options? = nil
) async throws {
try await plugin.confirmResetPassword(for: username, with: newPassword, confirmationCode: confirmationCode, options: options)
try await plugin.confirmResetPassword(
for: username,
with: newPassword,
confirmationCode: confirmationCode,
options: options
)
}

public func setUpTOTP() async throws -> TOTPSetupDetails {
Expand Down
9 changes: 7 additions & 2 deletions Amplify/Categories/Auth/AuthCategory+DeviceBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import Foundation

extension AuthCategory: AuthCategoryDeviceBehavior {

public func fetchDevices( options: AuthFetchDevicesRequest.Options? = nil) async throws -> [AuthDevice] {
public func fetchDevices(
options: AuthFetchDevicesRequest.Options? = nil
) async throws -> [AuthDevice] {
return try await plugin.fetchDevices(options: options)
}

public func forgetDevice( _ device: AuthDevice? = nil, options: AuthForgetDeviceRequest.Options? = nil) async throws {
public func forgetDevice(
_ device: AuthDevice? = nil,
options: AuthForgetDeviceRequest.Options? = nil
) async throws {
try await plugin.forgetDevice(device, options: options)
}

Expand Down
21 changes: 17 additions & 4 deletions Amplify/Categories/Auth/AuthCategory+UserBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ extension AuthCategory: AuthCategoryUserBehavior {
try await plugin.getCurrentUser()
}

public func fetchUserAttributes(options: AuthFetchUserAttributesRequest.Options? = nil) async throws -> [AuthUserAttribute] {
public func fetchUserAttributes(
options: AuthFetchUserAttributesRequest.Options? = nil
) async throws -> [AuthUserAttribute] {
try await plugin.fetchUserAttributes(options: options)
}

public func update(userAttribute: AuthUserAttribute, options: AuthUpdateUserAttributeRequest.Options? = nil) async throws -> AuthUpdateAttributeResult {
public func update(
userAttribute: AuthUserAttribute,
options: AuthUpdateUserAttributeRequest.Options? = nil
) async throws -> AuthUpdateAttributeResult {
try await plugin.update(userAttribute: userAttribute, options: options)
}

Expand Down Expand Up @@ -45,10 +50,18 @@ extension AuthCategory: AuthCategoryUserBehavior {
public func confirm(userAttribute: AuthUserAttributeKey,
confirmationCode: String,
options: AuthConfirmUserAttributeRequest.Options? = nil) async throws {
try await plugin.confirm(userAttribute: userAttribute, confirmationCode: confirmationCode, options: options)
try await plugin.confirm(
userAttribute: userAttribute,
confirmationCode: confirmationCode,
options: options
)
}

public func update(oldPassword: String, to newPassword: String, options: AuthChangePasswordRequest.Options? = nil) async throws {
public func update(
oldPassword: String,
to newPassword: String,
options: AuthChangePasswordRequest.Options? = nil
) async throws {
try await plugin.update(oldPassword: oldPassword, to: newPassword, options: options)
}

Expand Down
29 changes: 23 additions & 6 deletions Amplify/Categories/Auth/AuthCategoryBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - username: username to signUp
/// - password: password as per the password policy of the provider
/// - options: Parameters specific to plugin behavior
func signUp(username: String, password: String?, options: AuthSignUpRequest.Options?) async throws -> AuthSignUpResult
func signUp(
username: String,
password: String?,
options: AuthSignUpRequest.Options?
) async throws -> AuthSignUpResult

/// Confirms the `signUp` operation.
///
Expand All @@ -44,7 +48,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - Parameters:
/// - username: Username of the user to be confirmed.
/// - options: Parameters specific to plugin behavior.
func resendSignUpCode(for username: String, options: AuthResendSignUpCodeRequest.Options?) async throws -> AuthCodeDeliveryDetails
func resendSignUpCode(
for username: String,
options: AuthResendSignUpCodeRequest.Options?
) async throws -> AuthCodeDeliveryDetails

/// SignIn to the authentication provider
///
Expand Down Expand Up @@ -90,7 +97,10 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - Parameters:
/// - challengeResponse: Challenge response required to confirm the next step in signIn flow
/// - options: Parameters specific to plugin behavior.
func confirmSignIn(challengeResponse: String, options: AuthConfirmSignInRequest.Options?) async throws -> AuthSignInResult
func confirmSignIn(
challengeResponse: String,
options: AuthConfirmSignInRequest.Options?
) async throws -> AuthSignInResult

/// Sign out the currently logged-in user.
///
Expand Down Expand Up @@ -122,20 +132,27 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
/// - newPassword: new password for the user
/// - confirmationCode: Received confirmation code
/// - options: Parameters specific to plugin behavior
func confirmResetPassword(for username: String, with newPassword: String, confirmationCode: String, options: AuthConfirmResetPasswordRequest.Options?) async throws
func confirmResetPassword(
for username: String,
with newPassword: String,
confirmationCode: String,
options: AuthConfirmResetPasswordRequest.Options?
) async throws

/// Initiates TOTP Setup
///
/// Invoke this operation to setup TOTP for the user while signed in.
/// Calling this method will initiate TOTP setup process and returns a shared secret that can be used to generate QR code.
/// Calling this method will initiate TOTP setup process and
/// returns a shared secret that can be used to generate QR code.
/// The setup details also contains a URI generator helper that can be used to retireve a TOTP Setup URI.
///
func setUpTOTP() async throws -> TOTPSetupDetails

/// Verifies TOTP Setup
///
/// Invoke this operation to verify TOTP setup for the user while signed in.
/// Calling this method with the verification code from the associated Authenticator app will complete the TOTP setup process.
/// Calling this method with the verification code from the associated Authenticator app
/// will complete the TOTP setup process.
///
/// - Parameters:
/// - code: verification code from the associated Authenticator app
Expand Down
27 changes: 21 additions & 6 deletions Amplify/Categories/Auth/AuthCategoryUserBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,29 @@ public protocol AuthCategoryUserBehavior: AnyObject {
///
/// - Parameters:
/// - options: Parameters specific to plugin behavior
func fetchUserAttributes(options: AuthFetchUserAttributesRequest.Options?) async throws -> [AuthUserAttribute]
func fetchUserAttributes(
options: AuthFetchUserAttributesRequest.Options?
) async throws -> [AuthUserAttribute]

/// Update user attribute for the current user
///
/// - Parameters:
/// - userAttribute: Attribute that need to be updated
/// - options: Parameters specific to plugin behavior
func update(userAttribute: AuthUserAttribute, options: AuthUpdateUserAttributeRequest.Options?) async throws -> AuthUpdateAttributeResult
func update(
userAttribute: AuthUserAttribute,
options: AuthUpdateUserAttributeRequest.Options?
) async throws -> AuthUpdateAttributeResult

/// Update a list of user attributes for the current user
///
/// - Parameters:
/// - userAttributes: List of attribtues that need ot be updated
/// - options: Parameters specific to plugin behavior
func update(userAttributes: [AuthUserAttribute],
options: AuthUpdateUserAttributesRequest.Options?) async throws -> [AuthUserAttributeKey: AuthUpdateAttributeResult]
func update(
userAttributes: [AuthUserAttribute],
options: AuthUpdateUserAttributesRequest.Options?
) async throws -> [AuthUserAttributeKey: AuthUpdateAttributeResult]

/// Resends the confirmation code required to verify an attribute
///
Expand Down Expand Up @@ -61,7 +68,11 @@ public protocol AuthCategoryUserBehavior: AnyObject {
/// - userAttribute: Attribute to verify
/// - confirmationCode: Confirmation code received
/// - options: Parameters specific to plugin behavior
func confirm(userAttribute: AuthUserAttributeKey, confirmationCode: String, options: AuthConfirmUserAttributeRequest.Options?) async throws
func confirm(
userAttribute: AuthUserAttributeKey,
confirmationCode: String,
options: AuthConfirmUserAttributeRequest.Options?
) async throws

/// Update the current logged in user's password
///
Expand All @@ -70,5 +81,9 @@ public protocol AuthCategoryUserBehavior: AnyObject {
/// - oldPassword: Current password of the user
/// - newPassword: New password to be updated
/// - options: Parameters specific to plugin behavior
func update(oldPassword: String, to newPassword: String, options: AuthChangePasswordRequest.Options?) async throws
func update(
oldPassword: String,
to newPassword: String,
options: AuthChangePasswordRequest.Options?
) async throws
}
Loading

0 comments on commit 659e861

Please sign in to comment.