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
2 changes: 1 addition & 1 deletion Amplify/DevMenu/AmplifyDevMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UIKit
/// Presents a developer menu using the provided `DevMenuPresentationContextProvider`
/// upon notification from a `TriggerRecognizer`. Default recognizer is a `LongPressGestureRecognizer`
@MainActor
public final class AmplifyDevMenu: DevMenuBehavior, TriggerDelegate {
public final class AmplifyDevMenu: @preconcurrency DevMenuBehavior, @preconcurrency TriggerDelegate {

weak var devMenuPresentationContextProvider: DevMenuPresentationContextProvider?
var triggerRecognizer: TriggerRecognizer?
Expand Down
8 changes: 4 additions & 4 deletions Amplify/DevMenu/View/IssueReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ struct IssueReporter: View {
/// Open Amplify iOS issue logging screen on Github
private func reportToGithub() {
Task {
let issue = await IssueInfo(issueDescription: issueDescription,
let issue = IssueInfo(issueDescription: issueDescription,
includeEnvInfo: includeEnvInfo,
includeDeviceInfo: includeDeviceInfo)
let issueDescriptionMarkdown =
await IssueInfoHelper.generateMarkdownForIssue(
IssueInfoHelper.generateMarkdownForIssue(
issue: issue)

let urlString = amplifyIosNewIssueUrl + issueDescriptionMarkdown
Expand All @@ -122,10 +122,10 @@ struct IssueReporter: View {
/// Copy issue as a markdown string to clipboard
private func copyToClipboard() {
Task {
let issue = await IssueInfo(issueDescription: issueDescription,
let issue = IssueInfo(issueDescription: issueDescription,
includeEnvInfo: includeEnvInfo,
includeDeviceInfo: includeDeviceInfo)
let value = await IssueInfoHelper.generateMarkdownForIssue(issue: issue)
let value = IssueInfoHelper.generateMarkdownForIssue(issue: issue)
#if os(iOS)
UIPasteboard.general.string = value
#elseif canImport(AppKit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ fileprivate func toAPIError<R: Decodable>(_ errors: [Error], type: R.Type) -> AP
GraphQLResponseError<R>.error(errors)
)

case let errors as [WebSocketClient.Error]:
case _ as [WebSocketClient.Error]:
return APIError.networkError("WebSocketClient connection aborted", nil, URLError(.networkConnectionLost))
default:
return APIError.operationError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ final class APISwiftTests: XCTestCase {
func testCreateBlogMutation() {
let file = S3ObjectInput(bucket: "bucket", key: "let", region: "region")
let input = CreateBlogInput(name: "name", file: file)
let condition = ModelBlogConditionInput(name: .init(eq: "name"))
let mutation = CreateBlogMutation(input: input)

let request = GraphQLRequest<CreateBlogMutation.Data>(
document: CreateBlogMutation.requestString,
variables: mutation.variables?.jsonObject,
responseType: CreateBlogMutation.Data.self)

var expectedDocument = """
let expectedDocument = """
mutation CreateBlog($input: CreateBlogInput!, $condition: ModelBlogConditionInput) {
createBlog(input: $input, condition: $condition) {
__typename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ class AppSyncRealTimeClientTests: XCTestCase {

func testReconnect_whenHeartBeatSignalIsNotReceived() async throws {
var cancellables = Set<AnyCancellable>()
let timeout = 1.0
let mockWebSocketClient = MockWebSocketClient()
let mockAppSyncRequestInterceptor = MockAppSyncRequestInterceptor()
let appSyncClient = AppSyncRealTimeClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AuthTokenURLRequestInterceptorTests: XCTestCase {
do {
_ = try await interceptor.intercept(request).allHTTPHeaderFields
} catch {
guard case .operationError(let description, _, let underlyingError) = error as? APIError,
guard case .operationError(_, _, let underlyingError) = error as? APIError,
let authError = underlyingError as? AuthError,
case .sessionExpired = authError else {
XCTFail("Should be API.operationError with underlying AuthError.sessionExpired")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class GraphQLResponseDecoderPostComment4V2Tests: XCTestCase, SharedTestCasesPost
XCTAssertEqual(input["postID"] as? String, post.id)

let decoder = GraphQLResponseDecoder(request: request.toOperationRequest(operationType: .query))
var graphQLData: [String: JSONValue] = [
let graphQLData: [String: JSONValue] = [
"\(request.decodePath!)": [
"id": "id",
"content": "content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension CognitoUserPoolASF {
asfDeviceId: String,
asfClient: AdvancedSecurityBehavior,
userPoolConfiguration: UserPoolConfigurationData) async -> String? {
let deviceInfo: ASFDeviceBehavior = await ASFDeviceInfo(id: asfDeviceId)
let deviceInfo: ASFDeviceBehavior = ASFDeviceInfo(id: asfDeviceId)
let appInfo: ASFAppInfoBehavior = ASFAppInfo()

do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ public struct AWSAuthCognitoSession: AuthSession,
return .failure(AuthError.signedOut(
AuthPluginErrorConstants.userSubSignOutError.errorDescription,
AuthPluginErrorConstants.userSubSignOutError.recoverySuggestion))
} catch let error as AuthError {
return .failure(error)
} catch {
let error = AuthError.unknown("""
Could not retreive user sub from the fetched Cognito tokens.
""")
return .failure(error)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension AuthenticationError: Codable {
switch self {
case .configuration(let message):
try container.encode(message, forKey: .configuration)
case .service(let message, let error):
case .service(let message, _):
try container.encode(message, forKey: .service)
case .unknown(let message):
try container.encode(message, forKey: .unknown)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XCTest
class ASFDeviceInfoTests: XCTestCase {

func testdeviceInfo() async {
let asf = await ASFDeviceInfo(id: "mockID")
let asf = ASFDeviceInfo(id: "mockID")
let deviceFingerPrint = await asf.deviceInfo()
XCTAssertNotNil(deviceFingerPrint)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CognitoUserPoolASFTests: XCTestCase {
/// When: userContextData is invoked
/// Then: A non-empty string is returned
func testUserContextData_shouldReturnData() async throws {
let deviceInfo = await ASFDeviceInfo(id: "mockedDevice")
let deviceInfo = ASFDeviceInfo(id: "mockedDevice")
let result = try await userPool.userContextData(
for: "TestUser",
deviceInfo: deviceInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
do {
_ = try (session as? AuthCognitoTokensProvider)?.getCognitoTokens().get()
}
catch let error as AuthError {
catch {
guard case .invalidState = error else {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
Expand Down Expand Up @@ -585,7 +585,7 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
do {
_ = try (session as? AuthCognitoTokensProvider)?.getCognitoTokens().get()
}
catch let error as AuthError {
catch {
guard case .invalidState = error else {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
Expand Down Expand Up @@ -678,7 +678,7 @@ class AWSAuthFederationToIdentityPoolTests: BaseAuthorizationTests {
do {
_ = try (session as? AuthCognitoTokensProvider)?.getCognitoTokens().get()
}
catch let error as AuthError {
catch {
guard case .invalidState = error else {
XCTFail("Should throw Auth Error with invalid state \(error)")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeviceBehaviorFetchDevicesTests: BasePluginTest {
super.setUp()
mockIdentityProvider = MockIdentityProvider(
mockListDevicesOutput: { _ in
try ListDevicesOutput()
ListDevicesOutput()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeviceBehaviorRememberDeviceTests: BasePluginTest {
super.setUp()
mockIdentityProvider = MockIdentityProvider(
mockRememberDeviceResponse: { _ in
try UpdateDeviceStatusOutput()
UpdateDeviceStatusOutput()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension ChangePasswordOutput: Codable {

public init(from decoder: Decoder) throws {
let containerValues = try decoder.container(keyedBy: CodingKeys.self)
guard let httpResponse = try containerValues.decodeIfPresent(HTTPResponse.self, forKey: .httpResponse) else {
guard (try containerValues.decodeIfPresent(HTTPResponse.self, forKey: .httpResponse)) != nil else {
fatalError("Unable to decode http response")
}
self.init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension AuthSignInResult: Codable {
}
}

extension AuthSignInStep: Equatable {
extension AuthSignInStep {
public static func == (lhs: AuthSignInStep, rhs: AuthSignInStep) -> Bool {
switch (lhs, rhs) {
case (.confirmSignInWithSMSMFACode, .confirmSignInWithSMSMFACode),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ extension AuthState: Codable {
if type == "AuthState.Configured" {
let authenticationState = try values.decode(AuthenticationState.self, forKey: .authenticationState)
let authorizationState = try values.decode(AuthorizationState.self, forKey: .authorizationState)
let signUpState = try values.decode(SignUpState.self, forKey: .signUpState)
self = .configured(
authenticationState,
authorizationState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ struct CognitoAPIDecodingHelper {
switch responseType {
case "failure":
guard case .string(let errorType) = response["errorType"],
case .string(let errorMessage) = response["errorType"] else {
case .string(_) = response["errorType"] else {
fatalError()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct KeychainStoreMigrator {
try? KeychainStore(service: newAttributes.service, accessGroup: newAttributes.accessGroup)._removeAll()
}

var updateQuery = oldAttributes.defaultGetQuery()
let updateQuery = oldAttributes.defaultGetQuery()

var updateAttributes = [String: Any]()
updateAttributes[KeychainStore.Constants.AttributeService] = newAttributes.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ extension GraphQLRequest: ModelGraphQLRequestFactory {
includes: IncludedAssociations<M> = { _ in [] },
limit: Int? = nil,
authMode: AWSAuthorizationType? = nil) -> GraphQLRequest<List<M>> {
let primaryKeysOnly = (M.rootPath != nil) ? true : false
var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelSchema: modelType.schema,
operationType: .query)
documentBuilder.add(decorator: DirectiveNameDecorator(type: .list))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class LocalWebSocketServer {

func sendTransientFailureToConnections() {
self.connections.forEach {
var metadata = NWProtocolWebSocket.Metadata(opcode: .close)
let metadata = NWProtocolWebSocket.Metadata(opcode: .close)
metadata.closeCode = .protocolCode(NWProtocolWebSocket.CloseCode.Defined.internalServerError)
$0.send(
content: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
import Smithy
import SmithyIdentity

public class AmplifyAWSCredentialsProvider: AwsCommonRuntimeKit.CredentialsProviding {
public class AmplifyAWSCredentialsProvider: AwsCommonRuntimeKit.CredentialsProviding, @unchecked Sendable {

public func getCredentials() async throws -> AwsCommonRuntimeKit.Credentials {
let authSession = try await Amplify.Auth.fetchAuthSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ public class CascadeDeleteOperation<M: Model>: AsynchronousOperation, @unchecked
return queriedModels
}

private func collapseResults<M: Model>(
queryResult: DataStoreResult<[M]>?,
deleteResult: DataStoreResult<[M]>?,
private func collapseResults<Q: Model>(
queryResult: DataStoreResult<[Q]>?,
deleteResult: DataStoreResult<[Q]>?,
associatedModels: [(ModelName, Model)]
) -> DataStoreResult<QueryAndDeleteResult<M>> {
) -> DataStoreResult<QueryAndDeleteResult<Q>> {

guard let queryResult = queryResult else {
return .failure(.unknown("queryResult not set during transaction", "coding error", nil))
Expand Down Expand Up @@ -519,8 +519,8 @@ public class CascadeDeleteOperation<M: Model>: AsynchronousOperation, @unchecked
// MARK: - Supporting types
extension CascadeDeleteOperation {

struct QueryAndDeleteResult<M: Model> {
let deletedModels: [M]
struct QueryAndDeleteResult<Q: Model> {
let deletedModels: [Q]
let associatedModels: [(ModelName, Model)]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,12 @@ extension StorageEngine {
))
}

guard let apiGraphQL = api as? APICategoryGraphQLBehavior else {
log.info("Unable to find GraphQL API plugin for syncEngine. syncEngine will not be started")
return .failure(.configuration(
"Unable to find suitable GraphQL API plugin for syncEngine. syncEngine will not be started",
"Ensure the API category has been setup and configured for your project",
nil
))
}

let authPluginRequired = StorageEngine.requiresAuthPlugin(
api,
authModeStrategy: dataStoreConfiguration.authModeStrategyType
)
guard authPluginRequired else {
syncEngine.start(api: apiGraphQL, auth: nil)
syncEngine.start(api: api, auth: nil)
return .success(.successfullyInitialized)
}

Expand All @@ -52,7 +43,7 @@ extension StorageEngine {
))
}

syncEngine.start(api: apiGraphQL, auth: auth)
syncEngine.start(api: api, auth: auth)
}

return .success(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ final class InitialSyncOperation: AsynchronousOperation, @unchecked Sendable {
return
}

guard let api = api else {
guard api != nil else {
finish(result: .failure(DataStoreError.nilAPIHandle()))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,14 +967,6 @@ class SQLStatementTests: XCTestCase {
where 1 = 1
and "root"."@@postForeignKey" = ?
"""
let noJoin = """
select
"root"."@@primaryKey" as "@@primaryKey", "root"."id" as "id", "root"."content" as "content",
"root"."createdAt" as "createdAt", "root"."updatedAt" as "updatedAt", "root"."@@postForeignKey" as "@@postForeignKey"
from "CommentWithCompositeKey" as "root"
where 1 = 1
and "root"."@@postForeignKey" = ?
"""
XCTAssertEqual(statement.stringValue, expectedStatement)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest
import Combine

// Testable import b/c StateMachine is an internal type
@testable import AWSDataStorePlugin
@testable @preconcurrency import AWSDataStorePlugin

class StateMachineTests: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ final class StorageEngineTestsLazyPostComment4V2Tests: StorageEngineTestsBase, S
let comment2 = LazyChildComment4V2(id: "id2", content: "content", post: post2)
try await saveAsync(comment2)

var posts = try await queryAsync(LazyParentPost4V2.self)
let posts = try await queryAsync(LazyParentPost4V2.self)
XCTAssertEqual(posts.count, 2)
guard let postId1 = posts.first(where: { $0.id == "postId1" }) else {
XCTFail("Couldn't find post with `postId1`")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,8 @@ class InitialSyncOperationTests: XCTestCase {
syncMetadataSaved.fulfill()
}
}
wait(for: [syncMetadataSaved], timeout: 1.0)

await fulfillment(of: [syncMetadataSaved], timeout: 1.0)

let apiWasQueried = expectation(description: "API was queried for a PaginatedList of AnyModel")
let responder = QueryRequestResponder<PaginatedList<AnyModel>> { request in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Combine

@testable import Amplify
@testable import AmplifyTestCommon
@testable import AWSPluginsCore
@testable import AWSDataStorePlugin
@testable @preconcurrency import AWSPluginsCore
@testable @preconcurrency import AWSDataStorePlugin

class ModelSyncedEventEmitterTests: XCTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest
@testable import Amplify
@testable import AmplifyTestCommon
@testable import AWSPluginsCore
@testable import AWSDataStorePlugin
@testable @preconcurrency import AWSDataStorePlugin

final class IncomingAsyncSubscriptionEventPublisherTests: XCTestCase {
var apiPlugin: MockAPICategoryPlugin!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MockEndPointResolver: EndpointResolver {
}
}

class MockLogAgent: LogAgent {
class MockLogAgent: LogAgent, @unchecked Sendable {
func log(
level: Smithy.LogAgentLevel,
message: @autoclosure () -> String,
Expand Down
Loading
Loading