diff --git a/AmplifyTestApp/AppDelegate.swift b/AmplifyTestApp/AppDelegate.swift index 900a5a72a7..b5666b70b4 100644 --- a/AmplifyTestApp/AppDelegate.swift +++ b/AmplifyTestApp/AppDelegate.swift @@ -7,7 +7,7 @@ import UIKit -@UIApplicationMain +@main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? diff --git a/AmplifyTestCommon/Helpers/AmplifyAssertions.swift b/AmplifyTestCommon/Helpers/AmplifyAssertions.swift index 139e404fe9..2dc4abd66e 100644 --- a/AmplifyTestCommon/Helpers/AmplifyAssertions.swift +++ b/AmplifyTestCommon/Helpers/AmplifyAssertions.swift @@ -10,9 +10,11 @@ import XCTest @testable import CwlPreconditionTesting -public func XCTAssertThrowFatalError(_ expression: @escaping () -> Void, - file: StaticString = #file, - line: UInt = #line) throws { +public func XCTAssertThrowFatalError( + _ expression: @escaping () -> Void, + file: StaticString = #file, + line: UInt = #line +) throws { #if (os(iOS) || os(macOS)) && (arch(arm64) || arch(x86_64)) var reached = false let exception = catchBadInstruction { @@ -26,9 +28,11 @@ public func XCTAssertThrowFatalError(_ expression: @escaping () -> Void, #endif } -public func XCTAssertNoThrowFatalError(_ expression: @escaping () -> Void, - file: StaticString = #file, - line: UInt = #line) throws { +public func XCTAssertNoThrowFatalError( + _ expression: @escaping () -> Void, + file: StaticString = #file, + line: UInt = #line +) throws { #if (os(iOS) || os(macOS)) && (arch(arm64) || arch(x86_64)) var reached = false let exception = catchBadInstruction { diff --git a/AmplifyTestCommon/Helpers/AuthSignInHelper.swift b/AmplifyTestCommon/Helpers/AuthSignInHelper.swift index 98e6d9556a..d091aa412a 100644 --- a/AmplifyTestCommon/Helpers/AuthSignInHelper.swift +++ b/AmplifyTestCommon/Helpers/AuthSignInHelper.swift @@ -9,7 +9,7 @@ import Amplify public typealias CompletionType = (Bool, AuthError?) -> Void -public struct AuthSignInHelper { +public enum AuthSignInHelper { public static func signUpUser(username: String, password: String, email: String) async throws -> AuthSignUpResult { let options = AuthSignUpRequest.Options(userAttributes: [AuthUserAttribute(.email, value: email)]) diff --git a/AmplifyTestCommon/Helpers/HubListenerTestUtilities.swift b/AmplifyTestCommon/Helpers/HubListenerTestUtilities.swift index 60f0a4c311..31861451fc 100644 --- a/AmplifyTestCommon/Helpers/HubListenerTestUtilities.swift +++ b/AmplifyTestCommon/Helpers/HubListenerTestUtilities.swift @@ -8,7 +8,7 @@ import Amplify import Foundation -struct HubListenerTestUtilities { +enum HubListenerTestUtilities { /// Blocks current thread until the listener with `token` is attached to the plugin. Returns `true` if the listener /// becomes present before the `timeout` expires, `false` otherwise. @@ -17,11 +17,13 @@ struct HubListenerTestUtilities { /// - Parameter plugin: the plugin on which the listener will be checked /// - Parameter timeout: the maximum length of time to wait for the listener to be registered /// - Throws: if the plugin cannot be cast to `AWSHubPlugin` - static func waitForListener(with token: UnsubscribeToken, - plugin: HubCategoryPlugin? = nil, - timeout: TimeInterval, - file: StaticString = #file, - line: UInt = #line) async throws -> Bool { + static func waitForListener( + with token: UnsubscribeToken, + plugin: HubCategoryPlugin? = nil, + timeout: TimeInterval, + file: StaticString = #file, + line: UInt = #line + ) async throws -> Bool { let plugin = try plugin ?? Amplify.Hub.getPlugin(for: AWSHubPlugin.key) diff --git a/AmplifyTestCommon/Helpers/TypeRegistry.swift b/AmplifyTestCommon/Helpers/TypeRegistry.swift index b136759ab6..caa8fef882 100644 --- a/AmplifyTestCommon/Helpers/TypeRegistry.swift +++ b/AmplifyTestCommon/Helpers/TypeRegistry.swift @@ -29,7 +29,7 @@ class TypeRegistry { hasher.combine(ObjectIdentifier(type)) } - static func ==(lhs: TypeRegistry.Key, rhs: TypeRegistry.Key) -> Bool { + static func == (lhs: TypeRegistry.Key, rhs: TypeRegistry.Key) -> Bool { lhs.type == rhs.type } } diff --git a/AmplifyTestCommon/Mocks/MockAPICategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockAPICategoryPlugin.swift index d1336f66a1..779d2a99a3 100644 --- a/AmplifyTestCommon/Mocks/MockAPICategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockAPICategoryPlugin.swift @@ -85,17 +85,19 @@ class MockAPICategoryPlugin: MessageReporter, } let requestOptions = GraphQLOperationRequest.Options(pluginOptions: nil) - let request = GraphQLOperationRequest(apiName: request.apiName, - operationType: .subscription, - document: request.document, - variables: request.variables, - responseType: request.responseType, - options: requestOptions) - + let request = GraphQLOperationRequest( + apiName: request.apiName, + operationType: .subscription, + document: request.document, + variables: request.variables, + responseType: request.responseType, + options: requestOptions + ) + let taskRunner = MockAWSGraphQLSubscriptionTaskRunner(request: request) return taskRunner.sequence } - + public func reachabilityPublisher(for apiName: String?) -> AnyPublisher? { reachabilityPublisher() } @@ -112,16 +114,18 @@ class MockAPICategoryPlugin: MessageReporter, func get(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("get") - let operationRequest = RESTOperationRequest(apiName: request.apiName, - operationType: .get, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let operationRequest = RESTOperationRequest( + apiName: request.apiName, + operationType: .get, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: operationRequest) return operation } - + func get(request: RESTRequest) async throws -> RESTTask.Success { notify("get") return Data() @@ -129,24 +133,28 @@ class MockAPICategoryPlugin: MessageReporter, func put(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("put") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .put, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .put, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) return operation } - + func put(request: RESTRequest) async throws -> RESTTask.Success { notify("put") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .put, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .put, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) let taskAdapter = AmplifyOperationTaskAdapter(operation: operation) return try await taskAdapter.value @@ -154,74 +162,86 @@ class MockAPICategoryPlugin: MessageReporter, func post(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("post") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .post, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .post, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) return operation } func post(request: RESTRequest) async throws -> RESTTask.Success { notify("post") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .post, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .post, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) let taskAdapter = AmplifyOperationTaskAdapter(operation: operation) return try await taskAdapter.value } - + func delete(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("delete") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .delete, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .delete, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) return operation } func delete(request: RESTRequest) async throws -> RESTTask.Success { notify("delete") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .delete, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .delete, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) let taskAdapter = AmplifyOperationTaskAdapter(operation: operation) return try await taskAdapter.value } - + func patch(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("patch") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .patch, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .patch, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) return operation } - + func patch(request: RESTRequest) async throws -> RESTTask.Success { notify("patch") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .patch, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .patch, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) let taskAdapter = AmplifyOperationTaskAdapter(operation: operation) return try await taskAdapter.value @@ -229,29 +249,33 @@ class MockAPICategoryPlugin: MessageReporter, func head(request: RESTRequest, listener: RESTOperation.ResultListener?) -> RESTOperation { notify("head") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .head, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .head, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) return operation } - + func head(request: RESTRequest) async throws -> RESTTask.Success { notify("head") - let request = RESTOperationRequest(apiName: request.apiName, - operationType: .head, - path: request.path, - queryParameters: request.queryParameters, - body: request.body, - options: RESTOperationRequest.Options()) + let request = RESTOperationRequest( + apiName: request.apiName, + operationType: .head, + path: request.path, + queryParameters: request.queryParameters, + body: request.body, + options: RESTOperationRequest.Options() + ) let operation = MockAPIOperation(request: request) let taskAdapter = AmplifyOperationTaskAdapter(operation: operation) return try await taskAdapter.value } - + func add(interceptor: URLRequestInterceptor, for apiName: String) { notify("addInterceptor") @@ -260,7 +284,7 @@ class MockAPICategoryPlugin: MessageReporter, // MARK: - APICategoryAuthProviderFactoryBehavior func apiAuthProviderFactory() -> APIAuthProviderFactory { - if let authProviderFactory = authProviderFactory { + if let authProviderFactory { return authProviderFactory } else { return APIAuthProviderFactory() @@ -281,11 +305,15 @@ class MockGraphQLOperation: GraphQLOperation { override func resume() { } - init(request: Request, - responseType: R.Type) { - super.init(categoryType: .api, - eventName: HubPayload.EventName.API.mutate, - request: request) + init( + request: Request, + responseType: R.Type + ) { + super.init( + categoryType: .api, + eventName: HubPayload.EventName.API.mutate, + request: request + ) } } @@ -297,11 +325,15 @@ class MockSubscriptionGraphQLOperation: GraphQLSubscriptionOperati override func resume() { } - init(request: Request, - responseType: R.Type) { - super.init(categoryType: .api, - eventName: HubPayload.EventName.API.subscribe, - request: request) + init( + request: Request, + responseType: R.Type + ) { + super.init( + categoryType: .api, + eventName: HubPayload.EventName.API.subscribe, + request: request + ) } } @@ -313,9 +345,11 @@ class MockAPIOperation: AmplifyOperation, } init(request: Request) { - super.init(categoryType: .api, - eventName: request.operationType.hubEventName, - request: request) + super.init( + categoryType: .api, + eventName: request.operationType.hubEventName, + request: request + ) } } @@ -323,8 +357,10 @@ class MockAPIAuthProviderFactory: APIAuthProviderFactory { let oidcProvider: AmplifyOIDCAuthProvider? let functionProvider: AmplifyFunctionAuthProvider? - init(oidcProvider: AmplifyOIDCAuthProvider? = nil, - functionProvider: AmplifyFunctionAuthProvider? = nil) { + init( + oidcProvider: AmplifyOIDCAuthProvider? = nil, + functionProvider: AmplifyFunctionAuthProvider? = nil + ) { self.oidcProvider = oidcProvider self.functionProvider = functionProvider } @@ -340,7 +376,7 @@ class MockAPIAuthProviderFactory: APIAuthProviderFactory { class MockOIDCAuthProvider: AmplifyOIDCAuthProvider { var result: Result? - + func getLatestAuthToken() async throws -> String { if case let .success(token) = result { return token @@ -352,7 +388,7 @@ class MockOIDCAuthProvider: AmplifyOIDCAuthProvider { class MockFunctionAuthProvider: AmplifyFunctionAuthProvider { var result: Result? - + func getLatestAuthToken() async throws -> String { if case let .success(token) = result { return token @@ -363,17 +399,17 @@ class MockFunctionAuthProvider: AmplifyFunctionAuthProvider { } class MockAWSGraphQLSubscriptionTaskRunner: InternalTaskRunner, InternalTaskAsyncThrowingSequence, InternalTaskThrowingChannel { - + public typealias Request = GraphQLOperationRequest public typealias InProcess = GraphQLSubscriptionEvent public var request: GraphQLOperationRequest public var context = InternalTaskAsyncThrowingSequenceContext>() func run() async throws { - + } - + init(request: GraphQLOperationRequest) { self.request = request } - + } diff --git a/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift index 94e44aa795..de39825acd 100644 --- a/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { @@ -14,9 +14,11 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } - func signIn(username: String, - password: String, - options: AuthSignInRequest.Options?) async throws -> AuthSignInResult { + func signIn( + username: String, + password: String, + options: AuthSignInRequest.Options? + ) async throws -> AuthSignInResult { fatalError() } @@ -24,9 +26,11 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } - public func confirmSignUp(for username: String, - confirmationCode: String, - options: AuthConfirmSignUpRequest.Options? = nil) async throws -> AuthSignUpResult { + public func confirmSignUp( + for username: String, + confirmationCode: String, + options: AuthConfirmSignUpRequest.Options? = nil + ) async throws -> AuthSignUpResult { fatalError() } @@ -34,27 +38,35 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } - public func signIn(username: String? = nil, - password: String? = nil, - options: AuthSignInRequest.Options? = nil) async throws -> AuthSignInResult { + public func signIn( + username: String? = nil, + password: String? = nil, + options: AuthSignInRequest.Options? = nil + ) async throws -> AuthSignInResult { fatalError() } #if os(iOS) || os(macOS) - public func signInWithWebUI(presentationAnchor: AuthUIPresentationAnchor? = nil, - options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult { + public func signInWithWebUI( + presentationAnchor: AuthUIPresentationAnchor? = nil, + options: AuthWebUISignInRequest.Options? = nil + ) async throws -> AuthSignInResult { fatalError() } - public func signInWithWebUI(for authProvider: AuthProvider, - presentationAnchor: AuthUIPresentationAnchor? = nil, - options: AuthWebUISignInRequest.Options? = nil) async throws -> AuthSignInResult { + public func signInWithWebUI( + for authProvider: AuthProvider, + presentationAnchor: AuthUIPresentationAnchor? = nil, + options: AuthWebUISignInRequest.Options? = nil + ) async throws -> AuthSignInResult { fatalError() } #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 { fatalError() } @@ -74,10 +86,12 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } - public func confirmResetPassword(for username: String, - with newPassword: String, - confirmationCode: String, - options: AuthConfirmResetPasswordRequest.Options? = nil) async throws { + public func confirmResetPassword( + for username: String, + with newPassword: String, + confirmationCode: String, + options: AuthConfirmResetPasswordRequest.Options? = nil + ) async throws { fatalError() } @@ -100,7 +114,8 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { public func sendVerificationCode( forUserAttributeKey userAttributeKey: AuthUserAttributeKey, - options: AuthSendUserAttributeVerificationCodeRequest.Options? = nil) + options: AuthSendUserAttributeVerificationCodeRequest.Options? = nil + ) async throws -> AuthCodeDeliveryDetails { fatalError() } @@ -116,15 +131,19 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } - public func confirm(userAttribute: AuthUserAttributeKey, - confirmationCode: String, - options: AuthConfirmUserAttributeRequest.Options? = nil) async throws { + public func confirm( + userAttribute: AuthUserAttributeKey, + confirmationCode: String, + options: AuthConfirmUserAttributeRequest.Options? = nil + ) async throws { fatalError() } - 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 { notify("changePassword") } diff --git a/AmplifyTestCommon/Mocks/MockCredentialsProvider.swift b/AmplifyTestCommon/Mocks/MockCredentialsProvider.swift index 5b4f232074..8b10f8d91c 100644 --- a/AmplifyTestCommon/Mocks/MockCredentialsProvider.swift +++ b/AmplifyTestCommon/Mocks/MockCredentialsProvider.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import AWSPluginsCore import AWSClientRuntime +import AWSPluginsCore import Foundation class MockCredentialsProvider: AWSClientRuntime.CredentialsProviding { @@ -14,7 +14,7 @@ class MockCredentialsProvider: AWSClientRuntime.CredentialsProviding { return AWSCredentials( accessKey: "accessKey", secret: "secret", - expirationTimeout: Date().addingTimeInterval(1000) + expirationTimeout: Date().addingTimeInterval(1_000) ) } } diff --git a/AmplifyTestCommon/Mocks/MockDataStoreCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockDataStoreCategoryPlugin.swift index 5ba46da457..7f9944b46a 100644 --- a/AmplifyTestCommon/Mocks/MockDataStoreCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockDataStoreCategoryPlugin.swift @@ -24,30 +24,38 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { notify("reset") } - func save(_ model: M, - where condition: QueryPredicate? = nil, - completion: @escaping (DataStoreResult) -> Void) { + func save( + _ model: M, + where condition: QueryPredicate? = nil, + completion: @escaping (DataStoreResult) -> Void + ) { notify("save") if let responder = responders[.saveModelListener] as? SaveModelResponder { Task { - if let callback = await responder.callback((model: model, - where: condition)) { + if let callback = await responder.callback(( + model: model, + where: condition + )) { completion(callback) } } } } - - func save(_ model: M, - where condition: QueryPredicate? = nil) async throws -> M { + + func save( + _ model: M, + where condition: QueryPredicate? = nil + ) async throws -> M { notify("save") return model } - func query(_ modelType: M.Type, - byId id: String, - completion: @escaping (DataStoreResult) -> Void) { + func query( + _ modelType: M.Type, + byId id: String, + completion: @escaping (DataStoreResult) -> Void + ) { notify("queryById") if let responder = responders[.queryByIdListener] as? QueryByIdResponder { @@ -58,16 +66,20 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - - func query(_ modelType: M.Type, - byId id: String) async throws -> M? { + + func query( + _ modelType: M.Type, + byId id: String + ) async throws -> M? { notify("queryById") return nil } - func query(_ modelType: M.Type, - byIdentifier id: String, - completion: @escaping (DataStoreResult) -> Void) where M: ModelIdentifiable, + func query( + _ modelType: M.Type, + byIdentifier id: String, + completion: @escaping (DataStoreResult) -> Void + ) where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default { notify("queryByIdentifier") @@ -79,44 +91,54 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - - func query(_ modelType: M.Type, - byIdentifier id: String) async throws -> M? where M: ModelIdentifiable, + + func query( + _ modelType: M.Type, + byIdentifier id: String + ) async throws -> M? where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default { notify("queryByIdentifier") return nil } - func query(_ modelType: M.Type, - where predicate: QueryPredicate?, - sort sortInput: QuerySortInput?, - paginate paginationInput: QueryPaginationInput?, - completion: @escaping (DataStoreResult<[M]>) -> Void) { + func query( + _ modelType: M.Type, + where predicate: QueryPredicate?, + sort sortInput: QuerySortInput?, + paginate paginationInput: QueryPaginationInput?, + completion: @escaping (DataStoreResult<[M]>) -> Void + ) { notify("queryByPredicate") if let responder = responders[.queryModelsListener] as? QueryModelsResponder { Task { - if let result = await responder.callback((modelType: modelType, - where: predicate, - sort: sortInput, - paginate: paginationInput)) { + if let result = await responder.callback(( + modelType: modelType, + where: predicate, + sort: sortInput, + paginate: paginationInput + )) { completion(result) } } } } - - func query(_ modelType: M.Type, - where predicate: QueryPredicate?, - sort sortInput: QuerySortInput?, - paginate paginationInput: QueryPaginationInput?) async throws -> [M] { + + func query( + _ modelType: M.Type, + where predicate: QueryPredicate?, + sort sortInput: QuerySortInput?, + paginate paginationInput: QueryPaginationInput? + ) async throws -> [M] { notify("queryByPredicate") - + if let responder = responders[.queryModelsListener] as? QueryModelsResponder { - if let result = await responder.callback((modelType: modelType, - where: predicate, - sort: sortInput, - paginate: paginationInput)) { + if let result = await responder.callback(( + modelType: modelType, + where: predicate, + sort: sortInput, + paginate: paginationInput + )) { switch result { case .success(let models): return models @@ -125,13 +147,15 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - + return [] } - func query(_ modelType: M.Type, - byIdentifier id: ModelIdentifier, - completion: @escaping (DataStoreResult) -> Void) where M: Model, M: ModelIdentifiable { + func query( + _ modelType: M.Type, + byIdentifier id: ModelIdentifier, + completion: @escaping (DataStoreResult) -> Void + ) where M: Model, M: ModelIdentifiable { notify("queryWithIdentifier") if let responder = responders[.queryByIdListener] as? QueryByIdResponder { @@ -142,18 +166,22 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - - func query(_ modelType: M.Type, - byIdentifier id: ModelIdentifier) async throws -> M? + + func query( + _ modelType: M.Type, + byIdentifier id: ModelIdentifier + ) async throws -> M? where M: Model, M: ModelIdentifiable { notify("queryWithIdentifier") return nil } - func delete(_ modelType: M.Type, - withId id: String, - where predicate: QueryPredicate? = nil, - completion: @escaping (DataStoreResult) -> Void) { + func delete( + _ modelType: M.Type, + withId id: String, + where predicate: QueryPredicate? = nil, + completion: @escaping (DataStoreResult) -> Void + ) { notify("deleteById") if let responder = responders[.deleteByIdListener] as? DeleteByIdResponder { @@ -164,17 +192,21 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - - func delete(_ modelType: M.Type, - withId id: String, - where predicate: QueryPredicate? = nil) async throws { + + func delete( + _ modelType: (some Model).Type, + withId id: String, + where predicate: QueryPredicate? = nil + ) async throws { notify("deleteById") } - func delete(_ modelType: M.Type, - withIdentifier id: String, - where predicate: QueryPredicate? = nil, - completion: @escaping (DataStoreResult) -> Void) where M: ModelIdentifiable, + func delete( + _ modelType: M.Type, + withIdentifier id: String, + where predicate: QueryPredicate? = nil, + completion: @escaping (DataStoreResult) -> Void + ) where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default { notify("deleteByIdentifier") @@ -187,17 +219,21 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } - func delete(_ modelType: M.Type, - withIdentifier id: String, - where predicate: QueryPredicate? = nil) async throws + func delete( + _ modelType: M.Type, + withIdentifier id: String, + where predicate: QueryPredicate? = nil + ) async throws where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default { notify("deleteByIdentifier") } - - func delete(_ modelType: M.Type, - withIdentifier id: ModelIdentifier, - where predicate: QueryPredicate?, - completion: @escaping DataStoreCallback) where M: Model, M: ModelIdentifiable { + + func delete( + _ modelType: M.Type, + withIdentifier id: ModelIdentifier, + where predicate: QueryPredicate?, + completion: @escaping DataStoreCallback + ) where M: Model, M: ModelIdentifiable { notify("deleteByIdentifier") if let responder = responders[.deleteByIdListener] as? DeleteByIdResponder { @@ -209,15 +245,19 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } - func delete(_ modelType: M.Type, - withIdentifier id: ModelIdentifier, - where predicate: QueryPredicate?) async throws where M: Model, M: ModelIdentifiable { + func delete( + _ modelType: M.Type, + withIdentifier id: ModelIdentifier, + where predicate: QueryPredicate? + ) async throws where M: Model, M: ModelIdentifiable { notify("deleteByIdentifier") } - - func delete(_ modelType: M.Type, - where predicate: QueryPredicate, - completion: @escaping (DataStoreResult) -> Void) { + + func delete( + _ modelType: M.Type, + where predicate: QueryPredicate, + completion: @escaping (DataStoreResult) -> Void + ) { notify("deleteModelTypeByPredicate") if let responder = responders[.deleteModelTypeListener] as? DeleteModelTypeResponder { @@ -228,29 +268,37 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - - func delete(_ modelType: M.Type, - where predicate: QueryPredicate) async throws { + + func delete( + _ modelType: (some Model).Type, + where predicate: QueryPredicate + ) async throws { notify("deleteModelTypeByPredicate") } - func delete(_ model: M, - where predicate: QueryPredicate? = nil, - completion: @escaping DataStoreCallback) { + func delete( + _ model: M, + where predicate: QueryPredicate? = nil, + completion: @escaping DataStoreCallback + ) { notify("deleteByPredicate") if let responder = responders[.deleteModelListener] as? DeleteModelResponder { Task { - if let callback = await responder.callback((model: model, - where: predicate)) { + if let callback = await responder.callback(( + model: model, + where: predicate + )) { completion(callback) } } } } - - func delete(_ model: M, - where predicate: QueryPredicate? = nil) async throws { + + func delete( + _ model: some Model, + where predicate: QueryPredicate? = nil + ) async throws { notify("deleteByPredicate") } @@ -265,7 +313,7 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - + func clear() async throws { notify("clear") } @@ -281,7 +329,7 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { } } } - + func start() async throws { notify("start") } @@ -301,36 +349,42 @@ class MockDataStoreCategoryPlugin: MessageReporter, DataStoreCategoryPlugin { func stop() async throws { notify("stop") } - - func publisher(for modelType: M.Type) + + func publisher(for modelType: (some Model).Type) -> AnyPublisher { - let mutationEvent = MutationEvent(id: "testevent", - modelId: "123", - modelName: modelType.modelName, - json: "", - mutationType: .create, - createdAt: .now()) + let mutationEvent = MutationEvent( + id: "testevent", + modelId: "123", + modelName: modelType.modelName, + json: "", + mutationType: .create, + createdAt: .now() + ) notify("publisher") return Result.Publisher(mutationEvent).eraseToAnyPublisher() } - func observe(_ modelType: M.Type) -> AmplifyAsyncThrowingSequence { + func observe(_ modelType: (some Model).Type) -> AmplifyAsyncThrowingSequence { return AmplifyAsyncThrowingSequence(parent: nil) } - - public func observeQuery(for modelType: M.Type, - where predicate: QueryPredicate? = nil, - sort sortInput: QuerySortInput? = nil) + + public func observeQuery( + for modelType: M.Type, + where predicate: QueryPredicate? = nil, + sort sortInput: QuerySortInput? = nil + ) -> AnyPublisher, DataStoreError> { notify("observeQuery") let snapshot = DataStoreQuerySnapshot(items: [], isSynced: false) return Result.Publisher(snapshot).eraseToAnyPublisher() } - - func observeQuery(for modelType: M.Type, - where predicate: QueryPredicate?, - sort sortInput: QuerySortInput?) -> AmplifyAsyncThrowingSequence> { - + + func observeQuery( + for modelType: M.Type, + where predicate: QueryPredicate?, + sort sortInput: QuerySortInput? + ) -> AmplifyAsyncThrowingSequence> { + let request = ObserveQueryRequest(options: []) let taskRunner = MockObserveQueryTaskRunner(request: request) return taskRunner.sequence @@ -346,13 +400,13 @@ class MockSecondDataStoreCategoryPlugin: MockDataStoreCategoryPlugin { class ObserveQueryRequest: AmplifyOperationRequest { var options: Any - + typealias Options = Any - + init(options: Any) { self.options = options } - + } class MockObserveQueryTaskRunner: InternalTaskRunner, InternalTaskAsyncThrowingSequence, InternalTaskThrowingChannel { diff --git a/AmplifyTestCommon/Mocks/MockGeoCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockGeoCategoryPlugin.swift index f328e48b6f..55c7839975 100644 --- a/AmplifyTestCommon/Mocks/MockGeoCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockGeoCategoryPlugin.swift @@ -42,22 +42,25 @@ class MockGeoCategoryPlugin: MessageReporter, GeoCategoryPlugin { } private func createMapStyle() -> Geo.MapStyle { - Geo.MapStyle(mapName: "MapName", - style: "MapStyle", - styleURL: URL(string: "http://MapStyleURL")!) + Geo.MapStyle( + mapName: "MapName", + style: "MapStyle", + styleURL: URL(string: "http://MapStyleURL")! + ) } private func createPlace() -> Geo.Place { - Geo.Place(coordinates: Geo.Coordinates(latitude: 0, longitude: 0), - label: "Place Label", - addressNumber: nil, - street: nil, - municipality: nil, - neighborhood: nil, - region: nil, - subRegion: nil, - postalCode: nil, - country: nil + Geo.Place( + coordinates: Geo.Coordinates(latitude: 0, longitude: 0), + label: "Place Label", + addressNumber: nil, + street: nil, + municipality: nil, + neighborhood: nil, + region: nil, + subRegion: nil, + postalCode: nil, + country: nil ) } } diff --git a/AmplifyTestCommon/Mocks/MockHubCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockHubCategoryPlugin.swift index 4c5abd37a2..57df57ad97 100644 --- a/AmplifyTestCommon/Mocks/MockHubCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockHubCategoryPlugin.swift @@ -26,16 +26,20 @@ class MockHubCategoryPlugin: MessageReporter, HubCategoryPlugin { notify("dispatch") } - func listen(to channel: HubChannel, - eventName: HubPayloadEventName, - listener: @escaping HubListener) -> UnsubscribeToken { + func listen( + to channel: HubChannel, + eventName: HubPayloadEventName, + listener: @escaping HubListener + ) -> UnsubscribeToken { notify("listenEventName") return UnsubscribeToken(channel: channel, id: UUID()) } - func listen(to channel: HubChannel, - isIncluded filter: HubFilter?, - listener: @escaping HubListener) -> UnsubscribeToken { + func listen( + to channel: HubChannel, + isIncluded filter: HubFilter?, + listener: @escaping HubListener + ) -> UnsubscribeToken { notify("listen") return UnsubscribeToken(channel: channel, id: UUID()) } diff --git a/AmplifyTestCommon/Mocks/MockLoggingCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockLoggingCategoryPlugin.swift index ca51dc55c8..cd5ebcea1d 100644 --- a/AmplifyTestCommon/Mocks/MockLoggingCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockLoggingCategoryPlugin.swift @@ -17,7 +17,7 @@ class MockLoggingCategoryPlugin: MessageReporter, LoggingCategoryPlugin, Logger func logger(forCategory category: String) -> Logger { self } - + func logger(forNamespace namespace: String) -> Logger { self } @@ -25,15 +25,15 @@ class MockLoggingCategoryPlugin: MessageReporter, LoggingCategoryPlugin, Logger func logger(forCategory category: String, logLevel: LogLevel) -> Logger { self } - + func logger(forCategory category: String, forNamespace namespace: String) -> Logger { self } - + func enable() { notify("enable") } - + func disable() { notify("disable") } diff --git a/AmplifyTestCommon/Mocks/MockPredictionsCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockPredictionsCategoryPlugin.swift index e226dbddab..b33b97ccb3 100644 --- a/AmplifyTestCommon/Mocks/MockPredictionsCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockPredictionsCategoryPlugin.swift @@ -13,7 +13,7 @@ class MockPredictionsCategoryPlugin: MessageReporter, PredictionsCategoryPlugin fatalError() } - func convert(_ request: Predictions.Convert.Request, options: Options?) async throws -> Output { + func convert(_ request: Predictions.Convert.Request, options: Options?) async throws -> Output { fatalError() } diff --git a/AmplifyTestCommon/Mocks/MockPushNotificationsCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockPushNotificationsCategoryPlugin.swift index d545d1d129..b080ce92c6 100644 --- a/AmplifyTestCommon/Mocks/MockPushNotificationsCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockPushNotificationsCategoryPlugin.swift @@ -13,27 +13,27 @@ class MockPushNotificationsCategoryPlugin: MessageReporter, PushNotificationsCat var key: String { "MockPushNotificationsCategoryPlugin" } - + func configure(using configuration: Any?) throws { notify() } - + func reset() async { notify() } - + func identifyUser(userId: String, userProfile: AmplifyUserProfile?) { notify("identifyUser(userId:\(userId))") } - + func registerDevice(apnsToken: Data) { notify("registerDevice(token:\(apnsToken))") } - + func recordNotificationReceived(_ userInfo: Notifications.Push.UserInfo) { notify("recordNotificationReceived(userInfo:\(userInfo))") } - + #if !os(tvOS) func recordNotificationOpened(_ response: UNNotificationResponse) { notify("recordNotificationOpened(response:\(response))") diff --git a/AmplifyTestCommon/Mocks/MockStorageCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockStorageCategoryPlugin.swift index bc6255567f..81e90e4499 100644 --- a/AmplifyTestCommon/Mocks/MockStorageCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockStorageCategoryPlugin.swift @@ -10,19 +10,22 @@ import Foundation class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { - func getURL(key: String, - options: StorageGetURLRequest.Options?, - resultListener: StorageGetURLOperation.ResultListener?) -> StorageGetURLOperation { + func getURL( + key: String, + options: StorageGetURLRequest.Options?, + resultListener: StorageGetURLOperation.ResultListener? + ) -> StorageGetURLOperation { notify("getURL") let options = options ?? StorageGetURLRequest.Options() let request = StorageGetURLRequest(key: key, options: options) return MockStorageGetURLOperation(request: request) } - func downloadData(key: String, - options: StorageDownloadDataRequest.Options?, - progressListener: ProgressListener? = nil, - resultListener: StorageDownloadDataOperation.ResultListener? + func downloadData( + key: String, + options: StorageDownloadDataRequest.Options?, + progressListener: ProgressListener? = nil, + resultListener: StorageDownloadDataOperation.ResultListener? ) -> StorageDownloadDataOperation { notify("downloadData") let options = options ?? StorageDownloadDataRequest.Options() @@ -30,11 +33,12 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { return MockStorageDownloadDataOperation(request: request) } - func downloadFile(key: String, - local: URL, - options: StorageDownloadFileRequest.Options?, - progressListener: ProgressListener? = nil, - resultListener: StorageDownloadFileOperation.ResultListener? + func downloadFile( + key: String, + local: URL, + options: StorageDownloadFileRequest.Options?, + progressListener: ProgressListener? = nil, + resultListener: StorageDownloadFileOperation.ResultListener? ) -> StorageDownloadFileOperation { notify("downloadFile") let options = options ?? StorageDownloadFileRequest.Options() @@ -42,11 +46,12 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { return MockStorageDownloadFileOperation(request: request) } - func uploadData(key: String, - data: Data, - options: StorageUploadDataRequest.Options?, - progressListener: ProgressListener? = nil, - resultListener: StorageUploadDataOperation.ResultListener? + func uploadData( + key: String, + data: Data, + options: StorageUploadDataRequest.Options?, + progressListener: ProgressListener? = nil, + resultListener: StorageUploadDataOperation.ResultListener? ) -> StorageUploadDataOperation { notify("uploadData") let options = options ?? StorageUploadDataRequest.Options() @@ -54,11 +59,12 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { return MockStorageUploadDataOperation(request: request) } - func uploadFile(key: String, - local: URL, - options: StorageUploadFileRequest.Options?, - progressListener: ProgressListener? = nil, - resultListener: StorageUploadFileOperation.ResultListener? + func uploadFile( + key: String, + local: URL, + options: StorageUploadFileRequest.Options?, + progressListener: ProgressListener? = nil, + resultListener: StorageUploadFileOperation.ResultListener? ) -> StorageUploadFileOperation { notify("uploadFile") let options = options ?? StorageUploadFileRequest.Options() @@ -66,17 +72,21 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { return MockStorageUploadFileOperation(request: request) } - func remove(key: String, - options: StorageRemoveRequest.Options?, - resultListener: StorageRemoveOperation.ResultListener?) -> StorageRemoveOperation { + func remove( + key: String, + options: StorageRemoveRequest.Options?, + resultListener: StorageRemoveOperation.ResultListener? + ) -> StorageRemoveOperation { notify("remove") let options = options ?? StorageRemoveRequest.Options() let request = StorageRemoveRequest(key: key, options: options) return MockStorageRemoveOperation(request: request) } - func list(options: StorageListRequest.Options?, - resultListener: StorageListOperation.ResultListener?) -> StorageListOperation { + func list( + options: StorageListRequest.Options?, + resultListener: StorageListOperation.ResultListener? + ) -> StorageListOperation { notify("list") let options = options ?? StorageListRequest.Options() let request = StorageListRequest(options: options) @@ -98,8 +108,10 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { // MARK: - Async API - @discardableResult - func getURL(key: String, - options: StorageGetURLOperation.Request.Options?) async throws -> URL { + func getURL( + key: String, + options: StorageGetURLOperation.Request.Options? + ) async throws -> URL { notify("getURL") let options = options ?? StorageGetURLRequest.Options() let request = StorageGetURLRequest(key: key, options: options) @@ -109,8 +121,10 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { } @discardableResult - func remove(key: String, - options: StorageRemoveRequest.Options? = nil) async throws -> String { + func remove( + key: String, + options: StorageRemoveRequest.Options? = nil + ) async throws -> String { notify("remove") let options = options ?? StorageRemoveRequest.Options() let request = StorageRemoveRequest(key: key, options: options) @@ -120,8 +134,10 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { } @discardableResult - func downloadData(key: String, - options: StorageDownloadDataOperation.Request.Options? = nil) -> StorageDownloadDataTask { + func downloadData( + key: String, + options: StorageDownloadDataOperation.Request.Options? = nil + ) -> StorageDownloadDataTask { notify("downloadData") let options = options ?? StorageDownloadDataRequest.Options() let request = StorageDownloadDataRequest(key: key, options: options) @@ -131,9 +147,11 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { } @discardableResult - func downloadFile(key: String, - local: URL, - options: StorageDownloadFileOperation.Request.Options?) -> StorageDownloadFileTask { + func downloadFile( + key: String, + local: URL, + options: StorageDownloadFileOperation.Request.Options? + ) -> StorageDownloadFileTask { notify("downloadFile") let options = options ?? StorageDownloadFileRequest.Options() let request = StorageDownloadFileRequest(key: key, local: local, options: options) @@ -143,9 +161,11 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { } @discardableResult - func uploadData(key: String, - data: Data, - options: StorageUploadDataOperation.Request.Options?) -> StorageUploadDataTask { + func uploadData( + key: String, + data: Data, + options: StorageUploadDataOperation.Request.Options? + ) -> StorageUploadDataTask { notify("uploadData") let options = options ?? StorageUploadDataRequest.Options() let request = StorageUploadDataRequest(key: key, data: data, options: options) @@ -155,9 +175,11 @@ class MockStorageCategoryPlugin: MessageReporter, StorageCategoryPlugin { } @discardableResult - func uploadFile(key: String, - local: URL, - options: StorageUploadFileOperation.Request.Options?) -> StorageUploadFileTask { + func uploadFile( + key: String, + local: URL, + options: StorageUploadFileOperation.Request.Options? + ) -> StorageUploadFileTask { notify("uploadFile") let options = options ?? StorageUploadFileRequest.Options() let request = StorageUploadFileRequest(key: key, local: local, options: options) @@ -259,17 +281,19 @@ class MockStorageGetURLOperation: AmplifyOperation, StorageDownloadDataOperation { override func pause() { } @@ -278,17 +302,19 @@ StorageError } init(request: Request) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.downloadData, - request: request) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.downloadData, + request: request + ) } } class MockStorageDownloadFileOperation: AmplifyInProcessReportingOperation< -StorageDownloadFileRequest, -Progress, -Void, -StorageError + StorageDownloadFileRequest, + Progress, + Void, + StorageError >, StorageDownloadFileOperation { override func pause() { } @@ -297,17 +323,19 @@ StorageError } init(request: Request) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.downloadFile, - request: request) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.downloadFile, + request: request + ) } } class MockStorageUploadDataOperation: AmplifyInProcessReportingOperation< -StorageUploadDataRequest, -Progress, -String, -StorageError + StorageUploadDataRequest, + Progress, + String, + StorageError >, StorageUploadDataOperation { override func pause() { } @@ -316,17 +344,19 @@ StorageError } init(request: Request) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.uploadData, - request: request) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.uploadData, + request: request + ) } } class MockStorageUploadFileOperation: AmplifyInProcessReportingOperation< -StorageUploadFileRequest, -Progress, -String, -StorageError + StorageUploadFileRequest, + Progress, + String, + StorageError >, StorageUploadFileOperation { override func pause() { } @@ -335,9 +365,11 @@ StorageError } init(request: Request) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.uploadFile, - request: request) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.uploadFile, + request: request + ) } } @@ -350,9 +382,11 @@ class MockStorageRemoveOperation: AmplifyOperation {} + class Path: ModelPath {} - public static var rootPath: PropertyContainerPath? { Path() } + static var rootPath: PropertyContainerPath? { Path() } } diff --git a/AmplifyTestCommon/Models/Associations/Author.swift b/AmplifyTestCommon/Models/Associations/Author.swift index 61b68ea4d8..d2d6a84a87 100644 --- a/AmplifyTestCommon/Models/Associations/Author.swift +++ b/AmplifyTestCommon/Models/Associations/Author.swift @@ -16,9 +16,11 @@ public struct Author: Model { // hasMany(associatedWith: "author") public var books: List - public init(id: String = UUID().uuidString, - name: String, - books: List = []) { + public init( + id: String = UUID().uuidString, + name: String, + books: List = [] + ) { self.id = id self.name = name self.books = books diff --git a/AmplifyTestCommon/Models/Associations/Book+Schema.swift b/AmplifyTestCommon/Models/Associations/Book+Schema.swift index e71488b030..54f2790c63 100644 --- a/AmplifyTestCommon/Models/Associations/Book+Schema.swift +++ b/AmplifyTestCommon/Models/Associations/Book+Schema.swift @@ -8,34 +8,36 @@ import Amplify import Foundation -extension Book { +public extension Book { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case authors } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let book = Book.keys model.fields( .id(), .field(book.title, is: .required, ofType: .string), - .hasMany(book.authors, - ofType: BookAuthor.self, - associatedWith: BookAuthor.keys.author) + .hasMany( + book.authors, + ofType: BookAuthor.self, + associatedWith: BookAuthor.keys.author + ) ) } - public class Path : ModelPath {} + class Path: ModelPath {} - public static var rootPath: PropertyContainerPath? { Path() } + static var rootPath: PropertyContainerPath? { Path() } } diff --git a/AmplifyTestCommon/Models/Associations/Book.swift b/AmplifyTestCommon/Models/Associations/Book.swift index 64de97c0ed..49a6bee75e 100644 --- a/AmplifyTestCommon/Models/Associations/Book.swift +++ b/AmplifyTestCommon/Models/Associations/Book.swift @@ -16,9 +16,11 @@ public struct Book: Model { // hasMany(associatedWith: "book") public var authors: List - public init(id: String = UUID().uuidString, - title: String, - authors: List = []) { + public init( + id: String = UUID().uuidString, + title: String, + authors: List = [] + ) { self.id = id self.title = title self.authors = authors diff --git a/AmplifyTestCommon/Models/Associations/BookAuthor+Schema.swift b/AmplifyTestCommon/Models/Associations/BookAuthor+Schema.swift index c6a22c9bcb..4856720780 100644 --- a/AmplifyTestCommon/Models/Associations/BookAuthor+Schema.swift +++ b/AmplifyTestCommon/Models/Associations/BookAuthor+Schema.swift @@ -8,36 +8,40 @@ import Amplify import Foundation -extension BookAuthor { +public extension BookAuthor { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case book case author } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let bookAuthor = BookAuthor.keys model.fields( .id(), - .belongsTo(bookAuthor.book, - ofType: Book.self, - associatedWith: Book.keys.authors), - .belongsTo(bookAuthor.author, - ofType: Author.self, - associatedWith: Author.keys.books) + .belongsTo( + bookAuthor.book, + ofType: Book.self, + associatedWith: Book.keys.authors + ), + .belongsTo( + bookAuthor.author, + ofType: Author.self, + associatedWith: Author.keys.books + ) ) } - public class Path : ModelPath {} + class Path: ModelPath {} - public static var rootPath: PropertyContainerPath? { Path() } + static var rootPath: PropertyContainerPath? { Path() } } diff --git a/AmplifyTestCommon/Models/Associations/BookAuthor.swift b/AmplifyTestCommon/Models/Associations/BookAuthor.swift index 1c837b590c..e29875b031 100644 --- a/AmplifyTestCommon/Models/Associations/BookAuthor.swift +++ b/AmplifyTestCommon/Models/Associations/BookAuthor.swift @@ -18,9 +18,11 @@ public struct BookAuthor: Model { // belongsTo public let book: Book - public init(id: String = UUID().uuidString, - book: Book, - author: Author) { + public init( + id: String = UUID().uuidString, + book: Book, + author: Author + ) { self.id = id self.book = book self.author = author diff --git a/AmplifyTestCommon/Models/Associations/UserAccount+Schema.swift b/AmplifyTestCommon/Models/Associations/UserAccount+Schema.swift index dc51cd80e0..adf7fb3f85 100644 --- a/AmplifyTestCommon/Models/Associations/UserAccount+Schema.swift +++ b/AmplifyTestCommon/Models/Associations/UserAccount+Schema.swift @@ -8,27 +8,29 @@ import Amplify import Foundation -extension UserAccount { +public extension UserAccount { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case profile } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let account = UserAccount.keys model.fields( .id(), - .hasOne(account.profile, - is: .optional, - ofType: UserProfile.self, - associatedWith: UserProfile.CodingKeys.account) + .hasOne( + account.profile, + is: .optional, + ofType: UserProfile.self, + associatedWith: UserProfile.CodingKeys.account + ) ) } diff --git a/AmplifyTestCommon/Models/Associations/UserAccount.swift b/AmplifyTestCommon/Models/Associations/UserAccount.swift index 268b5f0fed..a05e352f88 100644 --- a/AmplifyTestCommon/Models/Associations/UserAccount.swift +++ b/AmplifyTestCommon/Models/Associations/UserAccount.swift @@ -20,8 +20,10 @@ public class UserAccount: Model { // hasOne(associatedWith: "account") public var profile: UserProfile? - public init(id: String = UUID().uuidString, - profile: UserProfile? = nil) { + public init( + id: String = UUID().uuidString, + profile: UserProfile? = nil + ) { self.id = id self.profile = profile } diff --git a/AmplifyTestCommon/Models/Associations/UserProfile+Schema.swift b/AmplifyTestCommon/Models/Associations/UserProfile+Schema.swift index 6b6eb355d7..d4e2c7ee1d 100644 --- a/AmplifyTestCommon/Models/Associations/UserProfile+Schema.swift +++ b/AmplifyTestCommon/Models/Associations/UserProfile+Schema.swift @@ -8,26 +8,28 @@ import Amplify import Foundation -extension UserProfile { +public extension UserProfile { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case account } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let profile = UserProfile.keys model.fields( .id(), - .belongsTo(profile.account, - ofType: UserAccount.self, - associatedWith: UserAccount.keys.profile) + .belongsTo( + profile.account, + ofType: UserAccount.self, + associatedWith: UserAccount.keys.profile + ) ) } diff --git a/AmplifyTestCommon/Models/Associations/UserProfile.swift b/AmplifyTestCommon/Models/Associations/UserProfile.swift index 227d1c8da5..26d1d2e7cb 100644 --- a/AmplifyTestCommon/Models/Associations/UserProfile.swift +++ b/AmplifyTestCommon/Models/Associations/UserProfile.swift @@ -20,8 +20,10 @@ public class UserProfile: Model { // belongsTo(associatedWith: "profile") public var account: UserAccount - public init(id: String = UUID().uuidString, - account: UserAccount) { + public init( + id: String = UUID().uuidString, + account: UserAccount + ) { self.id = id self.account = account } diff --git a/AmplifyTestCommon/Models/Collection/1/Project1+Schema.swift b/AmplifyTestCommon/Models/Collection/1/Project1+Schema.swift index d561583928..7d0aacab8b 100644 --- a/AmplifyTestCommon/Models/Collection/1/Project1+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/1/Project1+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Project1 { +public extension Project1 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case team } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project1 = Project1.keys model.listPluralName = "Project1s" diff --git a/AmplifyTestCommon/Models/Collection/1/Project1.swift b/AmplifyTestCommon/Models/Collection/1/Project1.swift index ab67718c80..8760364532 100644 --- a/AmplifyTestCommon/Models/Collection/1/Project1.swift +++ b/AmplifyTestCommon/Models/Collection/1/Project1.swift @@ -14,9 +14,11 @@ public struct Project1: Model { public var name: String? public var team: Team1? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String? = nil, - team: Team1? = nil) { + team: Team1? = nil + ) { self.id = id self.name = name self.team = team diff --git a/AmplifyTestCommon/Models/Collection/1/Team1+Schema.swift b/AmplifyTestCommon/Models/Collection/1/Team1+Schema.swift index be252d9197..946b4692c0 100644 --- a/AmplifyTestCommon/Models/Collection/1/Team1+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/1/Team1+Schema.swift @@ -9,17 +9,17 @@ import Amplify import Foundation -extension Team1 { +public extension Team1 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team1 = Team1.keys model.listPluralName = "Team1s" diff --git a/AmplifyTestCommon/Models/Collection/1/Team1.swift b/AmplifyTestCommon/Models/Collection/1/Team1.swift index 4a6101a50c..0bcf352358 100644 --- a/AmplifyTestCommon/Models/Collection/1/Team1.swift +++ b/AmplifyTestCommon/Models/Collection/1/Team1.swift @@ -13,8 +13,10 @@ public struct Team1: Model { public let id: String public var name: String - public init(id: String = UUID().uuidString, - name: String) { + public init( + id: String = UUID().uuidString, + name: String + ) { self.id = id self.name = name } diff --git a/AmplifyTestCommon/Models/Collection/2/Project2+Schema.swift b/AmplifyTestCommon/Models/Collection/2/Project2+Schema.swift index 7bd2fd74ce..837b30544e 100644 --- a/AmplifyTestCommon/Models/Collection/2/Project2+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/2/Project2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Project2 { +public extension Project2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case teamID case team } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project2 = Project2.keys model.listPluralName = "Project2s" diff --git a/AmplifyTestCommon/Models/Collection/2/Project2.swift b/AmplifyTestCommon/Models/Collection/2/Project2.swift index a5307b612c..0dbc730331 100644 --- a/AmplifyTestCommon/Models/Collection/2/Project2.swift +++ b/AmplifyTestCommon/Models/Collection/2/Project2.swift @@ -15,10 +15,12 @@ public struct Project2: Model { public var teamID: String public var team: Team2? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String? = nil, teamID: String, - team: Team2? = nil) { + team: Team2? = nil + ) { self.id = id self.name = name self.teamID = teamID diff --git a/AmplifyTestCommon/Models/Collection/2/Team2+Schema.swift b/AmplifyTestCommon/Models/Collection/2/Team2+Schema.swift index 9c7424a94d..4e97ad88c6 100644 --- a/AmplifyTestCommon/Models/Collection/2/Team2+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/2/Team2+Schema.swift @@ -9,17 +9,17 @@ import Amplify import Foundation -extension Team2 { +public extension Team2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team2 = Team2.keys model.listPluralName = "Team2s" diff --git a/AmplifyTestCommon/Models/Collection/2/Team2.swift b/AmplifyTestCommon/Models/Collection/2/Team2.swift index eece17c222..7c3b6617a8 100644 --- a/AmplifyTestCommon/Models/Collection/2/Team2.swift +++ b/AmplifyTestCommon/Models/Collection/2/Team2.swift @@ -13,8 +13,10 @@ public struct Team2: Model { public let id: String public var name: String - public init(id: String = UUID().uuidString, - name: String) { + public init( + id: String = UUID().uuidString, + name: String + ) { self.id = id self.name = name } diff --git a/AmplifyTestCommon/Models/Collection/3/Comment3+Schema.swift b/AmplifyTestCommon/Models/Collection/3/Comment3+Schema.swift index 03c4b0eb64..f2be1939c8 100644 --- a/AmplifyTestCommon/Models/Collection/3/Comment3+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/3/Comment3+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Comment3 { +public extension Comment3 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case postID case content } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment3 = Comment3.keys model.listPluralName = "Comment3s" diff --git a/AmplifyTestCommon/Models/Collection/3/Comment3.swift b/AmplifyTestCommon/Models/Collection/3/Comment3.swift index f24badf993..14c2cce660 100644 --- a/AmplifyTestCommon/Models/Collection/3/Comment3.swift +++ b/AmplifyTestCommon/Models/Collection/3/Comment3.swift @@ -14,9 +14,11 @@ public struct Comment3: Model { public var postID: String public var content: String - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, postID: String, - content: String) { + content: String + ) { self.id = id self.postID = postID self.content = content diff --git a/AmplifyTestCommon/Models/Collection/3/Post3+Schema.swift b/AmplifyTestCommon/Models/Collection/3/Post3+Schema.swift index 9f828c7c44..fbda57a013 100644 --- a/AmplifyTestCommon/Models/Collection/3/Post3+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/3/Post3+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Post3 { +public extension Post3 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post3 = Post3.keys model.listPluralName = "Post3s" diff --git a/AmplifyTestCommon/Models/Collection/3/Post3.swift b/AmplifyTestCommon/Models/Collection/3/Post3.swift index 1302c5a233..63d64a9316 100644 --- a/AmplifyTestCommon/Models/Collection/3/Post3.swift +++ b/AmplifyTestCommon/Models/Collection/3/Post3.swift @@ -14,9 +14,11 @@ public struct Post3: Model { public var title: String public var comments: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - comments: List? = []) { + comments: List? = [] + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/Collection/4/Comment4+Schema.swift b/AmplifyTestCommon/Models/Collection/4/Comment4+Schema.swift index 16b6b2a416..35b7c9278c 100644 --- a/AmplifyTestCommon/Models/Collection/4/Comment4+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/4/Comment4+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Comment4 { +public extension Comment4 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment4 = Comment4.keys model.listPluralName = "Comment4s" diff --git a/AmplifyTestCommon/Models/Collection/4/Comment4.swift b/AmplifyTestCommon/Models/Collection/4/Comment4.swift index 7b7cd90df6..5a18637a57 100644 --- a/AmplifyTestCommon/Models/Collection/4/Comment4.swift +++ b/AmplifyTestCommon/Models/Collection/4/Comment4.swift @@ -12,28 +12,30 @@ import Foundation public struct Comment4: Model { public let id: String public var content: String - internal var _post: LazyReference + var _post: LazyReference public var post: Post4? { get async throws { try await _post.get() } } - - public init(id: String = UUID().uuidString, - content: String, - post: Post4? = nil) { + + public init( + id: String = UUID().uuidString, + content: String, + post: Post4? = nil + ) { self.id = id self.content = content self._post = LazyReference(post) } - + public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - id = try values.decode(String.self, forKey: .id) - content = try values.decode(String.self, forKey: .content) - _post = try values.decodeIfPresent(LazyReference.self, forKey: .post) ?? LazyReference(identifiers: nil) + self.id = try values.decode(String.self, forKey: .id) + self.content = try values.decode(String.self, forKey: .content) + self._post = try values.decodeIfPresent(LazyReference.self, forKey: .post) ?? LazyReference(identifiers: nil) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) diff --git a/AmplifyTestCommon/Models/Collection/4/Post4+Schema.swift b/AmplifyTestCommon/Models/Collection/4/Post4+Schema.swift index 17144a90a0..ac5c751832 100644 --- a/AmplifyTestCommon/Models/Collection/4/Post4+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/4/Post4+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Post4 { +public extension Post4 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post4 = Post4.keys model.listPluralName = "Post4s" diff --git a/AmplifyTestCommon/Models/Collection/4/Post4.swift b/AmplifyTestCommon/Models/Collection/4/Post4.swift index 4764058a79..84fc6972ba 100644 --- a/AmplifyTestCommon/Models/Collection/4/Post4.swift +++ b/AmplifyTestCommon/Models/Collection/4/Post4.swift @@ -14,9 +14,11 @@ public struct Post4: Model { public var title: String public var comments: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - comments: List? = []) { + comments: List? = [] + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/Collection/5/Post5+Schema.swift b/AmplifyTestCommon/Models/Collection/5/Post5+Schema.swift index 3898f6addd..419ffc556d 100644 --- a/AmplifyTestCommon/Models/Collection/5/Post5+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/5/Post5+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Post5 { +public extension Post5 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case editors } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post5 = Post5.keys model.listPluralName = "Post5s" diff --git a/AmplifyTestCommon/Models/Collection/5/Post5.swift b/AmplifyTestCommon/Models/Collection/5/Post5.swift index 023c8eb0dc..d4f8fc51fa 100644 --- a/AmplifyTestCommon/Models/Collection/5/Post5.swift +++ b/AmplifyTestCommon/Models/Collection/5/Post5.swift @@ -14,9 +14,11 @@ public struct Post5: Model { public var title: String public var editors: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - editors: List? = []) { + editors: List? = [] + ) { self.id = id self.title = title self.editors = editors diff --git a/AmplifyTestCommon/Models/Collection/5/PostEditor5+Schema.swift b/AmplifyTestCommon/Models/Collection/5/PostEditor5+Schema.swift index 586429c143..2d054312a0 100644 --- a/AmplifyTestCommon/Models/Collection/5/PostEditor5+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/5/PostEditor5+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension PostEditor5 { +public extension PostEditor5 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case post case editor } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postEditor5 = PostEditor5.keys model.listPluralName = "PostEditor5s" diff --git a/AmplifyTestCommon/Models/Collection/5/PostEditor5.swift b/AmplifyTestCommon/Models/Collection/5/PostEditor5.swift index 24cad3a416..30af2f8558 100644 --- a/AmplifyTestCommon/Models/Collection/5/PostEditor5.swift +++ b/AmplifyTestCommon/Models/Collection/5/PostEditor5.swift @@ -14,9 +14,11 @@ public struct PostEditor5: Model { public var post: Post5 public var editor: User5 - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, post: Post5, - editor: User5) { + editor: User5 + ) { self.id = id self.post = post self.editor = editor diff --git a/AmplifyTestCommon/Models/Collection/5/User5+Schema.swift b/AmplifyTestCommon/Models/Collection/5/User5+Schema.swift index cf467b9f55..431a0027db 100644 --- a/AmplifyTestCommon/Models/Collection/5/User5+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/5/User5+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension User5 { +public extension User5 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case username case posts } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let user5 = User5.keys model.listPluralName = "User5s" diff --git a/AmplifyTestCommon/Models/Collection/5/User5.swift b/AmplifyTestCommon/Models/Collection/5/User5.swift index 3fab8d8d27..63e5ad8478 100644 --- a/AmplifyTestCommon/Models/Collection/5/User5.swift +++ b/AmplifyTestCommon/Models/Collection/5/User5.swift @@ -14,9 +14,11 @@ public struct User5: Model { public var username: String public var posts: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, username: String, - posts: List? = []) { + posts: List? = [] + ) { self.id = id self.username = username self.posts = posts diff --git a/AmplifyTestCommon/Models/Collection/6/Blog6+Schema.swift b/AmplifyTestCommon/Models/Collection/6/Blog6+Schema.swift index fc6b58b600..af044289e0 100644 --- a/AmplifyTestCommon/Models/Collection/6/Blog6+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/6/Blog6+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Blog6 { +public extension Blog6 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case posts } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let blog6 = Blog6.keys model.listPluralName = "Blog6s" diff --git a/AmplifyTestCommon/Models/Collection/6/Blog6.swift b/AmplifyTestCommon/Models/Collection/6/Blog6.swift index 9bc903c6d4..d226a82190 100644 --- a/AmplifyTestCommon/Models/Collection/6/Blog6.swift +++ b/AmplifyTestCommon/Models/Collection/6/Blog6.swift @@ -14,9 +14,11 @@ public struct Blog6: Model { public var name: String public var posts: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String, - posts: List? = []) { + posts: List? = [] + ) { self.id = id self.name = name self.posts = posts diff --git a/AmplifyTestCommon/Models/Collection/6/Comment6+Schema.swift b/AmplifyTestCommon/Models/Collection/6/Comment6+Schema.swift index 3d180ac245..ef05fae7ca 100644 --- a/AmplifyTestCommon/Models/Collection/6/Comment6+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/6/Comment6+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Comment6 { +public extension Comment6 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case post case content } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment6 = Comment6.keys model.listPluralName = "Comment6s" diff --git a/AmplifyTestCommon/Models/Collection/6/Comment6.swift b/AmplifyTestCommon/Models/Collection/6/Comment6.swift index 061c288aa1..960b55edd1 100644 --- a/AmplifyTestCommon/Models/Collection/6/Comment6.swift +++ b/AmplifyTestCommon/Models/Collection/6/Comment6.swift @@ -14,9 +14,11 @@ public struct Comment6: Model { public var post: Post6? public var content: String - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, post: Post6? = nil, - content: String) { + content: String + ) { self.id = id self.post = post self.content = content diff --git a/AmplifyTestCommon/Models/Collection/6/Post6+Schema.swift b/AmplifyTestCommon/Models/Collection/6/Post6+Schema.swift index e84aa85350..24956ef8f6 100644 --- a/AmplifyTestCommon/Models/Collection/6/Post6+Schema.swift +++ b/AmplifyTestCommon/Models/Collection/6/Post6+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Post6 { +public extension Post6 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case blog case comments } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post6 = Post6.keys model.listPluralName = "Post6s" diff --git a/AmplifyTestCommon/Models/Collection/6/Post6.swift b/AmplifyTestCommon/Models/Collection/6/Post6.swift index a470246a15..122eebf379 100644 --- a/AmplifyTestCommon/Models/Collection/6/Post6.swift +++ b/AmplifyTestCommon/Models/Collection/6/Post6.swift @@ -15,10 +15,12 @@ public struct Post6: Model { public var blog: Blog6? public var comments: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, blog: Blog6? = nil, - comments: List? = []) { + comments: List? = [] + ) { self.id = id self.title = title self.blog = blog diff --git a/AmplifyTestCommon/Models/Comment+Schema.swift b/AmplifyTestCommon/Models/Comment+Schema.swift index fe7813fada..b4395dc4b5 100644 --- a/AmplifyTestCommon/Models/Comment+Schema.swift +++ b/AmplifyTestCommon/Models/Comment+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Comment { +public extension Comment { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case createdAt case post } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment = Comment.keys model.listPluralName = "Comments" @@ -35,9 +35,9 @@ extension Comment { ) } - public class Path : ModelPath {} + class Path: ModelPath {} - public static var rootPath: PropertyContainerPath? { Path() } + static var rootPath: PropertyContainerPath? { Path() } } diff --git a/AmplifyTestCommon/Models/Comment.swift b/AmplifyTestCommon/Models/Comment.swift index 2f223e38aa..77e6c97d2a 100644 --- a/AmplifyTestCommon/Models/Comment.swift +++ b/AmplifyTestCommon/Models/Comment.swift @@ -13,31 +13,33 @@ public struct Comment: Model { public let id: String public var content: String public var createdAt: Temporal.DateTime - internal var _post: LazyReference + var _post: LazyReference public var post: Post { get async throws { try await _post.require() } } - - public init(id: String = UUID().uuidString, - content: String, - createdAt: Temporal.DateTime, - post: Post) { + + public init( + id: String = UUID().uuidString, + content: String, + createdAt: Temporal.DateTime, + post: Post + ) { self.id = id self.content = content self.createdAt = createdAt self._post = LazyReference(post) } - + public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - id = try values.decode(String.self, forKey: .id) - content = try values.decode(String.self, forKey: .content) - createdAt = try values.decode(Temporal.DateTime.self, forKey: .createdAt) - _post = try values.decode(LazyReference.self, forKey: .post) + self.id = try values.decode(String.self, forKey: .id) + self.content = try values.decode(String.self, forKey: .content) + self.createdAt = try values.decode(Temporal.DateTime.self, forKey: .createdAt) + self._post = try values.decode(LazyReference.self, forKey: .post) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey+Schema.swift index ced19ca608..669e370130 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CommentWithCompositeKey { +public extension CommentWithCompositeKey { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -19,10 +19,10 @@ extension CommentWithCompositeKey { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let commentWithCompositeKey = CommentWithCompositeKey.keys model.pluralName = "CommentWithCompositeKeys" @@ -47,9 +47,11 @@ extension CommentWithCompositeKey: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension CommentWithCompositeKey.IdentifierProtocol { - public static func identifier(id: String, - content: String) -> Self { +public extension CommentWithCompositeKey.IdentifierProtocol { + static func identifier( + id: String, + content: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "content", value: content)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey.swift index e29a37c037..e634f7e71a 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKey.swift @@ -16,20 +16,26 @@ public struct CommentWithCompositeKey: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String, - post: PostWithCompositeKey? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String, + post: PostWithCompositeKey? = nil + ) { + self.init( + id: id, content: content, post: post, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String, - post: PostWithCompositeKey? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String, + post: PostWithCompositeKey? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex+Schema.swift index 49d6789653..fae7029627 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CommentWithCompositeKeyAndIndex { +public extension CommentWithCompositeKeyAndIndex { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -19,10 +19,10 @@ extension CommentWithCompositeKeyAndIndex { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let commentWithCompositeKeyAndIndex = CommentWithCompositeKeyAndIndex.keys model.pluralName = "CommentWithCompositeKeyAndIndices" @@ -48,9 +48,11 @@ extension CommentWithCompositeKeyAndIndex: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension CommentWithCompositeKeyAndIndex.IdentifierProtocol { - public static func identifier(id: String, - content: String) -> Self { +public extension CommentWithCompositeKeyAndIndex.IdentifierProtocol { + static func identifier( + id: String, + content: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "content", value: content)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex.swift index 64742b54bc..595f98fa30 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyAndIndex.swift @@ -16,20 +16,26 @@ public struct CommentWithCompositeKeyAndIndex: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String, - post: PostWithCompositeKeyAndIndex? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String, + post: PostWithCompositeKeyAndIndex? = nil + ) { + self.init( + id: id, content: content, post: post, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String, - post: PostWithCompositeKeyAndIndex? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String, + post: PostWithCompositeKeyAndIndex? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional+Schema.swift index 91a30cf9de..4db364f449 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CommentWithCompositeKeyUnidirectional { +public extension CommentWithCompositeKeyUnidirectional { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case createdAt @@ -20,10 +20,10 @@ extension CommentWithCompositeKeyUnidirectional { case postWithCompositeKeyUnidirectionalCommentsTitle } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let commentWithCompositeKeyUnidirectional = CommentWithCompositeKeyUnidirectional.keys model.pluralName = "CommentWithCompositeKeyUnidirectionals" @@ -49,9 +49,11 @@ extension CommentWithCompositeKeyUnidirectional: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension CommentWithCompositeKeyUnidirectional.IdentifierProtocol { - public static func identifier(id: String, - content: String) -> Self { +public extension CommentWithCompositeKeyUnidirectional.IdentifierProtocol { + static func identifier( + id: String, + content: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "content", value: content)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional.swift index 23617b6d3e..d3ea55a904 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/CommentWithCompositeKeyUnidirectional.swift @@ -17,23 +17,29 @@ public struct CommentWithCompositeKeyUnidirectional: Model { public var postWithCompositeKeyUnidirectionalCommentsId: String? public var postWithCompositeKeyUnidirectionalCommentsTitle: String? - public init(id: String = UUID().uuidString, - content: String, - post21CommentsId: String? = nil, - post21CommentsTitle: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String, + post21CommentsId: String? = nil, + post21CommentsTitle: String? = nil + ) { + self.init( + id: id, content: content, createdAt: nil, updatedAt: nil, postWithCompositeKeyUnidirectionalCommentsId: post21CommentsId, - postWithCompositeKeyUnidirectionalCommentsTitle: post21CommentsTitle) + postWithCompositeKeyUnidirectionalCommentsTitle: post21CommentsTitle + ) } - internal init(id: String = UUID().uuidString, - content: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil, - postWithCompositeKeyUnidirectionalCommentsId: String? = nil, - postWithCompositeKeyUnidirectionalCommentsTitle: String? = nil) { + init( + id: String = UUID().uuidString, + content: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil, + postWithCompositeKeyUnidirectionalCommentsId: String? = nil, + postWithCompositeKeyUnidirectionalCommentsTitle: String? = nil + ) { self.id = id self.content = content self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk+Schema.swift index 5668fa4b33..668ee06320 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension ModelCompositeIntPk { +public extension ModelCompositeIntPk { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case serial case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelCompositeIntPk = ModelCompositeIntPk.keys model.pluralName = "ModelCompositeIntPks" @@ -46,8 +46,8 @@ extension ModelCompositeIntPk: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelCompositeIntPk.IdentifierProtocol { - public static func identifier(id: String, serial: Int) -> Self { +public extension ModelCompositeIntPk.IdentifierProtocol { + static func identifier(id: String, serial: Int) -> Self { .make(fields: [(name: "id", value: id), (name: "serial", value: serial)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk.swift index e0bd650570..1af43fb97a 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositeIntPk.swift @@ -15,17 +15,23 @@ public struct ModelCompositeIntPk: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - serial: Int) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + serial: Int + ) { + self.init( + id: id, serial: serial, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - serial: Int, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + serial: Int, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.serial = serial self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk+Schema.swift index a827c2fed6..05f6abd46e 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ModelCompositePk { +public extension ModelCompositePk { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dob case name @@ -19,10 +19,10 @@ extension ModelCompositePk { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelCompositePk = ModelCompositePk.keys model.pluralName = "ModelCompositePks" @@ -32,11 +32,11 @@ extension ModelCompositePk { ) model.fields( - .field(modelCompositePk.id, is: .required, ofType: .string), - .field(modelCompositePk.dob, is: .required, ofType: .dateTime), - .field(modelCompositePk.name, is: .optional, ofType: .string), - .field(modelCompositePk.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), - .field(modelCompositePk.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) + .field(modelCompositePk.id, is: .required, ofType: .string), + .field(modelCompositePk.dob, is: .required, ofType: .dateTime), + .field(modelCompositePk.name, is: .optional, ofType: .string), + .field(modelCompositePk.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), + .field(modelCompositePk.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) } } @@ -46,8 +46,8 @@ extension ModelCompositePk: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelCompositePk.IdentifierProtocol { - public static func identifier(id: String, dob: Temporal.DateTime) -> Self { +public extension ModelCompositePk.IdentifierProtocol { + static func identifier(id: String, dob: Temporal.DateTime) -> Self { .make(fields: [(name: "id", value: id), (name: "dob", value: dob)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk.swift index 755bfa19d2..98ce1635fa 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePk.swift @@ -16,20 +16,26 @@ public struct ModelCompositePk: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil + ) { + self.init( + id: id, dob: dob, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.dob = dob self.name = name diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo+Schema.swift index 525ecc5ce5..15d8123b26 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ModelCompositePkBelongsTo { +public extension ModelCompositePkBelongsTo { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dob case owner @@ -20,10 +20,10 @@ extension ModelCompositePkBelongsTo { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelCompositePkBelongsTo = ModelCompositePkBelongsTo.keys model.pluralName = "ModelCompositePkBelongsTos" @@ -33,17 +33,20 @@ extension ModelCompositePkBelongsTo { ) model.fields( - .field(modelCompositePkBelongsTo.id, is: .required, ofType: .string), - .field(modelCompositePkBelongsTo.dob, is: .required, ofType: .dateTime), - .field(modelCompositePkBelongsTo.name, is: .optional, ofType: .string), - .belongsTo(modelCompositePkBelongsTo.owner, is: .optional, - ofType: ModelCompositePkWithAssociation.self, - targetNames: [ - "modelCompositePkWithAssociationOtherModelsId", - "modelCompositePkWithAssociationOtherModelsDob" - ]), - .field(modelCompositePkBelongsTo.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), - .field(modelCompositePkBelongsTo.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) + .field(modelCompositePkBelongsTo.id, is: .required, ofType: .string), + .field(modelCompositePkBelongsTo.dob, is: .required, ofType: .dateTime), + .field(modelCompositePkBelongsTo.name, is: .optional, ofType: .string), + .belongsTo( + modelCompositePkBelongsTo.owner, + is: .optional, + ofType: ModelCompositePkWithAssociation.self, + targetNames: [ + "modelCompositePkWithAssociationOtherModelsId", + "modelCompositePkWithAssociationOtherModelsDob" + ] + ), + .field(modelCompositePkBelongsTo.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), + .field(modelCompositePkBelongsTo.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) } } @@ -53,8 +56,8 @@ extension ModelCompositePkBelongsTo: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelCompositePkBelongsTo.IdentifierProtocol { - public static func identifier(id: String, dob: Temporal.DateTime) -> Self { +public extension ModelCompositePkBelongsTo.IdentifierProtocol { + static func identifier(id: String, dob: Temporal.DateTime) -> Self { .make(fields: [(name: "id", value: id), (name: "dob", value: dob)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo.swift index 4d4817d0fc..8d9963a420 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkBelongsTo.swift @@ -17,23 +17,29 @@ public struct ModelCompositePkBelongsTo: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - owner: ModelCompositePkWithAssociation? = nil) { - self.init(id: id, - dob: dob, - name: name, - owner: owner, - createdAt: nil, - updatedAt: nil) + public init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + owner: ModelCompositePkWithAssociation? = nil + ) { + self.init( + id: id, + dob: dob, + name: name, + owner: owner, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - owner: ModelCompositePkWithAssociation? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + owner: ModelCompositePkWithAssociation? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.dob = dob self.name = name diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation+Schema.swift index cbb3bc7f85..0ad5807f7e 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ModelCompositePkWithAssociation { +public extension ModelCompositePkWithAssociation { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dob case name @@ -20,10 +20,10 @@ extension ModelCompositePkWithAssociation { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelCompositePkWithAssociation = ModelCompositePkWithAssociation.keys model.pluralName = "ModelCompositePkWithAssociations" @@ -36,10 +36,12 @@ extension ModelCompositePkWithAssociation { .field(modelCompositePkWithAssociation.id, is: .required, ofType: .string), .field(modelCompositePkWithAssociation.dob, is: .required, ofType: .dateTime), .field(modelCompositePkWithAssociation.name, is: .optional, ofType: .string), - .hasMany(modelCompositePkWithAssociation.otherModels, - is: .optional, - ofType: ModelCompositePkBelongsTo.self, - associatedWith: ModelCompositePkBelongsTo.keys.owner), + .hasMany( + modelCompositePkWithAssociation.otherModels, + is: .optional, + ofType: ModelCompositePkBelongsTo.self, + associatedWith: ModelCompositePkBelongsTo.keys.owner + ), .field(modelCompositePkWithAssociation.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), .field(modelCompositePkWithAssociation.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) @@ -51,8 +53,8 @@ extension ModelCompositePkWithAssociation: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelCompositePkWithAssociation.IdentifierProtocol { - public static func identifier(id: String, dob: Temporal.DateTime) -> Self { +public extension ModelCompositePkWithAssociation.IdentifierProtocol { + static func identifier(id: String, dob: Temporal.DateTime) -> Self { .make(fields: [(name: "id", value: id), (name: "dob", value: dob)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation.swift index 810e0e9a3f..ece232844f 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCompositePkWithAssociation.swift @@ -17,23 +17,29 @@ public struct ModelCompositePkWithAssociation: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - otherModels: List? = []) { - self.init(id: id, - dob: dob, - name: name, - otherModels: otherModels, - createdAt: nil, - updatedAt: nil) + public init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + otherModels: List? = [] + ) { + self.init( + id: id, + dob: dob, + name: name, + otherModels: otherModels, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - otherModels: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + otherModels: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.dob = dob self.name = name diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPKDefined.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPKDefined.swift index 651ae307db..e658cbc193 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPKDefined.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPKDefined.swift @@ -16,20 +16,26 @@ public struct ModelCustomPkDefined: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil + ) { + self.init( + id: id, dob: dob, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - name: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + name: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.dob = dob self.name = name diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPkDefined+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPkDefined+Schema.swift index 49c4b706a5..11809bb3f1 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPkDefined+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelCustomPkDefined+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ModelCustomPkDefined { +public extension ModelCustomPkDefined { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dob case name @@ -19,10 +19,10 @@ extension ModelCustomPkDefined { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelCompositePk = ModelCustomPkDefined.keys model.pluralName = "ModelCustomPkDefined" @@ -48,8 +48,8 @@ extension ModelCustomPkDefined: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelCustomPkDefined.IdentifierProtocol { - public static func identifier(id: String, dob: Temporal.DateTime) -> Self { +public extension ModelCustomPkDefined.IdentifierProtocol { + static func identifier(id: String, dob: Temporal.DateTime) -> Self { .make(fields: [(name: "id", value: id), (name: "dob", value: dob)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk+Schema.swift index 8ea03e2dc2..e357caf01b 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension ModelExplicitCustomPk { +public extension ModelExplicitCustomPk { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case userId case name case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelExplicitCustomPk = ModelExplicitCustomPk.keys model.pluralName = "ModelExplicitCustomPks" @@ -44,8 +44,8 @@ extension ModelExplicitCustomPk: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelExplicitCustomPk.IdentifierProtocol { - public static func identifier(userId: String) -> Self { +public extension ModelExplicitCustomPk.IdentifierProtocol { + static func identifier(userId: String) -> Self { .make(fields: [(name: "userId", value: userId)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk.swift index e1f809db6a..ac88946c3c 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitCustomPk.swift @@ -16,15 +16,19 @@ public struct ModelExplicitCustomPk: Model { public var updatedAt: Temporal.DateTime? public init(userId: String, name: String? = nil) { - self.init(userId: userId, - name: name, - createdAt: nil, - updatedAt: nil) + self.init( + userId: userId, + name: name, + createdAt: nil, + updatedAt: nil + ) } - internal init(userId: String, - name: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + userId: String, + name: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.userId = userId self.name = name self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk+Schema.swift index e7de2f2f80..fda645c5ba 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension ModelExplicitDefaultPk { +public extension ModelExplicitDefaultPk { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelExplicitDefaultPk = ModelExplicitDefaultPk.keys model.pluralName = "ModelExplicitDefaultPks" @@ -44,8 +44,8 @@ extension ModelExplicitDefaultPk: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension ModelExplicitDefaultPk.IdentifierProtocol { - public static func identifier(id: String) -> Self { +public extension ModelExplicitDefaultPk.IdentifierProtocol { + static func identifier(id: String) -> Self { .make(fields: [(name: "id", value: id)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk.swift index cd44b3b9e7..880c718eff 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelExplicitDefaultPk.swift @@ -15,17 +15,23 @@ public struct ModelExplicitDefaultPk: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String? = nil + ) { + self.init( + id: id, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk+Schema.swift index 9519e91e03..c92e102327 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension ModelImplicitDefaultPk { +public extension ModelImplicitDefaultPk { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let modelImplicitDefaultPk = ModelImplicitDefaultPk.keys model.pluralName = "ModelImplicitDefaultPks" diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk.swift index 57bb5def66..69fa2b17dc 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/ModelImplicitDefaultPk.swift @@ -15,17 +15,23 @@ public struct ModelImplicitDefaultPk: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String? = nil + ) { + self.init( + id: id, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey+Schema.swift index a78c515f67..f33472de51 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostTagsWithCompositeKey { +public extension PostTagsWithCompositeKey { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case postWithTagsCompositeKey case tagWithCompositeKey @@ -19,10 +19,10 @@ extension PostTagsWithCompositeKey { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postTagsWithCompositeKey = PostTagsWithCompositeKey.keys model.pluralName = "PostTagsWithCompositeKeys" diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey.swift index 1686ec3e48..9bf3f2b9e0 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostTagsWithCompositeKey.swift @@ -16,20 +16,26 @@ public struct PostTagsWithCompositeKey: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - postWithTagsCompositeKey: PostWithTagsCompositeKey, - tagWithCompositeKey: TagWithCompositeKey) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + postWithTagsCompositeKey: PostWithTagsCompositeKey, + tagWithCompositeKey: TagWithCompositeKey + ) { + self.init( + id: id, postWithTagsCompositeKey: postWithTagsCompositeKey, tagWithCompositeKey: tagWithCompositeKey, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - postWithTagsCompositeKey: PostWithTagsCompositeKey, - tagWithCompositeKey: TagWithCompositeKey, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + postWithTagsCompositeKey: PostWithTagsCompositeKey, + tagWithCompositeKey: TagWithCompositeKey, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.postWithTagsCompositeKey = postWithTagsCompositeKey self.tagWithCompositeKey = tagWithCompositeKey diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey+Schema.swift index d06ac91c7f..9a89d20bfe 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostWithCompositeKey { +public extension PostWithCompositeKey { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension PostWithCompositeKey { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post22 = PostWithCompositeKey.keys model.pluralName = "PostWithCompositeKeys" @@ -47,9 +47,11 @@ extension PostWithCompositeKey: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension PostWithCompositeKey.IdentifierProtocol { - public static func identifier(id: String, - title: String) -> Self { +public extension PostWithCompositeKey.IdentifierProtocol { + static func identifier( + id: String, + title: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "title", value: title)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey.swift index 16bd0ce395..ac441cae5d 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKey.swift @@ -16,20 +16,26 @@ public struct PostWithCompositeKey: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex+Schema.swift index be2161d7ba..16b1d5f5c1 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostWithCompositeKeyAndIndex { +public extension PostWithCompositeKeyAndIndex { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension PostWithCompositeKeyAndIndex { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postWithCompositeKeyAndIndex = PostWithCompositeKeyAndIndex.keys model.pluralName = "PostWithCompositeKeyAndIndices" @@ -47,9 +47,11 @@ extension PostWithCompositeKeyAndIndex: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension PostWithCompositeKeyAndIndex.IdentifierProtocol { - public static func identifier(id: String, - title: String) -> Self { +public extension PostWithCompositeKeyAndIndex.IdentifierProtocol { + static func identifier( + id: String, + title: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "title", value: title)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex.swift index d642b4b980..f190c30706 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyAndIndex.swift @@ -16,20 +16,26 @@ public struct PostWithCompositeKeyAndIndex: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional+Schema.swift index 3148b8c002..644cc6a816 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostWithCompositeKeyUnidirectional { +public extension PostWithCompositeKeyUnidirectional { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension PostWithCompositeKeyUnidirectional { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postWithCompositeKeyUnidirectional = PostWithCompositeKeyUnidirectional.keys model.pluralName = "PostWithCompositeKeyUnidirectionals" @@ -35,10 +35,12 @@ extension PostWithCompositeKeyUnidirectional { model.fields( .field(postWithCompositeKeyUnidirectional.id, is: .required, ofType: .string), .field(postWithCompositeKeyUnidirectional.title, is: .required, ofType: .string), - .hasMany(postWithCompositeKeyUnidirectional.comments, - is: .optional, - ofType: CommentWithCompositeKeyUnidirectional.self, - associatedWith: CommentWithCompositeKeyUnidirectional.keys.postWithCompositeKeyUnidirectionalCommentsId), + .hasMany( + postWithCompositeKeyUnidirectional.comments, + is: .optional, + ofType: CommentWithCompositeKeyUnidirectional.self, + associatedWith: CommentWithCompositeKeyUnidirectional.keys.postWithCompositeKeyUnidirectionalCommentsId + ), .field(postWithCompositeKeyUnidirectional.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), .field(postWithCompositeKeyUnidirectional.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) @@ -50,9 +52,11 @@ extension PostWithCompositeKeyUnidirectional: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension PostWithCompositeKeyUnidirectional.IdentifierProtocol { - public static func identifier(id: String, - title: String) -> Self { +public extension PostWithCompositeKeyUnidirectional.IdentifierProtocol { + static func identifier( + id: String, + title: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "title", value: title)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional.swift index 23bffde135..822c27b88e 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithCompositeKeyUnidirectional.swift @@ -16,20 +16,26 @@ public struct PostWithCompositeKeyUnidirectional: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey+Schema.swift index e1a30d6816..c2d50bd16a 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostWithTagsCompositeKey { +public extension PostWithTagsCompositeKey { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case postId case title case tags @@ -19,10 +19,10 @@ extension PostWithTagsCompositeKey { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postWithTagsCompositeKey = PostWithTagsCompositeKey.keys model.pluralName = "PostWithTagsCompositeKeys" @@ -47,9 +47,11 @@ extension PostWithTagsCompositeKey: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension PostWithTagsCompositeKey.IdentifierProtocol { - public static func identifier(postId: String, - title: String) -> Self { +public extension PostWithTagsCompositeKey.IdentifierProtocol { + static func identifier( + postId: String, + title: String + ) -> Self { .make(fields: [(name: "postId", value: postId), (name: "title", value: title)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey.swift index 65baeac282..73e3e3cd7c 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/PostWithTagsCompositeKey.swift @@ -16,20 +16,26 @@ public struct PostWithTagsCompositeKey: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(postId: String, - title: String, - tags: List? = []) { - self.init(postId: postId, + public init( + postId: String, + title: String, + tags: List? = [] + ) { + self.init( + postId: postId, title: title, tags: tags, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(postId: String, - title: String, - tags: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + postId: String, + title: String, + tags: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.postId = postId self.title = title self.tags = tags diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey+Schema.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey+Schema.swift index 4d65058a00..9332ae93d1 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey+Schema.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension TagWithCompositeKey { +public extension TagWithCompositeKey { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case posts @@ -19,10 +19,10 @@ extension TagWithCompositeKey { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let tagWithCompositeKey = TagWithCompositeKey.keys model.pluralName = "TagWithCompositeKeys" @@ -47,9 +47,11 @@ extension TagWithCompositeKey: ModelIdentifiable { public typealias IdentifierProtocol = ModelIdentifier } -extension TagWithCompositeKey.IdentifierProtocol { - public static func identifier(id: String, - name: String) -> Self { +public extension TagWithCompositeKey.IdentifierProtocol { + static func identifier( + id: String, + name: String + ) -> Self { .make(fields: [(name: "id", value: id), (name: "name", value: name)]) } } diff --git a/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey.swift b/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey.swift index 0c3a360868..b913c944db 100644 --- a/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey.swift +++ b/AmplifyTestCommon/Models/CustomPrimaryKey/TagWithCompositeKey.swift @@ -16,20 +16,26 @@ public struct TagWithCompositeKey: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - posts: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + posts: List? = [] + ) { + self.init( + id: id, name: name, posts: posts, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - posts: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + posts: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.posts = posts diff --git a/AmplifyTestCommon/Models/CustomerOrder+Schema.swift b/AmplifyTestCommon/Models/CustomerOrder+Schema.swift index c672f13325..a72bfa93f0 100644 --- a/AmplifyTestCommon/Models/CustomerOrder+Schema.swift +++ b/AmplifyTestCommon/Models/CustomerOrder+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension CustomerOrder { +public extension CustomerOrder { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case orderId case email } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let customerOrder = CustomerOrder.keys model.listPluralName = "CustomerOrders" diff --git a/AmplifyTestCommon/Models/CustomerOrder.swift b/AmplifyTestCommon/Models/CustomerOrder.swift index 92609d0848..2e3472728a 100644 --- a/AmplifyTestCommon/Models/CustomerOrder.swift +++ b/AmplifyTestCommon/Models/CustomerOrder.swift @@ -22,9 +22,11 @@ public struct CustomerOrder: Model { public var orderId: String public var email: String - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, orderId: String, - email: String) { + email: String + ) { self.id = id self.orderId = orderId self.email = email diff --git a/AmplifyTestCommon/Models/Deprecated/DeprecatedTodo.swift b/AmplifyTestCommon/Models/Deprecated/DeprecatedTodo.swift index 2e364e24d6..53a88d40c5 100644 --- a/AmplifyTestCommon/Models/Deprecated/DeprecatedTodo.swift +++ b/AmplifyTestCommon/Models/Deprecated/DeprecatedTodo.swift @@ -8,6 +8,7 @@ // swiftlint:disable all import Amplify import Foundation + /* The schema used to codegen this model: type DeprecatedTodo @model { @@ -30,27 +31,29 @@ public struct DeprecatedTodo: Model { public var description: String? public var note: Note? - public init(id: String = UUID().uuidString, - description: String? = nil, - note: Note? = nil) { + public init( + id: String = UUID().uuidString, + description: String? = nil, + note: Note? = nil + ) { self.id = id self.description = description self.note = note } } -extension DeprecatedTodo { +public extension DeprecatedTodo { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case description case note } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let deprecatedTodo = DeprecatedTodo.keys model.pluralName = "DeprecatedTodos" diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost+Schema.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost+Schema.swift index 7d700109e9..c9a94931a5 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost+Schema.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension M2MPost { +public extension M2MPost { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case editors } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let m2MPost = M2MPost.keys model.listPluralName = "M2MPosts" diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost.swift index 38b678400f..12862030b3 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPost.swift @@ -14,9 +14,11 @@ public struct M2MPost: Model { public var title: String public var editors: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - editors: List? = []) { + editors: List? = [] + ) { self.id = id self.title = title self.editors = editors diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor+Schema.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor+Schema.swift index 7c48259298..d37c0719cb 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor+Schema.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension M2MPostEditor { +public extension M2MPostEditor { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case post case editor } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let m2MPostEditor = M2MPostEditor.keys model.listPluralName = "M2MPostEditors" diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor.swift index f90b4ec386..2cfd57b223 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MPostEditor.swift @@ -14,9 +14,11 @@ public struct M2MPostEditor: Model { public var post: M2MPost public var editor: M2MUser - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, post: M2MPost, - editor: M2MUser) { + editor: M2MUser + ) { self.id = id self.post = post self.editor = editor diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser+Schema.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser+Schema.swift index 452ca2b270..1db74f78b5 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser+Schema.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension M2MUser { +public extension M2MUser { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case username case posts } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let m2MUser = M2MUser.keys model.listPluralName = "M2MUsers" diff --git a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser.swift b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser.swift index 076f5fb3b5..4c62eb0f75 100644 --- a/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser.swift +++ b/AmplifyTestCommon/Models/M2MPostEditorUser/M2MUser.swift @@ -14,9 +14,11 @@ public struct M2MUser: Model { public var username: String public var posts: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, username: String, - posts: List? = []) { + posts: List? = [] + ) { self.id = id self.username = username self.posts = posts diff --git a/AmplifyTestCommon/Models/NonModel/Category.swift b/AmplifyTestCommon/Models/NonModel/Category.swift index 277b136bf2..3f5375f2db 100644 --- a/AmplifyTestCommon/Models/NonModel/Category.swift +++ b/AmplifyTestCommon/Models/NonModel/Category.swift @@ -14,18 +14,20 @@ public struct Category: Embeddable { var color: Color } -extension Category { +public extension Category { - public enum CodingKeys: CodingKey { + enum CodingKeys: CodingKey { case name case color } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self - public static let schema = defineSchema { embedded in + static let schema = defineSchema { embedded in let category = Category.keys - embedded.fields(.field(category.name, is: .required, ofType: .string), - .field(category.color, is: .required, ofType: .embedded(type: Color.self))) + embedded.fields( + .field(category.name, is: .required, ofType: .string), + .field(category.color, is: .required, ofType: .embedded(type: Color.self)) + ) } } diff --git a/AmplifyTestCommon/Models/NonModel/Color.swift b/AmplifyTestCommon/Models/NonModel/Color.swift index 793b6a6844..be00159e03 100644 --- a/AmplifyTestCommon/Models/NonModel/Color.swift +++ b/AmplifyTestCommon/Models/NonModel/Color.swift @@ -16,21 +16,23 @@ public struct Color: Embeddable { var blue: Int } -extension Color { - public enum CodingKeys: CodingKey { +public extension Color { + enum CodingKeys: CodingKey { case name case red case green case blue } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self - public static let schema = defineSchema { embedded in + static let schema = defineSchema { embedded in let color = Color.keys - embedded.fields(.field(color.name, is: .required, ofType: .string), - .field(color.red, is: .required, ofType: .int), - .field(color.green, is: .required, ofType: .int), - .field(color.blue, is: .required, ofType: .int)) + embedded.fields( + .field(color.name, is: .required, ofType: .string), + .field(color.red, is: .required, ofType: .int), + .field(color.green, is: .required, ofType: .int), + .field(color.blue, is: .required, ofType: .int) + ) } } diff --git a/AmplifyTestCommon/Models/NonModel/DynamicEmbedded.swift b/AmplifyTestCommon/Models/NonModel/DynamicEmbedded.swift index 2636100012..dbe3743464 100644 --- a/AmplifyTestCommon/Models/NonModel/DynamicEmbedded.swift +++ b/AmplifyTestCommon/Models/NonModel/DynamicEmbedded.swift @@ -18,7 +18,7 @@ struct DynamicEmbedded: Embeddable, JSONValueHolder { public init(from decoder: Decoder) throws { let json = try JSONValue(from: decoder) if case .object(let jsonValue) = json { - values = jsonValue + self.values = jsonValue } else { self.values = [:] } diff --git a/AmplifyTestCommon/Models/NonModel/DynamicModel.swift b/AmplifyTestCommon/Models/NonModel/DynamicModel.swift index a88cfeb7fe..c2207d7e1d 100644 --- a/AmplifyTestCommon/Models/NonModel/DynamicModel.swift +++ b/AmplifyTestCommon/Models/NonModel/DynamicModel.swift @@ -21,10 +21,10 @@ struct DynamicModel: Model, JSONValueHolder { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - id = try container.decode(String.self, forKey: .id) + self.id = try container.decode(String.self, forKey: .id) let json = try JSONValue(from: decoder) if case .object(let jsonValues) = json { - values = jsonValues + self.values = jsonValues } else { self.values = [:] } diff --git a/AmplifyTestCommon/Models/NonModel/Section.swift b/AmplifyTestCommon/Models/NonModel/Section.swift index 0ffd42eb2f..2686d17849 100644 --- a/AmplifyTestCommon/Models/NonModel/Section.swift +++ b/AmplifyTestCommon/Models/NonModel/Section.swift @@ -14,17 +14,19 @@ public struct Section: Embeddable { var number: Double } -extension Section { - public enum CodingKeys: CodingKey { +public extension Section { + enum CodingKeys: CodingKey { case name case number } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self - public static let schema = defineSchema { embedded in + static let schema = defineSchema { embedded in let section = Section.keys - embedded.fields(.field(section.name, is: .required, ofType: .string), - .field(section.number, is: .required, ofType: .double)) + embedded.fields( + .field(section.name, is: .required, ofType: .string), + .field(section.number, is: .required, ofType: .double) + ) } } diff --git a/AmplifyTestCommon/Models/NonModel/Todo+Schema.swift b/AmplifyTestCommon/Models/NonModel/Todo+Schema.swift index d53b4c0e07..75a2e93363 100644 --- a/AmplifyTestCommon/Models/NonModel/Todo+Schema.swift +++ b/AmplifyTestCommon/Models/NonModel/Todo+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Todo { +public extension Todo { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case description @@ -20,10 +20,10 @@ extension Todo { case stickies } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let todo = Todo.keys model.listPluralName = "Todos" diff --git a/AmplifyTestCommon/Models/NonModel/Todo.swift b/AmplifyTestCommon/Models/NonModel/Todo.swift index 423f2aa568..58eb250fcf 100644 --- a/AmplifyTestCommon/Models/NonModel/Todo.swift +++ b/AmplifyTestCommon/Models/NonModel/Todo.swift @@ -8,6 +8,7 @@ // swiftlint:disable all import Amplify import Foundation + /* The schema used to codegen this model: type Todo @model { @@ -45,12 +46,14 @@ public struct Todo: Model { public var section: Section? public var stickies: [String]? - public init(id: String = UUID().uuidString, - name: String, - description: String? = nil, - categories: [Category]? = [], - section: Section? = nil, - stickies: [String]? = []) { + public init( + id: String = UUID().uuidString, + name: String, + description: String? = nil, + categories: [Category]? = [], + section: Section? = nil, + stickies: [String]? = [] + ) { self.id = id self.name = name self.description = description diff --git a/AmplifyTestCommon/Models/OGCScenarioBMGroupPost+Schema.swift b/AmplifyTestCommon/Models/OGCScenarioBMGroupPost+Schema.swift index 69170decb4..9a31e531e8 100644 --- a/AmplifyTestCommon/Models/OGCScenarioBMGroupPost+Schema.swift +++ b/AmplifyTestCommon/Models/OGCScenarioBMGroupPost+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension OGCScenarioBMGroupPost { +public extension OGCScenarioBMGroupPost { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case owner } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let oGCScenarioBMGroupPost = OGCScenarioBMGroupPost.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/OGCScenarioBMGroupPost.swift b/AmplifyTestCommon/Models/OGCScenarioBMGroupPost.swift index 64ab04bf3f..7b07808b60 100644 --- a/AmplifyTestCommon/Models/OGCScenarioBMGroupPost.swift +++ b/AmplifyTestCommon/Models/OGCScenarioBMGroupPost.swift @@ -14,9 +14,11 @@ public struct OGCScenarioBMGroupPost: Model { public var title: String public var owner: String? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - owner: String? = nil) { + owner: String? = nil + ) { self.id = id self.title = title self.owner = owner diff --git a/AmplifyTestCommon/Models/OGCScenarioBPost+Schema.swift b/AmplifyTestCommon/Models/OGCScenarioBPost+Schema.swift index 2a3c67066f..bf69f585ca 100644 --- a/AmplifyTestCommon/Models/OGCScenarioBPost+Schema.swift +++ b/AmplifyTestCommon/Models/OGCScenarioBPost+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension OGCScenarioBPost { +public extension OGCScenarioBPost { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case owner } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let oGCScenarioBPost = OGCScenarioBPost.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/OGCScenarioBPost.swift b/AmplifyTestCommon/Models/OGCScenarioBPost.swift index 5ee8d97fb9..b49ef50072 100644 --- a/AmplifyTestCommon/Models/OGCScenarioBPost.swift +++ b/AmplifyTestCommon/Models/OGCScenarioBPost.swift @@ -14,9 +14,11 @@ public struct OGCScenarioBPost: Model { public var title: String public var owner: String? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - owner: String? = nil) { + owner: String? = nil + ) { self.id = id self.title = title self.owner = owner diff --git a/AmplifyTestCommon/Models/Post+Schema.swift b/AmplifyTestCommon/Models/Post+Schema.swift index f60062941d..b79e38ead4 100644 --- a/AmplifyTestCommon/Models/Post+Schema.swift +++ b/AmplifyTestCommon/Models/Post+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post { +public extension Post { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case content @@ -23,10 +23,10 @@ extension Post { case comments } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post = Post.keys model.listPluralName = "Posts" @@ -45,9 +45,9 @@ extension Post { ) } - public class Path : ModelPath {} + class Path: ModelPath {} - public static var rootPath: PropertyContainerPath? { Path() } + static var rootPath: PropertyContainerPath? { Path() } } diff --git a/AmplifyTestCommon/Models/Post.swift b/AmplifyTestCommon/Models/Post.swift index 282bd91846..7c43a79452 100644 --- a/AmplifyTestCommon/Models/Post.swift +++ b/AmplifyTestCommon/Models/Post.swift @@ -20,7 +20,8 @@ public struct Post: Model { public var status: PostStatus? public var comments: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, content: String, createdAt: Temporal.DateTime, @@ -28,7 +29,8 @@ public struct Post: Model { draft: Bool? = nil, rating: Double? = nil, status: PostStatus? = nil, - comments: List? = []) { + comments: List? = [] + ) { self.id = id self.title = title self.content = content diff --git a/AmplifyTestCommon/Models/PostCommentModelRegistration.swift b/AmplifyTestCommon/Models/PostCommentModelRegistration.swift index b3c1e7a4a1..b3e51e7f77 100644 --- a/AmplifyTestCommon/Models/PostCommentModelRegistration.swift +++ b/AmplifyTestCommon/Models/PostCommentModelRegistration.swift @@ -8,7 +8,7 @@ import Amplify import Foundation -final public class PostCommentModelRegistration: AmplifyModelRegistration { +public final class PostCommentModelRegistration: AmplifyModelRegistration { public func registerModels(registry: ModelRegistry.Type) { ModelRegistry.register(modelType: Post.self) ModelRegistry.register(modelType: Comment.self) diff --git a/AmplifyTestCommon/Models/QPredGen+Schema.swift b/AmplifyTestCommon/Models/QPredGen+Schema.swift index 4571c1ed25..58ecadd569 100644 --- a/AmplifyTestCommon/Models/QPredGen+Schema.swift +++ b/AmplifyTestCommon/Models/QPredGen+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension QPredGen { +public extension QPredGen { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case myBool @@ -23,10 +23,10 @@ extension QPredGen { case myTime } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let qPredGen = QPredGen.keys model.listPluralName = "QPredGens" diff --git a/AmplifyTestCommon/Models/QPredGen.swift b/AmplifyTestCommon/Models/QPredGen.swift index b26ad62ede..6c5f5e6406 100644 --- a/AmplifyTestCommon/Models/QPredGen.swift +++ b/AmplifyTestCommon/Models/QPredGen.swift @@ -8,6 +8,7 @@ // swiftlint:disable all import Amplify import Foundation + /* Generated from: @@ -34,7 +35,8 @@ public struct QPredGen: Model { public var myDateTime: Temporal.DateTime? public var myTime: Temporal.Time? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String, myBool: Bool? = nil, myDouble: Double? = nil, @@ -42,7 +44,8 @@ public struct QPredGen: Model { myString: String? = nil, myDate: Temporal.Date? = nil, myDateTime: Temporal.DateTime? = nil, - myTime: Temporal.Time? = nil) { + myTime: Temporal.Time? = nil + ) { self.id = id self.name = name self.myBool = myBool diff --git a/AmplifyTestCommon/Models/Record+Schema.swift b/AmplifyTestCommon/Models/Record+Schema.swift index 7df7ca922e..5d014387bf 100644 --- a/AmplifyTestCommon/Models/Record+Schema.swift +++ b/AmplifyTestCommon/Models/Record+Schema.swift @@ -5,13 +5,14 @@ // SPDX-License-Identifier: Apache-2.0 // +import Amplify + // swiftlint:disable all import Foundation -import Amplify -extension Record { +public extension Record { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case description @@ -21,10 +22,10 @@ extension Record { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let record = Record.keys model.listPluralName = "Records" @@ -41,10 +42,11 @@ extension Record { isReadOnly: true, ofType: RecordCover.self, associatedWith: RecordCover.keys.id, - targetName: "coverId"), + targetName: "coverId" + ), .field(record.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), .field(record.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) - ) + ) } } diff --git a/AmplifyTestCommon/Models/Record.swift b/AmplifyTestCommon/Models/Record.swift index 6b8f224c54..47608bb491 100644 --- a/AmplifyTestCommon/Models/Record.swift +++ b/AmplifyTestCommon/Models/Record.swift @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // +import Amplify + // swiftlint:disable all import Foundation -import Amplify public struct Record: Model { public let id: String @@ -18,23 +19,29 @@ public struct Record: Model { public let createdAt: Temporal.DateTime? public let updatedAt: Temporal.DateTime? - public init(name: String, - description: String? = nil) { - self.init(name: name, - description: description, - coverId: nil, - cover: nil, - createdAt: nil, - updatedAt: nil) + public init( + name: String, + description: String? = nil + ) { + self.init( + name: name, + description: description, + coverId: nil, + cover: nil, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - description: String? = nil, - coverId: String? = nil, - cover: RecordCover? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + description: String? = nil, + coverId: String? = nil, + cover: RecordCover? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.description = description diff --git a/AmplifyTestCommon/Models/RecordCover+Schema.swift b/AmplifyTestCommon/Models/RecordCover+Schema.swift index 04f4f8a460..7b0fa29fcb 100644 --- a/AmplifyTestCommon/Models/RecordCover+Schema.swift +++ b/AmplifyTestCommon/Models/RecordCover+Schema.swift @@ -5,33 +5,34 @@ // SPDX-License-Identifier: Apache-2.0 // +import Amplify + // swiftlint:disable all import Foundation -import Amplify -extension RecordCover { +public extension RecordCover { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case artist case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let recordCover = RecordCover.keys model.listPluralName = "RecordCovers" model.syncPluralName = "RecordCovers" model.fields( - .id(), - .field(recordCover.artist, is: .required, ofType: .string), - .field(recordCover.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), - .field(recordCover.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) - ) + .id(), + .field(recordCover.artist, is: .required, ofType: .string), + .field(recordCover.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), + .field(recordCover.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) + ) } } diff --git a/AmplifyTestCommon/Models/RecordCover.swift b/AmplifyTestCommon/Models/RecordCover.swift index 21d00c458f..c3730c1d79 100644 --- a/AmplifyTestCommon/Models/RecordCover.swift +++ b/AmplifyTestCommon/Models/RecordCover.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation // swiftlint:disable all @@ -17,15 +17,19 @@ public struct RecordCover: Model { public let updatedAt: Temporal.DateTime? public init(artist: String) { - self.init(artist: artist, - createdAt: nil, - updatedAt: nil) + self.init( + artist: artist, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - artist: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + artist: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.artist = artist self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/ReservedWords/Group+Schema.swift b/AmplifyTestCommon/Models/ReservedWords/Group+Schema.swift index e7a80ecd9b..9bbab7d799 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Group+Schema.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Group+Schema.swift @@ -5,19 +5,19 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation -extension Group { +public extension Group { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let group = Group.keys model.listPluralName = "Groups" diff --git a/AmplifyTestCommon/Models/ReservedWords/Group.swift b/AmplifyTestCommon/Models/ReservedWords/Group.swift index 2a270048e6..5452511e2f 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Group.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Group.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation public struct Group: Model { public let id: String diff --git a/AmplifyTestCommon/Models/ReservedWords/Row+Schema.swift b/AmplifyTestCommon/Models/ReservedWords/Row+Schema.swift index 6878da26b5..3e55c96621 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Row+Schema.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Row+Schema.swift @@ -5,20 +5,20 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation -extension Row { +public extension Row { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case group } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let row = Row.keys model.listPluralName = "Rows" diff --git a/AmplifyTestCommon/Models/ReservedWords/Row.swift b/AmplifyTestCommon/Models/ReservedWords/Row.swift index 496c3426e7..4db70b5d80 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Row.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Row.swift @@ -5,15 +5,17 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import Amplify +import Foundation public struct Row: Model { public let id: String public var group: Group - public init(id: String = UUID().uuidString, - group: Group) { + public init( + id: String = UUID().uuidString, + group: Group + ) { self.id = id self.group = group } diff --git a/AmplifyTestCommon/Models/ReservedWords/Transaction+Schema.swift b/AmplifyTestCommon/Models/ReservedWords/Transaction+Schema.swift index 8c5ac3a9b0..4dc6dcfcfb 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Transaction+Schema.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Transaction+Schema.swift @@ -5,20 +5,21 @@ // SPDX-License-Identifier: Apache-2.0 // +import Amplify + // swiftlint:disable all import Foundation -import Amplify -extension Transaction { +public extension Transaction { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let transaction = Transaction.keys model.listPluralName = "Transactions" diff --git a/AmplifyTestCommon/Models/ReservedWords/Transaction.swift b/AmplifyTestCommon/Models/ReservedWords/Transaction.swift index 0cdd05cc3c..0c249b049a 100644 --- a/AmplifyTestCommon/Models/ReservedWords/Transaction.swift +++ b/AmplifyTestCommon/Models/ReservedWords/Transaction.swift @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // +import Amplify + // swiftlint:disable all import Foundation -import Amplify public struct Transaction: Model { public let id: String diff --git a/AmplifyTestCommon/Models/Restaurant/Dish+Schema.swift b/AmplifyTestCommon/Models/Restaurant/Dish+Schema.swift index 3022b9e276..e8945e7e10 100644 --- a/AmplifyTestCommon/Models/Restaurant/Dish+Schema.swift +++ b/AmplifyTestCommon/Models/Restaurant/Dish+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Dish { +public extension Dish { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dishName case menu } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let dish = Dish.keys model.listPluralName = "Dishes" diff --git a/AmplifyTestCommon/Models/Restaurant/Dish.swift b/AmplifyTestCommon/Models/Restaurant/Dish.swift index 73fe887fe0..58afa9e691 100644 --- a/AmplifyTestCommon/Models/Restaurant/Dish.swift +++ b/AmplifyTestCommon/Models/Restaurant/Dish.swift @@ -14,9 +14,11 @@ public struct Dish: Model { public var dishName: String? public var menu: Menu? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, dishName: String? = nil, - menu: Menu? = nil) { + menu: Menu? = nil + ) { self.id = id self.dishName = dishName self.menu = menu diff --git a/AmplifyTestCommon/Models/Restaurant/Menu+Schema.swift b/AmplifyTestCommon/Models/Restaurant/Menu+Schema.swift index e3188b3f4f..34a3e35ceb 100644 --- a/AmplifyTestCommon/Models/Restaurant/Menu+Schema.swift +++ b/AmplifyTestCommon/Models/Restaurant/Menu+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Menu { +public extension Menu { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case menuType @@ -19,10 +19,10 @@ extension Menu { case dishes } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let menu = Menu.keys model.listPluralName = "Menus" diff --git a/AmplifyTestCommon/Models/Restaurant/Menu.swift b/AmplifyTestCommon/Models/Restaurant/Menu.swift index 5b571fef48..7ec55a7ec6 100644 --- a/AmplifyTestCommon/Models/Restaurant/Menu.swift +++ b/AmplifyTestCommon/Models/Restaurant/Menu.swift @@ -16,11 +16,13 @@ public struct Menu: Model { public var restaurant: Restaurant? public var dishes: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String, menuType: MenuType? = nil, restaurant: Restaurant? = nil, - dishes: List? = []) { + dishes: List? = [] + ) { self.id = id self.name = name self.menuType = menuType diff --git a/AmplifyTestCommon/Models/Restaurant/Restaurant+Schema.swift b/AmplifyTestCommon/Models/Restaurant/Restaurant+Schema.swift index 6d677b46aa..636f1d05ad 100644 --- a/AmplifyTestCommon/Models/Restaurant/Restaurant+Schema.swift +++ b/AmplifyTestCommon/Models/Restaurant/Restaurant+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Restaurant { +public extension Restaurant { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case restaurantName case menus } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let restaurant = Restaurant.keys model.listPluralName = "Restaurants" diff --git a/AmplifyTestCommon/Models/Restaurant/Restaurant.swift b/AmplifyTestCommon/Models/Restaurant/Restaurant.swift index 37ce26d911..20ec8bde27 100644 --- a/AmplifyTestCommon/Models/Restaurant/Restaurant.swift +++ b/AmplifyTestCommon/Models/Restaurant/Restaurant.swift @@ -14,9 +14,11 @@ public struct Restaurant: Model { public var restaurantName: String public var menus: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, restaurantName: String, - menus: List? = []) { + menus: List? = [] + ) { self.id = id self.restaurantName = restaurantName self.menus = menus diff --git a/AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift b/AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift index 05ff5b0fbc..bd9858f7d1 100644 --- a/AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/EnumTestModel+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension EnumTestModel { +public extension EnumTestModel { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case enumVal case nullableEnumVal @@ -21,10 +21,10 @@ extension EnumTestModel { case nullableEnumNullableList } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let enumTestModel = EnumTestModel.keys model.listPluralName = "EnumTestModels" diff --git a/AmplifyTestCommon/Models/Scalar/EnumTestModel.swift b/AmplifyTestCommon/Models/Scalar/EnumTestModel.swift index 65fe699440..ac3e7f73e3 100644 --- a/AmplifyTestCommon/Models/Scalar/EnumTestModel.swift +++ b/AmplifyTestCommon/Models/Scalar/EnumTestModel.swift @@ -18,13 +18,15 @@ public struct EnumTestModel: Model { public var nullableEnumList: [TestEnum?] public var nullableEnumNullableList: [TestEnum?]? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, enumVal: TestEnum, nullableEnumVal: TestEnum? = nil, enumList: [TestEnum] = [], enumNullableList: [TestEnum]? = nil, nullableEnumList: [TestEnum?] = [], - nullableEnumNullableList: [TestEnum?]? = nil) { + nullableEnumNullableList: [TestEnum?]? = nil + ) { self.id = id self.enumVal = enumVal self.nullableEnumVal = nullableEnumVal diff --git a/AmplifyTestCommon/Models/Scalar/ListIntContainer+Schema.swift b/AmplifyTestCommon/Models/Scalar/ListIntContainer+Schema.swift index 6ef039ff38..8362ac98fe 100644 --- a/AmplifyTestCommon/Models/Scalar/ListIntContainer+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/ListIntContainer+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ListIntContainer { +public extension ListIntContainer { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case test case nullableInt @@ -21,10 +21,10 @@ extension ListIntContainer { case nullableIntNullableList } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let listIntContainer = ListIntContainer.keys model.listPluralName = "ListIntContainers" diff --git a/AmplifyTestCommon/Models/Scalar/ListIntContainer.swift b/AmplifyTestCommon/Models/Scalar/ListIntContainer.swift index 4dd8862fe3..45604058ba 100644 --- a/AmplifyTestCommon/Models/Scalar/ListIntContainer.swift +++ b/AmplifyTestCommon/Models/Scalar/ListIntContainer.swift @@ -18,13 +18,15 @@ public struct ListIntContainer: Model { public var nullableIntList: [Int?] public var nullableIntNullableList: [Int?]? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, test: Int, nullableInt: Int? = nil, intList: [Int] = [], intNullableList: [Int]? = nil, nullableIntList: [Int?] = [], - nullableIntNullableList: [Int?]? = nil) { + nullableIntNullableList: [Int?]? = nil + ) { self.id = id self.test = test self.nullableInt = nullableInt diff --git a/AmplifyTestCommon/Models/Scalar/ListStringContainer+Schema.swift b/AmplifyTestCommon/Models/Scalar/ListStringContainer+Schema.swift index 00d1f2b153..28095c5617 100644 --- a/AmplifyTestCommon/Models/Scalar/ListStringContainer+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/ListStringContainer+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ListStringContainer { +public extension ListStringContainer { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case test case nullableString @@ -21,10 +21,10 @@ extension ListStringContainer { case nullableStringNullableList } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let listStringContainer = ListStringContainer.keys model.listPluralName = "ListStringContainers" diff --git a/AmplifyTestCommon/Models/Scalar/ListStringContainer.swift b/AmplifyTestCommon/Models/Scalar/ListStringContainer.swift index 5a23f7a5de..712c970012 100644 --- a/AmplifyTestCommon/Models/Scalar/ListStringContainer.swift +++ b/AmplifyTestCommon/Models/Scalar/ListStringContainer.swift @@ -18,13 +18,15 @@ public struct ListStringContainer: Model { public var nullableStringList: [String?] public var nullableStringNullableList: [String?]? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, test: String, nullableString: String? = nil, stringList: [String] = [], stringNullableList: [String]? = nil, nullableStringList: [String?] = [], - nullableStringNullableList: [String?]? = nil) { + nullableStringNullableList: [String?]? = nil + ) { self.id = id self.test = test self.nullableString = nullableString diff --git a/AmplifyTestCommon/Models/Scalar/Nested+Schema.swift b/AmplifyTestCommon/Models/Scalar/Nested+Schema.swift index f1d85adce4..edafe3cc62 100644 --- a/AmplifyTestCommon/Models/Scalar/Nested+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/Nested+Schema.swift @@ -9,17 +9,17 @@ import Amplify import Foundation -extension Nested { +public extension Nested { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case valueOne case valueTwo } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let nested = Nested.keys model.listPluralName = "Nesteds" diff --git a/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel+Schema.swift b/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel+Schema.swift index 79f122f0ad..806dce775f 100644 --- a/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension NestedTypeTestModel { +public extension NestedTypeTestModel { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case nestedVal case nullableNestedVal @@ -21,10 +21,10 @@ extension NestedTypeTestModel { case nullableNestedNullableList } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let nestedTypeTestModel = NestedTypeTestModel.keys model.listPluralName = "NestedTypeTestModels" diff --git a/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel.swift b/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel.swift index 5ceda72443..c9ba508760 100644 --- a/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel.swift +++ b/AmplifyTestCommon/Models/Scalar/NestedTypeTestModel.swift @@ -18,13 +18,15 @@ public struct NestedTypeTestModel: Model { public var nullableNestedList: [Nested?] public var nullableNestedNullableList: [Nested?]? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, nestedVal: Nested, nullableNestedVal: Nested? = nil, nestedList: [Nested] = [], nestedNullableList: [Nested]? = nil, nullableNestedList: [Nested?] = [], - nullableNestedNullableList: [Nested?]? = nil) { + nullableNestedNullableList: [Nested?]? = nil + ) { self.id = id self.nestedVal = nestedVal self.nullableNestedVal = nullableNestedVal diff --git a/AmplifyTestCommon/Models/Scalar/Scalar+Equatable.swift b/AmplifyTestCommon/Models/Scalar/Scalar+Equatable.swift index 3dff2379d4..d8ddc691cc 100644 --- a/AmplifyTestCommon/Models/Scalar/Scalar+Equatable.swift +++ b/AmplifyTestCommon/Models/Scalar/Scalar+Equatable.swift @@ -7,7 +7,7 @@ extension ScalarContainer: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.id == rhs.id + return lhs.id == rhs.id && lhs.myInt == rhs.myInt && lhs.myDouble == rhs.myDouble && lhs.myBool == rhs.myBool @@ -19,60 +19,60 @@ extension ScalarContainer: Equatable { && lhs.myJSON == rhs.myJSON && lhs.myPhone == rhs.myPhone && lhs.myURL == rhs.myURL - && lhs.myIPAddress == rhs.myIPAddress) + && lhs.myIPAddress == rhs.myIPAddress } } extension ListIntContainer: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.id == rhs.id + return lhs.id == rhs.id && lhs.test == rhs.test && lhs.nullableInt == rhs.nullableInt && lhs.intList == rhs.intList && lhs.intNullableList == rhs.intNullableList && lhs.nullableIntList == rhs.nullableIntList - && lhs.nullableIntNullableList == rhs.nullableIntNullableList) + && lhs.nullableIntNullableList == rhs.nullableIntNullableList } } extension ListStringContainer: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.id == rhs.id + return lhs.id == rhs.id && lhs.test == rhs.test && lhs.nullableString == rhs.nullableString && lhs.stringList == rhs.stringList && lhs.stringNullableList == rhs.stringNullableList && lhs.nullableStringList == rhs.nullableStringList - && lhs.nullableStringNullableList == rhs.nullableStringNullableList) + && lhs.nullableStringNullableList == rhs.nullableStringNullableList } } extension EnumTestModel: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.id == rhs.id + return lhs.id == rhs.id && lhs.enumVal == rhs.enumVal && lhs.nullableEnumVal == rhs.nullableEnumVal && lhs.enumList == rhs.enumList && lhs.enumNullableList == rhs.enumNullableList && lhs.nullableEnumList == rhs.nullableEnumList - && lhs.nullableEnumNullableList == rhs.nullableEnumNullableList) + && lhs.nullableEnumNullableList == rhs.nullableEnumNullableList } } extension NestedTypeTestModel: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.id == rhs.id + return lhs.id == rhs.id && lhs.nestedVal == rhs.nestedVal && lhs.nullableNestedVal == rhs.nullableNestedVal && lhs.nestedList == rhs.nestedList && lhs.nestedNullableList == rhs.nestedNullableList && lhs.nullableNestedList == rhs.nullableNestedList - && lhs.nullableNestedNullableList == rhs.nullableNestedNullableList) + && lhs.nullableNestedNullableList == rhs.nullableNestedNullableList } } extension Nested: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { - return (lhs.valueOne == rhs.valueOne - && lhs.valueTwo == rhs.valueTwo) + return lhs.valueOne == rhs.valueOne + && lhs.valueTwo == rhs.valueTwo } } diff --git a/AmplifyTestCommon/Models/Scalar/ScalarContainer+Schema.swift b/AmplifyTestCommon/Models/Scalar/ScalarContainer+Schema.swift index 8fc935838a..d05931be73 100644 --- a/AmplifyTestCommon/Models/Scalar/ScalarContainer+Schema.swift +++ b/AmplifyTestCommon/Models/Scalar/ScalarContainer+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension ScalarContainer { +public extension ScalarContainer { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case myString case myInt @@ -28,10 +28,10 @@ extension ScalarContainer { case myIPAddress } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let scalarContainer = ScalarContainer.keys model.listPluralName = "ScalarContainers" diff --git a/AmplifyTestCommon/Models/Scalar/ScalarContainer.swift b/AmplifyTestCommon/Models/Scalar/ScalarContainer.swift index 17191db613..94b6ff7475 100644 --- a/AmplifyTestCommon/Models/Scalar/ScalarContainer.swift +++ b/AmplifyTestCommon/Models/Scalar/ScalarContainer.swift @@ -25,7 +25,8 @@ public struct ScalarContainer: Model { public var myURL: String? public var myIPAddress: String? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, myString: String? = nil, myInt: Int? = nil, myDouble: Double? = nil, @@ -38,7 +39,8 @@ public struct ScalarContainer: Model { myJSON: String? = nil, myPhone: String? = nil, myURL: String? = nil, - myIPAddress: String? = nil) { + myIPAddress: String? = nil + ) { self.id = id self.myString = myString self.myInt = myInt diff --git a/AmplifyTestCommon/Models/ScenarioATest6Post+Schema.swift b/AmplifyTestCommon/Models/ScenarioATest6Post+Schema.swift index 57d9581507..cbc6d7ea57 100644 --- a/AmplifyTestCommon/Models/ScenarioATest6Post+Schema.swift +++ b/AmplifyTestCommon/Models/ScenarioATest6Post+Schema.swift @@ -9,17 +9,17 @@ import Amplify import Foundation -extension ScenarioATest6Post { +public extension ScenarioATest6Post { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let scenarioATest6Post = ScenarioATest6Post.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/ScenarioATest6Post.swift b/AmplifyTestCommon/Models/ScenarioATest6Post.swift index 108b4bfa0e..db203304ff 100644 --- a/AmplifyTestCommon/Models/ScenarioATest6Post.swift +++ b/AmplifyTestCommon/Models/ScenarioATest6Post.swift @@ -13,8 +13,10 @@ public struct ScenarioATest6Post: Model { public let id: String public var title: String - public init(id: String = UUID().uuidString, - title: String) { + public init( + id: String = UUID().uuidString, + title: String + ) { self.id = id self.title = title } diff --git a/AmplifyTestCommon/Models/TeamProject/Project+Schema.swift b/AmplifyTestCommon/Models/TeamProject/Project+Schema.swift index 73c9190fdc..1716d0b332 100644 --- a/AmplifyTestCommon/Models/TeamProject/Project+Schema.swift +++ b/AmplifyTestCommon/Models/TeamProject/Project+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension Project { +public extension Project { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case team } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project = Project.keys model.listPluralName = "Projects" diff --git a/AmplifyTestCommon/Models/TeamProject/Project.swift b/AmplifyTestCommon/Models/TeamProject/Project.swift index 14ae5d0559..db3e85ced2 100644 --- a/AmplifyTestCommon/Models/TeamProject/Project.swift +++ b/AmplifyTestCommon/Models/TeamProject/Project.swift @@ -14,9 +14,11 @@ public struct Project: Model { public var name: String? public var team: Team? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String? = nil, - team: Team? = nil) { + team: Team? = nil + ) { self.id = id self.name = name self.team = team diff --git a/AmplifyTestCommon/Models/TeamProject/Team+Schema.swift b/AmplifyTestCommon/Models/TeamProject/Team+Schema.swift index a9710d86f8..d6dbe43e23 100644 --- a/AmplifyTestCommon/Models/TeamProject/Team+Schema.swift +++ b/AmplifyTestCommon/Models/TeamProject/Team+Schema.swift @@ -9,17 +9,17 @@ import Amplify import Foundation -extension Team { +public extension Team { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team = Team.keys model.listPluralName = "Teams" diff --git a/AmplifyTestCommon/Models/TeamProject/Team.swift b/AmplifyTestCommon/Models/TeamProject/Team.swift index 3ca4e7e2ef..086f20f10a 100644 --- a/AmplifyTestCommon/Models/TeamProject/Team.swift +++ b/AmplifyTestCommon/Models/TeamProject/Team.swift @@ -13,8 +13,10 @@ public struct Team: Model { public let id: String public var name: String - public init(id: String = UUID().uuidString, - name: String) { + public init( + id: String = UUID().uuidString, + name: String + ) { self.id = id self.name = name } diff --git a/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2+Schema.swift index e51bfa5402..f798199559 100644 --- a/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Project1V2 { +public extension Project1V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case team @@ -20,10 +20,10 @@ extension Project1V2 { case project1V2TeamId } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project1V2 = Project1V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2.swift b/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2.swift index 34440bbb51..7cf9f9a23f 100644 --- a/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/1V2/Project1V2.swift @@ -17,23 +17,29 @@ public struct Project1V2: Model { public var updatedAt: Temporal.DateTime? public var project1V2TeamId: String? - public init(id: String = UUID().uuidString, - name: String? = nil, - team: Team1V2? = nil, - project1V2TeamId: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String? = nil, + team: Team1V2? = nil, + project1V2TeamId: String? = nil + ) { + self.init( + id: id, name: name, team: team, createdAt: nil, updatedAt: nil, - project1V2TeamId: project1V2TeamId) + project1V2TeamId: project1V2TeamId + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - team: Team1V2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil, - project1V2TeamId: String? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + team: Team1V2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil, + project1V2TeamId: String? = nil + ) { self.id = id self.name = name self.team = team diff --git a/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2+Schema.swift index 8ed0f54ddf..2fa869b077 100644 --- a/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Team1V2 { +public extension Team1V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team1V2 = Team1V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2.swift b/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2.swift index ed29653b08..9e547cc972 100644 --- a/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/1V2/Team1V2.swift @@ -15,17 +15,23 @@ public struct Team1V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String + ) { + self.init( + id: id, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2+Schema.swift index 286ca57848..b1d25f76ab 100644 --- a/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Project2V2 { +public extension Project2V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case teamID @@ -20,10 +20,10 @@ extension Project2V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project2V2 = Project2V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2.swift b/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2.swift index fed160bd8c..adc2cfc7fc 100644 --- a/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/2V2/Project2V2.swift @@ -17,23 +17,29 @@ public struct Project2V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String? = nil, - teamID: String, - team: Team2V2? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String? = nil, + teamID: String, + team: Team2V2? = nil + ) { + self.init( + id: id, name: name, teamID: teamID, team: team, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - teamID: String, - team: Team2V2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + teamID: String, + team: Team2V2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.teamID = teamID diff --git a/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2+Schema.swift index 43e0f11b00..0db2c5e78b 100644 --- a/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Team2V2 { +public extension Team2V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team2V2 = Team2V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2.swift b/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2.swift index 7f13b3927a..9b8e27a8b3 100644 --- a/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/2V2/Team2V2.swift @@ -15,17 +15,23 @@ public struct Team2V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String + ) { + self.init( + id: id, name: name, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2+Schema.swift index cee3850f92..023f2e2d90 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment3V2 { +public extension Comment3V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case postID case content @@ -19,10 +19,10 @@ extension Comment3V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment3V2 = Comment3V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2.swift b/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2.swift index 52f14a06fe..6f0647dd70 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3V2/Comment3V2.swift @@ -16,20 +16,26 @@ public struct Comment3V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - postID: String, - content: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + postID: String, + content: String + ) { + self.init( + id: id, postID: postID, content: content, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - postID: String, - content: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + postID: String, + content: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.postID = postID self.content = content diff --git a/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2+Schema.swift index f377adf509..e8525efd3a 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post3V2 { +public extension Post3V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension Post3V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post3V2 = Post3V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2.swift b/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2.swift index 365ff8bc83..bfd3f9db93 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3V2/Post3V2.swift @@ -16,20 +16,26 @@ public struct Post3V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2+Schema.swift index 41081acbfc..a2efc3dd3f 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment3aV2 { +public extension Comment3aV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case createdAt @@ -19,10 +19,10 @@ extension Comment3aV2 { case post3aV2CommentsId } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment3aV2 = Comment3aV2.keys model.pluralName = "Comment3aV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2.swift b/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2.swift index 883bbd6eb8..362732db79 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3aV2/Comment3aV2.swift @@ -16,20 +16,26 @@ public struct Comment3aV2: Model { public var updatedAt: Temporal.DateTime? public var post3aV2CommentsId: String? - public init(id: String = UUID().uuidString, - content: String, - post3aV2CommentsId: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String, + post3aV2CommentsId: String? = nil + ) { + self.init( + id: id, content: content, createdAt: nil, updatedAt: nil, - post3aV2CommentsId: post3aV2CommentsId) + post3aV2CommentsId: post3aV2CommentsId + ) } - internal init(id: String = UUID().uuidString, - content: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil, - post3aV2CommentsId: String? = nil) { + init( + id: String = UUID().uuidString, + content: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil, + post3aV2CommentsId: String? = nil + ) { self.id = id self.content = content self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2+Schema.swift index 3b33c9960e..067713be06 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post3aV2 { +public extension Post3aV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension Post3aV2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post3aV2 = Post3aV2.keys model.pluralName = "Post3aV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2.swift b/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2.swift index 5332fcf81a..78361ec783 100644 --- a/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/3aV2/Post3aV2.swift @@ -16,20 +16,26 @@ public struct Post3aV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2+Schema.swift index db568413b1..90683b5561 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment4V2 { +public extension Comment4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -19,10 +19,10 @@ extension Comment4V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment4V2 = Comment4V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2.swift b/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2.swift index 5873d993e4..0d4073d6b4 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4V2/Comment4V2.swift @@ -16,20 +16,26 @@ public struct Comment4V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String, - post: Post4V2? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String, + post: Post4V2? = nil + ) { + self.init( + id: id, content: content, post: post, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String, - post: Post4V2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String, + post: Post4V2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post diff --git a/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2+Schema.swift index c0fa5fdfbb..e010e1c080 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post4V2 { +public extension Post4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -19,10 +19,10 @@ extension Post4V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post4V2 = Post4V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2.swift b/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2.swift index 7978edceb7..9106744759 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4V2/Post4V2.swift @@ -16,20 +16,26 @@ public struct Post4V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, title: title, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments diff --git a/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2+Schema.swift index 5142fd05de..63cb47ada7 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Project4aV2 { +public extension Project4aV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case team @@ -20,10 +20,10 @@ extension Project4aV2 { case project4aV2TeamId } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project4aV2 = Project4aV2.keys model.pluralName = "Project4aV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2.swift b/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2.swift index 51b873975c..4777b1dcda 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4aV2/Project4aV2.swift @@ -21,23 +21,29 @@ public class Project4aV2: Model { public var updatedAt: Temporal.DateTime? public var project4aV2TeamId: String? - public convenience init(id: String = UUID().uuidString, + public convenience init( + id: String = UUID().uuidString, name: String? = nil, team: Team4aV2? = nil, - project4aV2TeamId: String? = nil) { - self.init(id: id, + project4aV2TeamId: String? = nil + ) { + self.init( + id: id, name: name, team: team, createdAt: nil, updatedAt: nil, - project4aV2TeamId: project4aV2TeamId) + project4aV2TeamId: project4aV2TeamId + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - team: Team4aV2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil, - project4aV2TeamId: String? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + team: Team4aV2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil, + project4aV2TeamId: String? = nil + ) { self.id = id self.name = name self.team = team diff --git a/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2+Schema.swift index 9b7cae724e..18ccef180d 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Team4aV2 { +public extension Team4aV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case project @@ -19,10 +19,10 @@ extension Team4aV2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team4aV2 = Team4aV2.keys model.pluralName = "Team4aV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2.swift b/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2.swift index 71d880f56b..7abfb7100b 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4aV2/Team4aV2.swift @@ -16,20 +16,26 @@ public class Team4aV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public convenience init(id: String = UUID().uuidString, + public convenience init( + id: String = UUID().uuidString, name: String, - project: Project4aV2? = nil) { - self.init(id: id, + project: Project4aV2? = nil + ) { + self.init( + id: id, name: name, project: project, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - project: Project4aV2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + project: Project4aV2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.project = project diff --git a/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2+Schema.swift index 236d2be094..e3f4983c80 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Project4bV2 { +public extension Project4bV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case team @@ -20,10 +20,10 @@ extension Project4bV2 { case project4bV2TeamId } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let project4bV2 = Project4bV2.keys model.pluralName = "Project4bV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2.swift b/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2.swift index 2369a6c57b..9b280c61df 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4bV2/Project4bV2.swift @@ -17,23 +17,29 @@ public class Project4bV2: Model { public var updatedAt: Temporal.DateTime? public var project4bV2TeamId: String? - public convenience init(id: String = UUID().uuidString, + public convenience init( + id: String = UUID().uuidString, name: String? = nil, team: Team4bV2? = nil, - project4bV2TeamId: String? = nil) { - self.init(id: id, + project4bV2TeamId: String? = nil + ) { + self.init( + id: id, name: name, team: team, createdAt: nil, updatedAt: nil, - project4bV2TeamId: project4bV2TeamId) + project4bV2TeamId: project4bV2TeamId + ) } - internal init(id: String = UUID().uuidString, - name: String? = nil, - team: Team4bV2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil, - project4bV2TeamId: String? = nil) { + init( + id: String = UUID().uuidString, + name: String? = nil, + team: Team4bV2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil, + project4bV2TeamId: String? = nil + ) { self.id = id self.name = name self.team = team diff --git a/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2+Schema.swift index 311044fad2..eb0ec1c290 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Team4bV2 { +public extension Team4bV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case project @@ -19,10 +19,10 @@ extension Team4bV2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let team4bV2 = Team4bV2.keys model.pluralName = "Team4bV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2.swift b/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2.swift index 644c856c81..b1831b611b 100644 --- a/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/4bV2/Team4bV2.swift @@ -16,20 +16,26 @@ public class Team4bV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public convenience init(id: String = UUID().uuidString, + public convenience init( + id: String = UUID().uuidString, name: String, - project: Project4bV2? = nil) { - self.init(id: id, + project: Project4bV2? = nil + ) { + self.init( + id: id, name: name, project: project, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - project: Project4bV2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + project: Project4bV2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.project = project diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2+Schema.swift index 84a32e2cb8..9528d2576d 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post5V2 { +public extension Post5V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case editors @@ -19,10 +19,10 @@ extension Post5V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post5V2 = Post5V2.keys model.pluralName = "Post5V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2.swift index 3165ee7f99..1090df258b 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/Post5V2.swift @@ -16,20 +16,26 @@ public struct Post5V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - editors: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + editors: List? = [] + ) { + self.init( + id: id, title: title, editors: editors, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - editors: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + editors: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.editors = editors diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2+Schema.swift index cdbcd3e07d..23a7be5848 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension PostEditor5V2 { +public extension PostEditor5V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case post5V2 case user5V2 @@ -19,10 +19,10 @@ extension PostEditor5V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let postEditor5V2 = PostEditor5V2.keys model.pluralName = "PostEditor5V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2.swift index f78bbe9420..dabb434aac 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/PostEditor5V2.swift @@ -16,20 +16,26 @@ public struct PostEditor5V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - post5V2: Post5V2, - user5V2: User5V2) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + post5V2: Post5V2, + user5V2: User5V2 + ) { + self.init( + id: id, post5V2: post5V2, user5V2: user5V2, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - post5V2: Post5V2, - user5V2: User5V2, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + post5V2: Post5V2, + user5V2: User5V2, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.post5V2 = post5V2 self.user5V2 = user5V2 diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2+Schema.swift index 5c35bd5ad9..a15d33b3ab 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension User5V2 { +public extension User5V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case username case posts @@ -19,10 +19,10 @@ extension User5V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let user5V2 = User5V2.keys model.pluralName = "User5V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2.swift b/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2.swift index 7329a37803..dbf049a0f0 100644 --- a/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/5V2/User5V2.swift @@ -16,20 +16,26 @@ public struct User5V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - username: String, - posts: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + username: String, + posts: List? = [] + ) { + self.init( + id: id, username: username, posts: posts, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - username: String, - posts: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + username: String, + posts: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.username = username self.posts = posts diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2+Schema.swift index 0c2d801a88..280cafde47 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Blog6V2 { +public extension Blog6V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case posts @@ -19,10 +19,10 @@ extension Blog6V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let blog6V2 = Blog6V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2.swift index 1d1c62c34c..b4cbf30247 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Blog6V2.swift @@ -16,20 +16,26 @@ public struct Blog6V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - posts: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + posts: List? = [] + ) { + self.init( + id: id, name: name, posts: posts, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - posts: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + posts: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.posts = posts diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2+Schema.swift index 2d8fe7959c..cb476aa8cc 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment6V2 { +public extension Comment6V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case post case content @@ -19,10 +19,10 @@ extension Comment6V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment6V2 = Comment6V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2.swift index f975f70fb2..027da3fbc5 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Comment6V2.swift @@ -16,20 +16,26 @@ public struct Comment6V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - post: Post6V2? = nil, - content: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + post: Post6V2? = nil, + content: String + ) { + self.init( + id: id, post: post, content: content, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - post: Post6V2? = nil, - content: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + post: Post6V2? = nil, + content: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.post = post self.content = content diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2+Schema.swift index 5e96bf8cd9..8322b709e5 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post6V2 { +public extension Post6V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case blog @@ -20,10 +20,10 @@ extension Post6V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post6V2 = Post6V2.keys model.authRules = [ diff --git a/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2.swift b/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2.swift index bebe11af46..c955a6e87e 100644 --- a/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/6V2/Post6V2.swift @@ -17,23 +17,29 @@ public struct Post6V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - blog: Blog6V2? = nil, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + blog: Blog6V2? = nil, + comments: List? = [] + ) { + self.init( + id: id, title: title, blog: blog, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - blog: Blog6V2? = nil, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + blog: Blog6V2? = nil, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.blog = blog diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2+Schema.swift index 84fa41ace3..5e2f6f64ca 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Blog7V2 { +public extension Blog7V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case posts @@ -19,10 +19,10 @@ extension Blog7V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let blog7V2 = Blog7V2.keys model.pluralName = "Blog7V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2.swift index e963392ee5..537cd210a4 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Blog7V2.swift @@ -16,20 +16,26 @@ public struct Blog7V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - posts: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + posts: List? = [] + ) { + self.init( + id: id, name: name, posts: posts, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - posts: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + posts: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.posts = posts diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2+Schema.swift index 0f71ceb037..077286678f 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment7V2 { +public extension Comment7V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -19,10 +19,10 @@ extension Comment7V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment7V2 = Comment7V2.keys model.pluralName = "Comment7V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2.swift index 317bef7b62..fa9b8c14ec 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Comment7V2.swift @@ -16,20 +16,26 @@ public struct Comment7V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String? = nil, - post: Post7V2? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String? = nil, + post: Post7V2? = nil + ) { + self.init( + id: id, content: content, post: post, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String? = nil, - post: Post7V2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String? = nil, + post: Post7V2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2+Schema.swift index e16552145c..18d5da8dc9 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post7V2 { +public extension Post7V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case blog @@ -20,10 +20,10 @@ extension Post7V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post7V2 = Post7V2.keys model.pluralName = "Post7V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2.swift b/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2.swift index a1cb3dfb84..e6fe9a9aab 100644 --- a/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/7V2/Post7V2.swift @@ -17,23 +17,29 @@ public struct Post7V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - blog: Blog7V2? = nil, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + blog: Blog7V2? = nil, + comments: List? = [] + ) { + self.init( + id: id, title: title, blog: blog, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - blog: Blog7V2? = nil, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + blog: Blog7V2? = nil, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.blog = blog diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2+Schema.swift index d77a61d5ee..aa10f9edd5 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension Attendee8V2 { +public extension Attendee8V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case meetings case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let attendee8V2 = Attendee8V2.keys model.pluralName = "Attendee8V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2.swift index bdb90d7726..1ae9221f59 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Attendee8V2.swift @@ -15,17 +15,23 @@ public struct Attendee8V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - meetings: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + meetings: List? = [] + ) { + self.init( + id: id, meetings: meetings, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - meetings: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + meetings: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.meetings = meetings self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2+Schema.swift index ea734e16d1..540f9e81b7 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Meeting8V2 { +public extension Meeting8V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case attendees @@ -19,10 +19,10 @@ extension Meeting8V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let meeting8V2 = Meeting8V2.keys model.pluralName = "Meeting8V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2.swift index 84abbbdd0c..8101985510 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Meeting8V2.swift @@ -16,20 +16,26 @@ public struct Meeting8V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - title: String, - attendees: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + title: String, + attendees: List? = [] + ) { + self.init( + id: id, title: title, attendees: attendees, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - attendees: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + attendees: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.attendees = attendees diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2+Schema.swift index 72355ba4ea..303c84d91b 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Registration8V2 { +public extension Registration8V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case meeting case attendee @@ -19,10 +19,10 @@ extension Registration8V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let registration8V2 = Registration8V2.keys model.pluralName = "Registration8V2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2.swift b/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2.swift index f9d2aa3b4b..3c572b4969 100644 --- a/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/8V2/Registration8V2.swift @@ -16,20 +16,26 @@ public struct Registration8V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - meeting: Meeting8V2, - attendee: Attendee8V2) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + meeting: Meeting8V2, + attendee: Attendee8V2 + ) { + self.init( + id: id, meeting: meeting, attendee: attendee, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - meeting: Meeting8V2, - attendee: Attendee8V2, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + meeting: Meeting8V2, + attendee: Attendee8V2, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.meeting = meeting self.attendee = attendee diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2+Schema.swift index f760ef2c9c..fae219e308 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CustomerMultipleSecondaryIndexV2 { +public extension CustomerMultipleSecondaryIndexV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case phoneNumber @@ -21,10 +21,10 @@ extension CustomerMultipleSecondaryIndexV2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let customerMultipleSecondaryIndexV2 = CustomerMultipleSecondaryIndexV2.keys model.pluralName = "CustomerMultipleSecondaryIndexV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2.swift index 7e92f12052..1c4e60e2d5 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerMultipleSecondaryIndexV2.swift @@ -18,26 +18,32 @@ public struct CustomerMultipleSecondaryIndexV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - phoneNumber: String? = nil, - age: Int, - accountRepresentativeID: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + phoneNumber: String? = nil, + age: Int, + accountRepresentativeID: String + ) { + self.init( + id: id, name: name, phoneNumber: phoneNumber, age: age, accountRepresentativeID: accountRepresentativeID, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - phoneNumber: String? = nil, - age: Int, - accountRepresentativeID: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + phoneNumber: String? = nil, + age: Int, + accountRepresentativeID: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.phoneNumber = phoneNumber diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2+Schema.swift index 3058f7d566..1118ef8ca6 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CustomerSecondaryIndexV2 { +public extension CustomerSecondaryIndexV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case phoneNumber @@ -20,10 +20,10 @@ extension CustomerSecondaryIndexV2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let customerSecondaryIndexV2 = CustomerSecondaryIndexV2.keys model.pluralName = "CustomerSecondaryIndexV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2.swift index e6e0d76c04..195405ac60 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerSecondaryIndexV2.swift @@ -17,23 +17,29 @@ public struct CustomerSecondaryIndexV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - phoneNumber: String? = nil, - accountRepresentativeID: String) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + phoneNumber: String? = nil, + accountRepresentativeID: String + ) { + self.init( + id: id, name: name, phoneNumber: phoneNumber, accountRepresentativeID: accountRepresentativeID, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - phoneNumber: String? = nil, - accountRepresentativeID: String, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + phoneNumber: String? = nil, + accountRepresentativeID: String, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.phoneNumber = phoneNumber diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK+Schema.swift index 40e8c0f7ce..021d8bfa84 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension CustomerWithMultipleFieldsinPK { +public extension CustomerWithMultipleFieldsinPK { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case dob case date @@ -25,10 +25,10 @@ extension CustomerWithMultipleFieldsinPK { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let customerWithMultipleFieldsinPK = CustomerWithMultipleFieldsinPK.keys model.pluralName = "CustomerWithMultipleFieldsinPKs" diff --git a/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK.swift b/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK.swift index 32293d9975..0ae721e741 100644 --- a/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK.swift +++ b/AmplifyTestCommon/Models/TransformerV2/CustomerWithMultipleFieldsinPK.swift @@ -22,16 +22,19 @@ public struct CustomerWithMultipleFieldsinPK: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - date: Temporal.Date, - time: Temporal.Time, - phoneNumber: Int, - priority: Priority, - height: Double, - firstName: String? = nil, - lastName: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + date: Temporal.Date, + time: Temporal.Time, + phoneNumber: Int, + priority: Priority, + height: Double, + firstName: String? = nil, + lastName: String? = nil + ) { + self.init( + id: id, dob: dob, date: date, time: time, @@ -41,19 +44,22 @@ public struct CustomerWithMultipleFieldsinPK: Model { firstName: firstName, lastName: lastName, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - dob: Temporal.DateTime, - date: Temporal.Date, - time: Temporal.Time, - phoneNumber: Int, - priority: Priority, - height: Double, - firstName: String? = nil, - lastName: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + dob: Temporal.DateTime, + date: Temporal.Date, + time: Temporal.Time, + phoneNumber: Int, + priority: Priority, + height: Double, + firstName: String? = nil, + lastName: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.dob = dob self.date = date diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8+Schema.swift index 03ace0efac..9f21d12e70 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Blog8 { +public extension Blog8 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case customs @@ -21,10 +21,10 @@ extension Blog8 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let blog8 = Blog8.keys model.pluralName = "Blog8s" diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8.swift index 92c1ccae48..48aa59e7fc 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Blog8.swift @@ -18,26 +18,32 @@ public struct Blog8: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - customs: [MyCustomModel8?]? = nil, - notes: [String?]? = nil, - posts: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + customs: [MyCustomModel8?]? = nil, + notes: [String?]? = nil, + posts: List? = [] + ) { + self.init( + id: id, name: name, customs: customs, notes: notes, posts: posts, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - customs: [MyCustomModel8?]? = nil, - notes: [String?]? = nil, - posts: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + customs: [MyCustomModel8?]? = nil, + notes: [String?]? = nil, + posts: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.customs = customs diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8+Schema.swift index 6258c76ca6..f2e773e8ee 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Comment8 { +public extension Comment8 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -19,10 +19,10 @@ extension Comment8 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment8 = Comment8.keys model.pluralName = "Comment8s" diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8.swift index 4a0042140e..d6fa843ba3 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Comment8.swift @@ -16,20 +16,26 @@ public struct Comment8: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String? = nil, - post: Post8? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String? = nil, + post: Post8? = nil + ) { + self.init( + id: id, content: content, post: post, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String? = nil, - post: Post8? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String? = nil, + post: Post8? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyCustomModel8+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyCustomModel8+Schema.swift index 27f611af59..85693fb8fa 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyCustomModel8+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyCustomModel8+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension MyCustomModel8 { +public extension MyCustomModel8 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case desc case children } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let myCustomModel8 = MyCustomModel8.keys model.pluralName = "MyCustomModel8s" diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyNestedModel8+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyNestedModel8+Schema.swift index 1d18ede96f..206fee3987 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyNestedModel8+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/MyNestedModel8+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension MyNestedModel8 { +public extension MyNestedModel8 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case nestedName case notes } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let myNestedModel8 = MyNestedModel8.keys model.pluralName = "MyNestedModel8s" diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8+Schema.swift index bd21917eb4..5cf1fb9e29 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8+Schema.swift @@ -9,9 +9,9 @@ import Amplify import Foundation -extension Post8 { +public extension Post8 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case randomId @@ -21,10 +21,10 @@ extension Post8 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post8 = Post8.keys model.pluralName = "Post8s" diff --git a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8.swift b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8.swift index 306eb3395b..09bec3b160 100644 --- a/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8.swift +++ b/AmplifyTestCommon/Models/TransformerV2/OptionalAssociations/Post8.swift @@ -18,26 +18,32 @@ public struct Post8: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - name: String, - randomId: String? = nil, - blog: Blog8? = nil, - comments: List? = []) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + name: String, + randomId: String? = nil, + blog: Blog8? = nil, + comments: List? = [] + ) { + self.init( + id: id, name: name, randomId: randomId, blog: blog, comments: comments, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - name: String, - randomId: String? = nil, - blog: Blog8? = nil, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + name: String, + randomId: String? = nil, + blog: Blog8? = nil, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.name = name self.randomId = randomId diff --git a/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift+Schema.swift index 5d527c5bdf..59af4deb74 100644 --- a/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension SchemaDrift { +public extension SchemaDrift { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case enumValue case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let schemaDrift = SchemaDrift.keys model.pluralName = "SchemaDrifts" diff --git a/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift.swift b/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift.swift index dfac48fda6..b6159e7589 100644 --- a/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift.swift +++ b/AmplifyTestCommon/Models/TransformerV2/SchemaDrift/SchemaDrift.swift @@ -30,17 +30,23 @@ public struct SchemaDrift: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - enumValue: EnumDrift? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + enumValue: EnumDrift? = nil + ) { + self.init( + id: id, enumValue: enumValue, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - enumValue: EnumDrift? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + enumValue: EnumDrift? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.enumValue = enumValue self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2+Schema.swift index 716f4848fe..2ed40a52b9 100644 --- a/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension TodoCustomTimestampV2 { +public extension TodoCustomTimestampV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case createdOn case updatedOn } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let todoCustomTimestampV2 = TodoCustomTimestampV2.keys model.pluralName = "TodoCustomTimestampV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2.swift b/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2.swift index 4bad844e17..97842a31a0 100644 --- a/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/TodoCustomTimestampV2.swift @@ -15,17 +15,23 @@ public struct TodoCustomTimestampV2: Model { public var createdOn: Temporal.DateTime? public var updatedOn: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String? = nil + ) { + self.init( + id: id, content: content, createdOn: nil, - updatedOn: nil) + updatedOn: nil + ) } - internal init(id: String = UUID().uuidString, - content: String? = nil, - createdOn: Temporal.DateTime? = nil, - updatedOn: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String? = nil, + createdOn: Temporal.DateTime? = nil, + updatedOn: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.createdOn = createdOn diff --git a/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2+Schema.swift b/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2+Schema.swift index 6de5d45ae2..0e390adf51 100644 --- a/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2+Schema.swift +++ b/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension TodoWithDefaultValueV2 { +public extension TodoWithDefaultValueV2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case createdAt case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let todoWithDefaultValueV2 = TodoWithDefaultValueV2.keys model.pluralName = "TodoWithDefaultValueV2s" diff --git a/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2.swift b/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2.swift index dd622e15fc..75c66e59c2 100644 --- a/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2.swift +++ b/AmplifyTestCommon/Models/TransformerV2/TodoWithDefaultValueV2.swift @@ -15,17 +15,23 @@ public struct TodoWithDefaultValueV2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, - content: String? = nil) { - self.init(id: id, + public init( + id: String = UUID().uuidString, + content: String? = nil + ) { + self.init( + id: id, content: content, createdAt: nil, - updatedAt: nil) + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.createdAt = createdAt diff --git a/AmplifyTestCommon/Models/User+Schema.swift b/AmplifyTestCommon/Models/User+Schema.swift index a085ba40a2..21093edf18 100644 --- a/AmplifyTestCommon/Models/User+Schema.swift +++ b/AmplifyTestCommon/Models/User+Schema.swift @@ -9,19 +9,19 @@ import Amplify import Foundation -extension User { +public extension User { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case name case following case followers } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let user = User.keys model.listPluralName = "Users" @@ -34,10 +34,10 @@ extension User { .hasMany(user.followers, is: .optional, ofType: UserFollowers.self, associatedWith: UserFollowers.keys.user) ) } - - public class Path: ModelPath {} - - public static var rootPath: PropertyContainerPath? { Path() } + + class Path: ModelPath {} + + static var rootPath: PropertyContainerPath? { Path() } } extension ModelPath where ModelType == User { @@ -45,6 +45,6 @@ extension ModelPath where ModelType == User { var name: FieldPath { string("name") } var following: ModelPath { UserFollowing.Path(name: "following", isCollection: true, parent: self) } var followers: ModelPath { UserFollowers.Path(name: "followers", isCollection: true, parent: self) } - + } diff --git a/AmplifyTestCommon/Models/User.swift b/AmplifyTestCommon/Models/User.swift index e3bf9a2bb1..cd852353ea 100644 --- a/AmplifyTestCommon/Models/User.swift +++ b/AmplifyTestCommon/Models/User.swift @@ -15,10 +15,12 @@ public struct User: Model { public var following: List? public var followers: List? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, name: String, following: List? = [], - followers: List? = []) { + followers: List? = [] + ) { self.id = id self.name = name self.following = following diff --git a/AmplifyTestCommon/Models/UserFollowers+Schema.swift b/AmplifyTestCommon/Models/UserFollowers+Schema.swift index d582041f43..201dec549e 100644 --- a/AmplifyTestCommon/Models/UserFollowers+Schema.swift +++ b/AmplifyTestCommon/Models/UserFollowers+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension UserFollowers { +public extension UserFollowers { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case user case followersUser } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let userFollowers = UserFollowers.keys model.listPluralName = "UserFollowers" @@ -32,10 +32,10 @@ extension UserFollowers { .belongsTo(userFollowers.followersUser, is: .optional, ofType: User.self, targetName: "userFollowersFollowersUserId") ) } - - public class Path: ModelPath { } - - public static var rootPath: PropertyContainerPath? { Path() } + + class Path: ModelPath { } + + static var rootPath: PropertyContainerPath? { Path() } } extension ModelPath where ModelType == UserFollowers { diff --git a/AmplifyTestCommon/Models/UserFollowers.swift b/AmplifyTestCommon/Models/UserFollowers.swift index 5c2f851f90..ccbc4f0e10 100644 --- a/AmplifyTestCommon/Models/UserFollowers.swift +++ b/AmplifyTestCommon/Models/UserFollowers.swift @@ -14,9 +14,11 @@ public struct UserFollowers: Model { public var user: User? public var followersUser: User? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, user: User? = nil, - followersUser: User? = nil) { + followersUser: User? = nil + ) { self.id = id self.user = user self.followersUser = followersUser diff --git a/AmplifyTestCommon/Models/UserFollowing+Schema.swift b/AmplifyTestCommon/Models/UserFollowing+Schema.swift index 5b7919b96c..0f848b9089 100644 --- a/AmplifyTestCommon/Models/UserFollowing+Schema.swift +++ b/AmplifyTestCommon/Models/UserFollowing+Schema.swift @@ -9,18 +9,18 @@ import Amplify import Foundation -extension UserFollowing { +public extension UserFollowing { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case user case followingUser } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let userFollowing = UserFollowing.keys model.listPluralName = "UserFollowings" @@ -32,10 +32,10 @@ extension UserFollowing { .belongsTo(userFollowing.followingUser, is: .optional, ofType: User.self, targetName: "userFollowingFollowingUserId") ) } - - public class Path: ModelPath {} - - public static var rootPath: PropertyContainerPath? { Path() } + + class Path: ModelPath {} + + static var rootPath: PropertyContainerPath? { Path() } } extension ModelPath where ModelType == UserFollowing { diff --git a/AmplifyTestCommon/Models/UserFollowing.swift b/AmplifyTestCommon/Models/UserFollowing.swift index a545803ac3..cc61a04a54 100644 --- a/AmplifyTestCommon/Models/UserFollowing.swift +++ b/AmplifyTestCommon/Models/UserFollowing.swift @@ -14,9 +14,11 @@ public struct UserFollowing: Model { public var user: User? public var followingUser: User? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, user: User? = nil, - followingUser: User? = nil) { + followingUser: User? = nil + ) { self.id = id self.user = user self.followingUser = followingUser diff --git a/AmplifyTestCommon/SharedTestCases/SharedTestCasesPostComment4V2.swift b/AmplifyTestCommon/SharedTestCases/SharedTestCasesPostComment4V2.swift index 2404d3373b..ce671d3d38 100644 --- a/AmplifyTestCommon/SharedTestCases/SharedTestCasesPostComment4V2.swift +++ b/AmplifyTestCommon/SharedTestCases/SharedTestCasesPostComment4V2.swift @@ -24,21 +24,21 @@ import Foundation */ protocol SharedTestCasesPostComment4V2 { - + func testSaveCommentThenQueryComment() async throws - + func testSavePostThenQueryPost() async throws - + func testSaveMultipleThenQueryComments() async throws - + func testSaveMultipleThenQueryPosts() async throws - + func testSaveCommentWithPostThenQueryCommentAndAccessPost() async throws - + func testSaveCommentWithPostThenQueryPostAndAccessComments() async throws - + func testSaveMultipleCommentWithPostThenQueryCommentsAndAccessPost() async throws - + func testSaveMultipleCommentWithPostThenQueryPostAndAccessComments() async throws } @@ -50,21 +50,27 @@ public struct LazyParentPost4V2: Model { public var comments: List? public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - - public init(id: String = UUID().uuidString, - title: String, - comments: List? = []) { - self.init(id: id, - title: title, - comments: comments, - createdAt: nil, - updatedAt: nil) + + public init( + id: String = UUID().uuidString, + title: String, + comments: List? = [] + ) { + self.init( + id: id, + title: title, + comments: comments, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - title: String, - comments: List? = [], - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + title: String, + comments: List? = [], + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments @@ -72,28 +78,28 @@ public struct LazyParentPost4V2: Model { self.updatedAt = updatedAt } } -extension LazyParentPost4V2 { +public extension LazyParentPost4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments case createdAt case updatedAt } - - public static let keys = CodingKeys.self + + static let keys = CodingKeys.self // MARK: - ModelSchema - - public static let schema = defineSchema { model in + + static let schema = defineSchema { model in let post4V2 = Post4V2.keys - + model.authRules = [ rule(allow: .public, operations: [.create, .update, .delete, .read]) ] - + model.pluralName = "LazyParentPost4V2s" - + model.fields( .id(), .field(post4V2.title, is: .required, ofType: .string), @@ -107,7 +113,7 @@ extension LazyParentPost4V2 { public struct LazyChildComment4V2: Model { public let id: String public var content: String - internal var _post: LazyReference + var _post: LazyReference public var post: LazyParentPost4V2? { get async throws { try await _post.get() @@ -115,41 +121,47 @@ public struct LazyChildComment4V2: Model { } public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - - public init(id: String = UUID().uuidString, - content: String, - post: LazyParentPost4V2? = nil) { - self.init(id: id, - content: content, - post: post, - createdAt: nil, - updatedAt: nil) + + public init( + id: String = UUID().uuidString, + content: String, + post: LazyParentPost4V2? = nil + ) { + self.init( + id: id, + content: content, + post: post, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, - content: String, - post: LazyParentPost4V2? = nil, - createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + init( + id: String = UUID().uuidString, + content: String, + post: LazyParentPost4V2? = nil, + createdAt: Temporal.DateTime? = nil, + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self._post = LazyReference(post) self.createdAt = createdAt self.updatedAt = updatedAt } - + public mutating func setPost(_ post: LazyParentPost4V2) { - self._post = LazyReference(post) + _post = LazyReference(post) } - + public init(from decoder: Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) - id = try values.decode(String.self, forKey: .id) - content = try values.decode(String.self, forKey: .content) - _post = try values.decodeIfPresent(LazyReference.self, forKey: .post) ?? LazyReference(identifiers: nil) - createdAt = try? values.decode(Temporal.DateTime?.self, forKey: .createdAt) - updatedAt = try? values.decode(Temporal.DateTime?.self, forKey: .updatedAt) + self.id = try values.decode(String.self, forKey: .id) + self.content = try values.decode(String.self, forKey: .content) + self._post = try values.decodeIfPresent(LazyReference.self, forKey: .post) ?? LazyReference(identifiers: nil) + self.createdAt = try? values.decode(Temporal.DateTime?.self, forKey: .createdAt) + self.updatedAt = try? values.decode(Temporal.DateTime?.self, forKey: .updatedAt) } - + public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) @@ -160,32 +172,32 @@ public struct LazyChildComment4V2: Model { } } -extension LazyChildComment4V2 { +public extension LazyChildComment4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post case createdAt case updatedAt } - - public static let keys = CodingKeys.self + + static let keys = CodingKeys.self // MARK: - ModelSchema - - public static let schema = defineSchema { model in + + static let schema = defineSchema { model in let comment4V2 = Comment4V2.keys - + model.authRules = [ rule(allow: .public, operations: [.create, .update, .delete, .read]) ] - + model.pluralName = "LazyChildComment4V2s" - + model.attributes( .index(fields: ["postID", "content"], name: "byPost4") ) - + model.fields( .id(), .field(comment4V2.content, is: .required, ofType: .string), @@ -205,20 +217,26 @@ public struct ParentPost4V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, title: String, - comments: List? = []) { - self.init(id: id, - title: title, - comments: comments, - createdAt: nil, - updatedAt: nil) + comments: List? = [] + ) { + self.init( + id: id, + title: title, + comments: comments, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, + init( + id: String = UUID().uuidString, title: String, comments: List? = [], createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.title = title self.comments = comments @@ -226,9 +244,9 @@ public struct ParentPost4V2: Model { self.updatedAt = updatedAt } } -extension ParentPost4V2 { +public extension ParentPost4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case title case comments @@ -236,24 +254,24 @@ extension ParentPost4V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let post4V2 = Post4V2.keys model.authRules = [ - rule(allow: .public, operations: [.create, .update, .delete, .read]) + rule(allow: .public, operations: [.create, .update, .delete, .read]) ] model.pluralName = "ParentPost4V2s" model.fields( - .id(), - .field(post4V2.title, is: .required, ofType: .string), - .hasMany(post4V2.comments, is: .optional, ofType: ChildComment4V2.self, associatedWith: ChildComment4V2.keys.post), - .field(post4V2.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), - .field(post4V2.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) + .id(), + .field(post4V2.title, is: .required, ofType: .string), + .hasMany(post4V2.comments, is: .optional, ofType: ChildComment4V2.self, associatedWith: ChildComment4V2.keys.post), + .field(post4V2.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), + .field(post4V2.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) } } @@ -265,20 +283,26 @@ public struct ChildComment4V2: Model { public var createdAt: Temporal.DateTime? public var updatedAt: Temporal.DateTime? - public init(id: String = UUID().uuidString, + public init( + id: String = UUID().uuidString, content: String, - post: ParentPost4V2? = nil) { - self.init(id: id, - content: content, - post: post, - createdAt: nil, - updatedAt: nil) + post: ParentPost4V2? = nil + ) { + self.init( + id: id, + content: content, + post: post, + createdAt: nil, + updatedAt: nil + ) } - internal init(id: String = UUID().uuidString, + init( + id: String = UUID().uuidString, content: String, post: ParentPost4V2? = nil, createdAt: Temporal.DateTime? = nil, - updatedAt: Temporal.DateTime? = nil) { + updatedAt: Temporal.DateTime? = nil + ) { self.id = id self.content = content self.post = post @@ -287,9 +311,9 @@ public struct ChildComment4V2: Model { } } -extension ChildComment4V2 { +public extension ChildComment4V2 { // MARK: - CodingKeys - public enum CodingKeys: String, ModelKey { + enum CodingKeys: String, ModelKey { case id case content case post @@ -297,14 +321,14 @@ extension ChildComment4V2 { case updatedAt } - public static let keys = CodingKeys.self + static let keys = CodingKeys.self // MARK: - ModelSchema - public static let schema = defineSchema { model in + static let schema = defineSchema { model in let comment4V2 = Comment4V2.keys model.authRules = [ - rule(allow: .public, operations: [.create, .update, .delete, .read]) + rule(allow: .public, operations: [.create, .update, .delete, .read]) ] model.pluralName = "ChildComment4V2s" @@ -314,11 +338,11 @@ extension ChildComment4V2 { ) model.fields( - .id(), - .field(comment4V2.content, is: .required, ofType: .string), - .belongsTo(comment4V2.post, is: .optional, ofType: ParentPost4V2.self, targetName: "postID"), - .field(comment4V2.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), - .field(comment4V2.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) + .id(), + .field(comment4V2.content, is: .required, ofType: .string), + .belongsTo(comment4V2.post, is: .optional, ofType: ParentPost4V2.self, targetName: "postID"), + .field(comment4V2.createdAt, is: .optional, isReadOnly: true, ofType: .dateTime), + .field(comment4V2.updatedAt, is: .optional, isReadOnly: true, ofType: .dateTime) ) } } diff --git a/AmplifyTestCommon/TestCommonConstants.swift b/AmplifyTestCommon/TestCommonConstants.swift index 3f0128987b..7abbade9bd 100644 --- a/AmplifyTestCommon/TestCommonConstants.swift +++ b/AmplifyTestCommon/TestCommonConstants.swift @@ -6,6 +6,7 @@ // import Foundation + class TestCommonConstants { static let networkTimeout = TimeInterval(10) } diff --git a/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift b/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift index 09a85d35ab..0c6619a20a 100644 --- a/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift +++ b/AmplifyTests/CategoryTests/API/APICategoryClientGraphQLTests.swift @@ -55,7 +55,7 @@ class APICategoryClientGraphQLTests: XCTestCase { } let request = GraphQLRequest(document: "", variables: nil, responseType: JSONValue.self) - + let mutateCompleted = expectation(description: "mutate completed") Task { _ = try await Amplify.API.mutate(request: request) diff --git a/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift index 56ea2b9c39..3b40b0bbc8 100644 --- a/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/API/APICategoryConfigurationTests.swift @@ -99,8 +99,10 @@ class APICategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.API.getPlugin(for: "MockAPICategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.API.getPlugin(for: "MockAPICategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case APIError.invalidConfiguration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -213,7 +215,7 @@ class APICategoryConfigurationTests: XCTestCase { let amplifyConfig = AmplifyConfiguration(api: apiConfig) try Amplify.configure(amplifyConfig) - + let getCompleted = expectation(description: "get completed") Task { let plugin = try Amplify.API.getPlugin(for: "MockSecondAPICategoryPlugin") @@ -286,8 +288,10 @@ class APICategoryConfigurationTests: XCTestCase { try Amplify.API.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.API.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.API.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -395,8 +399,10 @@ class APICategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/API/NondeterminsticOperationTests.swift b/AmplifyTests/CategoryTests/API/NondeterminsticOperationTests.swift index 2923117710..889b8723cb 100644 --- a/AmplifyTests/CategoryTests/API/NondeterminsticOperationTests.swift +++ b/AmplifyTests/CategoryTests/API/NondeterminsticOperationTests.swift @@ -5,7 +5,6 @@ // SPDX-License-Identifier: Apache-2.0 // - import XCTest @testable import Amplify diff --git a/AmplifyTests/CategoryTests/API/RetryableGraphQLOperationTests.swift b/AmplifyTests/CategoryTests/API/RetryableGraphQLOperationTests.swift index a9e374f9e8..b424a6cb34 100644 --- a/AmplifyTests/CategoryTests/API/RetryableGraphQLOperationTests.swift +++ b/AmplifyTests/CategoryTests/API/RetryableGraphQLOperationTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // +import Combine import Foundation import XCTest -import Combine @testable import Amplify @testable import AmplifyTestCommon diff --git a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryClientAPITests.swift b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryClientAPITests.swift index 9e1d8c8044..9c7f45c22d 100644 --- a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryClientAPITests.swift +++ b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryClientAPITests.swift @@ -107,7 +107,7 @@ class AnalyticsCategoryClientAPITests: XCTestCase { analytics.unregisterGlobalProperties("one", "two") await fulfillment(of: [methodInvoked], timeout: 1) } - + func testUnregisterGlobalPropertiesWithArrayParameter() async throws { let expectedMessage = "unregisterGlobalProperties(_:)" let methodInvoked = expectation(description: "Expected method was invoked on plugin") diff --git a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift index b4eaef7b6b..95d1f07ade 100644 --- a/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Analytics/AnalyticsCategoryConfigurationTests.swift @@ -98,8 +98,10 @@ class AnalyticsCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Analytics.getPlugin(for: "MockAnalyticsCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Analytics.getPlugin(for: "MockAnalyticsCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case AnalyticsError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -260,8 +262,10 @@ class AnalyticsCategoryConfigurationTests: XCTestCase { ) try Amplify.Analytics.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Analytics.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Analytics.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -337,8 +341,10 @@ class AnalyticsCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift index 8cb62497d4..8312114193 100644 --- a/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Auth/AuthCategoryConfigurationTests.swift @@ -64,7 +64,7 @@ class AuthCategoryConfigurationTests: XCTestCase { func testCanConfigureCategoryWithAmplifyOutputs() throws { let plugin = MockAuthCategoryPlugin() try Amplify.add(plugin: plugin) - + let config = AmplifyOutputsData() try Amplify.configure(config) @@ -121,8 +121,10 @@ class AuthCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Auth.getPlugin(for: "MockAuthCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Auth.getPlugin(for: "MockAuthCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case AuthError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -336,8 +338,10 @@ class AuthCategoryConfigurationTests: XCTestCase { ) XCTAssertNoThrow(try Amplify.Auth.configure(using: config)) - XCTAssertThrowsError(try Amplify.Auth.configure(using: config), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Auth.configure(using: config), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -445,8 +449,10 @@ class AuthCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryConfigurationTests.swift index 18d4014d56..7131b777f6 100644 --- a/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/DataStoreCategoryConfigurationTests.swift @@ -105,8 +105,10 @@ class DataStoreCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.DataStore.getPlugin(for: "MockDataStoreCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.DataStore.getPlugin(for: "MockDataStoreCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case DataStoreError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -221,7 +223,7 @@ class DataStoreCategoryConfigurationTests: XCTestCase { let amplifyConfig = AmplifyConfiguration(dataStore: dataStoreConfig) try Amplify.configure(amplifyConfig) - + let saveSuccess = expectation(description: "save success") Task { _ = try await Amplify.DataStore.getPlugin(for: "MockSecondDataStoreCategoryPlugin") @@ -294,8 +296,10 @@ class DataStoreCategoryConfigurationTests: XCTestCase { ) try Amplify.DataStore.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.DataStore.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.DataStore.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -371,8 +375,10 @@ class DataStoreCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/DataStore/JSONValueHolderTest.swift b/AmplifyTests/CategoryTests/DataStore/JSONValueHolderTest.swift index 7fdd8ce982..46376e9537 100644 --- a/AmplifyTests/CategoryTests/DataStore/JSONValueHolderTest.swift +++ b/AmplifyTests/CategoryTests/DataStore/JSONValueHolderTest.swift @@ -5,14 +5,16 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest class JSONValueHolderTest: XCTestCase { - var jsonValueHodler = DynamicModel(values: ["id": 123, - "name": nil, - "comment": "here is a comment"]) + var jsonValueHodler = DynamicModel(values: [ + "id": 123, + "name": nil, + "comment": "here is a comment" + ]) func testJsonDoubleValue() { guard let id = jsonValueHodler.jsonValue(for: "id") as? Double else { diff --git a/AmplifyTests/CategoryTests/DataStore/Model/Collection/ArrayLiteralListProviderTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/Collection/ArrayLiteralListProviderTests.swift index 70835d17d1..78b9a399d7 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/Collection/ArrayLiteralListProviderTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/Collection/ArrayLiteralListProviderTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest class ArrayLiteralListProviderTests: XCTestCase { struct BasicModel: Model { @@ -42,7 +42,7 @@ class ArrayLiteralListProviderTests: XCTestCase { wait(for: [loadComplete], timeout: 1) } - + func testLoadAsync() async throws { let provider = ArrayLiteralListProvider(elements: [BasicModel(id: "id")]) let elements = try await provider.load() @@ -73,7 +73,7 @@ class ArrayLiteralListProviderTests: XCTestCase { wait(for: [getNextPageComplete], timeout: 1) } - + func testGetNextPageAsync() async { let provider = ArrayLiteralListProvider(elements: [BasicModel(id: "id")]) do { diff --git a/AmplifyTests/CategoryTests/DataStore/Model/LazyReferenceTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/LazyReferenceTests.swift index 16ea4fc54a..21005b4b4e 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/LazyReferenceTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/LazyReferenceTests.swift @@ -10,28 +10,28 @@ import XCTest @testable import AmplifyTestCommon final class LazyReferenceTests: XCTestCase { - + override func setUp() { ModelRegistry.register(modelType: LazyParentPost4V2.self) ModelRegistry.register(modelType: LazyChildComment4V2.self) } - + class MockModelProvider: ModelProvider { enum LoadedState { case notLoaded(identifiers: [LazyReferenceIdentifier]?) case loaded(model: ModelType?) } - + var loadedState: LoadedState - + init(loadedState: LoadedState) { self.loadedState = loadedState } - + func load() async throws -> Element? { return nil } - + func getState() -> ModelProviderState { switch loadedState { case .notLoaded(let identifiers): @@ -40,7 +40,7 @@ final class LazyReferenceTests: XCTestCase { return .loaded(model: model) } } - + func encode(to encoder: Encoder) throws { switch loadedState { case .notLoaded(let identifiers): @@ -51,7 +51,7 @@ final class LazyReferenceTests: XCTestCase { } } } - + func testEncodeDecodeLoaded() throws { let post = LazyParentPost4V2(id: "postId", title: "t") let comment = LazyChildComment4V2(id: "commentId", content: "c", post: post) @@ -75,22 +75,22 @@ final class LazyReferenceTests: XCTestCase { XCTAssertEqual(loadedPost.title, post.title) } } - + func testEncodeNotLoaded() async throws { var comment = LazyChildComment4V2(id: "commentId", content: "content") let modelProvider = MockModelProvider(loadedState: .notLoaded(identifiers: [.init(name: "id", value: "postId")])).eraseToAnyModelProvider() - + comment._post = LazyReference(modelProvider: modelProvider) let json = try comment.toJSON() let expectedJSON = #"{"content":"content","createdAt":null,"id":"commentId","post":[{"name":"id","value":"postId"}],"updatedAt":null}"# XCTAssertEqual(json, expectedJSON) } - + func testDecodePrimaryKeysOnly() async throws { let postIdentifierName = "id" let postIdentifierValue = UUID().uuidString - + let commentWithLazyPostJSON = """ { "post": { @@ -102,21 +102,21 @@ final class LazyReferenceTests: XCTestCase { "createdAt": null } """ - + let model = try ModelRegistry.decode( modelName: LazyChildComment4V2.modelName, from: commentWithLazyPostJSON ) - + let decodedComment = try XCTUnwrap(model as? LazyChildComment4V2) - + switch decodedComment._post.loadedState { case .notLoaded(let unloadedIdentifiers): let identifiers = try XCTUnwrap(unloadedIdentifiers) let descriptions = identifiers.map { "\($0.name): \($0.value)" } - + XCTAssertEqual(descriptions, ["\(postIdentifierName): \(postIdentifierValue)"]) - + case .loaded: XCTFail("Should be not loaded") } diff --git a/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift index 83215fc64e..284228e8d8 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/ListPaginationTests.swift @@ -9,7 +9,7 @@ import XCTest @testable import Amplify extension ListTests { - + func testFetchSuccess() async throws { let mockListProvider = MockListProvider(elements: [BasicModel]()).eraseToAnyModelListProvider() let list = List(listProvider: mockListProvider) @@ -19,7 +19,7 @@ extension ListTests { } let fetchComplete = expectation(description: "fetch completed") Task { - + try await list.fetch() guard case .loaded = list.loadedState else { XCTFail("Should be loaded") @@ -28,7 +28,7 @@ extension ListTests { fetchComplete.fulfill() } await fulfillment(of: [fetchComplete], timeout: 1) - + let fetchComplete2 = expectation(description: "fetch completed") Task { try await list.fetch() @@ -60,7 +60,7 @@ extension ListTests { } fetchCompleted.fulfill() } - + await fulfillment(of: [fetchCompleted], timeout: 1.0) } @@ -100,7 +100,7 @@ extension ListTests { getNextPageSuccess.fulfill() } await fulfillment(of: [getNextPageSuccess], timeout: 1.0) - + guard case .loaded = list.loadedState else { XCTFail("Should be loaded") return @@ -128,7 +128,7 @@ extension ListTests { fetchCompleted.fulfill() } await fulfillment(of: [fetchCompleted], timeout: 1.0) - + let getNextPageSuccess = expectation(description: "getNextPage successful") Task { do { diff --git a/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift b/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift index 26cefa0422..961aa02d9c 100644 --- a/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/Model/ListTests.swift @@ -43,13 +43,15 @@ class ListTests: XCTestCase { var errorOnNextPage: CoreError? var nextPage: List? var state: ModelListProviderState? - - public init(elements: [Element] = [Element](), - error: CoreError? = nil, - errorOnLoad: CoreError? = nil, - errorOnNextPage: CoreError? = nil, - nextPage: List? = nil, - state: ModelListProviderState? = nil) { + + public init( + elements: [Element] = [Element](), + error: CoreError? = nil, + errorOnLoad: CoreError? = nil, + errorOnNextPage: CoreError? = nil, + nextPage: List? = nil, + state: ModelListProviderState? = nil + ) { self.elements = elements self.error = error self.errorOnLoad = errorOnLoad @@ -61,9 +63,9 @@ class ListTests: XCTestCase { public func getState() -> ModelListProviderState { state ?? .notLoaded(associatedIdentifiers: [""], associatedFields: [""]) } - + public func load(completion: (Result<[Element], CoreError>) -> Void) { - if let error = error { + if let error { completion(.failure(error)) } else if let error = errorOnLoad { completion(.failure(error)) @@ -71,9 +73,9 @@ class ListTests: XCTestCase { completion(.success(elements)) } } - + public func load() async throws -> [Element] { - if let error = error { + if let error { throw error } else if let error = errorOnLoad { throw error @@ -87,29 +89,29 @@ class ListTests: XCTestCase { } public func getNextPage(completion: (Result, CoreError>) -> Void) { - if let error = error { + if let error { completion(.failure(error)) } else if let error = errorOnNextPage { completion(.failure(error)) - } else if let nextPage = nextPage { + } else if let nextPage { completion(.success(nextPage)) } else { fatalError("Mock not implemented") } } - + public func getNextPage() async throws -> List { - if let error = error { + if let error { throw error } else if let error = errorOnNextPage { throw error - } else if let nextPage = nextPage { + } else if let nextPage { return nextPage } else { fatalError("Mock not implemented") } } - + func encode(to encoder: Encoder) throws { try elements.encode(to: encoder) } @@ -137,7 +139,7 @@ class ListTests: XCTestCase { fetchSuccess.fulfill() } await fulfillment(of: [fetchSuccess], timeout: 1.0) - + XCTAssertEqual(list.count, 2) XCTAssertEqual(list.startIndex, 0) XCTAssertEqual(list.endIndex, 2) @@ -145,7 +147,7 @@ class ListTests: XCTestCase { XCTAssertNotNil(list[0]) let iterateSuccess = expectation(description: "Iterate over the list successfullly") iterateSuccess.expectedFulfillmentCount = 2 - list.makeIterator().forEach { _ in + for _ in list.makeIterator() { iterateSuccess.fulfill() } await fulfillment(of: [iterateSuccess], timeout: 1) @@ -178,7 +180,7 @@ class ListTests: XCTestCase { XCTAssertNotNil(list[0]) let iterateSuccess = expectation(description: "Iterate over the list successfullly") iterateSuccess.expectedFulfillmentCount = 2 - list.makeIterator().forEach { _ in + for _ in list.makeIterator() { iterateSuccess.fulfill() } await fulfillment(of: [iterateSuccess], timeout: 1) @@ -238,7 +240,7 @@ class ListTests: XCTestCase { return try encoder.encode(json) } - private static func toJSON(list: List) throws -> String { + private static func toJSON(list: List) throws -> String { let encoder = JSONEncoder() encoder.dateEncodingStrategy = ModelDateFormatting.encodingStrategy let data = try encoder.encode(list) diff --git a/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift b/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift index fab9543e07..00845a7a6a 100644 --- a/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/ModelFieldAssociationTests.swift @@ -80,9 +80,11 @@ class ModelFieldAssociationTests: XCTestCase { func testModelFieldWithBelongsToAssociation() { let belongsTo = ModelAssociation.belongsTo(associatedWith: nil, targetNames: ["commentPostId"]) - let field = ModelField.init(name: "post", - type: .model(type: Post.self), - association: belongsTo) + let field = ModelField.init( + name: "post", + type: .model(type: Post.self), + association: belongsTo + ) XCTAssertEqual("Post", field.associatedModelName) XCTAssertTrue(field.hasAssociation) @@ -91,10 +93,12 @@ class ModelFieldAssociationTests: XCTestCase { func testModelFieldWithHasManyAssociation() { let hasMany = ModelAssociation.hasMany(associatedWith: Comment.keys.post) - let field = ModelField.init(name: "comments", - type: .collection(of: Comment.self), - isArray: true, - association: hasMany) + let field = ModelField.init( + name: "comments", + type: .collection(of: Comment.self), + isArray: true, + association: hasMany + ) XCTAssertEqual("Comment", field.associatedModelName) XCTAssertTrue(field.hasAssociation) @@ -104,9 +108,11 @@ class ModelFieldAssociationTests: XCTestCase { func testModelFieldWithHasOneAssociation() { let hasOne = ModelAssociation.hasOne(associatedWith: Comment.keys.post, targetNames: ["postID"]) - let field = ModelField.init(name: "comment", - type: .model(type: Comment.self), - association: hasOne) + let field = ModelField.init( + name: "comment", + type: .model(type: Comment.self), + association: hasOne + ) XCTAssertEqual("Comment", field.associatedModelName) XCTAssertTrue(field.hasAssociation) diff --git a/AmplifyTests/CategoryTests/DataStore/ModelIdentifierTests.swift b/AmplifyTests/CategoryTests/DataStore/ModelIdentifierTests.swift index 8d8f607f21..4689aae23d 100644 --- a/AmplifyTests/CategoryTests/DataStore/ModelIdentifierTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/ModelIdentifierTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify import AmplifyTestCommon +import XCTest class ModelIdentifierTests: XCTestCase { override func setUp() { @@ -106,9 +106,11 @@ class ModelIdentifierTests: XCTestCase { } func testModelIdentifierCompositePredicate() { - let model = ModelCompositePk(id: "id", - dob: Temporal.DateTime.now(), - name: "name") + let model = ModelCompositePk( + id: "id", + dob: Temporal.DateTime.now(), + name: "name" + ) let identifier = model.identifier(schema: ModelCompositePk.schema) diff --git a/AmplifyTests/CategoryTests/DataStore/ModelPrimaryKeyTests.swift b/AmplifyTests/CategoryTests/DataStore/ModelPrimaryKeyTests.swift index 7554746cea..1e871a2b1e 100644 --- a/AmplifyTests/CategoryTests/DataStore/ModelPrimaryKeyTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/ModelPrimaryKeyTests.swift @@ -98,7 +98,7 @@ class ModelPrimaryKeyTests: XCTestCase { let expectedFieldsNames = ["id", "dob", "date", "time", "phoneNumber", "priority", "height"] XCTAssertEqual(primaryKey.isCompositeKey, true) XCTAssertEqual(primaryKey.fields.count, 7) - XCTAssertEqual(primaryKey.fields.map { $0.name }, expectedFieldsNames) + XCTAssertEqual(primaryKey.fields.map(\.name), expectedFieldsNames) } /// Given: a schema for model with a composite primary key field @@ -110,7 +110,7 @@ class ModelPrimaryKeyTests: XCTestCase { let expectedFieldsNames = ["id", "dob"] XCTAssertEqual(primaryKey.isCompositeKey, true) XCTAssertEqual(primaryKey.fields.count, 2) - XCTAssertEqual(primaryKey.fields.map { $0.name }, expectedFieldsNames) + XCTAssertEqual(primaryKey.fields.map(\.name), expectedFieldsNames) } /// Given: a schema for model with a legacy composite primary key field @@ -121,7 +121,7 @@ class ModelPrimaryKeyTests: XCTestCase { let expectedFieldsNames = ["orderId", "id"] XCTAssertEqual(primaryKey.isCompositeKey, true) XCTAssertEqual(primaryKey.fields.count, 2) - XCTAssertEqual(primaryKey.fields.map { $0.name }, expectedFieldsNames) + XCTAssertEqual(primaryKey.fields.map(\.name), expectedFieldsNames) } /// Given: a schema for model with an untyped model diff --git a/AmplifyTests/CategoryTests/DataStore/ModelRegistryTests.swift b/AmplifyTests/CategoryTests/DataStore/ModelRegistryTests.swift index 86a848511a..e9db674dd4 100644 --- a/AmplifyTests/CategoryTests/DataStore/ModelRegistryTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/ModelRegistryTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest @testable import AmplifyTestCommon class ModelRegistryTests: XCTestCase { diff --git a/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift b/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift index 914cd6ee24..e18d519486 100644 --- a/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift +++ b/AmplifyTests/CategoryTests/DataStore/TemporalTests.swift @@ -35,7 +35,8 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime.iso8601FormattedString(format: .long, timeZone: .utc), "2020-01-20T08:00:00Z") XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: pst), - "2020-01-20T00:00:00.000-08:00") + "2020-01-20T00:00:00.000-08:00" + ) XCTAssertEqual(datetime.iso8601FormattedString(format: .full, timeZone: .utc), "2020-01-20T08:00:00.000Z") } catch { XCTFail(error.localizedDescription) @@ -105,7 +106,8 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime.iso8601FormattedString(format: .long, timeZone: .utc), "2020-01-20T08:00:00Z") XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: pst), - "2020-01-20T00:00:00.000-08:00") + "2020-01-20T00:00:00.000-08:00" + ) XCTAssertEqual(datetime.iso8601FormattedString(format: .full, timeZone: .utc), "2020-01-20T08:00:00.000Z") } catch { XCTFail(error.localizedDescription) @@ -125,28 +127,36 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime.iso8601String, "2020-01-20T08:00:00.000Z") XCTAssertEqual( datetime.iso8601FormattedString(format: .short, timeZone: pst), - "2020-01-20T00:00") + "2020-01-20T00:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .short, timeZone: .utc), - "2020-01-20T08:00") + "2020-01-20T08:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .medium, timeZone: pst), - "2020-01-20T00:00:00") + "2020-01-20T00:00:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .medium, timeZone: .utc), - "2020-01-20T08:00:00") + "2020-01-20T08:00:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .long, timeZone: pst), - "2020-01-20T00:00:00-08:00") + "2020-01-20T00:00:00-08:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .long, timeZone: .utc), - "2020-01-20T08:00:00Z") + "2020-01-20T08:00:00Z" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: pst), - "2020-01-20T00:00:00.000-08:00") + "2020-01-20T00:00:00.000-08:00" + ) XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: .utc), - "2020-01-20T08:00:00.000Z") + "2020-01-20T08:00:00.000Z" + ) } catch { XCTFail(error.localizedDescription) } @@ -171,7 +181,8 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime.iso8601FormattedString(format: .long, timeZone: .utc), "2020-01-20T08:00:00Z") XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: pst), - "2020-01-20T00:00:00.180-08:00") + "2020-01-20T00:00:00.180-08:00" + ) XCTAssertEqual(datetime.iso8601FormattedString(format: .full, timeZone: .utc), "2020-01-20T08:00:00.180Z") } catch { XCTFail(error.localizedDescription) @@ -197,7 +208,8 @@ class TemporalTests: XCTestCase { XCTAssertEqual(datetime.iso8601FormattedString(format: .long, timeZone: .utc), "2020-01-20T16:00:00Z") XCTAssertEqual( datetime.iso8601FormattedString(format: .full, timeZone: pst), - "2020-01-20T08:00:00.180-08:00") + "2020-01-20T08:00:00.180-08:00" + ) XCTAssertEqual(datetime.iso8601FormattedString(format: .full, timeZone: .utc), "2020-01-20T16:00:00.180Z") } catch { XCTFail(error.localizedDescription) diff --git a/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift index 75767a9689..ad40da96dd 100644 --- a/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Geo/GeoCategoryConfigurationTests.swift @@ -80,8 +80,10 @@ class GeoCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Geo.getPlugin(for: "MockGeoCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Geo.getPlugin(for: "MockGeoCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case Geo.Error.invalidConfiguration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -239,8 +241,10 @@ class GeoCategoryConfigurationTests: XCTestCase { ) try Amplify.Geo.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Geo.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Geo.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -316,8 +320,10 @@ class GeoCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift b/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift index 0a5b3a01d1..4af4f96b8d 100644 --- a/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift +++ b/AmplifyTests/CategoryTests/Hub/AmplifyOperationHubTests.swift @@ -119,101 +119,125 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { func configure(using configuration: Any?) throws {} - func getURL(key: String, - options: StorageGetURLRequest.Options? = nil, - resultListener: StorageGetURLOperation.ResultListener? = nil) -> StorageGetURLOperation { + func getURL( + key: String, + options: StorageGetURLRequest.Options? = nil, + resultListener: StorageGetURLOperation.ResultListener? = nil + ) -> StorageGetURLOperation { let options = options ?? StorageGetURLRequest.Options() let request = StorageGetURLRequest(key: key, options: options) - let operation = MockDispatchingStorageGetURLOperation(request: request, - resultListener: resultListener) + let operation = MockDispatchingStorageGetURLOperation( + request: request, + resultListener: resultListener + ) return operation } - func downloadData(key: String, - options: StorageDownloadDataRequest.Options? = nil, - progressListener: ProgressListener? = nil, - resultListener: StorageDownloadDataOperation.ResultListener? = nil + func downloadData( + key: String, + options: StorageDownloadDataRequest.Options? = nil, + progressListener: ProgressListener? = nil, + resultListener: StorageDownloadDataOperation.ResultListener? = nil ) -> StorageDownloadDataOperation { let options = options ?? StorageDownloadDataRequest.Options() let request = StorageDownloadDataRequest(key: key, options: options) - let operation = MockDispatchingStorageDownloadDataOperation(request: request, - progressListener: progressListener, - resultListener: resultListener) + let operation = MockDispatchingStorageDownloadDataOperation( + request: request, + progressListener: progressListener, + resultListener: resultListener + ) return operation } - func downloadFile(key: String, - local: URL, - options: StorageDownloadFileRequest.Options? = nil, - progressListener: ProgressListener? = nil, - resultListener: StorageDownloadFileOperation.ResultListener? = nil + func downloadFile( + key: String, + local: URL, + options: StorageDownloadFileRequest.Options? = nil, + progressListener: ProgressListener? = nil, + resultListener: StorageDownloadFileOperation.ResultListener? = nil ) -> StorageDownloadFileOperation { let options = options ?? StorageDownloadFileRequest.Options() let request = StorageDownloadFileRequest(key: key, local: local, options: options) - let operation = MockDispatchingStorageDownloadFileOperation(request: request, - progressListener: progressListener, - resultListener: resultListener) + let operation = MockDispatchingStorageDownloadFileOperation( + request: request, + progressListener: progressListener, + resultListener: resultListener + ) return operation } - func uploadData(key: String, - data: Data, - options: StorageUploadDataRequest.Options? = nil, - progressListener: ProgressListener? = nil, - resultListener: StorageUploadDataOperation.ResultListener? = nil + func uploadData( + key: String, + data: Data, + options: StorageUploadDataRequest.Options? = nil, + progressListener: ProgressListener? = nil, + resultListener: StorageUploadDataOperation.ResultListener? = nil ) -> StorageUploadDataOperation { let options = options ?? StorageUploadDataRequest.Options() let request = StorageUploadDataRequest(key: key, data: data, options: options) - let operation = MockDispatchingStorageUploadDataOperation(request: request, - progressListener: progressListener, - resultListener: resultListener) + let operation = MockDispatchingStorageUploadDataOperation( + request: request, + progressListener: progressListener, + resultListener: resultListener + ) return operation } - func uploadFile(key: String, - local: URL, - options: StorageUploadFileRequest.Options? = nil, - progressListener: ProgressListener? = nil, - resultListener: StorageUploadFileOperation.ResultListener? = nil + func uploadFile( + key: String, + local: URL, + options: StorageUploadFileRequest.Options? = nil, + progressListener: ProgressListener? = nil, + resultListener: StorageUploadFileOperation.ResultListener? = nil ) -> StorageUploadFileOperation { let options = options ?? StorageUploadFileRequest.Options() let request = StorageUploadFileRequest(key: key, local: local, options: options) - let operation = MockDispatchingStorageUploadFileOperation(request: request, - progressListener: progressListener, - resultListener: resultListener) + let operation = MockDispatchingStorageUploadFileOperation( + request: request, + progressListener: progressListener, + resultListener: resultListener + ) return operation } - func remove(key: String, - options: StorageRemoveRequest.Options? = nil, - resultListener: StorageRemoveOperation.ResultListener? = nil) -> StorageRemoveOperation { + func remove( + key: String, + options: StorageRemoveRequest.Options? = nil, + resultListener: StorageRemoveOperation.ResultListener? = nil + ) -> StorageRemoveOperation { let options = options ?? StorageRemoveRequest.Options() let request = StorageRemoveRequest(key: key, options: options) - let operation = MockDispatchingStorageRemoveOperation(request: request, - resultListener: resultListener) + let operation = MockDispatchingStorageRemoveOperation( + request: request, + resultListener: resultListener + ) return operation } - func list(options: StorageListRequest.Options?, - resultListener: StorageListOperation.ResultListener?) -> StorageListOperation { + func list( + options: StorageListRequest.Options?, + resultListener: StorageListOperation.ResultListener? + ) -> StorageListOperation { let options = options ?? StorageListRequest.Options() let request = StorageListRequest(options: options) - let operation = MockDispatchingStorageListOperation(request: request, - resultListener: resultListener) + let operation = MockDispatchingStorageListOperation( + request: request, + resultListener: resultListener + ) return operation } @@ -228,8 +252,10 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { // MARK: - Async API - @discardableResult - func getURL(key: String, - options: StorageGetURLOperation.Request.Options?) async throws -> URL { + func getURL( + key: String, + options: StorageGetURLOperation.Request.Options? + ) async throws -> URL { let options = options ?? StorageGetURLRequest.Options() let request = StorageGetURLRequest(key: key, options: options) let operation = MockStorageGetURLOperation(request: request) @@ -238,8 +264,10 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { } @discardableResult - public func downloadData(key: String, - options: StorageDownloadDataOperation.Request.Options? = nil) -> StorageDownloadDataTask { + public func downloadData( + key: String, + options: StorageDownloadDataOperation.Request.Options? = nil + ) -> StorageDownloadDataTask { let options = options ?? StorageDownloadDataRequest.Options() let request = StorageDownloadDataRequest(key: key, options: options) let operation = MockDispatchingStorageDownloadDataOperation(request: request) @@ -248,9 +276,11 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { } @discardableResult - public func downloadFile(key: String, - local: URL, - options: StorageDownloadFileOperation.Request.Options?) -> StorageDownloadFileTask { + public func downloadFile( + key: String, + local: URL, + options: StorageDownloadFileOperation.Request.Options? + ) -> StorageDownloadFileTask { let options = options ?? StorageDownloadFileRequest.Options() let request = StorageDownloadFileRequest(key: key, local: local, options: options) let operation = MockDispatchingStorageDownloadFileOperation(request: request) @@ -259,9 +289,11 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { } @discardableResult - public func uploadData(key: String, - data: Data, - options: StorageUploadDataOperation.Request.Options?) -> StorageUploadDataTask { + public func uploadData( + key: String, + data: Data, + options: StorageUploadDataOperation.Request.Options? + ) -> StorageUploadDataTask { let options = options ?? StorageUploadDataRequest.Options() let request = StorageUploadDataRequest(key: key, data: data, options: options) let operation = MockDispatchingStorageUploadDataOperation(request: request) @@ -270,9 +302,11 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { } @discardableResult - public func uploadFile(key: String, - local: URL, - options: StorageUploadFileOperation.Request.Options?) -> StorageUploadFileTask { + public func uploadFile( + key: String, + local: URL, + options: StorageUploadFileOperation.Request.Options? + ) -> StorageUploadFileTask { let options = options ?? StorageUploadFileRequest.Options() let request = StorageUploadFileRequest(key: key, local: local, options: options) let operation = MockDispatchingStorageUploadFileOperation(request: request) @@ -281,8 +315,10 @@ class MockDispatchingStoragePlugin: StorageCategoryPlugin { } @discardableResult - public func remove(key: String, - options: StorageRemoveRequest.Options? = nil) async throws -> String { + public func remove( + key: String, + options: StorageRemoveRequest.Options? = nil + ) async throws -> String { let options = options ?? StorageRemoveRequest.Options() let request = StorageRemoveRequest(key: key, options: options) let operation = MockDispatchingStorageRemoveOperation(request: request) @@ -396,11 +432,13 @@ class MockDispatchingStorageDownloadFileOperation: AmplifyInProcessReportingOper StorageError >, StorageDownloadFileOperation { init(request: Request, progressListener: ProgressListener? = nil, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.downloadFile, - request: request, - inProcessListener: progressListener, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.downloadFile, + request: request, + inProcessListener: progressListener, + resultListener: resultListener + ) } func doMockDispatch() { @@ -420,11 +458,13 @@ class MockDispatchingStorageDownloadDataOperation: AmplifyInProcessReportingOper StorageError >, StorageDownloadDataOperation { init(request: Request, progressListener: ProgressListener? = nil, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.downloadData, - request: request, - inProcessListener: progressListener, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.downloadData, + request: request, + inProcessListener: progressListener, + resultListener: resultListener + ) } func doMockDispatch(result: StorageDownloadDataOperation.OperationResult = .success(Data())) { @@ -442,10 +482,12 @@ class MockDispatchingStorageGetURLOperation: AmplifyOperation< StorageError >, StorageGetURLOperation { init(request: Request, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.getURL, - request: request, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.getURL, + request: request, + resultListener: resultListener + ) } func doMockDispatch(result: StorageGetURLOperation.OperationResult = .success(URL(fileURLWithPath: "/path"))) { @@ -459,10 +501,12 @@ class MockDispatchingStorageListOperation: AmplifyOperation< StorageError >, StorageListOperation { init(request: Request, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.list, - request: request, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.list, + request: request, + resultListener: resultListener + ) } func doMockDispatch() { @@ -476,10 +520,12 @@ class MockDispatchingStorageRemoveOperation: AmplifyOperation< StorageError >, StorageRemoveOperation { init(request: Request, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.remove, - request: request, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.remove, + request: request, + resultListener: resultListener + ) } func doMockDispatch() { @@ -495,11 +541,13 @@ class MockDispatchingStorageUploadDataOperation: AmplifyInProcessReportingOperat StorageError >, StorageUploadDataOperation { init(request: Request, progressListener: ProgressListener? = nil, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.uploadData, - request: request, - inProcessListener: progressListener, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.uploadData, + request: request, + inProcessListener: progressListener, + resultListener: resultListener + ) } func doMockDispatch() { @@ -519,11 +567,13 @@ class MockDispatchingStorageUploadFileOperation: AmplifyInProcessReportingOperat StorageError >, StorageUploadFileOperation { init(request: Request, progressListener: ProgressListener? = nil, resultListener: ResultListener? = nil) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.uploadFile, - request: request, - inProcessListener: progressListener, - resultListener: resultListener) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.uploadFile, + request: request, + inProcessListener: progressListener, + resultListener: resultListener + ) } func doMockDispatch() { @@ -541,8 +591,10 @@ class NonListeningStorageListOperation: AmplifyOperation< StorageError >, StorageListOperation { init(request: Request) { - super.init(categoryType: .storage, - eventName: HubPayload.EventName.Storage.downloadFile, - request: request) + super.init( + categoryType: .storage, + eventName: HubPayload.EventName.Storage.downloadFile, + request: request + ) } } diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift index 0f8284a3d5..1c75747e5a 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginConcurrencyTests.swift @@ -12,7 +12,8 @@ import XCTest class DefaultHubPluginConcurrencyTests: XCTestCase { var plugin: HubCategoryPlugin { guard let plugin = try? Amplify.Hub.getPlugin(for: "awsHubPlugin"), - plugin.key == "awsHubPlugin" else { + plugin.key == "awsHubPlugin" + else { fatalError("Could not access AWSHubPlugin") } return plugin @@ -68,7 +69,7 @@ class DefaultHubPluginConcurrencyTests: XCTestCase { messagesReceived.append(messageReceived) } } - + let capturedChannels = channels DispatchQueue.concurrentPerform(iterations: channels.count) { iteration in diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift index 0e7e0892f5..d02e5207d4 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginCustomChannelTests.swift @@ -14,7 +14,8 @@ class DefaultHubPluginCustomChannelTests: XCTestCase { var plugin: HubCategoryPlugin { guard let plugin = try? Amplify.Hub.getPlugin(for: "awsHubPlugin"), - plugin.key == "awsHubPlugin" else { + plugin.key == "awsHubPlugin" + else { fatalError("Could not access AWSHubPlugin") } return plugin diff --git a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift index bf8fc5394a..a51c295597 100644 --- a/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift +++ b/AmplifyTests/CategoryTests/Hub/DefaultPluginTests/DefaultHubPluginTests.swift @@ -121,15 +121,17 @@ class DefaultHubPluginTests: XCTestCase { } currentExpectation = expectation(description: "Message was received as expected") - guard try await HubListenerTestUtilities.waitForListener(with: unsubscribeToken, - plugin: plugin, - timeout: 0.5) else { + guard try await HubListenerTestUtilities.waitForListener( + with: unsubscribeToken, + plugin: plugin, + timeout: 0.5 + ) else { XCTFail("Token with \(unsubscribeToken.id) was not registered") return } plugin.dispatch(to: .storage, payload: HubPayload(eventName: "TEST_EVENT")) - await fulfillment(of: [try XCTUnwrap(currentExpectation)], timeout: 0.5) + try await fulfillment(of: [XCTUnwrap(currentExpectation)], timeout: 0.5) plugin.removeListener(unsubscribeToken) try? await Task.sleep(seconds: 0.01) @@ -138,16 +140,18 @@ class DefaultHubPluginTests: XCTestCase { currentExpectation = expectation(description: "Message was received after removing listener") currentExpectation?.isInverted = true - await isStillRegistered.set( - try HubListenerTestUtilities.waitForListener(with: unsubscribeToken, - plugin: plugin, - timeout: 0.5) + try await isStillRegistered.set( + HubListenerTestUtilities.waitForListener( + with: unsubscribeToken, + plugin: plugin, + timeout: 0.5 + ) ) XCTAssertFalse(isStillRegistered.get(), "Should not be registered after removeListener") plugin.dispatch(to: .storage, payload: HubPayload(eventName: "TEST_EVENT")) - await fulfillment(of: [try XCTUnwrap(currentExpectation)], timeout: 0.5) + try await fulfillment(of: [XCTUnwrap(currentExpectation)], timeout: 0.5) } /// Given: The default Hub plugin diff --git a/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift index 8f894b74e8..3acdc24177 100644 --- a/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Hub/HubCategoryConfigurationTests.swift @@ -98,8 +98,10 @@ class HubCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Hub.getPlugin(for: "MockHubCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Hub.getPlugin(for: "MockHubCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case HubError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -261,8 +263,10 @@ class HubCategoryConfigurationTests: XCTestCase { ) try Amplify.Hub.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Hub.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Hub.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/Hub/HubCombineTests.swift b/AmplifyTests/CategoryTests/Hub/HubCombineTests.swift index 4f3aedc3fb..2eb4aed86a 100644 --- a/AmplifyTests/CategoryTests/Hub/HubCombineTests.swift +++ b/AmplifyTests/CategoryTests/Hub/HubCombineTests.swift @@ -6,8 +6,8 @@ // #if canImport(Combine) -import XCTest import Combine +import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -43,9 +43,13 @@ class HubCombineTests: XCTestCase { Amplify.Hub.dispatch(to: .auth, payload: HubPayload(eventName: "test")) - await fulfillment(of: [sub1ReceivedValue, - sub2ReceivedValue], - timeout: 0.05) + await fulfillment( + of: [ + sub1ReceivedValue, + sub2ReceivedValue + ], + timeout: 0.05 + ) sub1.cancel() sub2.cancel() @@ -63,9 +67,13 @@ class HubCombineTests: XCTestCase { Amplify.Hub.dispatch(to: .auth, payload: HubPayload(eventName: "test")) Amplify.Hub.dispatch(to: .custom("testChannel"), payload: HubPayload(eventName: "test")) - await fulfillment(of: [receivedValueForAuth, - receivedValueForCustom], - timeout: 0.05) + await fulfillment( + of: [ + receivedValueForAuth, + receivedValueForCustom + ], + timeout: 0.05 + ) authSink.cancel() customSink.cancel() diff --git a/AmplifyTests/CategoryTests/Hub/HubListenerTests.swift b/AmplifyTests/CategoryTests/Hub/HubListenerTests.swift index ba6e2f415b..b77ced94fe 100644 --- a/AmplifyTests/CategoryTests/Hub/HubListenerTests.swift +++ b/AmplifyTests/CategoryTests/Hub/HubListenerTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest @testable import AmplifyTestCommon diff --git a/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginAmplifyVersionableTests.swift b/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginAmplifyVersionableTests.swift index c2716d0968..67ced0b842 100644 --- a/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginAmplifyVersionableTests.swift +++ b/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginAmplifyVersionableTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest // swiftlint:disable:next type_name class DefaultLoggingPluginAmplifyVersionableTests: XCTestCase { diff --git a/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginTests.swift b/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginTests.swift index 91b9ecf586..17e857fef6 100644 --- a/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginTests.swift +++ b/AmplifyTests/CategoryTests/Logging/DefaultLoggingPluginTests.swift @@ -68,12 +68,16 @@ class DefaultLoggingPluginTests: XCTestCase { verboseMessageIncorrectlyEvaluated.isInverted = true Amplify.Logging.verbose("verbose \(verboseMessageIncorrectlyEvaluated.fulfill())") - await fulfillment(of: [errorMessageCorrectlyEvaluated, - warnMessageIncorrectlyEvaluated, - infoMessageIncorrectlyEvaluated, - debugMessageIncorrectlyEvaluated, - verboseMessageIncorrectlyEvaluated], - timeout: 0.1) + await fulfillment( + of: [ + errorMessageCorrectlyEvaluated, + warnMessageIncorrectlyEvaluated, + infoMessageIncorrectlyEvaluated, + debugMessageIncorrectlyEvaluated, + verboseMessageIncorrectlyEvaluated + ], + timeout: 0.1 + ) } /// - Given: default configuration @@ -102,11 +106,15 @@ class DefaultLoggingPluginTests: XCTestCase { infoMessageIncorrectlyEvaluatedAgain.isInverted = true Amplify.Logging.info("info \(infoMessageIncorrectlyEvaluatedAgain.fulfill())") - await fulfillment(of: [warnMessageCorrectlyEvaluated, - infoMessageIncorrectlyEvaluated, - warnMessageIncorrectlyEvaluated, - infoMessageIncorrectlyEvaluatedAgain], - timeout: 0.1) + await fulfillment( + of: [ + warnMessageCorrectlyEvaluated, + infoMessageIncorrectlyEvaluated, + warnMessageIncorrectlyEvaluated, + infoMessageIncorrectlyEvaluatedAgain + ], + timeout: 0.1 + ) } /// Although we can't assert it, the messages in the console log are expected to have different "category" tags @@ -150,10 +158,14 @@ class DefaultLoggingPluginTests: XCTestCase { logger1.info("logger1 \(logger1MessageCorrectlyEvaluated.fulfill())") logger2.info("logger2 \(logger2MessageIncorrectlyEvaluated.fulfill())") - await fulfillment(of: [logger1MessageCorrectlyEvaluated, - logger2MessageIncorrectlyEvaluated, - globalMessageCorrectlyEvaluated], - timeout: 0.1) + await fulfillment( + of: [ + logger1MessageCorrectlyEvaluated, + logger2MessageIncorrectlyEvaluated, + globalMessageCorrectlyEvaluated + ], + timeout: 0.1 + ) } /// - Given: default configuration diff --git a/AmplifyTests/CategoryTests/Logging/LoggingCategoryClientAPITests.swift b/AmplifyTests/CategoryTests/Logging/LoggingCategoryClientAPITests.swift index b155cf8a2f..5a774fd686 100644 --- a/AmplifyTests/CategoryTests/Logging/LoggingCategoryClientAPITests.swift +++ b/AmplifyTests/CategoryTests/Logging/LoggingCategoryClientAPITests.swift @@ -164,19 +164,19 @@ class NonEvaluatingLoggingPlugin: LoggingCategoryPlugin, Logger { var `default`: Logger { self } - + func enable() { - + } - + func disable() { - + } - + func logger(forNamespace namespace: String) -> Logger { self } - + func logger(forCategory category: String, forNamespace namespace: String) -> Logger { self } diff --git a/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift index 15432c3aab..5e90929a34 100644 --- a/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Logging/LoggingCategoryConfigurationTests.swift @@ -82,8 +82,10 @@ class LoggingCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Logging.getPlugin(for: "MockLoggingCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Logging.getPlugin(for: "MockLoggingCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case LoggingError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -249,8 +251,10 @@ class LoggingCategoryConfigurationTests: XCTestCase { ) try Amplify.Logging.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Logging.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Logging.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/Notifications/NotificationsCategoryTests.swift b/AmplifyTests/CategoryTests/Notifications/NotificationsCategoryTests.swift index 0393afb838..de6c940c21 100644 --- a/AmplifyTests/CategoryTests/Notifications/NotificationsCategoryTests.swift +++ b/AmplifyTests/CategoryTests/Notifications/NotificationsCategoryTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // +import XCTest @testable import Amplify @testable import AmplifyTestCommon -import XCTest final class NotificationsCategoryTests: XCTestCase { private var category: NotificationsCategory! @@ -32,7 +32,7 @@ final class NotificationsCategoryTests: XCTestCase { plugins: [notificationsPlugin.key: true] ) try Amplify.add(plugin: notificationsPlugin) - try Amplify.configure(AmplifyConfiguration(notifications:notificationsConfig)) + try Amplify.configure(AmplifyConfiguration(notifications: notificationsConfig)) let configuredCategories = category.subcategories XCTAssertEqual(configuredCategories.count, 1) diff --git a/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryClientAPITests.swift b/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryClientAPITests.swift index 6f18b35b6a..4417722a1f 100644 --- a/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryClientAPITests.swift +++ b/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryClientAPITests.swift @@ -5,10 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 // -@testable import Amplify -@testable import AmplifyTestCommon import UserNotifications import XCTest +@testable import Amplify +@testable import AmplifyTestCommon class PushNotificationsCategoryClientAPITests: XCTestCase { private var category: PushNotificationsCategory! @@ -18,11 +18,11 @@ class PushNotificationsCategoryClientAPITests: XCTestCase { await Amplify.reset() category = Amplify.Notifications.Push plugin = MockPushNotificationsCategoryPlugin() - + let categoryConfiguration = NotificationsCategoryConfiguration( plugins: ["MockPushNotificationsCategoryPlugin": true] ) - + let amplifyConfiguration = AmplifyConfiguration(notifications: categoryConfiguration) try Amplify.add(plugin: plugin) try Amplify.configure(amplifyConfiguration) diff --git a/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryConfigurationTests.swift index 5e0214ec44..7f9277b4dc 100644 --- a/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Notifications/Push/PushNotificationsCategoryConfigurationTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // +import XCTest @_spi(InternalAmplifyConfiguration) @testable import Amplify @testable import AmplifyTestCommon -import XCTest class PushNotificationsCategoryConfigurationTests: XCTestCase { // MARK: - Setup methods @@ -35,7 +35,7 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { private func createAmplifyConfig(hasSecondPlugin: Bool = false) -> AmplifyConfiguration { let categoryConfiguration = createCategoryConfig(hasSecondPlugin: hasSecondPlugin) - + return AmplifyConfiguration(notifications: categoryConfiguration) } @@ -51,8 +51,10 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { try Amplify.add(plugin: plugin) try Amplify.configure(createAmplifyConfig()) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -66,8 +68,10 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { let categoryConfig = createCategoryConfig() try Amplify.Notifications.Push.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Notifications.Push.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Notifications.Push.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -204,8 +208,10 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { try Amplify.configure(createAmplifyConfig()) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Notifications.Push.getPlugin(for: "MockPushNotificationsCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Notifications.Push.getPlugin(for: "MockPushNotificationsCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case PushNotificationsError.configuration = error else { XCTFail("Expected PushNotificationsError.configuration error") return @@ -224,7 +230,7 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { XCTAssertNotNil(try Amplify.Notifications.Push.getPlugin(for: "MockPushNotificationsCategoryPlugin")) XCTAssertNotNil(try Amplify.Notifications.Push.getPlugin(for: "MockPushNotificationsCategoryPlugin")) } - + func testUsingPlugin_withMultiplePlugins_shouldSucceed() async throws { let plugin1 = MockPushNotificationsCategoryPlugin() let methodShouldNotBeInvokedOnDefaultPlugin = @@ -236,7 +242,7 @@ class PushNotificationsCategoryConfigurationTests: XCTestCase { } } try Amplify.add(plugin: plugin1) - + let plugin2 = MockSecondPushNotificationsCategoryPlugin() let methodShouldBeInvokedOnSecondPlugin = expectation(description: "test method should be invoked on second plugin") diff --git a/AmplifyTests/CategoryTests/Predictions/ModelsTest/LanguageTypeTest.swift b/AmplifyTests/CategoryTests/Predictions/ModelsTest/LanguageTypeTest.swift index 9c2d8c7aba..935af8d7b2 100644 --- a/AmplifyTests/CategoryTests/Predictions/ModelsTest/LanguageTypeTest.swift +++ b/AmplifyTests/CategoryTests/Predictions/ModelsTest/LanguageTypeTest.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest class LanguageTypeTest: XCTestCase { diff --git a/AmplifyTests/CategoryTests/Predictions/PredictionsCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Predictions/PredictionsCategoryConfigurationTests.swift index 8aca2e84ea..f4c41a1c8d 100644 --- a/AmplifyTests/CategoryTests/Predictions/PredictionsCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Predictions/PredictionsCategoryConfigurationTests.swift @@ -220,8 +220,10 @@ class PredictionsCategoryConfigurationTests: XCTestCase { ) try Amplify.Predictions.configure(using: config) - XCTAssertThrowsError(try Amplify.Predictions.configure(using: config), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Predictions.configure(using: config), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CategoryTests/Storage/StorageCategoryConfigurationTests.swift b/AmplifyTests/CategoryTests/Storage/StorageCategoryConfigurationTests.swift index 49d2a3cc47..50ed508a32 100644 --- a/AmplifyTests/CategoryTests/Storage/StorageCategoryConfigurationTests.swift +++ b/AmplifyTests/CategoryTests/Storage/StorageCategoryConfigurationTests.swift @@ -81,8 +81,10 @@ class StorageCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) await Amplify.reset() - XCTAssertThrowsError(try Amplify.Storage.getPlugin(for: "MockStorageCategoryPlugin"), - "Getting a plugin after reset() should throw") { error in + XCTAssertThrowsError( + try Amplify.Storage.getPlugin(for: "MockStorageCategoryPlugin"), + "Getting a plugin after reset() should throw" + ) { error in guard case StorageError.configuration = error else { XCTFail("Expected PluginError.noSuchPlugin") return @@ -256,8 +258,10 @@ class StorageCategoryConfigurationTests: XCTestCase { ) try Amplify.Storage.configure(using: categoryConfig) - XCTAssertThrowsError(try Amplify.Storage.configure(using: categoryConfig), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.Storage.configure(using: categoryConfig), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return @@ -333,8 +337,10 @@ class StorageCategoryConfigurationTests: XCTestCase { try Amplify.configure(amplifyConfig) - XCTAssertThrowsError(try Amplify.add(plugin: plugin), - "configure() an already configured plugin should throw") { error in + XCTAssertThrowsError( + try Amplify.add(plugin: plugin), + "configure() an already configured plugin should throw" + ) { error in guard case ConfigurationError.amplifyAlreadyConfigured = error else { XCTFail("Expected ConfigurationError.amplifyAlreadyConfigured") return diff --git a/AmplifyTests/CoreTests/AmplifyAsyncSequenceTests.swift b/AmplifyTests/CoreTests/AmplifyAsyncSequenceTests.swift index 044282d285..cb4645a11d 100644 --- a/AmplifyTests/CoreTests/AmplifyAsyncSequenceTests.swift +++ b/AmplifyTests/CoreTests/AmplifyAsyncSequenceTests.swift @@ -114,14 +114,14 @@ final class AmplifyAsyncSequenceTests: XCTestCase { } XCTAssertNotNil(thrown) - let expected = Array(input[0..<2]) + let expected = Array(input[0 ..< 2]) XCTAssertEqual(expected, output) } func testChannelCancelled() async throws { // parent task is canceled while reducing values from sequence // before a value is sent which should result in a sum of zero - let input = 2006 + let input = 2_006 let reduced = expectation(description: "reduced") let done = expectation(description: "done") let channel = AmplifyAsyncSequence() @@ -151,7 +151,7 @@ final class AmplifyAsyncSequenceTests: XCTestCase { func testThrowingChannelCancelled() async throws { // parent task is canceled while reducing values from sequence // before a value is sent which should result in a sum of zero - let input = 2006 + let input = 2_006 let reduced = expectation(description: "reduced") let done = expectation(description: "done") let channel = AmplifyAsyncThrowingSequence() @@ -225,7 +225,7 @@ final class AmplifyAsyncSequenceTests: XCTestCase { let token = operation.subscribe { (value: LongOperation.InProcess) in count += 1 channel.send(value) - if value.completedUnitCount >= steps/2 { + if value.completedUnitCount >= steps / 2 { channel.cancel() sent.fulfill() } @@ -297,7 +297,7 @@ final class AmplifyAsyncSequenceTests: XCTestCase { let token = operation.subscribe { (value: LongOperation.InProcess) in count += 1 channel.send(value) - if value.completedUnitCount >= steps/2 { + if value.completedUnitCount >= steps / 2 { channel.cancel() sent.fulfill() } @@ -338,7 +338,7 @@ final class AmplifyAsyncSequenceTests: XCTestCase { while index < elements.count { try await Task.sleep(seconds: sleepSeconds) let element = elements[index] - if let processor = processor { + if let processor { do { let processed = try processor(element) channel.send(processed) diff --git a/AmplifyTests/CoreTests/AmplifyConfigurationInitializationTests.swift b/AmplifyTests/CoreTests/AmplifyConfigurationInitializationTests.swift index af9794abb8..bfdcc790e5 100644 --- a/AmplifyTests/CoreTests/AmplifyConfigurationInitializationTests.swift +++ b/AmplifyTests/CoreTests/AmplifyConfigurationInitializationTests.swift @@ -174,16 +174,20 @@ class AmplifyConfigurationInitializationTests: XCTestCase { /// Creates the directory used as the container for the test bundle; each test will need this. static func makeTempDir() throws { - try FileManager.default.createDirectory(at: tempDir, - withIntermediateDirectories: true) + try FileManager.default.createDirectory( + at: tempDir, + withIntermediateDirectories: true + ) } /// Creates a Bundle object from the container directory static func makeTestBundle(withConfigFileName: Data? = nil) throws -> Bundle { let customBundleDir = tempDir.appendingPathComponent("TestBundle.bundle") - try FileManager.default.createDirectory(at: customBundleDir, - withIntermediateDirectories: true) + try FileManager.default.createDirectory( + at: customBundleDir, + withIntermediateDirectories: true + ) guard let testBundle = Bundle(path: customBundleDir.path) else { throw "Could not create test bundle at \(customBundleDir.path)" diff --git a/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationChainedTests.swift b/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationChainedTests.swift index 30ea3d6b7c..d3ece1e6a6 100644 --- a/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationChainedTests.swift +++ b/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationChainedTests.swift @@ -6,8 +6,8 @@ // #if canImport(Combine) -import XCTest import Combine +import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -57,10 +57,14 @@ class AmplifyInProcessReportingOperationChainedTests: XCTestCase { mockOp1.main() mockOp2.main() - await fulfillment(of: [receivedValue, - receivedFailure, - receivedFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedValue, + receivedFailure, + receivedFinished + ], + timeout: 0.05 + ) sink.cancel() } @@ -90,7 +94,7 @@ class AmplifyInProcessReportingOperationChainedTests: XCTestCase { let sink = Publishers.Zip( mockOp1.internalResultPublisher, mockOp2.internalResultPublisher - ).flatMap { (_, _) -> AnyPublisher in + ).flatMap { _, _ -> AnyPublisher in let mockOp = MockPublisherInProcessOperation(responder: failureResponder) mockOp.main() return mockOp.internalResultPublisher @@ -112,10 +116,14 @@ class AmplifyInProcessReportingOperationChainedTests: XCTestCase { mockOp1.main() mockOp2.main() - await fulfillment(of: [receivedValue, - receivedFailure, - receivedFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedValue, + receivedFailure, + receivedFinished + ], + timeout: 0.05 + ) sink.cancel() } @@ -162,10 +170,14 @@ class AmplifyInProcessReportingOperationChainedTests: XCTestCase { mockOp1.main() mockOp2.main() - await fulfillment(of: [receivedValue, - receivedFailure, - receivedFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedValue, + receivedFailure, + receivedFinished + ], + timeout: 0.05 + ) sink.cancel() } diff --git a/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationCombineTests.swift b/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationCombineTests.swift index 6452d90e08..33f10051f6 100644 --- a/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationCombineTests.swift +++ b/AmplifyTests/CoreTests/AmplifyInProcessReportingOperationCombineTests.swift @@ -6,8 +6,8 @@ // #if canImport(Combine) -import XCTest import Combine +import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -53,13 +53,17 @@ class AmplifyInProcessReportingOperationCombineTests: XCTestCase { let operation = makeOperation(using: responder) operation.main() - await fulfillment(of: [receivedResultValue, - receivedResultFailure, - receivedResultFinished, - receivedInProcessValue, - receivedInProcessFailure, - receivedInProcessFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedResultValue, + receivedResultFailure, + receivedResultFinished, + receivedInProcessValue, + receivedInProcessFailure, + receivedInProcessFinished + ], + timeout: 0.05 + ) } func testResultPublisherFails() async { @@ -75,13 +79,17 @@ class AmplifyInProcessReportingOperationCombineTests: XCTestCase { let operation = makeOperation(using: responder) operation.main() - await fulfillment(of: [receivedResultValue, - receivedResultFailure, - receivedResultFinished, - receivedInProcessValue, - receivedInProcessFailure, - receivedInProcessFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedResultValue, + receivedResultFailure, + receivedResultFinished, + receivedInProcessValue, + receivedInProcessFailure, + receivedInProcessFinished + ], + timeout: 0.05 + ) } func testResultPublisherCancels() async { @@ -99,13 +107,17 @@ class AmplifyInProcessReportingOperationCombineTests: XCTestCase { let operation = makeOperation(using: responder) operation.cancel() - await fulfillment(of: [receivedResultValue, - receivedResultFailure, - receivedResultFinished, - receivedInProcessValue, - receivedInProcessFailure, - receivedInProcessFinished], - timeout: 0.05) + await fulfillment( + of: [ + receivedResultValue, + receivedResultFailure, + receivedResultFinished, + receivedInProcessValue, + receivedInProcessFailure, + receivedInProcessFinished + ], + timeout: 0.05 + ) } func makeOperation( diff --git a/AmplifyTests/CoreTests/AmplifyOperationCombineTests.swift b/AmplifyTests/CoreTests/AmplifyOperationCombineTests.swift index ec85f46e58..5ca4f421d8 100644 --- a/AmplifyTests/CoreTests/AmplifyOperationCombineTests.swift +++ b/AmplifyTests/CoreTests/AmplifyOperationCombineTests.swift @@ -6,8 +6,8 @@ // #if canImport(Combine) -import XCTest import Combine +import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -181,7 +181,7 @@ class AmplifyOperationCombineTests: XCTestCase { let sink = Publishers.Zip( mockOp1.internalResultPublisher, mockOp2.internalResultPublisher - ).flatMap { (_, _) -> AnyPublisher in + ).flatMap { _, _ -> AnyPublisher in let mockOp = MockPublisherOperation(responder: failureResponder) mockOp.main() return mockOp.internalResultPublisher @@ -280,7 +280,7 @@ class MockPublisherOperation: AmplifyOperation Bundle { let customBundleDir = tempDir.appendingPathComponent("TestBundle.bundle") - try FileManager.default.createDirectory(at: customBundleDir, - withIntermediateDirectories: true) + try FileManager.default.createDirectory( + at: customBundleDir, + withIntermediateDirectories: true + ) guard let testBundle = Bundle(path: customBundleDir.path) else { throw "Could not create test bundle at \(customBundleDir.path)" diff --git a/AmplifyTests/CoreTests/AmplifyPublisherTests.swift b/AmplifyTests/CoreTests/AmplifyPublisherTests.swift index 013cea0015..aa040fabce 100644 --- a/AmplifyTests/CoreTests/AmplifyPublisherTests.swift +++ b/AmplifyTests/CoreTests/AmplifyPublisherTests.swift @@ -6,8 +6,8 @@ // #if canImport(Combine) -import XCTest import Combine +import XCTest @testable import Amplify @testable import AmplifyTestCommon @@ -22,10 +22,10 @@ class AmplifyPublisherTests: XCTestCase { notDone.isInverted = true let done = expectation(description: "done") let input = 7 - var output: Int = 0 + var output = 0 var success = false var thrown: Error? = nil - + let sink = Amplify.Publisher.create { try await self.getOutput(input: input) } @@ -41,14 +41,14 @@ class AmplifyPublisherTests: XCTestCase { } receiveValue: { value in output = value } - + await fulfillment(of: [notDone], timeout: 0.01) await fulfillment(of: [done]) - + XCTAssertEqual(input, output) XCTAssertTrue(success) XCTAssertNil(thrown) - + sink.cancel() } @@ -56,10 +56,10 @@ class AmplifyPublisherTests: XCTestCase { let failed = expectation(description: "failed") let done = expectation(description: "done") let input = 13 - var output: Int = 0 + var output = 0 var success = false var thrown: Error? = nil - + let sink = Amplify.Publisher.create { try await self.getOutput(input: input) } @@ -75,7 +75,7 @@ class AmplifyPublisherTests: XCTestCase { } receiveValue: { value in output = value } - + await fulfillment(of: [failed]) await fulfillment(of: [done]) @@ -92,10 +92,10 @@ class AmplifyPublisherTests: XCTestCase { let noValueReceived = expectation(description: "noValueReceived") noValueReceived.isInverted = true let input = 7 - var output: Int = 0 + var output = 0 var success = false var thrown: Error? = nil - + let sink = Amplify.Publisher.create { try await self.getOutput(input: input, seconds: 0.25) } @@ -124,12 +124,12 @@ class AmplifyPublisherTests: XCTestCase { } func testCreateFromAmplifyAsyncSequenceSuccess() async throws { - let input = Array(1...100) + let input = Array(1 ... 100) let sequence = AmplifyAsyncSequence() var output = [Int]() let finished = expectation(description: "completion finished") let received = expectation(description: "values received") - + let sink = Amplify.Publisher.create(sequence) .sink { completion in switch completion { @@ -152,11 +152,11 @@ class AmplifyPublisherTests: XCTestCase { } func testCreateFromAmplifyAsyncThrowingSequenceSuccess() async throws { - let input = Array(1...100) + let input = Array(1 ... 100) let sequence = AmplifyAsyncThrowingSequence() var output = [Int]() let finished = expectation(description: "completion finished") - + let sink = Amplify.Publisher.create(sequence) .sink { completion in switch completion { @@ -181,7 +181,7 @@ class AmplifyPublisherTests: XCTestCase { let sequence = Doubles() var output = [Int]() let finished = expectation(description: "completion finished") - + let sink = Amplify.Publisher.create(sequence) .sink { completion in switch completion { @@ -200,13 +200,13 @@ class AmplifyPublisherTests: XCTestCase { } sink.cancel() } - + func testCreateFromBasicAsyncSequenceFail() async throws { let expected = [1, 2, 4] let sequence = Doubles(fails: true) var output = [Int]() let failed = expectation(description: "completion failed") - + let sink = Amplify.Publisher.create(sequence) .sink { completion in switch completion { @@ -228,20 +228,20 @@ class AmplifyPublisherTests: XCTestCase { } func testCreateFromAmplifyAsyncSequenceCancelSink() async throws { - let input = Array(1...100) + let input = Array(1 ... 100) let expected = [Int]() let sequence = AmplifyAsyncSequence() var output = [Int]() let completed = expectation(description: "should not have completed") completed.isInverted = true - + let sink = Amplify.Publisher.create(sequence) .sink { completion in completed.fulfill() } receiveValue: { value in output.append(value) } - + sink.cancel() send(input: input, sequence: sequence) @@ -249,7 +249,7 @@ class AmplifyPublisherTests: XCTestCase { await fulfillment(of: [completed], timeout: 0.1) XCTAssertEqual(expected, output) } - + func testCreateFromAmplifyAsyncSequenceCancelSequence() async throws { let expected = [Int]() let sequence = AmplifyAsyncSequence() @@ -274,9 +274,11 @@ class AmplifyPublisherTests: XCTestCase { sink.cancel() } - private func send(input: [Element], - sequence: AmplifyAsyncSequence, - finish: Bool = true) { + private func send( + input: [Element], + sequence: AmplifyAsyncSequence, + finish: Bool = true + ) { for value in input { sequence.send(value) } @@ -285,9 +287,11 @@ class AmplifyPublisherTests: XCTestCase { } } - private func send(input: [Element], - throwingSequence: AmplifyAsyncThrowingSequence, - finish: Bool = true) { + private func send( + input: [Element], + throwingSequence: AmplifyAsyncThrowingSequence, + finish: Bool = true + ) { for value in input { throwingSequence.send(value) } @@ -298,24 +302,24 @@ class AmplifyPublisherTests: XCTestCase { private struct Doubles: AsyncSequence { let fails: Bool - + init(fails: Bool = false) { self.fails = fails } typealias Element = Int - + func makeAsyncIterator() -> AsyncIterator { AsyncIterator(fails: fails) } - + struct AsyncIterator: AsyncIteratorProtocol { let fails: Bool - + init(fails: Bool = false) { self.fails = fails } - + var current = 1 mutating func next() async throws -> Element? { diff --git a/AmplifyTests/CoreTests/AmplifyTaskQueueTests.swift b/AmplifyTests/CoreTests/AmplifyTaskQueueTests.swift index 48c19c9182..5d9a74d94b 100644 --- a/AmplifyTests/CoreTests/AmplifyTaskQueueTests.swift +++ b/AmplifyTests/CoreTests/AmplifyTaskQueueTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest // As expected, running this work as straight up Task invocations: @@ -68,18 +68,18 @@ final class AmplifyTaskQueueTests: XCTestCase { func testAsync() async throws { let taskCount = 1_000 - let expectations: [XCTestExpectation] = (0..() - - for i in 0.. String { - let range = [UInt32](0x1F601...0x1F64F) - let ascii = range[Int(drand48() * (Double(range.count)))] + let range = [UInt32](0x1f601 ... 0x1f64f) + let ascii = range[Int(drand48() * Double(range.count))] let emoji = UnicodeScalar(ascii)?.description return emoji! } diff --git a/AmplifyTests/CoreTests/TreeTests.swift b/AmplifyTests/CoreTests/TreeTests.swift index c5f14142dc..506f4c2220 100644 --- a/AmplifyTests/CoreTests/TreeTests.swift +++ b/AmplifyTests/CoreTests/TreeTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import Amplify +import XCTest class TreeTests: XCTestCase { diff --git a/AmplifyTools/AmplifyXcode/Package.swift b/AmplifyTools/AmplifyXcode/Package.swift index 6f79f34bf4..c2564c3ff7 100644 --- a/AmplifyTools/AmplifyXcode/Package.swift +++ b/AmplifyTools/AmplifyXcode/Package.swift @@ -26,19 +26,23 @@ let package = Package( .product(name: "XcodeGenKit", package: "XcodeGen"), .product(name: "ProjectSpec", package: "XcodeGen"), "PathKit" - ]), + ] + ), .testTarget( name: "AmplifyXcodeCoreTests", - dependencies: ["AmplifyXcodeCore"]), + dependencies: ["AmplifyXcodeCore"] + ), .target( name: "AmplifyXcode", dependencies: [ "AmplifyXcodeCore", .product(name: "ArgumentParser", package: "swift-argument-parser") - ]), + ] + ), .testTarget( name: "AmplifyXcodeTests", - dependencies: ["AmplifyXcode"]) + dependencies: ["AmplifyXcode"] + ) ] ) diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLI.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLI.swift index 58c7bdc4ce..c5a69c4e34 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLI.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLI.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import ArgumentParser import AmplifyXcodeCore +import ArgumentParser +import Foundation /// This module defines a CLI (Command Line Interface) to commands defined in `Core/Commands`. /// Each "CLI command" is the actual executor of an `AmplifyCommand`, thus it's responsible @@ -22,5 +22,6 @@ struct AmplifyXcode: ParsableCommand { CLICommandImportConfig.self, CLICommandImportModels.self, CLICommandGenerateJSONSchema.self - ]) + ] + ) } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommand.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommand.swift index 37dbc6e2f1..055110217d 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommand.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommand.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import ArgumentParser +import Foundation protocol CLICommandInitializable { init() @@ -36,6 +36,6 @@ extension CLICommand { // MARK: - ParsableCommand + CLICommandEncodable extension CLICommand where Self: ParsableCommand { - static var commandName: String { Self.configuration.commandName! } - static var abstract: String { Self.configuration.abstract } + static var commandName: String { configuration.commandName! } + static var abstract: String { configuration.abstract } } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandGenerateJSONSchema.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandGenerateJSONSchema.swift index 461bc5a978..fc6e35c252 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandGenerateJSONSchema.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandGenerateJSONSchema.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import AmplifyXcodeCore import ArgumentParser +import Foundation /// Encodable representation of the `amplify-xcode` CLI. /// In order to get the necessary information to produce a representation of each commands, @@ -23,9 +23,11 @@ private struct CLISchema: Encodable { continue } _ = command.init() - commands.append(AnyCLICommandEncodable(name: command.commandName, - abstract: command.abstract, - parameters: command.parameters)) + commands.append(AnyCLICommandEncodable( + name: command.commandName, + abstract: command.abstract, + parameters: command.parameters + )) } } } @@ -47,8 +49,10 @@ struct CLICommandGenerateJSONSchema: ParsableCommand, CommandExecutable, CLIComm func run() throws { let schema = try JSONEncoder().encode(CLISchema()) let schemaFileName = "amplify-xcode.json" - let fullPath = try environment.createFile(atPath: schemaFileName, - content: String(data: schema, encoding: .utf8)!) + let fullPath = try environment.createFile( + atPath: schemaFileName, + content: String(data: schema, encoding: .utf8)! + ) print("Schema generated at: \(fullPath)") } } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportConfig.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportConfig.swift index 9b6f821c89..3e03c2f21d 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportConfig.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportConfig.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import ArgumentParser import AmplifyXcodeCore +import ArgumentParser +import Foundation /// CLI command invoking `CommandImportConfig`. struct CLICommandImportConfig: ParsableCommand, CommandExecutable, CLICommandReportable, CLICommand { diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportModels.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportModels.swift index 86761b06a0..9bea0572e9 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportModels.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandImportModels.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation -import ArgumentParser import AmplifyXcodeCore +import ArgumentParser +import Foundation /// CLI command invoking `CommandImportModels`. struct CLICommandImportModels: ParsableCommand, CommandExecutable, CLICommandReportable, CLICommand { diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandReportable.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandReportable.swift index 2387723d43..46577a089a 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandReportable.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/CLICommandReportable.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import AmplifyXcodeCore +import Foundation protocol CLICommandReportable { func report(result: AmplifyCommandResult) diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/Support/ArgumentParser+CLICommand.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/Support/ArgumentParser+CLICommand.swift index 073e47ea81..91e8922178 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/Support/ArgumentParser+CLICommand.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcode/Support/ArgumentParser+CLICommand.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import ArgumentParser +import Foundation /// The following extensions on ArgumentParser commands parameters property wrappers /// help us providing a hook to generate a JSON representation of a CLI command. @@ -22,7 +22,7 @@ extension Option where Value: ExpressibleByArgument { parsing: .next, completion: nil, help: ArgumentHelp(help) - ) + ) let type = String(describing: Value.self) parameters.insert(.option(name: name, type: type, help: help)) } @@ -33,7 +33,7 @@ extension Option where Value: ExpressibleByArgument { parsing: .next, help: ArgumentHelp(help), completion: nil - ) + ) let type = String(describing: Value.self) parameters.insert(.option(name: name, type: type, help: help)) } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/AmplifyCommandError.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/AmplifyCommandError.swift index 498dc4543e..be6f049e62 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/AmplifyCommandError.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/AmplifyCommandError.swift @@ -26,7 +26,7 @@ public struct AmplifyCommandError: Error { self.errorDescription = errorDescription self.recoverySuggestion = recoverySuggestion - if let error = error { + if let error { self.underlyingErrors = [error] } } @@ -61,7 +61,7 @@ public extension AmplifyCommandError { components.append("-- Recovery suggestion: \(recoveryMsg)") } - guard let underlyingErrors = self.underlyingErrors else { + guard let underlyingErrors else { return components.joined(separator: "\n") } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandExecutable.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandExecutable.swift index 77b4821eb1..b333f0b6cf 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandExecutable.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandExecutable.swift @@ -16,9 +16,11 @@ public protocol CommandExecutable where Self: CommandEnvironmentProvider { /// Provides a default implementation for an executable command public extension CommandExecutable { - private func exec(_ task: AmplifyCommandTaskExecutor, - args: TaskArgs, - prevResults: inout [AmplifyCommandTaskResult]) -> Bool { + private func exec( + _ task: AmplifyCommandTaskExecutor, + args: TaskArgs, + prevResults: inout [AmplifyCommandTaskResult] + ) -> Bool { let output = task(environment, args) switch output { case .failure: @@ -31,7 +33,7 @@ public extension CommandExecutable { } /// Given a command, executes its underlying tasks and aggregates the final result - func exec(command: Command) -> AmplifyCommandResult { + func exec(command: some AmplifyCommand) -> AmplifyCommandResult { var results: [AmplifyCommandTaskResult] = [] for task in command.tasks { diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportConfig.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportConfig.swift index 48b9e5d98f..4b79f8ca96 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportConfig.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportConfig.swift @@ -10,25 +10,29 @@ import Foundation enum ImportConfigTasks { static func amplifyFolderExist( environment: AmplifyCommandEnvironment, - args: CommandImportConfig.TaskArgs) -> AmplifyCommandTaskResult { + args: CommandImportConfig.TaskArgs + ) -> AmplifyCommandTaskResult { guard environment.directoryExists(atPath: "amplify") else { return .failure(AmplifyCommandError( - .folderNotFound, - errorDescription: "Amplify project not found at \(environment.basePath).", - recoverySuggestion: "Run `amplify init` to initialize an Amplify project.")) + .folderNotFound, + errorDescription: "Amplify project not found at \(environment.basePath).", + recoverySuggestion: "Run `amplify init` to initialize an Amplify project." + )) } return .success("Amplify project found.") } static func configFilesExist( environment: AmplifyCommandEnvironment, - args: CommandImportConfig.TaskArgs) -> AmplifyCommandTaskResult { + args: CommandImportConfig.TaskArgs + ) -> AmplifyCommandTaskResult { for file in args.configFiles { if !environment.fileExists(atPath: file) { return .failure(AmplifyCommandError( .fileNotFound, errorDescription: "\(file) not found.", - recoverySuggestion: "Verify the current Amplify project has been initialized successfully.")) + recoverySuggestion: "Verify the current Amplify project has been initialized successfully." + )) } } return .success("Amplify config files found.") @@ -36,16 +40,19 @@ enum ImportConfigTasks { static func addConfigFilesToXcodeProject( environment: AmplifyCommandEnvironment, - args: CommandImportConfig.TaskArgs) -> AmplifyCommandTaskResult { + args: CommandImportConfig.TaskArgs + ) -> AmplifyCommandTaskResult { let configFiles = args.configFiles.map { environment.createXcodeFile(withPath: environment.path(for: $0), ofType: .resource) } let projectPath = environment.basePath do { - try environment.addFilesToXcodeProject(projectPath: projectPath, - files: configFiles, - toGroup: args.configGroup, - inTarget: .primary) + try environment.addFilesToXcodeProject( + projectPath: projectPath, + files: configFiles, + toGroup: args.configGroup, + inTarget: .primary + ) return .success("Successfully updated project \(projectPath).") } catch { if let underlyingError = error as? AmplifyCommandError { diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportModels.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportModels.swift index f1a15061ee..f54af3b661 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportModels.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Commands/CommandImportModels.swift @@ -9,19 +9,21 @@ import Foundation import PathKit enum CommandImportModelsTasks { - static func projectHasGeneratedModels(environment: AmplifyCommandEnvironment, - args: CommandImportModels.TaskArgs) -> AmplifyCommandTaskResult { + static func projectHasGeneratedModels( + environment: AmplifyCommandEnvironment, + args: CommandImportModels.TaskArgs + ) -> AmplifyCommandTaskResult { let modelsPath = environment.path(for: args.generatedModelsPath) guard environment.directoryExists(atPath: modelsPath) else { do { _ = try environment.createDirectory(atPath: args.generatedModelsPath) - } - catch { + } catch { return .failure( AmplifyCommandError( .folderNotFound, errorDescription: "Unable to create a new folder for models at path: \(modelsPath)", - recoverySuggestion: "Run amplify codegen models.")) + recoverySuggestion: "Run amplify codegen models." + )) } return .success("Amplify models folder created at \(modelsPath)") @@ -30,8 +32,10 @@ enum CommandImportModelsTasks { return .success("Amplify models folder found at \(modelsPath)") } - static func addGeneratedModelsToProject(environment: AmplifyCommandEnvironment, - args: CommandImportModels.TaskArgs) -> AmplifyCommandTaskResult { + static func addGeneratedModelsToProject( + environment: AmplifyCommandEnvironment, + args: CommandImportModels.TaskArgs + ) -> AmplifyCommandTaskResult { let models = environment.glob(pattern: "\(args.generatedModelsPath)/*.swift").map { environment.createXcodeFile(withPath: $0, ofType: .source) } @@ -41,7 +45,8 @@ enum CommandImportModelsTasks { projectPath: environment.basePath, files: models, toGroup: args.modelsGroup, - inTarget: .primary) + inTarget: .primary + ) let addedModels = models.map { Path($0.path).lastComponent } return .success("Successfully added models \(addedModels) to '\(args.modelsGroup)' group.") diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/AmplifyCommandEnvironment.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/AmplifyCommandEnvironment.swift index 38fd26a9d9..f7c189d5c0 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/AmplifyCommandEnvironment.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/AmplifyCommandEnvironment.swift @@ -47,10 +47,12 @@ public protocol AmplifyCommandEnvironmentXcode { /// Reads an Xcode project file at `projectPath`, retrieves or creates a group `group` if it doesn't exist /// and adds `files` to it - func addFilesToXcodeProject(projectPath: String, - files: [XcodeProjectFile], - toGroup group: String, - inTarget target: XcodeProjectTarget) throws + func addFilesToXcodeProject( + projectPath: String, + files: [XcodeProjectFile], + toGroup group: String, + inTarget target: XcodeProjectTarget + ) throws } public typealias AmplifyCommandEnvironment = AmplifyCommandEnvironmentFileManager & AmplifyCommandEnvironmentXcode diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/CommandEnvironment.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/CommandEnvironment.swift index f27ef1c488..67c0b853ff 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/CommandEnvironment.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Environment/CommandEnvironment.swift @@ -21,21 +21,21 @@ public struct CommandEnvironment: AmplifyCommandEnvironment { } // MARK: - AmplifyCommandEnvironmentFileManager -extension CommandEnvironment { - public func path(for subpath: String) -> String { +public extension CommandEnvironment { + func path(for subpath: String) -> String { return URL(fileURLWithPath: subpath, relativeTo: basePathURL).path } - public func path(for components: [String]) -> String { + func path(for components: [String]) -> String { return path(for: components.joined(separator: "/")) } - public func glob(pattern: String) -> [String] { + func glob(pattern: String) -> [String] { let fullPath = path(for: pattern) return fileManager.glob(pattern: fullPath).map { $0 } } - @discardableResult public func createDirectory(atPath path: String) throws -> String { + @discardableResult func createDirectory(atPath path: String) throws -> String { let url = URL(fileURLWithPath: path, relativeTo: basePathURL) do { try fileManager.createDirectory(at: url, withIntermediateDirectories: true) @@ -45,7 +45,7 @@ extension CommandEnvironment { } } - @discardableResult public func createFile(atPath filePath: String, content: String) throws -> String { + @discardableResult func createFile(atPath filePath: String, content: String) throws -> String { let fullPath = path(for: filePath) if fileManager.createFile(atPath: fullPath, contents: content.data(using: .utf8)) { return fullPath @@ -53,14 +53,15 @@ extension CommandEnvironment { throw AmplifyCommandError(.unknown, error: nil) } - public func contentsOfDirectory(atPath directoryPath: String) throws -> [String] { + func contentsOfDirectory(atPath directoryPath: String) throws -> [String] { let fullPath = path(for: directoryPath) guard fileManager.directoryExists(atPath: fullPath) else { throw AmplifyCommandError( .folderNotFound, errorDescription: "Folder \(fullPath) not found", recoverySuggestion: nil, - error: nil) + error: nil + ) } do { let content = try fileManager.contentsOfDirectory(atPath: fullPath) @@ -70,17 +71,17 @@ extension CommandEnvironment { } } - public func directoryExists(atPath dirPath: String) -> Bool { + func directoryExists(atPath dirPath: String) -> Bool { fileManager.directoryExists(atPath: path(for: dirPath)) } - public func fileExists(atPath filePath: String) -> Bool { + func fileExists(atPath filePath: String) -> Bool { fileManager.fileExists(atPath: path(for: filePath)) } } // MARK: - AmplifyCommandEnvironmentXcode -extension CommandEnvironment { +public extension CommandEnvironment { private func loadFirstXcodeProject(fromDirectory path: String) throws -> XcodeProject { let xcodeProjFiles = try contentsOfDirectory(atPath: path).filter { $0.hasSuffix("xcodeproj") @@ -91,31 +92,35 @@ extension CommandEnvironment { .xcodeProject, errorDescription: "Unable to find an Xcode project (i.e. `xcodeproj` file) in directory: \(path)", recoverySuggestion: "Please create a new Xcode project or import one at \(path).", - error: XcodeProjectError.notFound(path: path)) + error: XcodeProjectError.notFound(path: path) + ) } let projectName = xcodeProjFiles[0] return try XcodeProject(at: path, projPath: self.path(for: projectName)) } - public func createXcodeFile(withPath path: String, ofType type: XcodeProjectFileType) -> XcodeProjectFile { + func createXcodeFile(withPath path: String, ofType type: XcodeProjectFileType) -> XcodeProjectFile { return XcodeProjectFile(path, type: type) } - public func addFilesToXcodeProject( + func addFilesToXcodeProject( projectPath path: String, files: [XcodeProjectFile], toGroup group: String, - inTarget target: XcodeProjectTarget) throws { + inTarget target: XcodeProjectTarget + ) throws { do { let xcodeProject = try loadFirstXcodeProject(fromDirectory: path) try xcodeProject.add(files: files, toGroup: group, inTarget: target) try xcodeProject.synchronize() } catch { if case let XcodeProjectError.targetNotFound(name: targetName) = error { - throw AmplifyCommandError(.xcodeProject, - errorDescription: "Target \(targetName) not found", - recoverySuggestion: "Manually add Amplify files to your Xcode project.") + throw AmplifyCommandError( + .xcodeProject, + errorDescription: "Target \(targetName) not found", + recoverySuggestion: "Manually add Amplify files to your Xcode project." + ) } throw AmplifyCommandError(.xcodeProject, error: error) } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+AmplifyFileManager.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+AmplifyFileManager.swift index b1255dc31c..10fd6ca33f 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+AmplifyFileManager.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+AmplifyFileManager.swift @@ -18,6 +18,6 @@ extension FileManager: AmplifyFileManager { } public func glob(pattern: String) -> [String] { - Path.glob(pattern).map { $0.string } + Path.glob(pattern).map(\.string) } } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+Utils.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+Utils.swift index 186479c316..80eb115e94 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+Utils.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/FileManager+Utils.swift @@ -7,17 +7,19 @@ import Foundation -extension FileManager { - public func directoryExists(atPath path: String) -> Bool { +public extension FileManager { + func directoryExists(atPath path: String) -> Bool { var isDirectory = ObjCBool(false) let exists = fileExists(atPath: path, isDirectory: &isDirectory) return exists && isDirectory.boolValue } - public func resolveHomeDirectoryIn(path: String) -> String { + func resolveHomeDirectoryIn(path: String) -> String { if let first = path.first, first == "~" { - return path.replacingCharacters(in: ...path.startIndex, - with: FileManager.default.homeDirectoryForCurrentUser.path) + return path.replacingCharacters( + in: ...path.startIndex, + with: FileManager.default.homeDirectoryForCurrentUser.path + ) } return path } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProj+Helpers.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProj+Helpers.swift index 45eb446f43..c88cce8423 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProj+Helpers.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProj+Helpers.swift @@ -16,7 +16,7 @@ extension XcodeProj { } func getOrCreateGroup(named group: String, in rootGroup: PBXGroup?) throws -> PBXGroup? { - guard let rootGroup = rootGroup else { + guard let rootGroup else { return nil } if let existingGroup = rootGroup.group(named: group) { @@ -38,8 +38,10 @@ extension XcodeProj { // MARK: Add files to project extension XcodeProj { - func targets(named targetName: String, - ofType productType: PBXProductType) -> [PBXTarget] { + func targets( + named targetName: String, + ofType productType: PBXProductType + ) -> [PBXTarget] { pbxproj.targets(named: targetName).filter { $0.productType == productType } } diff --git a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProject.swift b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProject.swift index 403ce30a83..9e3b85a36d 100644 --- a/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProject.swift +++ b/AmplifyTools/AmplifyXcode/Sources/AmplifyXcodeCore/Support/XcodeProject.swift @@ -64,12 +64,11 @@ struct XcodeProject { } private func resolveTarget(_ target: XcodeProjectTarget) throws -> PBXTarget { - let targetName: String - switch target { + let targetName: String = switch target { case .primary: - targetName = project.mainProject()?.name ?? "primary" + project.mainProject()?.name ?? "primary" case .named(let name): - targetName = name + name } if let targetRef = project.targets(named: targetName, ofType: .application).first { @@ -82,9 +81,11 @@ struct XcodeProject { // MARK: Add files extension XcodeProject { - func add(files: [XcodeProjectFile], - toGroup group: String, - inTarget target: XcodeProjectTarget) throws { + func add( + files: [XcodeProjectFile], + toGroup group: String, + inTarget target: XcodeProjectTarget + ) throws { guard let mainProject = project.mainProject() else { throw XcodeProjectError.noPbxProjFound } diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Commands/CommandImportModelsTasksTests.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Commands/CommandImportModelsTasksTests.swift index 7aa3e807fc..e9705ed45d 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Commands/CommandImportModelsTasksTests.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Commands/CommandImportModelsTasksTests.swift @@ -32,22 +32,24 @@ class CommandImportModelsTasksTests: XCTestCase { class CustomEnvironment: MockAmplifyCommandEnvironment { override func glob(pattern: String) -> [String] { [ - "Todo.swift", - "Note.swift" - ] + "Todo.swift", + "Note.swift" + ] } } let environment = CustomEnvironment(basePath: basePath, fileManager: fileManager) if case let .failure(error) = CommandImportModelsTasks.projectHasGeneratedModels( environment: environment, - args: taskArgs) { + args: taskArgs + ) { XCTFail("projectHasGeneratedModels failed with error \(error)") } if case let .failure(error) = CommandImportModelsTasks.addGeneratedModelsToProject( environment: environment, - args: taskArgs) { + args: taskArgs + ) { XCTFail("addGeneratedModelsToProject failed with error \(error)") } XCTAssertEqual(environment.createXcodeFileCalledTimes, 2) // one call for each model file found diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandEnvironmentTests.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandEnvironmentTests.swift index 859b24f313..803776669b 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandEnvironmentTests.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandEnvironmentTests.swift @@ -149,9 +149,11 @@ class AmplifyCommandEnvironmentTests: XCTestCase { } let environment = CommandEnvironment(basePath: basePath, fileManager: DirNotFoundFileManager()) let file = environment.createXcodeFile(withPath: "File.swift", ofType: .source) - XCTAssertThrowsError(try environment.addFilesToXcodeProject(projectPath: "project", - files: [file], - toGroup: "group", - inTarget: .primary)) + XCTAssertThrowsError(try environment.addFilesToXcodeProject( + projectPath: "project", + files: [file], + toGroup: "group", + inTarget: .primary + )) } } diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandErrorTests.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandErrorTests.swift index 68accff3a3..97179946a2 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandErrorTests.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Core/AmplifyCommandErrorTests.swift @@ -28,10 +28,11 @@ class AmplifyCommandErrorTests: XCTestCase { let recoveryMessage = "Recovery message" let tasksResults: [AmplifyCommandTaskResult] = [ .failure(AmplifyCommandError( - .folderNotFound, - errorDescription: errorDescription, - recoverySuggestion: recoveryMessage, - error: error)), + .folderNotFound, + errorDescription: errorDescription, + recoverySuggestion: recoveryMessage, + error: error + )), .success("Task 1 success message"), .success("Task 2 success message") ] diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyCommandEnvironment.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyCommandEnvironment.swift index a21bb33011..25bee3364b 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyCommandEnvironment.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyCommandEnvironment.swift @@ -66,10 +66,12 @@ class MockAmplifyCommandEnvironment: Mock, AmplifyCommandEnvironment { return XcodeProjectFile(path, type: type) } - func addFilesToXcodeProject(projectPath path: String, - files: [XcodeProjectFile], - toGroup group: String, - inTarget: XcodeProjectTarget) throws { + func addFilesToXcodeProject( + projectPath path: String, + files: [XcodeProjectFile], + toGroup group: String, + inTarget: XcodeProjectTarget + ) throws { captureCall("addFilesToXcodeProject") } } diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyFileManager.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyFileManager.swift index 316b0f747d..693762d1dd 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyFileManager.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeCoreTests/Mocks/MockAmplifyFileManager.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import Foundation import AmplifyXcodeCore +import Foundation class MockAmplifyFileManager: Mock, AmplifyFileManager { func fileExists(atPath filePath: String) -> Bool { diff --git a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeTests/AmplifyXcodeTests.swift b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeTests/AmplifyXcodeTests.swift index 159046c224..94924a98a9 100644 --- a/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeTests/AmplifyXcodeTests.swift +++ b/AmplifyTools/AmplifyXcode/Tests/AmplifyXcodeTests/AmplifyXcodeTests.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import XCTest import class Foundation.Bundle +import XCTest final class AmplifyXcodeTests: XCTestCase { func testExecutable() throws { diff --git a/canaries/example/MyAmplifyApp/MyAmplifyAppApp.swift b/canaries/example/MyAmplifyApp/MyAmplifyAppApp.swift index 68eddea3b8..9b60c116a6 100644 --- a/canaries/example/MyAmplifyApp/MyAmplifyAppApp.swift +++ b/canaries/example/MyAmplifyApp/MyAmplifyAppApp.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import SwiftUI import Amplify +import SwiftUI @main