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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/swiftformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: SwiftFormat
on:
workflow_dispatch:
workflow_call:
inputs:
identifier:
required: true
type: string

push:
branches-ignore:
- main
- v1
- release
- release-v1

permissions:
contents: read

concurrency:
group: ${{ inputs.identifier || github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref_name != 'main'}}

jobs:
run-swiftformat:
runs-on: macos-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 #v3.5.3
with:
persist-credentials: false

- name: SwiftFormat
run: |
swiftformat --lint . --reporter github-actions-log --swiftversion 5.9

confirm-pass:
runs-on: macos-latest
name: Confirm Passing SwiftFormat
if: ${{ !cancelled() }}
needs: [ run-swiftformat ]
env:
EXIT_CODE: ${{ contains(needs.*.result, 'failure') && 1 || 0 }}
steps:
- run: exit $EXIT_CODE
14 changes: 7 additions & 7 deletions Amplify/Categories/DataStore/DataStoreCategoryBehavior.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public protocol DataStoreBaseBehavior {
paginate paginationInput: QueryPaginationInput?
) async throws -> [M]

func delete<M: Model>(
_ model: M,
func delete(
_ model: some Model,
where predicate: QueryPredicate?
) async throws

func delete<M: Model>(
_ modelType: M.Type,
func delete(
_ modelType: (some Model).Type,
withId id: String,
where predicate: QueryPredicate?
) async throws
Expand All @@ -66,8 +66,8 @@ public protocol DataStoreBaseBehavior {
where predicate: QueryPredicate?
) async throws where M: ModelIdentifiable

func delete<M: Model>(
_ modelType: M.Type,
func delete(
_ modelType: (some Model).Type,
where predicate: QueryPredicate
) async throws

Expand Down Expand Up @@ -100,7 +100,7 @@ public protocol DataStoreBaseBehavior {
public protocol DataStoreSubscribeBehavior {
/// Returns an AmplifyAsyncThrowingSequence for model changes (create, updates, delete)
/// - Parameter modelType: The model type to observe
func observe<M: Model>(_ modelType: M.Type) -> AmplifyAsyncThrowingSequence<MutationEvent>
func observe(_ modelType: (some Model).Type) -> AmplifyAsyncThrowingSequence<MutationEvent>

/// Returns a Publisher for query snapshots.
///
Expand Down
4 changes: 2 additions & 2 deletions Amplify/Categories/DataStore/Subscribe/MutationEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public struct MutationEvent: Model {
Initializing from a model without a ModelSchema is deprecated.
Use init(model:modelSchema:mutationType:version:graphQLFilterJSON:) instead.
""")
public init<M: Model>(
model: M,
public init(
model: some Model,
mutationType: MutationType,
version: Int? = nil,
graphQLFilterJSON: String? = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public protocol PredictionsCategoryBehavior {
/// - request:
/// - options:
/// - Returns:
func convert<Input, Options, Output>(
_ request: Predictions.Convert.Request<Input, Options, Output>,
func convert<Options, Output>(
_ request: Predictions.Convert.Request<some Any, Options, Output>,
options: Options?
) async throws -> Output

Expand Down
2 changes: 1 addition & 1 deletion Amplify/Core/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public typealias PluginKey = String
/// to store heterogenous collections of Plugins in a category.
/// - Throws: PluginError.mismatchedPlugin if the instance is associated with the wrong category
public protocol PluginInitializable {
init<P: Plugin>(instance: P)
init(instance: some Plugin)
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public extension XCTestCase {
///
/// - Returns:The error thrown during the execution of `action`, or `nil` if it run successfully.
@discardableResult
internal func waitError<T>(
internal func waitError(
with expectation: AsyncExpectation,
timeout: TimeInterval = defaultNetworkTimeoutForAsyncExpectations,
action: @escaping () async throws -> T
action: @escaping () async throws -> some Any
) async -> Error? {
let task = Task { () -> Error? in
defer {
Expand Down Expand Up @@ -186,10 +186,10 @@ public extension XCTestCase {
///
/// - Returns:The error thrown during the execution of `action`, or `nil` if it run successfully.
@discardableResult
internal func waitError<T>(
internal func waitError(
name: String,
timeout: TimeInterval = defaultNetworkTimeoutForAsyncExpectations,
action: @escaping () async throws -> T
action: @escaping () async throws -> some Any
) async -> Error? {
let expectation = asyncExpectation(description: name)
return await waitError(with: expectation, timeout: timeout, action: action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ actor AppSyncRealTimeClient: AppSyncRealTimeClientProtocol {
// promptly returning the filtered publisher for downstream consumption of all error messages.
defer {
let task = Task { [weak self] in
guard let self = self else { return }
if !(await self.isConnected) {
guard let self else { return }
if await !(self.isConnected) {
try await connect()
try await waitForState(.connected)
}
try await self.storeInConnectionCancellables(await self.startSubscription(id))
try await self.storeInConnectionCancellables(self.startSubscription(id))
}
self.storeInConnectionCancellables(task.toAnyCancellable)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ extension GraphQLModelBasedTests {
func list<M: Model>(_ request: GraphQLRequest<List<M>>) async throws -> [M] {
func getAllPages(_ list: List<M>) async throws -> [M] {
if list.hasNextPage() {
return try list.elements + (await getAllPages(list.getNextPage()))
return try await list.elements + getAllPages(list.getNextPage())
} else {
return list.elements
}
}

return try await getAllPages(await Amplify.API.query(request: request).get())
return try await getAllPages(Amplify.API.query(request: request).get())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AppSyncRealTimeRequestAuthTests: XCTestCase {
}

private func areDictionariesEqual(_ lhs: [String: Any]?, _ rhs: [String: Any]?) -> Bool {
guard let lhs = lhs, let rhs = rhs else { return false }
guard let lhs, let rhs else { return false }
return NSDictionary(dictionary: lhs).isEqual(to: rhs)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ struct ASFDeviceInfo: ASFDeviceBehavior {
}

func deviceInfo() async -> String {
let model = await self.model
let type = await self.type
let version = await self.version
let model = await model
let type = await type
let version = await version
var build = "release"
#if DEBUG
build = "debug"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ struct CognitoUserPoolASF: AdvancedSecurityBehavior {
build = "debug"
#endif
let fingerPrint = await deviceInfo.deviceInfo()
var contextData: [String: String] = [
var contextData: [String: String] = await [
Self.targetSDKKey: appInfo.targetSDK,
Self.appVersionKey: appInfo.version,
Self.deviceNameKey: await deviceInfo.name,
Self.phoneTypeKey: await deviceInfo.type,
Self.deviceNameKey: deviceInfo.name,
Self.phoneTypeKey: deviceInfo.type,
Self.deviceIdKey: deviceInfo.id,
Self.releaseVersionKey: await deviceInfo.version,
Self.platformKey: await deviceInfo.platform,
Self.releaseVersionKey: deviceInfo.version,
Self.platformKey: deviceInfo.platform,
Self.buildTypeKey: build,
Self.timezoneKey: timeZoneOffet(),
Self.deviceHeightKey: await deviceInfo.height,
Self.deviceWidthKey: await deviceInfo.width,
Self.deviceLanguageKey: await deviceInfo.locale,
Self.deviceHeightKey: deviceInfo.height,
Self.deviceWidthKey: deviceInfo.width,
Self.deviceLanguageKey: deviceInfo.locale,
Self.deviceFingerPrintKey: fingerPrint
]
if let appName = appInfo.name {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extension AWSCognitoAuthPlugin {
endpointResolver: userPoolConfig.endpoint?.resolver
)

if var httpClientEngineProxy = httpClientEngineProxy {
if var httpClientEngineProxy {
httpClientEngineProxy.target = baseClientEngine(for: configuration)
configuration.httpClientEngine = UserAgentSettingClientEngine(
target: httpClientEngineProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ struct VerifySignInChallenge: Action {
message: "This code path only supports password and password SRP. Received: \(challenge.challenge)")
}

guard let challengeType = challengeType else {
guard let challengeType else {
throw SignInError.unknown(
message: "Unable to determine challenge type from \(String(describing: authFactorType))")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension RefreshSessionState {

var defaultState: RefreshSessionState = .notStarted

// swiftlint:disable:next cyclomatic_complexity
// swiftlint:disable:next cyclomatic_complexity function_body_length
func resolve(
oldState: RefreshSessionState,
byApplying event: StateMachineEvent
Expand Down
Loading
Loading