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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions .github/workflows/integ_test_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ jobs:
secrets: inherit

graphql-user-pool-test:
if: ${{ false }}
name: GraphQL | User Pool Tests
uses: ./.github/workflows/integ_test_api_graphql_user_pool.yml
secrets: inherit

graphql-auth-directive-test:
if: ${{ false }}
name: GraphQL | Auth Directive Tests
uses: ./.github/workflows/integ_test_api_graphql_auth_directive.yml
secrets: inherit

graphql-iam-test:
if: ${{ false }}
name: GraphQL | IAM Tests
uses: ./.github/workflows/integ_test_api_graphql_iam.yml
secrets: inherit
Expand All @@ -48,7 +45,6 @@ jobs:
secrets: inherit

rest-user-pool-test:
if: ${{ false }}
name: REST | User Pool Tests
uses: ./.github/workflows/integ_test_api_rest_user_pool.yml
secrets: inherit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ jobs:
exclude:
- platform: ${{ github.event.inputs.ios == 'false' && 'iOS' || 'None' }}
- platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }}
- platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }}
uses: ./.github/workflows/run_integration_tests.yml
with:
scheme: AWSAPIPluginGraphQLAuthDirectiveTests
scheme: ${{ matrix.platform == 'watchOS' && 'AWSAPIPluginGraphQLAuthDirectiveTestsWatch' || 'AWSAPIPluginGraphQLAuthDirectiveTests' }}
platform: ${{ matrix.platform }}
project_path: ./AmplifyPlugins/API/Tests/APIHostApp
resource_subfolder: api
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integ_test_api_graphql_iam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ jobs:
exclude:
- platform: ${{ github.event.inputs.ios == 'false' && 'iOS' || 'None' }}
- platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }}
- platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }}
uses: ./.github/workflows/run_integration_tests.yml
with:
scheme: AWSAPIPluginGraphQLIAMTests
scheme: ${{ matrix.platform == 'watchOS' && 'AWSAPIPluginGraphQLIAMTestsWatch' || 'AWSAPIPluginGraphQLIAMTests' }}
platform: ${{ matrix.platform }}
project_path: ./AmplifyPlugins/API/Tests/APIHostApp
resource_subfolder: api
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integ_test_api_rest_user_pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ jobs:
exclude:
- platform: ${{ github.event.inputs.ios == 'false' && 'iOS' || 'None' }}
- platform: ${{ github.event.inputs.tvos == 'false' && 'tvOS' || 'None' }}
- platform: ${{ github.event.inputs.watchos == 'false' && 'watchOS' || 'None' }}
uses: ./.github/workflows/run_integration_tests.yml
with:
scheme: AWSAPIPluginRESTUserPoolTests
scheme: ${{ matrix.platform == 'watchOS' && 'AWSAPIPluginRESTUserPoolTestsWatch' || 'AWSAPIPluginRESTUserPoolTests' }}
platform: ${{ matrix.platform }}
project_path: ./AmplifyPlugins/API/Tests/APIHostApp
resource_subfolder: api
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/issue_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

adjust-labels:
runs-on: ubuntu-latest
if: ${{ github.event.issue.state == 'open' }}
if: ${{ github.event.issue.state == 'open' && !github.event.issue.pull_request }}
permissions:
issues: write
env:
Expand All @@ -30,7 +30,7 @@ jobs:
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
steps:
- name: remove pending-community-response when new comment received
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && !github.event.issue.pull_request }}
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-community-response"
Expand Down
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
13 changes: 9 additions & 4 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@
--enable void
--empty void

--disable wrapArguments
--closingparen same-line
--wraparguments after-first
--enable wrapArguments
--closingparen balanced
--wraparguments before-first
--wrapcollections before-first
--wrapconditions preserve

