Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public extension DefaultModelIdentifier {
// MARK: - Persistable + stringValue
private extension Persistable {
var stringValue: String {
var value: String = switch self {
let value: String = switch self {
case let self as Temporal.Date:
self.iso8601String

Expand Down
37 changes: 20 additions & 17 deletions Amplify/Core/Support/ChildTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,28 @@ actor ChildTask<InProcess, Success, Failure: Error>: BufferingSequence {

var value: Success {
get async throws {
try await withTaskCancellationHandler(handler: {
Task {
await cancel()
}
}, operation: {
try await withCheckedThrowingContinuation { continuation in
if isCancelled {
// immediately cancel is already cancelled
continuation.resume(throwing: CancellationError())
} else if let result = storedResult {
// immediately send result if it is available
valueContinuations.append(continuation)
send(result)
} else {
// capture contination to use later
valueContinuations.append(continuation)
try await withTaskCancellationHandler(
operation: {
try await withCheckedThrowingContinuation { continuation in
if isCancelled {
// immediately cancel is already cancelled
continuation.resume(throwing: CancellationError())
} else if let result = storedResult {
// immediately send result if it is available
valueContinuations.append(continuation)
send(result)
} else {
// capture contination to use later
valueContinuations.append(continuation)
}
}
},
onCancel: {
Task {
await cancel()
}
}
})
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Amplify/DevMenu/Trigger/LongPressGestureRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import UIKit

/// A class for recognizing long press gesture which notifies a `TriggerDelegate` of the event
class LongPressGestureRecognizer: NSObject, @preconcurrency TriggerRecognizer, UIGestureRecognizerDelegate {
class LongPressGestureRecognizer: NSObject, TriggerRecognizer, UIGestureRecognizerDelegate {

weak var triggerDelegate: TriggerDelegate?
weak var uiWindow: UIWindow?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
try await appSyncClient.sendRequest(.connectionInit, timeout: timeout)
finishExpectation.fulfill()
} catch {
XCTFail("Operation shouldn't fail with error \(error)")

Check failure on line 56 in AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

View workflow job for this annotation

GitHub Actions / AWSAPIPlugin Unit Tests / visionOS Tests | AWSAPIPlugin / visionOS Tests | AWSAPIPlugin

testSendRequestWithTimeout_withCorrectResponse_succeed, failed - Operation shouldn't fail with error timeout

Check failure on line 56 in AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

View workflow job for this annotation

GitHub Actions / AWSAPIPlugin Unit Tests / watchOS Tests | AWSAPIPlugin / watchOS Tests | AWSAPIPlugin

testSendRequestWithTimeout_withCorrectResponse_succeed, failed - Operation shouldn't fail with error timeout
}
}
Task {
try await Task.sleep(nanoseconds: 80 * 1_000)
await appSyncClient.subject.send(.success(.init(id: nil, payload: nil, type: .connectionAck)))
appSyncClient.subject.send(.success(.init(id: nil, payload: nil, type: .connectionAck)))
}
await fulfillment(of: [finishExpectation], timeout: timeout + 1)

Check failure on line 63 in AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

View workflow job for this annotation

GitHub Actions / AWSAPIPlugin Unit Tests / watchOS Tests | AWSAPIPlugin / watchOS Tests | AWSAPIPlugin

testSendRequestWithTimeout_withCorrectResponse_succeed, Asynchronous wait failed: Exceeded timeout of 2 seconds, with unfulfilled expectations: "Request finished successfully".
}

func testSendRequestWithTimeout_withErrorResponse_transformLimitExceededError() async {
Expand Down Expand Up @@ -90,7 +90,7 @@
}
Task {
try await Task.sleep(nanoseconds: 80 * 1_000)
await appSyncClient.subject.send(.success(.init(
appSyncClient.subject.send(.success(.init(
id: id,
payload: .object([
"errors": .array([
Expand Down Expand Up @@ -126,14 +126,14 @@
XCTFail("Operation should be failed")
} catch {
let requestError = error as! AppSyncRealTimeRequest.Error
XCTAssertEqual(requestError, .maxSubscriptionsReached)

Check failure on line 129 in AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

View workflow job for this annotation

GitHub Actions / AWSAPIPlugin Unit Tests / visionOS Tests | AWSAPIPlugin / visionOS Tests | AWSAPIPlugin

testSendRequestWithTimeout_withErrorResponse_transformMaxSubscriptionsReachedError, XCTAssertEqual failed: ("timeout") is not equal to ("maxSubscriptionsReached")

Check failure on line 129 in AmplifyPlugins/API/Tests/AWSAPIPluginTests/AppSyncRealTimeClient/AppSyncRealTimeClientTests.swift

View workflow job for this annotation

GitHub Actions / AWSAPIPlugin Unit Tests / visionOS Tests | AWSAPIPlugin / visionOS Tests | AWSAPIPlugin

testSendRequestWithTimeout_withErrorResponse_transformMaxSubscriptionsReachedError, XCTAssertEqual failed: ("timeout") is not equal to ("maxSubscriptionsReached")
maxSubscriptionsReachedExpectation.fulfill()
}
}

Task {
try await Task.sleep(nanoseconds: 80 * 1_000)
await appSyncClient.subject.send(.success(.init(
appSyncClient.subject.send(.success(.init(
id: id,
payload: .object([
"errors": .array([
Expand Down Expand Up @@ -180,7 +180,7 @@

Task {
try await Task.sleep(nanoseconds: 80 * 1_000)
await appSyncClient.subject.send(.success(.init(
appSyncClient.subject.send(.success(.init(
id: id,
payload: .object([
"errors": .array([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ extension AWSCognitoAuthPlugin {
return nil
}

var headers = urlRequest.allHTTPHeaderFields ?? [:]
let headers = urlRequest.allHTTPHeaderFields ?? [:]
let httpMethod = (urlRequest.httpMethod?.uppercased())
.flatMap(HTTPMethodType.init(rawValue:)) ?? .get

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct InitializeAuthorizationConfiguration: Action {
) async {
// ATM this is a no-op action
logVerbose("\(#fileID) Starting execution", environment: environment)
var event = switch storedCredentials {
let event = switch storedCredentials {
case .noCredentials:
AuthorizationEvent(eventType: .configure)
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct InformSessionError: Action {
func execute(withDispatcher dispatcher: EventDispatcher, environment: Environment) async {

logVerbose("\(#fileID) Starting execution", environment: environment)
var event: AuthorizationEvent = switch error {
let event: AuthorizationEvent = switch error {
case .service(let serviceError):
if isNotAuthorizedError(serviceError) {
.init(eventType: .throwError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum AuthChallengeType {

}

extension CognitoIdentityProviderClientTypes.ChallengeNameType: Codable {
extension CognitoIdentityProviderClientTypes.ChallengeNameType: @retroactive Decodable, @retroactive Encodable {
var authChallengeType: AuthChallengeType {
switch self {
case .customChallenge:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FetchAuthSessionOperationHelper {
) async throws -> AuthSession {

if forceRefresh || !credentials.areValid() {
var event = switch credentials {
let event = switch credentials {
case .identityPoolWithFederation(let federatedToken, let identityId, _):
AuthorizationEvent(eventType: .startFederationToIdentityPool(federatedToken, identityId))
case .noCredentials:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ extension AuthError: AuthErrorConvertible {
return self
}
}

extension AuthError: @unchecked Sendable { }
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AWSAuthAttributeResendConfirmationCodeTask: AuthAttributeResendConfirmatio

func initiateGettingVerificationCode(with accessToken: String) async throws -> AuthCodeDeliveryDetails {
let userPoolService = try userPoolFactory()
let clientMetaData = (request.options.pluginOptions as? AWSAttributeResendConfirmationCodeOptions)?.metadata ?? [:]
let clientMetaData = (request.options.pluginOptions as? AWSSendUserAttributeVerificationCodeOptions)?.metadata ?? [:]

let input = GetUserAttributeVerificationCodeInput(
accessToken: accessToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,6 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
}
} catch {
XCTFail("Should throw Auth Error \(error)")
}

} catch {
Expand Down Expand Up @@ -633,8 +631,6 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
}
} catch {
XCTFail("Should throw Auth Error \(error)")
}
} catch {
XCTFail("Received failure with error \(error)")
Expand Down Expand Up @@ -730,8 +726,6 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
}
} catch {
XCTFail("Should throw Auth Error \(error)")
}
} catch {
XCTFail("Received failure with error \(error)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentityProvider
import ClientRuntime

// Already conforms to encodable
extension ChangePasswordInput: Decodable {
extension ChangePasswordInput: @retroactive Decodable {

enum CodingKeys: String, CodingKey {
case accessToken = "AccessToken"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import ClientRuntime

extension ConfirmDeviceInput: Decodable {
extension ConfirmDeviceInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case accessToken
case deviceKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension DeleteUserInput: Decodable {
extension DeleteUserInput: @retroactive Decodable {

public init(from decoder: Decoder) throws {
self.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension ForgotPasswordInput: Decodable {
extension ForgotPasswordInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case username
case clientId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import ClientRuntime

extension GetCredentialsForIdentityInput: Decodable {
extension GetCredentialsForIdentityInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case logins
case identityId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import ClientRuntime

extension GetIdInput: Decodable {
extension GetIdInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case logins
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension GlobalSignOutInput: Decodable {
extension GlobalSignOutInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case accessToken
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentity
import AWSCognitoIdentityProvider
import ClientRuntime

extension InitiateAuthInput: Decodable {
extension InitiateAuthInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case authFlow
case authParameters
Expand All @@ -32,4 +32,4 @@ extension InitiateAuthInput: Decodable {
}
}

extension CognitoIdentityProviderClientTypes.AuthFlowType: Decodable { }
extension CognitoIdentityProviderClientTypes.AuthFlowType: @retroactive Decodable { }
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension RespondToAuthChallengeInput: Decodable {
extension RespondToAuthChallengeInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {

case clientId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension RevokeTokenInput: Decodable {
extension RevokeTokenInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case token
case clientId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension SignUpInput: Decodable {
extension SignUpInput: @retroactive Decodable {
enum CodingKeys: String, CodingKey {
case username
case password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import SmithyHTTPAPI

extension ChangePasswordOutput: Codable {
extension ChangePasswordOutput: @retroactive Decodable, @retroactive Encodable {

enum CodingKeys: String, CodingKey {
case httpResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension ConfirmDeviceOutput: Codable {
extension ConfirmDeviceOutput: @retroactive Decodable, @retroactive Encodable {

enum CodingKeys: Swift.String, Swift.CodingKey {
case userConfirmationNecessary = "UserConfirmationNecessary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension DeleteUserOutput: Codable {
extension DeleteUserOutput: @retroactive Decodable, @retroactive Encodable {

public init(from decoder: Swift.Decoder) throws {
self.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension ForgotPasswordOutput: Codable {
extension ForgotPasswordOutput: @retroactive Decodable, @retroactive Encodable {

enum CodingKeys: Swift.String, Swift.CodingKey {
case codeDeliveryDetails = "CodeDeliveryDetails"
Expand All @@ -30,7 +30,7 @@ extension ForgotPasswordOutput: Codable {

}

extension CognitoIdentityProviderClientTypes.CodeDeliveryDetailsType: Decodable {
extension CognitoIdentityProviderClientTypes.CodeDeliveryDetailsType: @retroactive Decodable {
private enum CodingKeys: String, CodingKey {
case attributeName = "AttributeName"
case deliveryMedium = "DeliveryMedium"
Expand All @@ -50,4 +50,4 @@ extension CognitoIdentityProviderClientTypes.CodeDeliveryDetailsType: Decodable
}
}

extension CognitoIdentityProviderClientTypes.DeliveryMediumType: Decodable {}
extension CognitoIdentityProviderClientTypes.DeliveryMediumType: @retroactive Decodable {}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AWSCognitoIdentity
import ClientRuntime
import Foundation

extension GetCredentialsForIdentityOutput: Codable {
extension GetCredentialsForIdentityOutput: @retroactive Decodable, @retroactive Encodable {
enum CodingKeys: Swift.String, Swift.CodingKey {
case credentials = "Credentials"
case identityId = "IdentityId"
Expand All @@ -29,7 +29,7 @@ extension GetCredentialsForIdentityOutput: Codable {
}
}

extension CognitoIdentityClientTypes.Credentials: Decodable {
extension CognitoIdentityClientTypes.Credentials: @retroactive Decodable {
private enum CodingKeys: String, CodingKey {
case accessKeyId = "AccessKeyId"
case expiration = "Expiration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentity
import ClientRuntime

extension GetIdOutput: Codable {
extension GetIdOutput: @retroactive Decodable, @retroactive Encodable {
enum CodingKeys: Swift.String, Swift.CodingKey {
case identityId = "IdentityId"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import ClientRuntime

extension GlobalSignOutOutput: Codable {
extension GlobalSignOutOutput: @retroactive Decodable, @retroactive Encodable {

public init(from decoder: Swift.Decoder) throws {
self.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import AWSCognitoIdentityProvider
import SmithyHTTPAPI

extension SmithyHTTPAPI.HTTPResponse: Codable { }
extension SmithyHTTPAPI.HTTPResponse: @retroactive Decodable, @retroactive Encodable { }

enum HTTPResponseCodingKeys: String, CodingKey {
case statusCode
Expand Down
Loading
Loading