# standalone rules
--disable preferKeyPath
--disable conditionalAssignment
--disable wrapMultilineConditionalAssignment
--disable wrapMultilineStatementBraces
--disable andOperator
--disable anyObjectProtocol
--disable blankLinesAroundMark
Expand Down Expand Up @@ -114,4 +119,4 @@
--enable strongifiedSelf
--disable todos
--enable typeSugar
--enable yodaConditions
--enable yodaConditions
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
BlueprintName = "AWSCloudWatchLoggingPluginTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "AWSCloudWatchLoggingMonitorTests/testDelegateIsInvokedOnInterval()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
BlueprintName = "AWSS3StoragePluginTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "DefaultStorageTransferDatabaseTests/testLoadPersistableTasks()">
</Test>
<Test
Identifier = "DefaultStorageTransferDatabaseTests/testPrepareForBackground()">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
29 changes: 17 additions & 12 deletions Amplify/Amplify.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,63 +37,63 @@ public class Amplify: @unchecked Sendable {

/// - Tag: Amplify.Analytics
private static let analyticsAtomic = AtomicValue<AnalyticsCategory>(initialValue: AnalyticsCategory())
public static internal(set) var Analytics: AnalyticsCategory {
public internal(set) static var Analytics: AnalyticsCategory {
get { analyticsAtomic.get() }
set { analyticsAtomic.set(newValue) }
}

/// - Tag: Amplify.API
private static let apiAtomic = AtomicValue<APICategory>(initialValue: APICategory())
public static internal(set) var API: APICategory {
public internal(set) static var API: APICategory {
get { apiAtomic.get() }
set { apiAtomic.set(newValue) }
}

/// - Tag: Amplify.Auth
private static let authAtomic = AtomicValue<AuthCategory>(initialValue: AuthCategory())
public static internal(set) var Auth: AuthCategory {
public internal(set) static var Auth: AuthCategory {
get { authAtomic.get() }
set { authAtomic.set(newValue) }
}

/// - Tag: Amplify.DataStore
private static let dataStoreAtomic = AtomicValue<DataStoreCategory>(initialValue: DataStoreCategory())
public static internal(set) var DataStore: DataStoreCategory {
public internal(set) static var DataStore: DataStoreCategory {
get { dataStoreAtomic.get() }
set { dataStoreAtomic.set(newValue) }
}

/// - Tag: Amplify.Geo
private static let geoAtomic = AtomicValue<GeoCategory>(initialValue: GeoCategory())
public static internal(set) var Geo: GeoCategory {
public internal(set) static var Geo: GeoCategory {
get { geoAtomic.get() }
set { geoAtomic.set(newValue) }
}

/// - Tag: Amplify.Hub
private static let hubAtomic = AtomicValue<HubCategory>(initialValue: HubCategory())
public static internal(set) var Hub: HubCategory {
public internal(set) static var Hub: HubCategory {
get { hubAtomic.get() }
set { hubAtomic.set(newValue) }
}

/// - Tag: Amplify.Notifications
private static let notificationsAtomic = AtomicValue<NotificationsCategory>(initialValue: NotificationsCategory())
public static internal(set) var Notifications: NotificationsCategory {
public internal(set) static var Notifications: NotificationsCategory {
get { notificationsAtomic.get() }
set { notificationsAtomic.set(newValue) }
}

/// - Tag: Amplify.Predictions
private static let predictionsAtomic = AtomicValue<PredictionsCategory>(initialValue: PredictionsCategory())
public static internal(set) var Predictions: PredictionsCategory {
public internal(set) static var Predictions: PredictionsCategory {
get { predictionsAtomic.get() }
set { predictionsAtomic.set(newValue) }
}

/// - Tag: Amplify.Storage
private static let storageAtomic = AtomicValue<StorageCategory>(initialValue: StorageCategory())
public static internal(set) var Storage: StorageCategory {
public internal(set) static var Storage: StorageCategory {
get { storageAtomic.get() }
set { storageAtomic.set(newValue) }
}
Expand All @@ -102,7 +102,7 @@ public class Amplify: @unchecked Sendable {
/// methods during setup & teardown of tests
///
/// - Tag: Amplify.Logging
public static internal(set) var Logging: LoggingCategory {
public internal(set) static var Logging: LoggingCategory {
get {
loggingAtomic.get()
}
Expand All @@ -112,13 +112,15 @@ public class Amplify: @unchecked Sendable {
}
private static let loggingAtomic = AtomicValue<LoggingCategory>(initialValue: LoggingCategory())

// swiftlint:disable cyclomatic_complexity

/// Adds `plugin` to the category
///
/// See: [Category.removePlugin(for:)](x-source-tag://Category.removePlugin)
///
/// - Parameter plugin: The plugin to add
/// - Tag: Amplify.add_plugin
public static func add<P: Plugin>(plugin: P) throws {
public static func add(plugin: some Plugin) throws {
log.debug("Adding plugin: \(plugin))")
switch plugin {
case let plugin as AnalyticsCategoryPlugin:
Expand All @@ -144,8 +146,11 @@ public class Amplify: @unchecked Sendable {
default:
throw PluginError.pluginConfigurationError(
"Plugin category does not exist.",
"Verify that the library version is correct and supports the plugin's category.")
"Verify that the library version is correct and supports the plugin's category."
)
}

// swiftlint:enable cyclomatic_complexity
}
}

Expand Down
14 changes: 9 additions & 5 deletions Amplify/Categories/API/APICategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

/// The API category provides a solution for making HTTP requests to REST and GraphQL endpoints.
final public class APICategory: Category {
public final class APICategory: Category {
/// The category type for API
public var categoryType: CategoryType {
.api
Expand Down Expand Up @@ -57,8 +57,10 @@ final public class APICategory: Category {
let key = plugin.key
guard !key.isEmpty else {
let pluginDescription = String(describing: plugin)
let error = APIError.invalidConfiguration("Plugin \(pluginDescription) has an empty `key`.",
"Set the `key` property for \(String(describing: plugin))")
let error = APIError.invalidConfiguration(
"Plugin \(pluginDescription) has an empty `key`.",
"Set the `key` property for \(String(describing: plugin))"
)
throw error
}

Expand All @@ -81,8 +83,10 @@ final public class APICategory: Category {
public func getPlugin(for key: PluginKey) throws -> APICategoryPlugin {
guard let plugin = plugins[key] else {
let keys = plugins.keys.joined(separator: ", ")
let error = APIError.invalidConfiguration("No plugin has been added for '\(key)'.",
"Either add a plugin for '\(key)', or use one of the known keys: \(keys)")
let error = APIError.invalidConfiguration(
"No plugin has been added for '\(key)'.",
"Either add a plugin for '\(key)', or use one of the known keys: \(keys)"
)
throw error
}
return plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

extension APICategory: APICategoryReachabilityBehavior {
#if !os(watchOS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

/// Behavior of the API category that clients will use
public typealias APICategoryBehavior =
APICategoryRESTBehavior &
APICategoryAuthProviderFactoryBehavior &
APICategoryGraphQLBehavior &
APICategoryInterceptorBehavior &
APICategoryReachabilityBehavior &
APICategoryAuthProviderFactoryBehavior
APICategoryRESTBehavior &
APICategoryReachabilityBehavior
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public protocol APICategoryGraphQLBehavior: AnyObject {
/// - request: The GraphQL request containing apiName, document, variables, and responseType
/// - valueListener: Invoked when the GraphQL subscription receives a new value from the service
/// - completionListener: Invoked when the subscription has terminated
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
/// - Returns: The AmplifyInProcessReportingOperation being enqueued
func subscribe<R: Decodable>(
request: GraphQLRequest<R>
) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

/// API Reachability Behavior
public protocol APICategoryReachabilityBehavior {
Expand Down
1 change: 1 addition & 0 deletions Amplify/Categories/API/Error/APIError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extension APIError: AmplifyError {
For more information on HTTP status codes, take a look at
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
"""

case .pluginError(let error):
return error.recoverySuggestion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//

#if canImport(Combine)
import Foundation
import Combine
import Foundation

// MARK: - GraphQLSubscriptionOperation

Expand Down
Loading
Loading